@peer-agent/protocol 0.1.0-rc.10 → 0.1.0-rc.12
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/dist/delegation-coordination.d.ts +68 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +41 -3
- package/dist/delegation.js +13 -6
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/local-image.d.ts +36 -0
- package/dist/local-image.js +5 -0
- package/dist/project-agent-failure.d.ts +17 -0
- package/dist/project-agent-failure.js +36 -0
- package/dist/session-facts.d.ts +2 -0
- package/dist/session-facts.js +11 -1
- package/dist/task-overview.d.ts +2 -0
- package/dist/task-overview.js +3 -0
- package/dist/work-coordination.d.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Coordination authority is issued by the local host, never by model arguments. */
|
|
2
|
+
export type CoordinationAction = 'parallel' | 'augment' | 'revise' | 'query' | 'answer' | 'cancel' | 'replace' | 'handoff';
|
|
3
|
+
export type CoordinationLifecycle = 'active' | 'paused' | 'cancelled' | 'fulfilled';
|
|
4
|
+
export interface CoordinationMandate {
|
|
5
|
+
schemaVersion: 1;
|
|
6
|
+
mandateId: string;
|
|
7
|
+
workId: string;
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
parentConversationId: string;
|
|
10
|
+
rootInputIds: string[];
|
|
11
|
+
revisionInputIds: string[];
|
|
12
|
+
goalRevision: number;
|
|
13
|
+
allowedActions: CoordinationAction[];
|
|
14
|
+
sessionIds: string[];
|
|
15
|
+
revokedSessionIds?: string[];
|
|
16
|
+
executionBindings?: Record<string, CoordinationExecutionBinding>;
|
|
17
|
+
materialRefs: string[];
|
|
18
|
+
policyRevision: string;
|
|
19
|
+
lifecycle: CoordinationLifecycle;
|
|
20
|
+
}
|
|
21
|
+
/** Semantic routing is the model's decision; identity, authority and versions are host facts. */
|
|
22
|
+
export interface CoordinationDecision {
|
|
23
|
+
operationId: string;
|
|
24
|
+
workId: string;
|
|
25
|
+
expectedRevision: number;
|
|
26
|
+
action: CoordinationAction;
|
|
27
|
+
sourceInputIds: string[];
|
|
28
|
+
sourceEventIds: string[];
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}
|
|
32
|
+
export type TaskTransitionPhase = 'recorded' | 'stopping' | 'awaiting_outcome' | 'ready' | 'started' | 'completed' | 'blocked';
|
|
33
|
+
export interface TaskTransition {
|
|
34
|
+
schemaVersion: 1;
|
|
35
|
+
operationId: string;
|
|
36
|
+
workId: string;
|
|
37
|
+
mandateId: string;
|
|
38
|
+
expectedGoalRevision: number;
|
|
39
|
+
sourceInputIds: string[];
|
|
40
|
+
sourceEventIds: string[];
|
|
41
|
+
initiator: 'project_agent';
|
|
42
|
+
decisionSource: 'user_revision' | 'execution_repair';
|
|
43
|
+
action: CoordinationAction;
|
|
44
|
+
reason: string;
|
|
45
|
+
oldSessionId?: string;
|
|
46
|
+
replacementSessionId?: string;
|
|
47
|
+
executionEpoch: string;
|
|
48
|
+
phase: TaskTransitionPhase;
|
|
49
|
+
minimumExecutorVersion: 1;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CoordinationExecutionBinding {
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
workId: string;
|
|
55
|
+
goalRevision: number;
|
|
56
|
+
executionEpoch: string;
|
|
57
|
+
}
|
|
58
|
+
/** Factual view of a durable operation; completed means disposition applied, not task success. */
|
|
59
|
+
export interface CoordinationSessionFacts {
|
|
60
|
+
readonly operationId: string;
|
|
61
|
+
readonly action: CoordinationAction;
|
|
62
|
+
readonly phase: TaskTransitionPhase;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly goalRevision: number;
|
|
65
|
+
readonly priorSessionId?: string;
|
|
66
|
+
readonly replacementSessionId?: string;
|
|
67
|
+
readonly replacementTitle?: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/delegation.d.ts
CHANGED
|
@@ -4,10 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ModelSelectionSnapshot } from './model-routing.ts';
|
|
6
6
|
import { type GoalPlanProjectionSnapshot, type TaskOverviewItem } from './task-overview.ts';
|
|
7
|
-
export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
|
|
8
|
-
export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
|
|
7
|
+
export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'waiting_agent' | 'stopping' | 'awaiting_outcome' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
|
|
8
|
+
export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "waiting_agent", "stopping", "awaiting_outcome", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
|
|
9
9
|
export type InputSurface = 'desktop' | 'quick_chat' | 'tui' | 'remote';
|
|
10
10
|
export interface DelegationOrigin {
|
|
11
|
+
readonly takeover?: {
|
|
12
|
+
operationId: string;
|
|
13
|
+
phase: 'stopping' | 'completed';
|
|
14
|
+
text: string;
|
|
15
|
+
binding: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
16
|
+
requestedAt: string;
|
|
17
|
+
completedAt?: string;
|
|
18
|
+
};
|
|
19
|
+
readonly coordinationBinding?: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
20
|
+
readonly cancellation?: {
|
|
21
|
+
readonly operationId: string;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
readonly phase: 'stopping' | 'awaiting_outcome' | 'completed';
|
|
24
|
+
readonly requestedAt: string;
|
|
25
|
+
readonly completedAt?: string;
|
|
26
|
+
readonly evidenceCalls?: readonly string[];
|
|
27
|
+
};
|
|
11
28
|
readonly workId?: string;
|
|
12
29
|
readonly anchorMessageId: string;
|
|
13
30
|
readonly inputId: string;
|
|
@@ -36,6 +53,7 @@ export interface SessionQueueFacts {
|
|
|
36
53
|
readonly queueReason?: 'dependencies' | 'dependency_missing' | 'dependency_failed' | 'read_slot' | 'write_slot' | 'disk_space' | 'isolation_failed' | null;
|
|
37
54
|
}
|
|
38
55
|
export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
56
|
+
readonly coordination?: import('./delegation-coordination.ts').CoordinationSessionFacts;
|
|
39
57
|
readonly sessionId?: string;
|
|
40
58
|
readonly conversationId?: string;
|
|
41
59
|
readonly workspaceId: string;
|
|
@@ -48,6 +66,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
48
66
|
readonly phase?: 'starting' | 'verifying' | 'paused';
|
|
49
67
|
}
|
|
50
68
|
export interface WorkSession extends SessionQueueFacts {
|
|
69
|
+
readonly coordination?: import('./delegation-coordination.ts').CoordinationSessionFacts;
|
|
51
70
|
readonly sessionId: string;
|
|
52
71
|
readonly workspaceId: string;
|
|
53
72
|
readonly title: string;
|
|
@@ -82,7 +101,26 @@ export interface SessionReport {
|
|
|
82
101
|
readonly verification: 'unverified';
|
|
83
102
|
};
|
|
84
103
|
}
|
|
85
|
-
export type DelegationEventKind = 'session_spawned' | 'session_progress' | 'session_needs_user' | 'report_available' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
104
|
+
export type DelegationEventKind = 'agent_message' | 'session_running' | 'session_spawned' | 'session_progress' | 'session_needs_user' | 'report_available' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
105
|
+
/** Local orchestration facts; never a human authorization or a verified result. */
|
|
106
|
+
export interface AgentMessage {
|
|
107
|
+
readonly replyTo?: string;
|
|
108
|
+
readonly messageId: string;
|
|
109
|
+
readonly workspaceId: string;
|
|
110
|
+
readonly sessionId: string;
|
|
111
|
+
readonly senderConversationId: string;
|
|
112
|
+
readonly recipientConversationId: string;
|
|
113
|
+
readonly direction: 'parent_to_child' | 'child_to_parent';
|
|
114
|
+
readonly purpose: 'update' | 'question' | 'answer';
|
|
115
|
+
readonly text: string;
|
|
116
|
+
readonly at: string;
|
|
117
|
+
}
|
|
118
|
+
export interface AgentActivity {
|
|
119
|
+
readonly eventId: string;
|
|
120
|
+
readonly sessionId: string;
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly state: 'queued' | 'started' | 'update' | 'question' | 'answer' | 'reported' | 'verified' | 'ended' | 'cancelled' | 'blocked';
|
|
123
|
+
}
|
|
86
124
|
export type JsonValue = null | string | number | boolean | readonly JsonValue[] | {
|
|
87
125
|
readonly [key: string]: JsonValue;
|
|
88
126
|
};
|
package/dist/delegation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deriveSessionFacts } from "./session-facts.js";
|
|
2
2
|
import { projectGoalPlan, } from "./task-overview.js";
|
|
3
|
-
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'verifying',
|
|
3
|
+
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'waiting_agent', 'stopping', 'awaiting_outcome', 'verifying',
|
|
4
4
|
'result_ready', 'accepted', 'failed', 'cancelled', 'superseded'];
|
|
5
5
|
function fnv1a(text) {
|
|
6
6
|
let hash = 0x811c9dc5;
|
|
@@ -42,10 +42,13 @@ export function createDelegationEvent(input) {
|
|
|
42
42
|
}
|
|
43
43
|
function delegationStatus(snapshot, meta, projected) {
|
|
44
44
|
return deriveSessionFacts({ status: snapshot.status, runnerStatus: snapshot.runnerStatus,
|
|
45
|
+
cancellationPhase: meta.origin.cancellation?.phase,
|
|
46
|
+
takeoverPhase: meta.coordination?.phase === 'awaiting_outcome' ? 'awaiting_outcome' : meta.origin.takeover?.phase,
|
|
45
47
|
accepted: meta.accepted === true || (snapshot.status === 'completed' && meta.acceptance !== 'confirm'
|
|
46
48
|
&& meta.accepted === undefined && !meta.verifying && !snapshot.runnerStatus),
|
|
47
49
|
superseded: Boolean(meta.supersededBy), phase: meta.phase,
|
|
48
50
|
needsUser: snapshot.status === 'awaiting_approval', verificationActive: meta.verifying === true,
|
|
51
|
+
...(snapshot.agentWaiting ? { blockedReason: 'waiting_parent_agent' } : {}),
|
|
49
52
|
}).status;
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
@@ -55,16 +58,20 @@ function delegationStatus(snapshot, meta, projected) {
|
|
|
55
58
|
*/
|
|
56
59
|
export function projectWorkSession(plan, conversationMeta) {
|
|
57
60
|
const projected = projectGoalPlan(plan);
|
|
61
|
+
const status = delegationStatus(plan, conversationMeta, projected);
|
|
62
|
+
const transitioning = ['stopping', 'awaiting_outcome'].includes(status) || conversationMeta.origin.takeover?.phase === 'stopping';
|
|
58
63
|
return {
|
|
59
64
|
sessionId: conversationMeta.sessionId ?? plan.conversationId ?? plan.planId,
|
|
60
65
|
workspaceId: conversationMeta.workspaceId,
|
|
61
66
|
title: plan.title,
|
|
62
67
|
planId: plan.planId,
|
|
63
|
-
status
|
|
64
|
-
actionRight: projected.actionRight,
|
|
65
|
-
nextAction: projected.nextAction,
|
|
66
|
-
statusLabel:
|
|
67
|
-
|
|
68
|
+
status,
|
|
69
|
+
actionRight: transitioning ? 'peer_advancing' : projected.actionRight,
|
|
70
|
+
nextAction: transitioning ? 'none' : projected.nextAction,
|
|
71
|
+
statusLabel: status === 'stopping' ? '正在停止' : status === 'awaiting_outcome' ? '执行结果待核实'
|
|
72
|
+
: conversationMeta.origin.takeover?.phase === 'stopping' ? '正在接手' : projected.statusLabel,
|
|
73
|
+
...(!transitioning && projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
74
|
+
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
68
75
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
|
69
76
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
70
77
|
origin: conversationMeta.origin,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export type { ProjectWorkReceipt, ProjectWorkState, ProjectTurnEnd } from './work-coordination.ts';
|
|
1
|
+
export type { ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd } from './work-coordination.ts';
|
|
2
|
+
export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts } from './delegation-coordination.ts';
|
|
2
3
|
export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
|
|
3
|
-
export { projectAgentFailureKind, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
|
|
4
|
+
export { projectAgentFailureKind, classifyProjectAgentFailure, type ProjectRecoveryFailureKind, type ProviderRequestRecovery, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
|
|
4
5
|
export type { EvidenceSourceDescription, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
|
|
5
6
|
export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
|
|
6
7
|
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
|
|
@@ -743,7 +744,7 @@ export interface PermissionGrant {
|
|
|
743
744
|
readonly toolCallId: string;
|
|
744
745
|
readonly granted: boolean;
|
|
745
746
|
readonly duration: PermissionDuration;
|
|
746
|
-
readonly scope?: string;
|
|
747
|
+
readonly scope?: string | import('./local-image.ts').LocalImagePermissionScope;
|
|
747
748
|
readonly decidedAt: string;
|
|
748
749
|
}
|
|
749
750
|
/** Application-owned shell process snapshot. Source conversation is provenance, not ownership. */
|
|
@@ -877,3 +878,4 @@ export * from './project.ts';
|
|
|
877
878
|
export * from './objectives.ts';
|
|
878
879
|
export * from './remote-access-settings.ts';
|
|
879
880
|
export type { BotModelSelectionUpdateRequest, BotModelSelectionUpdateResult } from './bot-model-selection.ts';
|
|
881
|
+
export * from './local-image.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { deriveSessionFacts } from "./session-facts.js";
|
|
2
|
-
export { projectAgentFailureKind } from "./project-agent-failure.js";
|
|
2
|
+
export { projectAgentFailureKind, classifyProjectAgentFailure } from "./project-agent-failure.js";
|
|
3
3
|
export { toolActivityPreview, toolActivitySummary } from "./tool-activity-preview.js";
|
|
4
4
|
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort } from "./model-reasoning.js";
|
|
5
5
|
export { buildModelMenuGroups, modelMenuChannelName } from "./model-menu.js";
|
|
@@ -41,3 +41,4 @@ export * from "./model-routing.js";
|
|
|
41
41
|
export * from "./project.js";
|
|
42
42
|
export * from "./objectives.js";
|
|
43
43
|
export * from "./remote-access-settings.js";
|
|
44
|
+
export * from "./local-image.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export declare const LOCAL_IMAGE_CAPABILITY: "local.image.read";
|
|
3
|
+
export declare const LOCAL_IMAGE_TOOL: "view_image";
|
|
4
|
+
export declare const LOCAL_IMAGE_MAX_BYTES: number;
|
|
5
|
+
export declare const LOCAL_IMAGE_MAX_PIXELS = 24000000;
|
|
6
|
+
export type LocalImageMediaType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
|
|
7
|
+
export interface LocalImageMetadata {
|
|
8
|
+
path: string;
|
|
9
|
+
mediaType: LocalImageMediaType;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
byteLength: number;
|
|
13
|
+
sha256: string;
|
|
14
|
+
artifactRef: string;
|
|
15
|
+
}
|
|
16
|
+
/** Ephemeral host sideband. Object identity must also be validated by its Provider. */
|
|
17
|
+
export interface LocalImageObservation extends LocalImageMetadata {
|
|
18
|
+
kind: 'local_image';
|
|
19
|
+
dataUrl: string;
|
|
20
|
+
}
|
|
21
|
+
import type { ClientToolResult, PermissionGrant } from './index.ts';
|
|
22
|
+
export interface LocalImagePermissionScope {
|
|
23
|
+
capabilityId: typeof LOCAL_IMAGE_CAPABILITY;
|
|
24
|
+
path: string;
|
|
25
|
+
workspacePath: string | null;
|
|
26
|
+
action: 'read_image_for_model';
|
|
27
|
+
}
|
|
28
|
+
/** Concrete image grant; legacy grant scopes remain unchanged. */
|
|
29
|
+
export interface LocalImagePermissionGrant extends PermissionGrant {
|
|
30
|
+
scope: LocalImagePermissionScope | typeof LOCAL_IMAGE_CAPABILITY;
|
|
31
|
+
}
|
|
32
|
+
export interface LocalImageToolResult extends ClientToolResult {
|
|
33
|
+
modelContext?: {
|
|
34
|
+
visualObservations: readonly LocalImageObservation[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export const LOCAL_IMAGE_CAPABILITY = 'local.image.read';
|
|
3
|
+
export const LOCAL_IMAGE_TOOL = 'view_image';
|
|
4
|
+
export const LOCAL_IMAGE_MAX_BYTES = 8 * 1024 * 1024;
|
|
5
|
+
export const LOCAL_IMAGE_MAX_PIXELS = 24_000_000;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import type { DelegationEvent } from './delegation.ts';
|
|
2
|
+
export type ProjectRecoveryFailureKind = 'response_headers_timeout' | 'network' | 'stream_interrupted' | 'provider_transient' | 'rate_limited' | 'authentication' | 'invalid_request' | 'configuration' | 'permission' | 'budget_exhausted' | 'execution_outcome_unknown' | 'cancelled' | 'fatal';
|
|
3
|
+
/** Produced by the host request boundary; never inferred from assistant prose. */
|
|
4
|
+
export interface ProviderRequestRecovery {
|
|
5
|
+
readonly kind: ProjectRecoveryFailureKind;
|
|
6
|
+
readonly phase?: 'response_headers' | 'stream' | 'request';
|
|
7
|
+
readonly requestId?: string;
|
|
8
|
+
readonly attempts?: number;
|
|
9
|
+
readonly maxAttempts?: number;
|
|
10
|
+
readonly exhausted?: boolean;
|
|
11
|
+
readonly replaySafe?: boolean;
|
|
12
|
+
readonly retryable: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Legacy diagnostics are admitted only at this seam; structured host failure takes precedence. */
|
|
15
|
+
export declare function classifyProjectAgentFailure(reason: unknown, detail?: unknown): {
|
|
16
|
+
kind: ProjectRecoveryFailureKind;
|
|
17
|
+
retryable: boolean;
|
|
18
|
+
};
|
|
2
19
|
/** Host failure classification, including the persisted diagnostic prefix used by older cards. */
|
|
3
20
|
export declare function projectAgentFailureKind(reason: unknown): 'budget_exhausted' | 'unavailable';
|
|
4
21
|
/** Durable host facts for an explicit retry; never a new user authorization. */
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
const RECOVERABLE = new Set(['response_headers_timeout', 'network', 'stream_interrupted', 'provider_transient', 'rate_limited']);
|
|
2
|
+
const FAILURE_KINDS = new Set([...RECOVERABLE, 'authentication', 'invalid_request', 'configuration', 'permission', 'budget_exhausted', 'execution_outcome_unknown', 'cancelled', 'fatal']);
|
|
3
|
+
/** Legacy diagnostics are admitted only at this seam; structured host failure takes precedence. */
|
|
4
|
+
export function classifyProjectAgentFailure(reason, detail) {
|
|
5
|
+
if (detail && typeof detail === 'object' && 'kind' in detail && FAILURE_KINDS.has(detail.kind)) {
|
|
6
|
+
const kind = detail.kind;
|
|
7
|
+
return { kind, retryable: RECOVERABLE.has(kind) && !('retryable' in detail && detail.retryable === false) };
|
|
8
|
+
}
|
|
9
|
+
const code = typeof reason === 'string' ? reason.trim().replace(/^代理暂时不可用:\s*/, '') : '';
|
|
10
|
+
let kind = 'fatal';
|
|
11
|
+
if (/^(agent_tool_budget_exhausted|agent_loop_exhausted|work_budget_limited)(?:\s*:|$)/.test(code))
|
|
12
|
+
kind = 'budget_exhausted';
|
|
13
|
+
else if (/^(execution_outcome_unknown|checkpoint_persistence_failed)(?:\s*:|$)/.test(code))
|
|
14
|
+
kind = 'execution_outcome_unknown';
|
|
15
|
+
else if (/^(work_execution_stopped|aborted|AbortError|user_stopped)(?:\s*:|$)/i.test(code))
|
|
16
|
+
kind = 'cancelled';
|
|
17
|
+
else if (/^(permission_denied|permission_revoked|authorization_denied)(?:\s*:|$)/i.test(code))
|
|
18
|
+
kind = 'permission';
|
|
19
|
+
else if (/^(connect timeout after|response_headers_timeout)|ConnectTimeoutError/.test(code))
|
|
20
|
+
kind = 'response_headers_timeout';
|
|
21
|
+
else if (/^(provider_stream_idle_timeout|provider_stream_interrupted)(?:\s*:|$)/.test(code))
|
|
22
|
+
kind = 'stream_interrupted';
|
|
23
|
+
else if (/^(HTTP\s*)?(401|403)(?:\s|:|$)|^(authentication_error|invalid_api_key|credential_unavailable)(?:\s*:|$)/i.test(code))
|
|
24
|
+
kind = 'authentication';
|
|
25
|
+
else if (/^(HTTP\s*)?429(?:\s|:|$)/i.test(code))
|
|
26
|
+
kind = 'rate_limited';
|
|
27
|
+
else if (/^(HTTP\s*)?(500|502|503|504)(?:\s|:|$)|^(server_error|server_is_overloaded)(?:\s*:|$)/i.test(code))
|
|
28
|
+
kind = 'provider_transient';
|
|
29
|
+
else if (/^(HTTP\s*)?(400|404|422)(?:\s|:|$)|^(invalid_request|provider_checkpoint_mismatch)(?:\s*:|$)/i.test(code))
|
|
30
|
+
kind = 'invalid_request';
|
|
31
|
+
else if (/^(CERT_|ERR_CERT_|UNABLE_TO_VERIFY|SELF_SIGNED|DEPTH_ZERO_SELF_SIGNED_CERT|provider_not_configured|work_budget_host_unavailable)/i.test(code))
|
|
32
|
+
kind = 'configuration';
|
|
33
|
+
else if (/^(fetch failed|network|ECONNRESET|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|EAI_AGAIN|UND_ERR_(SOCKET|CONNECT_TIMEOUT)|(?:net::)?ERR_(CONNECTION|NETWORK|TIMED_OUT|NAME_NOT_RESOLVED|PROXY_CONNECTION_FAILED|TUNNEL_CONNECTION_FAILED|SOCKS_CONNECTION_FAILED|INTERNET_DISCONNECTED))/i.test(code))
|
|
34
|
+
kind = 'network';
|
|
35
|
+
return { kind, retryable: RECOVERABLE.has(kind) };
|
|
36
|
+
}
|
|
1
37
|
/** Host failure classification, including the persisted diagnostic prefix used by older cards. */
|
|
2
38
|
export function projectAgentFailureKind(reason) {
|
|
3
39
|
if (typeof reason !== 'string')
|
package/dist/session-facts.d.ts
CHANGED
package/dist/session-facts.js
CHANGED
|
@@ -7,7 +7,17 @@ export function deriveSessionFacts(input) {
|
|
|
7
7
|
status = 'failed';
|
|
8
8
|
else if (input.accepted)
|
|
9
9
|
status = 'accepted';
|
|
10
|
-
else if (input.
|
|
10
|
+
else if (input.cancellationPhase === 'awaiting_outcome' || input.takeoverPhase === 'awaiting_outcome')
|
|
11
|
+
status = 'awaiting_outcome';
|
|
12
|
+
else if (input.cancellationPhase === 'stopping')
|
|
13
|
+
status = 'stopping';
|
|
14
|
+
else if (input.takeoverPhase === 'stopping')
|
|
15
|
+
status = 'starting';
|
|
16
|
+
else if (input.needsUser || input.runnerStatus === 'waiting_user')
|
|
17
|
+
status = 'waiting_user';
|
|
18
|
+
else if (input.blockedReason === 'waiting_parent_agent' && input.phase !== 'paused' && !input.superseded && input.runnerStatus !== 'paused')
|
|
19
|
+
status = 'waiting_agent';
|
|
20
|
+
else if (input.runnerStatus === 'blocked')
|
|
11
21
|
status = 'waiting_user';
|
|
12
22
|
else if (verificationActive)
|
|
13
23
|
status = 'verifying';
|
package/dist/task-overview.d.ts
CHANGED
|
@@ -246,6 +246,8 @@ export interface GoalPlanProjectionSnapshot {
|
|
|
246
246
|
readonly runnerStatus?: GoalRunnerStatus;
|
|
247
247
|
/** Runner 阻塞是否由系统基础设施持有,而不是用户行动权。 */
|
|
248
248
|
readonly systemBlocked?: boolean;
|
|
249
|
+
/** A delegated worker is coordinating with its parent, not asking the human. */
|
|
250
|
+
readonly agentWaiting?: boolean;
|
|
249
251
|
/**
|
|
250
252
|
* 同一会话此刻是否有前台活流(正在输出 / 调工具 / compact)。
|
|
251
253
|
* 由聚合层从 listActiveStreams 写入;协议层只认这个布尔事实。
|
package/dist/task-overview.js
CHANGED
|
@@ -271,6 +271,9 @@ function decideGoalPlan(snapshot) {
|
|
|
271
271
|
}
|
|
272
272
|
const planStillActive = status === 'executing' || status === 'accepted' || status === 'approved';
|
|
273
273
|
const conversationLive = snapshot.conversationLive === true;
|
|
274
|
+
if (snapshot.agentWaiting && runnerStatus !== 'waiting_user' && ['executing', 'completed'].includes(status)) {
|
|
275
|
+
return { actionRight: 'peer_advancing', nextAction: 'none', statusLabel: '等待主 Bot 答复', actionLabel: '' };
|
|
276
|
+
}
|
|
274
277
|
const recoverableSystemBlocked = runnerStatus === 'blocked'
|
|
275
278
|
&& snapshot.systemBlocked === true;
|
|
276
279
|
// System infrastructure failures are not user decisions. A foreground turn may
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import type { ProjectRecoveryFailureKind } from './project-agent-failure.ts';
|
|
2
|
+
/** Local host reservation; neither model text nor a UI timer owns recovery. */
|
|
3
|
+
export interface ProjectWorkRecovery {
|
|
4
|
+
readonly failureKind: ProjectRecoveryFailureKind;
|
|
5
|
+
readonly retryable: boolean;
|
|
6
|
+
readonly autoAttempts: number;
|
|
7
|
+
readonly failedTurnId: string;
|
|
8
|
+
readonly retryAt?: string;
|
|
9
|
+
readonly reservationId?: string;
|
|
10
|
+
readonly deadlineAt?: string;
|
|
11
|
+
readonly blockedCode?: 'RECOVERY_CHECKPOINT_UNAVAILABLE';
|
|
12
|
+
}
|
|
1
13
|
export type ProjectWorkState = 'runnable' | 'waiting_children' | 'waiting_user' | 'retry_wait' | 'paused' | 'budget_limited' | 'blocked_system' | 'delivered' | 'cancelled';
|
|
2
14
|
export type ProjectTurnEnd = 'reply_committed' | 'awaiting_children' | 'yielded' | 'awaiting_user' | 'budget_limited' | 'provider_retryable' | 'no_progress' | 'user_stopped' | 'fatal';
|
|
3
15
|
export interface ProjectWorkReceipt {
|
|
@@ -11,6 +23,7 @@ export interface ProjectWorkReceipt {
|
|
|
11
23
|
readonly revision: number;
|
|
12
24
|
readonly checkpointRef?: string;
|
|
13
25
|
readonly nativeCheckpointRef?: string;
|
|
26
|
+
readonly recovery?: ProjectWorkRecovery;
|
|
14
27
|
readonly end?: ProjectTurnEnd;
|
|
15
28
|
readonly attemptId?: string;
|
|
16
29
|
readonly pendingEventIds?: readonly string[];
|