@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.
Files changed (120) hide show
  1. package/dist/acceptance-close-gate.d.ts +10 -1
  2. package/dist/acceptance-close-gate.js +12 -0
  3. package/dist/agent-supervision.d.ts +81 -0
  4. package/dist/agent-supervision.js +1 -0
  5. package/dist/attention.d.ts +44 -0
  6. package/dist/attention.js +1 -0
  7. package/dist/bot-access-policy.d.ts +29 -0
  8. package/dist/bot-access-policy.js +1 -0
  9. package/dist/bot-conversation-read.d.ts +67 -0
  10. package/dist/bot-conversation-read.js +9 -0
  11. package/dist/bot-direct-step.d.ts +11 -0
  12. package/dist/bot-direct-step.js +1 -0
  13. package/dist/bot-git.d.ts +55 -0
  14. package/dist/bot-git.js +1 -0
  15. package/dist/bot-model-selection.d.ts +13 -0
  16. package/dist/bot-model-selection.js +1 -0
  17. package/dist/browser-window.d.ts +48 -0
  18. package/dist/browser-window.js +23 -0
  19. package/dist/capability-admission.d.ts +20 -0
  20. package/dist/capability-admission.js +1 -0
  21. package/dist/compaction-history-selection.d.ts +15 -0
  22. package/dist/compaction-history-selection.js +30 -0
  23. package/dist/compaction.d.ts +5 -0
  24. package/dist/compaction.js +6 -0
  25. package/dist/context-accounting.d.ts +3 -0
  26. package/dist/conversation-execution.d.ts +68 -0
  27. package/dist/conversation-execution.js +222 -0
  28. package/dist/delegation-coordination.d.ts +81 -0
  29. package/dist/delegation-coordination.js +1 -0
  30. package/dist/delegation.d.ts +260 -7
  31. package/dist/delegation.js +97 -39
  32. package/dist/document-reference.d.ts +111 -0
  33. package/dist/document-reference.js +1 -0
  34. package/dist/evidence-inspection.d.ts +64 -0
  35. package/dist/evidence-inspection.js +1 -0
  36. package/dist/gemini-standard-pricing.json +105 -0
  37. package/dist/goal.d.ts +50 -2
  38. package/dist/hook-observation.d.ts +2 -0
  39. package/dist/hook-observation.js +19 -0
  40. package/dist/index.d.ts +109 -25
  41. package/dist/index.js +38 -0
  42. package/dist/input-prediction.d.ts +86 -0
  43. package/dist/input-prediction.js +48 -0
  44. package/dist/intent-coordination.d.ts +201 -0
  45. package/dist/intent-coordination.js +1 -0
  46. package/dist/interactive-result.d.ts +363 -0
  47. package/dist/interactive-result.js +215 -0
  48. package/dist/interactive-verification.d.ts +41 -0
  49. package/dist/interactive-verification.js +65 -0
  50. package/dist/local-git.d.ts +44 -0
  51. package/dist/local-git.js +3 -0
  52. package/dist/local-image.d.ts +53 -0
  53. package/dist/local-image.js +5 -0
  54. package/dist/local-read.d.ts +9 -0
  55. package/dist/local-read.js +1 -0
  56. package/dist/memory.d.ts +71 -11
  57. package/dist/memory.js +12 -0
  58. package/dist/model-reasoning.d.ts +16 -0
  59. package/dist/model-reasoning.js +25 -0
  60. package/dist/model-routing.d.ts +39 -3
  61. package/dist/model-routing.js +31 -5
  62. package/dist/native-process.d.ts +21 -0
  63. package/dist/native-process.js +51 -0
  64. package/dist/parent-coordination.d.ts +104 -0
  65. package/dist/parent-coordination.js +2 -0
  66. package/dist/project-agent-failure.d.ts +30 -0
  67. package/dist/project-agent-failure.js +44 -0
  68. package/dist/project-input-recovery.d.ts +83 -0
  69. package/dist/project-input-recovery.js +25 -0
  70. package/dist/project-matter.d.ts +225 -0
  71. package/dist/project-matter.js +1 -0
  72. package/dist/project-recovery.d.ts +43 -0
  73. package/dist/project-recovery.js +1 -0
  74. package/dist/project.d.ts +136 -0
  75. package/dist/project.js +130 -5
  76. package/dist/quiet-reply.d.ts +9 -0
  77. package/dist/quiet-reply.js +43 -0
  78. package/dist/remote-access.d.ts +15 -0
  79. package/dist/remote-access.js +1 -1
  80. package/dist/reply-delivery.d.ts +28 -0
  81. package/dist/reply-delivery.js +1 -0
  82. package/dist/resource-edit-execution.d.ts +68 -0
  83. package/dist/resource-edit-execution.js +96 -0
  84. package/dist/resource-edit.d.ts +237 -0
  85. package/dist/resource-edit.js +134 -0
  86. package/dist/resource-feedback-transport.d.ts +26 -0
  87. package/dist/resource-feedback-transport.js +94 -0
  88. package/dist/resource-feedback.d.ts +98 -0
  89. package/dist/resource-feedback.js +151 -0
  90. package/dist/resource-file-replace.d.ts +36 -0
  91. package/dist/resource-file-replace.js +40 -0
  92. package/dist/resource-reference-hints.d.ts +3 -0
  93. package/dist/resource-reference-hints.js +58 -0
  94. package/dist/resource-window.d.ts +222 -0
  95. package/dist/resource-window.js +252 -0
  96. package/dist/runtime-session-facts.d.ts +58 -0
  97. package/dist/runtime-session-facts.js +57 -0
  98. package/dist/session-control.d.ts +211 -0
  99. package/dist/session-control.js +48 -0
  100. package/dist/session-facts.d.ts +29 -0
  101. package/dist/session-facts.js +35 -0
  102. package/dist/skill-marketplace.d.ts +39 -4
  103. package/dist/spend-budget.d.ts +69 -0
  104. package/dist/spend-budget.js +1 -0
  105. package/dist/system-context.d.ts +7 -0
  106. package/dist/task-overview.d.ts +91 -0
  107. package/dist/task-overview.js +325 -17
  108. package/dist/tool-activity-preview.d.ts +4 -0
  109. package/dist/tool-activity-preview.js +72 -0
  110. package/dist/updater.d.ts +13 -3
  111. package/dist/usage-accounting.d.ts +42 -1
  112. package/dist/user-anchor.d.ts +17 -0
  113. package/dist/user-anchor.js +1 -0
  114. package/dist/work-coordination.d.ts +188 -0
  115. package/dist/work-coordination.js +1 -0
  116. package/dist/work-hook.d.ts +3 -0
  117. package/dist/work-hook.js +76 -0
  118. package/dist/working-plan.d.ts +18 -0
  119. package/dist/working-plan.js +1 -0
  120. package/package.json +1 -1
