@peer-agent/protocol 0.1.0-rc.49 → 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.
@@ -6,6 +6,19 @@ export interface BotConversationReadAvailability {
6
6
  readonly sourceVersion?: string;
7
7
  readonly code?: string;
8
8
  }
9
+ /** A continuation is valid only with the original version of the latest window. */
10
+ export interface BotConversationWindowCondition {
11
+ readonly sourceVersion?: string;
12
+ readonly deltaCursor?: string;
13
+ }
14
+ /** Wire metadata for the Rust interaction window. No status denotes a regular window. */
15
+ export interface BotConversationWindowVersion {
16
+ readonly status?: 'unchanged' | 'delta' | 'refresh';
17
+ readonly sourceVersion?: string;
18
+ readonly baseSourceVersion?: string;
19
+ readonly hasMore?: boolean;
20
+ readonly availability?: 'rebuilding' | 'version_changed' | 'damaged';
21
+ }
9
22
  /** Small durable accounting event; full results and provider checkpoints remain referenced. */
10
23
  export interface CoordinationUsageObservation {
11
24
  readonly kind: 'usage_observed';
@@ -0,0 +1,11 @@
1
+ export type BotDirectAction = 'read_file' | 'write_file' | 'edit_file' | 'list_files' | 'search_files' | 'read_result' | 'query_git' | 'run_command' | 'stop_command' | 'web_fetch' | 'web_search' | 'read_skill' | 'run_tool';
2
+ /** Compact display facts for a settled tool call on a Bot reply. */
3
+ export interface BotDirectStep {
4
+ readonly toolCallId: string;
5
+ readonly tool: string;
6
+ readonly action: BotDirectAction;
7
+ readonly status: 'succeeded' | 'failed' | 'skipped';
8
+ readonly target?: string;
9
+ readonly durationMs?: number;
10
+ readonly resultSummary?: string;
11
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/bot-git.d.ts CHANGED
@@ -20,6 +20,9 @@ export interface BotGitRepository {
20
20
  export interface BotGitWorkspaceRequest {
21
21
  readonly workspaceId: string;
22
22
  }
23
+ export interface BotGitOverviewRequest extends BotGitWorkspaceRequest {
24
+ readonly refresh?: true;
25
+ }
23
26
  export interface BotGitRepositoryRequest extends BotGitWorkspaceRequest {
24
27
  readonly repoKey: string;
25
28
  }
@@ -23,6 +23,14 @@ export interface ConversationExecution {
23
23
  readonly phase: 'prepared' | 'dispatching' | 'outcome_unknown';
24
24
  readonly declaredScopes: readonly unknown[];
25
25
  readonly nativeProcess?: unknown;
26
+ readonly admission?: {
27
+ readonly workspaceId: string;
28
+ readonly botConversationId: string;
29
+ readonly hostEpoch: string;
30
+ readonly policyRevision: string;
31
+ readonly projectionId: string;
32
+ readonly credentialRevision: string;
33
+ };
26
34
  }[];
27
35
  readonly handles: readonly {
28
36
  readonly handleId: string;
@@ -142,7 +142,8 @@ export function normalizeConversationExecution(raw) {
142
142
  || Object.entries(at).some(([k, v]) => v !== null && (k === 'estimatedCostUsd'
143
143
  ? typeof v !== 'number' || !Number.isFinite(v) || v < 0 : !text(v, 200)))
144
144
  || Object.hasOwn(at, 'streamId') && at.streamId !== raw.identity.streamId
145
- || at.role != null && at.role !== 'chat')
145
+ || at.role != null && at.role !== 'chat' && !(raw.engine === 'peer-native'
146
+ && (at.role === 'project_agent' || at.role === 'matter_thread') && typeof at.workspaceId === 'string'))
146
147
  return invalid();
147
148
  if (raw.usage !== null) {
148
149
  const u = raw.usage;
@@ -166,12 +167,20 @@ export function normalizeConversationExecution(raw) {
166
167
  return invalid();
167
168
  const seen = [new Set(), new Set(), new Set()];
168
169
  for (const p of raw.pendingTools) {
169
- if (!object(p) || !keys(p, ['toolCallId', 'dispatchId', 'messageId', 'capabilityId', 'argsDigest', 'phase', 'declaredScopes', 'nativeProcess'])
170
+ if (!object(p) || !keys(p, ['toolCallId', 'dispatchId', 'messageId', 'capabilityId', 'argsDigest', 'phase', 'declaredScopes', 'nativeProcess', 'admission'])
170
171
  || !['toolCallId', 'dispatchId', 'messageId', 'capabilityId'].every(k => text(p[k], 200))
171
172
  || typeof p.argsDigest !== 'string' || !/^[a-f0-9]{64}$/.test(p.argsDigest)
172
173
  || !['prepared', 'dispatching', 'outcome_unknown'].some(v => v === p.phase) || !Array.isArray(p.declaredScopes)
173
174
  || p.declaredScopes.length > 32 || p.declaredScopes.some(s => !normalizeExecutionResourceScope(s)))
174
175
  return invalid();
176
+ if (p.admission !== undefined) {
177
+ const a = p.admission;
178
+ const fields = ['workspaceId', 'botConversationId', 'hostEpoch', 'policyRevision', 'projectionId', 'credentialRevision'];
179
+ if (!object(a) || !keys(a, fields) || !fields.every(k => text(a[k], 8192))
180
+ || a.hostEpoch !== raw.owner.hostId
181
+ || (at.role === 'project_agent' || at.role === 'matter_thread') && a.workspaceId !== at.workspaceId)
182
+ return invalid();
183
+ }
175
184
  for (const [i, k] of ['toolCallId', 'dispatchId', 'messageId'].entries()) {
176
185
  const v = p[k];
177
186
  if (seen[i].has(v))
@@ -5,8 +5,8 @@
5
5
  import type { GoalDeliveryBinding } from './goal.ts';
6
6
  import type { ModelSelectionSnapshot } from './model-routing.ts';
7
7
  import { type ExecutionOwnership, type GoalPlanProjectionSnapshot, type TaskOverviewItem } from './task-overview.ts';
8
- export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'waiting_agent' | 'stopping' | 'awaiting_outcome' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
9
- export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "waiting_agent", "stopping", "awaiting_outcome", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
8
+ export type WorkSessionStatus = 'paused' | 'blocked' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'waiting_agent' | 'stopping' | 'awaiting_outcome' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
9
+ export declare const WORK_SESSION_STATUSES: readonly ["paused", "blocked", "queued", "starting", "running", "waiting_user", "waiting_agent", "stopping", "awaiting_outcome", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
10
10
  export type InputSurface = 'desktop' | 'quick_chat' | 'tui' | 'remote';
11
11
  export interface DelegationOrigin {
12
12
  readonly capabilityAdmission?: import('./capability-admission.ts').DelegationCapabilityAdmission;
@@ -84,8 +84,32 @@ export interface SessionQueueFacts {
84
84
  }[];
85
85
  readonly queueReason?: 'dependencies' | 'dependency_missing' | 'dependency_failed' | 'read_slot' | 'write_slot' | 'disk_space' | 'isolation_failed' | 'resource_protection' | 'resource_recovery' | null;
86
86
  }
87
+ export interface WorkSessionIsolationDiagnostic {
88
+ readonly stage: string;
89
+ readonly reasonCode: string;
90
+ readonly repoInput?: string;
91
+ readonly dirtyNotice?: boolean;
92
+ readonly candidates?: readonly {
93
+ readonly repoKey: string;
94
+ }[];
95
+ }
87
96
  /** Persisted delivery facts displayed by the work session. Legacy records may have only a commit. */
88
- export type WorkSessionDeliveryBinding = Partial<Pick<GoalDeliveryBinding, 'targetBranch' | 'baseCommit' | 'taskBranch' | 'executionIsolation' | 'worktreePath' | 'targetWorkspacePath'>>;
97
+ declare const bindingTextFields: readonly ["baseCommit", "taskBranch", "worktreePath", "targetWorkspacePath", "repoKey", "repoCommonDir", "repoRoot", "baseRef", "baseSha", "executionRoot", "expectedTargetTip"];
98
+ export type WorkSessionDeliveryBinding = Partial<Pick<GoalDeliveryBinding, 'executionIsolation'>> & Partial<Record<typeof bindingTextFields[number], string>> & {
99
+ readonly targetBranch?: string | null;
100
+ readonly requestedIsolation?: 'auto' | 'none' | 'worktree';
101
+ readonly effectiveIsolation?: 'none' | 'worktree';
102
+ readonly mainTreeDirty?: boolean | null;
103
+ readonly isolationDiagnostic?: WorkSessionIsolationDiagnostic;
104
+ readonly worktreeCleanup?: {
105
+ readonly status: 'cleaned' | 'reconciling';
106
+ readonly reason?: string;
107
+ };
108
+ readonly deliveryHandoff?: {
109
+ readonly status: 'delivered' | 'nothing_to_merge' | 'stopped' | 'reconciling';
110
+ readonly reason?: string;
111
+ };
112
+ };
89
113
  export declare function projectWorkSessionDeliveryBinding(value: unknown): WorkSessionDeliveryBinding | undefined;
90
114
  export interface WorkSessionConversationMeta extends SessionQueueFacts {
91
115
  readonly deliveryBinding?: WorkSessionDeliveryBinding;
@@ -523,3 +547,4 @@ export declare function decideAcceptance(input: {
523
547
  readonly accept: boolean;
524
548
  } | null;
525
549
  }): AcceptanceDecision;
550
+ export {};
@@ -4,22 +4,57 @@
4
4
  */
5
5
  import { controlPhasesForOrigin } from "./session-control.js";
6
6
  import { decideLifecycle, } from "./task-overview.js";
7
- export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'waiting_agent', 'stopping', 'awaiting_outcome', 'verifying',
7
+ export const WORK_SESSION_STATUSES = ['paused', 'blocked', 'queued', 'starting', 'running', 'waiting_user', 'waiting_agent', 'stopping', 'awaiting_outcome', 'verifying',
8
8
  'result_ready', 'accepted', 'failed', 'cancelled', 'superseded'];
9
+ /** Persisted delivery facts displayed by the work session. Legacy records may have only a commit. */
10
+ const bindingTextFields = ['baseCommit', 'taskBranch', 'worktreePath', 'targetWorkspacePath',
11
+ 'repoKey', 'repoCommonDir', 'repoRoot', 'baseRef', 'baseSha', 'executionRoot', 'expectedTargetTip'];
12
+ function projectWorktreeReceipt(value, allowed) {
13
+ if (!value || typeof value !== 'object' || Array.isArray(value))
14
+ return undefined;
15
+ const { status, reason } = value;
16
+ const match = allowed.find(candidate => candidate === status);
17
+ if (match)
18
+ return { status: match, ...(typeof reason === 'string' && reason ? { reason } : {}) };
19
+ }
9
20
  export function projectWorkSessionDeliveryBinding(value) {
10
21
  if (!value || typeof value !== 'object' || Array.isArray(value))
11
22
  return undefined;
12
23
  const raw = value;
13
24
  const facts = {};
14
- for (const key of ['targetBranch', 'baseCommit', 'taskBranch', 'worktreePath', 'targetWorkspacePath']) {
25
+ for (const key of bindingTextFields) {
15
26
  const field = raw[key];
16
27
  if (typeof field === 'string' && field.trim())
17
28
  facts[key] = field;
18
29
  }
19
- const isolation = raw.executionIsolation;
20
- if (isolation === 'worktree' || isolation === 'none')
21
- facts.executionIsolation = isolation;
22
- return Object.keys(facts).length ? facts : undefined;
30
+ const { executionIsolation, effectiveIsolation, requestedIsolation, targetBranch, mainTreeDirty } = raw;
31
+ const diagnostic = raw.isolationDiagnostic;
32
+ let isolationDiagnostic;
33
+ if (diagnostic && typeof diagnostic === 'object' && !Array.isArray(diagnostic)) {
34
+ const { stage, reasonCode, repoInput, dirtyNotice, candidates } = diagnostic;
35
+ if (typeof stage === 'string' && typeof reasonCode === 'string') {
36
+ isolationDiagnostic = {
37
+ stage, reasonCode,
38
+ ...(typeof repoInput === 'string' ? { repoInput } : {}),
39
+ ...(typeof dirtyNotice === 'boolean' ? { dirtyNotice } : {}),
40
+ ...(Array.isArray(candidates) ? { candidates: candidates.flatMap(item => item && typeof item.repoKey === 'string' ? [{ repoKey: item.repoKey }] : []) } : {}),
41
+ };
42
+ }
43
+ }
44
+ const worktreeCleanup = projectWorktreeReceipt(raw.worktreeCleanup, ['cleaned', 'reconciling']);
45
+ const deliveryHandoff = projectWorktreeReceipt(raw.deliveryHandoff, ['delivered', 'nothing_to_merge', 'stopped', 'reconciling']);
46
+ const projected = {
47
+ ...facts,
48
+ ...((typeof targetBranch === 'string' && targetBranch.trim()) || (targetBranch === null && typeof requestedIsolation === 'string') ? { targetBranch } : {}),
49
+ ...(executionIsolation === 'worktree' || executionIsolation === 'none' ? { executionIsolation } : {}),
50
+ ...(effectiveIsolation === 'worktree' || effectiveIsolation === 'none' ? { effectiveIsolation } : {}),
51
+ ...(requestedIsolation === 'auto' || requestedIsolation === 'worktree' || requestedIsolation === 'none' ? { requestedIsolation } : {}),
52
+ ...(typeof mainTreeDirty === 'boolean' || mainTreeDirty === null ? { mainTreeDirty } : {}),
53
+ ...(isolationDiagnostic ? { isolationDiagnostic } : {}),
54
+ ...(worktreeCleanup ? { worktreeCleanup } : {}),
55
+ ...(deliveryHandoff ? { deliveryHandoff } : {}),
56
+ };
57
+ return Object.keys(projected).length ? projected : undefined;
23
58
  }
24
59
  function fnv1a(text) {
25
60
  let hash = 0x811c9dc5;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { BotDirectAction, BotDirectStep } from './bot-direct-step.ts';
1
2
  export { WORK_HOOK_SEMANTIC_FLOOR, nativeWorkHasHookFacts } from './work-hook.ts';
2
3
  export type { AttentionCard, BotDecisionSnapshot, BotAttentionItem, BotAttentionRequest, BotAttentionResult } from './attention.ts';
3
4
  export type { ProjectWorkBudgetLimits, NativeEpisodeRecorder, ProjectWorkBudgetBoundary, ProjectReplyRecoveryAction, ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd, ProjectReplyFailureStatus, ProjectAgentSilentWait, } from './work-coordination.ts';
@@ -756,6 +757,12 @@ export interface ClientToolCallPollResult {
756
757
  readonly idleUntil?: string;
757
758
  }
758
759
  export type PermissionDuration = 'once' | 'task' | 'session' | 'scope' | 'persistent' | 'denied';
760
+ export interface LocalWritePermissionScope {
761
+ readonly kind: 'local_write';
762
+ readonly executionRoot: string;
763
+ readonly temporaryRoot: string;
764
+ readonly enforcement: 'provider_path_checks' | 'approval_required_no_os_sandbox';
765
+ }
759
766
  export interface PermissionGrant {
760
767
  /** Host-issued policy version; audit provenance, never a client authority token. */
761
768
  readonly policyRevision?: string;
@@ -763,7 +770,7 @@ export interface PermissionGrant {
763
770
  readonly toolCallId: string;
764
771
  readonly granted: boolean;
765
772
  readonly duration: PermissionDuration;
766
- readonly scope?: string | import('./local-image.ts').LocalImagePermissionScope | import('./local-read.ts').LocalReadPermissionScope;
773
+ readonly scope?: string | import('./local-image.ts').LocalImagePermissionScope | import('./local-read.ts').LocalReadPermissionScope | LocalWritePermissionScope;
767
774
  readonly decidedAt: string;
768
775
  }
769
776
  /** Application-owned shell process snapshot. Source conversation is provenance, not ownership. */
@@ -855,6 +862,8 @@ export interface Evidence {
855
862
  readonly artifactRefs: readonly string[];
856
863
  /** Host/Provider observation before tools/call; never read from server output. */
857
864
  readonly dispatchOutcome?: 'not_dispatched';
865
+ /** Durable native recovery proof for an unstarted dispatch of a logical call. */
866
+ readonly retiredDispatchId?: string;
858
867
  }
859
868
  /** Native MCP attempt metadata, including denials and failed initialization. */
860
869
  export interface NativeMcpToolEvidenceMetadata {
@@ -83,6 +83,8 @@ export type MatterRun = {
83
83
  hostStatus?: string;
84
84
  executionMode?: string;
85
85
  git?: MatterGit | null;
86
+ deliveryBinding?: import('./delegation.ts').WorkSessionDeliveryBinding;
87
+ liveIsolationLost?: boolean;
86
88
  briefRevision?: number | null;
87
89
  };
88
90
  export type MatterActivity = {
package/dist/project.d.ts CHANGED
@@ -138,7 +138,7 @@ export type ProjectHostTakeoverResult = {
138
138
  };
139
139
  export declare const BOT_AVATAR_HEADS: readonly ["none", "beret", "glasses", "beanie", "vermeer", "straw", "headphones", "crown"];
140
140
  export type BotAvatarHead = (typeof BOT_AVATAR_HEADS)[number];
141
- export declare const BOT_AVATAR_NECKS: readonly ["bowtie", "scarf", "sweater", "moon", "sailor", "cape"];
141
+ export declare const BOT_AVATAR_NECKS: readonly ["none", "bowtie", "scarf", "sweater", "moon", "sailor", "cape"];
142
142
  export type BotAvatarNeck = (typeof BOT_AVATAR_NECKS)[number];
143
143
  export interface BotAvatarPartsPatch {
144
144
  readonly shape?: string;
@@ -331,6 +331,7 @@ export interface BotListMessage {
331
331
  }
332
332
  export declare const BOT_AVATAR_SHAPES: readonly ["circle", "square", "triangle", "diamond", "hex", "pill", "star", "arch"];
333
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";
334
335
  export declare function generateAvatar(workspaceId: string): Extract<BotAvatar, {
335
336
  kind: 'generated';
336
337
  }>;
package/dist/project.js CHANGED
@@ -13,6 +13,7 @@ export const BOT_AVATAR_HEADS = [
13
13
  'crown',
14
14
  ];
15
15
  export const BOT_AVATAR_NECKS = [
16
+ 'none',
16
17
  'bowtie',
17
18
  'scarf',
18
19
  'sweater',
@@ -46,6 +47,14 @@ export const BOT_AVATAR_COLORS = [
46
47
  '#55bac7',
47
48
  '#a8a59f',
48
49
  ];
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
+ }
49
58
  const RUNNING_STATUSES = new Set(['starting', 'running', 'verifying']);
50
59
  function fnv1a(text) {
51
60
  let hash = 0x811c9dc5;
@@ -1,11 +1,14 @@
1
1
  /** Host-issued control and resource facts. None of these receipts grants tool permission. */
2
- /** Dispatch-declared protection scopes (ADR 127). Only 'directory' is produced today; the narrower kinds arrive with claim scope convergence. */
2
+ /** Dispatch-declared protection scopes (ADR 127 and ADR 145). */
3
3
  export type ExecutionResourceScope = {
4
4
  readonly kind: 'directory';
5
5
  readonly path: string;
6
6
  } | {
7
7
  readonly kind: 'file';
8
8
  readonly path: string;
9
+ } | {
10
+ readonly kind: 'git_common_dir';
11
+ readonly path: string;
9
12
  } | {
10
13
  readonly kind: 'git_ref';
11
14
  readonly ref: string;
@@ -4,7 +4,7 @@ export function normalizeExecutionResourceScope(raw) {
4
4
  const value = raw;
5
5
  if (Object.keys(value).length !== 2)
6
6
  return;
7
- if ((value.kind === 'directory' || value.kind === 'file') && typeof value.path === 'string'
7
+ if ((value.kind === 'directory' || value.kind === 'file' || value.kind === 'git_common_dir') && typeof value.path === 'string'
8
8
  && value.path.length > 0 && value.path.length <= 2048 && !/[\u0000-\u001f]/.test(value.path))
9
9
  return { kind: value.kind, path: value.path };
10
10
  if ((value.kind === 'git_ref' || value.kind === 'remote_object') && typeof value.ref === 'string'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/protocol",
3
- "version": "0.1.0-rc.49",
3
+ "version": "0.1.0-rc.50",
4
4
  "description": "Shared host-neutral protocol contracts for Peer Agent runtimes and clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",