@peer-agent/protocol 0.1.0-rc.40 → 0.1.0-rc.42
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/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 +58 -0
- package/dist/conversation-execution.js +183 -0
- package/dist/delegation.d.ts +21 -0
- package/dist/delegation.js +5 -0
- package/dist/hook-observation.d.ts +2 -0
- package/dist/hook-observation.js +19 -0
- package/dist/index.d.ts +35 -21
- package/dist/index.js +5 -1
- package/dist/input-prediction.d.ts +2 -2
- package/dist/input-prediction.js +2 -2
- package/dist/local-read.d.ts +9 -0
- package/dist/local-read.js +1 -0
- package/dist/native-process.d.ts +21 -0
- package/dist/native-process.js +51 -0
- package/dist/project-input-recovery.d.ts +9 -1
- package/dist/project.d.ts +68 -0
- package/dist/project.js +119 -0
- package/dist/resource-window.d.ts +5 -0
- package/dist/resource-window.js +9 -2
- package/dist/runtime-session-facts.js +4 -2
- package/dist/session-control.d.ts +100 -3
- package/dist/session-control.js +14 -0
- package/dist/task-overview.d.ts +2 -1
- package/dist/task-overview.js +4 -1
- package/dist/usage-accounting.d.ts +29 -0
- package/dist/work-coordination.d.ts +23 -0
- package/dist/work-hook.d.ts +3 -0
- package/dist/work-hook.js +76 -0
- package/package.json +1 -1
|
@@ -11,11 +11,11 @@ export interface InputPredictionSettings {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const INPUT_PREDICTION_LIMITS: Readonly<{
|
|
13
13
|
inputTokens: 4096;
|
|
14
|
-
outputTokens:
|
|
14
|
+
outputTokens: 256;
|
|
15
15
|
draftLength: 2048;
|
|
16
16
|
candidateLength: 240;
|
|
17
17
|
candidateGraphemes: 120;
|
|
18
|
-
timeoutMs:
|
|
18
|
+
timeoutMs: 6000;
|
|
19
19
|
validationMs: 150;
|
|
20
20
|
ttlMs: 60000;
|
|
21
21
|
requestIntervalMs: 3000;
|
package/dist/input-prediction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const INPUT_PREDICTION_LIMITS = Object.freeze({
|
|
2
|
-
inputTokens: 4096, outputTokens:
|
|
2
|
+
inputTokens: 4096, outputTokens: 256, draftLength: 2048,
|
|
3
3
|
candidateLength: 240, candidateGraphemes: 120,
|
|
4
|
-
timeoutMs:
|
|
4
|
+
timeoutMs: 6000, validationMs: 150, ttlMs: 60_000,
|
|
5
5
|
requestIntervalMs: 3000, requestsPerMinute: 12,
|
|
6
6
|
});
|
|
7
7
|
export function normalizeInputPredictionSettings(value) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** ADR106/131: the existing Git Provider's concrete local read approval shape.
|
|
2
|
+
* This is an audit scope, never a deserializable execution authority token.
|
|
3
|
+
*/
|
|
4
|
+
export interface LocalReadPermissionScope {
|
|
5
|
+
readonly kind: 'file-read';
|
|
6
|
+
readonly capabilityId: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly workspacePath: string | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SessionControlOperation } from './session-control.ts';
|
|
2
|
+
import { type SessionExecutionIdentity } from './session-control.ts';
|
|
3
|
+
type Recorder = NonNullable<SessionControlOperation['recorder']>;
|
|
4
|
+
export interface NativeOwnedProcess {
|
|
5
|
+
readonly schemaVersion: 1;
|
|
6
|
+
readonly kind: 'command';
|
|
7
|
+
readonly handleId: string;
|
|
8
|
+
readonly toolCallId: string;
|
|
9
|
+
readonly dispatchId: string;
|
|
10
|
+
readonly execution: SessionExecutionIdentity;
|
|
11
|
+
readonly generation: number;
|
|
12
|
+
readonly state: 'not_started' | 'starting' | 'running' | 'ended';
|
|
13
|
+
readonly owner: Recorder;
|
|
14
|
+
readonly child?: Recorder | null;
|
|
15
|
+
readonly stopObservation?: 'owned_completion' | 'owner_dead_not_started' | 'owner_dead_group_absent' | null;
|
|
16
|
+
}
|
|
17
|
+
/** Envelope shape only. Execution identity is validated by each owning contract. */
|
|
18
|
+
export declare function nativeProcessEnvelopeValid(raw: unknown): boolean;
|
|
19
|
+
/** Shape only: no value here proves local execution or process death. */
|
|
20
|
+
export declare function nativeProcessesInWork(work: unknown): readonly NativeOwnedProcess[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { normalizeSessionExecutionIdentity } from "./session-control.js";
|
|
2
|
+
const object = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) ? v : {};
|
|
3
|
+
const text = (v, bytes) => typeof v === 'string' && v.length > 0 && v.length <= bytes && new TextEncoder().encode(v).length <= bytes;
|
|
4
|
+
const recorder = (v) => {
|
|
5
|
+
const r = object(v);
|
|
6
|
+
return Number.isInteger(r.pid) && r.pid > 0 && r.pid <= 2147483647
|
|
7
|
+
&& ['bootId', 'pidStart', 'hostId', 'acquiredAt'].every(k => text(r[k], 8192));
|
|
8
|
+
};
|
|
9
|
+
/** Envelope shape only. Execution identity is validated by each owning contract. */
|
|
10
|
+
export function nativeProcessEnvelopeValid(raw) {
|
|
11
|
+
const p = object(raw), owner = object(p.owner), child = object(p.child);
|
|
12
|
+
const keys = ['schemaVersion', 'kind', 'handleId', 'toolCallId', 'dispatchId', 'execution', 'generation', 'state', 'owner', 'child', 'stopObservation'];
|
|
13
|
+
const validChild = p.child == null || recorder(child) && ['hostId', 'acquiredAt', 'bootId'].every(k => child[k] === owner[k]);
|
|
14
|
+
const gen = Number.isInteger(p.generation) && p.generation >= 0 && p.generation <= 64;
|
|
15
|
+
const phase = p.state === 'not_started' ? p.generation === 0 && p.child == null && p.stopObservation == null
|
|
16
|
+
: p.state === 'starting' ? p.generation > 0 && p.child == null && p.stopObservation == null
|
|
17
|
+
: p.state === 'running' ? p.generation > 0 && p.child != null && p.stopObservation == null
|
|
18
|
+
: p.state === 'ended' && (p.stopObservation === 'owned_completion'
|
|
19
|
+
|| p.stopObservation === 'owner_dead_not_started' && p.generation === 0 && p.child == null
|
|
20
|
+
|| p.stopObservation === 'owner_dead_group_absent' && p.generation > 0 && p.child != null);
|
|
21
|
+
return p.schemaVersion === 1 && p.kind === 'command' && !Object.keys(p).some(k => !keys.includes(k))
|
|
22
|
+
&& ['handleId', 'toolCallId', 'dispatchId'].every(k => text(p[k], 200))
|
|
23
|
+
&& !!gen && !!phase && recorder(owner) && !!validChild;
|
|
24
|
+
}
|
|
25
|
+
/** Shape only: no value here proves local execution or process death. */
|
|
26
|
+
export function nativeProcessesInWork(work) {
|
|
27
|
+
const budget = object(object(work).budget);
|
|
28
|
+
const rows = [...Object.values(object(budget.attempts)).flatMap(a => {
|
|
29
|
+
const pending = object(a).pendingTools;
|
|
30
|
+
return Array.isArray(pending) ? pending : [];
|
|
31
|
+
}), ...(Array.isArray(budget.uncertainDispatches) ? budget.uncertainDispatches : [])];
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const raw of rows) {
|
|
34
|
+
const row = object(raw);
|
|
35
|
+
if (!Object.hasOwn(row, 'nativeProcess'))
|
|
36
|
+
continue;
|
|
37
|
+
const p = object(row.nativeProcess), owner = object(p.owner);
|
|
38
|
+
const original = object(object(row.nativeRecorder).recorder);
|
|
39
|
+
const execution = normalizeSessionExecutionIdentity(p.execution);
|
|
40
|
+
const recordedExecution = normalizeSessionExecutionIdentity(object(row.nativeRecorder).execution);
|
|
41
|
+
if (!nativeProcessEnvelopeValid(p) || !recorder(original) || !execution || !recordedExecution
|
|
42
|
+
|| JSON.stringify(execution) !== JSON.stringify(recordedExecution)
|
|
43
|
+
|| !['pid', 'pidStart', 'bootId', 'hostId', 'acquiredAt'].every(k => owner[k] === original[k])
|
|
44
|
+
|| p.toolCallId !== row.toolCallId || p.dispatchId !== row.dispatchId || result.length >= 128
|
|
45
|
+
|| result.some(old => old.handleId === p.handleId || old.toolCallId === p.toolCallId || old.dispatchId === p.dispatchId)) {
|
|
46
|
+
throw new Error('native_process_invalid');
|
|
47
|
+
}
|
|
48
|
+
result.push(structuredClone(p));
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import type { ResourceFeedback } from './resource-feedback.ts';
|
|
2
|
-
import type { ProjectInputAttachment, ProjectAgentSubmitInputResult } from './delegation.ts';
|
|
2
|
+
import type { ProjectInputAttachment, ProjectAgentSubmitInputResult, WorkSessionStatus } from './delegation.ts';
|
|
3
3
|
export type LocalInputSurface = 'desktop' | 'quick_chat' | 'tui';
|
|
4
4
|
export interface InputDraftQuote {
|
|
5
5
|
readonly messageId: string;
|
|
6
6
|
readonly text: string;
|
|
7
7
|
}
|
|
8
|
+
export interface InputDraftTaskRef {
|
|
9
|
+
readonly sessionId: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly status: WorkSessionStatus | string;
|
|
12
|
+
readonly anchorMessageId?: string;
|
|
13
|
+
}
|
|
8
14
|
export interface InputDraftValue {
|
|
9
15
|
readonly text: string;
|
|
10
16
|
readonly quote: InputDraftQuote | null;
|
|
11
17
|
readonly attachments: readonly ProjectInputAttachment[];
|
|
18
|
+
readonly taskRefs?: readonly InputDraftTaskRef[];
|
|
12
19
|
readonly resourceFeedback?: readonly ResourceFeedback[];
|
|
13
20
|
}
|
|
14
21
|
/** User intent only. Presence here never means the input was received or executed. */
|
|
@@ -16,6 +23,7 @@ export interface UnconfirmedProjectInput {
|
|
|
16
23
|
readonly inputId: string;
|
|
17
24
|
readonly text: string;
|
|
18
25
|
readonly quoteRefs: readonly string[];
|
|
26
|
+
readonly taskRefs?: readonly InputDraftTaskRef[];
|
|
19
27
|
readonly answerTo?: string;
|
|
20
28
|
readonly attachments: readonly ProjectInputAttachment[];
|
|
21
29
|
readonly resourceFeedback?: readonly ResourceFeedback[];
|
package/dist/project.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ProjectModelPolicy } from './model-routing.ts';
|
|
6
6
|
import type { PendingApprovalState, WorkSessionStatus } from './delegation.ts';
|
|
7
|
+
import type { FollowUpProjection } from './task-overview.ts';
|
|
7
8
|
export interface DiagnosticText {
|
|
8
9
|
readonly length: number;
|
|
9
10
|
readonly sha256: string;
|
|
@@ -133,11 +134,25 @@ export type ProjectHostTakeoverResult = {
|
|
|
133
134
|
readonly ok: false;
|
|
134
135
|
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_UNAVAILABLE' | 'INVALID_INPUT';
|
|
135
136
|
};
|
|
137
|
+
export declare const BOT_AVATAR_HEADS: readonly ["none", "beret", "glasses", "beanie", "vermeer", "straw", "headphones", "crown"];
|
|
138
|
+
export type BotAvatarHead = (typeof BOT_AVATAR_HEADS)[number];
|
|
139
|
+
export declare const BOT_AVATAR_NECKS: readonly ["bowtie", "scarf", "sweater", "moon", "sailor", "cape"];
|
|
140
|
+
export type BotAvatarNeck = (typeof BOT_AVATAR_NECKS)[number];
|
|
141
|
+
export interface BotAvatarPartsPatch {
|
|
142
|
+
readonly shape?: string;
|
|
143
|
+
readonly color?: string;
|
|
144
|
+
readonly head?: BotAvatarHead;
|
|
145
|
+
readonly neck?: BotAvatarNeck;
|
|
146
|
+
readonly backdrop?: boolean;
|
|
147
|
+
}
|
|
136
148
|
export type BotAvatar = {
|
|
137
149
|
readonly kind: 'generated';
|
|
138
150
|
readonly shape: string;
|
|
139
151
|
readonly color: string;
|
|
140
152
|
readonly variant?: number;
|
|
153
|
+
readonly head?: BotAvatarHead;
|
|
154
|
+
readonly neck?: BotAvatarNeck;
|
|
155
|
+
readonly backdrop?: boolean;
|
|
141
156
|
} | {
|
|
142
157
|
readonly kind: 'image';
|
|
143
158
|
readonly ref: string;
|
|
@@ -149,6 +164,19 @@ export type BotAvatarReadResult = {
|
|
|
149
164
|
readonly ok: false;
|
|
150
165
|
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'INVALID_IMAGE';
|
|
151
166
|
};
|
|
167
|
+
export type BotCommunicationStyle = 'natural' | 'concise' | 'detailed' | 'technical';
|
|
168
|
+
export type BotProfileCommunicationStyle = 'inherit' | BotCommunicationStyle;
|
|
169
|
+
/** Per-bot capability mounting overrides (inherits global enabled state when absent). */
|
|
170
|
+
export interface BotCapabilityPolicy {
|
|
171
|
+
/** Skill IDs explicitly mounted on this bot (overrides global disable). */
|
|
172
|
+
readonly enabledSkillIds?: readonly string[];
|
|
173
|
+
/** Skill IDs explicitly unmounted on this bot (overrides global/workspace enable). */
|
|
174
|
+
readonly disabledSkillIds?: readonly string[];
|
|
175
|
+
/** MCP server IDs explicitly mounted on this bot (overrides global disable). */
|
|
176
|
+
readonly enabledMcpIds?: readonly string[];
|
|
177
|
+
/** MCP server IDs explicitly unmounted on this bot (overrides global enable). */
|
|
178
|
+
readonly disabledMcpIds?: readonly string[];
|
|
179
|
+
}
|
|
152
180
|
export interface BotProfile {
|
|
153
181
|
readonly workspaceId: string;
|
|
154
182
|
readonly displayName: string;
|
|
@@ -156,12 +184,21 @@ export interface BotProfile {
|
|
|
156
184
|
readonly managed?: boolean;
|
|
157
185
|
readonly agentConversationId?: string;
|
|
158
186
|
readonly proactivity?: 'inherit' | 'quiet' | 'low' | 'standard' | 'high' | 'muted';
|
|
187
|
+
readonly communicationStyle?: BotProfileCommunicationStyle;
|
|
159
188
|
/** Absent means this bot uses memory. */
|
|
160
189
|
readonly memoryEnabled?: boolean;
|
|
161
190
|
readonly planApproval?: 'never' | 'writes' | 'always';
|
|
162
191
|
readonly acceptancePolicy?: 'auto' | 'confirm';
|
|
163
192
|
/** Policy acceptance keeps a separate merge confirmation unless explicitly enabled. */
|
|
164
193
|
readonly autoHandoffOnPolicyAccept?: boolean;
|
|
194
|
+
/** ADR 127: user-delegated unknown-outcome closure policy. Absent or null means ask; the model can never write it. */
|
|
195
|
+
readonly unknownOutcomePolicy?: {
|
|
196
|
+
readonly tier: 'ask' | 'bot_verified';
|
|
197
|
+
readonly policyId: string;
|
|
198
|
+
readonly revision: number;
|
|
199
|
+
readonly delegatedAt?: string;
|
|
200
|
+
readonly updatedAt: string;
|
|
201
|
+
} | null;
|
|
165
202
|
/** Archived deletion intent, retained until each cleanup step is persisted. */
|
|
166
203
|
readonly deletionCleanup?: {
|
|
167
204
|
readonly folder: string;
|
|
@@ -169,6 +206,8 @@ export interface BotProfile {
|
|
|
169
206
|
readonly removePending: boolean;
|
|
170
207
|
} | null;
|
|
171
208
|
readonly modelPolicy?: ProjectModelPolicy | null;
|
|
209
|
+
/** Bot-mounted Skills & MCP overrides inherited by all derived child tasks. */
|
|
210
|
+
readonly capabilityPolicy?: BotCapabilityPolicy | null;
|
|
172
211
|
readonly updatedAt?: string;
|
|
173
212
|
}
|
|
174
213
|
export interface BotRowState {
|
|
@@ -185,6 +224,9 @@ export interface BotListItem {
|
|
|
185
224
|
readonly preview: string;
|
|
186
225
|
readonly lastActiveAt: string;
|
|
187
226
|
readonly state: BotRowState;
|
|
227
|
+
readonly activeSessions?: readonly BotListSession[];
|
|
228
|
+
readonly activeSessionTotal?: number;
|
|
229
|
+
readonly historySessionTotal?: number;
|
|
188
230
|
}
|
|
189
231
|
export interface BotListFilter {
|
|
190
232
|
readonly query?: string;
|
|
@@ -212,11 +254,21 @@ export interface ProjectAgentToolActivity {
|
|
|
212
254
|
/** Public conversation update, never hidden reasoning, Tool Result or Evidence.
|
|
213
255
|
* User agent_turn records may persist these as publicUpdates (100 / 32000 chars).
|
|
214
256
|
* Legacy rounds[].text is not a public-update source.
|
|
257
|
+
* role is the host-assigned display identity (ADR87 D4): opening = the first public
|
|
258
|
+
* text before any tool activity in the visible reply; every other public text is
|
|
259
|
+
* narration. Absent role means a pre-2026-11-09 legacy record; do not guess one.
|
|
215
260
|
*/
|
|
216
261
|
export interface ProjectAgentPublicUpdate {
|
|
217
262
|
readonly id: string;
|
|
218
263
|
readonly text: string;
|
|
264
|
+
readonly role?: 'opening' | 'narration';
|
|
219
265
|
}
|
|
266
|
+
/** Display contract version for persisted agent_turn records (ADR87 D4).
|
|
267
|
+
* Version 2: public text carries role, the canonical agent_reply is the only
|
|
268
|
+
* answer body, and the implicit pure-text fallback reply is closed. Absent
|
|
269
|
+
* version means a legacy record and must keep legacy presentation.
|
|
270
|
+
*/
|
|
271
|
+
export declare const AGENT_TURN_DISPLAY_CONTRACT: 2;
|
|
220
272
|
/** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
|
|
221
273
|
export interface ProjectAgentActivity {
|
|
222
274
|
/** Same-turn successful local file results only; navigation hints never grant access. */
|
|
@@ -250,8 +302,18 @@ export type ProjectAgentStopResponseResult = {
|
|
|
250
302
|
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
|
|
251
303
|
};
|
|
252
304
|
export interface BotListSession {
|
|
305
|
+
readonly sessionId?: string;
|
|
306
|
+
readonly title?: string;
|
|
253
307
|
readonly status: WorkSessionStatus;
|
|
254
308
|
readonly updatedAt?: string;
|
|
309
|
+
readonly followUp?: FollowUpProjection;
|
|
310
|
+
readonly phaseLabel?: string;
|
|
311
|
+
readonly anchorMessageId?: string;
|
|
312
|
+
readonly planId?: string;
|
|
313
|
+
readonly conversationId?: string;
|
|
314
|
+
readonly queueReason?: string;
|
|
315
|
+
readonly resultConfirmationRequired?: boolean;
|
|
316
|
+
readonly completionReviewRequired?: boolean;
|
|
255
317
|
}
|
|
256
318
|
export interface BotListApproval {
|
|
257
319
|
readonly state: PendingApprovalState;
|
|
@@ -280,3 +342,9 @@ export declare function projectBotListItem(input: {
|
|
|
280
342
|
}): BotListItem;
|
|
281
343
|
export declare function sortBotList(items: readonly BotListItem[]): BotListItem[];
|
|
282
344
|
export declare function filterBotList(items: readonly BotListItem[], filter?: BotListFilter): BotListItem[];
|
|
345
|
+
export declare function normalizeBotCapabilityPolicy(policy: BotCapabilityPolicy | null | undefined): BotCapabilityPolicy | null;
|
|
346
|
+
export declare function hasBotCapabilityOverrides(policy: BotCapabilityPolicy | null | undefined): boolean;
|
|
347
|
+
export declare function resolveBotSkillEnabled(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean): boolean;
|
|
348
|
+
export declare function resolveBotMcpEnabled(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean): boolean;
|
|
349
|
+
export declare function toggleBotSkillOverride(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
|
|
350
|
+
export declare function toggleBotMcpOverride(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
|
package/dist/project.js
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
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
|
+
export const BOT_AVATAR_HEADS = [
|
|
6
|
+
'none',
|
|
7
|
+
'beret',
|
|
8
|
+
'glasses',
|
|
9
|
+
'beanie',
|
|
10
|
+
'vermeer',
|
|
11
|
+
'straw',
|
|
12
|
+
'headphones',
|
|
13
|
+
'crown',
|
|
14
|
+
];
|
|
15
|
+
export const BOT_AVATAR_NECKS = [
|
|
16
|
+
'bowtie',
|
|
17
|
+
'scarf',
|
|
18
|
+
'sweater',
|
|
19
|
+
'moon',
|
|
20
|
+
'sailor',
|
|
21
|
+
'cape',
|
|
22
|
+
];
|
|
23
|
+
/** Display contract version for persisted agent_turn records (ADR87 D4).
|
|
24
|
+
* Version 2: public text carries role, the canonical agent_reply is the only
|
|
25
|
+
* answer body, and the implicit pure-text fallback reply is closed. Absent
|
|
26
|
+
* version means a legacy record and must keep legacy presentation.
|
|
27
|
+
*/
|
|
28
|
+
export const AGENT_TURN_DISPLAY_CONTRACT = 2;
|
|
5
29
|
export const BOT_AVATAR_SHAPES = [
|
|
6
30
|
'circle',
|
|
7
31
|
'square',
|
|
@@ -101,3 +125,98 @@ export function filterBotList(items, filter = {}) {
|
|
|
101
125
|
return haystack.includes(query);
|
|
102
126
|
});
|
|
103
127
|
}
|
|
128
|
+
function dedupCapabilityIds(ids) {
|
|
129
|
+
if (!Array.isArray(ids))
|
|
130
|
+
return [];
|
|
131
|
+
const out = [];
|
|
132
|
+
const seen = new Set();
|
|
133
|
+
for (const raw of ids) {
|
|
134
|
+
if (typeof raw !== 'string')
|
|
135
|
+
continue;
|
|
136
|
+
const trimmed = raw.trim();
|
|
137
|
+
if (!trimmed || seen.has(trimmed))
|
|
138
|
+
continue;
|
|
139
|
+
seen.add(trimmed);
|
|
140
|
+
out.push(trimmed);
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
export function normalizeBotCapabilityPolicy(policy) {
|
|
145
|
+
if (!policy || typeof policy !== 'object')
|
|
146
|
+
return null;
|
|
147
|
+
const disabledSkillIds = dedupCapabilityIds(policy.disabledSkillIds);
|
|
148
|
+
const disabledSkillSet = new Set(disabledSkillIds);
|
|
149
|
+
const enabledSkillIds = dedupCapabilityIds(policy.enabledSkillIds).filter((id) => !disabledSkillSet.has(id));
|
|
150
|
+
const disabledMcpIds = dedupCapabilityIds(policy.disabledMcpIds);
|
|
151
|
+
const disabledMcpSet = new Set(disabledMcpIds);
|
|
152
|
+
const enabledMcpIds = dedupCapabilityIds(policy.enabledMcpIds).filter((id) => !disabledMcpSet.has(id));
|
|
153
|
+
if (enabledSkillIds.length === 0
|
|
154
|
+
&& disabledSkillIds.length === 0
|
|
155
|
+
&& enabledMcpIds.length === 0
|
|
156
|
+
&& disabledMcpIds.length === 0) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...(enabledSkillIds.length > 0 ? { enabledSkillIds } : {}),
|
|
161
|
+
...(disabledSkillIds.length > 0 ? { disabledSkillIds } : {}),
|
|
162
|
+
...(enabledMcpIds.length > 0 ? { enabledMcpIds } : {}),
|
|
163
|
+
...(disabledMcpIds.length > 0 ? { disabledMcpIds } : {}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export function hasBotCapabilityOverrides(policy) {
|
|
167
|
+
return normalizeBotCapabilityPolicy(policy) !== null;
|
|
168
|
+
}
|
|
169
|
+
export function resolveBotSkillEnabled(policy, skillId, defaultEnabled) {
|
|
170
|
+
if (!policy)
|
|
171
|
+
return defaultEnabled;
|
|
172
|
+
if (policy.disabledSkillIds?.includes(skillId))
|
|
173
|
+
return false;
|
|
174
|
+
if (policy.enabledSkillIds?.includes(skillId))
|
|
175
|
+
return true;
|
|
176
|
+
return defaultEnabled;
|
|
177
|
+
}
|
|
178
|
+
export function resolveBotMcpEnabled(policy, mcpId, defaultEnabled) {
|
|
179
|
+
if (!policy)
|
|
180
|
+
return defaultEnabled;
|
|
181
|
+
if (policy.disabledMcpIds?.includes(mcpId))
|
|
182
|
+
return false;
|
|
183
|
+
if (policy.enabledMcpIds?.includes(mcpId))
|
|
184
|
+
return true;
|
|
185
|
+
return defaultEnabled;
|
|
186
|
+
}
|
|
187
|
+
export function toggleBotSkillOverride(policy, skillId, defaultEnabled, nextEnabled) {
|
|
188
|
+
const id = skillId.trim();
|
|
189
|
+
if (!id)
|
|
190
|
+
return normalizeBotCapabilityPolicy(policy);
|
|
191
|
+
const enabledSkillIds = dedupCapabilityIds(policy?.enabledSkillIds).filter((item) => item !== id);
|
|
192
|
+
const disabledSkillIds = dedupCapabilityIds(policy?.disabledSkillIds).filter((item) => item !== id);
|
|
193
|
+
if (nextEnabled !== defaultEnabled) {
|
|
194
|
+
if (nextEnabled)
|
|
195
|
+
enabledSkillIds.push(id);
|
|
196
|
+
else
|
|
197
|
+
disabledSkillIds.push(id);
|
|
198
|
+
}
|
|
199
|
+
return normalizeBotCapabilityPolicy({
|
|
200
|
+
...policy,
|
|
201
|
+
enabledSkillIds,
|
|
202
|
+
disabledSkillIds,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
export function toggleBotMcpOverride(policy, mcpId, defaultEnabled, nextEnabled) {
|
|
206
|
+
const id = mcpId.trim();
|
|
207
|
+
if (!id)
|
|
208
|
+
return normalizeBotCapabilityPolicy(policy);
|
|
209
|
+
const enabledMcpIds = dedupCapabilityIds(policy?.enabledMcpIds).filter((item) => item !== id);
|
|
210
|
+
const disabledMcpIds = dedupCapabilityIds(policy?.disabledMcpIds).filter((item) => item !== id);
|
|
211
|
+
if (nextEnabled !== defaultEnabled) {
|
|
212
|
+
if (nextEnabled)
|
|
213
|
+
enabledMcpIds.push(id);
|
|
214
|
+
else
|
|
215
|
+
disabledMcpIds.push(id);
|
|
216
|
+
}
|
|
217
|
+
return normalizeBotCapabilityPolicy({
|
|
218
|
+
...policy,
|
|
219
|
+
enabledMcpIds,
|
|
220
|
+
disabledMcpIds,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
@@ -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}`));
|
|
@@ -7,7 +7,7 @@ const ownerships = new Set(['live', 'ended', 'unknown']);
|
|
|
7
7
|
const owners = new Set(['bot', 'user', 'none']);
|
|
8
8
|
const reasons = new Set(['settled', 'superseded', 'stop_confirmed', 'user_withdrawn',
|
|
9
9
|
'stop_unconfirmed', 'human_request', 'awaiting_human_gate', 'technical_block', 'local_persistence_failed', 'awaiting_acceptance_technical',
|
|
10
|
-
'verification_failed', 'live_execution', 'paused', 'unknown_facts', 'obligation_indexed']);
|
|
10
|
+
'verification_failed', 'execution_failed', 'live_execution', 'paused', 'unknown_facts', 'obligation_indexed']);
|
|
11
11
|
const hostReasons = new Set(['live_execution', 'stop_unconfirmed', 'unknown_facts', 'local_persistence_failed']);
|
|
12
12
|
export function runtimeSessionFacts(value) {
|
|
13
13
|
const row = record(value), origin = record(row.origin), cancellation = record(origin.cancellation);
|
|
@@ -36,7 +36,9 @@ export function runtimeSessionFacts(value) {
|
|
|
36
36
|
: executionOwnership === 'live' || stopping || owner === 'bot' && hostReasons.has(reason) ? 'host'
|
|
37
37
|
: owner === 'none' ? 'none' : 'model';
|
|
38
38
|
return { sessionId, status, valid, executionOwnership, owner, reason, handling,
|
|
39
|
-
pendingManaged: reason === 'obligation_indexed'
|
|
39
|
+
pendingManaged: reason === 'obligation_indexed' || (reason === 'execution_failed' && handling === 'none')
|
|
40
|
+
? false
|
|
41
|
+
: handling === 'host' || handling === 'user' || !['accepted', 'cancelled'].includes(status) };
|
|
40
42
|
}
|
|
41
43
|
/** Missing/invalid facts remain obligations; a valid public terminal does not invent live ownership. */
|
|
42
44
|
export function hasPendingRuntimeSessions(sessions, expectedIds = []) {
|
|
@@ -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,102 @@ 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
|
+
}
|
|
166
|
+
/** ADR 131: local transport ownership only; never proof of remote tool effects. */
|
|
167
|
+
export interface NativeMcpHandleObservation {
|
|
168
|
+
readonly schemaVersion: 1;
|
|
169
|
+
readonly role: 'rpc' | 'connection';
|
|
170
|
+
readonly transport: 'stdio' | 'streamable_http' | 'sse';
|
|
171
|
+
readonly registryRevision: string;
|
|
172
|
+
readonly ownerRecorder: NonNullable<SessionControlOperation['recorder']>;
|
|
173
|
+
readonly childRecorder?: NonNullable<SessionControlOperation['recorder']>;
|
|
174
|
+
readonly ownerStopObservation?: 'original_owner_dead';
|
|
175
|
+
readonly childStopObservation?: 'group_absent';
|
|
176
|
+
}
|
|
83
177
|
export interface ExecutionResourceClaim {
|
|
84
178
|
readonly claimId: string;
|
|
85
179
|
readonly resourceRef: string;
|
|
@@ -93,8 +187,11 @@ export interface ExecutionResourceClaim {
|
|
|
93
187
|
readonly toolCallId: string;
|
|
94
188
|
readonly state: 'active' | 'ended' | 'unknown';
|
|
95
189
|
readonly completedAt?: string;
|
|
190
|
+
readonly nativeMcp?: NativeMcpHandleObservation;
|
|
96
191
|
}>>;
|
|
97
192
|
readonly evidenceCalls: readonly string[];
|
|
193
|
+
/** Absent means the legacy directory scope derived from resourceRef; dispatch-declared scopes arrive with claim scope convergence. */
|
|
194
|
+
readonly scope?: ExecutionResourceScope;
|
|
98
195
|
}
|
|
99
196
|
/** Feed the existing lifecycle projector; a stale compatibility mirror cannot revive an old stop. */
|
|
100
197
|
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)))
|
package/dist/task-overview.d.ts
CHANGED
|
@@ -407,6 +407,7 @@ export interface LifecycleFacts {
|
|
|
407
407
|
readonly interrupted?: boolean;
|
|
408
408
|
readonly interruptionOrigin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
409
409
|
readonly verificationActive?: boolean;
|
|
410
|
+
readonly verificationFailed?: boolean;
|
|
410
411
|
readonly blockedReason?: string;
|
|
411
412
|
readonly cancellationPhase?: string;
|
|
412
413
|
readonly cancellationDisposition?: 'user_withdrawn';
|
|
@@ -427,7 +428,7 @@ export interface LifecycleCoreDecision extends ProjectionDecision {
|
|
|
427
428
|
* `inCurrentList` 是派生事实,不允许消费端各自按 status 再判一次。
|
|
428
429
|
*/
|
|
429
430
|
export type FollowUpOwner = 'bot' | 'user' | 'none';
|
|
430
|
-
export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'local_persistence_failed' | 'awaiting_acceptance_technical' | 'verification_failed' | 'live_execution' | 'paused' | 'unknown_facts' | 'obligation_indexed';
|
|
431
|
+
export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'local_persistence_failed' | 'awaiting_acceptance_technical' | 'verification_failed' | 'execution_failed' | 'live_execution' | 'paused' | 'unknown_facts' | 'obligation_indexed';
|
|
431
432
|
export interface FollowUpProjection {
|
|
432
433
|
readonly owner: FollowUpOwner;
|
|
433
434
|
readonly inCurrentList: boolean;
|