dsh-plugin-dev-kb 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/cordis.patch.yml +12 -0
- package/kb/INDEX.md +210 -0
- package/kb/README.md +69 -0
- package/kb/extra/AGENTS.md +75 -0
- package/kb/extra/api-gateway.md +164 -0
- package/kb/extra/api-gateway.zh.md +164 -0
- package/kb/extra/cookbook/adding-a-vendored-package.md +59 -0
- package/kb/extra/cookbook/adding-a-vendored-package.zh.md +59 -0
- package/kb/extra/cookbook/maintaining-dsh-code-review.md +64 -0
- package/kb/extra/cookbook/maintaining-dsh-code-review.zh.md +64 -0
- package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
- package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
- package/kb/extra/defensive-patterns.md +33 -0
- package/kb/extra/defensive-patterns.zh.md +33 -0
- package/kb/extra/development.md +171 -0
- package/kb/extra/development.zh.md +171 -0
- package/kb/extra/event-producer-consumer.md +76 -0
- package/kb/extra/event-producer-consumer.zh.md +78 -0
- package/kb/extra/glossary.md +45 -0
- package/kb/extra/glossary.zh.md +45 -0
- package/kb/extra/graph-atlas.md +24 -0
- package/kb/extra/graph-atlas.zh.md +26 -0
- package/kb/extra/i18n/README.md +60 -0
- package/kb/extra/i18n/README.zh.md +60 -0
- package/kb/extra/i18n/style-samples.md +87 -0
- package/kb/extra/i18n/terminology.md +214 -0
- package/kb/extra/i18n/translation-prompt.md +263 -0
- package/kb/extra/i18n/translation-rules.md +69 -0
- package/kb/extra/i18n/translation-rules.zh.md +69 -0
- package/kb/extra/module-graph.md +1641 -0
- package/kb/extra/module-graph.zh.md +1643 -0
- package/kb/extra/postmortem/0001-acp-default-export-drops-inject.md +113 -0
- package/kb/extra/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
- package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
- package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
- package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
- package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
- package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
- package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
- package/kb/extra/postmortem/README.md +18 -0
- package/kb/extra/postmortem/README.zh.md +18 -0
- package/kb/extra/rescope.md +53 -0
- package/kb/extra/rescope.zh.md +53 -0
- package/kb/extra/subsystems/attachment.md +125 -0
- package/kb/extra/subsystems/attachment.zh.md +125 -0
- package/kb/extra/subsystems/extensions.md +364 -0
- package/kb/extra/subsystems/extensions.zh.md +364 -0
- package/kb/extra/subsystems/feedback.md +266 -0
- package/kb/extra/subsystems/feedback.zh.md +266 -0
- package/kb/extra/testing.md +49 -0
- package/kb/extra/testing.zh.md +49 -0
- package/kb/extra/web-styling.md +25 -0
- package/kb/extra/web-styling.zh.md +25 -0
- package/kb/meta/search-index.json +1328 -0
- package/kb/meta/site-pages.txt +168 -0
- package/kb/meta/source.json +13 -0
- package/kb/meta/topics.md +75 -0
- package/kb/site/develop/basic/config.md +108 -0
- package/kb/site/develop/basic/index.md +146 -0
- package/kb/site/develop/basic/publish.md +185 -0
- package/kb/site/develop/basic/tool.md +54 -0
- package/kb/site/develop/cordis-tutorial/01-first-plugin.md +95 -0
- package/kb/site/develop/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
- package/kb/site/develop/cordis-tutorial/03-services.md +98 -0
- package/kb/site/develop/cordis-tutorial/04-events.md +144 -0
- package/kb/site/develop/cordis-tutorial/05-config.md +84 -0
- package/kb/site/develop/cordis-tutorial/06-composition-and-hmr.md +113 -0
- package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +107 -0
- package/kb/site/develop/cordis-tutorial/index.md +62 -0
- package/kb/site/develop/framework/events.md +145 -0
- package/kb/site/develop/framework/index.md +139 -0
- package/kb/site/develop/framework/service.md +152 -0
- package/kb/site/develop/practice/index.md +157 -0
- package/kb/site/develop/practice/llm-adapter.md +190 -0
- package/kb/site/en/develop/basic/config.md +108 -0
- package/kb/site/en/develop/basic/index.md +146 -0
- package/kb/site/en/develop/basic/publish.md +185 -0
- package/kb/site/en/develop/basic/tool.md +54 -0
- package/kb/site/en/develop/cordis-tutorial/01-first-plugin.md +95 -0
- package/kb/site/en/develop/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
- package/kb/site/en/develop/cordis-tutorial/03-services.md +98 -0
- package/kb/site/en/develop/cordis-tutorial/04-events.md +144 -0
- package/kb/site/en/develop/cordis-tutorial/05-config.md +84 -0
- package/kb/site/en/develop/cordis-tutorial/06-composition-and-hmr.md +113 -0
- package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +107 -0
- package/kb/site/en/develop/cordis-tutorial/index.md +60 -0
- package/kb/site/en/develop/framework/events.md +145 -0
- package/kb/site/en/develop/framework/index.md +139 -0
- package/kb/site/en/develop/framework/service.md +150 -0
- package/kb/site/en/develop/practice/index.md +157 -0
- package/kb/site/en/develop/practice/llm-adapter.md +190 -0
- package/kb/site/en/guide/providers-custom-form.png +0 -0
- package/kb/site/en/guide/providers-models-page.png +0 -0
- package/kb/site/en/guide/providers.md +100 -0
- package/kb/site/en/guide/python-sdk.md +106 -0
- package/kb/site/en/guide/quickstart.md +32 -0
- package/kb/site/en/index.md +8 -0
- package/kb/site/en/reference/agent-lifecycle.md +86 -0
- package/kb/site/en/reference/capability-seams.md +475 -0
- package/kb/site/en/reference/config-catalog.md +3155 -0
- package/kb/site/en/reference/cookbook/adding-a-conversation-node.md +235 -0
- package/kb/site/en/reference/cookbook/adding-a-package.md +120 -0
- package/kb/site/en/reference/cookbook/adding-a-settings-card.md +102 -0
- package/kb/site/en/reference/cookbook/adding-a-tool.md +96 -0
- package/kb/site/en/reference/cookbook/adding-an-llm-adapter.md +45 -0
- package/kb/site/en/reference/cookbook/extension-cookbook.md +131 -0
- package/kb/site/en/reference/cordis-api/context.md +368 -0
- package/kb/site/en/reference/cordis-api/events.md +211 -0
- package/kb/site/en/reference/cordis-api/fiber.md +379 -0
- package/kb/site/en/reference/cordis-api/inherited.md +43 -0
- package/kb/site/en/reference/cordis-api/registry.md +156 -0
- package/kb/site/en/reference/cordis-api/service.md +106 -0
- package/kb/site/en/reference/cordis-primer.md +46 -0
- package/kb/site/en/reference/index.md +131 -0
- package/kb/site/en/reference/persistence-catalog.md +949 -0
- package/kb/site/en/reference/subsystems/approval.md +173 -0
- package/kb/site/en/reference/subsystems/client-modules.md +121 -0
- package/kb/site/en/reference/subsystems/code-runtime.md +194 -0
- package/kb/site/en/reference/subsystems/commands.md +190 -0
- package/kb/site/en/reference/subsystems/compaction.md +241 -0
- package/kb/site/en/reference/subsystems/core.md +1073 -0
- package/kb/site/en/reference/subsystems/credentials.md +136 -0
- package/kb/site/en/reference/subsystems/filesystem.md +498 -0
- package/kb/site/en/reference/subsystems/goal.md +280 -0
- package/kb/site/en/reference/subsystems/index.md +58 -0
- package/kb/site/en/reference/subsystems/invariants.md +91 -0
- package/kb/site/en/reference/subsystems/jobs.md +293 -0
- package/kb/site/en/reference/subsystems/llm-streaming.md +920 -0
- package/kb/site/en/reference/subsystems/lsp.md +205 -0
- package/kb/site/en/reference/subsystems/permission-presets.md +134 -0
- package/kb/site/en/reference/subsystems/persistence.md +388 -0
- package/kb/site/en/reference/subsystems/plan.md +90 -0
- package/kb/site/en/reference/subsystems/sandbox.md +221 -0
- package/kb/site/en/reference/subsystems/schedule.md +189 -0
- package/kb/site/en/reference/subsystems/scope.md +62 -0
- package/kb/site/en/reference/subsystems/session-projection.md +265 -0
- package/kb/site/en/reference/subsystems/session-query.md +498 -0
- package/kb/site/en/reference/subsystems/session-reference.md +111 -0
- package/kb/site/en/reference/subsystems/session-telemetry.md +197 -0
- package/kb/site/en/reference/subsystems/session-title.md +207 -0
- package/kb/site/en/reference/subsystems/session.md +852 -0
- package/kb/site/en/reference/subsystems/settings.md +313 -0
- package/kb/site/en/reference/subsystems/shell.md +306 -0
- package/kb/site/en/reference/subsystems/skills.md +334 -0
- package/kb/site/en/reference/subsystems/spill.md +120 -0
- package/kb/site/en/reference/subsystems/storage.md +232 -0
- package/kb/site/en/reference/subsystems/subagent.md +737 -0
- package/kb/site/en/reference/subsystems/subprocess.md +327 -0
- package/kb/site/en/reference/subsystems/system-prompt.md +210 -0
- package/kb/site/en/reference/subsystems/terminal.md +187 -0
- package/kb/site/en/reference/subsystems/token-meter.md +93 -0
- package/kb/site/en/reference/subsystems/tools.md +723 -0
- package/kb/site/en/reference/subsystems/typert.md +339 -0
- package/kb/site/en/reference/subsystems/user-questions.md +181 -0
- package/kb/site/en/reference/subsystems/web-server.md +111 -0
- package/kb/site/en/reference/subsystems/web.md +202 -0
- package/kb/site/en/reference/subsystems/workflow.md +281 -0
- package/kb/site/en/reference/subsystems/workspace.md +231 -0
- package/kb/site/en/reference/tool-catalog.md +1877 -0
- package/kb/site/en/reference/tool-execution-pipeline.md +66 -0
- package/kb/site/guide/providers-custom-form.zh.png +0 -0
- package/kb/site/guide/providers-models-page.zh.png +0 -0
- package/kb/site/guide/providers.md +100 -0
- package/kb/site/guide/python-sdk.md +106 -0
- package/kb/site/guide/quickstart.md +32 -0
- package/kb/site/index.md +8 -0
- package/kb/site/reference/agent-lifecycle.md +86 -0
- package/kb/site/reference/capability-seams.md +475 -0
- package/kb/site/reference/config-catalog.md +3154 -0
- package/kb/site/reference/cookbook/adding-a-conversation-node.md +235 -0
- package/kb/site/reference/cookbook/adding-a-package.md +120 -0
- package/kb/site/reference/cookbook/adding-a-settings-card.md +102 -0
- package/kb/site/reference/cookbook/adding-a-tool.md +98 -0
- package/kb/site/reference/cookbook/adding-an-llm-adapter.md +45 -0
- package/kb/site/reference/cookbook/extension-cookbook.md +133 -0
- package/kb/site/reference/cordis-api/context.md +368 -0
- package/kb/site/reference/cordis-api/events.md +211 -0
- package/kb/site/reference/cordis-api/fiber.md +379 -0
- package/kb/site/reference/cordis-api/inherited.md +43 -0
- package/kb/site/reference/cordis-api/registry.md +156 -0
- package/kb/site/reference/cordis-api/service.md +106 -0
- package/kb/site/reference/cordis-primer.md +52 -0
- package/kb/site/reference/index.md +135 -0
- package/kb/site/reference/persistence-catalog.md +949 -0
- package/kb/site/reference/subsystems/approval.md +173 -0
- package/kb/site/reference/subsystems/client-modules.md +121 -0
- package/kb/site/reference/subsystems/code-runtime.md +194 -0
- package/kb/site/reference/subsystems/commands.md +190 -0
- package/kb/site/reference/subsystems/compaction.md +241 -0
- package/kb/site/reference/subsystems/core.md +1081 -0
- package/kb/site/reference/subsystems/credentials.md +136 -0
- package/kb/site/reference/subsystems/filesystem.md +498 -0
- package/kb/site/reference/subsystems/goal.md +280 -0
- package/kb/site/reference/subsystems/index.md +58 -0
- package/kb/site/reference/subsystems/invariants.md +91 -0
- package/kb/site/reference/subsystems/jobs.md +293 -0
- package/kb/site/reference/subsystems/llm-streaming.md +926 -0
- package/kb/site/reference/subsystems/lsp.md +205 -0
- package/kb/site/reference/subsystems/permission-presets.md +134 -0
- package/kb/site/reference/subsystems/persistence.md +388 -0
- package/kb/site/reference/subsystems/plan.md +90 -0
- package/kb/site/reference/subsystems/sandbox.md +221 -0
- package/kb/site/reference/subsystems/schedule.md +189 -0
- package/kb/site/reference/subsystems/scope.md +62 -0
- package/kb/site/reference/subsystems/session-projection.md +265 -0
- package/kb/site/reference/subsystems/session-query.md +498 -0
- package/kb/site/reference/subsystems/session-reference.md +111 -0
- package/kb/site/reference/subsystems/session-telemetry.md +197 -0
- package/kb/site/reference/subsystems/session-title.md +207 -0
- package/kb/site/reference/subsystems/session.md +854 -0
- package/kb/site/reference/subsystems/settings.md +313 -0
- package/kb/site/reference/subsystems/shell.md +306 -0
- package/kb/site/reference/subsystems/skills.md +334 -0
- package/kb/site/reference/subsystems/spill.md +120 -0
- package/kb/site/reference/subsystems/storage.md +232 -0
- package/kb/site/reference/subsystems/subagent.md +739 -0
- package/kb/site/reference/subsystems/subprocess.md +327 -0
- package/kb/site/reference/subsystems/system-prompt.md +210 -0
- package/kb/site/reference/subsystems/terminal.md +187 -0
- package/kb/site/reference/subsystems/token-meter.md +93 -0
- package/kb/site/reference/subsystems/tools.md +723 -0
- package/kb/site/reference/subsystems/typert.md +339 -0
- package/kb/site/reference/subsystems/user-questions.md +181 -0
- package/kb/site/reference/subsystems/web-server.md +111 -0
- package/kb/site/reference/subsystems/web.md +202 -0
- package/kb/site/reference/subsystems/workflow.md +281 -0
- package/kb/site/reference/subsystems/workspace.md +231 -0
- package/kb/site/reference/tool-catalog.md +1880 -0
- package/kb/site/reference/tool-execution-pipeline.md +66 -0
- package/package.json +40 -0
- package/scripts/rebuild-index.mjs +88 -0
- package/skills/dsh-plugin-dev-kb.md +66 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
editSource: "docs/subsystems/session-telemetry.md"
|
|
3
|
+
outline: [2,3]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SessionTelemetryBackend
|
|
7
|
+
|
|
8
|
+
Outbound session reporting is split as a [capability seam](../capability-seams.md): the Service Definition and capture coordinator ([dsh-session-telemetry](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-telemetry), `ctx.sessionTelemetry`) own the capture points, fixed chunk projection, `session-telemetry/record` redaction waterfall, handoff cursor, and minimal backend contract; the Service Provider a deployment loads ([dsh-session-telemetry-otel](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-telemetry-otel)) is the OpenTelemetry JS SDK's log pipeline configured verbatim. It is one optional capability, not part of the agent-loop spine, and nothing here reaches a model request. The boundary axiom — the harness's aspect ends at `emit()`; batching, retry, queueing, and loss policy belong to the reporting SDK — and the rejected alternatives are pinned in the [revival Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md); the capture points, cursor, and projection contracts live in the [Service Definition README](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/README.md).
|
|
9
|
+
|
|
10
|
+
Source: [`packages/session/session-telemetry/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
|
|
11
|
+
|
|
12
|
+
## The logical record
|
|
13
|
+
|
|
14
|
+
```ts type-equiv
|
|
15
|
+
/**
|
|
16
|
+
* Severity of a telemetry record, pre-mapped at capture so a receiver can
|
|
17
|
+
* alert with zero configuration: `error` for events whose own outcome flag
|
|
18
|
+
* says so (the tool-result block's `isError`, `turn/end` error reasons) and for
|
|
19
|
+
* `agent-error` operational records. Captured events otherwise default to
|
|
20
|
+
* `info`; `warn` remains available to `session-telemetry/record` policies and
|
|
21
|
+
* backends.
|
|
22
|
+
*/
|
|
23
|
+
type SessionTelemetrySeverity = 'info' | 'warn' | 'error'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts type-equiv
|
|
27
|
+
/**
|
|
28
|
+
* One logical record handed to a backend — the capture contract's whole outbound
|
|
29
|
+
* vocabulary. Ledger records mirror session-log events one-to-one;
|
|
30
|
+
* operational records (`channel: 'ops'`) carry the two signals with no log
|
|
31
|
+
* home (`agent-error`, `shutdown`) and deliberately omit `event.seq`-style
|
|
32
|
+
* identity so they can never be mistaken for ledger rows.
|
|
33
|
+
*/
|
|
34
|
+
interface SessionTelemetryRecord {
|
|
35
|
+
/** Ledger (session-log mirror) or ops (operational signal) channel; backends keep the two under separate instrumentation scopes. */
|
|
36
|
+
channel: 'ledger' | 'ops'
|
|
37
|
+
/** Unix epoch milliseconds — the source event's append time for ledger records, the emission time for ops records. */
|
|
38
|
+
time: number
|
|
39
|
+
/** Pre-mapped alerting severity; see {@link SessionTelemetrySeverity}. */
|
|
40
|
+
severity: SessionTelemetrySeverity
|
|
41
|
+
/**
|
|
42
|
+
* Identity attributes, deliberately minimal: ledger records carry
|
|
43
|
+
* `session.id`, `event.type`, `event.seq`, plus `session.cwd` /
|
|
44
|
+
* `session.parent_id` / `session.seed_length` when the header has them;
|
|
45
|
+
* ops records carry `telemetry.op`, `session.id`, and (for `agent-error`)
|
|
46
|
+
* `agent.id`, `turn`, `step`, `error.name`. Anything recoverable from the
|
|
47
|
+
* body is intentionally NOT duplicated here.
|
|
48
|
+
*/
|
|
49
|
+
attributes: Record<string, string | number>
|
|
50
|
+
/**
|
|
51
|
+
* The complete payload: a deep copy of the session event's `data` for
|
|
52
|
+
* ledger records (JSON-serializable by `Session.append`'s own
|
|
53
|
+
* validation), or the op payload for ops records. Never mutated after
|
|
54
|
+
* handoff.
|
|
55
|
+
*/
|
|
56
|
+
body: unknown
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Only the first `assistant/chunk` of each `(turn, step)` ships — the stream-started signal; the rest drop at capture, so `seq` gaps are routine on the wire and never a loss signal. Every other [session event](./session.md) type, including plugin-merged ones the seam never heard of, passes through whole. Delivery is best-effort: the cursor marks handed-off, not delivered, records can be lost (crash, reload window) and duplicated (cursor-less re-adoption, SDK retries), so receivers dedupe ledger records on `(session.id, event.seq)`; ops records deliberately omit that identity — they are signals to alert on, not entries to sum, and tolerate duplicates instead.
|
|
61
|
+
|
|
62
|
+
## The sharing disclosure
|
|
63
|
+
|
|
64
|
+
The seam's acknowledgement contract (owned by the [Service Definition README's sharing-disclosure section](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/README.md#the-sharing-disclosure)): every backend discloses its deployment-selected sharing policy through the required abstract `sharing` member on `ctx.sessionTelemetry`, and consumers render "not configured" only when no telemetry service is mounted. The disclosure states the current policy, never delivery or retention — handoff is the non-blocking enqueue, and batching, retry, and loss policy stay the reporting SDK's.
|
|
65
|
+
|
|
66
|
+
```ts type-equiv
|
|
67
|
+
/**
|
|
68
|
+
* Deployment-selected session-sharing policy disclosed by a mounted
|
|
69
|
+
* {@link SessionTelemetryBackend} backend to human-facing acknowledgement surfaces (the
|
|
70
|
+
* `/feedback` command's confirmation text). The seam owns the vocabulary so
|
|
71
|
+
* any backend can disclose a policy without depending on the OTel package;
|
|
72
|
+
* the values mirror the OTel backend's serialized `SessionTelemetryMode` choices.
|
|
73
|
+
*/
|
|
74
|
+
type SessionTelemetrySharingStatus = 'full' | 'feedback-only' | 'disabled'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## The backend contract
|
|
78
|
+
|
|
79
|
+
```ts type-equiv
|
|
80
|
+
/**
|
|
81
|
+
* The minimum backend contract the coordinator requires. {@link SessionTelemetryBackend} is
|
|
82
|
+
* its service-registered form; tests compose the coordinator with a bare
|
|
83
|
+
* implementation of this interface.
|
|
84
|
+
*/
|
|
85
|
+
interface SessionTelemetrySink {
|
|
86
|
+
/**
|
|
87
|
+
* Hand one record to the backend's pipeline. MUST be a non-blocking
|
|
88
|
+
* enqueue — the coordinator calls this synchronously from the
|
|
89
|
+
* `session/event` hot path or an explicit canonical-log capture, so anything
|
|
90
|
+
* slower than a queue push would tax the agent loop or feedback handling.
|
|
91
|
+
* Errors thrown here are contained by the coordinator and logged; they
|
|
92
|
+
* never reach the loop.
|
|
93
|
+
* @param record - the logical record to report; owned by the backend after the call.
|
|
94
|
+
*/
|
|
95
|
+
emit(record: SessionTelemetryRecord): void
|
|
96
|
+
/**
|
|
97
|
+
* Optional hint that a turn ended. A backend may forward it to its SDK's
|
|
98
|
+
* flush so records are exported after each turn. Called
|
|
99
|
+
* fire-and-forget; implementations must not block and must not throw
|
|
100
|
+
* meaningfully (the coordinator contains exceptions). Most backends should
|
|
101
|
+
* leave this unimplemented and let their SDK's own batching cadence govern
|
|
102
|
+
* export timing: a backend that does implement it owns the interaction
|
|
103
|
+
* between its concurrent flushes and {@link shutdown}'s drain (the OTel
|
|
104
|
+
* backend leaves it unimplemented for exactly that hazard — see the
|
|
105
|
+
* revival Agent Note).
|
|
106
|
+
*/
|
|
107
|
+
flush?(): void
|
|
108
|
+
/**
|
|
109
|
+
* Forward the fiber's disposal to the SDK: flush whatever is queued and
|
|
110
|
+
* reach quiescence, per the SDK's own shutdown contract. Everything
|
|
111
|
+
* emitted before this call must still be delivered — including records
|
|
112
|
+
* enqueued while a {@link flush} hint is in flight, so a backend whose SDK
|
|
113
|
+
* guards against concurrent flushes orders behind the outstanding one (the
|
|
114
|
+
* coordinator emits its dispose-time `shutdown` markers immediately before
|
|
115
|
+
* calling this). Awaited by the coordinator's dispose; a rejection is
|
|
116
|
+
* logged as a warning and never fails application teardown.
|
|
117
|
+
* The coordinator captures dispose-time shutdown markers immediately before
|
|
118
|
+
* this call for live capture; on-demand capture creates no ops records.
|
|
119
|
+
* @returns resolves when the backend's pipeline has quiesced.
|
|
120
|
+
*/
|
|
121
|
+
shutdown(): Promise<void>
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`SessionTelemetryBackend` (`ctx.sessionTelemetry`, [signatures](#ctxsessiontelemetry--sessiontelemetrybackend-abstract-seam)) is the contract's loadable form — one implementation per context, duplicate load throws — and a backend composes the seam's `SessionTelemetryCoordinator` in its constructor to install the capture side.
|
|
126
|
+
|
|
127
|
+
## The redact waterfall: `session-telemetry/record`
|
|
128
|
+
|
|
129
|
+
Every record passes the `session-telemetry/record` [waterfall](../cordis-primer.md#cordis-waterfall-semantics) between projection and `emit()` ([event entry](#session-telemetryrecord--waterfall)). The seam ships NO rules of its own: with no listener mounted, records reach the backend exactly as captured, so exported data is precisely as clean as the rules a deployment mounts. Listeners stack by transforming `next()`'s return value; returning without `next()` replaces everything beneath; a throwing listener withholds that one record fail-closed inside the coordinator's containment. Redaction applies to the exported copy only — the canonical session log is never rewritten.
|
|
130
|
+
|
|
131
|
+
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
132
|
+
|
|
133
|
+
<a id="cordis-surface"></a>
|
|
134
|
+
|
|
135
|
+
## Cordis API
|
|
136
|
+
|
|
137
|
+
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — this section is byte-identical in both language sides of the page. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
138
|
+
|
|
139
|
+
<a id="ctxsessiontelemetry--sessiontelemetrybackend-abstract-seam"></a>
|
|
140
|
+
|
|
141
|
+
### `ctx.sessionTelemetry` — `SessionTelemetryBackend` (abstract seam)
|
|
142
|
+
|
|
143
|
+
Loadable form of the backend contract: one implementation per context — the cordis `Service` registration under the `telemetry` key throws on a duplicate, cordis' standard behavior. A backend composes a SessionTelemetryCoordinator in its constructor to install the capture side.
|
|
144
|
+
|
|
145
|
+
```ts cordis-catalog
|
|
146
|
+
/**
|
|
147
|
+
* See {@link SessionTelemetrySink.emit} — that declaration is the contract's one home.
|
|
148
|
+
* @param record - the logical record to report; owned by the backend after the call.
|
|
149
|
+
*/
|
|
150
|
+
abstract emit(record: SessionTelemetryRecord): void
|
|
151
|
+
|
|
152
|
+
/** See {@link SessionTelemetrySink.flush}. */
|
|
153
|
+
flush?(): void
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* See {@link SessionTelemetrySink.shutdown}.
|
|
157
|
+
* @returns resolves when the backend's pipeline has quiesced.
|
|
158
|
+
*/
|
|
159
|
+
abstract shutdown(): Promise<void>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Source: [`packages/session/session-telemetry/src/index.ts:148`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
|
|
163
|
+
|
|
164
|
+
<a id="session-telemetry-events"></a>
|
|
165
|
+
|
|
166
|
+
### `session-telemetry/*` events
|
|
167
|
+
|
|
168
|
+
<a id="session-telemetryrecord--waterfall"></a>
|
|
169
|
+
|
|
170
|
+
#### `session-telemetry/record` — waterfall
|
|
171
|
+
|
|
172
|
+
Transform one outbound record before it reaches the backend. This waterfall is the Service Definition's redaction extension point. It ships NO rules of its own: the innermost `next()` passes the record through unchanged, and with no listener mounted records reach the backend as captured, so exported data is exactly as clean as the rules a deployment mounts. Listeners stack by transforming `next()`'s return value; returning without `next()` replaces everything beneath. Dispatched synchronously on the capture hot path inside the coordinator's containment: a throwing listener withholds that one record (fail-closed) and never reaches the agent loop. Live capture dispatches at append time; on-demand capture dispatches while reading the canonical log. Redaction applies to the exported copy only; the canonical session log is never rewritten.
|
|
173
|
+
|
|
174
|
+
```ts cordis-catalog
|
|
175
|
+
/**
|
|
176
|
+
* Transform one outbound record before it reaches the backend. This
|
|
177
|
+
* waterfall is the Service Definition's redaction extension point. It ships NO rules
|
|
178
|
+
* of its own: the
|
|
179
|
+
* innermost `next()` passes the record through unchanged, and with no
|
|
180
|
+
* listener mounted records reach the backend as captured, so exported
|
|
181
|
+
* data is exactly as clean as the rules a deployment mounts. Listeners
|
|
182
|
+
* stack by transforming `next()`'s return value; returning without
|
|
183
|
+
* `next()` replaces everything beneath. Dispatched synchronously on the
|
|
184
|
+
* capture hot path inside the coordinator's containment: a throwing
|
|
185
|
+
* listener withholds that one record (fail-closed) and never reaches the
|
|
186
|
+
* agent loop. Live capture dispatches at append time; on-demand capture
|
|
187
|
+
* dispatches while reading the canonical log. Redaction applies to the
|
|
188
|
+
* exported copy only; the canonical session log is never rewritten.
|
|
189
|
+
* @param record - the candidate record, already the coordinator's own deep
|
|
190
|
+
* copy; listeners return a (possibly new) record and must not mutate it.
|
|
191
|
+
* @mode waterfall
|
|
192
|
+
*/
|
|
193
|
+
'session-telemetry/record'(record: SessionTelemetryRecord, next: () => SessionTelemetryRecord): SessionTelemetryRecord
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Source: [`packages/session/session-telemetry/src/index.ts:43`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
|
|
197
|
+
<!-- END GENERATED cordis-surface -->
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
editSource: "docs/subsystems/session-title.md"
|
|
3
|
+
outline: [2,3]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Session Titles
|
|
7
|
+
|
|
8
|
+
Durable latest-wins title state and the optional asynchronous provider vocabulary owned by [`@deepseek-ai/dsh-session-title`](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-title). The shared LLM helper owns the exact auxiliary request record. Package READMEs own timing, fallback, failure, and fork behavior; the generated [persistence catalog](../persistence-catalog.md) owns the complete event declarations.
|
|
9
|
+
|
|
10
|
+
Sources: [`packages/session/session-title/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title/src/index.ts), [`packages/session/session-title-llm/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title-llm/src/index.ts)
|
|
11
|
+
|
|
12
|
+
## Durable title state
|
|
13
|
+
|
|
14
|
+
`SessionTitleProviderId` is recorded for provider-produced revisions. `SessionTitleEventData` lists the exact human-message seqs used for the title, while `SessionTitleSnapshot` adds the durable event envelope facts selected by `foldSessionTitle()`.
|
|
15
|
+
|
|
16
|
+
```ts type-equiv
|
|
17
|
+
/** Identifies one session-title provider registration. */
|
|
18
|
+
type SessionTitleProviderId = Branded<'SessionTitleProviderId'>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts type-equiv
|
|
22
|
+
/** Exact auxiliary model route that produced a title. */
|
|
23
|
+
interface SessionTitleModelProvenance {
|
|
24
|
+
/** Registered LLM provider route. */
|
|
25
|
+
readonly provider: string
|
|
26
|
+
/** Provider model id. */
|
|
27
|
+
readonly model: string
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```ts type-equiv
|
|
32
|
+
/** Durable ownership record for an accepted session title. */
|
|
33
|
+
type SessionTitleSource =
|
|
34
|
+
| { readonly kind: 'fallback' }
|
|
35
|
+
| {
|
|
36
|
+
readonly kind: 'provider'
|
|
37
|
+
readonly provider: SessionTitleProviderId
|
|
38
|
+
readonly model?: SessionTitleModelProvenance
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
/** Explicit user rename: pins the title — automatic generation stops scheduling. */
|
|
42
|
+
readonly kind: 'user'
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```ts type-equiv
|
|
47
|
+
/** Payload of the log-only `session/title` event. */
|
|
48
|
+
interface SessionTitleEventData {
|
|
49
|
+
/** Normalized non-empty title text. */
|
|
50
|
+
readonly title: string
|
|
51
|
+
/** Exact human `user/message` seqs used to derive this title; empty for an explicit user rename. */
|
|
52
|
+
readonly messageSeqs: number[]
|
|
53
|
+
/** Whether the built-in fallback, a registered provider, or the user supplied the title. */
|
|
54
|
+
readonly source: SessionTitleSource
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```ts type-equiv
|
|
59
|
+
/** Latest folded title plus the title event's durable envelope facts. */
|
|
60
|
+
interface SessionTitleSnapshot extends SessionTitleEventData {
|
|
61
|
+
/** Seq of the latest `session/title` event. */
|
|
62
|
+
readonly eventSeq: number
|
|
63
|
+
/** Timestamp of the latest `session/title` event. */
|
|
64
|
+
readonly updatedAt: number
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Auxiliary request record
|
|
69
|
+
|
|
70
|
+
The shared LLM helper records each validated, dispatchable title request before calling the model. The payload reproduces the model-visible system and message input, routing, output limit, provider ownership, and source-message attribution even when generation later fails.
|
|
71
|
+
|
|
72
|
+
```ts type-equiv
|
|
73
|
+
/** Exact model-visible request recorded before one auxiliary title dispatch. */
|
|
74
|
+
interface SessionTitleLlmRequestEventData {
|
|
75
|
+
/** Registered title-provider identity responsible for the request. */
|
|
76
|
+
readonly titleProvider: SessionTitleProviderId
|
|
77
|
+
/** Exact human `user/message` seqs represented in `messages`. */
|
|
78
|
+
readonly messageSeqs: number[]
|
|
79
|
+
/** Exact auxiliary LLM route. */
|
|
80
|
+
readonly route: SessionTitleModelProvenance
|
|
81
|
+
/** Exact auxiliary system prompt. */
|
|
82
|
+
readonly system: string
|
|
83
|
+
/** Exact auxiliary message list. */
|
|
84
|
+
readonly messages: Message[]
|
|
85
|
+
/** Exact auxiliary output-token cap. */
|
|
86
|
+
readonly maxTokens: number
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Provider input and output
|
|
91
|
+
|
|
92
|
+
The service snapshots eligible messages through one revision. A provider returns only seqs from that request; service-owned acceptance verifies ordering, normalizes the title, enforces the byte limit, and appends the title with its source-message seqs and source kind.
|
|
93
|
+
|
|
94
|
+
```ts type-equiv
|
|
95
|
+
/** One eligible human text message exposed to title providers. */
|
|
96
|
+
interface SessionTitleUserMessage {
|
|
97
|
+
/** Source `user/message` event seq. */
|
|
98
|
+
readonly seq: number
|
|
99
|
+
/** Exact concatenated text-block content. */
|
|
100
|
+
readonly text: string
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```ts type-equiv
|
|
105
|
+
/** Automatic generation cadence owned by a registered provider. */
|
|
106
|
+
type SessionTitleAutomaticMode = 'first-prompt' | 'all-prompts'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```ts type-equiv
|
|
110
|
+
/** Immutable input supplied to one title-provider call. */
|
|
111
|
+
interface SessionTitleProviderRequest {
|
|
112
|
+
/** Live session being titled. */
|
|
113
|
+
readonly session: Session
|
|
114
|
+
/** All eligible human messages through this generation revision. */
|
|
115
|
+
readonly messages: readonly SessionTitleUserMessage[]
|
|
116
|
+
/** Exact current logged main-request route, when one has been recorded. */
|
|
117
|
+
readonly route?: SessionTitleModelProvenance
|
|
118
|
+
/** Cancellation for supersession, disposal, timeout composition, or the explicit caller. */
|
|
119
|
+
readonly signal: AbortSignal
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```ts type-equiv
|
|
124
|
+
/** Provider output before service-owned normalization and log acceptance. */
|
|
125
|
+
interface SessionTitleProviderResult {
|
|
126
|
+
/** Proposed title text. */
|
|
127
|
+
readonly title: string
|
|
128
|
+
/** Exact seqs from `request.messages` used by this result. */
|
|
129
|
+
readonly messageSeqs: readonly number[]
|
|
130
|
+
/** Auxiliary LLM route, when generation used a model. */
|
|
131
|
+
readonly model?: SessionTitleModelProvenance
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```ts type-equiv
|
|
136
|
+
/** One optional asynchronous title implementation registered with the service. */
|
|
137
|
+
interface SessionTitleProvider {
|
|
138
|
+
/** Stable id of the provider recorded with the title. */
|
|
139
|
+
readonly id: SessionTitleProviderId
|
|
140
|
+
/** When new human prompts start automatic generation. */
|
|
141
|
+
readonly automatic: SessionTitleAutomaticMode
|
|
142
|
+
/**
|
|
143
|
+
* Produce one title revision.
|
|
144
|
+
* @param request - message snapshot, current route, session, and cancellation.
|
|
145
|
+
* @returns proposed title plus exact input seqs and the optional provider/model route used to generate it.
|
|
146
|
+
*/
|
|
147
|
+
generate(request: SessionTitleProviderRequest): Promise<SessionTitleProviderResult>
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
152
|
+
|
|
153
|
+
<a id="cordis-surface"></a>
|
|
154
|
+
|
|
155
|
+
## Cordis API
|
|
156
|
+
|
|
157
|
+
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — this section is byte-identical in both language sides of the page. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
158
|
+
|
|
159
|
+
<a id="ctxsessiontitle--sessiontitleservice"></a>
|
|
160
|
+
|
|
161
|
+
### `ctx.sessionTitle` — `SessionTitleService`
|
|
162
|
+
|
|
163
|
+
Log-backed title fold plus asynchronous fallback generation.
|
|
164
|
+
|
|
165
|
+
```ts cordis-catalog
|
|
166
|
+
/**
|
|
167
|
+
* Read the latest folded title from one live or replayed session.
|
|
168
|
+
* @param session - session whose log is the title source of truth.
|
|
169
|
+
* @returns latest title snapshot, or `undefined` before eligible input.
|
|
170
|
+
*/
|
|
171
|
+
get(session: Session): SessionTitleSnapshot | undefined
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Accept an explicit user title. Appends a `session/title` event with the
|
|
175
|
+
* `user` source, which pins the title: in-flight automatic generation is
|
|
176
|
+
* superseded and later user messages schedule none (an explicit
|
|
177
|
+
* {@link SessionTitleService.refresh} remains the deliberate unpin).
|
|
178
|
+
* @param session - exact live session to rename.
|
|
179
|
+
* @param title - raw user input; normalized before acceptance.
|
|
180
|
+
* @returns the accepted title snapshot.
|
|
181
|
+
* @throws {SessionTitleInvalidError} when the title normalizes to empty.
|
|
182
|
+
* @throws {Error} when the session is not live or the service is disposed.
|
|
183
|
+
*/
|
|
184
|
+
rename(session: Session, title: string): SessionTitleSnapshot
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Explicitly retry the registered provider, or materialize the built-in
|
|
188
|
+
* fallback when no provider is registered.
|
|
189
|
+
* @param session - exact live session to refresh.
|
|
190
|
+
* @param signal - optional caller cancellation.
|
|
191
|
+
* @returns latest accepted title, or `undefined` when no eligible text exists.
|
|
192
|
+
*/
|
|
193
|
+
async refresh(session: Session, signal?: AbortSignal): Promise<SessionTitleSnapshot | undefined>
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Register the sole optional title provider. Disposal aborts its pending and
|
|
197
|
+
* active work before another provider may register.
|
|
198
|
+
* @param provider - provider identity, cadence, and generation function.
|
|
199
|
+
* @returns exact Cordis effect disposer, which settles after active calls quiesce.
|
|
200
|
+
*/
|
|
201
|
+
register(provider: SessionTitleProvider): () => Promise<void>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Types: [Session](./session.md)
|
|
205
|
+
|
|
206
|
+
Source: [`packages/session/session-title/src/index.ts:261`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title/src/index.ts)
|
|
207
|
+
<!-- END GENERATED cordis-surface -->
|