@peer-agent/protocol 0.1.0-beta.5 → 0.1.0-rc.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.
- package/dist/acceptance-close-gate.d.ts +10 -1
- package/dist/acceptance-close-gate.js +12 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/delegation.d.ts +48 -1
- package/dist/delegation.js +7 -36
- package/dist/evidence-inspection.d.ts +22 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/goal.d.ts +21 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/model-reasoning.d.ts +13 -0
- package/dist/model-reasoning.js +18 -0
- package/dist/model-routing.d.ts +18 -1
- package/dist/model-routing.js +10 -5
- package/dist/project-agent-failure.d.ts +13 -0
- package/dist/project-agent-failure.js +8 -0
- package/dist/project.d.ts +162 -0
- package/dist/session-facts.d.ts +17 -0
- package/dist/session-facts.js +30 -0
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +69 -0
- package/dist/work-coordination.d.ts +58 -0
- package/dist/work-coordination.js +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GoalCriterionResult, GoalManualConfirmation, GoalSuccessCriterion } from './goal.ts';
|
|
1
|
+
import type { GoalCriterionResult, GoalManualConfirmation, GoalSuccessCriterion, GoalModelReview } from './goal.ts';
|
|
2
2
|
export declare const ACCEPTANCE_CLOSE_GATE_CODE = "acceptance_evidence_incomplete";
|
|
3
3
|
export type AcceptanceCloseGapReason = 'missing' | 'failed' | 'unresolved';
|
|
4
4
|
export interface AcceptanceCloseGap {
|
|
@@ -17,6 +17,15 @@ export interface AcceptanceCloseTaskLike {
|
|
|
17
17
|
}
|
|
18
18
|
export interface AcceptanceClosePlanLike {
|
|
19
19
|
readonly successCriteria?: readonly GoalSuccessCriterion[] | null;
|
|
20
|
+
/** Current content revision derived by the host store, never admitted from a model patch. */
|
|
21
|
+
readonly modelReviewSourceRevision?: string;
|
|
22
|
+
readonly modelReviews?: readonly GoalModelReview[];
|
|
23
|
+
readonly runner?: {
|
|
24
|
+
readonly verifierRuns?: readonly {
|
|
25
|
+
readonly verifierRunId: string;
|
|
26
|
+
readonly status: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
20
29
|
readonly criterionResults?: readonly GoalCriterionResult[] | null;
|
|
21
30
|
readonly manualConfirmations?: readonly GoalManualConfirmation[] | null;
|
|
22
31
|
readonly evidenceRefs?: readonly string[] | null;
|
|
@@ -85,6 +85,18 @@ export function evaluateAcceptanceCloseGate(plan, options = {}) {
|
|
|
85
85
|
const description = criterion.description?.trim() || id;
|
|
86
86
|
const isAuto = AUTO_CRITERION_KINDS.has(criterion.kind);
|
|
87
87
|
const result = results.get(id) ?? null;
|
|
88
|
+
if (criterion.kind === 'model_review') {
|
|
89
|
+
const review = plan?.modelReviews?.slice().reverse().find(row => row.criterionId === id);
|
|
90
|
+
const current = review && plan?.modelReviewSourceRevision && review.sourceRevision === plan.modelReviewSourceRevision;
|
|
91
|
+
const verified = current && plan?.runner?.verifierRuns?.some(run => run.verifierRunId === review.verifierRunId && run.status === 'passed');
|
|
92
|
+
if (!current || !verified)
|
|
93
|
+
gaps.push({ criterionId: id, description, reason: 'missing' });
|
|
94
|
+
else if (!review.passed)
|
|
95
|
+
gaps.push({ criterionId: id, description, reason: 'failed' });
|
|
96
|
+
else if (!review.evidenceRefs.length || !review.evidenceRefs.every(ref => known.has(ref)))
|
|
97
|
+
gaps.push({ criterionId: id, description, reason: 'unresolved' });
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
88
100
|
if (!isAuto && latestManualApproval(plan ?? {}, id))
|
|
89
101
|
continue;
|
|
90
102
|
if (!result) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BotProfile } from './project.ts';
|
|
2
|
+
import type { ModelReasoningEffort } from './model-reasoning.ts';
|
|
3
|
+
/** A user choice for the Bot's future replies; never a per-input runtime override. */
|
|
4
|
+
export interface BotModelSelectionUpdateRequest {
|
|
5
|
+
readonly workspaceId: string;
|
|
6
|
+
readonly modelProviderId: string;
|
|
7
|
+
readonly reasoningEffort?: ModelReasoningEffort;
|
|
8
|
+
}
|
|
9
|
+
export interface BotModelSelectionUpdateResult {
|
|
10
|
+
readonly ok: boolean;
|
|
11
|
+
readonly code?: string;
|
|
12
|
+
readonly profile?: BotProfile;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/delegation.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | '
|
|
|
8
8
|
export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
|
|
9
9
|
export type InputSurface = 'desktop' | 'quick_chat' | 'tui' | 'remote';
|
|
10
10
|
export interface DelegationOrigin {
|
|
11
|
+
readonly workId?: string;
|
|
11
12
|
readonly anchorMessageId: string;
|
|
12
13
|
readonly inputId: string;
|
|
13
14
|
readonly surface: InputSurface;
|
|
@@ -66,14 +67,22 @@ export interface SessionReport {
|
|
|
66
67
|
readonly planId: string | null;
|
|
67
68
|
readonly status: WorkSessionStatus;
|
|
68
69
|
readonly summary: string;
|
|
70
|
+
readonly taskBrief?: string;
|
|
69
71
|
readonly keyFindings: readonly string[];
|
|
70
72
|
readonly changedFiles: readonly {
|
|
71
73
|
readonly path: string;
|
|
72
74
|
readonly summary: string;
|
|
73
75
|
}[];
|
|
74
76
|
readonly evidenceRefs: readonly string[];
|
|
77
|
+
/** Persisted worker output is a claim; verification still comes from host Evidence. */
|
|
78
|
+
readonly contentSource?: {
|
|
79
|
+
readonly kind: 'worker_message' | 'task_results';
|
|
80
|
+
readonly conversationId?: string;
|
|
81
|
+
readonly messageId?: string;
|
|
82
|
+
readonly verification: 'unverified';
|
|
83
|
+
};
|
|
75
84
|
}
|
|
76
|
-
export type DelegationEventKind = 'session_spawned' | 'session_progress' | 'session_needs_user' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
85
|
+
export type DelegationEventKind = 'session_spawned' | 'session_progress' | 'session_needs_user' | 'report_available' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
77
86
|
export type JsonValue = null | string | number | boolean | readonly JsonValue[] | {
|
|
78
87
|
readonly [key: string]: JsonValue;
|
|
79
88
|
};
|
|
@@ -101,6 +110,7 @@ export interface AgentReplyMeta {
|
|
|
101
110
|
readonly surfacing: 'interrupt' | 'message' | 'digest' | 'silent';
|
|
102
111
|
}
|
|
103
112
|
export interface ReplySessionState {
|
|
113
|
+
readonly sourceRevision?: string;
|
|
104
114
|
readonly sessionId: string;
|
|
105
115
|
readonly status: WorkSessionStatus;
|
|
106
116
|
}
|
|
@@ -155,6 +165,26 @@ export interface DispositionEvent {
|
|
|
155
165
|
readonly replyMessageId?: string;
|
|
156
166
|
}
|
|
157
167
|
export type VerificationOutcome = 'passed' | 'failed' | 'partial' | 'unverifiable';
|
|
168
|
+
/** Host-bound manual completion review; distinct from acceptance of a completed result. */
|
|
169
|
+
export interface SessionCompletionReview {
|
|
170
|
+
readonly sessionId: string;
|
|
171
|
+
readonly reviewToken: string;
|
|
172
|
+
readonly criteria: readonly {
|
|
173
|
+
readonly id: string;
|
|
174
|
+
readonly description: string;
|
|
175
|
+
}[];
|
|
176
|
+
readonly report: string;
|
|
177
|
+
readonly confirmed?: boolean;
|
|
178
|
+
}
|
|
179
|
+
export type SessionConfirmationInput = {
|
|
180
|
+
readonly workspaceId: string;
|
|
181
|
+
readonly sessionId: string;
|
|
182
|
+
} & ({
|
|
183
|
+
readonly stage?: 'result_acceptance';
|
|
184
|
+
} | {
|
|
185
|
+
readonly stage: 'manual_completion';
|
|
186
|
+
readonly reviewToken: string;
|
|
187
|
+
});
|
|
158
188
|
export type IndependentVerifierState = 'passed' | 'failed' | 'not_required' | 'missing';
|
|
159
189
|
export interface VerificationCheck {
|
|
160
190
|
readonly name: string;
|
|
@@ -200,6 +230,22 @@ export interface SurfacingEvent {
|
|
|
200
230
|
readonly severity: 'info' | 'notable' | 'urgent';
|
|
201
231
|
readonly deadlineImminent?: boolean;
|
|
202
232
|
}
|
|
233
|
+
/** Explicit user uploads are factual user context, never execution authority. */
|
|
234
|
+
export type ProjectInputAttachment = {
|
|
235
|
+
readonly id: string;
|
|
236
|
+
readonly name: string;
|
|
237
|
+
readonly mimeType: string;
|
|
238
|
+
readonly size: number;
|
|
239
|
+
readonly sourceKind: 'user_upload';
|
|
240
|
+
} & ({
|
|
241
|
+
readonly kind: 'image';
|
|
242
|
+
readonly dataUrl: string;
|
|
243
|
+
} | {
|
|
244
|
+
readonly kind: 'text';
|
|
245
|
+
readonly text: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly kind: 'unsupported';
|
|
248
|
+
});
|
|
203
249
|
export interface ProjectInput {
|
|
204
250
|
readonly inputId: string;
|
|
205
251
|
readonly workspaceId: string;
|
|
@@ -208,6 +254,7 @@ export interface ProjectInput {
|
|
|
208
254
|
readonly anchorRefs: readonly string[];
|
|
209
255
|
readonly quoteRefs: readonly string[];
|
|
210
256
|
readonly attachmentRefs: readonly string[];
|
|
257
|
+
readonly attachments?: readonly ProjectInputAttachment[];
|
|
211
258
|
readonly createdAt: string;
|
|
212
259
|
}
|
|
213
260
|
export type PendingApprovalState = 'open' | 'approved' | 'denied' | 'expired' | 'stale';
|
package/dist/delegation.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Project-agent delegation contracts. Pure projections only; nothing here runs a tool.
|
|
3
|
-
* The user-visible conclusion of a work session is projectGoalPlan's conclusion.
|
|
4
|
-
*/
|
|
1
|
+
import { deriveSessionFacts } from "./session-facts.js";
|
|
5
2
|
import { projectGoalPlan, } from "./task-overview.js";
|
|
6
3
|
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'verifying',
|
|
7
4
|
'result_ready', 'accepted', 'failed', 'cancelled', 'superseded'];
|
|
@@ -44,38 +41,12 @@ export function createDelegationEvent(input) {
|
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
43
|
function delegationStatus(snapshot, meta, projected) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return 'verifying';
|
|
54
|
-
if (meta.acceptance === 'confirm' && meta.accepted !== true)
|
|
55
|
-
return 'result_ready';
|
|
56
|
-
return 'accepted';
|
|
57
|
-
}
|
|
58
|
-
if (meta.supersededBy)
|
|
59
|
-
return 'superseded';
|
|
60
|
-
if (meta.phase === 'paused')
|
|
61
|
-
return 'paused';
|
|
62
|
-
// 复核进行中盖过「需要你」。草稿、待批准、等回答的计划在独立复核时都显示 verifying。
|
|
63
|
-
if (meta.verifying || meta.phase === 'verifying')
|
|
64
|
-
return 'verifying';
|
|
65
|
-
if (projected.actionRight === 'needs_you')
|
|
66
|
-
return 'waiting_user';
|
|
67
|
-
if (snapshot.runnerStatus === 'exploring')
|
|
68
|
-
return 'verifying';
|
|
69
|
-
if (meta.phase === 'starting')
|
|
70
|
-
return 'starting';
|
|
71
|
-
if (snapshot.status === 'approved'
|
|
72
|
-
|| snapshot.status === 'accepted'
|
|
73
|
-
|| snapshot.status === 'paused'
|
|
74
|
-
|| snapshot.status === 'interrupted'
|
|
75
|
-
|| projected.actionRight === 'paused') {
|
|
76
|
-
return 'queued';
|
|
77
|
-
}
|
|
78
|
-
return 'running';
|
|
44
|
+
return deriveSessionFacts({ status: snapshot.status, runnerStatus: snapshot.runnerStatus,
|
|
45
|
+
accepted: meta.accepted === true || (snapshot.status === 'completed' && meta.acceptance !== 'confirm'
|
|
46
|
+
&& meta.accepted === undefined && !meta.verifying && !snapshot.runnerStatus),
|
|
47
|
+
superseded: Boolean(meta.supersededBy), phase: meta.phase,
|
|
48
|
+
needsUser: snapshot.status === 'awaiting_approval', verificationActive: meta.verifying === true,
|
|
49
|
+
}).status;
|
|
79
50
|
}
|
|
80
51
|
/**
|
|
81
52
|
* Project a GoalPlan snapshot into a work session.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Read-only display facts. A saved operation is not proof that its task completed. */
|
|
2
|
+
export interface EvidenceSourceDescription {
|
|
3
|
+
readonly evidenceRef: string;
|
|
4
|
+
readonly toolName?: string;
|
|
5
|
+
readonly createdAt?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectAgentEvidenceReadRequest {
|
|
8
|
+
readonly evidenceRef?: string;
|
|
9
|
+
/** Source descriptions only; at most 100 unique references, no body or artifact reads. */
|
|
10
|
+
readonly evidenceRefs?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ProjectAgentEvidenceReadResult {
|
|
13
|
+
readonly ok: boolean;
|
|
14
|
+
readonly code?: string;
|
|
15
|
+
readonly evidenceRef?: string;
|
|
16
|
+
readonly kind?: 'file' | 'command' | 'diff' | 'screenshot' | 'observation';
|
|
17
|
+
readonly summary?: string;
|
|
18
|
+
readonly truncated?: boolean;
|
|
19
|
+
readonly availability?: 'available' | 'metadata_only' | 'not_found' | 'unavailable';
|
|
20
|
+
readonly source?: EvidenceSourceDescription;
|
|
21
|
+
readonly items?: readonly EvidenceSourceDescription[];
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/goal.d.ts
CHANGED
|
@@ -164,9 +164,9 @@ export interface EvidenceIndexRecord {
|
|
|
164
164
|
readonly toolName?: string;
|
|
165
165
|
readonly createdAt: string;
|
|
166
166
|
readonly artifactRefs?: readonly string[];
|
|
167
|
-
/** Redacted, bounded execution-time snapshot of a successful
|
|
167
|
+
/** Redacted, bounded execution-time snapshot of a successful local Tool Result. */
|
|
168
168
|
readonly bodyPreview?: {
|
|
169
|
-
readonly kind: 'file';
|
|
169
|
+
readonly kind: 'file' | 'command';
|
|
170
170
|
readonly text: string;
|
|
171
171
|
readonly truncated: boolean;
|
|
172
172
|
};
|
|
@@ -444,7 +444,7 @@ export interface GoalRunTrace {
|
|
|
444
444
|
readonly lastCheckpointNodeId?: string;
|
|
445
445
|
readonly events: readonly GoalRunEvent[];
|
|
446
446
|
}
|
|
447
|
-
export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'manual';
|
|
447
|
+
export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'model_review' | 'manual';
|
|
448
448
|
export interface GoalSuccessCriterion {
|
|
449
449
|
readonly id: string;
|
|
450
450
|
readonly kind: GoalSuccessCriterionKind;
|
|
@@ -452,6 +452,21 @@ export interface GoalSuccessCriterion {
|
|
|
452
452
|
readonly command?: string;
|
|
453
453
|
readonly path?: string;
|
|
454
454
|
readonly expect?: string;
|
|
455
|
+
readonly authority?: {
|
|
456
|
+
readonly source: 'model' | 'user' | 'project_policy' | 'legacy_unknown';
|
|
457
|
+
readonly sourceRef?: string;
|
|
458
|
+
readonly version: number;
|
|
459
|
+
readonly verifier: 'mechanical' | 'host_model' | 'human';
|
|
460
|
+
readonly rationale: string;
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
export interface GoalModelReview {
|
|
464
|
+
readonly criterionId: string;
|
|
465
|
+
readonly sourceRevision: string;
|
|
466
|
+
readonly verifierRunId: string;
|
|
467
|
+
readonly passed: boolean;
|
|
468
|
+
readonly evidenceRefs: readonly string[];
|
|
469
|
+
readonly checkedAt: string;
|
|
455
470
|
}
|
|
456
471
|
export interface GoalCriterionResult {
|
|
457
472
|
readonly criterionId: string;
|
|
@@ -678,6 +693,9 @@ export interface GoalPlan {
|
|
|
678
693
|
readonly successCriteria: readonly GoalSuccessCriterion[];
|
|
679
694
|
readonly criterionResults: readonly GoalCriterionResult[];
|
|
680
695
|
readonly manualConfirmations?: readonly GoalManualConfirmation[];
|
|
696
|
+
readonly modelReviews?: readonly GoalModelReview[];
|
|
697
|
+
/** Host-derived current revision for checking semantic review freshness. */
|
|
698
|
+
readonly modelReviewSourceRevision?: string;
|
|
681
699
|
readonly boundaries: GoalBoundaries;
|
|
682
700
|
readonly exceptionPolicies: ExceptionPolicy[];
|
|
683
701
|
/** 顶层汇总(来源于子任务) */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export type { ProjectWorkReceipt, ProjectWorkState, ProjectTurnEnd } from './work-coordination.ts';
|
|
2
|
+
export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
|
|
3
|
+
export { projectAgentFailureKind, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
|
|
4
|
+
export type { EvidenceSourceDescription, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
|
|
5
|
+
export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
|
|
6
|
+
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
|
|
1
7
|
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
|
|
2
8
|
export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
|
|
3
9
|
export { evaluateUiDelivery } from './ui-delivery-verification.ts';
|
|
@@ -870,3 +876,4 @@ export * from './model-routing.ts';
|
|
|
870
876
|
export * from './project.ts';
|
|
871
877
|
export * from './objectives.ts';
|
|
872
878
|
export * from './remote-access-settings.ts';
|
|
879
|
+
export type { BotModelSelectionUpdateRequest, BotModelSelectionUpdateResult } from './bot-model-selection.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export { deriveSessionFacts } from "./session-facts.js";
|
|
2
|
+
export { projectAgentFailureKind } from "./project-agent-failure.js";
|
|
3
|
+
export { toolActivityPreview, toolActivitySummary } from "./tool-activity-preview.js";
|
|
4
|
+
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort } from "./model-reasoning.js";
|
|
1
5
|
export { buildModelMenuGroups, modelMenuChannelName } from "./model-menu.js";
|
|
2
6
|
export { evaluateUiDelivery } from "./ui-delivery-verification.js";
|
|
3
7
|
export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from "./desktop-preview.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Provider-declared effort values. Unknown capabilities do not create UI choices. */
|
|
2
|
+
export type ModelReasoningEffort = 'off' | 'low' | 'medium' | 'default' | 'high' | 'xhigh' | 'max';
|
|
3
|
+
export declare function isModelReasoningEffort(value: unknown): value is ModelReasoningEffort;
|
|
4
|
+
export declare function modelReasoningLevels(provider: {
|
|
5
|
+
readonly supportsReasoning?: unknown;
|
|
6
|
+
readonly reasoningEffortLevels?: unknown;
|
|
7
|
+
}): readonly ModelReasoningEffort[];
|
|
8
|
+
export declare function modelDefaultReasoningEffort(provider: {
|
|
9
|
+
readonly supportsReasoning?: unknown;
|
|
10
|
+
readonly reasoningEffortLevels?: unknown;
|
|
11
|
+
readonly reasoningEffort?: unknown;
|
|
12
|
+
readonly defaultEffort?: unknown;
|
|
13
|
+
}): ModelReasoningEffort | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const ORDER = ['off', 'low', 'medium', 'default', 'high', 'xhigh', 'max'];
|
|
2
|
+
export function isModelReasoningEffort(value) {
|
|
3
|
+
return ORDER.includes(value);
|
|
4
|
+
}
|
|
5
|
+
export function modelReasoningLevels(provider) {
|
|
6
|
+
if (provider.supportsReasoning === false || !Array.isArray(provider.reasoningEffortLevels))
|
|
7
|
+
return [];
|
|
8
|
+
const declared = provider.reasoningEffortLevels;
|
|
9
|
+
return ORDER.filter(value => declared.includes(value));
|
|
10
|
+
}
|
|
11
|
+
export function modelDefaultReasoningEffort(provider) {
|
|
12
|
+
const levels = modelReasoningLevels(provider);
|
|
13
|
+
for (const value of [provider.reasoningEffort, provider.defaultEffort, 'default', 'medium', 'high', 'low', ...levels]) {
|
|
14
|
+
if (isModelReasoningEffort(value) && levels.includes(value))
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
package/dist/model-routing.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ModelReasoningEffort } from './model-reasoning.ts';
|
|
1
2
|
/**
|
|
2
3
|
* Role and tier model routing. Resolution is pure; hosts apply the result.
|
|
3
4
|
* Order and filters follow ADR 83. An empty candidate set is an error, not a silent downgrade.
|
|
@@ -10,6 +11,7 @@ export type RoleSetting = {
|
|
|
10
11
|
} | {
|
|
11
12
|
readonly mode: 'fixed';
|
|
12
13
|
readonly modelProviderId: string;
|
|
14
|
+
readonly reasoningEffort?: ModelReasoningEffort;
|
|
13
15
|
} | {
|
|
14
16
|
readonly mode: 'auto';
|
|
15
17
|
readonly pool: readonly string[];
|
|
@@ -65,7 +67,15 @@ export interface ModelRoutingMenuOption {
|
|
|
65
67
|
readonly supportsTools: boolean;
|
|
66
68
|
readonly supportsStructured: boolean;
|
|
67
69
|
readonly contextTokens: number;
|
|
70
|
+
readonly available?: boolean;
|
|
71
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
72
|
+
readonly defaultReasoningEffort?: ModelReasoningEffort;
|
|
68
73
|
}
|
|
74
|
+
export interface BotRoleModelView {
|
|
75
|
+
readonly resolution: ModelResolution;
|
|
76
|
+
readonly eligibleModelIds: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
export type BotModelViews = Partial<Record<ModelRole, BotRoleModelView>>;
|
|
69
79
|
/** Project one configured provider into the routing menu contract. */
|
|
70
80
|
export declare function projectModelRoutingMenuOption(provider: {
|
|
71
81
|
readonly id?: unknown;
|
|
@@ -81,6 +91,12 @@ export declare function projectModelRoutingMenuOption(provider: {
|
|
|
81
91
|
readonly toolUse?: unknown;
|
|
82
92
|
} | null;
|
|
83
93
|
readonly contextWindow?: unknown;
|
|
94
|
+
readonly apiKeyConfigured?: unknown;
|
|
95
|
+
readonly enabled?: unknown;
|
|
96
|
+
readonly supportsReasoning?: unknown;
|
|
97
|
+
readonly reasoningEffortLevels?: unknown;
|
|
98
|
+
readonly reasoningEffort?: unknown;
|
|
99
|
+
readonly defaultEffort?: unknown;
|
|
84
100
|
} | null | undefined): ModelRoutingMenuOption | null;
|
|
85
101
|
export interface CatalogModel {
|
|
86
102
|
readonly modelProviderId: string;
|
|
@@ -93,6 +109,7 @@ export interface CatalogModel {
|
|
|
93
109
|
readonly contextTokens?: number;
|
|
94
110
|
readonly local?: boolean;
|
|
95
111
|
readonly reasoningEffort?: string;
|
|
112
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
96
113
|
}
|
|
97
114
|
export type ModelResolution = {
|
|
98
115
|
readonly ok: true;
|
|
@@ -101,7 +118,7 @@ export type ModelResolution = {
|
|
|
101
118
|
readonly sameFamilyAsWorker?: boolean;
|
|
102
119
|
} | {
|
|
103
120
|
readonly ok: false;
|
|
104
|
-
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty';
|
|
121
|
+
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty' | 'reasoning';
|
|
105
122
|
readonly missing: string;
|
|
106
123
|
};
|
|
107
124
|
export interface RoleModelRequest {
|
package/dist/model-routing.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Role and tier model routing. Resolution is pure; hosts apply the result.
|
|
3
|
-
* Order and filters follow ADR 83. An empty candidate set is an error, not a silent downgrade.
|
|
4
|
-
*/
|
|
1
|
+
import { modelDefaultReasoningEffort, modelReasoningLevels } from "./model-reasoning.js";
|
|
5
2
|
/** Project one configured provider into the routing menu contract. */
|
|
6
3
|
export function projectModelRoutingMenuOption(provider) {
|
|
7
4
|
if (!provider || typeof provider.id !== 'string' || !provider.id.trim())
|
|
@@ -24,6 +21,9 @@ export function projectModelRoutingMenuOption(provider) {
|
|
|
24
21
|
supportsTools: provider.supportsTools !== false && provider.capabilities?.toolUse !== false,
|
|
25
22
|
supportsStructured: provider.supportsStructured !== false,
|
|
26
23
|
contextTokens: Number.isFinite(context) && context > 0 ? context : 128_000,
|
|
24
|
+
available: provider.enabled !== false && provider.apiKeyConfigured === true,
|
|
25
|
+
reasoningEffortLevels: modelReasoningLevels(provider),
|
|
26
|
+
defaultReasoningEffort: modelDefaultReasoningEffort(provider),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const EXPLORER_MIN_CONTEXT = 8_000;
|
|
@@ -75,6 +75,8 @@ function inScope(model, policy) {
|
|
|
75
75
|
return true;
|
|
76
76
|
}
|
|
77
77
|
function missingText(input, reason) {
|
|
78
|
+
if (reason === 'reasoning')
|
|
79
|
+
return '所选模型不支持该推理强度';
|
|
78
80
|
if (reason === 'auto_pool')
|
|
79
81
|
return '所选模型不在自动池内';
|
|
80
82
|
const localOnly = input.projectPolicy?.scope?.localOnly === true;
|
|
@@ -226,10 +228,13 @@ export function resolveRoleModel(input) {
|
|
|
226
228
|
const chosen = ordered[0];
|
|
227
229
|
if (!chosen)
|
|
228
230
|
return fail(input, 'empty');
|
|
231
|
+
const requestedEffort = layer.setting.mode === 'fixed' ? layer.setting.reasoningEffort : undefined;
|
|
232
|
+
if (requestedEffort !== undefined && !chosen.reasoningEffortLevels?.includes(requestedEffort))
|
|
233
|
+
return fail(input, 'reasoning');
|
|
229
234
|
const source = layer.setting.mode === 'auto' ? 'auto' : layer.source;
|
|
230
235
|
return {
|
|
231
236
|
ok: true,
|
|
232
|
-
selection: toSelection(chosen),
|
|
237
|
+
selection: { ...toSelection(chosen), ...(requestedEffort !== undefined ? { reasoningEffort: requestedEffort } : {}) },
|
|
233
238
|
source,
|
|
234
239
|
...(input.role === 'verifier'
|
|
235
240
|
? { sameFamilyAsWorker: sameFamily(chosen, input.workerModel) }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DelegationEvent } from './delegation.ts';
|
|
2
|
+
/** Host failure classification, including the persisted diagnostic prefix used by older cards. */
|
|
3
|
+
export declare function projectAgentFailureKind(reason: unknown): 'budget_exhausted' | 'unavailable';
|
|
4
|
+
/** Durable host facts for an explicit retry; never a new user authorization. */
|
|
5
|
+
export interface ProjectAgentTurnRecovery {
|
|
6
|
+
readonly events: readonly DelegationEvent[];
|
|
7
|
+
readonly throughSeq: number;
|
|
8
|
+
}
|
|
9
|
+
/** Factual recovery data returned by post_reply after anchor validation fails. */
|
|
10
|
+
export interface ReplyAnchorCandidate {
|
|
11
|
+
readonly messageId: string;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Host failure classification, including the persisted diagnostic prefix used by older cards. */
|
|
2
|
+
export function projectAgentFailureKind(reason) {
|
|
3
|
+
if (typeof reason !== 'string')
|
|
4
|
+
return 'unavailable';
|
|
5
|
+
const code = reason.trim().replace(/^代理暂时不可用:\s*/, '');
|
|
6
|
+
return /^(agent_tool_budget_exhausted|agent_loop_exhausted|work_budget_limited)(?:\s*:|$)/.test(code)
|
|
7
|
+
? 'budget_exhausted' : 'unavailable';
|
|
8
|
+
}
|
package/dist/project.d.ts
CHANGED
|
@@ -4,6 +4,116 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ProjectModelPolicy } from './model-routing.ts';
|
|
6
6
|
import type { PendingApprovalState, WorkSessionStatus } from './delegation.ts';
|
|
7
|
+
export interface DiagnosticText {
|
|
8
|
+
readonly length: number;
|
|
9
|
+
readonly sha256: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProjectAgentDiagnosticTiming {
|
|
12
|
+
readonly startedAt: string;
|
|
13
|
+
readonly finishedAt: string;
|
|
14
|
+
readonly durationMs: number;
|
|
15
|
+
readonly outcome: 'done' | 'error' | 'preempted';
|
|
16
|
+
}
|
|
17
|
+
export interface ProjectDiagnostics {
|
|
18
|
+
readonly schemaVersion: 1;
|
|
19
|
+
readonly generatedAt: string | null;
|
|
20
|
+
readonly errors: readonly string[];
|
|
21
|
+
readonly scheduler: {
|
|
22
|
+
readonly stats: {
|
|
23
|
+
readonly active: number | null;
|
|
24
|
+
readonly waiting: number | null;
|
|
25
|
+
readonly limit: number | null;
|
|
26
|
+
};
|
|
27
|
+
readonly queue: readonly {
|
|
28
|
+
readonly workspace: DiagnosticText | null;
|
|
29
|
+
readonly plan: DiagnosticText | null;
|
|
30
|
+
readonly priority: string;
|
|
31
|
+
readonly enqueuedAt: string | null;
|
|
32
|
+
}[];
|
|
33
|
+
readonly projects: readonly {
|
|
34
|
+
readonly workspace: DiagnosticText | null;
|
|
35
|
+
readonly slots: {
|
|
36
|
+
readonly read: number | null;
|
|
37
|
+
readonly write: number | null;
|
|
38
|
+
readonly isolated: number | null;
|
|
39
|
+
};
|
|
40
|
+
readonly queue: readonly {
|
|
41
|
+
readonly session: DiagnosticText | null;
|
|
42
|
+
readonly priority: string;
|
|
43
|
+
readonly enqueuedAt: string | null;
|
|
44
|
+
readonly reason: string | null;
|
|
45
|
+
}[];
|
|
46
|
+
}[];
|
|
47
|
+
} | null;
|
|
48
|
+
readonly bots: readonly {
|
|
49
|
+
readonly identity: DiagnosticText | null;
|
|
50
|
+
readonly workspace: '.';
|
|
51
|
+
readonly errors: readonly string[];
|
|
52
|
+
readonly lease: {
|
|
53
|
+
readonly holder: DiagnosticText | null;
|
|
54
|
+
readonly surface: string;
|
|
55
|
+
readonly pid: number | null;
|
|
56
|
+
readonly acquiredAt: string | null;
|
|
57
|
+
readonly heartbeatAt: string | null;
|
|
58
|
+
} | null;
|
|
59
|
+
readonly input: {
|
|
60
|
+
readonly depth: number | null;
|
|
61
|
+
readonly executionDepth: number | null;
|
|
62
|
+
readonly cursor: DiagnosticText | null;
|
|
63
|
+
readonly executedCursor: DiagnosticText | null;
|
|
64
|
+
} | null;
|
|
65
|
+
readonly inbox: {
|
|
66
|
+
readonly cursor: number | null;
|
|
67
|
+
readonly events: readonly {
|
|
68
|
+
readonly identity: DiagnosticText | null;
|
|
69
|
+
readonly seq: number | null;
|
|
70
|
+
readonly at: string | null;
|
|
71
|
+
readonly kind: string;
|
|
72
|
+
}[];
|
|
73
|
+
} | null;
|
|
74
|
+
readonly approvals: readonly {
|
|
75
|
+
readonly identity: DiagnosticText | null;
|
|
76
|
+
readonly state: 'open' | 'stale';
|
|
77
|
+
readonly capability: DiagnosticText | null;
|
|
78
|
+
readonly summary: DiagnosticText | null;
|
|
79
|
+
readonly at: string | null;
|
|
80
|
+
}[];
|
|
81
|
+
readonly objectives: readonly {
|
|
82
|
+
readonly identity: DiagnosticText | null;
|
|
83
|
+
readonly status: string;
|
|
84
|
+
readonly autonomy: string;
|
|
85
|
+
readonly watches: readonly {
|
|
86
|
+
readonly identity: DiagnosticText | null;
|
|
87
|
+
readonly kind: string;
|
|
88
|
+
readonly source: string;
|
|
89
|
+
readonly paths: readonly string[];
|
|
90
|
+
readonly lastObservationAt: string | null;
|
|
91
|
+
readonly nextRunAt: string | null;
|
|
92
|
+
readonly pending: boolean;
|
|
93
|
+
readonly unavailable: boolean;
|
|
94
|
+
}[];
|
|
95
|
+
}[];
|
|
96
|
+
readonly turns: readonly {
|
|
97
|
+
readonly identity: DiagnosticText | null;
|
|
98
|
+
readonly startedAt: string | null;
|
|
99
|
+
readonly finishedAt: string | null;
|
|
100
|
+
readonly durationMs: number | null;
|
|
101
|
+
readonly outcome: string;
|
|
102
|
+
}[];
|
|
103
|
+
}[];
|
|
104
|
+
}
|
|
105
|
+
export type ProjectDiagnosticsRequest = {
|
|
106
|
+
readonly action: 'read' | 'export';
|
|
107
|
+
};
|
|
108
|
+
export type ProjectDiagnosticsResult = {
|
|
109
|
+
readonly ok: true;
|
|
110
|
+
readonly report: ProjectDiagnostics;
|
|
111
|
+
readonly saved?: boolean;
|
|
112
|
+
readonly cancelled?: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
readonly ok: false;
|
|
115
|
+
readonly code: 'INVALID_INPUT' | 'DIAGNOSTICS_UNAVAILABLE' | 'DIAGNOSTICS_SAVE_FAILED';
|
|
116
|
+
};
|
|
7
117
|
export interface ProjectRegistryEntry {
|
|
8
118
|
readonly workspaceId: string;
|
|
9
119
|
readonly path: string;
|
|
@@ -79,6 +189,58 @@ export interface BotListFilter {
|
|
|
79
189
|
readonly query?: string;
|
|
80
190
|
readonly needsYouOnly?: boolean;
|
|
81
191
|
}
|
|
192
|
+
/** Bounded, redacted display preview; never an execution or Evidence object. */
|
|
193
|
+
export interface ProjectAgentToolPreview {
|
|
194
|
+
readonly text: string;
|
|
195
|
+
readonly truncated: boolean;
|
|
196
|
+
readonly redacted: boolean;
|
|
197
|
+
}
|
|
198
|
+
export interface ProjectAgentToolActivity {
|
|
199
|
+
readonly kind: 'tool';
|
|
200
|
+
readonly id: string;
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly status: 'preparing' | 'running' | 'done' | 'error' | 'stopped';
|
|
203
|
+
readonly startedAt?: string;
|
|
204
|
+
readonly finishedAt?: string;
|
|
205
|
+
readonly summary?: string;
|
|
206
|
+
readonly input?: ProjectAgentToolPreview;
|
|
207
|
+
readonly result?: ProjectAgentToolPreview;
|
|
208
|
+
readonly receivedChars?: number;
|
|
209
|
+
}
|
|
210
|
+
/** Public conversation update, never hidden reasoning, Tool Result or Evidence.
|
|
211
|
+
* User agent_turn records may persist these as publicUpdates (100 / 32000 chars).
|
|
212
|
+
* Legacy rounds[].text is not a public-update source.
|
|
213
|
+
*/
|
|
214
|
+
export interface ProjectAgentPublicUpdate {
|
|
215
|
+
readonly id: string;
|
|
216
|
+
readonly text: string;
|
|
217
|
+
}
|
|
218
|
+
/** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
|
|
219
|
+
export interface ProjectAgentActivity {
|
|
220
|
+
readonly workspaceId: string;
|
|
221
|
+
readonly conversationId: string;
|
|
222
|
+
readonly turnId: string;
|
|
223
|
+
readonly revision: number;
|
|
224
|
+
readonly startedAt: string;
|
|
225
|
+
readonly finishedAt?: string;
|
|
226
|
+
readonly modelSelection?: Pick<import('./model-routing.ts').RuntimeModelSelection, 'modelProviderId' | 'reasoningEffort'>;
|
|
227
|
+
readonly replyTo: readonly string[];
|
|
228
|
+
readonly phase: 'waiting' | 'thinking' | 'responding' | 'tool' | 'settling' | 'done' | 'error' | 'stopped' | 'disposed';
|
|
229
|
+
readonly replyText: string;
|
|
230
|
+
readonly segments: readonly (({
|
|
231
|
+
readonly kind: 'text';
|
|
232
|
+
} & ProjectAgentPublicUpdate) | ProjectAgentToolActivity)[];
|
|
233
|
+
}
|
|
234
|
+
export interface ProjectAgentStopResponseRequest {
|
|
235
|
+
readonly workspaceId: string;
|
|
236
|
+
readonly turnId: string;
|
|
237
|
+
}
|
|
238
|
+
export type ProjectAgentStopResponseResult = {
|
|
239
|
+
readonly ok: true;
|
|
240
|
+
} | {
|
|
241
|
+
readonly ok: false;
|
|
242
|
+
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
|
|
243
|
+
};
|
|
82
244
|
export interface BotListSession {
|
|
83
245
|
readonly status: WorkSessionStatus;
|
|
84
246
|
readonly updatedAt?: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WorkSessionStatus } from './delegation.ts';
|
|
2
|
+
export interface SessionFactSnapshot {
|
|
3
|
+
readonly status: WorkSessionStatus;
|
|
4
|
+
readonly verificationActive: boolean;
|
|
5
|
+
readonly needsUser: boolean;
|
|
6
|
+
readonly blockedReason?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function deriveSessionFacts(input: {
|
|
9
|
+
status?: string;
|
|
10
|
+
phase?: string;
|
|
11
|
+
runnerStatus?: string;
|
|
12
|
+
accepted?: boolean;
|
|
13
|
+
superseded?: boolean;
|
|
14
|
+
needsUser?: boolean;
|
|
15
|
+
blockedReason?: string;
|
|
16
|
+
verificationActive?: boolean;
|
|
17
|
+
}): SessionFactSnapshot;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function deriveSessionFacts(input) {
|
|
2
|
+
const verificationActive = input.verificationActive === true;
|
|
3
|
+
let status;
|
|
4
|
+
if (input.status === 'cancelled')
|
|
5
|
+
status = 'cancelled';
|
|
6
|
+
else if (input.status === 'failed')
|
|
7
|
+
status = 'failed';
|
|
8
|
+
else if (input.accepted)
|
|
9
|
+
status = 'accepted';
|
|
10
|
+
else if (input.needsUser || ['blocked', 'waiting_user'].includes(input.runnerStatus || ''))
|
|
11
|
+
status = 'waiting_user';
|
|
12
|
+
else if (verificationActive)
|
|
13
|
+
status = 'verifying';
|
|
14
|
+
else if (input.status === 'completed' && ['running', 'starting', 'waiting_provider', 'resuming_after_compaction'].includes(input.runnerStatus || ''))
|
|
15
|
+
status = 'running';
|
|
16
|
+
else if (input.status === 'completed')
|
|
17
|
+
status = 'result_ready';
|
|
18
|
+
else if (input.superseded)
|
|
19
|
+
status = 'superseded';
|
|
20
|
+
else if (input.phase === 'paused')
|
|
21
|
+
status = 'paused';
|
|
22
|
+
else if (input.phase === 'starting')
|
|
23
|
+
status = 'starting';
|
|
24
|
+
else if (['approved', 'accepted', 'paused', 'interrupted'].includes(input.status || '') || input.phase === 'queued')
|
|
25
|
+
status = 'queued';
|
|
26
|
+
else
|
|
27
|
+
status = 'running';
|
|
28
|
+
return { status, verificationActive: status === 'verifying', needsUser: status === 'waiting_user',
|
|
29
|
+
...(input.blockedReason ? { blockedReason: input.blockedReason } : {}) };
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProjectAgentToolPreview } from './project.ts';
|
|
2
|
+
/** One bounded display seam for tool parameters/results in live and historical presentation. It never executes a tool. */
|
|
3
|
+
export declare function toolActivityPreview(value: unknown, limit: number): ProjectAgentToolPreview;
|
|
4
|
+
export declare function toolActivitySummary(input: Readonly<Record<string, unknown>> | null | undefined): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const PRIVATE_FIELD = /(?:api.?key|token|secret|password|credential|authorization|cookie|private.?key|reasoning|thinking)/i;
|
|
2
|
+
/** One bounded display seam for tool parameters/results in live and historical presentation. It never executes a tool. */
|
|
3
|
+
export function toolActivityPreview(value, limit) {
|
|
4
|
+
if (typeof value === 'string' && value.length > 64_000)
|
|
5
|
+
return { text: '', truncated: true, redacted: true };
|
|
6
|
+
let redacted = false, truncated = false, nodes = 0;
|
|
7
|
+
const cleanText = (text) => {
|
|
8
|
+
const bounded = text.slice(0, 6000);
|
|
9
|
+
if (bounded.length < text.length)
|
|
10
|
+
truncated = true;
|
|
11
|
+
const clean = bounded
|
|
12
|
+
.replace(/\b(?:sk|pk|rk)-[A-Za-z0-9_-]{8,}/g, '[redacted]')
|
|
13
|
+
.replace(/AKIA[0-9A-Z]{16}/g, '[redacted]')
|
|
14
|
+
.replace(/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi, 'Bearer [redacted]')
|
|
15
|
+
.replace(/((?:api[_-]?key|token|secret|password|authorization|cookie)\s*["']?\s*[:=]\s*["']?)[^\s,"';}]+/gi, '$1[redacted]')
|
|
16
|
+
.replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*/g, '[redacted]');
|
|
17
|
+
if (clean !== bounded)
|
|
18
|
+
redacted = true;
|
|
19
|
+
return clean;
|
|
20
|
+
};
|
|
21
|
+
const visit = (item, depth = 0) => {
|
|
22
|
+
if (++nodes > 160 || depth > 6) {
|
|
23
|
+
truncated = true;
|
|
24
|
+
return '[truncated]';
|
|
25
|
+
}
|
|
26
|
+
if (typeof item === 'string')
|
|
27
|
+
return cleanText(item);
|
|
28
|
+
if (item == null || typeof item === 'boolean' || typeof item === 'number')
|
|
29
|
+
return item;
|
|
30
|
+
if (Array.isArray(item)) {
|
|
31
|
+
if (item.length > 40)
|
|
32
|
+
truncated = true;
|
|
33
|
+
return item.slice(0, 40).map(child => visit(child, depth + 1));
|
|
34
|
+
}
|
|
35
|
+
if (typeof item === 'object') {
|
|
36
|
+
const fields = [];
|
|
37
|
+
for (const key in item) {
|
|
38
|
+
if (!Object.hasOwn(item, key))
|
|
39
|
+
continue;
|
|
40
|
+
if (fields.length >= 40) {
|
|
41
|
+
truncated = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (PRIVATE_FIELD.test(key)) {
|
|
45
|
+
redacted = true;
|
|
46
|
+
fields.push([key, '[redacted]']);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
fields.push([cleanText(key), visit(item[key], depth + 1)]);
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(fields);
|
|
52
|
+
}
|
|
53
|
+
return String(item);
|
|
54
|
+
};
|
|
55
|
+
let parsed = value;
|
|
56
|
+
if (typeof value === 'string') {
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(value);
|
|
59
|
+
}
|
|
60
|
+
catch { /* Plain terminal/file output. */ }
|
|
61
|
+
}
|
|
62
|
+
const clean = visit(parsed);
|
|
63
|
+
const text = typeof clean === 'string' ? clean : JSON.stringify(clean ?? null, null, 2);
|
|
64
|
+
return { text: text.slice(0, limit), truncated: truncated || text.length > limit, redacted };
|
|
65
|
+
}
|
|
66
|
+
export function toolActivitySummary(input) {
|
|
67
|
+
const value = input?.path ?? input?.command ?? input?.cmd ?? input?.query ?? input?.title;
|
|
68
|
+
return typeof value === 'string' ? toolActivityPreview(value.replace(/\s+/g, ' ').trim(), 160).text : '';
|
|
69
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type ProjectWorkState = 'runnable' | 'waiting_children' | 'waiting_user' | 'retry_wait' | 'paused' | 'budget_limited' | 'blocked_system' | 'delivered' | 'cancelled';
|
|
2
|
+
export type ProjectTurnEnd = 'reply_committed' | 'awaiting_children' | 'yielded' | 'awaiting_user' | 'budget_limited' | 'provider_retryable' | 'no_progress' | 'user_stopped' | 'fatal';
|
|
3
|
+
export interface ProjectWorkReceipt {
|
|
4
|
+
readonly schemaVersion: 1;
|
|
5
|
+
readonly workId: string;
|
|
6
|
+
readonly workspaceId: string;
|
|
7
|
+
readonly parentConversationId: string;
|
|
8
|
+
readonly anchorInputIds: readonly string[];
|
|
9
|
+
readonly sessionIds: readonly string[];
|
|
10
|
+
readonly state: ProjectWorkState;
|
|
11
|
+
readonly revision: number;
|
|
12
|
+
readonly checkpointRef?: string;
|
|
13
|
+
readonly nativeCheckpointRef?: string;
|
|
14
|
+
readonly end?: ProjectTurnEnd;
|
|
15
|
+
readonly attemptId?: string;
|
|
16
|
+
readonly pendingEventIds?: readonly string[];
|
|
17
|
+
readonly waitFor: readonly {
|
|
18
|
+
readonly kind: 'session' | 'approval' | 'question' | 'retry_timer';
|
|
19
|
+
readonly id: string;
|
|
20
|
+
}[];
|
|
21
|
+
readonly consumedEventIds: readonly string[];
|
|
22
|
+
readonly pendingResultRefs: readonly string[];
|
|
23
|
+
readonly lastDeliveredFactKey?: string;
|
|
24
|
+
readonly budgetRef?: string;
|
|
25
|
+
readonly budget?: {
|
|
26
|
+
readonly modelRequests: number;
|
|
27
|
+
readonly toolCalls: number;
|
|
28
|
+
readonly tokens: number;
|
|
29
|
+
readonly costUsd: number;
|
|
30
|
+
readonly unknownUsage: boolean;
|
|
31
|
+
readonly unknownCost: boolean;
|
|
32
|
+
readonly limits: {
|
|
33
|
+
readonly maxModelRequests: number;
|
|
34
|
+
readonly maxToolCalls: number;
|
|
35
|
+
readonly maxTokens?: number;
|
|
36
|
+
readonly maxCostUsd?: number;
|
|
37
|
+
readonly source: string;
|
|
38
|
+
};
|
|
39
|
+
readonly attempts: Readonly<Record<string, {
|
|
40
|
+
readonly role: string;
|
|
41
|
+
readonly requests?: number;
|
|
42
|
+
readonly modelProviderId?: string;
|
|
43
|
+
readonly checkpointRef?: string;
|
|
44
|
+
readonly pendingTools?: readonly {
|
|
45
|
+
readonly toolCallId: string | null;
|
|
46
|
+
readonly capabilityId: string | null;
|
|
47
|
+
}[];
|
|
48
|
+
}>>;
|
|
49
|
+
readonly uncertainDispatches?: readonly {
|
|
50
|
+
readonly attemptId: string;
|
|
51
|
+
readonly role: string;
|
|
52
|
+
readonly toolCallId: string | null;
|
|
53
|
+
readonly capabilityId: string | null;
|
|
54
|
+
}[];
|
|
55
|
+
};
|
|
56
|
+
readonly stopScope: 'reply' | 'work';
|
|
57
|
+
readonly updatedAt: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|