@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.
- package/dist/acceptance-close-gate.d.ts +10 -1
- package/dist/acceptance-close-gate.js +12 -0
- package/dist/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/attention.d.ts +44 -0
- package/dist/attention.js +1 -0
- package/dist/bot-access-policy.d.ts +29 -0
- package/dist/bot-access-policy.js +1 -0
- package/dist/bot-conversation-read.d.ts +67 -0
- package/dist/bot-conversation-read.js +9 -0
- package/dist/bot-direct-step.d.ts +11 -0
- package/dist/bot-direct-step.js +1 -0
- package/dist/bot-git.d.ts +55 -0
- package/dist/bot-git.js +1 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/browser-window.d.ts +48 -0
- package/dist/browser-window.js +23 -0
- package/dist/capability-admission.d.ts +20 -0
- package/dist/capability-admission.js +1 -0
- package/dist/compaction-history-selection.d.ts +15 -0
- package/dist/compaction-history-selection.js +30 -0
- package/dist/compaction.d.ts +5 -0
- package/dist/compaction.js +6 -0
- package/dist/context-accounting.d.ts +3 -0
- package/dist/conversation-execution.d.ts +68 -0
- package/dist/conversation-execution.js +222 -0
- package/dist/delegation-coordination.d.ts +81 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +260 -7
- package/dist/delegation.js +97 -39
- package/dist/document-reference.d.ts +111 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +84 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/goal.d.ts +50 -2
- package/dist/group-chat.d.ts +87 -0
- package/dist/group-chat.js +1 -0
- package/dist/hook-observation.d.ts +2 -0
- package/dist/hook-observation.js +19 -0
- package/dist/index.d.ts +117 -25
- package/dist/index.js +41 -0
- package/dist/input-prediction.d.ts +86 -0
- package/dist/input-prediction.js +48 -0
- package/dist/intent-coordination.d.ts +201 -0
- package/dist/intent-coordination.js +1 -0
- package/dist/interactive-result.d.ts +363 -0
- package/dist/interactive-result.js +215 -0
- package/dist/interactive-verification.d.ts +41 -0
- package/dist/interactive-verification.js +65 -0
- package/dist/local-git.d.ts +44 -0
- package/dist/local-git.js +3 -0
- package/dist/local-image.d.ts +53 -0
- package/dist/local-image.js +5 -0
- package/dist/local-read.d.ts +9 -0
- package/dist/local-read.js +1 -0
- package/dist/memory.d.ts +117 -12
- package/dist/memory.js +12 -0
- package/dist/model-reasoning.d.ts +16 -0
- package/dist/model-reasoning.js +25 -0
- package/dist/model-routing.d.ts +39 -3
- package/dist/model-routing.js +31 -5
- package/dist/native-process.d.ts +21 -0
- package/dist/native-process.js +51 -0
- package/dist/parent-coordination.d.ts +104 -0
- package/dist/parent-coordination.js +2 -0
- package/dist/persistent-workspace.d.ts +519 -0
- package/dist/persistent-workspace.js +1 -0
- package/dist/project-agent-failure.d.ts +30 -0
- package/dist/project-agent-failure.js +44 -0
- package/dist/project-input-recovery.d.ts +83 -0
- package/dist/project-input-recovery.js +25 -0
- package/dist/project-matter.d.ts +359 -0
- package/dist/project-matter.js +1 -0
- package/dist/project-recovery.d.ts +43 -0
- package/dist/project-recovery.js +1 -0
- package/dist/project.d.ts +233 -0
- package/dist/project.js +134 -5
- package/dist/prompt-skill.d.ts +31 -0
- package/dist/prompt-skill.js +1 -0
- package/dist/quiet-reply.d.ts +9 -0
- package/dist/quiet-reply.js +43 -0
- package/dist/remote-access.d.ts +15 -0
- package/dist/remote-access.js +1 -1
- package/dist/reply-delivery.d.ts +28 -0
- package/dist/reply-delivery.js +1 -0
- package/dist/resource-edit-execution.d.ts +68 -0
- package/dist/resource-edit-execution.js +96 -0
- package/dist/resource-edit.d.ts +237 -0
- package/dist/resource-edit.js +134 -0
- package/dist/resource-feedback-transport.d.ts +26 -0
- package/dist/resource-feedback-transport.js +94 -0
- package/dist/resource-feedback.d.ts +110 -0
- package/dist/resource-feedback.js +168 -0
- package/dist/resource-file-replace.d.ts +36 -0
- package/dist/resource-file-replace.js +40 -0
- package/dist/resource-reference-hints.d.ts +3 -0
- package/dist/resource-reference-hints.js +58 -0
- package/dist/resource-window.d.ts +222 -0
- package/dist/resource-window.js +252 -0
- package/dist/routine.d.ts +82 -0
- package/dist/routine.js +1 -0
- package/dist/runtime-session-facts.d.ts +58 -0
- package/dist/runtime-session-facts.js +57 -0
- package/dist/session-control.d.ts +211 -0
- package/dist/session-control.js +48 -0
- package/dist/session-facts.d.ts +29 -0
- package/dist/session-facts.js +35 -0
- package/dist/skill-marketplace.d.ts +39 -4
- package/dist/spend-budget.d.ts +69 -0
- package/dist/spend-budget.js +1 -0
- package/dist/system-context.d.ts +7 -0
- package/dist/task-overview.d.ts +91 -0
- package/dist/task-overview.js +325 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/updater.d.ts +13 -3
- package/dist/usage-accounting.d.ts +42 -1
- package/dist/user-anchor.d.ts +17 -0
- package/dist/user-anchor.js +1 -0
- package/dist/work-coordination.d.ts +188 -0
- package/dist/work-coordination.js +1 -0
- package/dist/work-hook.d.ts +3 -0
- package/dist/work-hook.js +76 -0
- package/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.js +1 -0
- package/dist/workspace.d.ts +35 -0
- package/dist/workspace.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { BotDocumentReference, LocalDocumentReadResult } from './document-reference.ts';
|
|
2
|
+
import type { EvidenceDeliveryBinding } from './evidence-inspection.ts';
|
|
3
|
+
import { type InteractiveOwner, type InteractiveResultReference } from './interactive-result.ts';
|
|
4
|
+
/** Read-only presentation. None of these fields grant access or identify a browser guest/writer. */
|
|
5
|
+
export type ResourceWindowResource = ({
|
|
6
|
+
readonly kind: 'document';
|
|
7
|
+
readonly reference: BotDocumentReference;
|
|
8
|
+
readonly line?: number;
|
|
9
|
+
readonly delivery?: EvidenceDeliveryBinding;
|
|
10
|
+
} & ({
|
|
11
|
+
readonly mode: 'preview' | 'source';
|
|
12
|
+
} | {
|
|
13
|
+
readonly mode: 'diff';
|
|
14
|
+
readonly comparison: 'working' | 'staged';
|
|
15
|
+
})) | {
|
|
16
|
+
readonly kind: 'directory';
|
|
17
|
+
readonly reference: BotDocumentReference;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'comparison';
|
|
20
|
+
readonly reference: BotDocumentReference;
|
|
21
|
+
readonly fromRef: string;
|
|
22
|
+
readonly toRef?: string;
|
|
23
|
+
readonly comparison?: 'working' | 'staged';
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'interactive';
|
|
26
|
+
readonly reference: InteractiveResultReference;
|
|
27
|
+
};
|
|
28
|
+
export interface ResourceWindowNavigation {
|
|
29
|
+
readonly top: number;
|
|
30
|
+
readonly left: number;
|
|
31
|
+
readonly selected?: string;
|
|
32
|
+
readonly expanded?: readonly string[];
|
|
33
|
+
readonly filter?: string;
|
|
34
|
+
readonly mode?: 'preview' | 'source';
|
|
35
|
+
readonly positions?: readonly {
|
|
36
|
+
readonly key: string;
|
|
37
|
+
readonly top: number;
|
|
38
|
+
readonly left: number;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
export interface ResourceWindowOpenRequest {
|
|
42
|
+
readonly resource: ResourceWindowResource;
|
|
43
|
+
readonly sourceTabId?: string;
|
|
44
|
+
readonly navigation?: ResourceWindowNavigation;
|
|
45
|
+
}
|
|
46
|
+
export interface ResourceWindowOwner {
|
|
47
|
+
readonly workspaceId: string;
|
|
48
|
+
readonly conversationId: string;
|
|
49
|
+
readonly task?: BotDocumentReference['task'];
|
|
50
|
+
}
|
|
51
|
+
export interface ResourceWindowIdentity {
|
|
52
|
+
readonly viewId: string;
|
|
53
|
+
readonly windowId: string;
|
|
54
|
+
readonly generation: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ResourceWindowContext extends ResourceWindowIdentity {
|
|
57
|
+
readonly owner: ResourceWindowOwner;
|
|
58
|
+
readonly resource: ResourceWindowResource;
|
|
59
|
+
/** Factual presentation title resolved by the host; never an access grant. */
|
|
60
|
+
readonly title?: string;
|
|
61
|
+
readonly sourceTabId?: string;
|
|
62
|
+
readonly navigation?: ResourceWindowNavigation;
|
|
63
|
+
readonly sourceNavigation?: ResourceWindowNavigation;
|
|
64
|
+
readonly navigationVersion?: number;
|
|
65
|
+
readonly phase: 'prepared' | 'attached' | 'ready';
|
|
66
|
+
}
|
|
67
|
+
export type ResourceWindowStatus = 'invalid_request' | 'scope_denied' | 'permission_denied' | 'not_found' | 'workspace_unavailable' | 'revision_unavailable' | 'source_unavailable' | 'source_changed' | 'storage_unavailable' | 'limit_reached' | 'stale_view' | 'not_ready' | 'cancelled' | 'disposed' | 'content_cleaned' | 'incompatible_result' | 'result_unavailable';
|
|
68
|
+
export type ResourceWindowResult = {
|
|
69
|
+
readonly ok: true;
|
|
70
|
+
readonly context: ResourceWindowContext;
|
|
71
|
+
readonly persisted?: boolean;
|
|
72
|
+
readonly checkpointStatus?: 'owner_replaced';
|
|
73
|
+
readonly returnStatus?: 'returned' | 'source_tab_closed';
|
|
74
|
+
} | {
|
|
75
|
+
readonly ok: false;
|
|
76
|
+
readonly status: ResourceWindowStatus;
|
|
77
|
+
};
|
|
78
|
+
export interface ResourceWindowReturnRequest {
|
|
79
|
+
readonly requestId: string;
|
|
80
|
+
readonly context: ResourceWindowContext;
|
|
81
|
+
readonly expiresAt: number;
|
|
82
|
+
}
|
|
83
|
+
export interface ResourceWindowReturnAck {
|
|
84
|
+
readonly requestId: string;
|
|
85
|
+
readonly identity: ResourceWindowIdentity;
|
|
86
|
+
readonly status: 'returned' | 'source_tab_closed' | 'cancelled';
|
|
87
|
+
}
|
|
88
|
+
export interface ResourceWindowCheckpointRequest {
|
|
89
|
+
readonly requestId: string;
|
|
90
|
+
readonly identity: ResourceWindowIdentity;
|
|
91
|
+
}
|
|
92
|
+
export interface ResourceWindowCheckpointAck extends ResourceWindowCheckpointRequest {
|
|
93
|
+
readonly status: 'confirmed' | 'blocked';
|
|
94
|
+
}
|
|
95
|
+
export interface ResourceWindowCloseBlocked {
|
|
96
|
+
readonly identity: ResourceWindowIdentity;
|
|
97
|
+
readonly reason: 'save_failed' | 'unconfirmed';
|
|
98
|
+
}
|
|
99
|
+
export interface ResourceWindowHistoryEntry {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly owner: ResourceWindowOwner;
|
|
102
|
+
readonly request: ResourceWindowOpenRequest;
|
|
103
|
+
readonly savedAt: string;
|
|
104
|
+
readonly title?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ResourceWindowHistoryResult {
|
|
107
|
+
readonly ok: boolean;
|
|
108
|
+
readonly status: 'ok' | 'scope_denied' | 'storage_unavailable';
|
|
109
|
+
readonly entries: readonly ResourceWindowHistoryEntry[];
|
|
110
|
+
}
|
|
111
|
+
export interface ResourceLayoutSnapshot {
|
|
112
|
+
readonly formatVersion: 2;
|
|
113
|
+
readonly revision: number;
|
|
114
|
+
readonly order: readonly string[];
|
|
115
|
+
readonly recent: readonly string[];
|
|
116
|
+
readonly interactive: ResourceInteractiveSession;
|
|
117
|
+
readonly updatedAt: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ResourceInteractiveTab {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly reference: InteractiveResultReference;
|
|
122
|
+
readonly title?: string;
|
|
123
|
+
readonly navigation?: Pick<ResourceWindowNavigation, 'top' | 'left'>;
|
|
124
|
+
}
|
|
125
|
+
/** Domain presentation references only; values, raw drafts and writer truth stay in the state store. */
|
|
126
|
+
export interface ResourceInteractiveSession {
|
|
127
|
+
readonly tabs: readonly ResourceInteractiveTab[];
|
|
128
|
+
readonly activeTabId: string | null;
|
|
129
|
+
}
|
|
130
|
+
export type ResourceRecentReference = {
|
|
131
|
+
readonly kind: 'document';
|
|
132
|
+
readonly path: string;
|
|
133
|
+
readonly relativeTo?: string;
|
|
134
|
+
readonly task?: BotDocumentReference['task'];
|
|
135
|
+
readonly revision?: BotDocumentReference['revision'];
|
|
136
|
+
} | {
|
|
137
|
+
readonly kind: 'comparison';
|
|
138
|
+
readonly path: string;
|
|
139
|
+
readonly relativeTo?: string;
|
|
140
|
+
readonly task?: BotDocumentReference['task'];
|
|
141
|
+
readonly comparison: {
|
|
142
|
+
readonly fromRef: string;
|
|
143
|
+
readonly toRef?: string;
|
|
144
|
+
readonly comparison?: 'working' | 'staged';
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
readonly kind: 'directory';
|
|
148
|
+
readonly path: string;
|
|
149
|
+
readonly relativeTo?: string;
|
|
150
|
+
readonly task?: BotDocumentReference['task'];
|
|
151
|
+
} | {
|
|
152
|
+
readonly kind: 'browser';
|
|
153
|
+
readonly url: string;
|
|
154
|
+
} | {
|
|
155
|
+
readonly kind: 'interactive';
|
|
156
|
+
readonly reference: InteractiveResultReference;
|
|
157
|
+
readonly title?: string;
|
|
158
|
+
};
|
|
159
|
+
export interface ResourcePresentationApi {
|
|
160
|
+
readLayout(request: {
|
|
161
|
+
readonly owner: InteractiveOwner;
|
|
162
|
+
}): Promise<{
|
|
163
|
+
readonly ok: true;
|
|
164
|
+
readonly snapshot: ResourceLayoutSnapshot | null;
|
|
165
|
+
} | {
|
|
166
|
+
readonly ok: false;
|
|
167
|
+
readonly code: string;
|
|
168
|
+
}>;
|
|
169
|
+
writeLayout(request: {
|
|
170
|
+
readonly owner: InteractiveOwner;
|
|
171
|
+
readonly expectedRevision: number;
|
|
172
|
+
} & Pick<ResourceLayoutSnapshot, 'order' | 'recent' | 'interactive'>): Promise<{
|
|
173
|
+
readonly ok: true;
|
|
174
|
+
readonly snapshot: ResourceLayoutSnapshot;
|
|
175
|
+
} | {
|
|
176
|
+
readonly ok: false;
|
|
177
|
+
readonly code: string;
|
|
178
|
+
}>;
|
|
179
|
+
}
|
|
180
|
+
/** The host supplies owner, task, revision and allowed root from its lease, never from this request. */
|
|
181
|
+
export interface ResourceWindowReadRequest {
|
|
182
|
+
readonly identity: ResourceWindowIdentity;
|
|
183
|
+
readonly operation: 'content' | 'directory' | 'diff';
|
|
184
|
+
/** Directory descendants only. Omitted for the originally bound resource. */
|
|
185
|
+
readonly path?: string;
|
|
186
|
+
readonly expectedObservation?: BotDocumentReference['expectedObservation'];
|
|
187
|
+
readonly loadCurrent?: boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface ResourceWindowReadResult {
|
|
190
|
+
readonly ok: boolean;
|
|
191
|
+
readonly status: string;
|
|
192
|
+
readonly document?: LocalDocumentReadResult & {
|
|
193
|
+
readonly dataUrl?: string;
|
|
194
|
+
readonly media: 'text' | 'image';
|
|
195
|
+
};
|
|
196
|
+
readonly directory?: {
|
|
197
|
+
readonly entries: readonly {
|
|
198
|
+
readonly name: string;
|
|
199
|
+
readonly isDir: boolean;
|
|
200
|
+
readonly absPath: string;
|
|
201
|
+
}[];
|
|
202
|
+
readonly truncated?: boolean;
|
|
203
|
+
};
|
|
204
|
+
readonly diff?: {
|
|
205
|
+
readonly diffText: string;
|
|
206
|
+
readonly fromRef?: string;
|
|
207
|
+
readonly toRef?: string;
|
|
208
|
+
readonly untracked?: readonly string[];
|
|
209
|
+
readonly untrackedTruncated?: boolean;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** Only bounded hints for this kind of view; never accept a body, permission, browser instance or draft. */
|
|
213
|
+
export declare function normalizeResourceWindowNavigation(raw: unknown, kind: ResourceWindowResource['kind']): ResourceWindowNavigation | undefined;
|
|
214
|
+
export declare function normalizeResourceWindowRequest(raw: unknown): ResourceWindowOpenRequest | undefined;
|
|
215
|
+
export declare function normalizeResourceWindowOwner(raw: unknown): ResourceWindowOwner | undefined;
|
|
216
|
+
export declare function resourceWindowWorkspaceId(resource: ResourceWindowResource): string;
|
|
217
|
+
export declare function resourceWindowTask(resource: ResourceWindowResource): BotDocumentReference['task'] | undefined;
|
|
218
|
+
export declare function interactiveReferenceKey(reference: InteractiveResultReference): string;
|
|
219
|
+
export declare function normalizeResourceInteractiveSession(raw: unknown): ResourceInteractiveSession | undefined;
|
|
220
|
+
export declare function normalizeResourceRecentReference(raw: unknown): ResourceRecentReference | undefined;
|
|
221
|
+
export declare function normalizeResourceLayout(raw: unknown): Pick<ResourceLayoutSnapshot, 'order' | 'recent' | 'interactive'> | undefined;
|
|
222
|
+
export declare function normalizeResourceLayoutSnapshot(raw: unknown): ResourceLayoutSnapshot | undefined;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { interactiveToken, normalizeInteractiveReference } from "./interactive-result.js";
|
|
2
|
+
const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
3
|
+
const keys = (value, allowed) => Object.keys(value).every(key => allowed.includes(key));
|
|
4
|
+
const token = (value) => typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$/.test(value) && !value.includes('..');
|
|
5
|
+
const text = (value, max) => typeof value === 'string' && !!value.trim() && value.length <= max && !/[\u0000-\u001f]/.test(value);
|
|
6
|
+
const point = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 10_000_000;
|
|
7
|
+
function reference(raw) {
|
|
8
|
+
if (!object(raw) || !keys(raw, ['workspaceId', 'path', 'relativeTo', 'task', 'kind', 'expectedObservation', 'revision']) || !token(raw.workspaceId) || !text(raw.path, 8192))
|
|
9
|
+
return;
|
|
10
|
+
if (raw.kind !== undefined && raw.kind !== 'file' && raw.kind !== 'directory' || raw.relativeTo !== undefined && !text(raw.relativeTo, 8192))
|
|
11
|
+
return;
|
|
12
|
+
let task, expectedObservation, revision;
|
|
13
|
+
if (raw.task !== undefined) {
|
|
14
|
+
if (!object(raw.task) || !keys(raw.task, ['sessionId', 'planId']) || !token(raw.task.sessionId) || !token(raw.task.planId))
|
|
15
|
+
return;
|
|
16
|
+
task = { sessionId: raw.task.sessionId, planId: raw.task.planId };
|
|
17
|
+
}
|
|
18
|
+
if (raw.expectedObservation !== undefined) {
|
|
19
|
+
const e = raw.expectedObservation;
|
|
20
|
+
if (!object(e) || !keys(e, ['resourceId', 'contentVersion']) || (typeof e.resourceId !== 'string' || !/^sha256:[a-f0-9]{64}$/.test(e.resourceId))
|
|
21
|
+
|| e.contentVersion !== undefined && (typeof e.contentVersion !== 'string' || !/^sha256:[a-f0-9]{64}$/.test(e.contentVersion)))
|
|
22
|
+
return;
|
|
23
|
+
expectedObservation = { resourceId: e.resourceId, ...(typeof e.contentVersion === 'string' ? { contentVersion: e.contentVersion } : {}) };
|
|
24
|
+
}
|
|
25
|
+
if (raw.revision !== undefined) {
|
|
26
|
+
const r = raw.revision;
|
|
27
|
+
if (!object(r) || !keys(r, ['kind', 'commit', 'repositoryId']) || r.kind !== 'git' || typeof r.commit !== 'string' || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(r.commit)
|
|
28
|
+
|| r.repositoryId !== undefined && !text(r.repositoryId, 1024))
|
|
29
|
+
return;
|
|
30
|
+
revision = { kind: 'git', commit: r.commit, ...(typeof r.repositoryId === 'string' ? { repositoryId: r.repositoryId } : {}) };
|
|
31
|
+
}
|
|
32
|
+
return { workspaceId: raw.workspaceId, path: raw.path, ...(raw.kind ? { kind: raw.kind } : {}),
|
|
33
|
+
...(typeof raw.relativeTo === 'string' ? { relativeTo: raw.relativeTo } : {}), ...(task ? { task } : {}), ...(expectedObservation ? { expectedObservation } : {}), ...(revision ? { revision } : {}) };
|
|
34
|
+
}
|
|
35
|
+
function resource(raw) {
|
|
36
|
+
if (!object(raw))
|
|
37
|
+
return;
|
|
38
|
+
if (raw.kind === 'interactive') {
|
|
39
|
+
if (!keys(raw, ['kind', 'reference']))
|
|
40
|
+
return;
|
|
41
|
+
const fixed = normalizeInteractiveReference(raw.reference);
|
|
42
|
+
return fixed ? { kind: 'interactive', reference: fixed } : undefined;
|
|
43
|
+
}
|
|
44
|
+
const ref = reference(raw.reference);
|
|
45
|
+
if (!ref)
|
|
46
|
+
return;
|
|
47
|
+
if (raw.kind === 'directory') {
|
|
48
|
+
if (!keys(raw, ['kind', 'reference']) || ref.revision || ref.expectedObservation)
|
|
49
|
+
return;
|
|
50
|
+
return { kind: 'directory', reference: { ...ref, kind: 'directory' } };
|
|
51
|
+
}
|
|
52
|
+
if (raw.kind === 'comparison') {
|
|
53
|
+
if (!keys(raw, ['kind', 'reference', 'fromRef', 'toRef', 'comparison']) || ref.revision || ref.expectedObservation || !text(raw.fromRef, 256)
|
|
54
|
+
|| raw.toRef !== undefined && !text(raw.toRef, 256) || raw.comparison !== undefined && (typeof raw.comparison !== 'string' || !['working', 'staged'].includes(raw.comparison)))
|
|
55
|
+
return;
|
|
56
|
+
// A working/index comparison cannot silently discard a supplied immutable endpoint.
|
|
57
|
+
if (raw.comparison && (raw.fromRef !== 'HEAD' || raw.toRef !== undefined))
|
|
58
|
+
return;
|
|
59
|
+
if (!raw.comparison && (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(raw.fromRef)
|
|
60
|
+
|| typeof raw.toRef === 'string' && !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(raw.toRef)))
|
|
61
|
+
return;
|
|
62
|
+
return { kind: 'comparison', reference: { ...ref, kind: 'directory' }, fromRef: raw.fromRef,
|
|
63
|
+
...(typeof raw.toRef === 'string' ? { toRef: raw.toRef } : {}), ...(raw.comparison ? { comparison: raw.comparison } : {}) };
|
|
64
|
+
}
|
|
65
|
+
if (raw.kind !== 'document' || !keys(raw, ['kind', 'reference', 'mode', 'comparison', 'line', 'delivery']) || ref.kind === 'directory'
|
|
66
|
+
|| typeof raw.mode !== 'string' || !['preview', 'source', 'diff'].includes(raw.mode) || ref.revision && raw.mode === 'diff'
|
|
67
|
+
|| raw.mode === 'diff' && raw.comparison === undefined
|
|
68
|
+
|| raw.comparison !== undefined && (raw.mode !== 'diff' || typeof raw.comparison !== 'string' || !['working', 'staged'].includes(raw.comparison))
|
|
69
|
+
|| raw.line !== undefined && (!Number.isSafeInteger(raw.line) || Number(raw.line) < 1 || Number(raw.line) > 1_000_000))
|
|
70
|
+
return;
|
|
71
|
+
let delivery;
|
|
72
|
+
if (raw.delivery !== undefined) {
|
|
73
|
+
const d = raw.delivery;
|
|
74
|
+
if (ref.revision || !object(d) || !keys(d, ['evidenceRef', 'artifactRef']) || !text(d.evidenceRef, 500) || /[\s\\]/.test(d.evidenceRef) || d.evidenceRef.includes('..') || !text(d.artifactRef, 8192))
|
|
75
|
+
return;
|
|
76
|
+
delivery = { evidenceRef: d.evidenceRef, artifactRef: d.artifactRef };
|
|
77
|
+
}
|
|
78
|
+
const common = { kind: 'document', reference: { ...ref, kind: 'file' },
|
|
79
|
+
...(typeof raw.line === 'number' ? { line: raw.line } : {}), ...(delivery ? { delivery } : {}) };
|
|
80
|
+
return raw.mode === 'diff' ? { ...common, mode: 'diff', comparison: raw.comparison }
|
|
81
|
+
: { ...common, mode: raw.mode };
|
|
82
|
+
}
|
|
83
|
+
/** Only bounded hints for this kind of view; never accept a body, permission, browser instance or draft. */
|
|
84
|
+
export function normalizeResourceWindowNavigation(raw, kind) {
|
|
85
|
+
if (!object(raw) || !keys(raw, kind === 'interactive' ? ['top', 'left'] : kind === 'directory' ? ['top', 'left', 'selected', 'expanded', 'filter'] : kind === 'comparison' ? ['top', 'left', 'selected', 'positions'] : ['top', 'left', 'mode', 'positions']) || !point(raw.top) || !point(raw.left))
|
|
86
|
+
return;
|
|
87
|
+
if (raw.selected !== undefined && !text(raw.selected, 8192) || raw.filter !== undefined && (typeof raw.filter !== 'string' || raw.filter.length > 256 || /[\u0000-\u001f]/.test(raw.filter))
|
|
88
|
+
|| raw.expanded !== undefined && (!Array.isArray(raw.expanded) || raw.expanded.length > 64 || !raw.expanded.every(value => text(value, 8192))))
|
|
89
|
+
return;
|
|
90
|
+
if (raw.mode !== undefined && raw.mode !== 'preview' && raw.mode !== 'source')
|
|
91
|
+
return;
|
|
92
|
+
const relative = (value) => text(value, 4096) && (value === '.' || !/^[\\/]/.test(value) && value.split('/').length <= 16 && value.split('/').every(part => part && part !== '.' && part !== '..' && !/[\\:]/.test(part)));
|
|
93
|
+
if (kind === 'directory' && (raw.selected !== undefined && !relative(raw.selected)
|
|
94
|
+
|| Array.isArray(raw.expanded) && !raw.expanded.every(relative)))
|
|
95
|
+
return;
|
|
96
|
+
if (raw.positions !== undefined && (!Array.isArray(raw.positions) || raw.positions.length > 12 || !raw.positions.every(value => object(value) && keys(value, ['key', 'top', 'left']) && text(value.key, 8192) && point(value.top) && point(value.left)
|
|
97
|
+
&& (kind !== 'document' || ['preview', 'source', 'diff'].includes(value.key)))))
|
|
98
|
+
return;
|
|
99
|
+
if (Array.isArray(raw.positions) && new Set(raw.positions.map(value => value.key)).size !== raw.positions.length)
|
|
100
|
+
return;
|
|
101
|
+
return { top: raw.top, left: raw.left, ...(typeof raw.selected === 'string' ? { selected: raw.selected } : {}),
|
|
102
|
+
...(typeof raw.filter === 'string' ? { filter: raw.filter } : {}), ...(Array.isArray(raw.expanded) ? { expanded: [...new Set(raw.expanded)] } : {}),
|
|
103
|
+
...(raw.mode ? { mode: raw.mode } : {}), ...(Array.isArray(raw.positions) ? { positions: raw.positions.map(value => ({ key: value.key, top: value.top, left: value.left })) } : {}) };
|
|
104
|
+
}
|
|
105
|
+
export function normalizeResourceWindowRequest(raw) {
|
|
106
|
+
if (!object(raw) || !keys(raw, ['resource', 'sourceTabId', 'navigation']) || raw.sourceTabId !== undefined && !token(raw.sourceTabId))
|
|
107
|
+
return;
|
|
108
|
+
const target = resource(raw.resource);
|
|
109
|
+
if (!target)
|
|
110
|
+
return;
|
|
111
|
+
const navigation = raw.navigation === undefined ? undefined : normalizeResourceWindowNavigation(raw.navigation, target.kind);
|
|
112
|
+
if (raw.navigation !== undefined && !navigation)
|
|
113
|
+
return;
|
|
114
|
+
return { resource: target, ...(typeof raw.sourceTabId === 'string' ? { sourceTabId: raw.sourceTabId } : {}), ...(navigation ? { navigation } : {}) };
|
|
115
|
+
}
|
|
116
|
+
export function normalizeResourceWindowOwner(raw) {
|
|
117
|
+
if (!object(raw) || !keys(raw, ['workspaceId', 'conversationId', 'task']) || !token(raw.workspaceId) || !token(raw.conversationId))
|
|
118
|
+
return;
|
|
119
|
+
if (raw.task !== undefined && (!object(raw.task) || !keys(raw.task, ['sessionId', 'planId']) || !token(raw.task.sessionId) || !token(raw.task.planId)))
|
|
120
|
+
return;
|
|
121
|
+
return { workspaceId: raw.workspaceId, conversationId: raw.conversationId,
|
|
122
|
+
...(object(raw.task) ? { task: { sessionId: raw.task.sessionId, planId: raw.task.planId } } : {}) };
|
|
123
|
+
}
|
|
124
|
+
export function resourceWindowWorkspaceId(resource) {
|
|
125
|
+
return resource.kind === 'interactive' ? resource.reference.owner.workspaceId : resource.reference.workspaceId;
|
|
126
|
+
}
|
|
127
|
+
export function resourceWindowTask(resource) {
|
|
128
|
+
return resource.kind === 'interactive' ? undefined : resource.reference.task;
|
|
129
|
+
}
|
|
130
|
+
export function interactiveReferenceKey(reference) {
|
|
131
|
+
return JSON.stringify([reference.owner.workspaceId, reference.owner.conversationId, reference.resultId, reference.contentVersion]);
|
|
132
|
+
}
|
|
133
|
+
const titleHint = (value) => typeof value === 'string' && !!value.trim() && value.length <= 160 && !value.includes('\0');
|
|
134
|
+
export function normalizeResourceInteractiveSession(raw) {
|
|
135
|
+
if (!object(raw) || !keys(raw, ['tabs', 'activeTabId']) || !Array.isArray(raw.tabs) || raw.tabs.length > 32
|
|
136
|
+
|| raw.activeTabId !== null && !interactiveToken(raw.activeTabId))
|
|
137
|
+
return;
|
|
138
|
+
const tabs = [];
|
|
139
|
+
const ids = new Set(), references = new Set();
|
|
140
|
+
for (const item of raw.tabs) {
|
|
141
|
+
if (!object(item) || !keys(item, ['id', 'reference', 'title', 'navigation']) || !interactiveToken(item.id) || item.title !== undefined && !titleHint(item.title))
|
|
142
|
+
return;
|
|
143
|
+
const reference = normalizeInteractiveReference(item.reference);
|
|
144
|
+
const navigation = item.navigation === undefined ? undefined : normalizeResourceWindowNavigation(item.navigation, 'interactive');
|
|
145
|
+
if (!reference || item.navigation !== undefined && !navigation || ids.has(item.id) || references.has(interactiveReferenceKey(reference)))
|
|
146
|
+
return;
|
|
147
|
+
ids.add(item.id);
|
|
148
|
+
references.add(interactiveReferenceKey(reference));
|
|
149
|
+
tabs.push({ id: item.id, reference, ...(item.title !== undefined ? { title: item.title } : {}), ...(navigation ? { navigation } : {}) });
|
|
150
|
+
}
|
|
151
|
+
if (raw.activeTabId !== null && !ids.has(raw.activeTabId))
|
|
152
|
+
return;
|
|
153
|
+
return { tabs, activeTabId: raw.activeTabId };
|
|
154
|
+
}
|
|
155
|
+
export function normalizeResourceRecentReference(raw) {
|
|
156
|
+
if (!object(raw))
|
|
157
|
+
return;
|
|
158
|
+
if (raw.kind === 'interactive') {
|
|
159
|
+
if (!keys(raw, ['kind', 'reference', 'title']) || raw.title !== undefined && !titleHint(raw.title))
|
|
160
|
+
return;
|
|
161
|
+
const reference = normalizeInteractiveReference(raw.reference);
|
|
162
|
+
return reference ? { kind: 'interactive', reference, ...(raw.title !== undefined ? { title: raw.title } : {}) } : undefined;
|
|
163
|
+
}
|
|
164
|
+
if (raw.kind === 'browser') {
|
|
165
|
+
if (!keys(raw, ['kind', 'url']) || !text(raw.url, 8192))
|
|
166
|
+
return;
|
|
167
|
+
try {
|
|
168
|
+
const url = new URL(raw.url);
|
|
169
|
+
if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password)
|
|
170
|
+
return;
|
|
171
|
+
return { kind: 'browser', url: url.href };
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!['document', 'comparison', 'directory'].includes(String(raw.kind)) || !keys(raw, raw.kind === 'document' ? ['kind', 'path', 'relativeTo', 'task', 'revision'] : raw.kind === 'directory' ? ['kind', 'path', 'relativeTo', 'task'] : ['kind', 'path', 'relativeTo', 'task', 'comparison']))
|
|
178
|
+
return;
|
|
179
|
+
// A recent descriptor is a hint scoped by its containing owner. It never supplies a workspace or an access grant.
|
|
180
|
+
const ref = { workspaceId: 'presentation', path: raw.path, ...(raw.relativeTo !== undefined ? { relativeTo: raw.relativeTo } : {}),
|
|
181
|
+
...(raw.task !== undefined ? { task: raw.task } : {}), ...(raw.revision !== undefined ? { revision: raw.revision } : {}) };
|
|
182
|
+
if (raw.kind === 'directory') {
|
|
183
|
+
const request = normalizeResourceWindowRequest({ resource: { kind: 'directory', reference: ref } });
|
|
184
|
+
if (request?.resource.kind !== 'directory')
|
|
185
|
+
return;
|
|
186
|
+
const fixed = request.resource.reference;
|
|
187
|
+
return { kind: 'directory', path: fixed.path, ...(fixed.relativeTo ? { relativeTo: fixed.relativeTo } : {}), ...(fixed.task ? { task: fixed.task } : {}) };
|
|
188
|
+
}
|
|
189
|
+
if (raw.kind === 'document') {
|
|
190
|
+
const request = normalizeResourceWindowRequest({ resource: { kind: 'document', reference: ref, mode: 'preview' } });
|
|
191
|
+
if (request?.resource.kind !== 'document')
|
|
192
|
+
return;
|
|
193
|
+
const fixed = request.resource.reference;
|
|
194
|
+
return { kind: 'document', path: fixed.path, ...(fixed.relativeTo ? { relativeTo: fixed.relativeTo } : {}), ...(fixed.task ? { task: fixed.task } : {}), ...(fixed.revision ? { revision: fixed.revision } : {}) };
|
|
195
|
+
}
|
|
196
|
+
if (!object(raw.comparison) || !keys(raw.comparison, ['fromRef', 'toRef', 'comparison']))
|
|
197
|
+
return;
|
|
198
|
+
const request = normalizeResourceWindowRequest({ resource: { kind: 'comparison', reference: ref, ...raw.comparison } });
|
|
199
|
+
if (request?.resource.kind !== 'comparison')
|
|
200
|
+
return;
|
|
201
|
+
const fixed = request.resource;
|
|
202
|
+
return { kind: 'comparison', path: fixed.reference.path, ...(fixed.reference.relativeTo ? { relativeTo: fixed.reference.relativeTo } : {}), ...(fixed.reference.task ? { task: fixed.reference.task } : {}),
|
|
203
|
+
comparison: { fromRef: fixed.fromRef, ...(fixed.toRef ? { toRef: fixed.toRef } : {}), ...(fixed.comparison ? { comparison: fixed.comparison } : {}) } };
|
|
204
|
+
}
|
|
205
|
+
export function normalizeResourceLayout(raw) {
|
|
206
|
+
if (!object(raw) || !keys(raw, ['order', 'recent', 'interactive']))
|
|
207
|
+
return;
|
|
208
|
+
const interactive = normalizeResourceInteractiveSession(raw.interactive);
|
|
209
|
+
if (!interactive)
|
|
210
|
+
return;
|
|
211
|
+
const list = (value, limit) => Array.isArray(value) && value.length <= limit
|
|
212
|
+
&& value.every(key => typeof key === 'string' && key.length <= 8192 && !/[\u0000-\u001f]/.test(key)
|
|
213
|
+
&& (key === 'launcher' || /^(?:document|browser|conversation|interactive|directory):.+$/.test(key) || key === 'comparison:workspace')) && new Set(value).size === value.length;
|
|
214
|
+
if (!list(raw.order, 200) || !Array.isArray(raw.recent) || raw.recent.length > 16 || new TextEncoder().encode(JSON.stringify(raw)).byteLength > 256 * 1024)
|
|
215
|
+
return;
|
|
216
|
+
const mapped = new Set(interactive.tabs.map(tab => `interactive:${tab.id}`));
|
|
217
|
+
if (raw.order.some(key => key.startsWith('interactive:') && !mapped.has(key))
|
|
218
|
+
|| interactive.activeTabId !== null && !raw.order.includes(`interactive:${interactive.activeTabId}`))
|
|
219
|
+
return;
|
|
220
|
+
const recent = [];
|
|
221
|
+
for (const item of raw.recent) {
|
|
222
|
+
if (typeof item !== 'string' || item.length > 8192)
|
|
223
|
+
return;
|
|
224
|
+
if (list([item], 1)) {
|
|
225
|
+
recent.push(item);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const ref = normalizeResourceRecentReference(JSON.parse(item));
|
|
230
|
+
if (!ref)
|
|
231
|
+
return;
|
|
232
|
+
const descriptor = JSON.stringify(ref);
|
|
233
|
+
if (descriptor.length > 8192)
|
|
234
|
+
return;
|
|
235
|
+
recent.push(descriptor);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (new Set(recent).size !== recent.length)
|
|
242
|
+
return;
|
|
243
|
+
const layout = { order: [...raw.order], recent, interactive };
|
|
244
|
+
return new TextEncoder().encode(JSON.stringify(layout)).byteLength <= 256 * 1024 ? layout : undefined;
|
|
245
|
+
}
|
|
246
|
+
export function normalizeResourceLayoutSnapshot(raw) {
|
|
247
|
+
if (!object(raw) || !keys(raw, ['formatVersion', 'revision', 'order', 'recent', 'interactive', 'updatedAt']) || raw.formatVersion !== 2
|
|
248
|
+
|| !Number.isSafeInteger(raw.revision) || Number(raw.revision) < 1 || typeof raw.updatedAt !== 'string' || raw.updatedAt.length > 40 || !Number.isFinite(Date.parse(raw.updatedAt)))
|
|
249
|
+
return;
|
|
250
|
+
const layout = normalizeResourceLayout({ order: raw.order, recent: raw.recent, interactive: raw.interactive });
|
|
251
|
+
return layout ? { formatVersion: 2, ...layout, revision: raw.revision, updatedAt: raw.updatedAt } : undefined;
|
|
252
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type RoutineTrigger = {
|
|
2
|
+
readonly kind: 'manual';
|
|
3
|
+
} | {
|
|
4
|
+
readonly kind: 'cron';
|
|
5
|
+
readonly expression: string;
|
|
6
|
+
readonly timezone: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'interval_secs';
|
|
9
|
+
readonly seconds: number;
|
|
10
|
+
readonly anchorAt?: string | null;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'event';
|
|
13
|
+
};
|
|
14
|
+
export type RoutineTargetKind = 'bot' | 'group_chat';
|
|
15
|
+
export type RoutineRunStatus = 'queued' | 'preparing' | 'running' | 'waiting_permission' | 'waiting_user' | 'succeeded' | 'failed' | 'skipped' | 'cancelled' | 'timed_out' | 'blocked';
|
|
16
|
+
export interface RoutineDefinition {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly prompt: string;
|
|
19
|
+
readonly trigger: RoutineTrigger;
|
|
20
|
+
readonly targetKind: RoutineTargetKind;
|
|
21
|
+
readonly targetId: string;
|
|
22
|
+
readonly outputMode: 'chat_only' | 'update_page' | 'silent_on_no_reply';
|
|
23
|
+
readonly targetPageId?: string | null;
|
|
24
|
+
readonly enabled: boolean;
|
|
25
|
+
readonly misfirePolicy: 'skip_to_next' | 'run_once_coalesced';
|
|
26
|
+
}
|
|
27
|
+
export interface Routine extends RoutineDefinition {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly revision: number;
|
|
30
|
+
readonly nextRunAt: string | null;
|
|
31
|
+
readonly lastRunStatus: RoutineRunStatus | null;
|
|
32
|
+
readonly lastRunSummary: string | null;
|
|
33
|
+
readonly consecutiveFailures: number;
|
|
34
|
+
readonly archived: boolean;
|
|
35
|
+
}
|
|
36
|
+
export type RoutineListItem = (Routine & {
|
|
37
|
+
readonly sourceKind: 'routine' | 'legacy_automation';
|
|
38
|
+
readonly latestRun?: RoutineRun;
|
|
39
|
+
readonly activeRun?: RoutineRun;
|
|
40
|
+
readonly diagnostic?: string;
|
|
41
|
+
}) | {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly sourceKind: 'project_watch';
|
|
45
|
+
readonly readOnly: true;
|
|
46
|
+
readonly enabled: boolean;
|
|
47
|
+
readonly targetKind: 'bot';
|
|
48
|
+
readonly targetId: string;
|
|
49
|
+
readonly managementRef: {
|
|
50
|
+
readonly workspaceId: string;
|
|
51
|
+
readonly objectiveId: string;
|
|
52
|
+
readonly watchId: string;
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly sourceKind: 'legacy_automation';
|
|
58
|
+
readonly enabled: false;
|
|
59
|
+
readonly revision: number;
|
|
60
|
+
readonly archived: boolean;
|
|
61
|
+
readonly diagnostic: 'LEGACY_WRITER_CUTOVER_REQUIRED';
|
|
62
|
+
};
|
|
63
|
+
export interface RoutineRun {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly routineId: string;
|
|
66
|
+
readonly definitionRevision: number;
|
|
67
|
+
readonly snapshot?: Readonly<Record<string, unknown>>;
|
|
68
|
+
readonly scheduledFor: string;
|
|
69
|
+
readonly status: RoutineRunStatus;
|
|
70
|
+
readonly reason: string | null;
|
|
71
|
+
readonly summary: string | null;
|
|
72
|
+
readonly approvalId: string | null;
|
|
73
|
+
readonly conversationId: string | null;
|
|
74
|
+
readonly messageId: string | null;
|
|
75
|
+
readonly pageId: string | null;
|
|
76
|
+
readonly pageRevision: number | null;
|
|
77
|
+
readonly retryOf: string | null;
|
|
78
|
+
}
|
|
79
|
+
export type RoutineChanged = {
|
|
80
|
+
readonly routineId: string;
|
|
81
|
+
readonly revision: number;
|
|
82
|
+
};
|
package/dist/routine.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type WorkSessionStatus } from './delegation.ts';
|
|
2
|
+
import { type ExecutionOwnership, type FollowUpOwner } from './task-overview.ts';
|
|
3
|
+
export type RuntimeHandling = 'model' | 'host' | 'user' | 'none';
|
|
4
|
+
/** A checked view of existing session facts, never a second lifecycle or execution receipt. */
|
|
5
|
+
export interface RuntimeSessionFacts {
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
readonly status: WorkSessionStatus | 'unknown';
|
|
8
|
+
readonly valid: boolean;
|
|
9
|
+
readonly executionOwnership: ExecutionOwnership;
|
|
10
|
+
readonly owner: FollowUpOwner;
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
readonly handling: RuntimeHandling;
|
|
13
|
+
readonly pendingManaged: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function runtimeSessionFacts(value: unknown): RuntimeSessionFacts;
|
|
16
|
+
/** Missing/invalid facts remain obligations; a valid public terminal does not invent live ownership. */
|
|
17
|
+
export declare function hasPendingRuntimeSessions(sessions: readonly unknown[], expectedIds?: readonly string[]): boolean;
|
|
18
|
+
export interface RuntimeSessionOwnership {
|
|
19
|
+
readonly repairSessionIds: readonly string[];
|
|
20
|
+
readonly hostSessionIds: readonly string[];
|
|
21
|
+
readonly waitingSessionIds: readonly string[];
|
|
22
|
+
readonly needsUser: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function runtimeSessionOwnership(sessions: readonly unknown[]): RuntimeSessionOwnership;
|
|
25
|
+
export interface ResourceWaitScope {
|
|
26
|
+
readonly workspaceId: string;
|
|
27
|
+
readonly parentConversationId: string;
|
|
28
|
+
readonly workId: string;
|
|
29
|
+
readonly sessionIds: readonly string[];
|
|
30
|
+
readonly executionBindings?: Readonly<Record<string, {
|
|
31
|
+
readonly executionEpoch: string;
|
|
32
|
+
readonly goalRevision: number;
|
|
33
|
+
}>>;
|
|
34
|
+
}
|
|
35
|
+
export interface ResourceWaitReference {
|
|
36
|
+
readonly kind: 'resource';
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly revision: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ResourceWaitFact {
|
|
41
|
+
readonly sessionId: string;
|
|
42
|
+
readonly wait: ResourceWaitReference;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
}
|
|
45
|
+
export type ResourceWaitInspection = {
|
|
46
|
+
readonly state: 'waiting';
|
|
47
|
+
readonly current: ResourceWaitFact;
|
|
48
|
+
} | {
|
|
49
|
+
readonly state: 'ready';
|
|
50
|
+
readonly sessionId: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly state: 'stale' | 'unavailable';
|
|
53
|
+
readonly reason: string;
|
|
54
|
+
};
|
|
55
|
+
export interface ResourceWaitPort {
|
|
56
|
+
readonly read: (scope: ResourceWaitScope) => readonly ResourceWaitFact[];
|
|
57
|
+
readonly inspect: (scope: ResourceWaitScope, wait: ResourceWaitReference) => ResourceWaitInspection;
|
|
58
|
+
}
|