@wowyuarm/dsh-agent-team 0.1.9 → 0.1.11

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 (119) hide show
  1. package/README.md +17 -11
  2. package/README.zh.md +17 -11
  3. package/package.json +61 -47
  4. package/packages/agent-team/README.md +6 -4
  5. package/packages/agent-team/README.zh.md +6 -3
  6. package/packages/agent-team/lib/context-management.js +48 -55
  7. package/packages/agent-team/lib/context-projection.js +22 -8
  8. package/packages/agent-team/lib/context-source.js +163 -23
  9. package/packages/agent-team/lib/index.js +349 -176
  10. package/packages/agent-team/lib/invariant.js +38 -4
  11. package/packages/agent-team/lib/ledger.js +658 -294
  12. package/packages/agent-team/lib/member-context.js +6 -2
  13. package/packages/agent-team/lib/member-time-context.js +141 -0
  14. package/packages/agent-team/lib/pressure-policy.js +34 -11
  15. package/packages/agent-team/lib/progress-nudge.js +12 -4
  16. package/packages/agent-team/lib/session-event-cursor.js +116 -0
  17. package/packages/agent-team/lib/session-remediation.js +493 -0
  18. package/packages/agent-team/lib/spec.js +49 -36
  19. package/packages/agent-team/lib/stored-session-reader.js +138 -0
  20. package/packages/agent-team/lib/time-format.js +56 -0
  21. package/packages/agent-team/lib/typert.host.js +163 -63
  22. package/packages/agent-team/lib/typert.remote-client.d.ts.map +1 -1
  23. package/packages/agent-team/lib/typert.remote-client.js +105 -32
  24. package/packages/agent-team/lib/types/context-management.d.ts +13 -1
  25. package/packages/agent-team/lib/types/context-management.d.ts.map +1 -1
  26. package/packages/agent-team/lib/types/context-projection.d.ts +8 -0
  27. package/packages/agent-team/lib/types/context-projection.d.ts.map +1 -1
  28. package/packages/agent-team/lib/types/context-source.d.ts +70 -36
  29. package/packages/agent-team/lib/types/context-source.d.ts.map +1 -1
  30. package/packages/agent-team/lib/types/index.d.ts +110 -9
  31. package/packages/agent-team/lib/types/index.d.ts.map +1 -1
  32. package/packages/agent-team/lib/types/invariant.d.ts.map +1 -1
  33. package/packages/agent-team/lib/types/ledger.d.ts +205 -7
  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-time-context.d.ts +83 -0
  37. package/packages/agent-team/lib/types/member-time-context.d.ts.map +1 -0
  38. package/packages/agent-team/lib/types/pressure-policy.d.ts +18 -0
  39. package/packages/agent-team/lib/types/pressure-policy.d.ts.map +1 -1
  40. package/packages/agent-team/lib/types/progress-nudge.d.ts.map +1 -1
  41. package/packages/agent-team/lib/types/session-event-cursor.d.ts +119 -0
  42. package/packages/agent-team/lib/types/session-event-cursor.d.ts.map +1 -0
  43. package/packages/agent-team/lib/types/session-remediation.d.ts +172 -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/stored-session-reader.d.ts +92 -0
  47. package/packages/agent-team/lib/types/stored-session-reader.d.ts.map +1 -0
  48. package/packages/agent-team/lib/types/time-format.d.ts +28 -0
  49. package/packages/agent-team/lib/types/time-format.d.ts.map +1 -0
  50. package/packages/agent-team/lib/types/types/entities.d.ts +36 -2
  51. package/packages/agent-team/lib/types/types/entities.d.ts.map +1 -1
  52. package/packages/agent-team/lib/types/types/operations.d.ts +45 -19
  53. package/packages/agent-team/lib/types/types/operations.d.ts.map +1 -1
  54. package/packages/agent-team/lib/types/types/requests-results.d.ts +50 -3
  55. package/packages/agent-team/lib/types/types/requests-results.d.ts.map +1 -1
  56. package/packages/agent-team/preset/team-member/agent.cordis.yml +21 -4
  57. package/packages/client-agent-team/README.md +1 -1
  58. package/packages/client-agent-team/README.zh.md +1 -1
  59. package/packages/client-agent-team/lib/client.js +1121 -402
  60. package/packages/client-agent-team/lib/client.js.map +1 -1
  61. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.d.ts.map +1 -1
  62. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.js +24 -4
  63. package/packages/client-agent-team/lib/types/client/TeamChannelPage.d.ts.map +1 -1
  64. package/packages/client-agent-team/lib/types/client/TeamChannelPage.js +42 -22
  65. package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.d.ts.map +1 -1
  66. package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.js +13 -24
  67. package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts +11 -5
  68. package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts.map +1 -1
  69. package/packages/client-agent-team/lib/types/client/TeamComposer.js +15 -9
  70. package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts +1 -1
  71. package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts.map +1 -1
  72. package/packages/client-agent-team/lib/types/client/TeamConversation.js +8 -1
  73. package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts +21 -0
  74. package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts.map +1 -0
  75. package/packages/client-agent-team/lib/types/client/TeamInboxPage.js +71 -0
  76. package/packages/client-agent-team/lib/types/client/TeamMemberEditor.d.ts.map +1 -1
  77. package/packages/client-agent-team/lib/types/client/TeamMemberEditor.js +8 -24
  78. package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts +9 -2
  79. package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts.map +1 -1
  80. package/packages/client-agent-team/lib/types/client/TeamMessage.js +13 -6
  81. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts +8 -0
  82. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts.map +1 -1
  83. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.js +21 -1
  84. package/packages/client-agent-team/lib/types/client/TeamThreadPage.d.ts.map +1 -1
  85. package/packages/client-agent-team/lib/types/client/TeamThreadPage.js +106 -32
  86. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts +1 -1
  87. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts.map +1 -1
  88. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.js +50 -7
  89. package/packages/client-agent-team/lib/types/client/index.d.ts.map +1 -1
  90. package/packages/client-agent-team/lib/types/client/index.js +25 -9
  91. package/packages/client-agent-team/lib/types/client/locales.d.ts +18 -0
  92. package/packages/client-agent-team/lib/types/client/locales.d.ts.map +1 -1
  93. package/packages/client-agent-team/lib/types/client/locales.js +18 -0
  94. package/packages/client-agent-team/lib/types/client/navigation.d.ts +10 -0
  95. package/packages/client-agent-team/lib/types/client/navigation.d.ts.map +1 -1
  96. package/packages/client-agent-team/lib/types/client/navigation.js +18 -7
  97. package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts +41 -0
  98. package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts.map +1 -0
  99. package/packages/client-agent-team/lib/types/client/scope-coverage.js +64 -0
  100. package/packages/client-agent-team/lib/types/client/slots.d.ts +8 -2
  101. package/packages/client-agent-team/lib/types/client/slots.d.ts.map +1 -1
  102. package/packages/client-agent-team/lib/types/client/team-changes.d.ts +26 -1
  103. package/packages/client-agent-team/lib/types/client/team-changes.d.ts.map +1 -1
  104. package/packages/client-agent-team/lib/types/client/team-changes.js +66 -15
  105. package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts +20 -0
  106. package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts.map +1 -0
  107. package/packages/client-agent-team/lib/types/client/team-dialog-save.js +36 -0
  108. package/packages/client-agent-team/lib/types/client/team-formatters.d.ts +9 -0
  109. package/packages/client-agent-team/lib/types/client/team-formatters.d.ts.map +1 -1
  110. package/packages/client-agent-team/lib/types/client/team-formatters.js +34 -6
  111. package/packages/tool-agent-team/README.md +8 -6
  112. package/packages/tool-agent-team/README.zh.md +8 -6
  113. package/packages/tool-agent-team/lib/context-tools.js +18 -14
  114. package/packages/tool-agent-team/lib/host-access.js +20 -0
  115. package/packages/tool-agent-team/lib/index.js +314 -123
  116. package/packages/tool-agent-team/lib/types/context-tools.d.ts.map +1 -1
  117. package/packages/tool-agent-team/lib/types/host-access.d.ts +14 -0
  118. package/packages/tool-agent-team/lib/types/host-access.d.ts.map +1 -0
  119. package/packages/tool-agent-team/lib/types/index.d.ts.map +1 -1
