@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.51

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 (130) 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 +84 -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/group-chat.d.ts +87 -0
  39. package/dist/group-chat.js +1 -0
  40. package/dist/hook-observation.d.ts +2 -0
  41. package/dist/hook-observation.js +19 -0
  42. package/dist/index.d.ts +117 -25
  43. package/dist/index.js +41 -0
  44. package/dist/input-prediction.d.ts +86 -0
  45. package/dist/input-prediction.js +48 -0
  46. package/dist/intent-coordination.d.ts +201 -0
  47. package/dist/intent-coordination.js +1 -0
  48. package/dist/interactive-result.d.ts +363 -0
  49. package/dist/interactive-result.js +215 -0
  50. package/dist/interactive-verification.d.ts +41 -0
  51. package/dist/interactive-verification.js +65 -0
  52. package/dist/local-git.d.ts +44 -0
  53. package/dist/local-git.js +3 -0
  54. package/dist/local-image.d.ts +53 -0
  55. package/dist/local-image.js +5 -0
  56. package/dist/local-read.d.ts +9 -0
  57. package/dist/local-read.js +1 -0
  58. package/dist/memory.d.ts +117 -12
  59. package/dist/memory.js +12 -0
  60. package/dist/model-reasoning.d.ts +16 -0
  61. package/dist/model-reasoning.js +25 -0
  62. package/dist/model-routing.d.ts +39 -3
  63. package/dist/model-routing.js +31 -5
  64. package/dist/native-process.d.ts +21 -0
  65. package/dist/native-process.js +51 -0
  66. package/dist/parent-coordination.d.ts +104 -0
  67. package/dist/parent-coordination.js +2 -0
  68. package/dist/persistent-workspace.d.ts +519 -0
  69. package/dist/persistent-workspace.js +1 -0
  70. package/dist/project-agent-failure.d.ts +30 -0
  71. package/dist/project-agent-failure.js +44 -0
  72. package/dist/project-input-recovery.d.ts +83 -0
  73. package/dist/project-input-recovery.js +25 -0
  74. package/dist/project-matter.d.ts +359 -0
  75. package/dist/project-matter.js +1 -0
  76. package/dist/project-recovery.d.ts +43 -0
  77. package/dist/project-recovery.js +1 -0
  78. package/dist/project.d.ts +233 -0
  79. package/dist/project.js +134 -5
  80. package/dist/prompt-skill.d.ts +31 -0
  81. package/dist/prompt-skill.js +1 -0
  82. package/dist/quiet-reply.d.ts +9 -0
  83. package/dist/quiet-reply.js +43 -0
  84. package/dist/remote-access.d.ts +15 -0
  85. package/dist/remote-access.js +1 -1
  86. package/dist/reply-delivery.d.ts +28 -0
  87. package/dist/reply-delivery.js +1 -0
  88. package/dist/resource-edit-execution.d.ts +68 -0
  89. package/dist/resource-edit-execution.js +96 -0
  90. package/dist/resource-edit.d.ts +237 -0
  91. package/dist/resource-edit.js +134 -0
  92. package/dist/resource-feedback-transport.d.ts +26 -0
  93. package/dist/resource-feedback-transport.js +94 -0
  94. package/dist/resource-feedback.d.ts +110 -0
  95. package/dist/resource-feedback.js +168 -0
  96. package/dist/resource-file-replace.d.ts +36 -0
  97. package/dist/resource-file-replace.js +40 -0
  98. package/dist/resource-reference-hints.d.ts +3 -0
  99. package/dist/resource-reference-hints.js +58 -0
  100. package/dist/resource-window.d.ts +222 -0
  101. package/dist/resource-window.js +252 -0
  102. package/dist/routine.d.ts +82 -0
  103. package/dist/routine.js +1 -0
  104. package/dist/runtime-session-facts.d.ts +58 -0
  105. package/dist/runtime-session-facts.js +57 -0
  106. package/dist/session-control.d.ts +211 -0
  107. package/dist/session-control.js +48 -0
  108. package/dist/session-facts.d.ts +29 -0
  109. package/dist/session-facts.js +35 -0
  110. package/dist/skill-marketplace.d.ts +39 -4
  111. package/dist/spend-budget.d.ts +69 -0
  112. package/dist/spend-budget.js +1 -0
  113. package/dist/system-context.d.ts +7 -0
  114. package/dist/task-overview.d.ts +91 -0
  115. package/dist/task-overview.js +325 -17
  116. package/dist/tool-activity-preview.d.ts +4 -0
  117. package/dist/tool-activity-preview.js +72 -0
  118. package/dist/updater.d.ts +13 -3
  119. package/dist/usage-accounting.d.ts +42 -1
  120. package/dist/user-anchor.d.ts +17 -0
  121. package/dist/user-anchor.js +1 -0
  122. package/dist/work-coordination.d.ts +188 -0
  123. package/dist/work-coordination.js +1 -0
  124. package/dist/work-hook.d.ts +3 -0
  125. package/dist/work-hook.js +76 -0
  126. package/dist/working-plan.d.ts +18 -0
  127. package/dist/working-plan.js +1 -0
  128. package/dist/workspace.d.ts +35 -0
  129. package/dist/workspace.js +1 -0
  130. 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,19 +166,42 @@ 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 {
183
+ readonly kind?: 'project' | 'global';
153
184
  readonly workspaceId: string;
154
185
  readonly displayName: string;
155
186
  readonly avatar: BotAvatar;
156
187
  readonly managed?: boolean;
157
188
  readonly agentConversationId?: string;
158
189
  readonly proactivity?: 'inherit' | 'quiet' | 'low' | 'standard' | 'high' | 'muted';
190
+ readonly communicationStyle?: BotProfileCommunicationStyle;
159
191
  /** Absent means this bot uses memory. */
160
192
  readonly memoryEnabled?: boolean;
161
193
  readonly planApproval?: 'never' | 'writes' | 'always';
162
194
  readonly acceptancePolicy?: 'auto' | 'confirm';
163
195
  /** Policy acceptance keeps a separate merge confirmation unless explicitly enabled. */
164
196
  readonly autoHandoffOnPolicyAccept?: boolean;
197
+ /** ADR 127: user-delegated unknown-outcome closure policy. Absent or null means ask; the model can never write it. */
198
+ readonly unknownOutcomePolicy?: {
199
+ readonly tier: 'ask' | 'bot_verified';
200
+ readonly policyId: string;
201
+ readonly revision: number;
202
+ readonly delegatedAt?: string;
203
+ readonly updatedAt: string;
204
+ } | null;
165
205
  /** Archived deletion intent, retained until each cleanup step is persisted. */
166
206
  readonly deletionCleanup?: {
167
207
  readonly folder: string;
@@ -169,10 +209,76 @@ export interface BotProfile {
169
209
  readonly removePending: boolean;
170
210
  } | null;
171
211
  readonly modelPolicy?: ProjectModelPolicy | null;
212
+ /** Bot-mounted Skills & MCP overrides inherited by all derived child tasks. */
213
+ readonly capabilityPolicy?: BotCapabilityPolicy | null;
172
214
  readonly updatedAt?: string;
173
215
  }
216
+ export declare function isGlobalBotProfile(profile: Pick<BotProfile, 'kind'> | null | undefined): boolean;
217
+ export interface GlobalBotPreferences {
218
+ readonly visible: boolean;
219
+ readonly pinned: boolean;
220
+ readonly revision: string;
221
+ }
222
+ export type GlobalBotPreferencesUpdate = {
223
+ readonly expectedRevision: string;
224
+ } & ({
225
+ readonly visible: boolean;
226
+ readonly pinned?: boolean;
227
+ } | {
228
+ readonly visible?: boolean;
229
+ readonly pinned: boolean;
230
+ });
231
+ export type GlobalBotErrorCode = 'BUILTIN_GLOBAL_BOT_PROTECTED' | 'GLOBAL_BOT_IDENTITY_CONFLICT' | 'GLOBAL_BOT_BOOTSTRAP_INCOMPLETE' | 'PROTECTED_PATH' | 'CORRUPT_REGISTRY' | 'CORRUPT_PROFILE' | 'RUNTIME_UNAVAILABLE' | 'POLICY_UNAVAILABLE' | 'POLICY_RESOURCE_LIMIT' | 'STORE_LOCK_BUSY' | 'STORE_LOCK_OWNERSHIP_CHANGED' | 'STORE_COMMIT_UNCERTAIN' | 'BACKGROUND_READ_FAILED' | 'BACKGROUND_VERSION_CHANGED' | 'BACKGROUND_HISTORY_CORRUPT' | 'BACKGROUND_HISTORY_LIMIT' | 'INVALID_INPUT' | 'INVALID_PATH' | 'INVALID_WORKSPACE' | 'INVALID_SETTINGS' | 'SETTINGS_CONFLICT' | 'IO_ERROR' | 'SERIALIZE_ERROR' | 'ARCHIVED' | 'OUT_OF_SCOPE' | 'NOT_FOUND' | 'AVATAR_EXHAUSTED' | 'CANCELLED';
232
+ export type GlobalBotRpcFailure = {
233
+ readonly ok: false;
234
+ readonly code: GlobalBotErrorCode;
235
+ };
236
+ export type GlobalBotPreferencesResult = ({
237
+ readonly ok: true;
238
+ } & GlobalBotPreferences) | GlobalBotRpcFailure;
239
+ export type EnsureGlobalBotResult = {
240
+ readonly ok: true;
241
+ readonly workspaceId: string;
242
+ readonly profile: BotProfile;
243
+ readonly created: boolean;
244
+ } | GlobalBotRpcFailure;
245
+ export declare const BOT_CONTEXT_BOUNDARY_KIND = "context_boundary";
246
+ export type NewBotConversationResult = {
247
+ readonly ok: true;
248
+ readonly created: boolean;
249
+ readonly boundaryId: string | null;
250
+ readonly revision: number;
251
+ readonly timestamp: string | null;
252
+ } | {
253
+ readonly ok: false;
254
+ readonly code: string;
255
+ };
256
+ export interface GlobalBotRpc {
257
+ readonly 'project.bot.newConversation': {
258
+ readonly params: {
259
+ readonly workspaceId: string;
260
+ };
261
+ readonly result: NewBotConversationResult;
262
+ };
263
+ readonly 'project.bot.ensureGlobal': {
264
+ readonly params: Record<string, never>;
265
+ readonly result: EnsureGlobalBotResult;
266
+ };
267
+ readonly 'project.bot.globalPreferences.get': {
268
+ readonly params: Record<string, never>;
269
+ readonly result: GlobalBotPreferencesResult;
270
+ };
271
+ readonly 'project.bot.globalPreferences.update': {
272
+ readonly params: GlobalBotPreferencesUpdate;
273
+ readonly result: GlobalBotPreferencesResult;
274
+ };
275
+ }
276
+ export interface GlobalBotRpcNotifications {
277
+ readonly 'project.bot.globalPreferences.changed': GlobalBotPreferences;
278
+ }
174
279
  export interface BotRowState {
175
280
  readonly needsYou: number;
281
+ readonly attentionExpiresAt?: string;
176
282
  readonly unread: number;
177
283
  readonly running: number;
178
284
  /** Ephemeral status of the runner hosted by this desktop process. */
@@ -184,14 +290,131 @@ export interface BotListItem {
184
290
  readonly preview: string;
185
291
  readonly lastActiveAt: string;
186
292
  readonly state: BotRowState;
293
+ readonly activeSessions?: readonly BotListSession[];
294
+ readonly activeSessionTotal?: number;
295
+ readonly historySessionTotal?: number;
187
296
  }
188
297
  export interface BotListFilter {
189
298
  readonly query?: string;
190
299
  readonly needsYouOnly?: boolean;
191
300
  }
301
+ /** Bounded, redacted display preview; never an execution or Evidence object. */
302
+ export interface ProjectAgentToolPreview {
303
+ readonly text: string;
304
+ readonly truncated: boolean;
305
+ readonly redacted: boolean;
306
+ }
307
+ export interface ReplyTraceTool {
308
+ readonly verb: string;
309
+ readonly status?: 'done' | 'failed' | 'cancelled' | 'unknown';
310
+ readonly commandPreview?: string;
311
+ readonly targetSummary?: string;
312
+ readonly errorCode?: string;
313
+ readonly errorSummary?: string;
314
+ readonly matchCount?: number;
315
+ }
316
+ export interface ReplyTraceModelSpan {
317
+ readonly startedAtMs: number;
318
+ readonly endedAtMs: number;
319
+ readonly durationMs: number;
320
+ readonly failed?: boolean;
321
+ /** Public assistant commentary following host admission and redaction. */
322
+ readonly text?: string;
323
+ }
324
+ export interface ReplyTraceSummary {
325
+ readonly steps: number;
326
+ readonly failures: number;
327
+ readonly totalDurationMs?: number;
328
+ readonly modelDurationMs?: number;
329
+ readonly toolDurationMs?: number;
330
+ }
331
+ export interface ProjectAgentToolActivity {
332
+ readonly kind: 'tool';
333
+ readonly id: string;
334
+ readonly name: string;
335
+ readonly status: 'preparing' | 'running' | 'awaiting_permission' | 'done' | 'error' | 'stopped';
336
+ readonly startedAt?: string;
337
+ readonly finishedAt?: string;
338
+ readonly startedAtMs?: number;
339
+ readonly endedAtMs?: number;
340
+ readonly durationMs?: number;
341
+ readonly trace?: ReplyTraceTool;
342
+ readonly summary?: string;
343
+ readonly input?: ProjectAgentToolPreview;
344
+ readonly result?: ProjectAgentToolPreview;
345
+ readonly receivedChars?: number;
346
+ readonly permissionDeadlineAt?: string;
347
+ }
348
+ /** Public conversation update, never hidden reasoning, Tool Result or Evidence.
349
+ * User agent_turn records may persist these as publicUpdates (100 / 32000 chars).
350
+ * Legacy rounds[].text is not a public-update source.
351
+ * role is the host-assigned display identity (ADR87 D4): opening = the first public
352
+ * text before any tool activity in the visible reply; every other public text is
353
+ * narration. Absent role means a pre-2026-11-09 legacy record; do not guess one.
354
+ */
355
+ export interface ProjectAgentPublicUpdate {
356
+ readonly id: string;
357
+ readonly text: string;
358
+ readonly role?: 'opening' | 'narration';
359
+ }
360
+ /** Display contract version for persisted agent_turn records (ADR87 D4).
361
+ * Version 2: public text carries role, the canonical agent_reply is the only
362
+ * answer body, and the implicit pure-text fallback reply is closed. Absent
363
+ * version means a legacy record and must keep legacy presentation.
364
+ */
365
+ export declare const AGENT_TURN_DISPLAY_CONTRACT: 2;
366
+ /** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
367
+ export interface ProjectAgentActivity {
368
+ /** Same-turn successful local file results only; navigation hints never grant access. */
369
+ readonly resourceReferences?: readonly import('./document-reference.ts').BotResourceReferenceHint[];
370
+ readonly workspaceId: string;
371
+ readonly conversationId: string;
372
+ readonly turnId: string;
373
+ /** Existing coordination identity; several execution attempts may serve one reply. */
374
+ readonly workId?: string;
375
+ readonly revision: number;
376
+ readonly startedAt: string;
377
+ readonly finishedAt?: string;
378
+ readonly modelSelection?: Pick<import('./model-routing.ts').RuntimeModelSelection, 'modelProviderId' | 'reasoningEffort'>;
379
+ readonly replyTo: readonly string[];
380
+ readonly modelSpans?: readonly ReplyTraceModelSpan[];
381
+ readonly phase: 'waiting' | 'thinking' | 'responding' | 'tool' | 'awaiting_permission' | 'settling' | 'done' | 'error' | 'stopped' | 'disposed';
382
+ readonly replyText: string;
383
+ /** A factual recovery event, cleared when the next provider event arrives. */
384
+ readonly recovery?: 'connection' | 'provider';
385
+ readonly segments: readonly (({
386
+ readonly kind: 'text';
387
+ } & ProjectAgentPublicUpdate) | ProjectAgentToolActivity)[];
388
+ }
389
+ export interface ProjectAgentStopResponseRequest {
390
+ readonly workspaceId: string;
391
+ readonly turnId: string;
392
+ }
393
+ export type ProjectAgentStopResponseResult = {
394
+ readonly ok: true;
395
+ } | {
396
+ readonly ok: false;
397
+ readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
398
+ };
192
399
  export interface BotListSession {
400
+ readonly matterId?: string;
401
+ readonly matterNumber?: number;
402
+ readonly followUpEpoch?: number;
403
+ readonly runAvailable?: boolean;
404
+ readonly startedAt?: string;
405
+ readonly endedAt?: string;
406
+ readonly sessionId?: string;
407
+ readonly title?: string;
193
408
  readonly status: WorkSessionStatus;
194
409
  readonly updatedAt?: string;
410
+ readonly followUp?: FollowUpProjection;
411
+ readonly phaseLabel?: string;
412
+ readonly anchorMessageId?: string;
413
+ readonly planId?: string;
414
+ readonly conversationId?: string;
415
+ readonly queueReason?: string;
416
+ readonly resultConfirmationRequired?: boolean;
417
+ readonly completionReviewRequired?: boolean;
195
418
  }
196
419
  export interface BotListApproval {
197
420
  readonly state: PendingApprovalState;
@@ -205,6 +428,7 @@ export interface BotListMessage {
205
428
  }
206
429
  export declare const BOT_AVATAR_SHAPES: readonly ["circle", "square", "triangle", "diamond", "hex", "pill", "star", "arch"];
207
430
  export declare const BOT_AVATAR_COLORS: readonly ["#6474e5", "#f36d63", "#f4ad45", "#61b68c", "#a884e5", "#e774ad", "#55bac7", "#a8a59f"];
431
+ export declare function resolveLegacyBotAvatarShape(shape: string, variant: number): "circle" | "square" | "triangle" | "diamond" | "hex" | "pill" | "star" | "arch";
208
432
  export declare function generateAvatar(workspaceId: string): Extract<BotAvatar, {
209
433
  kind: 'generated';
210
434
  }>;
@@ -213,7 +437,16 @@ export declare function projectBotListItem(input: {
213
437
  readonly lastMessage?: BotListMessage | null;
214
438
  readonly sessions?: readonly BotListSession[];
215
439
  readonly approvals?: readonly BotListApproval[];
440
+ readonly attention?: readonly {
441
+ readonly id: string;
442
+ }[];
216
443
  readonly readCursor?: string | null;
217
444
  }): BotListItem;
218
445
  export declare function sortBotList(items: readonly BotListItem[]): BotListItem[];
219
446
  export declare function filterBotList(items: readonly BotListItem[], filter?: BotListFilter): BotListItem[];
447
+ export declare function normalizeBotCapabilityPolicy(policy: BotCapabilityPolicy | null | undefined): BotCapabilityPolicy | null;
448
+ export declare function hasBotCapabilityOverrides(policy: BotCapabilityPolicy | null | undefined): boolean;
449
+ export declare function resolveBotSkillEnabled(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean): boolean;
450
+ export declare function resolveBotMcpEnabled(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean): boolean;
451
+ export declare function toggleBotSkillOverride(policy: BotCapabilityPolicy | null | undefined, skillId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
452
+ export declare function toggleBotMcpOverride(policy: BotCapabilityPolicy | null | undefined, mcpId: string, defaultEnabled: boolean, nextEnabled: boolean): BotCapabilityPolicy | null;
package/dist/project.js CHANGED
@@ -2,6 +2,35 @@
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
+ export function isGlobalBotProfile(profile) {
25
+ return profile?.kind === 'global';
26
+ }
27
+ export const BOT_CONTEXT_BOUNDARY_KIND = 'context_boundary';
28
+ /** Display contract version for persisted agent_turn records (ADR87 D4).
29
+ * Version 2: public text carries role, the canonical agent_reply is the only
30
+ * answer body, and the implicit pure-text fallback reply is closed. Absent
31
+ * version means a legacy record and must keep legacy presentation.
32
+ */
33
+ export const AGENT_TURN_DISPLAY_CONTRACT = 2;
5
34
  export const BOT_AVATAR_SHAPES = [
6
35
  'circle',
7
36
  'square',
@@ -22,7 +51,14 @@ export const BOT_AVATAR_COLORS = [
22
51
  '#55bac7',
23
52
  '#a8a59f',
24
53
  ];
25
- const NEEDS_YOU_STATUSES = new Set(['waiting_user', 'result_ready']);
54
+ // Profiles saved before variant was persisted used this order when rotating coats.
55
+ const LEGACY_ROTATION_ORDER = [
56
+ 'circle', 'square', 'pill', 'arch', 'hex', 'diamond', 'triangle', 'star',
57
+ ];
58
+ export function resolveLegacyBotAvatarShape(shape, variant) {
59
+ const index = LEGACY_ROTATION_ORDER.findIndex(item => item === shape);
60
+ return LEGACY_ROTATION_ORDER[(Math.max(0, index) + variant) % LEGACY_ROTATION_ORDER.length] ?? 'circle';
61
+ }
26
62
  const RUNNING_STATUSES = new Set(['starting', 'running', 'verifying']);
27
63
  function fnv1a(text) {
28
64
  let hash = 0x811c9dc5;
@@ -51,9 +87,7 @@ function latestIso(values) {
51
87
  }
52
88
  export function projectBotListItem(input) {
53
89
  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;
90
+ const attention = new Set((input.attention ?? []).map(item => item.id));
57
91
  const running = sessions.filter((item) => RUNNING_STATUSES.has(item.status)).length;
58
92
  const lastMessage = input.lastMessage ?? null;
59
93
  const unread = lastMessage
@@ -72,7 +106,7 @@ export function projectBotListItem(input) {
72
106
  ...sessions.map((item) => item.updatedAt),
73
107
  ]),
74
108
  state: {
75
- needsYou: openApprovals + waitingSessions,
109
+ needsYou: attention.size,
76
110
  unread,
77
111
  running,
78
112
  },
@@ -104,3 +138,98 @@ export function filterBotList(items, filter = {}) {
104
138
  return haystack.includes(query);
105
139
  });
106
140
  }
141
+ function dedupCapabilityIds(ids) {
142
+ if (!Array.isArray(ids))
143
+ return [];
144
+ const out = [];
145
+ const seen = new Set();
146
+ for (const raw of ids) {
147
+ if (typeof raw !== 'string')
148
+ continue;
149
+ const trimmed = raw.trim();
150
+ if (!trimmed || seen.has(trimmed))
151
+ continue;
152
+ seen.add(trimmed);
153
+ out.push(trimmed);
154
+ }
155
+ return out;
156
+ }
157
+ export function normalizeBotCapabilityPolicy(policy) {
158
+ if (!policy || typeof policy !== 'object')
159
+ return null;
160
+ const disabledSkillIds = dedupCapabilityIds(policy.disabledSkillIds);
161
+ const disabledSkillSet = new Set(disabledSkillIds);
162
+ const enabledSkillIds = dedupCapabilityIds(policy.enabledSkillIds).filter((id) => !disabledSkillSet.has(id));
163
+ const disabledMcpIds = dedupCapabilityIds(policy.disabledMcpIds);
164
+ const disabledMcpSet = new Set(disabledMcpIds);
165
+ const enabledMcpIds = dedupCapabilityIds(policy.enabledMcpIds).filter((id) => !disabledMcpSet.has(id));
166
+ if (enabledSkillIds.length === 0
167
+ && disabledSkillIds.length === 0
168
+ && enabledMcpIds.length === 0
169
+ && disabledMcpIds.length === 0) {
170
+ return null;
171
+ }
172
+ return {
173
+ ...(enabledSkillIds.length > 0 ? { enabledSkillIds } : {}),
174
+ ...(disabledSkillIds.length > 0 ? { disabledSkillIds } : {}),
175
+ ...(enabledMcpIds.length > 0 ? { enabledMcpIds } : {}),
176
+ ...(disabledMcpIds.length > 0 ? { disabledMcpIds } : {}),
177
+ };
178
+ }
179
+ export function hasBotCapabilityOverrides(policy) {
180
+ return normalizeBotCapabilityPolicy(policy) !== null;
181
+ }
182
+ export function resolveBotSkillEnabled(policy, skillId, defaultEnabled) {
183
+ if (!policy)
184
+ return defaultEnabled;
185
+ if (policy.disabledSkillIds?.includes(skillId))
186
+ return false;
187
+ if (policy.enabledSkillIds?.includes(skillId))
188
+ return true;
189
+ return defaultEnabled;
190
+ }
191
+ export function resolveBotMcpEnabled(policy, mcpId, defaultEnabled) {
192
+ if (!policy)
193
+ return defaultEnabled;
194
+ if (policy.disabledMcpIds?.includes(mcpId))
195
+ return false;
196
+ if (policy.enabledMcpIds?.includes(mcpId))
197
+ return true;
198
+ return defaultEnabled;
199
+ }
200
+ export function toggleBotSkillOverride(policy, skillId, defaultEnabled, nextEnabled) {
201
+ const id = skillId.trim();
202
+ if (!id)
203
+ return normalizeBotCapabilityPolicy(policy);
204
+ const enabledSkillIds = dedupCapabilityIds(policy?.enabledSkillIds).filter((item) => item !== id);
205
+ const disabledSkillIds = dedupCapabilityIds(policy?.disabledSkillIds).filter((item) => item !== id);
206
+ if (nextEnabled !== defaultEnabled) {
207
+ if (nextEnabled)
208
+ enabledSkillIds.push(id);
209
+ else
210
+ disabledSkillIds.push(id);
211
+ }
212
+ return normalizeBotCapabilityPolicy({
213
+ ...policy,
214
+ enabledSkillIds,
215
+ disabledSkillIds,
216
+ });
217
+ }
218
+ export function toggleBotMcpOverride(policy, mcpId, defaultEnabled, nextEnabled) {
219
+ const id = mcpId.trim();
220
+ if (!id)
221
+ return normalizeBotCapabilityPolicy(policy);
222
+ const enabledMcpIds = dedupCapabilityIds(policy?.enabledMcpIds).filter((item) => item !== id);
223
+ const disabledMcpIds = dedupCapabilityIds(policy?.disabledMcpIds).filter((item) => item !== id);
224
+ if (nextEnabled !== defaultEnabled) {
225
+ if (nextEnabled)
226
+ enabledMcpIds.push(id);
227
+ else
228
+ disabledMcpIds.push(id);
229
+ }
230
+ return normalizeBotCapabilityPolicy({
231
+ ...policy,
232
+ enabledMcpIds,
233
+ disabledMcpIds,
234
+ });
235
+ }
@@ -0,0 +1,31 @@
1
+ export type PromptSkillScope = {
2
+ readonly scope: 'global';
3
+ } | {
4
+ readonly scope: 'workspace';
5
+ readonly workspaceId: string;
6
+ };
7
+ export interface SavePromptSkill {
8
+ readonly destination: PromptSkillScope;
9
+ readonly operationId: string;
10
+ readonly name: string;
11
+ readonly description: string;
12
+ readonly prompt: string;
13
+ readonly source: {
14
+ readonly messageId: string;
15
+ } & ({
16
+ readonly conversationId: string;
17
+ readonly groupChatId?: never;
18
+ } | {
19
+ readonly conversationId?: never;
20
+ readonly groupChatId: string;
21
+ });
22
+ }
23
+ export type SavePromptSkillResult = {
24
+ readonly ok: true;
25
+ readonly skillId: string;
26
+ readonly destination: PromptSkillScope;
27
+ } | {
28
+ readonly ok: false;
29
+ readonly code: 'INVALID_SKILL' | 'INVALID_SKILL_SOURCE' | 'SKILL_SECRET_REJECTED' | 'NOT_FOUND' | 'SKILL_ALREADY_EXISTS' | 'OPERATION_ID_CONFLICT';
30
+ readonly field?: string;
31
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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 {};