mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Merge remote-tracking branch 'origin/master' into xtr/agent-loop-message-machine
# Conflicts: # docs/cordis-catalog/services.md # docs/core-data-structures/session.i18n.yaml # docs/event-producer-consumer.md # examples/acp-agent/tests/snapshots/cordis-inspect-jsdoc/session.jsonl
This commit is contained in:
File diff suppressed because one or more lines are too long
43
examples/headless-agent/tests/fixtures/telemetry-otel-driver.ts
vendored
Normal file
43
examples/headless-agent/tests/fixtures/telemetry-otel-driver.ts
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Test driver: start a mock OTLP/HTTP collector, boot the telemetry Loader
|
||||
* composition against it, run one turn whose prompt carries a fixture
|
||||
* credential, then persist everything the collector captured to
|
||||
* `./otlp-captures.json` for the e2e's inspect step.
|
||||
*/
|
||||
|
||||
import { writeFile } from 'node:fs/promises'
|
||||
import { createServer } from 'node:http'
|
||||
import { once } from 'node:events'
|
||||
import { boot, resolveConfigPath } from '@deepseek-ai/dsh-app-boot'
|
||||
import { runOneShot } from '@deepseek-ai/dsh-cli-demo/src/cli.ts'
|
||||
|
||||
const configPath = process.argv[2]
|
||||
if (configPath === undefined) throw new Error('telemetry-otel driver requires a config path')
|
||||
|
||||
const captures: unknown[] = []
|
||||
const server = createServer((request, response) => {
|
||||
const chunks: Buffer[] = []
|
||||
request.on('data', chunk => chunks.push(chunk as Buffer))
|
||||
request.on('end', () => {
|
||||
captures.push(JSON.parse(Buffer.concat(chunks).toString()))
|
||||
response.writeHead(200, { 'content-type': 'application/json' }).end('{}')
|
||||
})
|
||||
})
|
||||
server.listen(0, '127.0.0.1')
|
||||
await once(server, 'listening')
|
||||
const address = server.address()
|
||||
if (address === null || typeof address === 'string') throw new Error('collector has no port')
|
||||
process.env.DSH_TELEMETRY_E2E_URL = `http://127.0.0.1:${address.port}/v1/logs`
|
||||
|
||||
const ctx = await boot('telemetry-otel-e2e', resolveConfigPath(configPath, undefined))
|
||||
try {
|
||||
// The fixture credential rides the model-visible user message; the exported
|
||||
// copy must scrub it while the canonical log keeps the original bytes.
|
||||
await runOneShot(ctx, { task: 'prove telemetry with key sk-e2efixture1234567890' })
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
}
|
||||
await writeFile('./otlp-captures.json', JSON.stringify(captures))
|
||||
server.close()
|
||||
server.closeAllConnections()
|
||||
28
examples/headless-agent/tests/fixtures/telemetry-otel.cordis.yml
vendored
Normal file
28
examples/headless-agent/tests/fixtures/telemetry-otel.cordis.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Test-only composition: session-telemetry-otel through the real Loader/app
|
||||
# path, exporting to the mock OTLP collector the driver starts (url via env).
|
||||
# The redact-rule entry models a deployment mounting its own scrub rule on the
|
||||
# telemetry/record waterfall — the seam itself ships no rules.
|
||||
- id: cli-mock-llm
|
||||
name: './cli-mock-llm.ts'
|
||||
|
||||
- id: telemetry-redact-rule
|
||||
name: './telemetry-redact-rule.ts'
|
||||
|
||||
- id: bash
|
||||
name: '@deepseek-ai/dsh-bash-local'
|
||||
|
||||
- id: telemetry-otel
|
||||
name: '@deepseek-ai/dsh-session-telemetry-otel'
|
||||
config:
|
||||
exporter:
|
||||
url: !!js process.env.DSH_TELEMETRY_E2E_URL
|
||||
|
||||
- id: cli-agent
|
||||
name: '@deepseek-ai/dsh-cli-demo'
|
||||
config:
|
||||
provider: cli-mock
|
||||
model: cli-mock
|
||||
persona: 'Test the session-telemetry-otel plugin.'
|
||||
persistenceRoot: './.sessions'
|
||||
persistenceCompression: 'none'
|
||||
workspaceContext: false
|
||||
29
examples/headless-agent/tests/fixtures/telemetry-redact-rule.ts
vendored
Normal file
29
examples/headless-agent/tests/fixtures/telemetry-redact-rule.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { Context } from 'cordis'
|
||||
|
||||
/**
|
||||
* Deployment-style redaction rule for the telemetry e2e: scrubs the fixture
|
||||
* credential from body strings, exactly as a real deployment would mount its
|
||||
* own rules on the `telemetry/record` waterfall.
|
||||
*/
|
||||
|
||||
const SECRET = /sk-e2efixture[0-9]+/g
|
||||
const PLACEHOLDER = '[E2E-REDACTED]'
|
||||
|
||||
function scrub(value: unknown): unknown {
|
||||
if (typeof value === 'string') return value.replace(SECRET, PLACEHOLDER)
|
||||
if (Array.isArray(value)) return value.map(scrub)
|
||||
if (value !== null && typeof value === 'object') {
|
||||
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, scrub(entry)]))
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
export const name = 'telemetry-redact-rule'
|
||||
|
||||
/** Mount the fixture scrub rule onto the redact waterfall. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.on('telemetry/record', (_record, next) => {
|
||||
const record = next()
|
||||
return { ...record, body: scrub(record.body) }
|
||||
})
|
||||
}
|
||||
@@ -42,6 +42,7 @@
|
||||
"@deepseek-ai/dsh-session-checkpoint-policy": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-query": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-query-sqlite": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-telemetry-otel": "workspace:*",
|
||||
"@deepseek-ai/dsh-spill-local": "workspace:*",
|
||||
"@deepseek-ai/dsh-spill-policy": "workspace:*",
|
||||
"@deepseek-ai/dsh-tui-demo": "workspace:*",
|
||||
|
||||
Reference in New Issue
Block a user