@@ -1,35 +1,52 @@
1
1
  /**
2
- * Merge-extended message sources for Agent Team context management.
2
+ * Plugin-attributed message sources for Agent Team context management.
3
3
  *
4
- * The sources ride ordinary `UserMessage`s and never add a Harness
5
- * `ContextForm`: the handoff snapshot reuses the shipped `snapshot` form, the
6
- * quieter notices reuse `notice`. Predicates here are the single place that
7
- * recognizes these notices, so callers never match on localized body text.
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.
8
23
  * @module @wowyuarm/dsh-agent-team/context-source
9
24
  */
10
25
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
11
- /** Stable one-line account for checkpoint continuation notices. */
12
- export const CONTEXT_CONTINUATION_NOTICE_SUMMARY = 'Context checkpoint recorded; work continues in the next turn';
26
+ /** Plugin identity attributing every Agent Team message source. */
27
+ export const AGENT_TEAM_PLUGIN_ID = '@wowyuarm/dsh-agent-team';
13
28
  /** Handoff snapshot section name carrying the model-authored prose. */
14
29
  export const HANDOFF_SECTION_NAME = 'HANDOFF';
30
+ /** Stable section name marking a checkpoint continuation and carrying its ref. */
31
+ export const CHECKPOINT_SECTION_NAME = 'Checkpoint';
32
+ /** Fixed text of the quiet checkpoint continuation delivered on the next turn. */
33
+ export const CHECKPOINT_CONTINUATION_TEXT = 'A context checkpoint was recorded at the end of the previous turn. Continue the work you were doing.';
15
34
  /**
16
35
  * Build the first model-facing context of one rollover generation. The Host
17
36
  * owns only the verifiable envelope; the prose is the Member's own handoff.
37
+ *
38
+ * The envelope sections are additive structure, not the only carrier of these
39
+ * facts: {@link handoffBody} already states them in the model-facing text, so a
40
+ * surface that renders only the body loses nothing.
18
41
  */
