@wowyuarm/dsh-agent-team 0.2.0 → 0.2.1
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 +5 -5
- package/README.zh.md +5 -5
- package/cordis.patch.yml +26 -12
- package/package.json +50 -47
- package/packages/agent-team/lib/attachments.js +63 -4
- package/packages/agent-team/lib/compaction-engine.js +18 -0
- package/packages/agent-team/lib/context-continuity-host.js +198 -4
- package/packages/agent-team/lib/context-judge.js +150 -0
- package/packages/agent-team/lib/index.js +482 -97
- package/packages/agent-team/lib/invariant.js +36 -12
- package/packages/agent-team/lib/ledger.js +2 -1
- package/packages/agent-team/lib/member-runtime.js +2 -1
- package/packages/agent-team/lib/recovery.js +53 -4
- package/packages/agent-team/lib/typert.host.js +138 -44
- package/packages/agent-team/lib/typert.remote-client.d.ts +3 -1
- package/packages/agent-team/lib/typert.remote-client.d.ts.map +1 -1
- package/packages/agent-team/lib/typert.remote-client.js +75 -35
- package/packages/agent-team/lib/types/attachments.d.ts +32 -2
- package/packages/agent-team/lib/types/attachments.d.ts.map +1 -1
- package/packages/agent-team/lib/types/compaction-engine.d.ts +19 -0
- package/packages/agent-team/lib/types/compaction-engine.d.ts.map +1 -0
- package/packages/agent-team/lib/types/context-continuity-host.d.ts +131 -4
- package/packages/agent-team/lib/types/context-continuity-host.d.ts.map +1 -1
- package/packages/agent-team/lib/types/context-judge.d.ts +82 -0
- package/packages/agent-team/lib/types/context-judge.d.ts.map +1 -0
- package/packages/agent-team/lib/types/index.d.ts +259 -17
- package/packages/agent-team/lib/types/index.d.ts.map +1 -1
- package/packages/agent-team/lib/types/invariant.d.ts +27 -5
- package/packages/agent-team/lib/types/invariant.d.ts.map +1 -1
- package/packages/agent-team/lib/types/ledger.d.ts.map +1 -1
- package/packages/agent-team/lib/types/member-runtime.d.ts +1 -1
- package/packages/agent-team/lib/types/member-runtime.d.ts.map +1 -1
- package/packages/agent-team/lib/types/recovery.d.ts +19 -6
- package/packages/agent-team/lib/types/recovery.d.ts.map +1 -1
- package/packages/agent-team/lib/types/types/requests-results.d.ts +28 -2
- package/packages/agent-team/lib/types/types/requests-results.d.ts.map +1 -1
- package/packages/agent-team/lib/types/types.d.ts +9 -0
- package/packages/agent-team/lib/types/types.d.ts.map +1 -1
- package/packages/client-agent-team/lib/client.js +1006 -374
- package/packages/client-agent-team/lib/client.js.map +1 -1
- package/packages/client-agent-team/lib/types/client/{HumanSettingsSection.d.ts → TeamSettingsSection.d.ts} +12 -4
- package/packages/client-agent-team/lib/types/client/TeamSettingsSection.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/TeamSettingsSection.js +195 -0
- package/packages/client-agent-team/lib/types/client/attachment-preview.d.ts +7 -11
- package/packages/client-agent-team/lib/types/client/attachment-preview.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/attachment-preview.js +13 -3
- package/packages/client-agent-team/lib/types/client/context-judge.d.ts +64 -0
- package/packages/client-agent-team/lib/types/client/context-judge.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/context-judge.js +78 -0
- package/packages/client-agent-team/lib/types/client/index.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/index.js +75 -11
- package/packages/client-agent-team/lib/types/client/judge-form.d.ts +99 -0
- package/packages/client-agent-team/lib/types/client/judge-form.d.ts.map +1 -0
- package/packages/client-agent-team/lib/types/client/judge-form.js +208 -0
- package/packages/client-agent-team/lib/types/client/locales.d.ts +52 -6
- package/packages/client-agent-team/lib/types/client/locales.d.ts.map +1 -1
- package/packages/client-agent-team/lib/types/client/locales.js +55 -6
- package/packages/tool-agent-team/README.md +6 -3
- package/packages/tool-agent-team/README.zh.md +6 -3
- package/packages/tool-agent-team/lib/context-tools.js +84 -112
- package/packages/tool-agent-team/lib/types/context-tools.d.ts +29 -13
- package/packages/tool-agent-team/lib/types/context-tools.d.ts.map +1 -1
- package/packages/agent-team/lib/pressure-policy.js +0 -235
- package/packages/agent-team/lib/types/pressure-policy.d.ts +0 -134
- package/packages/agent-team/lib/types/pressure-policy.d.ts.map +0 -1
- package/packages/client-agent-team/lib/types/client/HumanSettingsSection.d.ts.map +0 -1
- package/packages/client-agent-team/lib/types/client/HumanSettingsSection.js +0 -118
|
@@ -2,9 +2,39 @@
|
|
|
2
2
|
const PACKAGE_NAME = '@wowyuarm/dsh-agent-team';
|
|
3
3
|
/** Cordis companion plugin name. */
|
|
4
4
|
export const name = 'agent-team-invariant';
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Services required before the companion can validate Team state. The check
|
|
7
|
+
* is self-hosted in this plugin's own fiber — companions used to register
|
|
8
|
+
* into `@deepseek-ai/dsh-invariants`, which the Harness line after `rc.2`
|
|
9
|
+
* removes wholesale.
|
|
10
|
+
*/
|
|
11
|
+
export const inject = ['agentTeam'];
|
|
12
|
+
/**
|
|
13
|
+
* A violated Team ledger invariant, raised on the frame that triggered the
|
|
14
|
+
* check: boot when the mount replay fails, the committing call while a
|
|
15
|
+
* divergence is latched. The Host's post-commit boundary recognizes this class
|
|
16
|
+
* and re-raises it instead of degrading it to a log line.
|
|
17
|
+
*/
|
|
18
|
+
export class AgentTeamInvariantError extends Error {
|
|
19
|
+
/** Stable failure code, carried over from the removed upstream error class. */
|
|
20
|
+
code = 'INVARIANT';
|
|
21
|
+
/** Full npm package name that owns the violated invariant. */
|
|
22
|
+
packageName = PACKAGE_NAME;
|
|
23
|
+
/**
|
|
24
|
+
* Construct a Team invariant failure.
|
|
25
|
+
* @param message - violated contract, without the standard error prefix.
|
|
26
|
+
*/
|
|
27
|
+
constructor(message) {
|
|
28
|
+
super(`invariant violated by "${PACKAGE_NAME}": ${message}`);
|
|
29
|
+
this.name = 'AgentTeamInvariantError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validate Team state at mount and keep validating it after every commit.
|
|
34
|
+
* @param ctx - Cordis context carrying the Agent Team service.
|
|
35
|
+
* @returns nothing; listeners and the pending check ride the plugin fiber.
|
|
36
|
+
*/
|
|
37
|
+
export const apply = (ctx) => {
|
|
8
38
|
const divergence = (error) => `durable ledger and Team projection diverged: ${String(error)}`;
|
|
9
39
|
// Mounting stays synchronous: a durable ledger that cannot be re-derived
|
|
10
40
|
// must fail startup instead of racing the first commit. The mount adopts
|
|
@@ -15,7 +45,7 @@ const install = Object.assign(async (ctx, fail) => {
|
|
|
15
45
|
ctx.agentTeam.validateLedgerAtMount();
|
|
16
46
|
}
|
|
17
47
|
catch (error) {
|
|
18
|
-
|
|
48
|
+
throw new AgentTeamInvariantError(divergence(error));
|
|
19
49
|
}
|
|
20
50
|
// The commit path cannot pay a full replay before its Remote response
|
|
21
51
|
// returns, and opening a Thread commits. The replay stays the same full one
|
|
@@ -47,12 +77,6 @@ const install = Object.assign(async (ctx, fail) => {
|
|
|
47
77
|
if (pending === undefined)
|
|
48
78
|
pending = setImmediate(check);
|
|
49
79
|
if (latched !== undefined)
|
|
50
|
-
|
|
80
|
+
throw new AgentTeamInvariantError(latched);
|
|
51
81
|
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Register the Agent Team ledger invariant.
|
|
55
|
-
* @param ctx - Cordis context carrying the invariant registry.
|
|
56
|
-
* @returns the installed registration disposer after setup succeeds.
|
|
57
|
-
*/
|
|
58
|
-
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
82
|
+
};
|
|
@@ -3780,7 +3780,7 @@ export class AgentTeamLedger {
|
|
|
3780
3780
|
if (operation.kind !== 'team/message-sent' || !this.sameActor(operation.actor, request.actor)
|
|
3781
3781
|
|| operation.data.workspaceId !== request.workspaceId || operation.data.message.channelRef !== request.channelRef
|
|
3782
3782
|
|| operation.data.message.body !== request.body.trim() || !this.sameList(operation.data.mentions, recipients)
|
|
3783
|
-
|| !this.sameList(operation.data.message.attachments?.map(attachment => attachment.attachmentId) ?? [], request.
|
|
3783
|
+
|| !this.sameList(operation.data.message.attachments?.map(attachment => attachment.attachmentId) ?? [], request.resolvedAttachments?.map(attachment => attachment.attachmentId) ?? [])
|
|
3784
3784
|
|| (request.asTask !== false) !== (operation.data.task !== undefined))
|
|
3785
3785
|
this.throwRequestCollision(request.requestId);
|
|
3786
3786
|
}
|
|
@@ -3791,6 +3791,7 @@ export class AgentTeamLedger {
|
|
|
3791
3791
|
|| (request.taskRef !== undefined && operation.data.task?.taskRef !== request.taskRef)
|
|
3792
3792
|
|| (request.threadRef === undefined && request.taskRef === undefined)
|
|
3793
3793
|
|| operation.data.message.body !== request.body.trim() || operation.data.baseRevision !== request.baseRevision
|
|
3794
|
+
|| !this.sameList(operation.data.message.attachments?.map(attachment => attachment.attachmentId) ?? [], request.resolvedAttachments?.map(attachment => attachment.attachmentId) ?? [])
|
|
3794
3795
|
|| !this.sameList(operation.data.mentions, recipients))
|
|
3795
3796
|
this.throwRequestCollision(request.requestId);
|
|
3796
3797
|
}
|
|
@@ -35,7 +35,8 @@ export const AGENT_TEAM_TOOL_NAMES = Object.freeze([
|
|
|
35
35
|
'team_view',
|
|
36
36
|
'context_rollover',
|
|
37
37
|
'context_checkpoint',
|
|
38
|
-
'
|
|
38
|
+
'context_status',
|
|
39
|
+
'context_compact',
|
|
39
40
|
]);
|
|
40
41
|
/** Copy a Remote-supplied capability overlay into owned frozen storage. */
|
|
41
42
|
export function deepCopyCapabilities(capabilities) {
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
const TRANSIENT_NETWORK_PATTERNS = [/fetch failed/i, /econnreset/i, /etimedout/i, /socket hang up/i];
|
|
2
2
|
const RATE_LIMIT_PATTERNS = [/\b429\b/, /rate limit/i, /\b503\b/, /overloaded/i];
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Read the stable code/status off any Harness-shaped failure without trusting
|
|
5
|
+
* class identity: a cross-package copy of `dsh-llm` preserves own data but
|
|
6
|
+
* not `instanceof`, so the own fields are the contract.
|
|
7
|
+
*/
|
|
8
|
+
function structuredFailure(error) {
|
|
9
|
+
if (typeof error !== 'object' || error === null)
|
|
10
|
+
return {};
|
|
11
|
+
const root = error;
|
|
12
|
+
const failure = typeof root.failure === 'object' && root.failure !== null
|
|
13
|
+
? root.failure
|
|
14
|
+
: undefined;
|
|
15
|
+
const code = typeof failure?.code === 'string' && failure.code.length > 0 ? failure.code
|
|
16
|
+
: typeof root.code === 'string' && root.code.length > 0 ? root.code : undefined;
|
|
17
|
+
if (code === undefined)
|
|
18
|
+
return {};
|
|
19
|
+
const status = typeof failure?.status === 'number' && Number.isInteger(failure.status) ? failure.status
|
|
20
|
+
: typeof root.status === 'number' && Number.isInteger(root.status) ? root.status : undefined;
|
|
21
|
+
return { code, ...status === undefined ? {} : { status } };
|
|
22
|
+
}
|
|
23
|
+
/** The readable message of an arbitrary thrown value. */
|
|
24
|
+
function failureMessage(error) {
|
|
25
|
+
if (error instanceof Error)
|
|
26
|
+
return error.message;
|
|
27
|
+
if (typeof error === 'object' && error !== null) {
|
|
28
|
+
const message = error.message;
|
|
29
|
+
if (typeof message === 'string' && message.length > 0)
|
|
30
|
+
return message;
|
|
31
|
+
}
|
|
32
|
+
return String(error);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Classify one `agent/error` occurrence. Structured data outranks wording: a
|
|
36
|
+
* Harness code decides alone (a message can never upgrade a terminal failure
|
|
37
|
+
* back to recoverable), and the narrow message signatures run only when no
|
|
38
|
+
* usable code exists at all — `UNKNOWN` means the Harness folded a foreign
|
|
39
|
+
* error whose own taxonomy Team must not trust.
|
|
40
|
+
*/
|
|
41
|
+
export function classifyRecoverableError(error) {
|
|
42
|
+
const { code, status } = structuredFailure(error);
|
|
43
|
+
if (code !== undefined && code !== 'UNKNOWN') {
|
|
44
|
+
if (code === 'RATE_LIMIT')
|
|
45
|
+
return 'rate limiting';
|
|
46
|
+
if (code === 'TRANSPORT' || code === 'TIMEOUT')
|
|
47
|
+
return 'transient network';
|
|
48
|
+
if (status === 429 || status === 503)
|
|
49
|
+
return 'rate limiting';
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const message = failureMessage(error);
|
|
4
53
|
if (RATE_LIMIT_PATTERNS.some(pattern => pattern.test(message)))
|
|
5
54
|
return 'rate limiting';
|
|
6
55
|
if (TRANSIENT_NETWORK_PATTERNS.some(pattern => pattern.test(message)))
|
|
@@ -26,9 +75,9 @@ export class RecoveryCoordinator {
|
|
|
26
75
|
this.delayMs = options.delayMs ?? RECOVERY_DELAY_MS;
|
|
27
76
|
this.maxConsecutiveErrors = options.maxConsecutiveErrors ?? RECOVERY_MAX_CONSECUTIVE_ERRORS;
|
|
28
77
|
}
|
|
29
|
-
/** Observe one `agent/error` occurrence for a Member. */
|
|
30
|
-
onError(memberId,
|
|
31
|
-
if (classifyRecoverableError(
|
|
78
|
+
/** Observe one `agent/error` occurrence for a Member; `error` is the raw event payload. */
|
|
79
|
+
onError(memberId, error) {
|
|
80
|
+
if (classifyRecoverableError(error) === undefined) {
|
|
32
81
|
// A non-recoverable failure cancels anything pending: retrying cannot help.
|
|
33
82
|
this.stopTracking(memberId);
|
|
34
83
|
return;
|