@wowyuarm/dsh-agent-team 0.1.8 → 0.1.10

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.
Files changed (81) hide show
  1. package/README.md +4 -11
  2. package/README.zh.md +4 -11
  3. package/package.json +54 -44
  4. package/packages/agent-team/README.md +7 -5
  5. package/packages/agent-team/README.zh.md +7 -4
  6. package/packages/agent-team/lib/attachments.js +14 -4
  7. package/packages/agent-team/lib/context-management.js +382 -0
  8. package/packages/agent-team/lib/context-projection.js +578 -0
  9. package/packages/agent-team/lib/context-source.js +212 -0
  10. package/packages/agent-team/lib/index.js +1272 -76
  11. package/packages/agent-team/lib/ledger.js +333 -44
  12. package/packages/agent-team/lib/member-context.js +6 -2
  13. package/packages/agent-team/lib/member-runtime.js +159 -4
  14. package/packages/agent-team/lib/member-time-context.js +126 -0
  15. package/packages/agent-team/lib/pressure-policy.js +199 -0
  16. package/packages/agent-team/lib/progress-nudge.js +12 -4
  17. package/packages/agent-team/lib/session-remediation.js +481 -0
  18. package/packages/agent-team/lib/spec.js +21 -2
  19. package/packages/agent-team/lib/time-format.js +56 -0
  20. package/packages/agent-team/lib/typert.host.js +168 -54
  21. package/packages/agent-team/lib/typert.remote-client.d.ts.map +1 -1
  22. package/packages/agent-team/lib/typert.remote-client.js +59 -25
  23. package/packages/agent-team/lib/types/attachments.d.ts +1 -1
  24. package/packages/agent-team/lib/types/attachments.d.ts.map +1 -1
  25. package/packages/agent-team/lib/types/context-management.d.ts +147 -0
  26. package/packages/agent-team/lib/types/context-management.d.ts.map +1 -0
  27. package/packages/agent-team/lib/types/context-projection.d.ts +219 -0
  28. package/packages/agent-team/lib/types/context-projection.d.ts.map +1 -0
  29. package/packages/agent-team/lib/types/context-source.d.ts +117 -0
  30. package/packages/agent-team/lib/types/context-source.d.ts.map +1 -0
  31. package/packages/agent-team/lib/types/index.d.ts +300 -2
  32. package/packages/agent-team/lib/types/index.d.ts.map +1 -1
  33. package/packages/agent-team/lib/types/ledger.d.ts +119 -6
  34. package/packages/agent-team/lib/types/ledger.d.ts.map +1 -1
  35. package/packages/agent-team/lib/types/member-context.d.ts.map +1 -1
  36. package/packages/agent-team/lib/types/member-runtime.d.ts +30 -2
  37. package/packages/agent-team/lib/types/member-runtime.d.ts.map +1 -1
  38. package/packages/agent-team/lib/types/member-time-context.d.ts +83 -0
  39. package/packages/agent-team/lib/types/member-time-context.d.ts.map +1 -0
  40. package/packages/agent-team/lib/types/pressure-policy.d.ts +106 -0
  41. package/packages/agent-team/lib/types/pressure-policy.d.ts.map +1 -0
  42. package/packages/agent-team/lib/types/progress-nudge.d.ts.map +1 -1
  43. package/packages/agent-team/lib/types/session-remediation.d.ts +149 -0
  44. package/packages/agent-team/lib/types/session-remediation.d.ts.map +1 -0
  45. package/packages/agent-team/lib/types/spec.d.ts.map +1 -1
  46. package/packages/agent-team/lib/types/time-format.d.ts +28 -0
  47. package/packages/agent-team/lib/types/time-format.d.ts.map +1 -0
  48. package/packages/agent-team/lib/types/types/entities.d.ts +22 -1
  49. package/packages/agent-team/lib/types/types/entities.d.ts.map +1 -1
  50. package/packages/agent-team/lib/types/types/operations.d.ts +38 -3
  51. package/packages/agent-team/lib/types/types/operations.d.ts.map +1 -1
  52. package/packages/agent-team/lib/types/types/requests-results.d.ts +58 -1
  53. package/packages/agent-team/lib/types/types/requests-results.d.ts.map +1 -1
  54. package/packages/agent-team/preset/team-member/agent.cordis.yml +27 -4
  55. package/packages/client-agent-team/lib/client.js +369 -352
  56. package/packages/client-agent-team/lib/client.js.map +1 -1
  57. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.d.ts +1 -2
  58. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.d.ts.map +1 -1
  59. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.js +61 -41
  60. package/packages/client-agent-team/lib/types/client/TeamMessage.js +2 -2
  61. package/packages/client-agent-team/lib/types/client/TeamThreadPage.js +4 -4
  62. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts +1 -1
  63. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts.map +1 -1
  64. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.js +2 -2
  65. package/packages/client-agent-team/lib/types/client/index.d.ts.map +1 -1
  66. package/packages/client-agent-team/lib/types/client/index.js +44 -16
  67. package/packages/client-agent-team/lib/types/client/locales.d.ts +0 -14
  68. package/packages/client-agent-team/lib/types/client/locales.d.ts.map +1 -1
  69. package/packages/client-agent-team/lib/types/client/locales.js +0 -14
  70. package/packages/client-agent-team/lib/types/client/slots.d.ts +6 -1
  71. package/packages/client-agent-team/lib/types/client/slots.d.ts.map +1 -1
  72. package/packages/tool-agent-team/README.md +11 -6
  73. package/packages/tool-agent-team/README.zh.md +11 -6
  74. package/packages/tool-agent-team/lib/context-tools.js +179 -0
  75. package/packages/tool-agent-team/lib/index.js +369 -58
  76. package/packages/tool-agent-team/lib/types/context-tools.d.ts +16 -0
  77. package/packages/tool-agent-team/lib/types/context-tools.d.ts.map +1 -0
  78. package/packages/tool-agent-team/lib/types/index.d.ts.map +1 -1
  79. package/packages/agent-team/lib/auto-compaction.js +0 -201
  80. package/packages/agent-team/lib/types/auto-compaction.d.ts +0 -47
  81. package/packages/agent-team/lib/types/auto-compaction.d.ts.map +0 -1
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Host-only Session projection for Agent Team context management.
3
+ *
4
+ * One pure synchronous fold over a Member Session log derives every
5
+ * context-management fact the Host needs: pending rollover intent (a
6
+ * successful `context_rollover` call/result pair — under the legacy
7
+ * `new_context` name for Sessions recorded before the rename), explicit
8
+ * checkpoints (a
9
+ * successful `context_checkpoint` pair resolved by its containing `turn/end`),
10
+ * handoff/compaction boundaries, and quiet-continuation delivery state. The
11
+ * fold is the single authority for these facts — no second store, and callers
12
+ * never re-derive intent from raw events.
13
+ *
14
+ * A seeded child Session folds with `inheritedEventCount` respected: events
15
+ * inherited from the fork prefix are already resolved history, never fresh
16
+ * intent. The cold fold and the registered unit both start past the inherited
17
+ * cut, so an inherited historical rollover call can never schedule
18
+ * another transition in the child.
19
+ * @module @wowyuarm/dsh-agent-team/context-projection
20
+ */
21
+ import type { UserMessage } from '@deepseek-ai/dsh-llm';
22
+ import type { SessionEvent, SessionLogOffset } from '@deepseek-ai/dsh-session';
23
+ import type { ProjectionDefinition } from '@deepseek-ai/dsh-session-projection';
24
+ import type { AgentTeamContextCheckpointRef } from './types.ts';
25
+ import { isCheckpointContinuationMessage } from './context-source.ts';
26
+ /** Whether one notice summary is a pure reminder (never a semantic Team fact). */
27
+ export declare function isReminderNoticeSummary(summary: string): boolean;
28
+ /** Stable tool names the projection recognizes. */
29
+ export declare const CONTEXT_CHECKPOINT_TOOL_NAME = "context_checkpoint";
30
+ export declare const CONTEXT_ROLLOVER_TOOL_NAME = "context_rollover";
31
+ /**
32
+ * Legacy decoder name: the rollover tool was renamed `new_context` →
33
+ * `context_rollover`, and Sessions recorded before the rename still carry
34
+ * durable `new_context` call/result pairs. The projection keeps folding them
35
+ * — pending rollovers and crash recovery of existing Members depend on old
36
+ * events still resolving intent — but this is a log decoder, not a tool
37
+ * alias: no new call can carry the old name.
38
+ */
39
+ export declare const NEW_CONTEXT_TOOL_NAME = "new_context";
40
+ /** One completed-turn checkpoint anchor in this Session lineage. */
41
+ export interface ContextCheckpointEntry {
42
+ /** Opaque stable ref; selection authority, never derived from the name. */
43
+ readonly checkpointRef: AgentTeamContextCheckpointRef;
44
+ /** Display label supplied by the model. */
45
+ readonly name: string;
46
+ /** Seq of the successful tool result that recorded the checkpoint. */
47
+ readonly resultSeq: number;
48
+ /** Turn the checkpoint concluded; the completed-turn boundary anchor. */
49
+ readonly turn: number;
50
+ /** Seq of the `turn/end` that resolved the checkpoint; -1 until resolved. */
51
+ readonly turnEndSeq: number;
52
+ }
53
+ /** Arguments the model passed to one successful rollover call. */
54
+ export interface RolloverToolArguments {
55
+ readonly handoff: string;
56
+ readonly checkpointRef?: AgentTeamContextCheckpointRef | undefined;
57
+ readonly relatedFiles: readonly {
58
+ readonly path: string;
59
+ readonly reason: string;
60
+ }[];
61
+ }
62
+ /** Rollover intent waiting for the containing turn to finish and the Agent to idle. */
63
+ export interface PendingRolloverIntent extends RolloverToolArguments {
64
+ /** The provider-issued call id of the successful rollover call. */
65
+ readonly toolCallId: string;
66
+ /** Seq of the successful rollover tool result. */
67
+ readonly resultSeq: number;
68
+ /** Turn containing the successful call; the swap waits for its end. */
69
+ readonly turn: number;
70
+ /** Seq of the `turn/end` that released the intent for the swap; -1 until observed. */
71
+ readonly turnEndSeq: number;
72
+ }
73
+ /** Quiet-continuation delivery state for one checkpoint, keyed by checkpointRef. */
74
+ export interface ContinuationDeliveryState {
75
+ /** The checkpoint the continuation follows. */
76
+ readonly checkpointRef: AgentTeamContextCheckpointRef;
77
+ /** Seq of the delivered continuation notice in this Session; -1 until delivered. */
78
+ readonly deliveredSeq: number;
79
+ }
80
+ /** One non-Team message queued after the pending intent; a carry candidate. */
81
+ export interface CarriedCandidate {
82
+ /** The queued message itself, verbatim. */
83
+ readonly message: UserMessage;
84
+ /** The turn that surfaced the message onto the model-visible input, if any. */
85
+ readonly surfacedTurn: number;
86
+ /** Whether a completed assistant answer proved the old generation handled it. */
87
+ readonly consumed: boolean;
88
+ }
89
+ /** State of the `agentTeamContext` projection for one Session. */
90
+ export interface AgentTeamContextProjectionState {
91
+ /** Checkpoints recorded by a successful call, resolved ones anchored to their turn end. */
92
+ readonly checkpoints: readonly ContextCheckpointEntry[];
93
+ /** Rollover intent awaiting its containing turn end, at most one. */
94
+ readonly pending: PendingRolloverIntent | null;
95
+ /** Quiet continuations recorded (with or without delivery), keyed by checkpoint ref. */
96
+ readonly continuations: readonly ContinuationDeliveryState[];
97
+ /**
98
+ * Non-Team messages queued into the inbox after the pending intent's tool
99
+ * result. The durable `agent/inbox/spliced` log is the truth: the
100
+ * transition delivers every candidate the old generation never answered
101
+ * (a claimed-but-rejected or canceled message stays a candidate), deduped
102
+ * by message id. Empty until an intent exists.
103
+ */
104
+ readonly carriedCandidates: readonly CarriedCandidate[];
105
+ /** The most recently opened turn; user/message events carry no turn of their own. */
106
+ readonly lastTurn: number;
107
+ /**
108
+ * Context-tool calls whose results have not landed yet. Part of the state so
109
+ * the live unit folds one event at a time and still pairs call to result; a
110
+ * dangling call at any cut simply never becomes intent or a checkpoint.
111
+ */
112
+ readonly openCalls: readonly {
113
+ readonly callId: string;
114
+ readonly name: string;
115
+ readonly arguments: string;
116
+ }[];
117
+ /**
118
+ * Timeline boundaries beyond explicit checkpoints, resolved to their
119
+ * containing completed turn: handoff deliveries (each generation begins
120
+ * with one), compaction notices, and Team semantic facts that entered
121
+ * model context (successful claim-state tool results or structured Team
122
+ * notification delivery). Each is a structural timeline candidate with the
123
+ * same completed-turn anchor contract as a checkpoint.
124
+ */
125
+ readonly boundaries: readonly TimelineBoundary[];
126
+ /**
127
+ * Threads whose first delivery already anchored a boundary. The first
128
+ * arrival of a Thread's facts is the one preserved push-face anchor; every
129
+ * later re-delivery of the same Thread is noise and produces no boundary.
130
+ * Fold-internal by design: cold and live folds replay it identically from
131
+ * the event log, so no query-time rescan exists.
132
+ */
133
+ readonly seenThreads: readonly string[];
134
+ /** Seq of the latest resolved `turn/end`; the head boundary of the timeline. */
135
+ readonly lastTurnEndSeq: number;
136
+ }
137
+ /** One non-checkpoint timeline candidate resolved at a completed turn. */
138
+ export interface TimelineBoundary {
139
+ /** Stable identity for the timeline: kind plus the anchoring event seq. */
140
+ readonly key: string;
141
+ /** Which structural source produced this boundary. */
142
+ readonly source: 'team-boundary' | 'handoff' | 'compaction';
143
+ /** Human-facing label derived from the boundary's own data. */
144
+ readonly label: string;
145
+ /** Seq of the boundary's own anchoring event (delivery or tool result). */
146
+ readonly seq: number;
147
+ /** Turn the boundary landed in. */
148
+ readonly turn: number;
149
+ /** Seq of the `turn/end` that resolved it; -1 until resolved. */
150
+ readonly turnEndSeq: number;
151
+ }
152
+ declare module '@deepseek-ai/dsh-session-projection/types' {
153
+ interface SessionProjectionStateMap {
154
+ agentTeamContext: AgentTeamContextProjectionState;
155
+ }
156
+ }
157
+ /**
158
+ * Deterministic checkpoint ref from the recording session and tool call
159
+ * identity: a bounded, collision-resistant opaque token. Provider call ids
160
+ * are arbitrary-length free text that may repeat across generations and even
161
+ * collide between Sessions, so the ref derives from the SHA-256 of the exact
162
+ * `(sessionId, callId)` pair — same pair always reproduces the ref, any
163
+ * other pair is overwhelmingly unlikely to collide, and the token can never
164
+ * smuggle delimiters or unbounded content through a ref field.
165
+ */
166
+ export declare function checkpointRefFor(sessionId: string, callId: string): AgentTeamContextCheckpointRef;
167
+ /**
168
+ * Deterministic default-boundary ref for one delivered Team boundary: the
169
+ * same session-scoped hash shape as checkpoint refs, keyed on the boundary's
170
+ * anchoring event seq. Consecutive generations routinely repeat event seqs,
171
+ * so the Session identity must be part of the key or two generations'
172
+ * boundaries at the same seq collide — the timeline would silently drop the
173
+ * ancestor item and a `context_rollover` return would resolve the wrong boundary.
174
+ */
175
+ export declare function boundaryRefFor(sessionId: string, seq: number): AgentTeamContextCheckpointRef;
176
+ /**
177
+ * Cold-fold one immutable event log into the projection state. Events at or
178
+ * before `inheritedEventCount` belong to the fork prefix and are resolved
179
+ * history in this Session, so they never produce fresh intent. `sessionId` is
180
+ * the log's own Session identity — it keys checkpoint refs, so the same
181
+ * provider call id in two different Sessions produces two distinct refs.
182
+ */
183
+ export declare function foldContextProjection(events: readonly SessionEvent[], inheritedEventCount?: SessionLogOffset, sessionId?: string): AgentTeamContextProjectionState;
184
+ /**
185
+ * The host-only projection unit; no wire view is published. The definition is
186
+ * a factory: each Session folds with its own identity so checkpoint refs
187
+ * derive from that Session's exact `(sessionId, callId)` pairs.
188
+ */
189
+ export declare const agentTeamContextProjectionDefinition: (sessionId: string) => ProjectionDefinition<"agentTeamContext", AgentTeamContextProjectionState>;
190
+ /** The carried input one transition must deliver: unconsumed post-intent candidates, in queue order. */
191
+ export declare function carriedInputOf(state: AgentTeamContextProjectionState): readonly UserMessage[];
192
+ /** Whether a quiet continuation for one checkpoint was already delivered in this Session. */
193
+ export declare function continuationDelivered(state: AgentTeamContextProjectionState, checkpointRef: AgentTeamContextCheckpointRef): boolean;
194
+ /** Record that a continuation for one checkpoint is scheduled (delivery not yet seen). */
195
+ export declare function withScheduledContinuation(state: AgentTeamContextProjectionState, checkpointRef: AgentTeamContextCheckpointRef): AgentTeamContextProjectionState;
196
+ export { isCheckpointContinuationMessage };
197
+ /** One structural timeline candidate, projection view: anchor plus identity. */
198
+ export interface TimelineCandidate {
199
+ /** Stable selection ref (checkpoint refs for agent checkpoints; the boundary key otherwise). */
200
+ readonly ref: string;
201
+ /** Semantic label: the model-supplied checkpoint name or the boundary label. */
202
+ readonly label: string;
203
+ /** Which structural source produced this candidate. */
204
+ readonly source: 'agent' | 'team-boundary' | 'handoff' | 'compaction' | 'head';
205
+ /** Seq of the anchoring event (the tool result or delivery message). */
206
+ readonly seq: number;
207
+ /** Seq of the completed `turn/end` that resolved the candidate; -1 while unresolved. */
208
+ readonly turnEndSeq: number;
209
+ }
210
+ /**
211
+ * Bounded structural timeline candidates, newest first: explicit checkpoints
212
+ * (resolved only), structural boundaries, then the current head. The Host
213
+ * prices retained/discarded tokens and applies restorability guards on top;
214
+ * this view is the single source of candidate anchors and labels.
215
+ */
216
+ export declare function timelineCandidates(state: AgentTeamContextProjectionState, limit: number): readonly TimelineCandidate[];
217
+ /** Find one resolved checkpoint entry by its stable ref, if it exists. */
218
+ export declare function checkpointByRef(state: AgentTeamContextProjectionState, checkpointRef: string): ContextCheckpointEntry | undefined;
219
+ //# sourceMappingURL=context-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-projection.d.ts","sourceRoot":"","sources":["../../src/context-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAA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W,EAAE,CAE7F;AAaD,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,+BAA+B,EAAE,aAAa,EAAE,6BAA6B,GAAG,OAAO,CAEnI;AAED,0FAA0F;AAC1F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,+BAA+B,EAAE,aAAa,EAAE,6BAA6B,GAAG,+BAA+B,CAG/J;AAsDD,OAAO,EAAE,+BAA+B,EAAE,CAAA;AAE1C,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,gGAAgG;IAChG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,CAAA;IAC9E,wEAAwE;IACxE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,+BAA+B,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,iBAAiB,EAAE,CAgBtH;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,KAAK,EAAE,+BAA+B,EAAE,aAAa,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEjI"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Plugin-attributed message sources for Agent Team context management.
3
+ *
4
+ * Both sources ride ordinary `UserMessage`s under the shipped `plugin` kind
5
+ * with the `snapshot` context form — the same shape the Harness's own
6
+ * system-prompt producer writes. This module declares no `MessageSourceMap`
7
+ * member of its own, and carries no bespoke source members: Session format
8
+ * migration validates a `plugin` source against a closed member list
9
+ * (`kind`, `plugin`, `form`, `sections`, `summary`), and refuses every logged
10
+ * Session that carries anything else. A plugin-declared kind is type-legal yet
11
+ * refused the same way. See `docs/dsh-release-compatibility.md`
12
+ * § "Session message sources".
13
+ *
14
+ * Everything the Host needs to read back therefore rides the admitted payload
15
+ * slots: the handoff envelope and the checkpoint correlation both travel as
16
+ * named {@link ContextSnapshotSection} contributions, distinguished by their
17
+ * stable section names. Sections are the format's designed slot for structured
18
+ * producer payload, and they render as named contributions on any
19
+ * snapshot-aware surface.
20
+ *
21
+ * The validators below are the single place that recognizes these messages, so
22
+ * callers never match on localized body text.
23
+ * @module @wowyuarm/dsh-agent-team/context-source
24
+ */
25
+ import type { ContextSnapshotSection, UserMessage } from '@deepseek-ai/dsh-llm';
26
+ /** Plugin identity attributing every Agent Team message source. */
27
+ export declare const AGENT_TEAM_PLUGIN_ID = "@wowyuarm/dsh-agent-team";
28
+ /** Handoff snapshot section name carrying the model-authored prose. */
29
+ export declare const HANDOFF_SECTION_NAME = "HANDOFF";
30
+ /** Stable section name marking a checkpoint continuation and carrying its ref. */
31
+ export declare const CHECKPOINT_SECTION_NAME = "Checkpoint";
32
+ /** Fixed text of the quiet checkpoint continuation delivered on the next turn. */
33
+ export declare const CHECKPOINT_CONTINUATION_TEXT = "A context checkpoint was recorded at the end of the previous turn. Continue the work you were doing.";
34
+ /**
35
+ * The rollover handoff envelope: the model-authored prose plus the verifiable
36
+ * Host facts, all as named snapshot contributions.
37
+ */
38
+ export interface AgentTeamContextHandoff {
39
+ /** The Member's Session before this rollover. */
40
+ readonly previousSessionId: string;
41
+ /** The rollover generation this handoff opened. */
42
+ readonly newSessionId: string;
43
+ /** Why the rollover happened. */
44
+ readonly trigger: 'model' | 'pressure';
45
+ /** Seq of the successful `context_rollover` tool result in the previous Session log. */
46
+ readonly handoffEventSeq: number;
47
+ /** The checkpoint a return was seeded from; absent on a fresh rollover. */
48
+ readonly checkpointRef?: string;
49
+ /** Workspace paths the handoff called out as relevant. */
50
+ readonly relatedFiles?: readonly string[];
51
+ /** Named contributions, starting with the model-authored handoff prose. */
52
+ readonly sections: readonly ContextSnapshotSection[];
53
+ }
54
+ /**
55
+ * Build the first model-facing context of one rollover generation. The Host
56
+ * owns only the verifiable envelope; the prose is the Member's own handoff.
57
+ *
58
+ * The envelope sections are additive structure, not the only carrier of these
59
+ * facts: {@link handoffBody} already states them in the model-facing text, so a
60
+ * surface that renders only the body loses nothing.
61
+ */
62
+ export declare function createHandoffMessage(input: {
63
+ readonly handoff: string;
64
+ readonly previousSessionId: string;
65
+ readonly newSessionId: string;
66
+ readonly trigger: 'model' | 'pressure';
67
+ readonly handoffEventSeq: number;
68
+ readonly checkpointRef?: string;
69
+ readonly relatedFiles?: readonly {
70
+ readonly path: string;
71
+ readonly reason?: string;
72
+ }[];
73
+ }): UserMessage;
74
+ /**
75
+ * Build the quiet follow-up that continues work after an explicit checkpoint
76
+ * concluded its turn. Delivery is scheduled only after the checkpoint's
77
+ * successful tool result is durable, so a result-render failure can never
78
+ * leave a ghost continuation behind.
79
+ *
80
+ * This is a `snapshot` rather than a `notice` for one reason: the projection
81
+ * must read the checkpoint ref back out of the durable log to record delivery,
82
+ * and `sections` is the only admitted payload slot that carries structure. A
83
+ * notice would have forced the ref into its human-readable one-line summary.
84
+ */
85
+ export declare function createCheckpointContinuationMessage(checkpointRef: string): UserMessage;
86
+ /**
87
+ * The rollover handoff one message carries, when it is one.
88
+ * @param message - candidate user message.
89
+ * @returns the envelope, or `undefined` when the message is not a handoff.
90
+ */
91
+ export declare function handoffOf(message: UserMessage): AgentTeamContextHandoff | undefined;
92
+ /**
93
+ * The checkpoint ref one continuation notice carries, when the message is one.
94
+ * @param message - candidate user message.
95
+ * @returns the checkpoint ref, or `undefined` when the message is not a continuation.
96
+ */
97
+ export declare function continuationCheckpointRefOf(message: UserMessage): string | undefined;
98
+ /** Whether one user message is a rollover handoff snapshot. */
99
+ export declare function isHandoffMessage(message: UserMessage): boolean;
100
+ /** Whether one user message is a checkpoint continuation, optionally for one checkpoint. */
101
+ export declare function isCheckpointContinuationMessage(message: UserMessage, checkpointRef?: string): boolean;
102
+ /**
103
+ * Whether one message carries a rollover-handoff or checkpoint-continuation
104
+ * envelope. Ordinary Team notices share this plugin's attribution, so callers
105
+ * that replace rederived notices must exclude these two families explicitly.
106
+ */
107
+ export declare function isAgentTeamContextSource(message: UserMessage): boolean;
108
+ /** Envelope section names; stable, because they are read back from the log.
109
+ * Exported for the legacy-artifact remediation, which rewrites pre-0.1.10
110
+ * envelopes into exactly these names — one shared vocabulary, no drift. */
111
+ export declare const HANDOFF_PREVIOUS_SESSION = "Previous session";
112
+ export declare const HANDOFF_NEW_SESSION = "New session";
113
+ export declare const HANDOFF_TRIGGER = "Trigger";
114
+ export declare const HANDOFF_EVENT_SEQ = "Handoff event seq";
115
+ export declare const HANDOFF_CHECKPOINT = "Continued from checkpoint";
116
+ export declare const HANDOFF_RELATED_FILES = "Related files";
117
+ //# sourceMappingURL=context-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-source.d.ts","sourceRoot":"","sources":["../../src/context-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAG/E,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAE9D,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,YAAY,CAAA;AAE7C,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,eAAe,CAAA;AAEnD,kFAAkF;AAClF,eAAO,MAAM,4BAA4B,yGAAyG,CAAA;AAElJ;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,mDAAmD;IACnD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAA;IACtC,wFAAwF;IACxF,QAAQ,CAAC,eAAe,EAAE,M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