19
42
  export function createHandoffMessage(input) {
20
43
  return createUserMessage({
21
44
  content: [{ type: 'text', text: handoffBody(input) }],
22
45
  source: {
23
- kind: 'agent-team-context-handoff',
46
+ kind: 'plugin',
47
+ plugin: AGENT_TEAM_PLUGIN_ID,
24
48
  form: 'snapshot',
25
- version: 1,
26
- previousSessionId: input.previousSessionId,
27
- newSessionId: input.newSessionId,
28
- trigger: input.trigger,
29
- handoffEventSeq: input.handoffEventSeq,
30
- ...(input.checkpointRef === undefined ? {} : { checkpointRef: input.checkpointRef }),
31
- ...(input.relatedFiles === undefined || input.relatedFiles.length === 0 ? {} : { relatedFiles: input.relatedFiles.map(file => file.path) }),
32
- sections: [{ name: HANDOFF_SECTION_NAME, text: input.handoff }],
49
+ sections: handoffSections(input),
33
50
  },
34
51
  });
35
52
  }
@@ -38,22 +55,145 @@ export function createHandoffMessage(input) {
38
55
  * concluded its turn. Delivery is scheduled only after the checkpoint's
39
56
  * successful tool result is durable, so a result-render failure can never
40
57
  * leave a ghost continuation behind.
58
+ *
59
+ * This is a `snapshot` rather than a `notice` for one reason: the projection
60
+ * must read the checkpoint ref back out of the durable log to record delivery,
61
+ * and `sections` is the only admitted payload slot that carries structure. A
62
+ * notice would have forced the ref into its human-readable one-line summary.
41
63
  */
42
64
  export function createCheckpointContinuationMessage(checkpointRef) {
43
65
  return createUserMessage({
44
- content: [{ type: 'text', text: 'A context checkpoint was recorded at the end of the previous turn. Continue the work you were doing.' }],
45
- source: { kind: 'agent-team-context-continuation', form: 'notice', summary: CONTEXT_CONTINUATION_NOTICE_SUMMARY, checkpointRef, version: 1 },
66
+ content: [{ type: 'text', text: CHECKPOINT_CONTINUATION_TEXT }],
67
+ source: {
68
+ kind: 'plugin',
69
+ plugin: AGENT_TEAM_PLUGIN_ID,
70
+ form: 'snapshot',
71
+ sections: [{ name: CHECKPOINT_SECTION_NAME, text: checkpointRef }],
72
+ },
46
73
  });
47
74
  }
75
+ /**
76
+ * Read one message's snapshot sections when it is this plugin's own snapshot.
77
+ * @param message - candidate user message.
78
+ * @returns the sections, or `undefined` when another producer owns the message.
79
+ */
80
+ function ownSections(message) {
81
+ const source = message.source;
82
+ if (source.kind !== 'plugin' || source.plugin !== AGENT_TEAM_PLUGIN_ID)
83
+ return undefined;
84
+ if (source.form !== 'snapshot')
85
+ return undefined;
86
+ return source.sections;
87
+ }
88
+ /** The text of one named section, or undefined when it is absent. */
89
+ function sectionText(sections, name) {
90
+ return sections.find(section => section.name === name)?.text;
91
+ }
92
+ /**
93
+ * Decode the `Related files` section. The Host writes the exact path array as
94
+ * JSON, which round-trips every path a file system admits — including one
95
+ * containing a comma, which the `', '`-joined form this replaced could not.
96
+ * Sections written before that encoding are still read; the legacy split is a
97
+ * read-side accommodation for old generations, never a write path.
98
+ */
99
+ function parseRelatedFiles(text) {
100
+ try {
101
+ const parsed = JSON.parse(text);
102
+ if (Array.isArray(parsed) && parsed.every(path => typeof path === 'string' && path.length > 0)) {
103
+ return parsed;
104
+ }
105
+ }
106
+ catch {
107
+ // Not JSON: the section predates the JSON encoding.
108
+ }
109
+ return text.split(', ').filter(path => path.length > 0);
110
+ }
111
+ /**
112
+ * The rollover handoff one message carries, when it is one.
113
+ * @param message - candidate user message.
114
+ * @returns the envelope, or `undefined` when the message is not a handoff.
115
+ */
116
+ export function handoffOf(message) {
117
+ const sections = ownSections(message);
118
+ if (sections === undefined)
119
+ return undefined;
120
+ const handoff = sectionText(sections, HANDOFF_SECTION_NAME);
121
+ if (handoff === undefined)
122
+ return undefined;
123
+ const previousSessionId = sectionText(sections, HANDOFF_PREVIOUS_SESSION);
124
+ const newSessionId = sectionText(sections, HANDOFF_NEW_SESSION);
125
+ const trigger = sectionText(sections, HANDOFF_TRIGGER);
126
+ const handoffEventSeq = sectionText(sections, HANDOFF_EVENT_SEQ);
127
+ if (previousSessionId === undefined || newSessionId === undefined)
128
+ return undefined;
129
+ if (trigger !== 'model' && trigger !== 'pressure')
130
+ return undefined;
131
+ const seq = Number(handoffEventSeq);
132
+ if (handoffEventSeq === undefined || !Number.isSafeInteger(seq))
133
+ return undefined;
134
+ const checkpointRef = sectionText(sections, HANDOFF_CHECKPOINT);
135
+ const relatedFiles = sectionText(sections, HANDOFF_RELATED_FILES);
136
+ return {
137
+ previousSessionId,
138
+ newSessionId,
139
+ trigger,
140
+ handoffEventSeq: seq,
141
+ ...(checkpointRef === undefined ? {} : { checkpointRef }),
142
+ ...(relatedFiles === undefined ? {} : { relatedFiles: parseRelatedFiles(relatedFiles) }),
143
+ sections,
144
+ };
145
+ }
146
+ /**
147
+ * The checkpoint ref one continuation notice carries, when the message is one.
148
+ * @param message - candidate user message.
149
+ * @returns the checkpoint ref, or `undefined` when the message is not a continuation.
150
+ */
151
+ export function continuationCheckpointRefOf(message) {
152
+ const sections = ownSections(message);
153
+ if (sections === undefined || sections.length !== 1)
154
+ return undefined;
155
+ const ref = sectionText(sections, CHECKPOINT_SECTION_NAME);
156
+ return ref === undefined || ref.length === 0 ? undefined : ref;
157
+ }
48
158
  /** Whether one user message is a rollover handoff snapshot. */
49
159
  export function isHandoffMessage(message) {
50
- return message.source.kind === 'agent-team-context-handoff';
160
+ return handoffOf(message) !== undefined;
51
161
  }
52
- /** Whether one user message is a checkpoint continuation notice, optionally for one checkpoint. */
162
+ /** Whether one user message is a checkpoint continuation, optionally for one checkpoint. */
53
163
  export function isCheckpointContinuationMessage(message, checkpointRef) {
54
- const source = message.source;
55
- return source.kind === 'agent-team-context-continuation'
56
- && (checkpointRef === undefined || source.checkpointRef === checkpointRef);
164
+ const ref = continuationCheckpointRefOf(message);
165
+ return ref !== undefined && (checkpointRef === undefined || ref === checkpointRef);
166
+ }
167
+ /**
168
+ * Whether one message carries a rollover-handoff or checkpoint-continuation
169
+ * envelope. Ordinary Team notices share this plugin's attribution, so callers
170
+ * that replace rederived notices must exclude these two families explicitly.
171
+ */
172
+ export function isAgentTeamContextSource(message) {
173
+ return isHandoffMessage(message) || isCheckpointContinuationMessage(message);
174
+ }
175
+ /** Envelope section names; stable, because they are read back from the log.
176
+ * Exported for the legacy-artifact remediation, which rewrites pre-0.1.10
177
+ * envelopes into exactly these names — one shared vocabulary, no drift. */
178
+ export const HANDOFF_PREVIOUS_SESSION = 'Previous session';
179
+ export const HANDOFF_NEW_SESSION = 'New session';
180
+ export const HANDOFF_TRIGGER = 'Trigger';
181
+ export const HANDOFF_EVENT_SEQ = 'Handoff event seq';
182
+ export const HANDOFF_CHECKPOINT = 'Continued from checkpoint';
183
+ export const HANDOFF_RELATED_FILES = 'Related files';
184
+ /** The envelope contributions of one handoff, prose first. */
185
+ function handoffSections(input) {
186
+ return [
187
+ { name: HANDOFF_SECTION_NAME, text: input.handoff },
188
+ { name: HANDOFF_PREVIOUS_SESSION, text: input.previousSessionId },
189
+ { name: HANDOFF_NEW_SESSION, text: input.newSessionId },
190
+ { name: HANDOFF_TRIGGER, text: input.trigger },
191
+ { name: HANDOFF_EVENT_SEQ, text: String(input.handoffEventSeq) },
192
+ ...(input.checkpointRef === undefined ? [] : [{ name: HANDOFF_CHECKPOINT, text: input.checkpointRef }]),
193
+ ...(input.relatedFiles === undefined || input.relatedFiles.length === 0
194
+ ? []
195
+ : [{ name: HANDOFF_RELATED_FILES, text: JSON.stringify(input.relatedFiles.map(file => file.path)) }]),
196
+ ];
57
197
  }
58
198
  function handoffBody(input) {
59
199
  const lines = [