@pstdio/pocketcoder-sdk 0.8.0 → 0.9.0
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/README.md +43 -3
- package/dist/index.d.ts +5888 -2279
- package/dist/index.js +1238 -436
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { createHash } from "node:crypto";
|
|
3
4
|
import { posix } from "node:path";
|
|
@@ -14,37 +15,6 @@ const AttachmentDescriptorSchema = z.object({
|
|
|
14
15
|
size_bytes: z.number().int().min(0).max(ATTACHMENT_MAX_FILE_BYTES),
|
|
15
16
|
sha256: z.string().regex(/^[0-9a-f]{64}$/)
|
|
16
17
|
});
|
|
17
|
-
z.looseObject({
|
|
18
|
-
type: z.literal("user"),
|
|
19
|
-
content: z.string(),
|
|
20
|
-
attachment_ids: z.array(z.uuid()).min(1).max(10).refine((ids) => new Set(ids).size === ids.length, "attachment_ids must be unique").optional()
|
|
21
|
-
});
|
|
22
|
-
const MANIFEST_OPEN = "<pocketcoder-attachments>";
|
|
23
|
-
const MANIFEST_CLOSE = "</pocketcoder-attachments>";
|
|
24
|
-
function splitAttachmentManifest(content) {
|
|
25
|
-
const open = content.lastIndexOf(MANIFEST_OPEN);
|
|
26
|
-
if (open < 0 || !content.trimEnd().endsWith(MANIFEST_CLOSE)) return {
|
|
27
|
-
text: content,
|
|
28
|
-
attachments: null
|
|
29
|
-
};
|
|
30
|
-
const close = content.lastIndexOf(MANIFEST_CLOSE);
|
|
31
|
-
const parsed = z.array(AttachmentDescriptorSchema).safeParse(safeJson(content.slice(open + 25, close)));
|
|
32
|
-
if (!parsed.success) return {
|
|
33
|
-
text: content,
|
|
34
|
-
attachments: null
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
text: content.slice(0, open).trimEnd(),
|
|
38
|
-
attachments: parsed.data
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function safeJson(value) {
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(value);
|
|
44
|
-
} catch {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
18
|
const AttachmentStartPayload = z.object({
|
|
49
19
|
operation_id: z.uuid(),
|
|
50
20
|
attachment_id: z.uuid(),
|
|
@@ -139,7 +109,8 @@ const WorkloadCapabilitySchema = z.enum([
|
|
|
139
109
|
"workspace-services",
|
|
140
110
|
"revocable-preview-grants",
|
|
141
111
|
"workspace-cancel",
|
|
142
|
-
"unknown-outcome"
|
|
112
|
+
"unknown-outcome",
|
|
113
|
+
"parallel-conversations"
|
|
143
114
|
]);
|
|
144
115
|
const WorkloadProfileSchema = z.enum([
|
|
145
116
|
"finite-process",
|
|
@@ -191,8 +162,7 @@ const InstalledWorkloadSchema = z.strictObject({
|
|
|
191
162
|
kind: z.enum([
|
|
192
163
|
"process",
|
|
193
164
|
"service",
|
|
194
|
-
"pi"
|
|
195
|
-
"agentapi"
|
|
165
|
+
"pi"
|
|
196
166
|
]),
|
|
197
167
|
digest: WorkloadDigestSchema,
|
|
198
168
|
protocol: z.string().min(1).max(128),
|
|
@@ -203,6 +173,7 @@ const InstalledWorkloadSchema = z.strictObject({
|
|
|
203
173
|
//#region ../contracts/src/attachments/input-reference.ts
|
|
204
174
|
const InputObjectReferenceSchema = z.strictObject({
|
|
205
175
|
workspaceId: z.uuid(),
|
|
176
|
+
storageOwnerId: z.uuid().optional(),
|
|
206
177
|
fileId: z.uuid(),
|
|
207
178
|
objectVersion: WorkloadDigestSchema,
|
|
208
179
|
name: z.string().min(1).max(255),
|
|
@@ -268,6 +239,10 @@ const SCOPES = [
|
|
|
268
239
|
"network:read",
|
|
269
240
|
"terminal:attach",
|
|
270
241
|
"terminal:read",
|
|
242
|
+
"sessions:read",
|
|
243
|
+
"sessions:write",
|
|
244
|
+
"budgets:read",
|
|
245
|
+
"budgets:admin",
|
|
271
246
|
"admin"
|
|
272
247
|
];
|
|
273
248
|
z.strictObject({
|
|
@@ -572,6 +547,7 @@ const ERROR_CODES = {
|
|
|
572
547
|
"principal.name_conflict": 409,
|
|
573
548
|
"key.not_found": 404,
|
|
574
549
|
"request.body_too_large": 413,
|
|
550
|
+
"request.not_found": 404,
|
|
575
551
|
"validation.invalid": 400,
|
|
576
552
|
"idempotency.conflict": 409,
|
|
577
553
|
"capacity.queue_full": 429,
|
|
@@ -635,6 +611,16 @@ const ERROR_CODES = {
|
|
|
635
611
|
"account.purge_pending": 503,
|
|
636
612
|
"recovery.required": 503,
|
|
637
613
|
"recovery.failed": 409,
|
|
614
|
+
"session.not_found": 404,
|
|
615
|
+
"session.closed": 409,
|
|
616
|
+
"profile.not_found": 404,
|
|
617
|
+
"budget.not_found": 404,
|
|
618
|
+
"budget.exhausted": 429,
|
|
619
|
+
"budget.conflict": 409,
|
|
620
|
+
"revision.stale": 412,
|
|
621
|
+
"events.cursor_invalid": 400,
|
|
622
|
+
"events.cursor_expired": 410,
|
|
623
|
+
"runtime.unavailable": 503,
|
|
638
624
|
"internal.error": 500
|
|
639
625
|
};
|
|
640
626
|
const errorCodes = Object.keys(ERROR_CODES);
|
|
@@ -734,6 +720,45 @@ const ConversationProtocolSupportSchema = z.object({
|
|
|
734
720
|
producer_capabilities: z.null()
|
|
735
721
|
});
|
|
736
722
|
//#endregion
|
|
723
|
+
//#region ../contracts/src/conversations/parts.ts
|
|
724
|
+
const text = z.string().max(262144);
|
|
725
|
+
const payload = JsonValueSchema.refine((value) => new TextEncoder().encode(JSON.stringify(value)).length <= 262144, "Session part payload exceeds 256 KiB");
|
|
726
|
+
const ConversationPartSchema = z.discriminatedUnion("type", [
|
|
727
|
+
z.strictObject({
|
|
728
|
+
type: z.literal("text"),
|
|
729
|
+
text
|
|
730
|
+
}),
|
|
731
|
+
z.strictObject({
|
|
732
|
+
type: z.literal("tool"),
|
|
733
|
+
call_id: z.string().min(1).max(256),
|
|
734
|
+
name: z.string().min(1).max(128),
|
|
735
|
+
status: z.enum([
|
|
736
|
+
"pending",
|
|
737
|
+
"running",
|
|
738
|
+
"completed",
|
|
739
|
+
"failed",
|
|
740
|
+
"canceled"
|
|
741
|
+
]),
|
|
742
|
+
input: payload,
|
|
743
|
+
output: payload.optional(),
|
|
744
|
+
output_text: text.optional(),
|
|
745
|
+
started_at: z.iso.datetime().nullable().optional(),
|
|
746
|
+
ended_at: z.iso.datetime().nullable().optional()
|
|
747
|
+
}),
|
|
748
|
+
z.strictObject({
|
|
749
|
+
type: z.literal("error"),
|
|
750
|
+
code: z.string().min(1).max(128),
|
|
751
|
+
message: text
|
|
752
|
+
}),
|
|
753
|
+
z.strictObject({
|
|
754
|
+
type: z.literal("file"),
|
|
755
|
+
file_id: z.uuid(),
|
|
756
|
+
name: z.string().min(1).max(512),
|
|
757
|
+
media_type: z.string().min(1).max(256),
|
|
758
|
+
size_bytes: z.number().int().nonnegative()
|
|
759
|
+
})
|
|
760
|
+
]);
|
|
761
|
+
//#endregion
|
|
737
762
|
//#region ../contracts/src/conversations/conversation.ts
|
|
738
763
|
const CONVERSATION_ROLES = [
|
|
739
764
|
"user",
|
|
@@ -746,6 +771,7 @@ const ConversationMessageInputSchema = z.object({
|
|
|
746
771
|
message_id: z.string().min(1).max(256),
|
|
747
772
|
role: z.enum(CONVERSATION_ROLES),
|
|
748
773
|
content: z.string().max(262144),
|
|
774
|
+
parts: z.array(ConversationPartSchema).max(256).optional(),
|
|
749
775
|
occurred_at: z.iso.datetime(),
|
|
750
776
|
metadata: ConversationMetadataSchema.default({}),
|
|
751
777
|
identity: ConversationMessageIdentitySchema.nullable().optional()
|
|
@@ -789,7 +815,7 @@ const ConversationActivitySchema = z.object({
|
|
|
789
815
|
ended_at: z.iso.datetime().nullable(),
|
|
790
816
|
outcome: z.string().nullable()
|
|
791
817
|
});
|
|
792
|
-
z.object({
|
|
818
|
+
const ConversationRecordDocumentSchema = z.object({
|
|
793
819
|
schema: z.literal("pocketcoder.conversation-record/v1"),
|
|
794
820
|
turn_id: z.uuid().nullable(),
|
|
795
821
|
request: ConversationRequestIdentitySchema.nullable(),
|
|
@@ -850,7 +876,10 @@ const ViewSessionSchema = z.discriminatedUnion("mode", [
|
|
|
850
876
|
parentOrigin: HttpsOriginSchema
|
|
851
877
|
})
|
|
852
878
|
]);
|
|
853
|
-
z.strictObject({
|
|
879
|
+
z.strictObject({
|
|
880
|
+
session: ViewSessionSchema.default({ mode: "local" }),
|
|
881
|
+
grantId: z.uuid().optional()
|
|
882
|
+
}).refine((input) => input.session.mode === "local" || !!input.grantId, "Cloud previews require a grant");
|
|
854
883
|
//#endregion
|
|
855
884
|
//#region ../contracts/src/displays/display.ts
|
|
856
885
|
const DisplaySchema = z.strictObject({ mode: z.enum(["desktop", "browser"]) });
|
|
@@ -1022,7 +1051,7 @@ const ExportObjectReferenceSchema = z.strictObject({
|
|
|
1022
1051
|
mediaType: AttachmentMediaTypeSchema,
|
|
1023
1052
|
digest: WorkloadDigestSchema
|
|
1024
1053
|
});
|
|
1025
|
-
z.strictObject({
|
|
1054
|
+
const WorkloadExportReferenceSchema = z.strictObject({
|
|
1026
1055
|
exportId: z.uuid(),
|
|
1027
1056
|
execution: WorkloadExecutionReferenceSchema,
|
|
1028
1057
|
manifestDigest: WorkloadDigestSchema,
|
|
@@ -1031,6 +1060,11 @@ z.strictObject({
|
|
|
1031
1060
|
"partial",
|
|
1032
1061
|
"lost"
|
|
1033
1062
|
]),
|
|
1063
|
+
cleanupState: z.enum([
|
|
1064
|
+
"not_required",
|
|
1065
|
+
"pending",
|
|
1066
|
+
"complete"
|
|
1067
|
+
]).optional(),
|
|
1034
1068
|
publication: z.enum([
|
|
1035
1069
|
"published",
|
|
1036
1070
|
"unavailable",
|
|
@@ -1057,6 +1091,11 @@ z.strictObject({
|
|
|
1057
1091
|
path: ["expiresAt"],
|
|
1058
1092
|
message: "export retention must be positive"
|
|
1059
1093
|
});
|
|
1094
|
+
if (value.completeness === "complete" !== (value.errors.length === 0)) ctx.addIssue({
|
|
1095
|
+
code: "custom",
|
|
1096
|
+
path: ["errors"],
|
|
1097
|
+
message: "Export errors must agree with completeness"
|
|
1098
|
+
});
|
|
1060
1099
|
const ids = value.objects.map((object) => object.objectId);
|
|
1061
1100
|
if (new Set(ids).size !== ids.length) ctx.addIssue({
|
|
1062
1101
|
code: "custom",
|
|
@@ -1124,6 +1163,14 @@ const PreviewSocketPayload = z.discriminatedUnion("op", [
|
|
|
1124
1163
|
request_id: z.uuid()
|
|
1125
1164
|
})
|
|
1126
1165
|
]);
|
|
1166
|
+
z.strictObject({
|
|
1167
|
+
id: z.uuid(),
|
|
1168
|
+
subject: z.string().min(1).max(256),
|
|
1169
|
+
accessRevision: z.string().min(1).max(256),
|
|
1170
|
+
previews: z.array(PreviewNameSchema).min(1).max(16).refine((names) => new Set(names).size === names.length, "Preview names must be unique"),
|
|
1171
|
+
ceilingAt: z.iso.datetime()
|
|
1172
|
+
});
|
|
1173
|
+
z.strictObject({ accessRevision: z.string().min(1).max(256) });
|
|
1127
1174
|
//#endregion
|
|
1128
1175
|
//#region ../contracts/src/workspaces/workspace.ts
|
|
1129
1176
|
const WORKSPACE_STATES = [
|
|
@@ -1170,6 +1217,7 @@ const REASON_CODES = [
|
|
|
1170
1217
|
"idle_expired",
|
|
1171
1218
|
"queue_timeout",
|
|
1172
1219
|
"launch_failed",
|
|
1220
|
+
"launch_refused",
|
|
1173
1221
|
"preserve_requested",
|
|
1174
1222
|
"preserved_by_policy",
|
|
1175
1223
|
"checkpoint_created",
|
|
@@ -1190,7 +1238,6 @@ const AGENT_STATES = [
|
|
|
1190
1238
|
"running",
|
|
1191
1239
|
"stable"
|
|
1192
1240
|
];
|
|
1193
|
-
const AgentInterruptResponseSchema = z.object({ status: z.enum(["requested", "idle"]) });
|
|
1194
1241
|
z.object({
|
|
1195
1242
|
external_id: z.string().min(1).max(256),
|
|
1196
1243
|
template: z.object({
|
|
@@ -1206,15 +1253,10 @@ const TemplateRefSchema = z.object({
|
|
|
1206
1253
|
version: z.string(),
|
|
1207
1254
|
digest: z.string()
|
|
1208
1255
|
});
|
|
1209
|
-
const AgentMetadataSchema = z.object({
|
|
1210
|
-
type: z.string(),
|
|
1211
|
-
model: z.string().min(1).max(255).nullable()
|
|
1212
|
-
});
|
|
1213
1256
|
const WorkspaceResourceSchema = z.object({
|
|
1214
1257
|
id: z.uuid(),
|
|
1215
1258
|
external_id: z.string(),
|
|
1216
1259
|
template: TemplateRefSchema,
|
|
1217
|
-
agent: AgentMetadataSchema.nullable(),
|
|
1218
1260
|
state: z.enum(WORKSPACE_STATES),
|
|
1219
1261
|
reason_code: z.enum(REASON_CODES).nullable(),
|
|
1220
1262
|
agent_state: z.enum(AGENT_STATES),
|
|
@@ -1228,6 +1270,10 @@ const WorkspaceResourceSchema = z.object({
|
|
|
1228
1270
|
connected_at: z.iso.datetime().nullable(),
|
|
1229
1271
|
ready_at: z.iso.datetime().nullable(),
|
|
1230
1272
|
deadline_at: z.iso.datetime(),
|
|
1273
|
+
lifetime: z.strictObject({
|
|
1274
|
+
revision: z.number().int().positive(),
|
|
1275
|
+
ceilingAt: z.iso.datetime()
|
|
1276
|
+
}).optional(),
|
|
1231
1277
|
terminal_at: z.iso.datetime().nullable(),
|
|
1232
1278
|
metadata: z.record(z.string(), z.string()),
|
|
1233
1279
|
origin_workspace_id: z.uuid().nullable(),
|
|
@@ -1272,7 +1318,6 @@ const TemplateListItemSchema = z.object({
|
|
|
1272
1318
|
name: z.string(),
|
|
1273
1319
|
version: z.string(),
|
|
1274
1320
|
digest: z.string(),
|
|
1275
|
-
agent: AgentMetadataSchema.nullable(),
|
|
1276
1321
|
description: z.string().optional(),
|
|
1277
1322
|
status: z.enum([
|
|
1278
1323
|
"active",
|
|
@@ -1452,14 +1497,6 @@ const HarnessSchema = z.object({
|
|
|
1452
1497
|
env: EnvSchema.default({}),
|
|
1453
1498
|
cwd: z.string().refine(isAbsolutePath, "expected an absolute path").optional()
|
|
1454
1499
|
});
|
|
1455
|
-
const AgentSchema = HarnessSchema.extend({
|
|
1456
|
-
model: z.string().min(1).max(255).optional().describe("Display metadata only; does not configure the agent model."),
|
|
1457
|
-
type: z.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/).default("custom"),
|
|
1458
|
-
transport: z.enum(["pty", "acp"]).default("pty"),
|
|
1459
|
-
termWidth: z.number().int().min(10).max(65535).optional(),
|
|
1460
|
-
stateFile: z.string().refine(isAbsolutePath, "expected an absolute path").optional(),
|
|
1461
|
-
interruptKeys: z.string().min(1).max(16).optional()
|
|
1462
|
-
});
|
|
1463
1500
|
const TerminalSchema = z.object({
|
|
1464
1501
|
command: CommandSchema,
|
|
1465
1502
|
env: EnvSchema.default({}),
|
|
@@ -1538,7 +1575,7 @@ const CheckpointHookSchema = z.object({
|
|
|
1538
1575
|
env: EnvSchema.default({}),
|
|
1539
1576
|
cwd: z.string().refine(isAbsolutePath, "expected an absolute path").optional()
|
|
1540
1577
|
});
|
|
1541
|
-
const
|
|
1578
|
+
const RuntimeTemplatePolicySchema = z.object({
|
|
1542
1579
|
version: z.string().regex(SEMVER_RE),
|
|
1543
1580
|
image: z.string().regex(IMAGE_DIGEST_RE, { message: "image must be digest-pinned (repo@sha256:<64 hex>)" }),
|
|
1544
1581
|
imagePullSecret: z.string().refine((value) => value.startsWith("secretRef:") && SecretNameSchema.safeParse(value.slice(10)).success, "imagePullSecret must name a stored secret").optional(),
|
|
@@ -1549,7 +1586,6 @@ const TemplateSpecSchema = z.object({
|
|
|
1549
1586
|
"/run/pocketcoder/input"
|
|
1550
1587
|
]),
|
|
1551
1588
|
setup: z.array(SetupStepSchema).max(32).default([]),
|
|
1552
|
-
agent: AgentSchema.optional(),
|
|
1553
1589
|
harness: HarnessSchema.optional(),
|
|
1554
1590
|
terminal: TerminalSchema.optional(),
|
|
1555
1591
|
previews: PreviewsSchema.optional(),
|
|
@@ -1561,59 +1597,14 @@ const TemplateSpecSchema = z.object({
|
|
|
1561
1597
|
security: SecuritySchema.prefault({}),
|
|
1562
1598
|
network: NetworkPolicySchema,
|
|
1563
1599
|
maxLaunchInputBytes: z.number().int().positive().max(1048576).default(65536),
|
|
1564
|
-
compat: z.object({
|
|
1565
|
-
agent: z.string().optional(),
|
|
1566
|
-
agentapi: z.string().optional()
|
|
1567
|
-
}).default({}),
|
|
1568
1600
|
persistence: PersistenceSpecSchema.prefault({}),
|
|
1569
1601
|
source: SourceSpecSchema.nullable().default(null),
|
|
1570
1602
|
checkpointHook: CheckpointHookSchema.optional(),
|
|
1571
1603
|
outputs: z.record(z.string().regex(NAME_RE), OutputDeclarationSchema).default({})
|
|
1572
|
-
})
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
message: "either agent or harness is required"
|
|
1577
|
-
});
|
|
1578
|
-
if (!spec.agent) return;
|
|
1579
|
-
if (spec.agent.transport === "acp") for (const field of [
|
|
1580
|
-
"termWidth",
|
|
1581
|
-
"stateFile",
|
|
1582
|
-
"interruptKeys"
|
|
1583
|
-
]) {
|
|
1584
|
-
if (spec.agent[field] === void 0) continue;
|
|
1585
|
-
ctx.addIssue({
|
|
1586
|
-
code: "custom",
|
|
1587
|
-
path: ["agent", field],
|
|
1588
|
-
message: `${field} is only valid for PTY transport`
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
for (const field of [
|
|
1592
|
-
"harness",
|
|
1593
|
-
"services",
|
|
1594
|
-
"checkpointHook"
|
|
1595
|
-
]) {
|
|
1596
|
-
if (spec[field] === void 0) continue;
|
|
1597
|
-
ctx.addIssue({
|
|
1598
|
-
code: "custom",
|
|
1599
|
-
path: [field],
|
|
1600
|
-
message: `agent cannot be combined with ${field}`
|
|
1601
|
-
});
|
|
1602
|
-
}
|
|
1603
|
-
}).transform((spec) => {
|
|
1604
|
-
if (spec.agent) {
|
|
1605
|
-
const { harness: _harness, services: _services, checkpointHook: _hook, ...native } = spec;
|
|
1606
|
-
return {
|
|
1607
|
-
...native,
|
|
1608
|
-
agent: spec.agent
|
|
1609
|
-
};
|
|
1610
|
-
}
|
|
1611
|
-
const { agent: _agent, ...legacy } = spec;
|
|
1612
|
-
return {
|
|
1613
|
-
...legacy,
|
|
1614
|
-
harness: spec.harness,
|
|
1615
|
-
services: spec.services ?? {}
|
|
1616
|
-
};
|
|
1604
|
+
});
|
|
1605
|
+
const TemplateSpecSchema = RuntimeTemplatePolicySchema.extend({
|
|
1606
|
+
harness: HarnessSchema,
|
|
1607
|
+
services: z.record(z.string().regex(NAME_RE), ServiceSchema).default({})
|
|
1617
1608
|
});
|
|
1618
1609
|
const TemplateManifestBaseSchema = z.object({
|
|
1619
1610
|
apiVersion: z.literal("pocketcoder.dev/v1alpha1", { error: "unsupported template format for the alpha runtime; canonical workloads require an installed workload runtime" }),
|
|
@@ -1664,7 +1655,12 @@ const WaitingRuntimeSpecSchema = z.strictObject({
|
|
|
1664
1655
|
incarnationId: z.string().min(1).max(256),
|
|
1665
1656
|
profile: WorkloadProfileSchema,
|
|
1666
1657
|
operations: z.record(z.string(), HarnessSchema),
|
|
1667
|
-
infrastructure: z.record(z.string(), HarnessSchema)
|
|
1658
|
+
infrastructure: z.record(z.string(), HarnessSchema),
|
|
1659
|
+
serviceHealth: z.record(z.string(), z.strictObject({
|
|
1660
|
+
baseUrl: z.string().url(),
|
|
1661
|
+
healthPath: z.string()
|
|
1662
|
+
})).optional(),
|
|
1663
|
+
manualServices: z.array(z.string()).optional()
|
|
1668
1664
|
});
|
|
1669
1665
|
const ProcessStartPayload = z.strictObject({
|
|
1670
1666
|
execution: ProcessReferenceSchema,
|
|
@@ -1688,6 +1684,11 @@ const ProcessCancelResultPayload = ProcessTargetPayload.extend({
|
|
|
1688
1684
|
])
|
|
1689
1685
|
});
|
|
1690
1686
|
//#endregion
|
|
1687
|
+
//#region ../contracts/src/templates/template-runtime.ts
|
|
1688
|
+
function templateServices(spec) {
|
|
1689
|
+
return spec.services ?? {};
|
|
1690
|
+
}
|
|
1691
|
+
//#endregion
|
|
1691
1692
|
//#region ../contracts/src/secrets/credential-slot.ts
|
|
1692
1693
|
const CredentialSlotSchema = z.strictObject({
|
|
1693
1694
|
policyRef: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._/-]{0,254}$/).refine((value) => !value.includes("..")),
|
|
@@ -1727,22 +1728,18 @@ const WorkloadInputSchema = z.strictObject({
|
|
|
1727
1728
|
//#endregion
|
|
1728
1729
|
//#region ../contracts/src/templates/template-validation.ts
|
|
1729
1730
|
function envSources(spec) {
|
|
1730
|
-
const sources = [[["spec", "env"], spec.env], [
|
|
1731
|
-
"spec",
|
|
1732
|
-
"agent",
|
|
1733
|
-
"env"
|
|
1734
|
-
] : [
|
|
1731
|
+
const sources = [[["spec", "env"], spec.env], [[
|
|
1735
1732
|
"spec",
|
|
1736
1733
|
"harness",
|
|
1737
1734
|
"env"
|
|
1738
|
-
],
|
|
1735
|
+
], spec.harness.env]];
|
|
1739
1736
|
for (const [i, step] of spec.setup.entries()) sources.push([[
|
|
1740
1737
|
"spec",
|
|
1741
1738
|
"setup",
|
|
1742
1739
|
i,
|
|
1743
1740
|
"env"
|
|
1744
1741
|
], step.env]);
|
|
1745
|
-
if (
|
|
1742
|
+
if (spec.checkpointHook) sources.push([[
|
|
1746
1743
|
"spec",
|
|
1747
1744
|
"checkpointHook",
|
|
1748
1745
|
"env"
|
|
@@ -1793,10 +1790,10 @@ function validateServices$1(spec, ctx) {
|
|
|
1793
1790
|
],
|
|
1794
1791
|
message: "healthPath must be a normalized absolute path"
|
|
1795
1792
|
});
|
|
1796
|
-
validateServiceRoutes(serviceName, service.routes, ctx);
|
|
1793
|
+
validateServiceRoutes$1(serviceName, service.routes, ctx);
|
|
1797
1794
|
}
|
|
1798
1795
|
}
|
|
1799
|
-
function validateServiceRoutes(serviceName, routes, ctx) {
|
|
1796
|
+
function validateServiceRoutes$1(serviceName, routes, ctx) {
|
|
1800
1797
|
const seen = /* @__PURE__ */ new Set();
|
|
1801
1798
|
for (const [index, route] of routes.entries()) {
|
|
1802
1799
|
if (!isNormalizedPath(route.path)) ctx.addIssue({
|
|
@@ -1919,7 +1916,6 @@ function validateTemplatePersistence(spec, ctx) {
|
|
|
1919
1916
|
const mounts = spec.persistence.mounts;
|
|
1920
1917
|
for (const [index, mount] of mounts.entries()) validatePersistenceMount(spec, mounts, mount, index, seenNames, ctx);
|
|
1921
1918
|
validateSourceMount(spec, mounts, ctx);
|
|
1922
|
-
validateAgentStateFile(spec, mounts, ctx);
|
|
1923
1919
|
if (spec.persistence.conversationRestore === "supported" && (!spec.persistence.sessionCompatibility || mounts.length < 2)) ctx.addIssue({
|
|
1924
1920
|
code: "custom",
|
|
1925
1921
|
path: [
|
|
@@ -1930,43 +1926,6 @@ function validateTemplatePersistence(spec, ctx) {
|
|
|
1930
1926
|
message: "supported conversation restore requires sessionCompatibility and a separate harness-state mount"
|
|
1931
1927
|
});
|
|
1932
1928
|
}
|
|
1933
|
-
function validateAgentStateFile(spec, mounts, ctx) {
|
|
1934
|
-
if (!spec.agent) return;
|
|
1935
|
-
const stateFile = spec.agent.stateFile;
|
|
1936
|
-
const normalized = stateFile !== void 0 && isNormalizedFilesystemPath(stateFile);
|
|
1937
|
-
if (stateFile !== void 0 && !normalized) ctx.addIssue({
|
|
1938
|
-
code: "custom",
|
|
1939
|
-
path: [
|
|
1940
|
-
"spec",
|
|
1941
|
-
"agent",
|
|
1942
|
-
"stateFile"
|
|
1943
|
-
],
|
|
1944
|
-
message: "stateFile must be a normalized absolute filesystem path"
|
|
1945
|
-
});
|
|
1946
|
-
if (spec.agent.transport === "acp" && spec.persistence.conversationRestore === "supported") {
|
|
1947
|
-
ctx.addIssue({
|
|
1948
|
-
code: "custom",
|
|
1949
|
-
path: [
|
|
1950
|
-
"spec",
|
|
1951
|
-
"persistence",
|
|
1952
|
-
"conversationRestore"
|
|
1953
|
-
],
|
|
1954
|
-
message: "supported conversation restore requires PTY transport"
|
|
1955
|
-
});
|
|
1956
|
-
return;
|
|
1957
|
-
}
|
|
1958
|
-
if (spec.persistence.conversationRestore !== "supported") return;
|
|
1959
|
-
if (normalized && mounts.some((mount) => stateFile.startsWith(`${mount.target}/`))) return;
|
|
1960
|
-
ctx.addIssue({
|
|
1961
|
-
code: "custom",
|
|
1962
|
-
path: [
|
|
1963
|
-
"spec",
|
|
1964
|
-
"agent",
|
|
1965
|
-
"stateFile"
|
|
1966
|
-
],
|
|
1967
|
-
message: "supported conversation restore requires agent.stateFile below a persistence mount"
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
1929
|
function validatePersistenceMount(spec, mounts, mount, index, seenNames, ctx) {
|
|
1971
1930
|
const path = [
|
|
1972
1931
|
"spec",
|
|
@@ -2108,7 +2067,7 @@ function validateAdapters(spec, issue) {
|
|
|
2108
2067
|
const path = ["adapters", name];
|
|
2109
2068
|
if (adapter.kind === "service") {
|
|
2110
2069
|
if (!adapter.service || !Object.hasOwn(spec.services, adapter.service) || adapter.command) issue(path, "service adapters require a declared service and no process command");
|
|
2111
|
-
} else if (!adapter.command || adapter.service) issue(path, "process
|
|
2070
|
+
} else if (!adapter.command || adapter.service) issue(path, "process and Pi adapters require a command and no service reference");
|
|
2112
2071
|
}
|
|
2113
2072
|
}
|
|
2114
2073
|
function validateProcessEnvironment(spec, issue) {
|
|
@@ -2164,16 +2123,24 @@ function validateOperations(spec, issue) {
|
|
|
2164
2123
|
"adapter"
|
|
2165
2124
|
], "operation must name a pinned adapter");
|
|
2166
2125
|
if (spec.profile === "cloud-interactive" && adapter?.kind === "process") issue(["operations", name], "cloud-interactive requires request-aware adapters");
|
|
2167
|
-
|
|
2126
|
+
validateOutputRoots(spec, name, operation.outputRoots, issue);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
function validateOutputRoots(spec, name, roots, issue) {
|
|
2130
|
+
const path = [
|
|
2131
|
+
"operations",
|
|
2132
|
+
name,
|
|
2133
|
+
"outputRoots"
|
|
2134
|
+
];
|
|
2135
|
+
for (const root of roots) {
|
|
2136
|
+
if (!isWorkloadPath(root) || [
|
|
2168
2137
|
"/run",
|
|
2169
2138
|
"/proc",
|
|
2170
2139
|
"/sys",
|
|
2171
2140
|
"/dev"
|
|
2172
|
-
].some((
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
"outputRoots"
|
|
2176
|
-
], "output roots must be normalized and outside protected storage");
|
|
2141
|
+
].some((base) => overlaps(base, root))) issue(path, "output roots must be normalized and outside protected storage");
|
|
2142
|
+
if (spec.lifecycle?.persistence.mounts.some((mount) => overlaps(mount.target, root))) issue(path, "output roots must not overlap checkpoint storage");
|
|
2143
|
+
if (roots.some((other) => other !== root && overlaps(root, other))) issue(path, "output roots must not overlap");
|
|
2177
2144
|
}
|
|
2178
2145
|
}
|
|
2179
2146
|
function serviceUrl(value) {
|
|
@@ -2192,27 +2159,32 @@ function isLoopbackService(url) {
|
|
|
2192
2159
|
}
|
|
2193
2160
|
function validateServices(spec, issue) {
|
|
2194
2161
|
for (const [name, service] of Object.entries(spec.services)) {
|
|
2162
|
+
if (service.autostart === false && service.required) issue(["services", name], "manual services cannot be required for initial readiness");
|
|
2195
2163
|
const url = serviceUrl(service.baseUrl);
|
|
2196
2164
|
if (!url || !isLoopbackService(url)) {
|
|
2197
2165
|
issue(["services", name], "service must use loopback HTTP without credentials or a path");
|
|
2198
2166
|
continue;
|
|
2199
2167
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2168
|
+
validateServiceRoutes(name, service, issue);
|
|
2169
|
+
const privateTransport = Object.values(spec.adapters).some((adapter) => adapter.service === name);
|
|
2170
|
+
for (const [previewName, preview] of Object.entries(spec.previews)) if (privateTransport && preview.port === Number(url.port || 80)) issue(["previews", previewName], "preview port is reserved by a service");
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
function validateServiceRoutes(name, service, issue) {
|
|
2174
|
+
const routes = /* @__PURE__ */ new Set();
|
|
2175
|
+
if (!isNormalizedPath(service.healthPath)) issue([
|
|
2176
|
+
"services",
|
|
2177
|
+
name,
|
|
2178
|
+
"healthPath"
|
|
2179
|
+
], "health path must be normalized");
|
|
2180
|
+
for (const route of service.routes) {
|
|
2181
|
+
const key = `${route.method} ${route.path}`;
|
|
2182
|
+
if (!isNormalizedPath(route.path) || routes.has(key)) issue([
|
|
2202
2183
|
"services",
|
|
2203
2184
|
name,
|
|
2204
|
-
"
|
|
2205
|
-
], "
|
|
2206
|
-
|
|
2207
|
-
const key = `${route.method} ${route.path}`;
|
|
2208
|
-
if (!isNormalizedPath(route.path) || routes.has(key)) issue([
|
|
2209
|
-
"services",
|
|
2210
|
-
name,
|
|
2211
|
-
"routes"
|
|
2212
|
-
], "routes must be normalized and unique");
|
|
2213
|
-
routes.add(key);
|
|
2214
|
-
}
|
|
2215
|
-
for (const [previewName, preview] of Object.entries(spec.previews)) if (preview.port === Number(url.port || 80)) issue(["previews", previewName], "preview port is reserved by a service");
|
|
2185
|
+
"routes"
|
|
2186
|
+
], "routes must be normalized and unique");
|
|
2187
|
+
routes.add(key);
|
|
2216
2188
|
}
|
|
2217
2189
|
}
|
|
2218
2190
|
function validateWorkloadTemplate(manifest, ctx) {
|
|
@@ -2243,8 +2215,7 @@ const WorkloadAdapterSchema = z.strictObject({
|
|
|
2243
2215
|
kind: z.enum([
|
|
2244
2216
|
"process",
|
|
2245
2217
|
"service",
|
|
2246
|
-
"pi"
|
|
2247
|
-
"agentapi"
|
|
2218
|
+
"pi"
|
|
2248
2219
|
]),
|
|
2249
2220
|
digest: WorkloadDigestSchema,
|
|
2250
2221
|
protocol: z.string().min(1).max(128),
|
|
@@ -2269,11 +2240,15 @@ const WorkloadTemplateSchema = z.strictObject({
|
|
|
2269
2240
|
spec: z.strictObject({
|
|
2270
2241
|
version: z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/),
|
|
2271
2242
|
image: WorkloadImageSchema,
|
|
2243
|
+
imagePullSecret: RuntimeTemplatePolicySchema.shape.imagePullSecret,
|
|
2272
2244
|
runtime: WorkloadRuntimePinSchema,
|
|
2273
2245
|
profile: WorkloadProfileSchema,
|
|
2274
2246
|
adapters: z.record(WorkloadNameSchema, WorkloadAdapterSchema),
|
|
2275
2247
|
operations: z.record(WorkloadNameSchema, WorkloadOperationSchema),
|
|
2276
|
-
services: z.record(WorkloadNameSchema, ServiceSchema.extend({
|
|
2248
|
+
services: z.record(WorkloadNameSchema, ServiceSchema.extend({
|
|
2249
|
+
process: HarnessSchema.strict().optional(),
|
|
2250
|
+
autostart: z.boolean().optional()
|
|
2251
|
+
}).strict()),
|
|
2277
2252
|
previews: PreviewsSchema,
|
|
2278
2253
|
credentialSlots: z.record(WorkloadNameSchema, CredentialSlotSchema),
|
|
2279
2254
|
resources: ResourcesSchema.strict(),
|
|
@@ -2300,65 +2275,6 @@ const WorkloadTemplateSnapshotSchema = z.strictObject({
|
|
|
2300
2275
|
message: "snapshot identity does not match its immutable manifest"
|
|
2301
2276
|
});
|
|
2302
2277
|
});
|
|
2303
|
-
//#endregion
|
|
2304
|
-
//#region ../contracts/src/templates/template-runtime.ts
|
|
2305
|
-
const LEGACY_AGENTAPI_SERVICE = ServiceSchema.parse({
|
|
2306
|
-
baseUrl: "http://127.0.0.1:3284",
|
|
2307
|
-
routes: [
|
|
2308
|
-
{
|
|
2309
|
-
method: "GET",
|
|
2310
|
-
path: "/status"
|
|
2311
|
-
},
|
|
2312
|
-
{
|
|
2313
|
-
method: "GET",
|
|
2314
|
-
path: "/messages",
|
|
2315
|
-
query: ["after"]
|
|
2316
|
-
},
|
|
2317
|
-
{
|
|
2318
|
-
method: "POST",
|
|
2319
|
-
path: "/message"
|
|
2320
|
-
}
|
|
2321
|
-
]
|
|
2322
|
-
});
|
|
2323
|
-
const AGENTAPI_SERVICE = ServiceSchema.parse({
|
|
2324
|
-
...LEGACY_AGENTAPI_SERVICE,
|
|
2325
|
-
routes: [...LEGACY_AGENTAPI_SERVICE.routes, {
|
|
2326
|
-
method: "GET",
|
|
2327
|
-
path: "/events",
|
|
2328
|
-
responseMode: "stream",
|
|
2329
|
-
maxResponseBytes: 4194304,
|
|
2330
|
-
deadlineSeconds: 300
|
|
2331
|
-
}]
|
|
2332
|
-
});
|
|
2333
|
-
function isAgentApiNative(spec) {
|
|
2334
|
-
return "agent" in spec && spec.agent !== void 0;
|
|
2335
|
-
}
|
|
2336
|
-
function agentApiHarness(spec) {
|
|
2337
|
-
if (!isAgentApiNative(spec)) {
|
|
2338
|
-
if (!spec.harness) throw new Error("A workload infrastructure process is not an alpha harness.");
|
|
2339
|
-
return spec.harness;
|
|
2340
|
-
}
|
|
2341
|
-
return {
|
|
2342
|
-
command: [
|
|
2343
|
-
"/usr/local/bin/agentapi",
|
|
2344
|
-
"server",
|
|
2345
|
-
"--type",
|
|
2346
|
-
spec.agent.type,
|
|
2347
|
-
...spec.agent.transport === "acp" ? ["--experimental-acp"] : [],
|
|
2348
|
-
...spec.agent.termWidth === void 0 ? [] : ["--term-width", String(spec.agent.termWidth)],
|
|
2349
|
-
...spec.agent.stateFile === void 0 ? [] : ["--state-file", spec.agent.stateFile],
|
|
2350
|
-
"--port",
|
|
2351
|
-
"3284",
|
|
2352
|
-
"--",
|
|
2353
|
-
...spec.agent.command
|
|
2354
|
-
],
|
|
2355
|
-
env: spec.agent.env,
|
|
2356
|
-
...spec.agent.cwd ? { cwd: spec.agent.cwd } : {}
|
|
2357
|
-
};
|
|
2358
|
-
}
|
|
2359
|
-
function templateServices(spec) {
|
|
2360
|
-
return isAgentApiNative(spec) ? { agent: AGENTAPI_SERVICE } : spec.services ?? {};
|
|
2361
|
-
}
|
|
2362
2278
|
z.object({
|
|
2363
2279
|
name: z.string(),
|
|
2364
2280
|
version: z.string(),
|
|
@@ -2428,7 +2344,6 @@ const CheckpointUploadStatusPayload = z.object({
|
|
|
2428
2344
|
const SOURCE_CREDENTIAL_MAX_BYTES = 65536;
|
|
2429
2345
|
const RestoreModeSchema = z.enum(["provider_installed", "controller_archive"]);
|
|
2430
2346
|
const ExecSpecSchema = z.object({
|
|
2431
|
-
agentapi_native: z.boolean().default(false),
|
|
2432
2347
|
setup: z.array(SetupStepSchema),
|
|
2433
2348
|
harness: HarnessSchema.nullable(),
|
|
2434
2349
|
workload: WaitingRuntimeSpecSchema.optional(),
|
|
@@ -2705,7 +2620,8 @@ const EnvelopeBase = z.object({
|
|
|
2705
2620
|
z.literal(10),
|
|
2706
2621
|
z.literal(11),
|
|
2707
2622
|
z.literal(12),
|
|
2708
|
-
z.literal(13)
|
|
2623
|
+
z.literal(13),
|
|
2624
|
+
z.literal(14)
|
|
2709
2625
|
]),
|
|
2710
2626
|
workspace_id: z.uuid(),
|
|
2711
2627
|
connection_id: z.uuid(),
|
|
@@ -2719,25 +2635,17 @@ const RegisteredPayload = z.object({
|
|
|
2719
2635
|
version: z.string(),
|
|
2720
2636
|
digest: z.string()
|
|
2721
2637
|
}),
|
|
2722
|
-
agentapi_version: z.string().optional(),
|
|
2723
2638
|
services: z.array(z.string()),
|
|
2724
2639
|
pid: z.number().int().positive()
|
|
2725
2640
|
});
|
|
2726
|
-
const HeartbeatPayload = z.object({
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
]),
|
|
2735
|
-
agentapi_state: z.enum([
|
|
2736
|
-
"unknown",
|
|
2737
|
-
"stable",
|
|
2738
|
-
"running"
|
|
2739
|
-
]).optional()
|
|
2740
|
-
});
|
|
2641
|
+
const HeartbeatPayload = z.object({ child: z.enum([
|
|
2642
|
+
"starting",
|
|
2643
|
+
"setup",
|
|
2644
|
+
"waiting",
|
|
2645
|
+
"running",
|
|
2646
|
+
"exited",
|
|
2647
|
+
"terminating"
|
|
2648
|
+
]) });
|
|
2741
2649
|
const ProcessStatePayload = z.object({
|
|
2742
2650
|
phase: z.enum([
|
|
2743
2651
|
"starting",
|
|
@@ -3140,194 +3048,758 @@ z.strictObject({
|
|
|
3140
3048
|
root: fileIdentity,
|
|
3141
3049
|
lock: fileIdentity
|
|
3142
3050
|
});
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3051
|
+
//#endregion
|
|
3052
|
+
//#region ../contracts/src/budgets/policy.ts
|
|
3053
|
+
const BudgetPolicyWriteSchema = z.strictObject({
|
|
3054
|
+
scopeId: z.uuid(),
|
|
3055
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3056
|
+
period: z.enum(["utc_day", "utc_month"]),
|
|
3057
|
+
limits: z.strictObject({
|
|
3058
|
+
workspaceStarts: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
3059
|
+
maxActiveWorkspaces: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
3060
|
+
maxRunningRequestsPerSession: z.literal(1),
|
|
3061
|
+
maxChatProcessesPerWorkspace: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER)
|
|
3062
|
+
})
|
|
3147
3063
|
});
|
|
3148
|
-
z.
|
|
3064
|
+
const BudgetPolicySchema = BudgetPolicyWriteSchema.extend({ effectiveAt: z.iso.datetime({ offset: true }) });
|
|
3065
|
+
//#endregion
|
|
3066
|
+
//#region ../contracts/src/budgets/usage.ts
|
|
3067
|
+
const BudgetUsageSchema = z.strictObject({
|
|
3068
|
+
scopeId: z.uuid(),
|
|
3069
|
+
policyRevision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3070
|
+
periodStart: z.iso.datetime({ offset: true }),
|
|
3071
|
+
periodEnd: z.iso.datetime({ offset: true }),
|
|
3072
|
+
workspaceStarts: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
3073
|
+
activeWorkspaces: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
3074
|
+
asOf: z.iso.datetime({ offset: true })
|
|
3075
|
+
});
|
|
3076
|
+
const CleanupReceiptFieldsSchema = z.strictObject({
|
|
3077
|
+
workspaceId: z.uuid(),
|
|
3078
|
+
generationId: z.string().min(1).max(256),
|
|
3079
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3080
|
+
state: z.enum(["pending", "proved"]),
|
|
3081
|
+
basis: z.enum([
|
|
3082
|
+
"never_launched",
|
|
3083
|
+
"processes_exited",
|
|
3084
|
+
"provider_fenced"
|
|
3085
|
+
]).nullable(),
|
|
3086
|
+
observedAt: z.iso.datetime({ offset: true }),
|
|
3087
|
+
capacityReleasedAt: z.iso.datetime({ offset: true }).nullable()
|
|
3088
|
+
});
|
|
3089
|
+
const CleanupReceiptSchema = z.union([CleanupReceiptFieldsSchema.extend({
|
|
3090
|
+
state: z.literal("pending"),
|
|
3091
|
+
basis: z.null(),
|
|
3092
|
+
capacityReleasedAt: z.null()
|
|
3093
|
+
}), CleanupReceiptFieldsSchema.extend({
|
|
3094
|
+
state: z.literal("proved"),
|
|
3095
|
+
basis: z.enum([
|
|
3096
|
+
"never_launched",
|
|
3097
|
+
"processes_exited",
|
|
3098
|
+
"provider_fenced"
|
|
3099
|
+
])
|
|
3100
|
+
})]);
|
|
3101
|
+
//#endregion
|
|
3102
|
+
//#region ../contracts/src/workspaces/lifetime.ts
|
|
3103
|
+
const LifetimeExtensionSchema = z.strictObject({
|
|
3104
|
+
extensionId: z.uuid(),
|
|
3105
|
+
expectedRevision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
3106
|
+
deadlineAt: z.iso.datetime()
|
|
3107
|
+
});
|
|
3108
|
+
const LifetimeReceiptSchema = LifetimeExtensionSchema.extend({
|
|
3109
|
+
workspaceId: z.uuid(),
|
|
3110
|
+
revision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
3111
|
+
ceilingAt: z.iso.datetime()
|
|
3112
|
+
});
|
|
3113
|
+
//#endregion
|
|
3114
|
+
//#region ../contracts/src/workspaces/service-control.ts
|
|
3115
|
+
const ServiceStartSchema = z.strictObject({ startId: z.uuid() });
|
|
3116
|
+
const ServiceReceiptSchema = z.strictObject({
|
|
3149
3117
|
workspaceId: z.uuid(),
|
|
3150
3118
|
incarnationId: z.string().min(1).max(256),
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3119
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{0,62}$/),
|
|
3120
|
+
startId: z.uuid().nullable(),
|
|
3121
|
+
attemptId: z.uuid().nullable(),
|
|
3122
|
+
state: z.enum([
|
|
3123
|
+
"stopped",
|
|
3124
|
+
"starting",
|
|
3125
|
+
"running",
|
|
3126
|
+
"exited",
|
|
3127
|
+
"lost"
|
|
3128
|
+
]),
|
|
3129
|
+
pid: z.number().int().positive().nullable(),
|
|
3130
|
+
exitCode: z.number().int().nullable(),
|
|
3131
|
+
listener: z.enum([
|
|
3132
|
+
"unknown",
|
|
3133
|
+
"healthy",
|
|
3134
|
+
"unhealthy"
|
|
3135
|
+
])
|
|
3157
3136
|
});
|
|
3158
3137
|
//#endregion
|
|
3159
|
-
//#region ../contracts/src/
|
|
3160
|
-
const
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
]);
|
|
3169
|
-
z.strictObject({
|
|
3170
|
-
acceptance: WorkloadAcceptanceSchema,
|
|
3171
|
-
conversationIdentity: ConversationRequestIdentitySchema.nullable(),
|
|
3172
|
-
outcome: JsonValueSchema.nullable(),
|
|
3173
|
-
acceptedAt: z.iso.datetime(),
|
|
3174
|
-
dispatchClaimedAt: z.iso.datetime().nullable(),
|
|
3175
|
-
phase: ExecutionPhaseSchema,
|
|
3176
|
-
cancel: z.strictObject({
|
|
3177
|
-
cancelId: z.uuid(),
|
|
3178
|
-
requestedAt: z.iso.datetime()
|
|
3179
|
-
}).nullable(),
|
|
3180
|
-
settledAt: z.iso.datetime().nullable(),
|
|
3181
|
-
acknowledgedAt: z.iso.datetime().nullable(),
|
|
3182
|
-
finalizedAt: z.iso.datetime().nullable()
|
|
3138
|
+
//#region ../contracts/src/sessions/files.ts
|
|
3139
|
+
const MAX_SESSION_FILE_REFERENCES = 1e3;
|
|
3140
|
+
const InputReferenceSchema = z.strictObject({
|
|
3141
|
+
inputId: z.uuid(),
|
|
3142
|
+
versionId: z.uuid(),
|
|
3143
|
+
sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
3144
|
+
name: z.string().min(1).max(255),
|
|
3145
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
3146
|
+
sizeBytes: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
|
|
3183
3147
|
});
|
|
3184
|
-
z.strictObject({
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3148
|
+
const InputUploadSchema = z.strictObject({
|
|
3149
|
+
inputId: z.uuid(),
|
|
3150
|
+
name: z.string().min(1).max(255),
|
|
3151
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
3152
|
+
sizeBytes: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
3153
|
+
sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/)
|
|
3190
3154
|
});
|
|
3191
|
-
|
|
3192
|
-
z.
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3155
|
+
const InputObjectSchema = z.strictObject({
|
|
3156
|
+
sessionId: z.uuid(),
|
|
3157
|
+
reference: InputReferenceSchema,
|
|
3158
|
+
state: z.enum([
|
|
3159
|
+
"uploading",
|
|
3160
|
+
"ready",
|
|
3161
|
+
"rejected",
|
|
3162
|
+
"expired"
|
|
3163
|
+
]),
|
|
3164
|
+
expiresAt: z.iso.datetime({ offset: true })
|
|
3200
3165
|
});
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3166
|
+
const ExportObjectSchema = z.strictObject({
|
|
3167
|
+
exportId: z.uuid(),
|
|
3168
|
+
sessionId: z.uuid(),
|
|
3169
|
+
requestId: z.uuid(),
|
|
3170
|
+
versionId: z.uuid(),
|
|
3171
|
+
sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
3172
|
+
name: z.string().min(1).max(255),
|
|
3173
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
3174
|
+
sizeBytes: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
3175
|
+
completeness: z.enum(["complete", "partial"]),
|
|
3176
|
+
availability: z.enum([
|
|
3177
|
+
"published",
|
|
3178
|
+
"expired",
|
|
3179
|
+
"unavailable"
|
|
3212
3180
|
]),
|
|
3213
|
-
|
|
3214
|
-
})
|
|
3215
|
-
WorkloadCancelSchema.extend({ fingerprint: WorkloadDigestSchema });
|
|
3181
|
+
expiresAt: z.iso.datetime({ offset: true })
|
|
3182
|
+
});
|
|
3216
3183
|
//#endregion
|
|
3217
|
-
//#region src/
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
}
|
|
3184
|
+
//#region ../contracts/src/sessions/collection.ts
|
|
3185
|
+
const fields = z.strictObject({
|
|
3186
|
+
sessionId: z.uuid(),
|
|
3187
|
+
requestId: z.uuid(),
|
|
3188
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3189
|
+
state: z.enum([
|
|
3190
|
+
"pending",
|
|
3191
|
+
"finalizing",
|
|
3192
|
+
"settled"
|
|
3193
|
+
]),
|
|
3194
|
+
completeness: z.enum([
|
|
3195
|
+
"complete",
|
|
3196
|
+
"partial",
|
|
3197
|
+
"lost"
|
|
3198
|
+
]).nullable(),
|
|
3199
|
+
manifestDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/).nullable(),
|
|
3200
|
+
objects: z.array(ExportObjectSchema).max(MAX_SESSION_FILE_REFERENCES),
|
|
3201
|
+
errors: z.array(z.string().min(1).max(512)).max(100),
|
|
3202
|
+
settledAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3203
|
+
expiresAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3204
|
+
cleanupState: z.enum([
|
|
3205
|
+
"not_required",
|
|
3206
|
+
"pending",
|
|
3207
|
+
"complete"
|
|
3208
|
+
])
|
|
3209
|
+
});
|
|
3210
|
+
const CollectionResultSchema = z.union([fields.extend({
|
|
3211
|
+
state: z.enum(["pending", "finalizing"]),
|
|
3212
|
+
completeness: z.null(),
|
|
3213
|
+
manifestDigest: z.null(),
|
|
3214
|
+
settledAt: z.null(),
|
|
3215
|
+
expiresAt: z.null()
|
|
3216
|
+
}), fields.extend({
|
|
3217
|
+
state: z.literal("settled"),
|
|
3218
|
+
completeness: z.enum([
|
|
3219
|
+
"complete",
|
|
3220
|
+
"partial",
|
|
3221
|
+
"lost"
|
|
3222
|
+
]),
|
|
3223
|
+
manifestDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
3224
|
+
settledAt: z.iso.datetime({ offset: true }),
|
|
3225
|
+
expiresAt: z.iso.datetime({ offset: true })
|
|
3226
|
+
})]).superRefine((value, ctx) => {
|
|
3227
|
+
if (value.completeness && value.completeness === "complete" !== (value.errors.length === 0)) ctx.addIssue({
|
|
3228
|
+
code: "custom",
|
|
3229
|
+
path: ["errors"],
|
|
3230
|
+
message: "Collection errors must agree with completeness"
|
|
3231
|
+
});
|
|
3232
|
+
for (const object of value.objects) if (object.sessionId !== value.sessionId || object.requestId !== value.requestId) ctx.addIssue({
|
|
3233
|
+
code: "custom",
|
|
3234
|
+
path: ["objects"],
|
|
3235
|
+
message: "Collection object owner mismatch"
|
|
3236
|
+
});
|
|
3237
|
+
});
|
|
3236
3238
|
//#endregion
|
|
3237
|
-
//#region src/
|
|
3238
|
-
z.
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3239
|
+
//#region ../contracts/src/sessions/profile.ts
|
|
3240
|
+
const ExecutionProfileSchema = z.strictObject({
|
|
3241
|
+
profileId: z.uuid(),
|
|
3242
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3243
|
+
isolationScopeId: z.uuid(),
|
|
3244
|
+
budgetScopeIds: z.array(z.uuid()).min(1).max(1e3).refine((items) => new Set(items).size === items.length, "Values must be unique"),
|
|
3245
|
+
templateDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
3246
|
+
credentialBindingId: z.uuid().nullable()
|
|
3247
|
+
});
|
|
3248
|
+
const SessionCreateSchema = z.strictObject({
|
|
3249
|
+
sessionId: z.uuid(),
|
|
3250
|
+
profileId: z.uuid(),
|
|
3251
|
+
profileRevision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER)
|
|
3252
|
+
});
|
|
3253
|
+
const SessionSchema = z.strictObject({
|
|
3254
|
+
sessionId: z.uuid(),
|
|
3255
|
+
profileId: z.uuid(),
|
|
3256
|
+
profileRevision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3257
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3258
|
+
state: z.enum([
|
|
3259
|
+
"provisioning",
|
|
3260
|
+
"ready",
|
|
3261
|
+
"suspended",
|
|
3262
|
+
"closed",
|
|
3263
|
+
"failed"
|
|
3264
|
+
]),
|
|
3265
|
+
reasonCode: z.string().min(1).max(256).nullable(),
|
|
3266
|
+
createdAt: z.iso.datetime({ offset: true }),
|
|
3267
|
+
updatedAt: z.iso.datetime({ offset: true })
|
|
3268
|
+
});
|
|
3269
|
+
//#endregion
|
|
3270
|
+
//#region ../contracts/src/sessions/request.ts
|
|
3271
|
+
const RequestInputSchema = z.strictObject({
|
|
3272
|
+
requestId: z.uuid(),
|
|
3273
|
+
message: z.string().min(1).max(262144).refine((value) => value.isWellFormed(), "Message must contain valid Unicode").refine((value) => new TextEncoder().encode(value).length <= 262144, "Message exceeds 256 KiB UTF-8"),
|
|
3274
|
+
attachments: z.array(InputReferenceSchema).max(MAX_SESSION_FILE_REFERENCES),
|
|
3275
|
+
dispatchDeadline: z.iso.datetime({ offset: true })
|
|
3276
|
+
});
|
|
3277
|
+
const RequestFieldsSchema = z.strictObject({
|
|
3278
|
+
sessionId: z.uuid(),
|
|
3279
|
+
requestId: z.uuid(),
|
|
3280
|
+
turnId: z.uuid(),
|
|
3281
|
+
inputFingerprint: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
3282
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3283
|
+
state: z.enum([
|
|
3284
|
+
"accepted",
|
|
3285
|
+
"waiting",
|
|
3286
|
+
"running",
|
|
3287
|
+
"checking_outcome",
|
|
3288
|
+
"terminal"
|
|
3289
|
+
]),
|
|
3290
|
+
outcome: z.enum([
|
|
3291
|
+
"completed",
|
|
3292
|
+
"failed",
|
|
3293
|
+
"canceled",
|
|
3294
|
+
"interrupted",
|
|
3295
|
+
"lost"
|
|
3296
|
+
]).nullable(),
|
|
3297
|
+
reasonCode: z.string().min(1).max(256).nullable(),
|
|
3298
|
+
acceptedAt: z.iso.datetime({ offset: true }),
|
|
3299
|
+
startedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3300
|
+
endedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3301
|
+
dispatchDeadline: z.iso.datetime({ offset: true }),
|
|
3302
|
+
collection: CollectionResultSchema,
|
|
3303
|
+
finalResponse: z.string().max(1048576).nullable()
|
|
3304
|
+
});
|
|
3305
|
+
const RequestSchema = z.union([RequestFieldsSchema.extend({
|
|
3306
|
+
state: z.literal("terminal"),
|
|
3307
|
+
outcome: z.enum([
|
|
3308
|
+
"completed",
|
|
3309
|
+
"failed",
|
|
3310
|
+
"canceled",
|
|
3311
|
+
"interrupted",
|
|
3312
|
+
"lost"
|
|
3313
|
+
])
|
|
3314
|
+
}), RequestFieldsSchema.extend({
|
|
3315
|
+
state: z.enum([
|
|
3316
|
+
"accepted",
|
|
3317
|
+
"waiting",
|
|
3318
|
+
"running",
|
|
3319
|
+
"checking_outcome"
|
|
3320
|
+
]),
|
|
3321
|
+
outcome: z.null(),
|
|
3322
|
+
endedAt: z.null()
|
|
3323
|
+
})]).superRefine((request, ctx) => {
|
|
3324
|
+
if (request.sessionId !== request.collection.sessionId || request.requestId !== request.collection.requestId) ctx.addIssue({
|
|
3325
|
+
code: "custom",
|
|
3326
|
+
path: ["collection"],
|
|
3327
|
+
message: "Collection owner mismatch"
|
|
3328
|
+
});
|
|
3329
|
+
});
|
|
3330
|
+
const CancelCommandSchema = z.strictObject({ cancelId: z.uuid() });
|
|
3331
|
+
const CancelReceiptFieldsSchema = z.strictObject({
|
|
3332
|
+
sessionId: z.uuid(),
|
|
3333
|
+
requestId: z.uuid().nullable(),
|
|
3334
|
+
cancelId: z.uuid(),
|
|
3335
|
+
scope: z.enum(["request", "session"]),
|
|
3336
|
+
state: z.enum(["pending", "completed"]),
|
|
3337
|
+
acceptedAt: z.iso.datetime({ offset: true }),
|
|
3338
|
+
completedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3339
|
+
cancelDeadline: z.iso.datetime({ offset: true })
|
|
3340
|
+
});
|
|
3341
|
+
const CancelReceiptSchema = z.union([CancelReceiptFieldsSchema.extend({
|
|
3342
|
+
scope: z.literal("request"),
|
|
3343
|
+
requestId: z.uuid()
|
|
3344
|
+
}), CancelReceiptFieldsSchema.extend({
|
|
3345
|
+
scope: z.literal("session"),
|
|
3346
|
+
requestId: z.null()
|
|
3347
|
+
})]).superRefine((receipt, ctx) => {
|
|
3348
|
+
if (receipt.state === "completed" !== (receipt.completedAt !== null)) ctx.addIssue({
|
|
3349
|
+
code: "custom",
|
|
3350
|
+
path: ["completedAt"],
|
|
3351
|
+
message: "Completion time must agree with state"
|
|
3352
|
+
});
|
|
3353
|
+
});
|
|
3354
|
+
//#endregion
|
|
3355
|
+
//#region ../contracts/src/sessions/event.ts
|
|
3356
|
+
const RuntimeEventFieldsSchema = z.strictObject({
|
|
3357
|
+
eventId: z.uuid(),
|
|
3358
|
+
cursor: z.string().min(1).max(256),
|
|
3359
|
+
sessionId: z.uuid(),
|
|
3360
|
+
requestId: z.uuid().nullable(),
|
|
3361
|
+
sequence: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3362
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
3363
|
+
occurredAt: z.iso.datetime({ offset: true }).nullable(),
|
|
3364
|
+
recordedAt: z.iso.datetime({ offset: true }),
|
|
3365
|
+
kind: z.enum([
|
|
3366
|
+
"session.updated",
|
|
3367
|
+
"request.updated",
|
|
3368
|
+
"output.published"
|
|
3369
|
+
]),
|
|
3370
|
+
data: z.union([
|
|
3371
|
+
SessionSchema,
|
|
3372
|
+
RequestSchema,
|
|
3373
|
+
ExportObjectSchema
|
|
3374
|
+
])
|
|
3375
|
+
});
|
|
3376
|
+
const RuntimeEventSchema = z.discriminatedUnion("kind", [
|
|
3377
|
+
RuntimeEventFieldsSchema.extend({
|
|
3378
|
+
kind: z.literal("session.updated"),
|
|
3379
|
+
requestId: z.null(),
|
|
3380
|
+
data: SessionSchema
|
|
3381
|
+
}),
|
|
3382
|
+
RuntimeEventFieldsSchema.extend({
|
|
3383
|
+
kind: z.literal("request.updated"),
|
|
3384
|
+
requestId: z.uuid(),
|
|
3385
|
+
data: RequestSchema
|
|
3386
|
+
}),
|
|
3387
|
+
RuntimeEventFieldsSchema.extend({
|
|
3388
|
+
kind: z.literal("output.published"),
|
|
3389
|
+
requestId: z.uuid(),
|
|
3390
|
+
data: ExportObjectSchema
|
|
3391
|
+
})
|
|
3392
|
+
]).superRefine((event, ctx) => {
|
|
3393
|
+
if (event.sessionId !== event.data.sessionId) ctx.addIssue({
|
|
3394
|
+
code: "custom",
|
|
3395
|
+
path: ["sessionId"],
|
|
3396
|
+
message: "Session identity mismatch"
|
|
3397
|
+
});
|
|
3398
|
+
if (event.kind !== "session.updated" && event.requestId !== event.data.requestId) ctx.addIssue({
|
|
3399
|
+
code: "custom",
|
|
3400
|
+
path: ["requestId"],
|
|
3401
|
+
message: "Request identity mismatch"
|
|
3402
|
+
});
|
|
3403
|
+
if (event.kind !== "output.published" && event.revision !== event.data.revision) ctx.addIssue({
|
|
3404
|
+
code: "custom",
|
|
3405
|
+
path: ["revision"],
|
|
3406
|
+
message: "Resource revision mismatch"
|
|
3407
|
+
});
|
|
3408
|
+
});
|
|
3409
|
+
const ErrorSchema = z.strictObject({ error: z.strictObject({
|
|
3410
|
+
code: z.string().min(1).max(256),
|
|
3411
|
+
message: z.string().max(512),
|
|
3412
|
+
retry: z.enum([
|
|
3413
|
+
"never",
|
|
3414
|
+
"same_identity",
|
|
3415
|
+
"after_capacity_change",
|
|
3416
|
+
"reconcile"
|
|
3417
|
+
]),
|
|
3418
|
+
retryAfterSeconds: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
3419
|
+
requestId: z.uuid().nullable()
|
|
3420
|
+
}) });
|
|
3421
|
+
//#endregion
|
|
3422
|
+
//#region ../contracts/src/sessions/fingerprint.ts
|
|
3423
|
+
const LogicalRequestInputSchema = RequestInputSchema.extend({
|
|
3424
|
+
sessionId: z.uuid(),
|
|
3425
|
+
profileId: z.uuid(),
|
|
3426
|
+
profileRevision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER)
|
|
3427
|
+
}).superRefine((input, ctx) => {
|
|
3428
|
+
for (const [index, attachment] of input.attachments.entries()) for (const field of ["name", "mediaType"]) if (!attachment[field].isWellFormed()) ctx.addIssue({
|
|
3429
|
+
code: "custom",
|
|
3430
|
+
path: [
|
|
3431
|
+
"attachments",
|
|
3432
|
+
index,
|
|
3433
|
+
field
|
|
3434
|
+
],
|
|
3435
|
+
message: "Invalid Unicode"
|
|
3436
|
+
});
|
|
3437
|
+
});
|
|
3438
|
+
function fingerprintRequest(input) {
|
|
3439
|
+
return digestOf(LogicalRequestInputSchema.parse(input));
|
|
3440
|
+
}
|
|
3441
|
+
//#endregion
|
|
3442
|
+
//#region ../contracts/src/sessions/pages.ts
|
|
3443
|
+
const ManagedHistoryQuerySchema = z.strictObject({
|
|
3444
|
+
cursor: z.string().min(1).max(4096).optional(),
|
|
3445
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
3446
|
+
});
|
|
3447
|
+
const ManagedHistoryPageSchema = z.strictObject({
|
|
3448
|
+
records: z.array(ConversationRecordDocumentSchema),
|
|
3449
|
+
nextCursor: z.string().min(1).max(4096).nullable(),
|
|
3450
|
+
eventCursor: z.string().min(1).max(4096)
|
|
3451
|
+
});
|
|
3452
|
+
const ManagedExportPageSchema = z.strictObject({
|
|
3453
|
+
items: z.array(ExportObjectSchema),
|
|
3454
|
+
nextCursor: z.string().min(1).max(4096).nullable()
|
|
3455
|
+
});
|
|
3456
|
+
//#endregion
|
|
3457
|
+
//#region ../contracts/src/sessions/placement.ts
|
|
3458
|
+
function managedPlacement(principalId, sessionId, input) {
|
|
3459
|
+
const profile = ExecutionProfileSchema.parse(input);
|
|
3460
|
+
const mode = profile.credentialBindingId === null ? "shared" : "exclusive";
|
|
3461
|
+
return {
|
|
3462
|
+
mode,
|
|
3463
|
+
key: digestOf({
|
|
3464
|
+
principalId,
|
|
3465
|
+
profile,
|
|
3466
|
+
sessionId: mode === "exclusive" ? sessionId : null
|
|
3467
|
+
})
|
|
3468
|
+
};
|
|
3469
|
+
}
|
|
3470
|
+
const MANAGED_SESSION_METADATA = "pocketcoder.managed-session";
|
|
3471
|
+
//#endregion
|
|
3472
|
+
//#region ../contracts/src/sessions/provisioning.ts
|
|
3473
|
+
const BudgetScopeGrantSchema = z.strictObject({
|
|
3474
|
+
principalId: z.uuid(),
|
|
3475
|
+
installation: z.boolean()
|
|
3476
|
+
});
|
|
3477
|
+
const CredentialBindingSchema = z.strictObject({
|
|
3478
|
+
bindingId: z.uuid(),
|
|
3479
|
+
principalId: z.uuid(),
|
|
3480
|
+
secretName: z.string().min(1).max(128),
|
|
3481
|
+
secretVersionId: z.uuid().optional(),
|
|
3482
|
+
slots: z.array(z.string().min(1).max(128)).min(1).max(100),
|
|
3483
|
+
authorityExpiresAt: z.iso.datetime({ offset: true })
|
|
3484
|
+
});
|
|
3485
|
+
//#endregion
|
|
3486
|
+
//#region ../contracts/src/sessions/states.ts
|
|
3487
|
+
const requestTransitions = {
|
|
3488
|
+
accepted: [
|
|
3489
|
+
"waiting",
|
|
3490
|
+
"running",
|
|
3491
|
+
"checking_outcome",
|
|
3492
|
+
"terminal"
|
|
3493
|
+
],
|
|
3494
|
+
waiting: [
|
|
3495
|
+
"running",
|
|
3496
|
+
"checking_outcome",
|
|
3497
|
+
"terminal"
|
|
3498
|
+
],
|
|
3499
|
+
running: ["checking_outcome", "terminal"],
|
|
3500
|
+
checking_outcome: ["running", "terminal"],
|
|
3501
|
+
terminal: []
|
|
3252
3502
|
};
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3503
|
+
const sessionTransitions = {
|
|
3504
|
+
provisioning: [
|
|
3505
|
+
"ready",
|
|
3506
|
+
"suspended",
|
|
3507
|
+
"closed",
|
|
3508
|
+
"failed"
|
|
3509
|
+
],
|
|
3510
|
+
ready: [
|
|
3511
|
+
"provisioning",
|
|
3512
|
+
"suspended",
|
|
3513
|
+
"closed",
|
|
3514
|
+
"failed"
|
|
3515
|
+
],
|
|
3516
|
+
suspended: [
|
|
3517
|
+
"provisioning",
|
|
3518
|
+
"closed",
|
|
3519
|
+
"failed"
|
|
3520
|
+
],
|
|
3521
|
+
closed: [],
|
|
3522
|
+
failed: ["provisioning", "closed"]
|
|
3263
3523
|
};
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3524
|
+
const canTransitionRequest = (from, to) => requestTransitions[from].includes(to);
|
|
3525
|
+
const canTransitionSession = (from, to) => sessionTransitions[from].includes(to);
|
|
3526
|
+
const ManagedQueueLimitsSchema = z.strictObject({
|
|
3527
|
+
requests: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
3528
|
+
bytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER)
|
|
3529
|
+
});
|
|
3530
|
+
//#endregion
|
|
3531
|
+
//#region ../contracts/src/sessions/schemas.ts
|
|
3532
|
+
const MANAGED_CONTRACT_REVISION = "pocketcoder.managed/v1";
|
|
3533
|
+
const managedSchemas = {
|
|
3534
|
+
ExecutionProfile: ExecutionProfileSchema,
|
|
3535
|
+
BudgetScopeGrant: BudgetScopeGrantSchema,
|
|
3536
|
+
CredentialBinding: CredentialBindingSchema,
|
|
3537
|
+
SessionCreate: SessionCreateSchema,
|
|
3538
|
+
Session: SessionSchema,
|
|
3539
|
+
InputReference: InputReferenceSchema,
|
|
3540
|
+
InputUpload: InputUploadSchema,
|
|
3541
|
+
InputObject: InputObjectSchema,
|
|
3542
|
+
ExportObject: ExportObjectSchema,
|
|
3543
|
+
CollectionResult: CollectionResultSchema,
|
|
3544
|
+
RequestInput: RequestInputSchema,
|
|
3545
|
+
Request: RequestSchema,
|
|
3546
|
+
CancelCommand: CancelCommandSchema,
|
|
3547
|
+
CancelReceipt: CancelReceiptSchema,
|
|
3548
|
+
RuntimeEvent: RuntimeEventSchema,
|
|
3549
|
+
Error: ErrorSchema,
|
|
3550
|
+
WireError: ErrorEnvelopeSchema,
|
|
3551
|
+
BudgetPolicy: BudgetPolicySchema,
|
|
3552
|
+
BudgetPolicyWrite: BudgetPolicyWriteSchema,
|
|
3553
|
+
BudgetUsage: BudgetUsageSchema,
|
|
3554
|
+
CleanupReceipt: CleanupReceiptSchema,
|
|
3555
|
+
HistoryPage: ManagedHistoryPageSchema,
|
|
3556
|
+
OpenTurns: z.object({ turns: z.array(ConversationLiveEventSchema) }),
|
|
3557
|
+
ExportPage: ManagedExportPageSchema,
|
|
3558
|
+
ServiceStart: ServiceStartSchema,
|
|
3559
|
+
ServiceReceipt: ServiceReceiptSchema,
|
|
3560
|
+
LifetimeExtension: LifetimeExtensionSchema,
|
|
3561
|
+
LifetimeReceipt: LifetimeReceiptSchema,
|
|
3562
|
+
QueueLimits: ManagedQueueLimitsSchema
|
|
3273
3563
|
};
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3564
|
+
//#endregion
|
|
3565
|
+
//#region ../contracts/src/sessions/index.ts
|
|
3566
|
+
var sessions_exports = /* @__PURE__ */ __exportAll({
|
|
3567
|
+
BudgetPolicySchema: () => BudgetPolicySchema,
|
|
3568
|
+
BudgetPolicyWriteSchema: () => BudgetPolicyWriteSchema,
|
|
3569
|
+
BudgetUsageSchema: () => BudgetUsageSchema,
|
|
3570
|
+
CancelCommandSchema: () => CancelCommandSchema,
|
|
3571
|
+
CancelReceiptSchema: () => CancelReceiptSchema,
|
|
3572
|
+
CleanupReceiptSchema: () => CleanupReceiptSchema,
|
|
3573
|
+
CollectionResultSchema: () => CollectionResultSchema,
|
|
3574
|
+
ErrorSchema: () => ErrorSchema,
|
|
3575
|
+
ExecutionProfileSchema: () => ExecutionProfileSchema,
|
|
3576
|
+
ExportObjectSchema: () => ExportObjectSchema,
|
|
3577
|
+
InputObjectSchema: () => InputObjectSchema,
|
|
3578
|
+
InputReferenceSchema: () => InputReferenceSchema,
|
|
3579
|
+
InputUploadSchema: () => InputUploadSchema,
|
|
3580
|
+
LifetimeExtensionSchema: () => LifetimeExtensionSchema,
|
|
3581
|
+
LifetimeReceiptSchema: () => LifetimeReceiptSchema,
|
|
3582
|
+
LogicalRequestInputSchema: () => LogicalRequestInputSchema,
|
|
3583
|
+
MANAGED_CONTRACT_REVISION: () => MANAGED_CONTRACT_REVISION,
|
|
3584
|
+
MANAGED_SESSION_METADATA: () => MANAGED_SESSION_METADATA,
|
|
3585
|
+
MAX_SESSION_FILE_REFERENCES: () => MAX_SESSION_FILE_REFERENCES,
|
|
3586
|
+
ManagedExportPageSchema: () => ManagedExportPageSchema,
|
|
3587
|
+
ManagedHistoryPageSchema: () => ManagedHistoryPageSchema,
|
|
3588
|
+
ManagedHistoryQuerySchema: () => ManagedHistoryQuerySchema,
|
|
3589
|
+
ManagedQueueLimitsSchema: () => ManagedQueueLimitsSchema,
|
|
3590
|
+
RequestInputSchema: () => RequestInputSchema,
|
|
3591
|
+
RequestSchema: () => RequestSchema,
|
|
3592
|
+
RuntimeEventSchema: () => RuntimeEventSchema,
|
|
3593
|
+
ServiceReceiptSchema: () => ServiceReceiptSchema,
|
|
3594
|
+
ServiceStartSchema: () => ServiceStartSchema,
|
|
3595
|
+
SessionCreateSchema: () => SessionCreateSchema,
|
|
3596
|
+
SessionSchema: () => SessionSchema,
|
|
3597
|
+
canTransitionRequest: () => canTransitionRequest,
|
|
3598
|
+
canTransitionSession: () => canTransitionSession,
|
|
3599
|
+
fingerprintRequest: () => fingerprintRequest,
|
|
3600
|
+
managedPlacement: () => managedPlacement,
|
|
3601
|
+
managedSchemas: () => managedSchemas
|
|
3602
|
+
});
|
|
3603
|
+
//#endregion
|
|
3604
|
+
//#region ../contracts/src/templates/session-template.ts
|
|
3605
|
+
function sessionTemplate(input) {
|
|
3606
|
+
const protocol = "pocketcoder.execution/v1";
|
|
3607
|
+
const { producer } = input;
|
|
3608
|
+
return WorkloadTemplateSchema.parse({
|
|
3609
|
+
apiVersion: "pocketcoder.dev/v1",
|
|
3610
|
+
kind: "Template",
|
|
3611
|
+
metadata: { name: input.name },
|
|
3612
|
+
spec: {
|
|
3613
|
+
version: input.version,
|
|
3614
|
+
image: input.image,
|
|
3615
|
+
profile: "service",
|
|
3616
|
+
runtime: {
|
|
3617
|
+
protocol: "pocketcoder.workload/v1",
|
|
3618
|
+
digest: input.runtimeDigest
|
|
3619
|
+
},
|
|
3620
|
+
adapters: { session: {
|
|
3621
|
+
kind: "service",
|
|
3622
|
+
digest: producer.digest,
|
|
3623
|
+
protocol,
|
|
3624
|
+
service: "session",
|
|
3625
|
+
env: {}
|
|
3626
|
+
} },
|
|
3627
|
+
operations: { message: {
|
|
3628
|
+
adapter: "session",
|
|
3629
|
+
inputSchema: {
|
|
3630
|
+
type: "object",
|
|
3631
|
+
properties: { message: { type: "string" } },
|
|
3632
|
+
required: ["message"],
|
|
3633
|
+
additionalProperties: false
|
|
3634
|
+
},
|
|
3635
|
+
requiredCapabilities: [
|
|
3636
|
+
"request-lookup",
|
|
3637
|
+
"deduplicated-accept",
|
|
3638
|
+
"targeted-cancel"
|
|
3639
|
+
],
|
|
3640
|
+
outputRoots: []
|
|
3641
|
+
} },
|
|
3642
|
+
services: { session: {
|
|
3643
|
+
...ServiceSchema.parse({
|
|
3644
|
+
baseUrl: "http://127.0.0.1:3284",
|
|
3645
|
+
healthPath: "/healthz",
|
|
3646
|
+
routes: [
|
|
3647
|
+
"accept",
|
|
3648
|
+
"lookup",
|
|
3649
|
+
"cancel",
|
|
3650
|
+
"ack"
|
|
3651
|
+
].map((action) => ({
|
|
3652
|
+
method: "POST",
|
|
3653
|
+
path: `/executions/${action}`,
|
|
3654
|
+
maxRequestBytes: 1048576,
|
|
3655
|
+
maxResponseBytes: 8388608,
|
|
3656
|
+
deadlineSeconds: 30
|
|
3657
|
+
}))
|
|
3658
|
+
}),
|
|
3659
|
+
process: {
|
|
3660
|
+
command: producer.command,
|
|
3661
|
+
env: producer.env ?? {},
|
|
3662
|
+
...producer.cwd ? { cwd: producer.cwd } : {}
|
|
3663
|
+
}
|
|
3664
|
+
} },
|
|
3665
|
+
previews: {},
|
|
3666
|
+
credentialSlots: {},
|
|
3667
|
+
resources: {
|
|
3668
|
+
cpu: "1",
|
|
3669
|
+
memory: "1Gi"
|
|
3670
|
+
},
|
|
3671
|
+
network: { mode: "unrestricted" },
|
|
3672
|
+
security: SecuritySchema.parse({ writableMemoryPaths: ["/tmp"] }),
|
|
3673
|
+
lifecycle: { timeouts: TimeoutsSchema.parse({}) },
|
|
3674
|
+
limits: {
|
|
3675
|
+
deadlineSeconds: 7200,
|
|
3676
|
+
finalizationSeconds: 30,
|
|
3677
|
+
inputFileBytes: 16777216,
|
|
3678
|
+
stagedInputBytes: 67108864,
|
|
3679
|
+
inputFiles: 100,
|
|
3680
|
+
inFlightTransfers: 2,
|
|
3681
|
+
exportBytes: 16777216,
|
|
3682
|
+
exportFiles: 100,
|
|
3683
|
+
unreferencedInputRetentionSeconds: 3600,
|
|
3684
|
+
exportRetentionSeconds: 86400
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3291
3687
|
});
|
|
3292
3688
|
}
|
|
3689
|
+
z.strictObject({ manifest: z.union([TemplateManifestSchema, WorkloadTemplateSchema]) });
|
|
3690
|
+
z.object({
|
|
3691
|
+
name: z.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/),
|
|
3692
|
+
version: z.string().min(1).max(256)
|
|
3693
|
+
});
|
|
3694
|
+
z.strictObject({
|
|
3695
|
+
workspaceId: z.uuid(),
|
|
3696
|
+
incarnationId: z.string().min(1).max(256),
|
|
3697
|
+
profiles: z.array(WorkloadProfileSchema),
|
|
3698
|
+
storageProfiles: z.array(z.enum(["controller-readonly/v1", "shared-writer-readonly/v1"])),
|
|
3699
|
+
ceilings: WorkloadLimitsSchema,
|
|
3700
|
+
now: z.iso.datetime(),
|
|
3701
|
+
expiresAt: z.iso.datetime(),
|
|
3702
|
+
installed: InstalledWorkloadSchema.optional()
|
|
3703
|
+
});
|
|
3704
|
+
z.strictObject({
|
|
3705
|
+
requestId: z.uuid(),
|
|
3706
|
+
conversationId: z.uuid(),
|
|
3707
|
+
message: z.string().min(1).max(262144),
|
|
3708
|
+
files: z.array(InputObjectReferenceSchema).max(1e3)
|
|
3709
|
+
});
|
|
3293
3710
|
//#endregion
|
|
3294
|
-
//#region src/
|
|
3295
|
-
const
|
|
3296
|
-
|
|
3711
|
+
//#region ../contracts/src/workspaces/execution-dispatch.ts
|
|
3712
|
+
const ExecutionPhaseSchema = z.enum([
|
|
3713
|
+
"accepted",
|
|
3714
|
+
"dispatching",
|
|
3715
|
+
"running",
|
|
3716
|
+
"terminal",
|
|
3717
|
+
"canceled",
|
|
3718
|
+
"unknown",
|
|
3719
|
+
"lost"
|
|
3720
|
+
]);
|
|
3721
|
+
const ExecutionRecordSchema = z.strictObject({
|
|
3722
|
+
acceptance: WorkloadAcceptanceSchema,
|
|
3723
|
+
conversationIdentity: ConversationRequestIdentitySchema.nullable(),
|
|
3724
|
+
outcome: JsonValueSchema.nullable(),
|
|
3725
|
+
acceptedAt: z.iso.datetime(),
|
|
3726
|
+
dispatchClaimedAt: z.iso.datetime().nullable(),
|
|
3727
|
+
producerSendClaimedAt: z.iso.datetime().optional(),
|
|
3728
|
+
finalizationBasis: z.enum([
|
|
3729
|
+
"never_sent",
|
|
3730
|
+
"producer_acknowledged",
|
|
3731
|
+
"runtime_fenced"
|
|
3732
|
+
]).optional(),
|
|
3733
|
+
phase: ExecutionPhaseSchema,
|
|
3734
|
+
cancel: z.strictObject({
|
|
3735
|
+
cancelId: z.uuid(),
|
|
3736
|
+
requestedAt: z.iso.datetime()
|
|
3737
|
+
}).nullable(),
|
|
3738
|
+
settledAt: z.iso.datetime().nullable(),
|
|
3739
|
+
acknowledgedAt: z.iso.datetime().nullable(),
|
|
3740
|
+
finalizedAt: z.iso.datetime().nullable(),
|
|
3741
|
+
collection: WorkloadExportReferenceSchema.optional(),
|
|
3742
|
+
publicationComplete: z.boolean().optional()
|
|
3743
|
+
});
|
|
3744
|
+
z.strictObject({
|
|
3745
|
+
acceptance: WorkloadAcceptanceSchema,
|
|
3746
|
+
conversationIdentity: ConversationRequestIdentitySchema.optional()
|
|
3747
|
+
}).refine(({ acceptance, conversationIdentity }) => acceptance.execution.owner !== "conversation-request" || conversationIdentity !== void 0, {
|
|
3748
|
+
path: ["conversationIdentity"],
|
|
3749
|
+
message: "Conversation execution requires a conversation identity."
|
|
3750
|
+
});
|
|
3751
|
+
WorkloadCancelSchema.refine((cancel) => cancel.scope === "operation", { message: "Use workspace release for workspace cancellation" });
|
|
3752
|
+
z.strictObject({
|
|
3753
|
+
workspaceId: z.uuid(),
|
|
3754
|
+
callerPrincipalId: z.uuid(),
|
|
3755
|
+
incarnationId: z.string().min(1),
|
|
3756
|
+
template: WorkloadTemplateSnapshotSchema,
|
|
3757
|
+
producer: InstalledWorkloadSchema,
|
|
3758
|
+
readyAt: z.iso.datetime().nullable(),
|
|
3759
|
+
endedAt: z.iso.datetime().nullable()
|
|
3760
|
+
});
|
|
3761
|
+
z.discriminatedUnion("phase", [z.strictObject({
|
|
3762
|
+
execution: WorkloadExecutionReferenceSchema,
|
|
3763
|
+
phase: z.literal("absent")
|
|
3764
|
+
}), z.strictObject({
|
|
3765
|
+
execution: WorkloadExecutionReferenceSchema,
|
|
3766
|
+
fingerprint: WorkloadDigestSchema,
|
|
3767
|
+
phase: z.enum([
|
|
3768
|
+
"accepted",
|
|
3769
|
+
"running",
|
|
3770
|
+
"terminal",
|
|
3771
|
+
"canceled"
|
|
3772
|
+
]),
|
|
3773
|
+
outcome: JsonValueSchema.nullable(),
|
|
3774
|
+
messages: z.array(ConversationMessageInputSchema).max(1024).optional(),
|
|
3775
|
+
publication: z.strictObject({
|
|
3776
|
+
complete: z.boolean(),
|
|
3777
|
+
objects: z.array(z.strictObject({
|
|
3778
|
+
publicationId: z.uuid(),
|
|
3779
|
+
name: z.string().min(1).max(255),
|
|
3780
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
3781
|
+
sizeBytes: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
3782
|
+
digest: WorkloadDigestSchema,
|
|
3783
|
+
contentBase64: z.string()
|
|
3784
|
+
})).max(1e3)
|
|
3785
|
+
}).optional()
|
|
3786
|
+
})]);
|
|
3787
|
+
WorkloadCancelSchema.extend({ fingerprint: WorkloadDigestSchema });
|
|
3788
|
+
//#endregion
|
|
3789
|
+
//#region src/resources/admin/admin.ts
|
|
3790
|
+
var AdministrationApi = class {
|
|
3297
3791
|
transport;
|
|
3298
|
-
|
|
3299
|
-
constructor(transport, workspaces) {
|
|
3792
|
+
constructor(transport) {
|
|
3300
3793
|
this.transport = transport;
|
|
3301
|
-
this.workspaces = workspaces;
|
|
3302
3794
|
}
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
const response = await this.transport.raw(`/v1/workspaces/${encodeURIComponent(workspaceId)}/agent/message`, {
|
|
3306
|
-
method: "POST",
|
|
3307
|
-
...input.signal ? { signal: input.signal } : {},
|
|
3308
|
-
headers: { "content-type": "application/json" },
|
|
3309
|
-
body: JSON.stringify({
|
|
3310
|
-
type: "user",
|
|
3311
|
-
content: input.content,
|
|
3312
|
-
...input.attachmentIds?.length ? { attachment_ids: input.attachmentIds } : {}
|
|
3313
|
-
})
|
|
3314
|
-
});
|
|
3315
|
-
if (response.ok) return;
|
|
3316
|
-
const text = await response.text();
|
|
3317
|
-
let body;
|
|
3318
|
-
try {
|
|
3319
|
-
body = JSON.parse(text);
|
|
3320
|
-
} catch {
|
|
3321
|
-
throw new PocketCoderError({
|
|
3322
|
-
message: `PocketCoder returned a non-JSON response (${response.status})`,
|
|
3323
|
-
code: "client.non_json_response",
|
|
3324
|
-
status: response.status
|
|
3325
|
-
});
|
|
3326
|
-
}
|
|
3327
|
-
throw responseError(response, body);
|
|
3795
|
+
warmPools(options = {}) {
|
|
3796
|
+
return this.transport.request("/v1/warm-pools", WarmPoolInventorySchema, options);
|
|
3328
3797
|
}
|
|
3329
|
-
|
|
3330
|
-
return this.transport.request(
|
|
3798
|
+
storageInventory(options = {}) {
|
|
3799
|
+
return this.transport.request("/v1/storage/inventory", StorageInventorySchema, options);
|
|
3800
|
+
}
|
|
3801
|
+
pruneStorage(options = {}) {
|
|
3802
|
+
return this.transport.request("/v1/storage/prune", StoragePruneResultSchema, {
|
|
3331
3803
|
method: "POST",
|
|
3332
3804
|
signal: options.signal
|
|
3333
3805
|
});
|
|
@@ -3380,6 +3852,50 @@ var AttachmentsApi = class {
|
|
|
3380
3852
|
}
|
|
3381
3853
|
};
|
|
3382
3854
|
//#endregion
|
|
3855
|
+
//#region src/resources/budgets/budgets.ts
|
|
3856
|
+
const scopePath = (scopeId) => `/v1/budget-scopes/${encodeURIComponent(scopeId)}`;
|
|
3857
|
+
var ManagedAuthorityApi = class {
|
|
3858
|
+
transport;
|
|
3859
|
+
constructor(transport) {
|
|
3860
|
+
this.transport = transport;
|
|
3861
|
+
}
|
|
3862
|
+
async grantScope(scopeId, grant, options = {}) {
|
|
3863
|
+
await this.transport.request(`${scopePath(scopeId)}/grant`, z.undefined(), {
|
|
3864
|
+
...options,
|
|
3865
|
+
method: "PUT",
|
|
3866
|
+
body: JSON.stringify(managedSchemas.BudgetScopeGrant.parse(grant))
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
putPolicy(policy, expectedRevision, options = {}) {
|
|
3870
|
+
return this.transport.request(`${scopePath(policy.scopeId)}/policy`, BudgetPolicySchema, {
|
|
3871
|
+
...options,
|
|
3872
|
+
method: "PUT",
|
|
3873
|
+
body: JSON.stringify(BudgetPolicyWriteSchema.parse(policy)),
|
|
3874
|
+
headers: expectedRevision === null ? { "if-none-match": "*" } : { "if-match": `"${expectedRevision}"` }
|
|
3875
|
+
});
|
|
3876
|
+
}
|
|
3877
|
+
getPolicy(scopeId, options = {}) {
|
|
3878
|
+
return this.transport.request(`${scopePath(scopeId)}/policy`, BudgetPolicySchema, options);
|
|
3879
|
+
}
|
|
3880
|
+
usage(scopeId, options = {}) {
|
|
3881
|
+
return this.transport.request(`${scopePath(scopeId)}/usage`, BudgetUsageSchema, options);
|
|
3882
|
+
}
|
|
3883
|
+
putProfile(principalId, profile, options = {}) {
|
|
3884
|
+
return this.transport.request(`/v1/execution-profiles/${encodeURIComponent(profile.profileId)}/revisions/${profile.revision}?principalId=${encodeURIComponent(principalId)}`, ExecutionProfileSchema, {
|
|
3885
|
+
...options,
|
|
3886
|
+
method: "PUT",
|
|
3887
|
+
body: JSON.stringify(ExecutionProfileSchema.parse(profile))
|
|
3888
|
+
});
|
|
3889
|
+
}
|
|
3890
|
+
async putCredentialBinding(binding, options = {}) {
|
|
3891
|
+
await this.transport.request(`/v1/credential-bindings/${encodeURIComponent(binding.bindingId)}`, z.undefined(), {
|
|
3892
|
+
...options,
|
|
3893
|
+
method: "PUT",
|
|
3894
|
+
body: JSON.stringify(managedSchemas.CredentialBinding.parse(binding))
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3897
|
+
};
|
|
3898
|
+
//#endregion
|
|
3383
3899
|
//#region src/transport/common.ts
|
|
3384
3900
|
function queryString(values) {
|
|
3385
3901
|
const params = new URLSearchParams();
|
|
@@ -3509,8 +4025,95 @@ var ConversationsApi = class {
|
|
|
3509
4025
|
const response = await this.transport.stream(path, options.signal);
|
|
3510
4026
|
if (response.body) yield* liveEvents(response.body);
|
|
3511
4027
|
}
|
|
4028
|
+
async open(id, options = {}) {
|
|
4029
|
+
return this.transport.request(`${workspacePath(id)}/conversation/open${options.conversationId ? `?${queryString({ conversationId: options.conversationId })}` : ""}`, z.object({ turns: z.array(ConversationLiveEventSchema) }), options);
|
|
4030
|
+
}
|
|
4031
|
+
};
|
|
4032
|
+
//#endregion
|
|
4033
|
+
//#region src/resources/conversations/requests.ts
|
|
4034
|
+
const path = (workspaceId) => `/v1/workspaces/${encodeURIComponent(workspaceId)}/requests`;
|
|
4035
|
+
var WorkspaceRequestsApi = class {
|
|
4036
|
+
transport;
|
|
4037
|
+
constructor(transport) {
|
|
4038
|
+
this.transport = transport;
|
|
4039
|
+
}
|
|
4040
|
+
submit(workspaceId, input, options = {}) {
|
|
4041
|
+
return this.transport.request(path(workspaceId), ExecutionRecordSchema, {
|
|
4042
|
+
...options,
|
|
4043
|
+
method: "POST",
|
|
4044
|
+
body: JSON.stringify(input)
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
get(workspaceId, requestId, conversationId, options = {}) {
|
|
4048
|
+
return this.transport.request(`${path(workspaceId)}/${encodeURIComponent(requestId)}?${queryString({ conversationId })}`, ExecutionRecordSchema, options);
|
|
4049
|
+
}
|
|
4050
|
+
list(workspaceId, query, options = {}) {
|
|
4051
|
+
return this.transport.request(`${path(workspaceId)}?${queryString(query)}`, z.object({
|
|
4052
|
+
items: z.array(ExecutionRecordSchema),
|
|
4053
|
+
next_cursor: z.uuid().nullable()
|
|
4054
|
+
}), options);
|
|
4055
|
+
}
|
|
4056
|
+
cancel(record, cancelId, options = {}) {
|
|
4057
|
+
const execution = record.acceptance.execution;
|
|
4058
|
+
return this.transport.request(`/v1/workspaces/${encodeURIComponent(execution.workspaceId)}/executions/${encodeURIComponent(execution.requestId)}/cancel`, ExecutionRecordSchema, {
|
|
4059
|
+
...options,
|
|
4060
|
+
method: "POST",
|
|
4061
|
+
body: JSON.stringify({
|
|
4062
|
+
execution,
|
|
4063
|
+
cancelId,
|
|
4064
|
+
scope: "operation"
|
|
4065
|
+
})
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
3512
4068
|
};
|
|
3513
4069
|
//#endregion
|
|
4070
|
+
//#region src/transport/errors.ts
|
|
4071
|
+
z.enum(["client.non_json_response", "client.invalid_response"]);
|
|
4072
|
+
var PocketCoderError = class extends Error {
|
|
4073
|
+
code;
|
|
4074
|
+
status;
|
|
4075
|
+
requestId;
|
|
4076
|
+
details;
|
|
4077
|
+
constructor(input) {
|
|
4078
|
+
super(input.message);
|
|
4079
|
+
this.name = "PocketCoderError";
|
|
4080
|
+
this.code = input.code;
|
|
4081
|
+
this.status = input.status;
|
|
4082
|
+
this.requestId = input.requestId;
|
|
4083
|
+
this.details = input.details;
|
|
4084
|
+
}
|
|
4085
|
+
};
|
|
4086
|
+
var ConversationGoneError = class extends PocketCoderError {};
|
|
4087
|
+
var WorkspaceTerminalError = class extends Error {
|
|
4088
|
+
workspace;
|
|
4089
|
+
constructor(workspace) {
|
|
4090
|
+
const reason = workspace.reason_code ?? workspace.failure?.reason_code ?? "no reason";
|
|
4091
|
+
const tail = workspace.failure?.log_tail.trim();
|
|
4092
|
+
super([`workspace ${workspace.id} reached ${workspace.state} (${reason})`, ...tail ? [`failure log:\n${tail}`] : []].join("\n"));
|
|
4093
|
+
this.name = "WorkspaceTerminalError";
|
|
4094
|
+
this.workspace = workspace;
|
|
4095
|
+
}
|
|
4096
|
+
};
|
|
4097
|
+
function isPocketCoderErrorCode(value) {
|
|
4098
|
+
return typeof value === "string" && value in ERROR_CODES;
|
|
4099
|
+
}
|
|
4100
|
+
function responseError(response, body) {
|
|
4101
|
+
const parsed = ErrorEnvelopeSchema.safeParse(body);
|
|
4102
|
+
if (!parsed.success) return new PocketCoderError({
|
|
4103
|
+
message: `PocketCoder returned an invalid error response (${response.status})`,
|
|
4104
|
+
code: "client.invalid_response",
|
|
4105
|
+
status: response.status
|
|
4106
|
+
});
|
|
4107
|
+
const { code, message, request_id: requestId, details } = parsed.data.error;
|
|
4108
|
+
return new (code === "conversation.deleted" || code === "conversation.expired" ? ConversationGoneError : PocketCoderError)({
|
|
4109
|
+
message,
|
|
4110
|
+
code,
|
|
4111
|
+
status: response.status,
|
|
4112
|
+
requestId,
|
|
4113
|
+
details
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
//#endregion
|
|
3514
4117
|
//#region src/resources/diagnostics/diagnostics.ts
|
|
3515
4118
|
var WorkspaceCursorApi = class {
|
|
3516
4119
|
transport;
|
|
@@ -3660,7 +4263,10 @@ var PreviewsApi = class {
|
|
|
3660
4263
|
open(workspaceId, name, options = {}) {
|
|
3661
4264
|
return this.transport.request(`/v1/workspaces/${encodeURIComponent(workspaceId)}/previews/${encodeURIComponent(name)}`, PreviewOpenResponseSchema, {
|
|
3662
4265
|
method: "POST",
|
|
3663
|
-
body: JSON.stringify({
|
|
4266
|
+
body: JSON.stringify({
|
|
4267
|
+
session: options.session ?? { mode: "local" },
|
|
4268
|
+
...options.grantId ? { grantId: options.grantId } : {}
|
|
4269
|
+
}),
|
|
3664
4270
|
signal: options.signal
|
|
3665
4271
|
});
|
|
3666
4272
|
}
|
|
@@ -3718,6 +4324,204 @@ var SecretsApi = class {
|
|
|
3718
4324
|
}
|
|
3719
4325
|
};
|
|
3720
4326
|
//#endregion
|
|
4327
|
+
//#region src/resources/sessions/events.ts
|
|
4328
|
+
async function* frames(body) {
|
|
4329
|
+
const decoder = new TextDecoder();
|
|
4330
|
+
let buffer = "";
|
|
4331
|
+
for await (const chunk of body) {
|
|
4332
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
4333
|
+
let end = buffer.indexOf("\n\n");
|
|
4334
|
+
while (end !== -1) {
|
|
4335
|
+
const block = buffer.slice(0, end).split("\n");
|
|
4336
|
+
buffer = buffer.slice(end + 2);
|
|
4337
|
+
const field = (name) => block.find((line) => line.startsWith(`${name}:`))?.slice(name.length + 1).trim();
|
|
4338
|
+
const data = block.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
4339
|
+
yield {
|
|
4340
|
+
id: field("id") ?? null,
|
|
4341
|
+
event: field("event") ?? null,
|
|
4342
|
+
data
|
|
4343
|
+
};
|
|
4344
|
+
end = buffer.indexOf("\n\n");
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
async function* sessionEvents(transport, sessionId, options = {}) {
|
|
4349
|
+
let cursor = options.after ?? null;
|
|
4350
|
+
do {
|
|
4351
|
+
const query = cursor ? `?after=${encodeURIComponent(cursor)}` : "";
|
|
4352
|
+
const response = await transport.stream(`/v1/sessions/${encodeURIComponent(sessionId)}/events${query}`, options.signal, cursor ? { "last-event-id": cursor } : {});
|
|
4353
|
+
if (!response.body) return;
|
|
4354
|
+
for await (const frame of frames(response.body)) {
|
|
4355
|
+
if (frame.event === "keepalive") continue;
|
|
4356
|
+
if (frame.event === "error") {
|
|
4357
|
+
const { code } = JSON.parse(frame.data);
|
|
4358
|
+
throw new PocketCoderError({
|
|
4359
|
+
message: `Session event stream ended: ${code}`,
|
|
4360
|
+
code,
|
|
4361
|
+
status: 0
|
|
4362
|
+
});
|
|
4363
|
+
}
|
|
4364
|
+
const event = RuntimeEventSchema.parse(JSON.parse(frame.data));
|
|
4365
|
+
cursor = event.cursor;
|
|
4366
|
+
yield event;
|
|
4367
|
+
}
|
|
4368
|
+
} while (options.reconnect !== false && !options.signal?.aborted);
|
|
4369
|
+
}
|
|
4370
|
+
//#endregion
|
|
4371
|
+
//#region src/resources/sessions/sessions.ts
|
|
4372
|
+
function sessionPath(sessionId) {
|
|
4373
|
+
return `/v1/sessions/${encodeURIComponent(sessionId)}`;
|
|
4374
|
+
}
|
|
4375
|
+
const SessionPreviewSchema = PreviewOpenResponseSchema.extend({ grantId: z.uuid().nullable() });
|
|
4376
|
+
var SessionsApi = class {
|
|
4377
|
+
transport;
|
|
4378
|
+
constructor(transport) {
|
|
4379
|
+
this.transport = transport;
|
|
4380
|
+
}
|
|
4381
|
+
create(input, options = {}) {
|
|
4382
|
+
return this.transport.request("/v1/sessions", SessionSchema, {
|
|
4383
|
+
...options,
|
|
4384
|
+
method: "POST",
|
|
4385
|
+
body: JSON.stringify(SessionCreateSchema.parse(input))
|
|
4386
|
+
});
|
|
4387
|
+
}
|
|
4388
|
+
get(sessionId, options = {}) {
|
|
4389
|
+
return this.transport.request(sessionPath(sessionId), SessionSchema, options);
|
|
4390
|
+
}
|
|
4391
|
+
resume(sessionId, options = {}) {
|
|
4392
|
+
return this.transport.request(`${sessionPath(sessionId)}/resume`, SessionSchema, {
|
|
4393
|
+
...options,
|
|
4394
|
+
method: "POST"
|
|
4395
|
+
});
|
|
4396
|
+
}
|
|
4397
|
+
close(sessionId, command, options = {}) {
|
|
4398
|
+
return this.transport.request(`${sessionPath(sessionId)}/close`, CancelReceiptSchema, {
|
|
4399
|
+
...options,
|
|
4400
|
+
method: "POST",
|
|
4401
|
+
body: JSON.stringify(CancelCommandSchema.parse(command))
|
|
4402
|
+
});
|
|
4403
|
+
}
|
|
4404
|
+
history(sessionId, query = {}, options = {}) {
|
|
4405
|
+
return this.transport.request(`${sessionPath(sessionId)}/history?${queryString({
|
|
4406
|
+
cursor: query.cursor,
|
|
4407
|
+
limit: query.limit ?? 50
|
|
4408
|
+
})}`, ManagedHistoryPageSchema, options);
|
|
4409
|
+
}
|
|
4410
|
+
async snapshot(sessionId, options = {}) {
|
|
4411
|
+
const records = [];
|
|
4412
|
+
let cursor;
|
|
4413
|
+
let eventCursor = "";
|
|
4414
|
+
do {
|
|
4415
|
+
const page = await this.history(sessionId, {
|
|
4416
|
+
cursor,
|
|
4417
|
+
limit: 200
|
|
4418
|
+
}, options);
|
|
4419
|
+
records.push(...page.records);
|
|
4420
|
+
eventCursor = page.eventCursor;
|
|
4421
|
+
cursor = page.nextCursor ?? void 0;
|
|
4422
|
+
} while (cursor);
|
|
4423
|
+
return {
|
|
4424
|
+
records,
|
|
4425
|
+
eventCursor
|
|
4426
|
+
};
|
|
4427
|
+
}
|
|
4428
|
+
events(sessionId, options = {}) {
|
|
4429
|
+
return sessionEvents(this.transport, sessionId, options);
|
|
4430
|
+
}
|
|
4431
|
+
open(sessionId, options = {}) {
|
|
4432
|
+
return this.transport.request(`${sessionPath(sessionId)}/conversation/open`, z.object({ turns: z.array(ConversationLiveEventSchema) }), options);
|
|
4433
|
+
}
|
|
4434
|
+
openPreview(sessionId, name, options = {}) {
|
|
4435
|
+
return this.transport.request(`${sessionPath(sessionId)}/previews/${encodeURIComponent(name)}`, SessionPreviewSchema, {
|
|
4436
|
+
method: "POST",
|
|
4437
|
+
body: JSON.stringify({
|
|
4438
|
+
session: options.session ?? { mode: "local" },
|
|
4439
|
+
...options.grant ? { grant: options.grant } : {}
|
|
4440
|
+
}),
|
|
4441
|
+
signal: options.signal
|
|
4442
|
+
});
|
|
4443
|
+
}
|
|
4444
|
+
};
|
|
4445
|
+
//#endregion
|
|
4446
|
+
//#region src/resources/sessions/files.ts
|
|
4447
|
+
var SessionFilesApi = class {
|
|
4448
|
+
transport;
|
|
4449
|
+
constructor(transport) {
|
|
4450
|
+
this.transport = transport;
|
|
4451
|
+
}
|
|
4452
|
+
register(sessionId, input, options = {}) {
|
|
4453
|
+
return this.transport.request(`${sessionPath(sessionId)}/inputs`, InputObjectSchema, {
|
|
4454
|
+
...options,
|
|
4455
|
+
method: "POST",
|
|
4456
|
+
body: JSON.stringify(InputUploadSchema.parse(input))
|
|
4457
|
+
});
|
|
4458
|
+
}
|
|
4459
|
+
upload(sessionId, inputId, bytes, options = {}) {
|
|
4460
|
+
return this.transport.request(`${sessionPath(sessionId)}/inputs/${encodeURIComponent(inputId)}/content`, InputObjectSchema, {
|
|
4461
|
+
...options,
|
|
4462
|
+
method: "PUT",
|
|
4463
|
+
body: bytes,
|
|
4464
|
+
headers: { "content-type": "application/octet-stream" }
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4467
|
+
async put(sessionId, file, options = {}) {
|
|
4468
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", file.bytes));
|
|
4469
|
+
const sha256 = `sha256:${Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
4470
|
+
const registered = await this.register(sessionId, {
|
|
4471
|
+
inputId: file.inputId,
|
|
4472
|
+
name: file.name,
|
|
4473
|
+
mediaType: file.mediaType,
|
|
4474
|
+
sizeBytes: file.bytes.byteLength,
|
|
4475
|
+
sha256
|
|
4476
|
+
}, options);
|
|
4477
|
+
if (registered.state === "ready") return registered;
|
|
4478
|
+
return this.upload(sessionId, file.inputId, file.bytes, options);
|
|
4479
|
+
}
|
|
4480
|
+
get(sessionId, inputId, options = {}) {
|
|
4481
|
+
return this.transport.request(`${sessionPath(sessionId)}/inputs/${encodeURIComponent(inputId)}`, InputObjectSchema, options);
|
|
4482
|
+
}
|
|
4483
|
+
exports(sessionId, requestId, options = {}) {
|
|
4484
|
+
return this.transport.request(`${sessionPath(sessionId)}/exports?requestId=${encodeURIComponent(requestId)}`, ManagedExportPageSchema, options);
|
|
4485
|
+
}
|
|
4486
|
+
async content(sessionId, exportId, options = {}) {
|
|
4487
|
+
const response = await this.transport.raw(`${sessionPath(sessionId)}/exports/${encodeURIComponent(exportId)}/content`, options);
|
|
4488
|
+
if (!response.ok) {
|
|
4489
|
+
const text = await response.text();
|
|
4490
|
+
throw responseError(response, text ? JSON.parse(text) : void 0);
|
|
4491
|
+
}
|
|
4492
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
4493
|
+
}
|
|
4494
|
+
};
|
|
4495
|
+
//#endregion
|
|
4496
|
+
//#region src/resources/sessions/requests.ts
|
|
4497
|
+
const requestPath = (sessionId, requestId) => `${sessionPath(sessionId)}/requests/${encodeURIComponent(requestId)}`;
|
|
4498
|
+
var SessionRequestsApi = class {
|
|
4499
|
+
transport;
|
|
4500
|
+
constructor(transport) {
|
|
4501
|
+
this.transport = transport;
|
|
4502
|
+
}
|
|
4503
|
+
submit(sessionId, input, options = {}) {
|
|
4504
|
+
return this.transport.request(`${sessionPath(sessionId)}/requests`, RequestSchema, {
|
|
4505
|
+
...options,
|
|
4506
|
+
method: "POST",
|
|
4507
|
+
body: JSON.stringify(RequestInputSchema.parse(input))
|
|
4508
|
+
});
|
|
4509
|
+
}
|
|
4510
|
+
get(sessionId, requestId, options = {}) {
|
|
4511
|
+
return this.transport.request(requestPath(sessionId, requestId), RequestSchema, options);
|
|
4512
|
+
}
|
|
4513
|
+
cancel(sessionId, requestId, command, options = {}) {
|
|
4514
|
+
return this.transport.request(`${requestPath(sessionId, requestId)}/cancel`, CancelReceiptSchema, {
|
|
4515
|
+
...options,
|
|
4516
|
+
method: "POST",
|
|
4517
|
+
body: JSON.stringify(CancelCommandSchema.parse(command))
|
|
4518
|
+
});
|
|
4519
|
+
}
|
|
4520
|
+
collection(sessionId, requestId, options = {}) {
|
|
4521
|
+
return this.transport.request(`${requestPath(sessionId, requestId)}/collection`, CollectionResultSchema, options);
|
|
4522
|
+
}
|
|
4523
|
+
};
|
|
4524
|
+
//#endregion
|
|
3721
4525
|
//#region src/resources/templates/templates.ts
|
|
3722
4526
|
var TemplatesApi = class {
|
|
3723
4527
|
transport;
|
|
@@ -3926,17 +4730,6 @@ var WorkspacesApi = class {
|
|
|
3926
4730
|
}
|
|
3927
4731
|
return workspace;
|
|
3928
4732
|
}
|
|
3929
|
-
async waitForAgentInput(id, timeoutMs, options = {}) {
|
|
3930
|
-
const deadline = Date.now() + timeoutMs;
|
|
3931
|
-
let workspace = await this.get(id, options);
|
|
3932
|
-
while (workspace.agent_state !== "stable") {
|
|
3933
|
-
if (TERMINAL_STATES.includes(workspace.state)) throw new WorkspaceTerminalError(workspace);
|
|
3934
|
-
const remainingMs = deadline - Date.now();
|
|
3935
|
-
if (remainingMs <= 0) throw new AgentNotReadyError(workspace.id, workspace.agent_state, timeoutMs);
|
|
3936
|
-
workspace = (await this.change(workspace.id, workspace.change_cursor, Math.max(1, Math.min(30, Math.ceil(remainingMs / 1e3))), options)).workspace;
|
|
3937
|
-
}
|
|
3938
|
-
return workspace;
|
|
3939
|
-
}
|
|
3940
4733
|
preserve(id, input, key, options = {}) {
|
|
3941
4734
|
return this.jsonOperation(`/v1/workspaces/${encodeURIComponent(id)}/preserve`, input, key, PreserveResponseSchema, options);
|
|
3942
4735
|
}
|
|
@@ -4015,11 +4808,12 @@ var PocketCoderTransport = class {
|
|
|
4015
4808
|
await delay(100 * 2 ** attempt, signal);
|
|
4016
4809
|
}
|
|
4017
4810
|
}
|
|
4018
|
-
async stream(path, signal) {
|
|
4811
|
+
async stream(path, signal, headers = {}) {
|
|
4019
4812
|
const response = await this.fetchImpl(`${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`, {
|
|
4020
4813
|
headers: {
|
|
4021
4814
|
authorization: `Bearer ${this.apiKey}`,
|
|
4022
|
-
accept: "text/event-stream"
|
|
4815
|
+
accept: "text/event-stream",
|
|
4816
|
+
...headers
|
|
4023
4817
|
},
|
|
4024
4818
|
...signal ? { signal } : {}
|
|
4025
4819
|
});
|
|
@@ -4099,8 +4893,8 @@ var PocketCoderClient = class {
|
|
|
4099
4893
|
previews;
|
|
4100
4894
|
displays;
|
|
4101
4895
|
attachments;
|
|
4102
|
-
agent;
|
|
4103
4896
|
conversations;
|
|
4897
|
+
workspaceRequests;
|
|
4104
4898
|
checkpoints;
|
|
4105
4899
|
operations;
|
|
4106
4900
|
logs;
|
|
@@ -4111,6 +4905,10 @@ var PocketCoderClient = class {
|
|
|
4111
4905
|
principals;
|
|
4112
4906
|
keys;
|
|
4113
4907
|
recovery;
|
|
4908
|
+
sessions;
|
|
4909
|
+
requests;
|
|
4910
|
+
files;
|
|
4911
|
+
authority;
|
|
4114
4912
|
constructor(config, fetchImpl = fetch) {
|
|
4115
4913
|
this.transport = new PocketCoderTransport(config, fetchImpl);
|
|
4116
4914
|
this.secrets = new SecretsApi(this.transport);
|
|
@@ -4119,8 +4917,8 @@ var PocketCoderClient = class {
|
|
|
4119
4917
|
this.previews = new PreviewsApi(this.transport);
|
|
4120
4918
|
this.displays = new DisplaysApi(this.transport);
|
|
4121
4919
|
this.attachments = new AttachmentsApi(this.transport);
|
|
4122
|
-
this.agent = new AgentApi(this.transport, this.workspaces);
|
|
4123
4920
|
this.conversations = new ConversationsApi(this.transport);
|
|
4921
|
+
this.workspaceRequests = new WorkspaceRequestsApi(this.transport);
|
|
4124
4922
|
this.checkpoints = new CheckpointsApi(this.transport);
|
|
4125
4923
|
this.operations = new OperationsApi(this.transport);
|
|
4126
4924
|
this.logs = new LogsApi(this.transport);
|
|
@@ -4131,6 +4929,10 @@ var PocketCoderClient = class {
|
|
|
4131
4929
|
this.principals = new PrincipalsApi(this.transport);
|
|
4132
4930
|
this.keys = new KeysApi(this.transport);
|
|
4133
4931
|
this.recovery = new RecoveryApi(this.transport);
|
|
4932
|
+
this.sessions = new SessionsApi(this.transport);
|
|
4933
|
+
this.requests = new SessionRequestsApi(this.transport);
|
|
4934
|
+
this.files = new SessionFilesApi(this.transport);
|
|
4935
|
+
this.authority = new ManagedAuthorityApi(this.transport);
|
|
4134
4936
|
}
|
|
4135
4937
|
raw(path, init = {}) {
|
|
4136
4938
|
return this.transport.raw(path, init);
|
|
@@ -4281,4 +5083,4 @@ var WorkspaceTurnResolver = class {
|
|
|
4281
5083
|
}
|
|
4282
5084
|
};
|
|
4283
5085
|
//#endregion
|
|
4284
|
-
export { AdministrationApi,
|
|
5086
|
+
export { AdministrationApi, AttachmentsApi, CheckpointsApi, ConversationGoneError, ConversationsApi, KeysApi, LogsApi, ManagedAuthorityApi, NetworkEventsApi, OperationsApi, OutputsApi, PocketCoderClient, PocketCoderError, PrincipalsApi, RecoveryApi, SecretsApi, SessionFilesApi, SessionRequestsApi, SessionsApi, TERMINAL_WORKSPACE_STATES, TemplatesApi, TerminalConnection, TerminalsApi, WorkspaceRequestsApi, WorkspaceTerminalError, WorkspaceTurnResolutionError, WorkspaceTurnResolver, WorkspacesApi, isPocketCoderErrorCode, sessions_exports as managed, sessionTemplate };
|