package/dist/project.d.ts CHANGED
@@ -2,8 +2,10 @@
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
+ import type { BotInputDeliveryBlocker } from './bot-conversation-read.ts';
5
6
  import type { ProjectModelPolicy } from './model-routing.ts';
6
7
  import type { PendingApprovalState, WorkSessionStatus } from './delegation.ts';
8
+ import type { FollowUpProjection } from './task-overview.ts';
7
9
  export interface DiagnosticText {
8
10
  readonly length: number;
9
11
  readonly sha256: string;
@@ -56,6 +58,7 @@ export interface ProjectDiagnostics {
56
58
  readonly acquiredAt: string | null;
57
59
  readonly heartbeatAt: string | null;
58
60
  } | null;
61
+ readonly inputDeliveryBlocker?: BotInputDeliveryBlocker | null;
59
62
  readonly input: {
60
63
  readonly depth: number | null;
61
64
  readonly executionDepth: number | null;
@@ -133,11 +136,25 @@ export type ProjectHostTakeoverResult = {
133
136
  readonly ok: false;
134
137
  readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_UNAVAILABLE' | 'INVALID_INPUT';
135
138
  };
139
+ export declare const BOT_AVATAR_HEADS: readonly ["none", "beret", "glasses", "beanie", "vermeer", "straw", "headphones", "crown"];
140
+ export type BotAvatarHead = (typeof BOT_AVATAR_HEADS)[number];
141
+ export declare const BOT_AVATAR_NECKS: readonly ["none", "bowtie", "scarf", "sweater", "moon", "sailor", "cape"];
142
+ export type BotAvatarNeck = (typeof BOT_AVATAR_NECKS)[number];
143
+ export interface BotAvatarPartsPatch {
144
+ readonly shape?: string;
145
+ readonly color?: string;
146
+ readonly head?: BotAvatarHead;
147
+ readonly neck?: BotAvatarNeck;
148
+ readonly backdrop?: boolean;
149
+ }
136
150
  export type BotAvatar = {
137
151
  readonly kind: 'generated';
138
152
  readonly shape: string;
139
153
  readonly color: string;
140
154
  readonly variant?: number;
155
+ readonly head?: BotAvatarHead;
156
+ readonly neck?: BotAvatarNeck;
157
+ readonly backdrop?: boolean;
141
158
  } | {
142
159
  readonly kind: 'image';
143
160
  readonly ref: string;
@@ -149,6 +166,19 @@ export type BotAvatarReadResult = {
149
166
  readonly ok: false;
150
167
  readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'INVALID_IMAGE';
151
168
  };
169
+ export type BotCommunicationStyle = 'natural' | 'concise' | 'detailed' | 'technical';
170
+ export type BotProfileCommunicationStyle = 'inherit' | BotCommunicationStyle;
171
+ /** Per-bot capability mounting overrides (inherits global enabled state when absent). */
172
+ export interface BotCapabilityPolicy {
173
+ /** Skill IDs explicitly mounted on this bot (overrides global disable). */
174
+ readonly enabledSkillIds?: readonly string[];
175
+ /** Skill IDs explicitly unmounted on this bot (overrides global/workspace enable). */
176
+ readonly disabledSkillIds?: readonly string[];
177
+ /** MCP server IDs explicitly mounted on this bot (overrides global disable). */
178
+ readonly enabledMcpIds?: readonly string[];
179
+ /** MCP server IDs explicitly unmounted on this bot (overrides global enable). */
180
+ readonly disabledMcpIds?: readonly string[];
181
+ }
152
182
  export interface BotProfile {
153
183
  readonly workspaceId: string;
154
184
  readonly displayName: string;
@@ -156,12 +186,21 @@ export interface BotProfile {
156
186
  readonly managed?: boolean;
157
187
  readonly agentConversationId?: string;
158
188
  readonly proactivity?: 'inherit' | 'quiet' | 'low' | 'standard' | 'high' | 'muted';
189
+ readonly communicationStyle?: BotProfileCommunicationStyle;
159
190
  /** Absent means this bot uses memory. */
160
191
  readonly memoryEnabled?: boolean;
161
192
  readonly planApproval?: 'never' | 'writes' | 'always';
162
193
  readonly acceptancePolicy?: 'auto' | 'confirm';
163
194
  /** Policy acceptance keeps a separate merge confirmation unless explicitly enabled. */
164
195
  readonly autoHandoffOnPolicyAccept?: boolean;
196
+ /** ADR 127: user-delegated unknown-outcome closure policy. Absent or null means ask; the model can never write it. */
197
+ readonly unknownOutcomePolicy?: {
198
+ readonly tier: 'ask' | 'bot_verified';
199
+ readonly policyId: string;
200
+ readonly revision: number;
201
+ readonly delegatedAt?: string;
202
+ readonly updatedAt: string;
203
+ } | null;
165
204
  /** Archived deletion intent, retained until each cleanup step is persisted. */
166
205
  readonly deletionCleanup?: {
167
206
  readonly folder: string;
@@ -169,10 +208,13 @@ export interface BotProfile {
169
208
  readonly removePending: boolean;
170
209
  } | null;
171
210
  readonly modelPolicy?: ProjectModelPolicy | null;
211
+ /** Bot-mounted Skills & MCP overrides inherited by all derived child tasks. */
212
+ readonly capabilityPolicy?: BotCapabilityPolicy | null;
172
213
  readonly updatedAt?: string;
173
214
  }
174
215
  export interface BotRowState {
175
216
  readonly needsYou: number;
217
+ readonly attentionExpiresAt?: string;
176
218
  readonly unread: number;
177
219
  readonly running: number;
178
220
  /** Ephemeral status of the runner hosted by this desktop process. */
@@ -184,14 +226,98 @@ export interface BotListItem {
184
226
  readonly preview: string;
185
227
  readonly lastActiveAt: string;
186
228
  readonly state: BotRowState;
229
+ readonly activeSessions?: readonly BotListSession[];
230
+ readonly activeSessionTotal?: number;
231
+ readonly historySessionTotal?: number;
187
232
  }
188
233
  export interface BotListFilter {
189
234
  readonly query?: string;
190
235
  readonly needsYouOnly?: boolean;
191
236
  }
237
+ /** Bounded, redacted display preview; never an execution or Evidence object. */
238
+ export interface ProjectAgentToolPreview {
239
+ readonly text: string;
240
+ readonly truncated: boolean;
241
+ readonly redacted: boolean;
242
+ }
243
+ export interface ProjectAgentToolActivity {
244
+ readonly kind: 'tool';
245
+ readonly id: string;
246
+ readonly name: string;
247
+ readonly status: 'preparing' | 'running' | 'awaiting_permission' | 'done' | 'error' | 'stopped';
248
+ readonly startedAt?: string;
249
+ readonly finishedAt?: string;
250
+ readonly summary?: string;
251
+ readonly input?: ProjectAgentToolPreview;
252
+ readonly result?: ProjectAgentToolPreview;
253
+ readonly receivedChars?: number;
254
+ readonly permissionDeadlineAt?: string;
255
+ }
256
+ /** Public conversation update, never hidden reasoning, Tool Result or Evidence.
257
+ * User agent_turn records may persist these as publicUpdates (100 / 32000 chars).
258
+ * Legacy rounds[].text is not a public-update source.
259
+ * role is the host-assigned display identity (ADR87 D4): opening = the first public
260
+ * text before any tool activity in the visible reply; every other public text is
261
+ * narration. Absent role means a pre-2026-11-09 legacy record; do not guess one.
262
+ */
263
+ export interface ProjectAgentPublicUpdate {
264
+ readonly id: string;
265
+ readonly text: string;
266
+ readonly role?: 'opening' | 'narration';
267
+ }
268
+ /** Display contract version for persisted agent_turn records (ADR87 D4).
269
+ * Version 2: public text carries role, the canonical agent_reply is the only
270
+ * answer body, and the implicit pure-text fallback reply is closed. Absent
271
+ * version means a legacy record and must keep legacy presentation.
272
+ */
273
+ export declare const AGENT_TURN_DISPLAY_CONTRACT: 2;
274
+ /** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
275
+ export interface ProjectAgentActivity {
276
+ /** Same-turn successful local file results only; navigation hints never grant access. */
277
+ readonly resourceReferences?: readonly import('./document-reference.ts').BotResourceReferenceHint[];
278
+ readonly workspaceId: string;
279
+ readonly conversationId: string;
280
+ readonly turnId: string;
281
+ /** Existing coordination identity; several execution attempts may serve one reply. */
282
+ readonly workId?: string;
283
+ readonly revision: number;
284
+ readonly startedAt: string;
285
+ readonly finishedAt?: string;
286
+ readonly modelSelection?: Pick<import('./model-routing.ts').RuntimeModelSelection, 'modelProviderId' | 'reasoningEffort'>;
287
+ readonly replyTo: readonly string[];
288
+ readonly phase: 'waiting' | 'thinking' | 'responding' | 'tool' | 'awaiting_permission' | 'settling' | 'done' | 'error' | 'stopped' | 'disposed';
289
+ readonly replyText: string;
290
+ /** A factual recovery event, cleared when the next provider event arrives. */
291
+ readonly recovery?: 'connection' | 'provider';
292
+ readonly segments: readonly (({
293
+ readonly kind: 'text';
294
+ } & ProjectAgentPublicUpdate) | ProjectAgentToolActivity)[];
295
+ }
296
+ export interface ProjectAgentStopResponseRequest {
297
+ readonly workspaceId: string;
298
+ readonly turnId: string;
299
+ }
300
+ export type ProjectAgentStopResponseResult = {
301
+ readonly ok: true;
302
+ } | {
303
+ readonly ok: false;
304
+ readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
305
+ };
192
306
  export interface BotListSession {
307
+ readonly startedAt?: string;
308
+ readonly endedAt?: string;
309
+ readonly sessionId?: string;
310
+ readonly title?: string;
193
311
  readonly status: WorkSessionStatus;
194
312
  readonly updatedAt?: string;
313
+ readonly followUp?: FollowUpProjection;
314
+ readonly phaseLabel?: string;
315
+ readonly anchorMessageId?: string;
316
+ readonly planId?: string;
317
+ readonly conversationId?: string;
318
+ readonly queueReason?: string;
319
+ readonly resultConfirmationRequired?: boolean;
320
+ readonly completionReviewRequired?: boolean;
195
321
  }
196
322
  export interface BotListApproval {
197
323
  readonly state: PendingApprovalState;
@@ -205,6 +331,7 @@ export interface BotListMessage {
205
331
  }
206
332
  export declare const BOT_AVATAR_SHAPES: readonly ["circle", "square", "triangle", "diamond", "hex", "pill", "star", "arch"];
207
333
  export declare const BOT_AVATAR_COLORS: readonly ["#6474e5", "#f36d63", "#f4ad45", "#61b68c", "#a884e5", "#e774ad", "#55bac7", "#a8a59f"];
334
+ export declare function resolveLegacyBotAvatarShape(shape: string, variant: number): "circle" | "square" | "triangle" | "diamond" | "hex" | "pill" | "star" | "arch";
208
335
  export declare function generateAvatar(workspaceId: string): Extract<BotAvatar, {
209
336
  kind: 'generated';
210
337
  }>;
@@ -213,7 +340,16 @@ export declare function projectBotListItem(input: {
213
340
  readonly lastMessage?: BotListMessage | null;
214
341
  readonly sessions?: readonly BotListSession[];
215
342
  readonly approvals?: readonly BotListApproval[];
343
+ readonly attention?: readonly {
344
+ readonly id: string;
345
+ }[];
216
346
  readonly readCursor?: string | null;
217
347
  }): BotListItem;
218
348
  export declare function sortBotList(items: readonly BotListItem[]): BotListItem[];
219
349
  export declare function filterBotList(items: readonly BotListItem[], filter?: BotListFilter): BotListItem[];
350
+ export declare function normalizeBotCapabilityPolicy(policy: BotCapabilityPolicy | null | undefined): BotCapabilityPolicy | null;
351
+ export declare function hasBotCapabilityOverrides(policy: BotCapabilityPolicy | null | undefined): boolean;
352
+ export declare function resolveBotSkillEnabled(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean): boolean;
353
+ export declare function resolveBotMcpEnabled(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean): boolean;
354
+ export declare function toggleBotSkillOverride(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
355
+ export declare function toggleBotMcpOverride(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
package/dist/project.js CHANGED
@@ -2,6 +2,31 @@
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
+ 'none',
17
+ 'bowtie',
18
+ 'scarf',
19
+ 'sweater',
20
+ 'moon',
21
+ 'sailor',
22
+ 'cape',
23
+ ];
24
+ /** Display contract version for persisted agent_turn records (ADR87 D4).
25
+ * Version 2: public text carries role, the canonical agent_reply is the only
26
+ * answer body, and the implicit pure-text fallback reply is closed. Absent
27
+ * version means a legacy record and must keep legacy presentation.
28
+ */
29
+ export const AGENT_TURN_DISPLAY_CONTRACT = 2;
5
30
  export const BOT_AVATAR_SHAPES = [
6
31
  'circle',
7
32
  'square',
@@ -22,7 +47,14 @@ export const BOT_AVATAR_COLORS = [
22
47
  '#55bac7',
23
48
  '#a8a59f',
24
49
  ];
25
- const NEEDS_YOU_STATUSES = new Set(['waiting_user', 'result_ready']);
50
+ // Profiles saved before variant was persisted used this order when rotating coats.
51
+ const LEGACY_ROTATION_ORDER = [
52
+ 'circle', 'square', 'pill', 'arch', 'hex', 'diamond', 'triangle', 'star',
53
+ ];
54
+ export function resolveLegacyBotAvatarShape(shape, variant) {
55
+ const index = LEGACY_ROTATION_ORDER.findIndex(item => item === shape);
56
+ return LEGACY_ROTATION_ORDER[(Math.max(0, index) + variant) % LEGACY_ROTATION_ORDER.length] ?? 'circle';
57
+ }
26
58
  const RUNNING_STATUSES = new Set(['starting', 'running', 'verifying']);
27
59
  function fnv1a(text) {
28
60
  let hash = 0x811c9dc5;
@@ -51,9 +83,7 @@ function latestIso(values) {
51
83
  }
52
84
  export function projectBotListItem(input) {
53
85
  const sessions = input.sessions ?? [];
54
- const approvals = input.approvals ?? [];
55
- const openApprovals = approvals.filter((item) => item.state === 'open' || item.state === 'stale').length;
56
- const waitingSessions = sessions.filter((item) => NEEDS_YOU_STATUSES.has(item.status)).length;
86
+ const attention = new Set((input.attention ?? []).map(item => item.id));
57
87
  const running = sessions.filter((item) => RUNNING_STATUSES.has(item.status)).length;
58
88
  const lastMessage = input.lastMessage ?? null;
59
89
  const unread = lastMessage
@@ -72,7 +102,7 @@ export function projectBotListItem(input) {
72
102
  ...sessions.map((item) => item.updatedAt),
73
103
  ]),
74
104
  state: {
75
- needsYou: openApprovals + waitingSessions,
105
+ needsYou: attention.size,
76
106
  unread,
77
107
  running,
78
108
  },
@@ -104,3 +134,98 @@ export function filterBotList(items, filter = {}) {
104
134
  return haystack.includes(query);
105
135
  });
106
136
  }
137
+ function dedupCapabilityIds(ids) {
138
+ if (!Array.isArray(ids))
139
+ return [];
140
+ const out = [];
141
+ const seen = new Set();
142
+ for (const raw of ids) {
143
+ if (typeof raw !== 'string')
144
+ continue;
145
+ const trimmed = raw.trim();
146
+ if (!trimmed || seen.has(trimmed))
147
+ continue;
148
+ seen.add(trimmed);
149
+ out.push(trimmed);
150
+ }
151
+ return out;
152
+ }
153
+ export function normalizeBotCapabilityPolicy(policy) {
154
+ if (!policy || typeof policy !== 'object')
155
+ return null;
156
+ const disabledSkillIds = dedupCapabilityIds(policy.disabledSkillIds);
157
+ const disabledSkillSet = new Set(disabledSkillIds);
158
+ const enabledSkillIds = dedupCapabilityIds(policy.enabledSkillIds).filter((id) => !disabledSkillSet.has(id));
159
+ const disabledMcpIds = dedupCapabilityIds(policy.disabledMcpIds);
160
+ const disabledMcpSet = new Set(disabledMcpIds);
161
+ const enabledMcpIds = dedupCapabilityIds(policy.enabledMcpIds).filter((id) => !disabledMcpSet.has(id));
162
+ if (enabledSkillIds.length === 0
163
+ && disabledSkillIds.length === 0
164
+ && enabledMcpIds.length === 0
165
+ && disabledMcpIds.length === 0) {
166
+ return null;
167
+ }
168
+ return {
169
+ ...(enabledSkillIds.length > 0 ? { enabledSkillIds } : {}),
170
+ ...(disabledSkillIds.length > 0 ? { disabledSkillIds } : {}),
171
+ ...(enabledMcpIds.length > 0 ? { enabledMcpIds } : {}),
172
+ ...(disabledMcpIds.length > 0 ? { disabledMcpIds } : {}),
173
+ };
174
+ }
175
+ export function hasBotCapabilityOverrides(policy) {
176
+ return normalizeBotCapabilityPolicy(policy) !== null;
177
+ }
178
+ export function resolveBotSkillEnabled(policy, skillId, defaultEnabled) {
179
+ if (!policy)
180
+ return defaultEnabled;
181
+ if (policy.disabledSkillIds?.includes(skillId))
182
+ return false;
183
+ if (policy.enabledSkillIds?.includes(skillId))
184
+ return true;
185
+ return defaultEnabled;
186
+ }
187
+ export function resolveBotMcpEnabled(policy, mcpId, defaultEnabled) {
188
+ if (!policy)
189
+ return defaultEnabled;
190
+ if (policy.disabledMcpIds?.includes(mcpId))
191
+ return false;
192
+ if (policy.enabledMcpIds?.includes(mcpId))
193
+ return true;
194
+ return defaultEnabled;
195
+ }
196
+ export function toggleBotSkillOverride(policy, skillId, defaultEnabled, nextEnabled) {
197
+ const id = skillId.trim();
198
+ if (!id)
199
+ return normalizeBotCapabilityPolicy(policy);
200
+ const enabledSkillIds = dedupCapabilityIds(policy?.enabledSkillIds).filter((item) => item !== id);
201
+ const disabledSkillIds = dedupCapabilityIds(policy?.disabledSkillIds).filter((item) => item !== id);
202
+ if (nextEnabled !== defaultEnabled) {
203
+ if (nextEnabled)
204
+ enabledSkillIds.push(id);
205
+ else
206
+ disabledSkillIds.push(id);
207
+ }
208
+ return normalizeBotCapabilityPolicy({
209
+ ...policy,
210
+ enabledSkillIds,
211
+ disabledSkillIds,
212
+ });
213
+ }
214
+ export function toggleBotMcpOverride(policy, mcpId, defaultEnabled, nextEnabled) {
215
+ const id = mcpId.trim();
216
+ if (!id)
217
+ return normalizeBotCapabilityPolicy(policy);
218
+ const enabledMcpIds = dedupCapabilityIds(policy?.enabledMcpIds).filter((item) => item !== id);
219
+ const disabledMcpIds = dedupCapabilityIds(policy?.disabledMcpIds).filter((item) => item !== id);
220
+ if (nextEnabled !== defaultEnabled) {
221
+ if (nextEnabled)
222
+ enabledMcpIds.push(id);
223
+ else
224
+ disabledMcpIds.push(id);
225
+ }
226
+ return normalizeBotCapabilityPolicy({
227
+ ...policy,
228
+ enabledMcpIds,
229
+ disabledMcpIds,
230
+ });
231
+ }
@@ -0,0 +1,9 @@
1
+ export declare const QUIET_REPLY_MARKER: "NO_REPLY";
2
+ export interface QuietReplyParse {
3
+ readonly isQuiet: boolean;
4
+ readonly leadingText: string;
5
+ readonly isPureQuiet: boolean;
6
+ }
7
+ export declare function parseQuietReply(raw: string): QuietReplyParse;
8
+ export declare function isQuietReply(raw: string): boolean;
9
+ export declare function withoutGrowingQuietMarker(raw: string): string;
@@ -0,0 +1,43 @@
1
+ export const QUIET_REPLY_MARKER = 'NO_REPLY';
2
+ // Match Rust char::is_whitespace and char::is_alphanumeric, including non-ASCII letters.
3
+ const alphanumeric = /[\p{Alphabetic}\p{Number}]/u;
4
+ const markup = /^[`*_]*/u;
5
+ const validSuffix = /^[`*_.!]*$/u;
6
+ const trimEnd = (text) => text.replace(/\p{White_Space}+$/u, '');
7
+ function inlineReference(before, decorations) {
8
+ return decorations.includes('`') && alphanumeric.test(before.slice(before.lastIndexOf('\n') + 1));
9
+ }
10
+ function wordParts(text, separator) {
11
+ let start = text.length;
12
+ while (start > 0 && !separator.test(text[start - 1] ?? ''))
13
+ start--;
14
+ const word = text.slice(start);
15
+ const before = text.slice(0, start);
16
+ const decorations = markup.exec(word)?.[0] ?? '';
17
+ return { before, decorations, bare: word.slice(decorations.length) };
18
+ }
19
+ function exactMarker(bare) {
20
+ return bare.startsWith(QUIET_REPLY_MARKER) && validSuffix.test(bare.slice(QUIET_REPLY_MARKER.length));
21
+ }
22
+ export function parseQuietReply(raw) {
23
+ let remaining = trimEnd(raw);
24
+ let isQuiet = false;
25
+ while (true) {
26
+ const { before, decorations, bare } = wordParts(remaining, /\p{White_Space}/u);
27
+ if (!exactMarker(bare) || inlineReference(before, decorations))
28
+ break;
29
+ isQuiet = true;
30
+ remaining = trimEnd(before);
31
+ }
32
+ const isPureQuiet = isQuiet && !alphanumeric.test(remaining);
33
+ return { isQuiet, isPureQuiet, leadingText: isPureQuiet ? '' : isQuiet ? remaining : raw };
34
+ }
35
+ export function isQuietReply(raw) {
36
+ return parseQuietReply(raw).isQuiet;
37
+ }
38
+ export function withoutGrowingQuietMarker(raw) {
39
+ const { before, decorations, bare } = wordParts(trimEnd(raw), /[ \n\t]/u);
40
+ return bare && (QUIET_REPLY_MARKER.startsWith(bare) || exactMarker(bare)) && !inlineReference(before, decorations)
41
+ ? trimEnd(before)
42
+ : raw;
43
+ }
@@ -54,6 +54,8 @@ export declare const REMOTE_PROJECT_LIMITS: Readonly<{
54
54
  projects: 200;
55
55
  messages: 50;
56
56
  text: 4000;
57
+ interactiveResults: 8;
58
+ interactiveSummary: 256;
57
59
  requestBytes: number;
58
60
  delegationBytes: number;
59
61
  resultBytes: number;
@@ -90,6 +92,19 @@ export type RemoteProjectRequest = RemoteProjectRequestBase & ({
90
92
  readonly workspaceId: string;
91
93
  readonly text: string;
92
94
  });
95
+ /** Optional fixed-result projection on the existing project.session.read response. */
96
+ export type RemoteProjectInteractiveResult = {
97
+ readonly ref: string;
98
+ readonly availability: 'available' | 'cleaned';
99
+ } & ({
100
+ readonly title: string;
101
+ readonly summary: string;
102
+ readonly truncated: boolean;
103
+ } | {
104
+ readonly title?: never;
105
+ readonly summary?: never;
106
+ readonly truncated?: never;
107
+ });
93
108
  export interface RemoteProjectContext extends Omit<RemoteReadContext, 'delegation' | 'task'> {
94
109
  readonly delegation: {
95
110
  readonly version: number;
@@ -57,7 +57,7 @@ export function admitRemoteRead(value, context) {
57
57
  return parsed;
58
58
  }
59
59
  export const REMOTE_PROJECT_LIMITS = Object.freeze({
60
- projects: 200, messages: 50, text: 4000,
60
+ projects: 200, messages: 50, text: 4000, interactiveResults: 8, interactiveSummary: 256,
61
61
  requestBytes: 32 * 1024, delegationBytes: 128 * 1024, resultBytes: 2 * 1024 * 1024,
62
62
  });
63
63
  const projectBaseFields = [
@@ -0,0 +1,28 @@
1
+ /** The old delivered aggregate still requires both canonical commit and host settlement. */
2
+ export interface ReplyDeliveryReceipt {
3
+ readonly state: 'prepared' | 'delivered' | 'invalidated' | 'deferred' | 'aggregated';
4
+ readonly heldAt?: string;
5
+ readonly deliveredBy?: string;
6
+ readonly canonicalCommittedAt?: string;
7
+ readonly settlement?: {
8
+ readonly operationId: string;
9
+ readonly status: 'pending' | 'failed' | 'applied';
10
+ readonly attempts: number;
11
+ readonly updatedAt: string;
12
+ readonly phase?: 'commit' | 'settlement';
13
+ readonly error?: string;
14
+ readonly retryAt?: string;
15
+ };
16
+ }
17
+ /** Derived locally from current assessments, never accepted from assistant reply metadata. */
18
+ export interface IntentReplyBinding {
19
+ readonly workId: string;
20
+ readonly goalRevision: number;
21
+ readonly intentRevision: number;
22
+ readonly decisionRef: string;
23
+ readonly replyRef: string;
24
+ }
25
+ export interface ReplyGoalScope {
26
+ readonly workId: string;
27
+ readonly goalRevision: number;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ import { type ResourceEditOperation, type ResourceEditReceipt } from './resource-edit.ts';
2
+ import { RESOURCE_FILE_REPLACE_CAPABILITY, RESOURCE_FILE_REPLACE_TOOL, type ResourceFileReplacePreview, type ResourceFileReplaceInput } from './resource-file-replace.ts';
3
+ import type { PermissionGrant } from './index.ts';
4
+ export declare const RESOURCE_EDIT_EXECUTION_BYTES = 32768;
5
+ export declare const RESOURCE_EDIT_POSTLUDE_BYTES = 16384;
6
+ export declare const RESOURCE_EDIT_EXECUTION_TOTAL_BYTES: number;
7
+ /** Stored facts have their own schema; they never contain the complete Tool Call arguments. */
8
+ export interface ResourceEditExecutionRecord {
9
+ readonly schemaVersion: 1;
10
+ readonly workspaceId: string;
11
+ readonly requestId: string;
12
+ readonly payloadHash: string;
13
+ readonly projectionId: string;
14
+ readonly sessionId: string;
15
+ readonly call: {
16
+ readonly toolCallId: string;
17
+ readonly capabilityId: typeof RESOURCE_FILE_REPLACE_CAPABILITY;
18
+ readonly toolName: typeof RESOURCE_FILE_REPLACE_TOOL;
19
+ readonly argumentsDigest: string;
20
+ readonly occurredAt: string;
21
+ readonly permissionCallId?: string;
22
+ };
23
+ readonly grant: Omit<PermissionGrant, 'scope'> & {
24
+ readonly scope?: typeof RESOURCE_FILE_REPLACE_CAPABILITY | null;
25
+ };
26
+ readonly result: {
27
+ readonly toolCallId: string;
28
+ readonly status: 'success' | 'failed' | 'denied' | 'cancelled';
29
+ readonly completedAt: string;
30
+ readonly observation?: ResourceFileReplacePreview;
31
+ readonly blockedReason?: string;
32
+ readonly evidence: {
33
+ readonly evidenceId: string;
34
+ readonly toolCallId: string;
35
+ readonly summary: string;
36
+ readonly locale: string;
37
+ readonly returnedToCloud: false;
38
+ readonly dataLevel: 'D2_sensitive';
39
+ readonly redactions: readonly string[];
40
+ readonly artifactRefs: readonly string[];
41
+ };
42
+ };
43
+ }
44
+ export interface ResourceEditHookFact {
45
+ readonly id?: string;
46
+ readonly event?: 'PreToolUse' | 'PostToolUse';
47
+ readonly decision: 'allow' | 'ask' | 'deny';
48
+ readonly reason?: string;
49
+ readonly outcome?: string;
50
+ readonly durationMs?: number;
51
+ readonly exitCode?: number | null;
52
+ }
53
+ export interface ResourceEditPostlude {
54
+ readonly schemaVersion: 1;
55
+ readonly requestId: string;
56
+ readonly payloadHash: string;
57
+ readonly completedAt: string;
58
+ readonly status: 'recorded' | 'unconfirmed';
59
+ readonly reason?: string;
60
+ readonly hookFinalDecision?: 'allow' | 'ask' | 'deny';
61
+ readonly hooks?: readonly ResourceEditHookFact[];
62
+ }
63
+ export declare function resourceFileReplaceArgumentPayload(raw: ResourceFileReplaceInput): string;
64
+ export declare function normalizeResourceEditExecutionRecord(raw: unknown): ResourceEditExecutionRecord | undefined;
65
+ export declare function resourceEditExecutionMatches(record: ResourceEditExecutionRecord, raw: ResourceEditOperation): boolean;
66
+ /** Caller must have obtained this record from the actual host execution index, never model text. */
67
+ export declare function resourceEditExecutionReceipt(record: ResourceEditExecutionRecord, operation: ResourceEditOperation): ResourceEditReceipt | undefined;
68
+ export declare function normalizeResourceEditPostlude(raw: unknown): ResourceEditPostlude | undefined;