@peer-agent/protocol 0.1.0-rc.40 → 0.1.0-rc.41
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.d.ts +13 -0
- package/dist/delegation.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/project.d.ts +18 -0
- package/dist/project.js +6 -0
- package/dist/resource-window.d.ts +5 -0
- package/dist/resource-window.js +9 -2
- package/dist/session-control.d.ts +88 -3
- package/dist/session-control.js +14 -0
- package/package.json +1 -1
package/dist/delegation.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface DelegationOrigin {
|
|
|
11
11
|
readonly capabilityAdmission?: import('./capability-admission.ts').DelegationCapabilityAdmission;
|
|
12
12
|
readonly executionGeneration?: string;
|
|
13
13
|
readonly executionControl?: import('./session-control.ts').SessionControlOperation;
|
|
14
|
+
/** Host receipt for a user-authorized claim closure. It is not a stop receipt. */
|
|
15
|
+
readonly executionClaimClosure?: import('./session-control.ts').ExecutionClaimClosure;
|
|
16
|
+
/** Host receipt for an unknown-outcome resolution (ADR 127). It ends occupancy only; not a stop receipt or a tool result. */
|
|
17
|
+
readonly unknownOutcomeResolution?: import('./session-control.ts').UnknownOutcomeResolution;
|
|
14
18
|
readonly takeover?: {
|
|
15
19
|
operationId: string;
|
|
16
20
|
phase: 'stopping' | 'completed' | 'superseded' | 'rejected';
|
|
@@ -64,6 +68,15 @@ export interface DelegationOrigin {
|
|
|
64
68
|
}
|
|
65
69
|
export interface SessionQueueFacts {
|
|
66
70
|
readonly resourceBlocker?: import('./session-control.ts').ExecutionResourceBlocker;
|
|
71
|
+
readonly executionClaimClosure?: import('./session-control.ts').ExecutionClaimClosure;
|
|
72
|
+
readonly unknownOutcomePolicy?: import('./session-control.ts').UnknownOutcomePolicyTier;
|
|
73
|
+
readonly unknownOutcomeResolution?: import('./session-control.ts').UnknownOutcomeResolution;
|
|
74
|
+
readonly retainedUnknowns?: readonly {
|
|
75
|
+
readonly closureId: string;
|
|
76
|
+
readonly unknownCalls: readonly string[];
|
|
77
|
+
readonly at: string;
|
|
78
|
+
readonly proof: 'verified_dead' | 'legacy_user_confirmed';
|
|
79
|
+
}[];
|
|
67
80
|
readonly queuedBehind?: readonly {
|
|
68
81
|
readonly sessionId: string;
|
|
69
82
|
readonly title: string;
|
package/dist/delegation.js
CHANGED
|
@@ -97,6 +97,10 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
97
97
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
98
98
|
origin: conversationMeta.origin,
|
|
99
99
|
...(conversationMeta.resourceBlocker ? { resourceBlocker: conversationMeta.resourceBlocker } : {}),
|
|
100
|
+
...(conversationMeta.executionClaimClosure ? { executionClaimClosure: conversationMeta.executionClaimClosure } : {}),
|
|
101
|
+
...(conversationMeta.unknownOutcomePolicy ? { unknownOutcomePolicy: conversationMeta.unknownOutcomePolicy } : {}),
|
|
102
|
+
...(conversationMeta.unknownOutcomeResolution ? { unknownOutcomeResolution: conversationMeta.unknownOutcomeResolution } : {}),
|
|
103
|
+
...(conversationMeta.retainedUnknowns?.length ? { retainedUnknowns: conversationMeta.retainedUnknowns } : {}),
|
|
100
104
|
...(conversationMeta.queuedBehind ? { queuedBehind: conversationMeta.queuedBehind.map(item => ({ ...item })) } : {}),
|
|
101
105
|
...(conversationMeta.queueReason ? { queueReason: conversationMeta.queueReason } : {}),
|
|
102
106
|
...(conversationMeta.supersededBy ? { supersededBy: conversationMeta.supersededBy } : {}),
|
package/dist/index.d.ts
CHANGED
|
@@ -916,8 +916,8 @@ export * from './resource-edit.ts';
|
|
|
916
916
|
export * from './resource-file-replace.ts';
|
|
917
917
|
export * from './resource-edit-execution.ts';
|
|
918
918
|
export { decideFollowUp, type FollowUpOwner, type FollowUpReason, type FollowUpProjection } from './task-overview.ts';
|
|
919
|
-
export type { SessionExecutionIdentity, StopBarrierReceipt, SessionControlOperation, ExecutionResourceBlocker, ExecutionResourceClaim, ExecutionResourceScope } from './session-control.ts';
|
|
920
|
-
export { controlPhasesForOrigin, normalizeSessionExecutionIdentity } from './session-control.ts';
|
|
919
|
+
export type { SessionExecutionIdentity, StopBarrierReceipt, SessionControlOperation, ExecutionResourceBlocker, ExecutionClaimClosure, ExecutionResourceClaim, ExecutionResourceScope, UnknownOutcomePolicy, UnknownOutcomePolicyTier, UnknownOutcomeResolution, UnknownOutcomeResolutionTier, ReconciliationEvidence, ReconciliationProbe, ReconciliationProbeKind, ReconciliationVerdict } from './session-control.ts';
|
|
920
|
+
export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExecutionResourceScope } from './session-control.ts';
|
|
921
921
|
export * from './input-prediction.ts';
|
|
922
922
|
export * from './interactive-result.ts';
|
|
923
923
|
export * from './interactive-verification.ts';
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export * from "./resource-edit.js";
|
|
|
58
58
|
export * from "./resource-file-replace.js";
|
|
59
59
|
export * from "./resource-edit-execution.js";
|
|
60
60
|
export { decideFollowUp } from "./task-overview.js";
|
|
61
|
-
export { controlPhasesForOrigin, normalizeSessionExecutionIdentity } from "./session-control.js";
|
|
61
|
+
export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExecutionResourceScope } from "./session-control.js";
|
|
62
62
|
export * from "./input-prediction.js";
|
|
63
63
|
export * from "./interactive-result.js";
|
|
64
64
|
export * from "./interactive-verification.js";
|
package/dist/project.d.ts
CHANGED
|
@@ -162,6 +162,14 @@ export interface BotProfile {
|
|
|
162
162
|
readonly acceptancePolicy?: 'auto' | 'confirm';
|
|
163
163
|
/** Policy acceptance keeps a separate merge confirmation unless explicitly enabled. */
|
|
164
164
|
readonly autoHandoffOnPolicyAccept?: boolean;
|
|
165
|
+
/** ADR 127: user-delegated unknown-outcome closure policy. Absent or null means ask; the model can never write it. */
|
|
166
|
+
readonly unknownOutcomePolicy?: {
|
|
167
|
+
readonly tier: 'ask' | 'bot_verified';
|
|
168
|
+
readonly policyId: string;
|
|
169
|
+
readonly revision: number;
|
|
170
|
+
readonly delegatedAt?: string;
|
|
171
|
+
readonly updatedAt: string;
|
|
172
|
+
} | null;
|
|
165
173
|
/** Archived deletion intent, retained until each cleanup step is persisted. */
|
|
166
174
|
readonly deletionCleanup?: {
|
|
167
175
|
readonly folder: string;
|
|
@@ -212,11 +220,21 @@ export interface ProjectAgentToolActivity {
|
|
|
212
220
|
/** Public conversation update, never hidden reasoning, Tool Result or Evidence.
|
|
213
221
|
* User agent_turn records may persist these as publicUpdates (100 / 32000 chars).
|
|
214
222
|
* Legacy rounds[].text is not a public-update source.
|
|
223
|
+
* role is the host-assigned display identity (ADR87 D4): opening = the first public
|
|
224
|
+
* text before any tool activity in the visible reply; every other public text is
|
|
225
|
+
* narration. Absent role means a pre-2026-11-09 legacy record; do not guess one.
|
|
215
226
|
*/
|
|
216
227
|
export interface ProjectAgentPublicUpdate {
|
|
217
228
|
readonly id: string;
|
|
218
229
|
readonly text: string;
|
|
230
|
+
readonly role?: 'opening' | 'narration';
|
|
219
231
|
}
|
|
232
|
+
/** Display contract version for persisted agent_turn records (ADR87 D4).
|
|
233
|
+
* Version 2: public text carries role, the canonical agent_reply is the only
|
|
234
|
+
* answer body, and the implicit pure-text fallback reply is closed. Absent
|
|
235
|
+
* version means a legacy record and must keep legacy presentation.
|
|
236
|
+
*/
|
|
237
|
+
export declare const AGENT_TURN_DISPLAY_CONTRACT: 2;
|
|
220
238
|
/** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
|
|
221
239
|
export interface ProjectAgentActivity {
|
|
222
240
|
/** Same-turn successful local file results only; navigation hints never grant access. */
|
package/dist/project.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
* Bot list projection. Sort is recent activity only.
|
|
3
3
|
* needsYou changes the badge and the filter, not the order.
|
|
4
4
|
*/
|
|
5
|
+
/** Display contract version for persisted agent_turn records (ADR87 D4).
|
|
6
|
+
* Version 2: public text carries role, the canonical agent_reply is the only
|
|
7
|
+
* answer body, and the implicit pure-text fallback reply is closed. Absent
|
|
8
|
+
* version means a legacy record and must keep legacy presentation.
|
|
9
|
+
*/
|
|
10
|
+
export const AGENT_TURN_DISPLAY_CONTRACT = 2;
|
|
5
11
|
export const BOT_AVATAR_SHAPES = [
|
|
6
12
|
'circle',
|
|
7
13
|
'square',
|
|
@@ -143,6 +143,11 @@ export type ResourceRecentReference = {
|
|
|
143
143
|
readonly toRef?: string;
|
|
144
144
|
readonly comparison?: 'working' | 'staged';
|
|
145
145
|
};
|
|
146
|
+
} | {
|
|
147
|
+
readonly kind: 'directory';
|
|
148
|
+
readonly path: string;
|
|
149
|
+
readonly relativeTo?: string;
|
|
150
|
+
readonly task?: BotDocumentReference['task'];
|
|
146
151
|
} | {
|
|
147
152
|
readonly kind: 'browser';
|
|
148
153
|
readonly url: string;
|
package/dist/resource-window.js
CHANGED
|
@@ -174,11 +174,18 @@ export function normalizeResourceRecentReference(raw) {
|
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
if (!['document', 'comparison'].includes(String(raw.kind)) || !keys(raw, raw.kind === 'document' ? ['kind', 'path', 'relativeTo', 'task', 'revision'] : ['kind', 'path', 'relativeTo', 'task', 'comparison']))
|
|
177
|
+
if (!['document', 'comparison', 'directory'].includes(String(raw.kind)) || !keys(raw, raw.kind === 'document' ? ['kind', 'path', 'relativeTo', 'task', 'revision'] : raw.kind === 'directory' ? ['kind', 'path', 'relativeTo', 'task'] : ['kind', 'path', 'relativeTo', 'task', 'comparison']))
|
|
178
178
|
return;
|
|
179
179
|
// A recent descriptor is a hint scoped by its containing owner. It never supplies a workspace or an access grant.
|
|
180
180
|
const ref = { workspaceId: 'presentation', path: raw.path, ...(raw.relativeTo !== undefined ? { relativeTo: raw.relativeTo } : {}),
|
|
181
181
|
...(raw.task !== undefined ? { task: raw.task } : {}), ...(raw.revision !== undefined ? { revision: raw.revision } : {}) };
|
|
182
|
+
if (raw.kind === 'directory') {
|
|
183
|
+
const request = normalizeResourceWindowRequest({ resource: { kind: 'directory', reference: ref } });
|
|
184
|
+
if (request?.resource.kind !== 'directory')
|
|
185
|
+
return;
|
|
186
|
+
const fixed = request.resource.reference;
|
|
187
|
+
return { kind: 'directory', path: fixed.path, ...(fixed.relativeTo ? { relativeTo: fixed.relativeTo } : {}), ...(fixed.task ? { task: fixed.task } : {}) };
|
|
188
|
+
}
|
|
182
189
|
if (raw.kind === 'document') {
|
|
183
190
|
const request = normalizeResourceWindowRequest({ resource: { kind: 'document', reference: ref, mode: 'preview' } });
|
|
184
191
|
if (request?.resource.kind !== 'document')
|
|
@@ -203,7 +210,7 @@ export function normalizeResourceLayout(raw) {
|
|
|
203
210
|
return;
|
|
204
211
|
const list = (value, limit) => Array.isArray(value) && value.length <= limit
|
|
205
212
|
&& value.every(key => typeof key === 'string' && key.length <= 8192 && !/[\u0000-\u001f]/.test(key)
|
|
206
|
-
&& (key === 'launcher' || /^(?:document|browser|conversation|interactive):.+$/.test(key) || key === 'comparison:workspace')) && new Set(value).size === value.length;
|
|
213
|
+
&& (key === 'launcher' || /^(?:document|browser|conversation|interactive|directory):.+$/.test(key) || key === 'comparison:workspace')) && new Set(value).size === value.length;
|
|
207
214
|
if (!list(raw.order, 200) || !Array.isArray(raw.recent) || raw.recent.length > 16 || new TextEncoder().encode(JSON.stringify(raw)).byteLength > 256 * 1024)
|
|
208
215
|
return;
|
|
209
216
|
const mapped = new Set(interactive.tabs.map(tab => `interactive:${tab.id}`));
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/** Host-issued control and resource facts. None of these receipts grants tool permission. */
|
|
2
|
-
|
|
2
|
+
/** Dispatch-declared protection scopes (ADR 127). Only 'directory' is produced today; the narrower kinds arrive with claim scope convergence. */
|
|
3
|
+
export type ExecutionResourceScope = {
|
|
3
4
|
readonly kind: 'directory';
|
|
4
5
|
readonly path: string;
|
|
5
|
-
}
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'file';
|
|
8
|
+
readonly path: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'git_ref';
|
|
11
|
+
readonly ref: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'remote_object';
|
|
14
|
+
readonly ref: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function normalizeExecutionResourceScope(raw: unknown): ExecutionResourceScope | undefined;
|
|
6
17
|
export interface SessionExecutionIdentity {
|
|
7
18
|
readonly planId: string;
|
|
8
19
|
readonly sessionId: string;
|
|
@@ -67,19 +78,91 @@ export type ExecutionResourceBlocker = {
|
|
|
67
78
|
readonly title: string;
|
|
68
79
|
} | {
|
|
69
80
|
readonly kind: 'protection';
|
|
70
|
-
readonly nextAction?: 'reconcile_execution_outcome' | 'confirm_execution_stopped';
|
|
81
|
+
readonly nextAction?: 'reconcile_execution_outcome' | 'confirm_execution_stopped' | 'close_execution_claim';
|
|
71
82
|
readonly code: 'execution_outcome_unknown' | 'execution_stop_unconfirmed';
|
|
72
83
|
readonly resourceRef: string;
|
|
73
84
|
readonly claimId: string;
|
|
74
85
|
readonly sessionId?: string;
|
|
75
86
|
readonly operationId?: string;
|
|
76
87
|
readonly evidenceCalls: readonly string[];
|
|
88
|
+
readonly closeClaimAvailable?: boolean;
|
|
89
|
+
readonly scope?: ExecutionResourceScope;
|
|
90
|
+
readonly unknownOutcomePolicy?: UnknownOutcomePolicyTier;
|
|
91
|
+
readonly reconciliationAvailable?: boolean;
|
|
92
|
+
readonly resolutionTier?: UnknownOutcomeResolutionTier;
|
|
77
93
|
} | {
|
|
78
94
|
readonly kind: 'recovery';
|
|
79
95
|
readonly nextAction?: 'inspect_resource_recovery';
|
|
80
96
|
readonly code: string;
|
|
81
97
|
readonly resourceRef?: string;
|
|
82
98
|
};
|
|
99
|
+
/** A user-authorized end to one resource claim. It is not a stop receipt or a tool result. */
|
|
100
|
+
export interface ExecutionClaimClosure {
|
|
101
|
+
readonly closureId: string;
|
|
102
|
+
readonly claimId: string;
|
|
103
|
+
readonly claimRevision: number;
|
|
104
|
+
readonly execution: SessionExecutionIdentity;
|
|
105
|
+
readonly resourceRef: string;
|
|
106
|
+
readonly unknownCalls: readonly string[];
|
|
107
|
+
readonly authorityRef: string;
|
|
108
|
+
readonly proof: 'verified_dead' | 'legacy_user_confirmed';
|
|
109
|
+
/** ADR 127: present when reconciliation evidence, not a user card, authorized this closure. */
|
|
110
|
+
readonly resolution?: {
|
|
111
|
+
readonly resolutionId: string;
|
|
112
|
+
readonly tier: 'user_confirmed' | 'bot_verified';
|
|
113
|
+
readonly verdict: 'no_effect_observed' | 'effect_observed';
|
|
114
|
+
readonly evidenceDigest: string;
|
|
115
|
+
readonly policyRef?: string;
|
|
116
|
+
};
|
|
117
|
+
readonly scope: 'managed_execution';
|
|
118
|
+
readonly at: string;
|
|
119
|
+
}
|
|
120
|
+
/** ADR 127: user-delegated closure policy for unknown outcomes. Bound to the bot subject (ADR 101); the model reads it but can never write it. */
|
|
121
|
+
export type UnknownOutcomePolicyTier = 'ask' | 'bot_verified';
|
|
122
|
+
export interface UnknownOutcomePolicy {
|
|
123
|
+
readonly workspaceId: string;
|
|
124
|
+
readonly agentConversationId: string;
|
|
125
|
+
readonly tier: UnknownOutcomePolicyTier;
|
|
126
|
+
readonly policyId: string;
|
|
127
|
+
readonly revision: number;
|
|
128
|
+
readonly delegatedAt?: string;
|
|
129
|
+
readonly updatedAt: string;
|
|
130
|
+
}
|
|
131
|
+
export type ReconciliationVerdict = 'no_effect_observed' | 'effect_observed' | 'inconclusive' | 'unfenced_external';
|
|
132
|
+
export type ReconciliationProbeKind = 'process' | 'handle' | 'workspace' | 'git' | 'receipt';
|
|
133
|
+
export interface ReconciliationProbe {
|
|
134
|
+
readonly kind: ReconciliationProbeKind;
|
|
135
|
+
readonly ref: string;
|
|
136
|
+
readonly result: string;
|
|
137
|
+
readonly observedAt: string;
|
|
138
|
+
readonly digest: string;
|
|
139
|
+
}
|
|
140
|
+
/** Host-computed probe bundle. Its verdict can end occupancy at most; it never turns an unknown call into a success. */
|
|
141
|
+
export interface ReconciliationEvidence {
|
|
142
|
+
readonly execution: SessionExecutionIdentity;
|
|
143
|
+
readonly claimId: string;
|
|
144
|
+
readonly claimRevision: number;
|
|
145
|
+
readonly scope: ExecutionResourceScope;
|
|
146
|
+
readonly probes: readonly ReconciliationProbe[];
|
|
147
|
+
readonly verdict: ReconciliationVerdict;
|
|
148
|
+
readonly evidenceDigest: string;
|
|
149
|
+
}
|
|
150
|
+
export type UnknownOutcomeResolutionTier = 'user_confirmed' | 'bot_verified';
|
|
151
|
+
/** Ends occupancy for one claim (ADR 127). Unknown calls stay retained; this is not a tool result, a stop receipt or a success claim. */
|
|
152
|
+
export interface UnknownOutcomeResolution {
|
|
153
|
+
readonly resolutionId: string;
|
|
154
|
+
readonly claimId: string;
|
|
155
|
+
readonly claimRevision: number;
|
|
156
|
+
readonly execution: SessionExecutionIdentity;
|
|
157
|
+
readonly scope: ExecutionResourceScope;
|
|
158
|
+
readonly verdict: ReconciliationVerdict;
|
|
159
|
+
readonly evidenceDigest: string;
|
|
160
|
+
readonly tier: UnknownOutcomeResolutionTier;
|
|
161
|
+
readonly policyRef?: string;
|
|
162
|
+
readonly authorityRef: string;
|
|
163
|
+
readonly unknownCalls: readonly string[];
|
|
164
|
+
readonly at: string;
|
|
165
|
+
}
|
|
83
166
|
export interface ExecutionResourceClaim {
|
|
84
167
|
readonly claimId: string;
|
|
85
168
|
readonly resourceRef: string;
|
|
@@ -95,6 +178,8 @@ export interface ExecutionResourceClaim {
|
|
|
95
178
|
readonly completedAt?: string;
|
|
96
179
|
}>>;
|
|
97
180
|
readonly evidenceCalls: readonly string[];
|
|
181
|
+
/** Absent means the legacy directory scope derived from resourceRef; dispatch-declared scopes arrive with claim scope convergence. */
|
|
182
|
+
readonly scope?: ExecutionResourceScope;
|
|
98
183
|
}
|
|
99
184
|
/** Feed the existing lifecycle projector; a stale compatibility mirror cannot revive an old stop. */
|
|
100
185
|
export declare function controlPhasesForOrigin(origin: {
|
package/dist/session-control.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export function normalizeExecutionResourceScope(raw) {
|
|
2
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)))
|
|
3
|
+
return;
|
|
4
|
+
const value = raw;
|
|
5
|
+
if (Object.keys(value).length !== 2)
|
|
6
|
+
return;
|
|
7
|
+
if ((value.kind === 'directory' || value.kind === 'file') && typeof value.path === 'string'
|
|
8
|
+
&& value.path.length > 0 && value.path.length <= 2048 && !/[\u0000-\u001f]/.test(value.path))
|
|
9
|
+
return { kind: value.kind, path: value.path };
|
|
10
|
+
if ((value.kind === 'git_ref' || value.kind === 'remote_object') && typeof value.ref === 'string'
|
|
11
|
+
&& /^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,511}$/.test(value.ref) && !value.ref.includes('..'))
|
|
12
|
+
return { kind: value.kind, ref: value.ref };
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
1
15
|
/** Shape only; a host must still compare it with the current canonical plan. */
|
|
2
16
|
export function normalizeSessionExecutionIdentity(raw) {
|
|
3
17
|
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)))
|