@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.
- package/README.md +17 -11
- package/README.zh.md +17 -11
- package/package.json +61 -47
- package/packages/agent-team/README.md +6 -4
- package/packages/agent-team/README.zh.md +6 -3
- package/packages/agent-team/lib/context-management.js +48 -55
- package/packages/agent-team/lib/context-projection.js +22 -8
- package/packages/agent-team/lib/context-source.js +163 -23
- package/packages/agent-team/lib/index.js +349 -176
- package/packages/agent-team/lib/invariant.js +38 -4
- package/packages/agent-team/lib/ledger.js +658 -294
- package/packages/agent-team/lib/member-context.js +6 -2
- package/packages/agent-team/lib/member-time-context.js +141 -0
- package/packages/agent-team/lib/pressure-policy.js +34 -11
- package/packages/agent-team/lib/progress-nudge.js +12 -4
- package/packages/agent-team/lib/session-event-cursor.js +116 -0
- package/packages/agent-team/lib/session-remediation.js +493 -0
- package/packages/agent-team/lib/spec.js +49 -36
- package/packages/agent-team/lib/stored-session-reader.js +138 -0
- package/packages/agent-team/lib/time-format.js +56 -0
- package/packages/agent-team/lib/typert.host.js +163 -63
- package/packages/agent-team/lib/typert.remote-client.d.ts.map +1 -1
- package/packages/agent-team/lib/typert.remote-client.js +105 -32
- package/packages/agent-team/lib/types/context-management.d.ts +13 -1
- package/packages/agent-team/lib/types/context-management.d.ts.map +1 -1
- package/packages/agent-team/lib/types/context-projection.d.ts +8 -0
- package/packages/agent-team/lib/types/context-projection.d.ts.map +1 -1
- package/packages/agent-team/lib/types/context-source.d.ts +70 -36
- package/packages/agent-team/lib/types/context-source.d.ts.map +1 -1
- package/packages/agent-team/lib/types/index.d.ts +110 -9
- package/packages/agent-team/lib/types/index.d.ts.map +1 -1
- package/packages/agent-team/lib/types/invariant.d.ts.map +1 -1
- package/packages/agent-team/lib/types/ledger.d.ts +205 -7
- package/packages/agent-team/lib/types/ledger.d.ts.map +1 -1
- package/packages/agent-team/lib/types/member-context.d.ts.map +1 -1
- package/packages/agent-team/lib/types/member-time-context.d.ts +83 -0
- package/packages/agent-team/lib/types/member-time-context.d.ts.map +1 -0
- package/packages/agent-team/lib/types/pressure-policy.d.ts +18 -0
- package/packages/agent-team/lib/types/pressure-policy.d.ts.map +1 -1
- package/packages/agent-team/lib/types/progress-nudge.d.ts.map +1 -1
- package/packages/agent-team/lib/types/session-event-cursor.d.ts +119 -0
- package/packages/agent-team/lib/types/session-event-cursor.d.ts.map +1 -0
- package/packages/agent-team/lib/types/session-remediation.d.ts +172 -0
- package/packages/agent-team/lib/types/session-remediation.d.ts.map +1 -0
- package/packages/agent-team/lib/types/spec.d.ts.map +1 -1
- package/packages/agent-team/lib/types/stored-session-reader.d.ts +92 -0
- package/packages/agent-team/lib/types/stored-session-reader.d.ts.map +1 -0
- package/packages/agent-team/lib/types/time-format.d.ts +28 -0
- package/packages/agent-team/lib/types/time-format.d.ts.map +1 -0
- package/packages/agent-team/lib/types/types/entities.d.ts +36 -2
- package/packages/agent-team/lib/types/types/entities.d.ts.map +1 -1
- package/packages/agent-team/lib/types/types/operations.d.ts +45 -19
- package/packages/agent-team/lib/types/types/operations.d.ts.map +1 -1
- package/packages/agent-team/lib/types/types/requests-results.d.ts +50 -3
- package/packages/agent-team/lib/types/types/requests-results.d.ts.map +1 -1
- package/packages/agent-team/preset/team-member/agent.cordis.yml +21 -4
- package/packages/client-agent-team/README.md +1 -1
- package/packages/client-agent-team/README.zh.md +1 -1
- package/packages/client-agent-team/lib/client.js +1121 -402
- package/packages/client-agent-team/lib/client.js.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.js +24 -4
- package/packages/client-agent-team/lib/types/client/TeamChannelPage.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamChannelPage.js +42 -22
- package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.js +13 -24
- package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts +11 -5
- package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamComposer.js +15 -9
- package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts +1 -1
- package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamConversation.js +8 -1
- package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts +21 -0
- package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/TeamInboxPage.js +71 -0
- package/packages/client-agent-team/lib/types/client/TeamMemberEditor.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamMemberEditor.js +8 -24
- package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts +9 -2
- package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamMessage.js +13 -6
- package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts +8 -0
- package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamPresenceDot.js +21 -1
- package/packages/client-agent-team/lib/types/client/TeamThreadPage.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamThreadPage.js +106 -32
- package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts +1 -1
- package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.js +50 -7
- package/packages/client-agent-team/lib/types/client/index.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/index.js +25 -9
- package/packages/client-agent-team/lib/types/client/locales.d.ts +18 -0
- package/packages/client-agent-team/lib/types/client/locales.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/locales.js +18 -0
- package/packages/client-agent-team/lib/types/client/navigation.d.ts +10 -0
- package/packages/client-agent-team/lib/types/client/navigation.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/navigation.js +18 -7
- package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts +41 -0
- package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/scope-coverage.js +64 -0
- package/packages/client-agent-team/lib/types/client/slots.d.ts +8 -2
- package/packages/client-agent-team/lib/types/client/slots.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/team-changes.d.ts +26 -1
- package/packages/client-agent-team/lib/types/client/team-changes.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/team-changes.js +66 -15
- package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts +20 -0
- package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/team-dialog-save.js +36 -0
- package/packages/client-agent-team/lib/types/client/team-formatters.d.ts +9 -0
- package/packages/client-agent-team/lib/types/client/team-formatters.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/team-formatters.js +34 -6
- package/packages/tool-agent-team/README.md +8 -6
- package/packages/tool-agent-team/README.zh.md +8 -6
- package/packages/tool-agent-team/lib/context-tools.js +18 -14
- package/packages/tool-agent-team/lib/host-access.js +20 -0
- package/packages/tool-agent-team/lib/index.js +314 -123
- package/packages/tool-agent-team/lib/types/context-tools.d.ts.map +1 -1
- package/packages/tool-agent-team/lib/types/host-access.d.ts +14 -0
- package/packages/tool-agent-team/lib/types/host-access.d.ts.map +1 -0
- package/packages/tool-agent-team/lib/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Team's single seam for reading stored Sessions.
|
|
3
|
+
*
|
|
4
|
+
* Every per-Session read the Host performs goes through here: one
|
|
5
|
+
* `open → read → close` cycle whose handle lifecycle is guaranteed closed,
|
|
6
|
+
* and whose failures are normalized into the five categories consumers choose
|
|
7
|
+
* policy by. Callers never touch a `SessionHandle`, an artifact path, a
|
|
8
|
+
* format generation, or Harness error message text.
|
|
9
|
+
*
|
|
10
|
+
* The reader owns reading and classification only — not Member lifecycle,
|
|
11
|
+
* Agent create/resume, UI, ledger, or remediation (which reads raw artifact
|
|
12
|
+
* bytes through its own repair path).
|
|
13
|
+
*
|
|
14
|
+
* Classification notes: the shipped JSONL backend throws its
|
|
15
|
+
* `corrupt session log` family as plain `Error`s, so corruption is detected by
|
|
16
|
+
* that stable message prefix (an upstream gap; if the text ever changes the
|
|
17
|
+
* failure degrades to `unknown`, which consumers treat conservatively —
|
|
18
|
+
* blocking rather than silently skipping). Typed refusals are also matched
|
|
19
|
+
* through `error.cause` chains because the Harness agent layer wraps
|
|
20
|
+
* persistence failures during resume.
|
|
21
|
+
* @module @wowyuarm/dsh-agent-team/stored-session-reader
|
|
22
|
+
*/
|
|
23
|
+
import { SessionFormatUnsupportedError, SessionPersistenceCorruptionError, SessionPersistenceNotFoundError, } from '@deepseek-ai/dsh-session-persistence';
|
|
24
|
+
/**
|
|
25
|
+
* A call site's session-read failure, carrying the typed classification so
|
|
26
|
+
* activation can route the diagnostic without re-matching error text.
|
|
27
|
+
*/
|
|
28
|
+
export class StoredSessionReadError extends Error {
|
|
29
|
+
failure;
|
|
30
|
+
constructor(message, failure) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.failure = failure;
|
|
33
|
+
this.name = 'StoredSessionReadError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** How deep to follow `error.cause` chains looking for a typed session failure. */
|
|
37
|
+
const MAX_CAUSE_DEPTH = 4;
|
|
38
|
+
/** The JSONL backend's stable corruption-message prefix (plain `Error`s, not typed). */
|
|
39
|
+
const CORRUPT_SESSION_LOG_TEXT = /corrupt session log/;
|
|
40
|
+
function messageOf(error) {
|
|
41
|
+
return error instanceof Error ? error.message : String(error);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The deterministic session-shaped classification of one error value:
|
|
45
|
+
* typed Harness failures plus the corruption message family. A system error
|
|
46
|
+
* code is deliberately NOT matched here — outside the reader an fs error may
|
|
47
|
+
* come from unrelated work (private memory, attachment cache), so only the
|
|
48
|
+
* reader itself, where the failed operation is known to be a session read,
|
|
49
|
+
* may classify an fs error as `io`.
|
|
50
|
+
*/
|
|
51
|
+
function sessionClassOf(error) {
|
|
52
|
+
if (error instanceof SessionPersistenceNotFoundError)
|
|
53
|
+
return { kind: 'missing' };
|
|
54
|
+
if (error instanceof SessionFormatUnsupportedError) {
|
|
55
|
+
return { kind: 'refused', ...(error.location === undefined ? {} : { location: error.location }) };
|
|
56
|
+
}
|
|
57
|
+
if (error instanceof SessionPersistenceCorruptionError)
|
|
58
|
+
return { kind: 'corrupt' };
|
|
59
|
+
if (error instanceof Error && CORRUPT_SESSION_LOG_TEXT.test(error.message))
|
|
60
|
+
return { kind: 'corrupt' };
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/** The first session-shaped classification in an error's cause chain, with the matched error for its message. */
|
|
64
|
+
function sessionClassInChain(error) {
|
|
65
|
+
let current = error;
|
|
66
|
+
for (let depth = 0; current !== undefined && current !== null && depth <= MAX_CAUSE_DEPTH; depth += 1) {
|
|
67
|
+
const classified = sessionClassOf(current);
|
|
68
|
+
if (classified !== undefined)
|
|
69
|
+
return { classified, matched: current };
|
|
70
|
+
current = current instanceof Error ? current.cause : undefined;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Classify any failure as a stored-Session read failure. Total: unmatched
|
|
76
|
+
* errors become `unknown`, and a direct system error code becomes `io` —
|
|
77
|
+
* call this only where the failed operation is known to be a session read.
|
|
78
|
+
*/
|
|
79
|
+
export function classifyStoredSessionFailure(error, sessionId) {
|
|
80
|
+
const inChain = sessionClassInChain(error);
|
|
81
|
+
if (inChain !== undefined) {
|
|
82
|
+
return { kind: inChain.classified.kind, sessionId, detail: messageOf(inChain.matched), ...('location' in inChain.classified ? { location: inChain.classified.location } : {}) };
|
|
83
|
+
}
|
|
84
|
+
if (error !== null && typeof error === 'object' && typeof error.code === 'string') {
|
|
85
|
+
return { kind: 'io', sessionId, detail: messageOf(error) };
|
|
86
|
+
}
|
|
87
|
+
return { kind: 'unknown', sessionId, detail: messageOf(error) };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The session-shaped failure carried by an arbitrary error, when it carries
|
|
91
|
+
* one at all: deterministic markers (typed classes, the corruption message
|
|
92
|
+
* family) are matched through the cause chain; transient fs errors are not —
|
|
93
|
+
* outside the reader they are not provably session-related. Activation uses
|
|
94
|
+
* this to route diagnostics; `undefined` means the failure is not
|
|
95
|
+
* session-shaped.
|
|
96
|
+
*/
|
|
97
|
+
export function sessionFailureOf(error, sessionId) {
|
|
98
|
+
const inChain = sessionClassInChain(error);
|
|
99
|
+
if (inChain === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
return { kind: inChain.classified.kind, sessionId, detail: messageOf(inChain.matched), ...('location' in inChain.classified ? { location: inChain.classified.location } : {}) };
|
|
102
|
+
}
|
|
103
|
+
/** Read stored Sessions through one seam: full validated reads with normalized failures. */
|
|
104
|
+
export class StoredSessionReader {
|
|
105
|
+
ctx;
|
|
106
|
+
constructor(ctx) {
|
|
107
|
+
this.ctx = ctx;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Read one stored Session completely. The handle is closed on every path;
|
|
111
|
+
* any failure of open, read, or close is returned as its normalized
|
|
112
|
+
* category, never thrown.
|
|
113
|
+
*/
|
|
114
|
+
async read(sessionId) {
|
|
115
|
+
try {
|
|
116
|
+
const handle = await this.ctx.sessionPersistence.open(sessionId, 'read');
|
|
117
|
+
try {
|
|
118
|
+
const { events } = await handle.read();
|
|
119
|
+
return { ok: true, inspection: { header: handle.header, inheritedEventCount: handle.inheritedEventCount, events } };
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
await handle.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return { ok: false, failure: classifyStoredSessionFailure(error, sessionId) };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether one stored Session has durable persisted content, decided through
|
|
131
|
+
* `stat`: the backend reports a still-draining session through its pending
|
|
132
|
+
* header, so this is the existence probe activation relies on. Only the
|
|
133
|
+
* missing case returns `false`; unexpected errors propagate as before.
|
|
134
|
+
*/
|
|
135
|
+
async exists(sessionId) {
|
|
136
|
+
return (await this.ctx.sessionPersistence.stat(sessionId)) !== undefined;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one agent-facing Team timestamp formatter.
|
|
3
|
+
*
|
|
4
|
+
* Ledger storage keeps UTC ISO instants (`occurredAt` on every operation);
|
|
5
|
+
* rendering converts them into the fixed Team coordination zone UTC+8 with
|
|
6
|
+
* an explicit offset (`2026-09-08T17:00:00+08:00`). The conversion is a
|
|
7
|
+
* fixed offset with no daylight-saving component, so the same stored instant
|
|
8
|
+
* renders byte-identically on every reread path — the context-cache
|
|
9
|
+
* invariant. The Web Client keeps its own browser-local rendering and never
|
|
10
|
+
* passes through this module; a future configuration layer may make the
|
|
11
|
+
* zone configurable, but the render must stay a single deterministic
|
|
12
|
+
* formatter per stored instant.
|
|
13
|
+
* @module @wowyuarm/dsh-agent-team/time-format
|
|
14
|
+
*/
|
|
15
|
+
/** The fixed Team coordination offset from UTC, in minutes. */
|
|
16
|
+
const TEAM_ZONE_OFFSET_MINUTES = 8 * 60;
|
|
17
|
+
/** Rendered offset text, e.g. `+08:00`. */
|
|
18
|
+
const OFFSET_TEXT = '+08:00';
|
|
19
|
+
/**
|
|
20
|
+
* Format one stored UTC ISO instant as the agent-facing Team timestamp.
|
|
21
|
+
* @param occurredAt - stored UTC ISO 8601 instant (ledger `occurredAt`).
|
|
22
|
+
* @returns the fixed-offset UTC+8 rendering, or the input unchanged when it
|
|
23
|
+
* cannot be parsed (never a fabricated time).
|
|
24
|
+
*/
|
|
25
|
+
export function formatTeamTimestamp(occurredAt) {
|
|
26
|
+
const instant = Date.parse(occurredAt);
|
|
27
|
+
if (!Number.isFinite(instant))
|
|
28
|
+
return occurredAt;
|
|
29
|
+
const shifted = new Date(instant + TEAM_ZONE_OFFSET_MINUTES * 60_000);
|
|
30
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
31
|
+
return `${shifted.getUTCFullYear()}-${pad(shifted.getUTCMonth() + 1)}-${pad(shifted.getUTCDate())}`
|
|
32
|
+
+ `T${pad(shifted.getUTCHours())}:${pad(shifted.getUTCMinutes())}:${pad(shifted.getUTCSeconds())}${OFFSET_TEXT}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Format a non-negative elapsed millisecond count as compact whole-second
|
|
36
|
+
* units (`2d 3h 12m 8s`), mirroring the shipped harness time-context
|
|
37
|
+
* vocabulary so both clock families read the same way.
|
|
38
|
+
*/
|
|
39
|
+
export function formatTeamDuration(elapsedMs) {
|
|
40
|
+
let seconds = Math.floor(Math.max(0, elapsedMs) / 1000);
|
|
41
|
+
const days = Math.floor(seconds / 86_400);
|
|
42
|
+
seconds %= 86_400;
|
|
43
|
+
const hours = Math.floor(seconds / 3600);
|
|
44
|
+
seconds %= 3600;
|
|
45
|
+
const minutes = Math.floor(seconds / 60);
|
|
46
|
+
seconds %= 60;
|
|
47
|
+
const parts = [];
|
|
48
|
+
if (days > 0)
|
|
49
|
+
parts.push(`${days}d`);
|
|
50
|
+
if (hours > 0)
|
|
51
|
+
parts.push(`${hours}h`);
|
|
52
|
+
if (minutes > 0)
|
|
53
|
+
parts.push(`${minutes}m`);
|
|
54
|
+
parts.push(`${seconds}s`);
|
|
55
|
+
return parts.join(' ');
|
|
56
|
+
}
|