@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.50
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/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/attention.d.ts +44 -0
- package/dist/attention.js +1 -0
- package/dist/bot-access-policy.d.ts +29 -0
- package/dist/bot-access-policy.js +1 -0
- package/dist/bot-conversation-read.d.ts +67 -0
- package/dist/bot-conversation-read.js +9 -0
- package/dist/bot-direct-step.d.ts +11 -0
- package/dist/bot-direct-step.js +1 -0
- package/dist/bot-git.d.ts +55 -0
- package/dist/bot-git.js +1 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/browser-window.d.ts +48 -0
- package/dist/browser-window.js +23 -0
- package/dist/capability-admission.d.ts +20 -0
- package/dist/capability-admission.js +1 -0
- package/dist/compaction-history-selection.d.ts +15 -0
- package/dist/compaction-history-selection.js +30 -0
- package/dist/compaction.d.ts +5 -0
- package/dist/compaction.js +6 -0
- package/dist/context-accounting.d.ts +3 -0
- package/dist/conversation-execution.d.ts +68 -0
- package/dist/conversation-execution.js +222 -0
- package/dist/delegation-coordination.d.ts +81 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +260 -7
- package/dist/delegation.js +97 -39
- package/dist/document-reference.d.ts +111 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +64 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/goal.d.ts +50 -2
- package/dist/hook-observation.d.ts +2 -0
- package/dist/hook-observation.js +19 -0
- package/dist/index.d.ts +109 -25
- package/dist/index.js +38 -0
- package/dist/input-prediction.d.ts +86 -0
- package/dist/input-prediction.js +48 -0
- package/dist/intent-coordination.d.ts +201 -0
- package/dist/intent-coordination.js +1 -0
- package/dist/interactive-result.d.ts +363 -0
- package/dist/interactive-result.js +215 -0
- package/dist/interactive-verification.d.ts +41 -0
- package/dist/interactive-verification.js +65 -0
- package/dist/local-git.d.ts +44 -0
- package/dist/local-git.js +3 -0
- package/dist/local-image.d.ts +53 -0
- package/dist/local-image.js +5 -0
- package/dist/local-read.d.ts +9 -0
- package/dist/local-read.js +1 -0
- package/dist/memory.d.ts +71 -11
- package/dist/memory.js +12 -0
- package/dist/model-reasoning.d.ts +16 -0
- package/dist/model-reasoning.js +25 -0
- package/dist/model-routing.d.ts +39 -3
- package/dist/model-routing.js +31 -5
- package/dist/native-process.d.ts +21 -0
- package/dist/native-process.js +51 -0
- package/dist/parent-coordination.d.ts +104 -0
- package/dist/parent-coordination.js +2 -0
- package/dist/project-agent-failure.d.ts +30 -0
- package/dist/project-agent-failure.js +44 -0
- package/dist/project-input-recovery.d.ts +83 -0
- package/dist/project-input-recovery.js +25 -0
- package/dist/project-matter.d.ts +225 -0
- package/dist/project-matter.js +1 -0
- package/dist/project-recovery.d.ts +43 -0
- package/dist/project-recovery.js +1 -0
- package/dist/project.d.ts +136 -0
- package/dist/project.js +130 -5
- package/dist/quiet-reply.d.ts +9 -0
- package/dist/quiet-reply.js +43 -0
- package/dist/remote-access.d.ts +15 -0
- package/dist/remote-access.js +1 -1
- package/dist/reply-delivery.d.ts +28 -0
- package/dist/reply-delivery.js +1 -0
- package/dist/resource-edit-execution.d.ts +68 -0
- package/dist/resource-edit-execution.js +96 -0
- package/dist/resource-edit.d.ts +237 -0
- package/dist/resource-edit.js +134 -0
- package/dist/resource-feedback-transport.d.ts +26 -0
- package/dist/resource-feedback-transport.js +94 -0
- package/dist/resource-feedback.d.ts +98 -0
- package/dist/resource-feedback.js +151 -0
- package/dist/resource-file-replace.d.ts +36 -0
- package/dist/resource-file-replace.js +40 -0
- package/dist/resource-reference-hints.d.ts +3 -0
- package/dist/resource-reference-hints.js +58 -0
- package/dist/resource-window.d.ts +222 -0
- package/dist/resource-window.js +252 -0
- package/dist/runtime-session-facts.d.ts +58 -0
- package/dist/runtime-session-facts.js +57 -0
- package/dist/session-control.d.ts +211 -0
- package/dist/session-control.js +48 -0
- package/dist/session-facts.d.ts +29 -0
- package/dist/session-facts.js +35 -0
- package/dist/skill-marketplace.d.ts +39 -4
- package/dist/spend-budget.d.ts +69 -0
- package/dist/spend-budget.js +1 -0
- package/dist/system-context.d.ts +7 -0
- package/dist/task-overview.d.ts +91 -0
- package/dist/task-overview.js +325 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/updater.d.ts +13 -3
- package/dist/usage-accounting.d.ts +42 -1
- package/dist/user-anchor.d.ts +17 -0
- package/dist/user-anchor.js +1 -0
- package/dist/work-coordination.d.ts +188 -0
- package/dist/work-coordination.js +1 -0
- package/dist/work-hook.d.ts +3 -0
- package/dist/work-hook.js +76 -0
- package/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.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,81 @@
|
|
|
1
|
+
/** Local coordination facts. These records never grant project capabilities or human approval. */
|
|
2
|
+
export type AgentDeliveryIntent = 'mailbox_only' | 'ensure_turn';
|
|
3
|
+
export type InterruptionOrigin = 'user' | 'provider' | 'host_handoff' | 'lease_loss' | 'tool' | 'budget' | 'unknown';
|
|
4
|
+
export interface AgentDecisionRequest {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly workId: string;
|
|
7
|
+
readonly parentConversationId: string;
|
|
8
|
+
readonly requestId: string;
|
|
9
|
+
readonly revision: number;
|
|
10
|
+
readonly question: string;
|
|
11
|
+
readonly options?: readonly {
|
|
12
|
+
readonly optionId: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
}[];
|
|
15
|
+
readonly multiple?: boolean;
|
|
16
|
+
readonly allowText: boolean;
|
|
17
|
+
readonly responder: 'parent' | 'user';
|
|
18
|
+
readonly status: 'open' | 'answered' | 'cancelled';
|
|
19
|
+
readonly goalRevision: number;
|
|
20
|
+
readonly answerId?: string;
|
|
21
|
+
readonly userRequestRef?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AgentDecisionAnswer {
|
|
24
|
+
/** Host-issued linkage to a current native user answer; never model arguments. */
|
|
25
|
+
readonly sourceInputId?: string;
|
|
26
|
+
readonly userRequestRef?: string;
|
|
27
|
+
readonly requestId: string;
|
|
28
|
+
readonly expectedRequestRevision: number;
|
|
29
|
+
readonly optionIds?: readonly string[];
|
|
30
|
+
readonly text?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentCommandReceipt {
|
|
33
|
+
readonly workspaceId: string;
|
|
34
|
+
readonly operationId: string;
|
|
35
|
+
readonly messageId: string;
|
|
36
|
+
readonly sessionId: string;
|
|
37
|
+
readonly goalRevision: number;
|
|
38
|
+
readonly executionEpoch?: string;
|
|
39
|
+
readonly delivery: 'queued' | 'observed';
|
|
40
|
+
readonly admission: 'not_requested' | 'pending' | 'admitted' | 'rejected';
|
|
41
|
+
readonly effect: 'not_requested' | 'pending' | 'applied' | 'unknown' | 'rejected';
|
|
42
|
+
readonly error?: string;
|
|
43
|
+
readonly observedAt?: string;
|
|
44
|
+
readonly attemptRef?: string;
|
|
45
|
+
readonly completionRecorded?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface ContextWindowRecord {
|
|
48
|
+
readonly state: 'prepared';
|
|
49
|
+
readonly windowId: string;
|
|
50
|
+
readonly workId: string;
|
|
51
|
+
readonly conversationId: string;
|
|
52
|
+
readonly previousWindowId?: string;
|
|
53
|
+
readonly historyCursor?: string;
|
|
54
|
+
readonly hint: string;
|
|
55
|
+
readonly obligationRefs: readonly string[];
|
|
56
|
+
readonly budgetRef: string;
|
|
57
|
+
readonly at: string;
|
|
58
|
+
}
|
|
59
|
+
export interface WorkNoteRevision {
|
|
60
|
+
readonly noteId: string;
|
|
61
|
+
readonly revision: number;
|
|
62
|
+
readonly workId: string;
|
|
63
|
+
readonly conversationId: string;
|
|
64
|
+
readonly text: string;
|
|
65
|
+
readonly sourceRefs: readonly string[];
|
|
66
|
+
readonly at: string;
|
|
67
|
+
}
|
|
68
|
+
/** Bounded task-detail projection; roster queries do not hydrate the mailbox. */
|
|
69
|
+
export interface AgentSupervisionReport {
|
|
70
|
+
readonly recovery?: {
|
|
71
|
+
readonly state: 'settled' | 'waiting_user' | 'waiting_agent' | 'observing' | 'reconciliation_required' | 'user_stopped' | 'legacy_unbound' | 'blocked' | 'repairable';
|
|
72
|
+
readonly blockers: readonly string[];
|
|
73
|
+
readonly nextAction: 'none' | 'native_user_decision' | 'inspect_original_results' | 'current_user_required' | 'adopt_with_current_user' | 'inspect_blocker_and_change_method' | 'inspect_current_facts' | 'coordinate_resume' | 'answer_agent_request' | 'observe_current_attempt';
|
|
74
|
+
readonly expectedRevision?: number;
|
|
75
|
+
readonly requestId?: string;
|
|
76
|
+
readonly expectedRequestRevision?: number;
|
|
77
|
+
readonly replayAllowed?: false;
|
|
78
|
+
};
|
|
79
|
+
readonly requests: readonly AgentDecisionRequest[];
|
|
80
|
+
readonly receipts: readonly AgentCommandReceipt[];
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Read-only presentation facts. Actions remain subject to their original host gates. */
|
|
2
|
+
export interface AttentionCard {
|
|
3
|
+
readonly cardId: string;
|
|
4
|
+
readonly kind: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
readonly resolvedState?: 'open' | 'resolved';
|
|
7
|
+
readonly actions?: readonly {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly channel?: string;
|
|
10
|
+
readonly seam?: string;
|
|
11
|
+
readonly payload?: Readonly<Record<string, unknown>>;
|
|
12
|
+
}[];
|
|
13
|
+
readonly refs?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly resolution?: {
|
|
15
|
+
readonly state: string;
|
|
16
|
+
};
|
|
17
|
+
readonly completionReview?: import('./delegation.ts').SessionCompletionReview;
|
|
18
|
+
}
|
|
19
|
+
export interface BotAttentionItem {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
readonly botName: string;
|
|
23
|
+
readonly kind: 'question' | 'approval' | 'confirmation';
|
|
24
|
+
readonly title: string;
|
|
25
|
+
readonly createdAt?: string;
|
|
26
|
+
readonly expiresAt?: string;
|
|
27
|
+
readonly messageId?: string;
|
|
28
|
+
readonly sessionId?: string;
|
|
29
|
+
readonly card?: AttentionCard;
|
|
30
|
+
}
|
|
31
|
+
export interface BotAttentionRequest {
|
|
32
|
+
readonly workspaceId?: string;
|
|
33
|
+
}
|
|
34
|
+
export type BotAttentionResult = {
|
|
35
|
+
readonly ok: true;
|
|
36
|
+
readonly items: readonly BotAttentionItem[];
|
|
37
|
+
} | {
|
|
38
|
+
readonly ok: false;
|
|
39
|
+
readonly code: string;
|
|
40
|
+
};
|
|
41
|
+
/** Current conversational decision, including when its source lies outside the returned page. */
|
|
42
|
+
export interface BotDecisionSnapshot {
|
|
43
|
+
readonly activeReplyQuestionId: string | null;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LocalAccessLevel } from './index.ts';
|
|
2
|
+
/** Device-local user authority. Never supplied by a model or copied into a worker profile. */
|
|
3
|
+
export interface BotAccessPolicy {
|
|
4
|
+
readonly workspaceId: string;
|
|
5
|
+
readonly conversationId: string;
|
|
6
|
+
readonly accessLevel: LocalAccessLevel;
|
|
7
|
+
readonly revision: number;
|
|
8
|
+
readonly updatedAt: string;
|
|
9
|
+
readonly source: 'legacy_migration' | 'new_bot' | 'local_ui';
|
|
10
|
+
}
|
|
11
|
+
export interface BotAccessPolicyReadRequest {
|
|
12
|
+
readonly workspaceId?: string;
|
|
13
|
+
readonly conversationId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BotAccessPolicyUpdateRequest {
|
|
16
|
+
readonly workspaceId: string;
|
|
17
|
+
readonly expectedRevision: number;
|
|
18
|
+
readonly accessLevel: LocalAccessLevel;
|
|
19
|
+
}
|
|
20
|
+
export type BotAccessPolicyResult = {
|
|
21
|
+
readonly ok: true;
|
|
22
|
+
readonly policy: BotAccessPolicy | null;
|
|
23
|
+
readonly inherited: boolean;
|
|
24
|
+
readonly botName?: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly ok: false;
|
|
27
|
+
readonly code: 'INVALID_INPUT' | 'NOT_FOUND' | 'OUT_OF_SCOPE' | 'POLICY_CONFLICT' | 'POLICY_UNAVAILABLE' | 'PROJECT_AGENT_DISABLED';
|
|
28
|
+
readonly policy?: BotAccessPolicy;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** Independent read sections; availability never grants execution authority. */
|
|
2
|
+
export type BotConversationReadView = 'interactions' | 'cards';
|
|
3
|
+
export interface BotConversationReadAvailability {
|
|
4
|
+
readonly section: 'messages' | 'cards';
|
|
5
|
+
readonly state: 'ready' | 'rebuilding' | 'unavailable';
|
|
6
|
+
readonly sourceVersion?: string;
|
|
7
|
+
readonly code?: string;
|
|
8
|
+
}
|
|
9
|
+
/** A continuation is valid only with the original version of the latest window. */
|
|
10
|
+
export interface BotConversationWindowCondition {
|
|
11
|
+
readonly sourceVersion?: string;
|
|
12
|
+
readonly deltaCursor?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Wire metadata for the Rust interaction window. No status denotes a regular window. */
|
|
15
|
+
export interface BotConversationWindowVersion {
|
|
16
|
+
readonly status?: 'unchanged' | 'delta' | 'refresh';
|
|
17
|
+
readonly sourceVersion?: string;
|
|
18
|
+
readonly baseSourceVersion?: string;
|
|
19
|
+
readonly hasMore?: boolean;
|
|
20
|
+
readonly availability?: 'rebuilding' | 'version_changed' | 'damaged';
|
|
21
|
+
}
|
|
22
|
+
/** Small durable accounting event; full results and provider checkpoints remain referenced. */
|
|
23
|
+
export interface CoordinationUsageObservation {
|
|
24
|
+
readonly kind: 'usage_observed';
|
|
25
|
+
readonly workId: string;
|
|
26
|
+
readonly observationId: string;
|
|
27
|
+
readonly tokens: number | null;
|
|
28
|
+
readonly costUsd: number | null;
|
|
29
|
+
}
|
|
30
|
+
/** A durable input receipt is independent of this execution/recovery barrier. */
|
|
31
|
+
export interface BotRecoveryStatus {
|
|
32
|
+
readonly state: 'blocked';
|
|
33
|
+
readonly reason: 'history_conflict' | 'reconciliation_required' | 'recovery_failed';
|
|
34
|
+
readonly code: string;
|
|
35
|
+
readonly phase: string;
|
|
36
|
+
readonly retryable: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function projectBotRecoveryStatus(error: unknown, phase?: string): BotRecoveryStatus;
|
|
39
|
+
export interface BotPendingInput {
|
|
40
|
+
readonly inputId: string;
|
|
41
|
+
readonly createdAt: string;
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly threadTarget: {
|
|
44
|
+
readonly kind: 'main_chat';
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'matter';
|
|
47
|
+
readonly matterId: string;
|
|
48
|
+
};
|
|
49
|
+
readonly surface: 'desktop' | 'quick_chat' | 'tui' | 'remote';
|
|
50
|
+
}
|
|
51
|
+
export interface BotInputDeliveryBlocker {
|
|
52
|
+
readonly stage: 'lease' | 'recovery' | 'queue' | 'consume' | 'commit' | 'model' | 'execution';
|
|
53
|
+
readonly errorCode: string;
|
|
54
|
+
readonly pendingCount: number | null;
|
|
55
|
+
readonly leaseOwnerSurface: 'desktop' | 'tui' | null;
|
|
56
|
+
readonly heldByOtherHost: boolean;
|
|
57
|
+
readonly updatedAt: string;
|
|
58
|
+
readonly suggestedActions: readonly ('take_over' | 'retry' | 'open_diagnostics' | 'open_settings')[];
|
|
59
|
+
}
|
|
60
|
+
/** Pending text is authorized conversation data. Diagnostics carry only the blocker. */
|
|
61
|
+
export interface BotInputDeliveryRead {
|
|
62
|
+
readonly pendingInputs?: readonly BotPendingInput[];
|
|
63
|
+
readonly pendingInputsTotal?: number;
|
|
64
|
+
readonly pendingInputsTruncated?: boolean;
|
|
65
|
+
readonly pendingInputsErrorCode?: string;
|
|
66
|
+
readonly deliveryBlocker?: BotInputDeliveryBlocker | null;
|
|
67
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function projectBotRecoveryStatus(error, phase = 'unknown') {
|
|
2
|
+
const code = typeof error === 'string' && /^[a-zA-Z0-9_:-]{1,120}$/.test(error) ? error : 'RECOVERY_FAILED';
|
|
3
|
+
const conflict = ['coordination_legacy_changed', 'coordination_hash_mismatch', 'coordination_journal_missing',
|
|
4
|
+
'coordination_legacy_seal_invalid', 'coordination_repair_incomplete', 'coordination_fence_incomplete', 'coordination_fence_invalid', 'coordination_writer_fence_missing',
|
|
5
|
+
'coordination_writer_upgrade_required', 'coordination_schema_unsupported'].includes(code);
|
|
6
|
+
const held = code === 'coordination_reconciliation_required';
|
|
7
|
+
return { state: 'blocked', reason: held ? 'reconciliation_required' : conflict ? 'history_conflict' : 'recovery_failed', code,
|
|
8
|
+
phase: /^[a-z_]{1,40}$/.test(phase) ? phase : 'unknown', retryable: !conflict && !held };
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type BotDirectAction = 'read_file' | 'write_file' | 'edit_file' | 'list_files' | 'search_files' | 'read_result' | 'query_git' | 'run_command' | 'stop_command' | 'web_fetch' | 'web_search' | 'read_skill' | 'run_tool';
|
|
2
|
+
/** Compact display facts for a settled tool call on a Bot reply. */
|
|
3
|
+
export interface BotDirectStep {
|
|
4
|
+
readonly toolCallId: string;
|
|
5
|
+
readonly tool: string;
|
|
6
|
+
readonly action: BotDirectAction;
|
|
7
|
+
readonly status: 'succeeded' | 'failed' | 'skipped';
|
|
8
|
+
readonly target?: string;
|
|
9
|
+
readonly durationMs?: number;
|
|
10
|
+
readonly resultSummary?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** User-requested desktop Git operations on a registered Bot workspace. */
|
|
2
|
+
export interface BotGitRepository {
|
|
3
|
+
readonly repoKey: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly branch: string | null;
|
|
6
|
+
readonly detached: boolean;
|
|
7
|
+
readonly unborn: boolean;
|
|
8
|
+
readonly headShort: string | null;
|
|
9
|
+
readonly upstream: string | null;
|
|
10
|
+
readonly defaultRef: string | null;
|
|
11
|
+
readonly compareRef: string | null;
|
|
12
|
+
readonly ahead: number | null;
|
|
13
|
+
readonly behind: number | null;
|
|
14
|
+
readonly changedCount: number;
|
|
15
|
+
readonly stagedCount: number;
|
|
16
|
+
readonly unstagedCount: number;
|
|
17
|
+
readonly untrackedCount: number;
|
|
18
|
+
readonly clean: boolean | null;
|
|
19
|
+
}
|
|
20
|
+
export interface BotGitWorkspaceRequest {
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BotGitOverviewRequest extends BotGitWorkspaceRequest {
|
|
24
|
+
readonly refresh?: true;
|
|
25
|
+
}
|
|
26
|
+
export interface BotGitRepositoryRequest extends BotGitWorkspaceRequest {
|
|
27
|
+
readonly repoKey: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BotGitSwitchRequest extends BotGitRepositoryRequest {
|
|
30
|
+
readonly branch: string;
|
|
31
|
+
}
|
|
32
|
+
export interface BotGitCreateRequest extends BotGitRepositoryRequest {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly startPoint: string;
|
|
35
|
+
}
|
|
36
|
+
export type BotGitErrorCode = 'invalid_workspace' | 'invalid_repository' | 'invalid_branch' | 'invalid_start_point' | 'branch_missing' | 'branch_exists' | 'branch_in_use' | 'worktree_conflict' | 'repository_busy' | 'external_filter' | 'outcome_unknown' | 'git_unavailable' | 'resource_unavailable';
|
|
37
|
+
export type BotGitResult<T> = ({
|
|
38
|
+
readonly ok: true;
|
|
39
|
+
} & T) | {
|
|
40
|
+
readonly ok: false;
|
|
41
|
+
readonly code: BotGitErrorCode;
|
|
42
|
+
};
|
|
43
|
+
export type BotGitOverview = BotGitResult<{
|
|
44
|
+
readonly mode: 'none' | 'single' | 'multi';
|
|
45
|
+
readonly repos: readonly BotGitRepository[];
|
|
46
|
+
}>;
|
|
47
|
+
export type BotGitBranches = BotGitResult<{
|
|
48
|
+
readonly current: string | null;
|
|
49
|
+
readonly defaultRef: string | null;
|
|
50
|
+
readonly localBranches: readonly string[];
|
|
51
|
+
readonly remoteBranches: readonly string[];
|
|
52
|
+
}>;
|
|
53
|
+
export type BotGitMutation = BotGitResult<{
|
|
54
|
+
readonly branch: string;
|
|
55
|
+
}>;
|
package/dist/bot-git.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Native address copies have independent instance identities; never a migrated webview. */
|
|
2
|
+
export interface BrowserWindowIdentity {
|
|
3
|
+
readonly viewId: string;
|
|
4
|
+
readonly windowId: string;
|
|
5
|
+
readonly generation: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BrowserWindowCopyRequest {
|
|
8
|
+
readonly conversationId: string;
|
|
9
|
+
readonly browserTabId: string;
|
|
10
|
+
readonly webContentsId: number;
|
|
11
|
+
}
|
|
12
|
+
export type BrowserWindowAction = 'navigate' | 'back' | 'forward' | 'reload' | 'stop' | 'return' | 'close';
|
|
13
|
+
export interface BrowserWindowState {
|
|
14
|
+
readonly identity: BrowserWindowIdentity;
|
|
15
|
+
readonly conversationId: string;
|
|
16
|
+
readonly browserTabId: string;
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly loading: boolean;
|
|
20
|
+
readonly canBack: boolean;
|
|
21
|
+
readonly canForward: boolean;
|
|
22
|
+
readonly failure: string | null;
|
|
23
|
+
readonly sequence: number;
|
|
24
|
+
readonly copy: true;
|
|
25
|
+
}
|
|
26
|
+
export type BrowserWindowResult = {
|
|
27
|
+
readonly ok: true;
|
|
28
|
+
readonly state: BrowserWindowState;
|
|
29
|
+
readonly returnStatus?: 'returned' | 'source_tab_closed';
|
|
30
|
+
} | {
|
|
31
|
+
readonly ok: false;
|
|
32
|
+
readonly status: 'invalid_request' | 'scope_denied' | 'source_unavailable' | 'limit_reached' | 'stale_view' | 'cancelled';
|
|
33
|
+
};
|
|
34
|
+
export interface BrowserWindowReturnRequest {
|
|
35
|
+
readonly requestId: string;
|
|
36
|
+
readonly identity: BrowserWindowIdentity;
|
|
37
|
+
readonly conversationId: string;
|
|
38
|
+
readonly workspaceId?: string;
|
|
39
|
+
readonly browserTabId: string;
|
|
40
|
+
readonly expiresAt: number;
|
|
41
|
+
}
|
|
42
|
+
export interface BrowserWindowReturnAck {
|
|
43
|
+
readonly requestId: string;
|
|
44
|
+
readonly identity: BrowserWindowIdentity;
|
|
45
|
+
readonly status: 'returned' | 'source_tab_closed' | 'cancelled';
|
|
46
|
+
}
|
|
47
|
+
export declare function normalizeBrowserWindowUrl(raw: unknown): string | null;
|
|
48
|
+
export declare function normalizeBrowserWindowCopyRequest(raw: unknown): BrowserWindowCopyRequest | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function normalizeBrowserWindowUrl(raw) {
|
|
2
|
+
if (typeof raw !== 'string' || raw.length > 8192)
|
|
3
|
+
return null;
|
|
4
|
+
try {
|
|
5
|
+
const url = new URL(raw);
|
|
6
|
+
return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password ? url.href : null;
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function normalizeBrowserWindowCopyRequest(raw) {
|
|
13
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
14
|
+
return null;
|
|
15
|
+
const v = raw;
|
|
16
|
+
if (Object.keys(v).some(k => !['conversationId', 'browserTabId', 'webContentsId'].includes(k)))
|
|
17
|
+
return null;
|
|
18
|
+
if (![v.conversationId, v.browserTabId].every(x => typeof x === 'string' && x.length > 0 && x.length <= 256))
|
|
19
|
+
return null;
|
|
20
|
+
if (!Number.isSafeInteger(v.webContentsId) || v.webContentsId <= 0)
|
|
21
|
+
return null;
|
|
22
|
+
return { conversationId: v.conversationId, browserTabId: v.browserTabId, webContentsId: v.webContentsId };
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A factual refusal layer; it never grants permission or changes acceptance. */
|
|
2
|
+
export interface CapabilityBlocker {
|
|
3
|
+
readonly stage: 'projection' | 'role' | 'delegation_admission' | 'permission' | 'execution';
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
readonly capabilityId?: string;
|
|
6
|
+
readonly required?: readonly string[];
|
|
7
|
+
readonly available?: readonly string[];
|
|
8
|
+
readonly missing?: readonly string[];
|
|
9
|
+
readonly criterionIds?: readonly string[];
|
|
10
|
+
readonly alternatives?: readonly string[];
|
|
11
|
+
readonly retryable: boolean;
|
|
12
|
+
readonly userActionRequired: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DelegationCapabilityAdmission {
|
|
15
|
+
readonly required: readonly string[];
|
|
16
|
+
readonly inventoryHash: string | null;
|
|
17
|
+
readonly inventoryKnown: boolean;
|
|
18
|
+
readonly requirementsDeclared: boolean;
|
|
19
|
+
readonly checkedAt: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Source references only; this object never proves a capability result. */
|
|
2
|
+
export interface CompactionHistorySelection {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly compactionEpoch: number;
|
|
5
|
+
readonly retainedMessageIds: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** Checked against the language-neutral resource by native CLI conformance. */
|
|
8
|
+
export declare const COMPACTION_HISTORY_SELECTION_LIMITS: Readonly<{
|
|
9
|
+
version: 1;
|
|
10
|
+
projectorVersion: 3;
|
|
11
|
+
maxRetained: 4096;
|
|
12
|
+
maxIdBytes: 200;
|
|
13
|
+
maxSelectionBytes: 65536;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function normalizeCompactionHistorySelection(value: unknown): CompactionHistorySelection | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Checked against the language-neutral resource by native CLI conformance. */
|
|
2
|
+
export const COMPACTION_HISTORY_SELECTION_LIMITS = Object.freeze({
|
|
3
|
+
version: 1, projectorVersion: 3, maxRetained: 4096, maxIdBytes: 200, maxSelectionBytes: 65536,
|
|
4
|
+
});
|
|
5
|
+
export function normalizeCompactionHistorySelection(value) {
|
|
6
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
7
|
+
return null;
|
|
8
|
+
const row = value;
|
|
9
|
+
if (Object.keys(row).some(k => !['version', 'compactionEpoch', 'retainedMessageIds'].includes(k))
|
|
10
|
+
|| row.version !== 1 || !Number.isSafeInteger(row.compactionEpoch) || Number(row.compactionEpoch) <= 0
|
|
11
|
+
|| !Array.isArray(row.retainedMessageIds) || row.retainedMessageIds.length > COMPACTION_HISTORY_SELECTION_LIMITS.maxRetained)
|
|
12
|
+
return null;
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
let bytes = 0;
|
|
16
|
+
for (const id of row.retainedMessageIds) {
|
|
17
|
+
if (typeof id !== 'string' || !id || seen.has(id))
|
|
18
|
+
return null;
|
|
19
|
+
if ([...id].some(c => { const point = c.codePointAt(0); return point >= 0xD800 && point <= 0xDFFF; }))
|
|
20
|
+
return null;
|
|
21
|
+
const size = encoder.encode(id).length;
|
|
22
|
+
if (size > COMPACTION_HISTORY_SELECTION_LIMITS.maxIdBytes)
|
|
23
|
+
return null;
|
|
24
|
+
bytes += size;
|
|
25
|
+
seen.add(id);
|
|
26
|
+
}
|
|
27
|
+
if (bytes > COMPACTION_HISTORY_SELECTION_LIMITS.maxSelectionBytes)
|
|
28
|
+
return null;
|
|
29
|
+
return { version: 1, compactionEpoch: Number(row.compactionEpoch), retainedMessageIds: [...seen] };
|
|
30
|
+
}
|
package/dist/compaction.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { type CompactionHistorySelection } from './compaction-history-selection.ts';
|
|
2
|
+
export { normalizeCompactionHistorySelection, COMPACTION_HISTORY_SELECTION_LIMITS } from './compaction-history-selection.ts';
|
|
3
|
+
export type { CompactionHistorySelection } from './compaction-history-selection.ts';
|
|
1
4
|
/** 压缩摘要的产生方式,与 runtime-core CompactionMethod 保持同枚举。 */
|
|
2
5
|
export type CompactionMarkerMethod = 'llm' | 'structured' | 'structural' | 'fallback_drop';
|
|
3
6
|
/** 持久化在 handoff 消息 `_compaction` 字段上的共享 marker 形状。 */
|
|
4
7
|
export interface ConversationCompactionMarker {
|
|
8
|
+
readonly historySelection?: CompactionHistorySelection;
|
|
5
9
|
readonly method: CompactionMarkerMethod;
|
|
6
10
|
/** LLM 摘要失败降级原因(仅降级时存在)。 */
|
|
7
11
|
readonly fallbackReason?: string;
|
|
@@ -35,6 +39,7 @@ export interface ConversationCompactionMarker {
|
|
|
35
39
|
* 数值一律钳制为非负整数;method 非法时回退 'structured';可选降级字段仅在非空时出现。
|
|
36
40
|
*/
|
|
37
41
|
export declare function buildCompactionMarker(input: {
|
|
42
|
+
readonly historySelection?: CompactionHistorySelection | null;
|
|
38
43
|
readonly method?: unknown;
|
|
39
44
|
readonly fallbackReason?: string | null;
|
|
40
45
|
readonly fallbackDetail?: string | null;
|
package/dist/compaction.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// `_compaction` marker 是 Desktop 与 CLI/TUI 共享会话事实面的一部分:
|
|
4
4
|
// 任一端压缩后,另一端必须能按同一形状恢复 active provider history 分界与连续性摘要。
|
|
5
5
|
// 两端持久化必须经 buildCompactionMarker() 产出,不得手写字面量,防止字段漂移。
|
|
6
|
+
import { normalizeCompactionHistorySelection } from "./compaction-history-selection.js";
|
|
7
|
+
export { normalizeCompactionHistorySelection, COMPACTION_HISTORY_SELECTION_LIMITS } from "./compaction-history-selection.js";
|
|
6
8
|
function nonNegativeInt(value) {
|
|
7
9
|
const parsed = Number(value);
|
|
8
10
|
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;
|
|
@@ -17,6 +19,9 @@ function normalizeMethod(value) {
|
|
|
17
19
|
* 数值一律钳制为非负整数;method 非法时回退 'structured';可选降级字段仅在非空时出现。
|
|
18
20
|
*/
|
|
19
21
|
export function buildCompactionMarker(input) {
|
|
22
|
+
const selection = input.historySelection == null ? null : normalizeCompactionHistorySelection(input.historySelection);
|
|
23
|
+
if (input.historySelection != null && (!selection || typeof input.summary !== 'string' || !input.summary.trim()))
|
|
24
|
+
throw new Error('compaction_history_selection_invalid');
|
|
20
25
|
const fallbackReason = typeof input.fallbackReason === 'string' && input.fallbackReason.trim()
|
|
21
26
|
? input.fallbackReason
|
|
22
27
|
: undefined;
|
|
@@ -24,6 +29,7 @@ export function buildCompactionMarker(input) {
|
|
|
24
29
|
? input.fallbackDetail
|
|
25
30
|
: undefined;
|
|
26
31
|
return {
|
|
32
|
+
...(selection ? { historySelection: selection } : {}),
|
|
27
33
|
method: normalizeMethod(input.method),
|
|
28
34
|
...(fallbackReason ? { fallbackReason } : {}),
|
|
29
35
|
...(fallbackDetail ? { fallbackDetail } : {}),
|
|
@@ -82,6 +82,9 @@ export declare function normalizeContextUsageBreakdown(value: unknown): ContextU
|
|
|
82
82
|
*/
|
|
83
83
|
export interface ContextAccountingSnapshot {
|
|
84
84
|
readonly version: 1;
|
|
85
|
+
/** Durable occupancy binding; required for append-only historySelection. */
|
|
86
|
+
readonly projectorVersion?: 3;
|
|
87
|
+
readonly compactionBoundaryId?: string | null;
|
|
85
88
|
readonly conversationId: string;
|
|
86
89
|
readonly contentRevision: number;
|
|
87
90
|
readonly modelKey: string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Ordinary execution facts in the original Conversation index. Shape is never
|
|
2
|
+
* permission, process-death proof, or authority to replay a pending dispatch. */
|
|
3
|
+
import { type SessionControlOperation } from './session-control.ts';
|
|
4
|
+
type Recorder = NonNullable<SessionControlOperation['recorder']>;
|
|
5
|
+
export interface ConversationExecutionIdentity {
|
|
6
|
+
readonly kind: 'conversation';
|
|
7
|
+
readonly conversationId: string;
|
|
8
|
+
readonly streamId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ConversationExecution {
|
|
11
|
+
readonly schemaVersion: 1;
|
|
12
|
+
readonly identity: ConversationExecutionIdentity;
|
|
13
|
+
readonly engine: 'peer-native' | 'peer-ts';
|
|
14
|
+
readonly owner: Recorder;
|
|
15
|
+
readonly revision: number;
|
|
16
|
+
readonly phase: 'active' | 'stopping' | 'stopped' | 'recovery_required';
|
|
17
|
+
readonly pendingTools: readonly {
|
|
18
|
+
readonly toolCallId: string;
|
|
19
|
+
readonly dispatchId: string;
|
|
20
|
+
readonly messageId: string;
|
|
21
|
+
readonly capabilityId: string;
|
|
22
|
+
readonly argsDigest: string;
|
|
23
|
+
readonly phase: 'prepared' | 'dispatching' | 'outcome_unknown';
|
|
24
|
+
readonly declaredScopes: readonly unknown[];
|
|
25
|
+
readonly nativeProcess?: unknown;
|
|
26
|
+
readonly admission?: {
|
|
27
|
+
readonly workspaceId: string;
|
|
28
|
+
readonly botConversationId: string;
|
|
29
|
+
readonly hostEpoch: string;
|
|
30
|
+
readonly policyRevision: string;
|
|
31
|
+
readonly projectionId: string;
|
|
32
|
+
readonly credentialRevision: string;
|
|
33
|
+
};
|
|
34
|
+
}[];
|
|
35
|
+
readonly handles: readonly {
|
|
36
|
+
readonly handleId: string;
|
|
37
|
+
readonly toolCallId: string;
|
|
38
|
+
readonly state: 'active' | 'ended';
|
|
39
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
40
|
+
}[];
|
|
41
|
+
readonly usage: null | {
|
|
42
|
+
readonly requestBreakdown?: readonly import("./usage-accounting.js").RequestSpend[];
|
|
43
|
+
readonly usageScope: 'runtime_turn';
|
|
44
|
+
readonly providerRequestCount: number;
|
|
45
|
+
readonly inputTokens: number;
|
|
46
|
+
readonly outputTokens: number;
|
|
47
|
+
readonly cacheReadTokens: number;
|
|
48
|
+
readonly cacheWriteTokens: number;
|
|
49
|
+
readonly totalTokens: number;
|
|
50
|
+
};
|
|
51
|
+
readonly unknownUsage: boolean;
|
|
52
|
+
readonly attribution: Readonly<Record<string, unknown>>;
|
|
53
|
+
readonly usageCommitted: boolean;
|
|
54
|
+
readonly stop?: {
|
|
55
|
+
readonly owner: Recorder;
|
|
56
|
+
readonly observedAt: string;
|
|
57
|
+
readonly runnerIdle: true;
|
|
58
|
+
readonly admissionClosed: true;
|
|
59
|
+
readonly handlesEnded: true;
|
|
60
|
+
} | null;
|
|
61
|
+
readonly updatedAt: string;
|
|
62
|
+
}
|
|
63
|
+
/** Strict decoding: unknown versions/fields are preserved by the caller and block
|
|
64
|
+
* execution. Return a clone so a parser consumer cannot change the stored fact. */
|
|
65
|
+
export declare function validConversationSpend(value: unknown): boolean;
|
|
66
|
+
export declare function normalizeConversationExecution(raw: unknown): ConversationExecution;
|
|
67
|
+
export declare function conversationExecutionPermitsNewRun(raw: unknown): boolean;
|
|
68
|
+
export {};
|