@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
@@ -0,0 +1,222 @@
1
+ /** Ordinary execution facts in the original Conversation index. Shape is never
2
+ * permission, process-death proof, or authority to replay a pending dispatch. */
3
+ import { normalizeExecutionResourceScope } from "./session-control.js";
4
+ import { isHookObservation } from "./hook-observation.js";
5
+ import { nativeProcessEnvelopeValid } from "./native-process.js";
6
+ const object = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
7
+ const keys = (v, allowed) => Object.keys(v).every(k => allowed.includes(k));
8
+ const text = (v, max) => typeof v === 'string' && v.trim().length > 0
9
+ && new TextEncoder().encode(v).length <= max && !/[\u0000-\u001f\u007f-\u009f]/u.test(v);
10
+ const recorderKeys = ['bootId', 'pid', 'pidStart', 'hostId', 'acquiredAt'];
11
+ const recorder = (v) => object(v) && Object.keys(v).length === 5 && keys(v, recorderKeys)
12
+ && Number.isInteger(v.pid) && v.pid > 0 && v.pid <= 2147483647
13
+ && recorderKeys.filter(k => k !== 'pid').every(k => typeof v[k] === 'string' && v[k].length > 0
14
+ && new TextEncoder().encode(v[k]).length <= 8192);
15
+ const sameRecorder = (a, b) => recorderKeys.every(k => a[k] === b[k]);
16
+ const safe = (v) => Number.isSafeInteger(v) && v >= 0;
17
+ const amountKeys = ['inputTokens', 'outputTokens', 'cacheReadTokens', 'cacheWriteTokens'];
18
+ const identity = (v) => object(v)
19
+ && Object.keys(v).length === 3 && keys(v, ['kind', 'conversationId', 'streamId']) && v.kind === 'conversation'
20
+ && typeof v.conversationId === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(v.conversationId) && text(v.streamId, 200);
21
+ function equalsRecord(a, b) {
22
+ if (!object(a) || !object(b))
23
+ return a === b;
24
+ const fields = Object.keys(a);
25
+ return fields.length === Object.keys(b).length && fields.every(k => Object.hasOwn(b, k) && equalsRecord(a[k], b[k]));
26
+ }
27
+ function validBackgroundShellHandle(h, metadata, run, runIdentity, owner, pending) {
28
+ const shell = metadata.nativeShell;
29
+ if (run.engine !== 'peer-native' || Object.keys(metadata).length !== 2 || !object(shell)
30
+ || Object.keys(shell).length !== 2 || shell.schemaVersion !== 1)
31
+ return false;
32
+ const process = shell.process;
33
+ if (!object(process) || !nativeProcessEnvelopeValid(process) || !recorder(process.owner) || !sameRecorder(process.owner, owner)
34
+ || !identity(process.execution) || !equalsRecord(process.execution, runIdentity)
35
+ || typeof process.handleId !== 'string' || !/^shell_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(process.handleId)
36
+ || !process.handleId.startsWith('shell_') || process.generation > 1
37
+ || process.child != null && (!recorder(process.child) || process.child.pid === owner.pid)
38
+ || h.handleId !== process.handleId || h.toolCallId !== process.toolCallId
39
+ || h.state !== (process.state === 'ended' ? 'ended' : 'active'))
40
+ return false;
41
+ return pending.some(call => {
42
+ if (!object(call) || !object(call.nativeProcess) || call.toolCallId !== process.toolCallId || call.dispatchId !== process.dispatchId
43
+ || call.capabilityId !== 'local.shell.exec' || call.phase === 'prepared')
44
+ return false;
45
+ const comparable = (value) => ({
46
+ ...value, child: value.child ?? null, stopObservation: value.stopObservation ?? null,
47
+ });
48
+ return equalsRecord(comparable(call.nativeProcess), comparable(process));
49
+ });
50
+ }
51
+ function validPersistentShellHandle(h, metadata, runIdentity, owner, pending) {
52
+ const session = metadata.nativeShellSession;
53
+ if (Object.keys(metadata).length !== 2 || !object(session)
54
+ || Object.keys(session).length !== 3 || !keys(session, ['schemaVersion', 'process', 'command'])
55
+ || session.schemaVersion !== 1 || !Object.hasOwn(session, 'command'))
56
+ return false;
57
+ const process = session.process;
58
+ if (!object(process) || !nativeProcessEnvelopeValid(process) || !recorder(process.owner)
59
+ || !sameRecorder(process.owner, owner) || !identity(process.execution) || !equalsRecord(process.execution, runIdentity)
60
+ || typeof process.handleId !== 'string' || !process.handleId.startsWith('shell-session_')
61
+ || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(process.handleId.slice('shell-session_'.length))
62
+ || process.generation > 1 || process.child != null && (!recorder(process.child) || process.child.pid === owner.pid)
63
+ || h.handleId !== process.handleId || h.toolCallId !== process.toolCallId
64
+ || h.state !== (process.state === 'ended' ? 'ended' : 'active'))
65
+ return false;
66
+ const bound = (callId, dispatchId) => pending.some(call => object(call) && call.toolCallId === callId && call.dispatchId === dispatchId
67
+ && call.capabilityId === 'local.shell.exec' && call.phase !== 'prepared' && call.nativeProcess == null);
68
+ if ((process.state === 'not_started' || process.state === 'starting')
69
+ && !bound(process.toolCallId, process.dispatchId))
70
+ return false;
71
+ const command = session.command;
72
+ return command === null || object(command) && Object.keys(command).length === 3
73
+ && keys(command, ['toolCallId', 'dispatchId', 'generation'])
74
+ && ['running', 'ended'].some(state => state === process.state) && process.child != null
75
+ && command.generation === process.generation && bound(command.toolCallId, command.dispatchId);
76
+ }
77
+ function validHookHandle(h, metadata, runIdentity, owner, pending) {
78
+ const hook = metadata.nativeHook;
79
+ if (Object.keys(metadata).length !== 2 || !object(hook)
80
+ || !keys(hook, ['schemaVersion', 'event', 'ruleDigest', 'process', 'observation'])
81
+ || hook.schemaVersion !== 1 || !['PreToolUse', 'PostToolUse'].some(v => v === hook.event)
82
+ || typeof hook.ruleDigest !== 'string' || !/^[a-f0-9]{64}$/.test(hook.ruleDigest))
83
+ return false;
84
+ const p = hook.process;
85
+ if (!object(p) || !nativeProcessEnvelopeValid(p) || !recorder(p.owner)
86
+ || !sameRecorder(p.owner, owner) || !identity(p.execution)
87
+ || p.execution.conversationId !== runIdentity.conversationId || p.execution.streamId !== runIdentity.streamId
88
+ || p.handleId !== h.handleId || p.toolCallId !== h.toolCallId
89
+ || h.state !== (p.state === 'ended' ? 'ended' : 'active')
90
+ || !safe(p.generation) || p.generation > 1 || p.child != null && !recorder(p.child)
91
+ || !pending.some(row => object(row) && row.toolCallId === p.toolCallId && row.dispatchId === p.dispatchId
92
+ && (hook.event === 'PreToolUse' || row.phase !== 'prepared')))
93
+ return false;
94
+ if (p.stopObservation !== 'owned_completion')
95
+ return !Object.hasOwn(hook, 'observation');
96
+ return isHookObservation(hook.observation, hook.event, hook.ruleDigest, p.handleId);
97
+ }
98
+ /** Strict decoding: unknown versions/fields are preserved by the caller and block
99
+ * execution. Return a clone so a parser consumer cannot change the stored fact. */
100
+ export function validConversationSpend(value) {
101
+ if (!Array.isArray(value) || value.length > 1000 || new TextEncoder().encode(JSON.stringify(value)).length > 128 * 1024)
102
+ return false;
103
+ const ids = new Set();
104
+ return value.every(row => {
105
+ if (!object(row) || !keys(row, ['id', 'at', 'groupId', 'model', 'modelVersion', 'rawPromptTokens', 'usage', 'estimatedCostUsd', 'pricingSource'])
106
+ || typeof row.id !== 'string' || !text(row.id, 64) || ids.has(row.id)
107
+ || !text(row.at, 64) || !text(row.groupId, 200) || !text(row.model, 512)
108
+ || row.modelVersion !== undefined && !text(row.modelVersion, 128)
109
+ || row.rawPromptTokens !== undefined && !safe(row.rawPromptTokens))
110
+ return false;
111
+ if (row.estimatedCostUsd === null) {
112
+ if (row.pricingSource !== undefined)
113
+ return false;
114
+ }
115
+ else if (typeof row.estimatedCostUsd !== 'string' || row.estimatedCostUsd.length > 64
116
+ || !/^\d+(?:\.\d+)?$/.test(row.estimatedCostUsd)
117
+ || !['manual', 'provider', 'gemini-official-reference', 'models.dev-reference'].some(s => s === row.pricingSource)
118
+ || row.usage === null)
119
+ return false;
120
+ const usage = row.usage;
121
+ if (usage !== null && (!object(usage) || !keys(usage, [...amountKeys, 'totalTokens'])
122
+ || !amountKeys.every(k => safe(usage[k])) || !safe(usage.totalTokens)
123
+ || amountKeys.reduce((sum, k) => sum + usage[k], 0) !== usage.totalTokens))
124
+ return false;
125
+ ids.add(row.id);
126
+ return true;
127
+ });
128
+ }
129
+ export function normalizeConversationExecution(raw) {
130
+ const invalid = () => { throw new Error('conversation_execution_invalid'); };
131
+ if (!object(raw) || !keys(raw, ['schemaVersion', 'identity', 'engine', 'owner', 'revision', 'phase', 'pendingTools',
132
+ 'handles', 'usage', 'unknownUsage', 'attribution', 'usageCommitted', 'stop', 'updatedAt'])
133
+ || raw.schemaVersion !== 1 || !identity(raw.identity) || !recorder(raw.owner)
134
+ || !['peer-native', 'peer-ts'].some(v => v === raw.engine) || !safe(raw.revision) || raw.revision < 1
135
+ || !['active', 'stopping', 'stopped', 'recovery_required'].some(v => v === raw.phase)
136
+ || !text(raw.updatedAt, 64) || typeof raw.unknownUsage !== 'boolean' || typeof raw.usageCommitted !== 'boolean'
137
+ || !Array.isArray(raw.pendingTools) || raw.pendingTools.length > 128 || !Array.isArray(raw.handles) || raw.handles.length > 128
138
+ || !Object.hasOwn(raw, 'usage') || !object(raw.attribution) || raw.attribution.id !== raw.identity.streamId)
139
+ return invalid();
140
+ const at = raw.attribution;
141
+ if (!keys(at, ['id', 'at', 'streamId', 'modelProviderId', 'groupId', 'model', 'providerName', 'role', 'workspaceId', 'estimatedCostUsd', 'pricingSource'])
142
+ || Object.entries(at).some(([k, v]) => v !== null && (k === 'estimatedCostUsd'
143
+ ? typeof v !== 'number' || !Number.isFinite(v) || v < 0 : !text(v, 200)))
144
+ || Object.hasOwn(at, 'streamId') && at.streamId !== raw.identity.streamId
145
+ || at.role != null && at.role !== 'chat' && !(raw.engine === 'peer-native'
146
+ && (at.role === 'project_agent' || at.role === 'matter_thread') && typeof at.workspaceId === 'string'))
147
+ return invalid();
148
+ if (raw.usage !== null) {
149
+ const u = raw.usage;
150
+ if (!object(u) || Object.keys(u).length !== 7 + Number(Object.hasOwn(u, 'requestBreakdown')) || !keys(u, ['usageScope', 'providerRequestCount', ...amountKeys, 'totalTokens', 'requestBreakdown'])
151
+ || u.requestBreakdown !== undefined && !validConversationSpend(u.requestBreakdown)
152
+ || u.usageScope !== 'runtime_turn' || !safe(u.providerRequestCount) || !safe(u.totalTokens)
153
+ || !amountKeys.every(k => safe(u[k])) || amountKeys.reduce((n, k) => n + u[k], 0) !== u.totalTokens
154
+ || u.totalTokens > 0 && u.providerRequestCount === 0)
155
+ return invalid();
156
+ }
157
+ if (raw.stop != null) {
158
+ const s = raw.stop;
159
+ if (!object(s) || !keys(s, ['owner', 'observedAt', 'runnerIdle', 'admissionClosed', 'handlesEnded']) || !recorder(s.owner)
160
+ || !sameRecorder(s.owner, raw.owner) || !text(s.observedAt, 64) || s.runnerIdle !== true || s.admissionClosed !== true
161
+ || s.handlesEnded !== true || ['active', 'stopping'].some(v => v === raw.phase))
162
+ return invalid();
163
+ }
164
+ else if (raw.phase === 'stopped')
165
+ return invalid();
166
+ if (raw.phase === 'stopped' && (raw.pendingTools.length !== 0 || !raw.usageCommitted))
167
+ return invalid();
168
+ const seen = [new Set(), new Set(), new Set()];
169
+ for (const p of raw.pendingTools) {
170
+ if (!object(p) || !keys(p, ['toolCallId', 'dispatchId', 'messageId', 'capabilityId', 'argsDigest', 'phase', 'declaredScopes', 'nativeProcess', 'admission'])
171
+ || !['toolCallId', 'dispatchId', 'messageId', 'capabilityId'].every(k => text(p[k], 200))
172
+ || typeof p.argsDigest !== 'string' || !/^[a-f0-9]{64}$/.test(p.argsDigest)
173
+ || !['prepared', 'dispatching', 'outcome_unknown'].some(v => v === p.phase) || !Array.isArray(p.declaredScopes)
174
+ || p.declaredScopes.length > 32 || p.declaredScopes.some(s => !normalizeExecutionResourceScope(s)))
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
+ }
184
+ for (const [i, k] of ['toolCallId', 'dispatchId', 'messageId'].entries()) {
185
+ const v = p[k];
186
+ if (seen[i].has(v))
187
+ return invalid();
188
+ seen[i].add(v);
189
+ }
190
+ if (p.nativeProcess != null) {
191
+ const n = p.nativeProcess;
192
+ if (p.phase === 'prepared' || !object(n) || !nativeProcessEnvelopeValid(n) || !recorder(n.owner)
193
+ || !sameRecorder(n.owner, raw.owner) || !identity(n.execution) || n.execution.conversationId !== raw.identity.conversationId
194
+ || n.execution.streamId !== raw.identity.streamId || n.toolCallId !== p.toolCallId || n.dispatchId !== p.dispatchId
195
+ || n.child != null && !recorder(n.child))
196
+ return invalid();
197
+ }
198
+ }
199
+ const handles = new Set();
200
+ let shellSessionSeen = false;
201
+ for (const h of raw.handles) {
202
+ if (!object(h) || Object.keys(h).length !== 4 || !keys(h, ['handleId', 'toolCallId', 'state', 'metadata'])
203
+ || !text(h.handleId, 512) || handles.has(h.handleId) || !text(h.toolCallId, 200) || !object(h.metadata)
204
+ || !['active', 'ended'].some(v => v === h.state) || raw.phase === 'stopped' && h.state !== 'ended')
205
+ return invalid();
206
+ if (h.metadata.kind === 'hook' && !validHookHandle(h, h.metadata, raw.identity, raw.owner, raw.pendingTools))
207
+ return invalid();
208
+ if (h.metadata.kind === 'shell_background' && !validBackgroundShellHandle(h, h.metadata, raw, raw.identity, raw.owner, raw.pendingTools))
209
+ return invalid();
210
+ if (h.metadata.kind === 'shell_session') {
211
+ if (shellSessionSeen || !validPersistentShellHandle(h, h.metadata, raw.identity, raw.owner, raw.pendingTools))
212
+ return invalid();
213
+ shellSessionSeen = true;
214
+ }
215
+ handles.add(h.handleId);
216
+ }
217
+ return structuredClone(raw);
218
+ }
219
+ export function conversationExecutionPermitsNewRun(raw) {
220
+ const r = normalizeConversationExecution(raw);
221
+ return r.phase === 'stopped' && r.pendingTools.length === 0 && r.usageCommitted;
222
+ }
@@ -0,0 +1,81 @@
1
+ /** Coordination authority is issued by the local host, never by model arguments. */
2
+ export type { ReplyDeliveryReceipt, IntentReplyBinding, ReplyGoalScope } from './reply-delivery.ts';
3
+ export type { InputDispositionKind, InputDisposition, IntentRequirement, IntentInterpretation, GoalCoverageItem, WorkDisposition, IntentAssessment, IntentCoordination, IntentClosureRequest, IntentDecisionReceipt, IntentCoordinationRequest, CoordinationDecisionFrame, ProgressObservation } from './intent-coordination.ts';
4
+ export type CoordinationAction = 'parallel' | 'augment' | 'revise' | 'query' | 'answer' | 'cancel' | 'replace' | 'handoff' | 'resume';
5
+ export type CoordinationLifecycle = 'active' | 'paused' | 'cancelled' | 'fulfilled';
6
+ export interface CoordinationMandate {
7
+ schemaVersion: 1;
8
+ intentSchemaVersion?: 1;
9
+ mandateId: string;
10
+ workId: string;
11
+ workspaceId: string;
12
+ parentConversationId: string;
13
+ rootInputIds: string[];
14
+ revisionInputIds: string[];
15
+ goalRevision: number;
16
+ allowedActions: CoordinationAction[];
17
+ sessionIds: string[];
18
+ revokedSessionIds?: string[];
19
+ executionBindings?: Record<string, CoordinationExecutionBinding>;
20
+ materialRefs: string[];
21
+ policyRevision: string;
22
+ lifecycle: CoordinationLifecycle;
23
+ }
24
+ /** Semantic routing is the model's decision; identity, authority and versions are host facts. */
25
+ export interface CoordinationDecision {
26
+ operationId: string;
27
+ workId: string;
28
+ expectedRevision: number;
29
+ action: CoordinationAction;
30
+ sourceInputIds: string[];
31
+ sourceDecisionRef?: string;
32
+ sourceEventIds: string[];
33
+ sessionId?: string;
34
+ reason: string;
35
+ }
36
+ export type TaskTransitionPhase = 'recorded' | 'stopping' | 'awaiting_outcome' | 'ready' | 'started' | 'completed' | 'blocked';
37
+ export interface TaskTransition {
38
+ diagnostic?: import('./capability-admission.ts').CapabilityBlocker;
39
+ schemaVersion: 1;
40
+ operationId: string;
41
+ workId: string;
42
+ mandateId: string;
43
+ expectedGoalRevision: number;
44
+ sourceInputIds: string[];
45
+ sourceEventIds: string[];
46
+ initiator: 'project_agent';
47
+ decisionSource: 'user_revision' | 'execution_repair';
48
+ action: CoordinationAction;
49
+ reason: string;
50
+ oldSessionId?: string;
51
+ replacementSessionId?: string;
52
+ executionEpoch: string;
53
+ phase: TaskTransitionPhase;
54
+ minimumExecutorVersion: 1 | 2 | 3;
55
+ executionAdmission?: 'queued' | 'admitted' | 'rejected';
56
+ executionEffect?: 'pending' | 'applied' | 'unknown' | 'rejected';
57
+ executionAttemptRef?: string;
58
+ reconciliationRef?: string;
59
+ controlOperationRef?: string;
60
+ updatedAt: string;
61
+ }
62
+ export interface CoordinationExecutionBinding {
63
+ sessionId?: string;
64
+ workId: string;
65
+ goalRevision: number;
66
+ executionEpoch: string;
67
+ }
68
+ /** Factual view of a durable operation; completed means disposition applied, not task success. */
69
+ export interface CoordinationSessionFacts {
70
+ readonly executionAdmission?: TaskTransition['executionAdmission'];
71
+ readonly executionEffect?: TaskTransition['executionEffect'];
72
+ readonly executionAttemptRef?: string;
73
+ readonly operationId: string;
74
+ readonly action: CoordinationAction;
75
+ readonly phase: TaskTransitionPhase;
76
+ readonly reason: string;
77
+ readonly goalRevision: number;
78
+ readonly priorSessionId?: string;
79
+ readonly replacementSessionId?: string;
80
+ readonly replacementTitle?: string;
81
+ }
@@ -0,0 +1 @@
1
+ export {};