@byok-sdk/protocol 0.27.0-rc.2 → 0.28.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/dist/agent-egress.d.ts +1 -0
- package/dist/bot-turn-outcome.d.ts +252 -0
- package/dist/codec.d.ts +4 -0
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/envelope.d.ts +21 -0
- package/dist/http-api.d.ts +21 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +303 -10
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +33 -1
- package/dist/result-schema.d.ts +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/wire-additions.d.ts +3 -3
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,8 @@ var CAPABILITY_FLAGS = [
|
|
|
56
56
|
CUSTOM_HARNESS_CAPABILITY,
|
|
57
57
|
MAILBOX_READ_AHEAD_CAPABILITY,
|
|
58
58
|
PROVIDER_PROVISIONING_CAPABILITY,
|
|
59
|
-
AGENT_MEMORY_INTENT_CAPABILITY
|
|
59
|
+
AGENT_MEMORY_INTENT_CAPABILITY,
|
|
60
|
+
"agent-message-draft"
|
|
60
61
|
];
|
|
61
62
|
|
|
62
63
|
// src/task-state.ts
|
|
@@ -127,7 +128,12 @@ var WIRE_ADDITIONS = Object.freeze([
|
|
|
127
128
|
{ kind: "envelope", rule: "gated", surface: "agent.input.preparation", capability: "agent-input-preparation-v9", advertisedBy: "device" },
|
|
128
129
|
{ kind: "envelope", rule: "gated", surface: "provider.provisioning.available", capability: "provider-provisioning.v1", advertisedBy: "device" },
|
|
129
130
|
{ kind: "envelope", rule: "gated", surface: "agent.memory.intent.available", capability: "agent-memory-intent.v1", advertisedBy: "device" },
|
|
131
|
+
// One optional runtime capability, shared by discovery and the claim snapshot.
|
|
132
|
+
{ kind: "envelope", rule: "strip-safe", surface: "conn.hello", field: "runtimes[].capabilities.messageDraft" },
|
|
133
|
+
{ kind: "envelope", rule: "strip-safe", surface: "conn.hello", field: "harnesses[].capabilities.messageDraft" },
|
|
134
|
+
{ kind: "envelope", rule: "strip-safe", surface: "task.claim", field: "capabilities.messageDraft" },
|
|
130
135
|
// Daemon to server.
|
|
136
|
+
{ kind: "envelope", rule: "gated", surface: "agent.message.draft", capability: "agent-message-draft", advertisedBy: "server" },
|
|
131
137
|
{ kind: "envelope", rule: "gated", surface: "task.approval_resolved", capability: "approval_resolved", advertisedBy: "server" }
|
|
132
138
|
]);
|
|
133
139
|
function requiredReceiverCapabilities(type, payload) {
|
|
@@ -415,13 +421,13 @@ var IssueSink = class {
|
|
|
415
421
|
// "[]"
|
|
416
422
|
add(pointer, keyword, message) {
|
|
417
423
|
const issue = { pointer: cut(pointer), keyword: cut(keyword), message: cut(message) };
|
|
418
|
-
const
|
|
419
|
-
if (this.issues.length >= RESULT_ISSUES_MAX_COUNT || this.bytes +
|
|
424
|
+
const size2 = encoder.encode(JSON.stringify(issue)).length + (this.issues.length === 0 ? 0 : 1);
|
|
425
|
+
if (this.issues.length >= RESULT_ISSUES_MAX_COUNT || this.bytes + size2 > RESULT_ISSUES_MAX_BYTES) {
|
|
420
426
|
this.truncated = true;
|
|
421
427
|
return;
|
|
422
428
|
}
|
|
423
429
|
this.issues.push(issue);
|
|
424
|
-
this.bytes +=
|
|
430
|
+
this.bytes += size2;
|
|
425
431
|
}
|
|
426
432
|
get empty() {
|
|
427
433
|
return this.issues.length === 0 && !this.truncated;
|
|
@@ -476,7 +482,7 @@ function documentFailure(check, what, maxBytes) {
|
|
|
476
482
|
return { ok: false, reason: check.reason, bytes: check.bytes, issues: sink.issues, truncated: false };
|
|
477
483
|
}
|
|
478
484
|
}
|
|
479
|
-
function checkSubschema(node, pointer, depth, sink) {
|
|
485
|
+
function checkSubschema(node, pointer, depth, sink, requireObjectRoot = true) {
|
|
480
486
|
if (!isObject(node)) {
|
|
481
487
|
sink.add(pointer, "schema", "a subschema must be a JSON object");
|
|
482
488
|
return;
|
|
@@ -488,7 +494,7 @@ function checkSubschema(node, pointer, depth, sink) {
|
|
|
488
494
|
for (const key of Object.keys(node)) {
|
|
489
495
|
if (!KEYWORDS.has(key)) sink.add(pointerTo(pointer, key), key, "keyword is outside the result schema subset");
|
|
490
496
|
}
|
|
491
|
-
if (depth === 0 && node.type !== "object") {
|
|
497
|
+
if (requireObjectRoot && depth === 0 && node.type !== "object") {
|
|
492
498
|
sink.add(pointerTo(pointer, "type"), "type", "the root schema must declare type: 'object'");
|
|
493
499
|
}
|
|
494
500
|
if (Object.hasOwn(node, "type")) {
|
|
@@ -572,6 +578,89 @@ function validateResultOutcome(schema, outcome) {
|
|
|
572
578
|
for (const unit of result.errors) sink.add(fragmentToPointer(unit.instanceLocation), unit.keyword, unit.error);
|
|
573
579
|
return { ok: false, reason: "schema-mismatch", bytes: document.bytes, issues: sink.issues, truncated: sink.truncated };
|
|
574
580
|
}
|
|
581
|
+
var MAX_BYTES_PER_CODE_POINT = 6;
|
|
582
|
+
var MAX_NUMBER_BYTES = 25;
|
|
583
|
+
var MAX_INTEGER_BYTES = 24;
|
|
584
|
+
var DECIMAL_LIMIT = 1e21;
|
|
585
|
+
var enc = new TextEncoder();
|
|
586
|
+
var size = (v) => enc.encode(JSON.stringify(v)).length;
|
|
587
|
+
function typeBound(node, type) {
|
|
588
|
+
switch (type) {
|
|
589
|
+
case "null":
|
|
590
|
+
return 4;
|
|
591
|
+
case "boolean":
|
|
592
|
+
return 5;
|
|
593
|
+
case "integer": {
|
|
594
|
+
const lo = typeof node.minimum === "number" ? Math.ceil(node.minimum) : void 0;
|
|
595
|
+
const hi = typeof node.maximum === "number" ? Math.floor(node.maximum) : void 0;
|
|
596
|
+
if (lo === void 0 || hi === void 0 || !(Math.abs(lo) < DECIMAL_LIMIT) || !(Math.abs(hi) < DECIMAL_LIMIT)) return MAX_INTEGER_BYTES;
|
|
597
|
+
return Math.min(MAX_INTEGER_BYTES, Math.max(String(lo).length, String(hi).length));
|
|
598
|
+
}
|
|
599
|
+
case "number":
|
|
600
|
+
return MAX_NUMBER_BYTES;
|
|
601
|
+
case "string":
|
|
602
|
+
return typeof node.maxLength === "number" ? 2 + MAX_BYTES_PER_CODE_POINT * node.maxLength : null;
|
|
603
|
+
case "array": {
|
|
604
|
+
if (node.maxItems === 0) return 2;
|
|
605
|
+
if (typeof node.maxItems !== "number" || node.items === void 0) return null;
|
|
606
|
+
const item = outcomeBound(node.items);
|
|
607
|
+
return item === null ? null : 2 + node.maxItems * item + Math.max(0, node.maxItems - 1);
|
|
608
|
+
}
|
|
609
|
+
case "object": {
|
|
610
|
+
if (node.additionalProperties !== false) return null;
|
|
611
|
+
const entries = Object.entries(node.properties ?? {});
|
|
612
|
+
let total = 2 + Math.max(0, entries.length - 1);
|
|
613
|
+
for (const [name, sub] of entries) {
|
|
614
|
+
const b = outcomeBound(sub);
|
|
615
|
+
if (b === null) return null;
|
|
616
|
+
total += size(name) + 1 + b;
|
|
617
|
+
}
|
|
618
|
+
return total;
|
|
619
|
+
}
|
|
620
|
+
default:
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function outcomeBound(schema) {
|
|
625
|
+
const node = schema;
|
|
626
|
+
const bounds = [];
|
|
627
|
+
if (Object.hasOwn(node, "const")) bounds.push(size(node.const));
|
|
628
|
+
if (Array.isArray(node.enum)) bounds.push(Math.max(...node.enum.map(size)));
|
|
629
|
+
if (Array.isArray(node.oneOf)) {
|
|
630
|
+
const branches = node.oneOf.map(outcomeBound);
|
|
631
|
+
if (branches.every((b) => b !== null)) bounds.push(Math.max(...branches));
|
|
632
|
+
}
|
|
633
|
+
if (node.type !== void 0) {
|
|
634
|
+
const types = Array.isArray(node.type) ? node.type : [node.type];
|
|
635
|
+
const each = types.map((t) => typeBound(node, t));
|
|
636
|
+
if (each.every((b) => b !== null)) bounds.push(Math.max(...each));
|
|
637
|
+
}
|
|
638
|
+
return bounds.length === 0 ? null : Math.min(...bounds);
|
|
639
|
+
}
|
|
640
|
+
function resultOutcomeMaxBytes(schema) {
|
|
641
|
+
const pending = [schema];
|
|
642
|
+
const seen = /* @__PURE__ */ new Set();
|
|
643
|
+
while (pending.length > 0) {
|
|
644
|
+
const value = pending.pop();
|
|
645
|
+
if (typeof value === "function") return null;
|
|
646
|
+
if (value === null || typeof value !== "object" || seen.has(value)) continue;
|
|
647
|
+
seen.add(value);
|
|
648
|
+
const prototype = Object.getPrototypeOf(value);
|
|
649
|
+
if (prototype !== null && prototype !== Object.prototype && prototype !== Array.prototype) return null;
|
|
650
|
+
for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
651
|
+
if (name === "toJSON" && (!Object.hasOwn(descriptor, "value") || typeof descriptor.value === "function")) return null;
|
|
652
|
+
if (!descriptor.enumerable) continue;
|
|
653
|
+
if (!Object.hasOwn(descriptor, "value")) return null;
|
|
654
|
+
pending.push(descriptor.value);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const document = canonicalDocument(schema, RESULT_SCHEMA_MAX_BYTES);
|
|
658
|
+
if (!document.ok) return null;
|
|
659
|
+
const sink = new IssueSink();
|
|
660
|
+
checkSubschema(document.canonical, "", 0, sink, false);
|
|
661
|
+
if (!sink.empty) return null;
|
|
662
|
+
return outcomeBound(document.canonical);
|
|
663
|
+
}
|
|
575
664
|
|
|
576
665
|
// src/terminal-projection.ts
|
|
577
666
|
var TerminalProjectionContractSchema = z.string().min(1).max(128).regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u, "terminal projection contracts must be opaque lowercase ids");
|
|
@@ -599,6 +688,7 @@ var TerminalProjectionSelectionSchema = z.discriminatedUnion("mode", [
|
|
|
599
688
|
]);
|
|
600
689
|
var POLICY_REVISION = z.string().min(1).max(160).regex(/^[^\u0000-\u001f\u007f\r\n]+$/u, "policyRevision must not contain control characters");
|
|
601
690
|
var POSITIVE_LIMIT = z.number().int().positive().max(2147483647);
|
|
691
|
+
var AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES = 16 * 1024;
|
|
602
692
|
var AGENT_MESSAGE_MAX_BYTES = 256 * 1024;
|
|
603
693
|
var AgentMessageContractSchema = z.string().min(1).max(160).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u, "message contract must be an opaque portable identifier");
|
|
604
694
|
var AgentMessageContentTypeSchema = z.enum(["text/plain", "text/markdown"]);
|
|
@@ -1084,7 +1174,8 @@ var RuntimeCapabilitiesSchema = z.object({
|
|
|
1084
1174
|
resume: z.boolean().optional(),
|
|
1085
1175
|
approvalInteractive: z.boolean().optional(),
|
|
1086
1176
|
/** Whether this runtime can project a locally configured MCP toolset into one task. */
|
|
1087
|
-
mcpToolsets: z.boolean().optional()
|
|
1177
|
+
mcpToolsets: z.boolean().optional(),
|
|
1178
|
+
messageDraft: z.boolean().optional()
|
|
1088
1179
|
});
|
|
1089
1180
|
var RuntimeInfoSchema = z.object({
|
|
1090
1181
|
id: RuntimeIdSchema,
|
|
@@ -1255,6 +1346,16 @@ var AGENT_MESSAGE_BODY = z.string().min(1).refine(
|
|
|
1255
1346
|
(value) => new TextEncoder().encode(value).byteLength <= AGENT_MESSAGE_MAX_BYTES,
|
|
1256
1347
|
`Agent message body exceeds ${AGENT_MESSAGE_MAX_BYTES} bytes`
|
|
1257
1348
|
);
|
|
1349
|
+
var AgentMessageDraftPayloadSchema = z.object({
|
|
1350
|
+
agentRef: AgentRefSchema,
|
|
1351
|
+
revision: z.number().int().min(1),
|
|
1352
|
+
offset: z.number().int().nonnegative(),
|
|
1353
|
+
text: z.string().refine(
|
|
1354
|
+
(value) => new TextEncoder().encode(value).byteLength <= AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES,
|
|
1355
|
+
`Agent message draft frame exceeds ${AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES} bytes`
|
|
1356
|
+
),
|
|
1357
|
+
overflow: z.literal(true).optional()
|
|
1358
|
+
}).strict();
|
|
1258
1359
|
var AgentMessagePublishPayloadSchema = z.object({
|
|
1259
1360
|
agentRef: AgentRefSchema,
|
|
1260
1361
|
sessionRef: EGRESS_SESSION_REF,
|
|
@@ -1561,6 +1662,7 @@ var MESSAGE_PAYLOAD_SCHEMAS = {
|
|
|
1561
1662
|
...TASK_OFFER_PAYLOAD_SCHEMAS,
|
|
1562
1663
|
"agent.egress.reliable": AgentEgressReliablePayloadSchema,
|
|
1563
1664
|
"agent.egress.ack": AgentEgressAckPayloadSchema,
|
|
1665
|
+
"agent.message.draft": AgentMessageDraftPayloadSchema,
|
|
1564
1666
|
"agent.message.publish": AgentMessagePublishPayloadSchema,
|
|
1565
1667
|
"agent.message.disposition": AgentMessageDispositionPayloadSchema,
|
|
1566
1668
|
"agent.content.read": AgentContentReadPayloadSchema,
|
|
@@ -1617,6 +1719,7 @@ var DAEMON_TO_SERVER_TYPES = [
|
|
|
1617
1719
|
"task.cancelled",
|
|
1618
1720
|
"task.approval_resolved",
|
|
1619
1721
|
"agent.egress.reliable",
|
|
1722
|
+
"agent.message.draft",
|
|
1620
1723
|
"agent.message.publish",
|
|
1621
1724
|
"agent.content.receipt"
|
|
1622
1725
|
];
|
|
@@ -1912,6 +2015,7 @@ var EnvelopeSchema = z.discriminatedUnion("type", [
|
|
|
1912
2015
|
envelopeShape("task.cancelled", REQUIRED_TASK_ID, OPTIONAL_SEQ),
|
|
1913
2016
|
envelopeShape("task.approval_resolved", REQUIRED_TASK_ID, OPTIONAL_SEQ),
|
|
1914
2017
|
envelopeShape("agent.egress.reliable", OPTIONAL_TASK_ID, OPTIONAL_SEQ),
|
|
2018
|
+
envelopeShape("agent.message.draft", REQUIRED_TASK_ID, OPTIONAL_SEQ),
|
|
1915
2019
|
envelopeShape("agent.message.publish", REQUIRED_TASK_ID, OPTIONAL_SEQ),
|
|
1916
2020
|
envelopeShape("agent.content.receipt", OPTIONAL_TASK_ID, OPTIONAL_SEQ)
|
|
1917
2021
|
]);
|
|
@@ -1969,10 +2073,10 @@ function parseMessage(data) {
|
|
|
1969
2073
|
);
|
|
1970
2074
|
}
|
|
1971
2075
|
function decodeEnvelope(line) {
|
|
1972
|
-
const
|
|
2076
|
+
const text2 = decodeText(line).replace(/[\r\n]+$/, "");
|
|
1973
2077
|
let json;
|
|
1974
2078
|
try {
|
|
1975
|
-
json = JSON.parse(
|
|
2079
|
+
json = JSON.parse(text2);
|
|
1976
2080
|
} catch (cause) {
|
|
1977
2081
|
throw new EnvelopeParseError("Envelope line is not valid JSON", cause);
|
|
1978
2082
|
}
|
|
@@ -2247,6 +2351,195 @@ function byokBlobContentPath(blobId) {
|
|
|
2247
2351
|
return `/byok/blobs/${blobId}/content`;
|
|
2248
2352
|
}
|
|
2249
2353
|
|
|
2250
|
-
|
|
2354
|
+
// src/bot-turn-outcome.ts
|
|
2355
|
+
var BOT_TURN_OUTCOME_CONTRACT = "bot-turn-outcome.v1";
|
|
2356
|
+
var BOT_TURN_OUTCOME_LIMITS = Object.freeze({
|
|
2357
|
+
delegateMaxItems: 2,
|
|
2358
|
+
delegateRequestMaxLength: 1e3,
|
|
2359
|
+
cancelDelegationMaxItems: 2,
|
|
2360
|
+
askUserQuestionMaxLength: 400,
|
|
2361
|
+
askUserOptionsMaxItems: 6,
|
|
2362
|
+
askUserOptionIdMaxLength: 24,
|
|
2363
|
+
askUserOptionLabelMaxLength: 80,
|
|
2364
|
+
confirmableActionMaxItems: 1,
|
|
2365
|
+
confirmableSummaryMaxLength: 300,
|
|
2366
|
+
confirmableDraftMaxBytes: 16384,
|
|
2367
|
+
createRoutineMaxItems: 1,
|
|
2368
|
+
updateRoutineMaxItems: 1,
|
|
2369
|
+
cancelRoutineMaxItems: 2,
|
|
2370
|
+
routinePromptMaxLength: 500,
|
|
2371
|
+
postTextMaxLength: 2730,
|
|
2372
|
+
roomCallMembersMaxItems: 4,
|
|
2373
|
+
createBotMaxItems: 3,
|
|
2374
|
+
updateBotMaxItems: 1,
|
|
2375
|
+
deleteBotMaxItems: 1,
|
|
2376
|
+
botNameMaxLength: 40,
|
|
2377
|
+
botRoleMaxLength: 80,
|
|
2378
|
+
botPersonaMaxLength: 300,
|
|
2379
|
+
createRoomMaxItems: 1,
|
|
2380
|
+
updateRoomMaxItems: 1,
|
|
2381
|
+
roomNameMaxLength: 40,
|
|
2382
|
+
roomMembersMaxItems: 12,
|
|
2383
|
+
roomAnnouncementMaxLength: 300,
|
|
2384
|
+
teamNoteMaxLength: 300
|
|
2385
|
+
});
|
|
2386
|
+
var L = BOT_TURN_OUTCOME_LIMITS;
|
|
2387
|
+
var text = (maxLength) => ({ type: "string", minLength: 1, maxLength });
|
|
2388
|
+
var oneOfIds = (ids) => ({ enum: [...ids] });
|
|
2389
|
+
var closed = (properties, required) => ({ type: "object", additionalProperties: false, required, properties });
|
|
2390
|
+
var list = (items, maxItems) => ({ type: "array", minItems: 1, maxItems, items });
|
|
2391
|
+
var ROUTINE_DAYS_OF_WEEK = Object.freeze(["mon", "tue", "wed", "thu", "fri", "sat", "sun"]);
|
|
2392
|
+
var integer = (minimum, maximum) => ({ type: "integer", minimum, maximum });
|
|
2393
|
+
var BotTurnOutcomeSchemaError = class extends Error {
|
|
2394
|
+
constructor(code, message) {
|
|
2395
|
+
super(message);
|
|
2396
|
+
this.code = code;
|
|
2397
|
+
this.name = "BotTurnOutcomeSchemaError";
|
|
2398
|
+
}
|
|
2399
|
+
code;
|
|
2400
|
+
};
|
|
2401
|
+
function schedule(timeZones, shape) {
|
|
2402
|
+
const fields = {
|
|
2403
|
+
minute: integer(0, 59),
|
|
2404
|
+
hour: integer(0, 23),
|
|
2405
|
+
daysOfWeek: { type: "array", minItems: 1, maxItems: 7, items: { enum: [...ROUTINE_DAYS_OF_WEEK] } },
|
|
2406
|
+
dayOfMonth: integer(1, 31),
|
|
2407
|
+
month: integer(1, 12),
|
|
2408
|
+
tz: oneOfIds(timeZones)
|
|
2409
|
+
};
|
|
2410
|
+
const outer = {
|
|
2411
|
+
description: "Local time in tz. No day field: every day. daysOfWeek: those days only. dayOfMonth: that day of each month, or of month only.",
|
|
2412
|
+
...closed(fields, ["minute", "hour", "tz"])
|
|
2413
|
+
};
|
|
2414
|
+
if (shape === "flat") return outer;
|
|
2415
|
+
const only = (names, required) => ({ additionalProperties: false, ...required.length ? { required } : {}, properties: Object.fromEntries(names.map((n) => [n, {}])) });
|
|
2416
|
+
return { ...outer, oneOf: [
|
|
2417
|
+
only(["minute", "hour", "tz"], []),
|
|
2418
|
+
only(["minute", "hour", "daysOfWeek", "tz"], ["daysOfWeek"]),
|
|
2419
|
+
only(["minute", "hour", "dayOfMonth", "month", "tz"], ["dayOfMonth"])
|
|
2420
|
+
] };
|
|
2421
|
+
}
|
|
2422
|
+
function roomFields(members) {
|
|
2423
|
+
return {
|
|
2424
|
+
name: text(L.roomNameMaxLength),
|
|
2425
|
+
members: { type: "array", minItems: 1, maxItems: L.roomMembersMaxItems, items: oneOfIds(members) },
|
|
2426
|
+
admin: oneOfIds(members),
|
|
2427
|
+
mode: { enum: ["mention", "admin"] },
|
|
2428
|
+
announcement: text(L.roomAnnouncementMaxLength)
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
var botTurnOutcomeFragments = {
|
|
2432
|
+
/** `to` lists this Bot first: delegating to yourself is a continuation. */
|
|
2433
|
+
delegate(o) {
|
|
2434
|
+
return list(closed({ to: oneOfIds(o.to), request: text(L.delegateRequestMaxLength) }, ["to", "request"]), L.delegateMaxItems);
|
|
2435
|
+
},
|
|
2436
|
+
/** Owner-authorized Main Bot turns only. The Host lists open delegations. */
|
|
2437
|
+
cancelDelegation(o) {
|
|
2438
|
+
return list(closed({ delegationId: oneOfIds(o.delegationIds) }, ["delegationId"]), L.cancelDelegationMaxItems);
|
|
2439
|
+
},
|
|
2440
|
+
askUser() {
|
|
2441
|
+
const question = text(L.askUserQuestionMaxLength);
|
|
2442
|
+
const option = closed({ id: text(L.askUserOptionIdMaxLength), label: text(L.askUserOptionLabelMaxLength) }, ["id", "label"]);
|
|
2443
|
+
return { oneOf: [
|
|
2444
|
+
closed({ question, answerKind: { const: "text" } }, ["question", "answerKind"]),
|
|
2445
|
+
closed({
|
|
2446
|
+
question,
|
|
2447
|
+
answerKind: { const: "single_choice" },
|
|
2448
|
+
options: { type: "array", minItems: 2, maxItems: L.askUserOptionsMaxItems, items: option }
|
|
2449
|
+
}, ["question", "answerKind", "options"])
|
|
2450
|
+
] };
|
|
2451
|
+
},
|
|
2452
|
+
/** One branch per Host action; each draft needs a finite bound of at most confirmableDraftMaxBytes. */
|
|
2453
|
+
confirmableAction(o) {
|
|
2454
|
+
for (const { action, draft } of o.actions) {
|
|
2455
|
+
const bound = resultOutcomeMaxBytes(draft);
|
|
2456
|
+
if (bound === null || bound > L.confirmableDraftMaxBytes) {
|
|
2457
|
+
throw new BotTurnOutcomeSchemaError("draft-over-budget", `draft for ${action} is ${bound ?? "unbounded"}; cap ${L.confirmableDraftMaxBytes}`);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
const branches = o.actions.map(({ action, draft }) => closed({ action: { const: action }, summary: text(L.confirmableSummaryMaxLength), draft }, ["action", "summary", "draft"]));
|
|
2461
|
+
return list(branches.length === 1 ? branches[0] : { oneOf: branches }, L.confirmableActionMaxItems);
|
|
2462
|
+
},
|
|
2463
|
+
/** `targets` only for a Main Bot: the Bot itself first, then team Bots. Omitted means the Bot itself. */
|
|
2464
|
+
createRoutine(o) {
|
|
2465
|
+
return list(closed({
|
|
2466
|
+
localId: oneOfIds(o.localIds),
|
|
2467
|
+
schedule: schedule(o.timeZones, o.scheduleShape ?? "checked"),
|
|
2468
|
+
prompt: text(L.routinePromptMaxLength),
|
|
2469
|
+
...o.targets ? { target: oneOfIds(o.targets) } : {}
|
|
2470
|
+
}, ["localId", "schedule", "prompt"]), L.createRoutineMaxItems);
|
|
2471
|
+
},
|
|
2472
|
+
updateRoutine(o) {
|
|
2473
|
+
return list(closed(
|
|
2474
|
+
{ routineId: oneOfIds(o.routineIds), schedule: schedule(o.timeZones, o.scheduleShape ?? "checked"), prompt: text(L.routinePromptMaxLength) },
|
|
2475
|
+
["routineId"]
|
|
2476
|
+
), L.updateRoutineMaxItems);
|
|
2477
|
+
},
|
|
2478
|
+
cancelRoutine(o) {
|
|
2479
|
+
return list(closed({ routineId: oneOfIds(o.routineIds) }, ["routineId"]), L.cancelRoutineMaxItems);
|
|
2480
|
+
},
|
|
2481
|
+
/** Room turns only. Exactly one of post or pass. */
|
|
2482
|
+
speech() {
|
|
2483
|
+
return { oneOf: [
|
|
2484
|
+
closed({ kind: { const: "post" }, text: text(L.postTextMaxLength) }, ["kind", "text"]),
|
|
2485
|
+
closed({ kind: { const: "pass" } }, ["kind"])
|
|
2486
|
+
] };
|
|
2487
|
+
},
|
|
2488
|
+
roomCall(o) {
|
|
2489
|
+
return closed({ members: { type: "array", minItems: 1, maxItems: L.roomCallMembersMaxItems, items: oneOfIds(o.members) } }, ["members"]);
|
|
2490
|
+
},
|
|
2491
|
+
createBot(o) {
|
|
2492
|
+
return list(closed({
|
|
2493
|
+
localId: oneOfIds(o.localIds),
|
|
2494
|
+
name: text(L.botNameMaxLength),
|
|
2495
|
+
role: text(L.botRoleMaxLength),
|
|
2496
|
+
persona: text(L.botPersonaMaxLength),
|
|
2497
|
+
model: oneOfIds(o.models)
|
|
2498
|
+
}, ["localId", "name", "role", "persona", "model"]), L.createBotMaxItems);
|
|
2499
|
+
},
|
|
2500
|
+
updateBot(o) {
|
|
2501
|
+
return list(closed({
|
|
2502
|
+
botId: oneOfIds(o.botIds),
|
|
2503
|
+
name: text(L.botNameMaxLength),
|
|
2504
|
+
role: text(L.botRoleMaxLength),
|
|
2505
|
+
persona: text(L.botPersonaMaxLength),
|
|
2506
|
+
model: oneOfIds(o.models)
|
|
2507
|
+
}, ["botId"]), L.updateBotMaxItems);
|
|
2508
|
+
},
|
|
2509
|
+
deleteBot(o) {
|
|
2510
|
+
return list(closed({ botId: oneOfIds(o.botIds) }, ["botId"]), L.deleteBotMaxItems);
|
|
2511
|
+
},
|
|
2512
|
+
/** `members`: team Bot ids plus the create_bot localId slots of this outcome. */
|
|
2513
|
+
createRoom(o) {
|
|
2514
|
+
return list(closed({ localId: oneOfIds(o.localIds), ...roomFields(o.members) }, ["localId", "name", "members"]), L.createRoomMaxItems);
|
|
2515
|
+
},
|
|
2516
|
+
updateRoom(o) {
|
|
2517
|
+
return list(closed({ roomId: oneOfIds(o.roomIds), ...roomFields(o.members) }, ["roomId"]), L.updateRoomMaxItems);
|
|
2518
|
+
},
|
|
2519
|
+
teamNote() {
|
|
2520
|
+
return closed({ text: text(L.teamNoteMaxLength) }, ["text"]);
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
function composeBotTurnOutcomeSchema(fragments, required = []) {
|
|
2524
|
+
const schema = {
|
|
2525
|
+
type: "object",
|
|
2526
|
+
additionalProperties: false,
|
|
2527
|
+
description: `${BOT_TURN_OUTCOME_CONTRACT}: actions for the Host. Omit a field for no action of that kind; {} means no actions.`,
|
|
2528
|
+
...required.length ? { required: [...required] } : {},
|
|
2529
|
+
properties: fragments
|
|
2530
|
+
};
|
|
2531
|
+
const admitted = checkResultSchema(schema);
|
|
2532
|
+
if (!admitted.ok && admitted.reason === "over-cap") {
|
|
2533
|
+
throw new BotTurnOutcomeSchemaError("schema-over-budget", `schema is ${admitted.bytes} bytes; cap ${RESULT_SCHEMA_MAX_BYTES}`);
|
|
2534
|
+
}
|
|
2535
|
+
if (!admitted.ok) throw new BotTurnOutcomeSchemaError("not-subset", JSON.stringify(admitted.issues));
|
|
2536
|
+
const bound = resultOutcomeMaxBytes(admitted.canonical);
|
|
2537
|
+
if (bound === null || bound > RESULT_OUTCOME_MAX_BYTES) {
|
|
2538
|
+
throw new BotTurnOutcomeSchemaError("over-budget", `largest outcome is ${bound ?? "unbounded"} bytes; cap ${RESULT_OUTCOME_MAX_BYTES}`);
|
|
2539
|
+
}
|
|
2540
|
+
return admitted.canonical;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_MEMORY_DIGEST_MAX_BYTES, AGENT_HOME_MEMORY_DIGEST_MAX_FILES, AGENT_HOME_MEMORY_PATH_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS_BY_RESERVATION, AGENT_MEMORY_INTENT_HOST_TERMINAL_CODES, AGENT_MEMORY_INTENT_OPERATIONS, AGENT_MEMORY_INTENT_PATH_MAX_BYTES, AGENT_MEMORY_INTENT_READBACK_DISPOSITIONS, AGENT_MEMORY_INTENT_REJECTION_CODES, AGENT_MEMORY_INTENT_RESERVATIONS, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, ActivityIngressSchema, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeAccessSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentInputPreparationPayloadSchema, AgentMemoryIntentApprovalRefSchema, AgentMemoryIntentAvailablePayloadSchema, AgentMemoryIntentCompletionSchema, AgentMemoryIntentContentSchema, AgentMemoryIntentFetchRequestSchema, AgentMemoryIntentFetchResponseSchema, AgentMemoryIntentFileObservationSchema, AgentMemoryIntentHostTerminalCodeSchema, AgentMemoryIntentOperationDigestSchema, AgentMemoryIntentOperationSchema, AgentMemoryIntentPathSchema, AgentMemoryIntentReadbackDispositionSchema, AgentMemoryIntentReadbackSchema, AgentMemoryIntentRejectionCodeSchema, AgentMemoryIntentReservationSchema, AgentMemoryIntentRevisionSchema, AgentMemoryIntentV1Schema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageDraftPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BOT_TURN_OUTCOME_CONTRACT, BOT_TURN_OUTCOME_LIMITS, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_INPUT_PREPARATIONS_PATH, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, BotTurnOutcomeSchemaError, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, CUSTOM_HARNESS_CAPABILITY, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, HOST_MCP_TASK_CONTEXT_CAPABILITY, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, INPUT_PREPARATION_WIRE_VERSION, InputPreparationAccountingPolicyRefSchema, InputPreparationArtifactSummarySchema, InputPreparationBindingSchema, InputPreparationCompletionRequestSchema, InputPreparationContentHashSchema, InputPreparationContextDocumentSchema, InputPreparationCounterEvidenceSchema, InputPreparationCounterProviderEvidenceSchema, InputPreparationCounterTargetSchema, InputPreparationHostCanonicalAssistantMessageSchema, InputPreparationMessageSchema, InputPreparationModelCostSchema, InputPreparationModelSchema, InputPreparationOfferBindingSchema, InputPreparationOptionsSchema, InputPreparationPolicyRevisionSchema, InputPreparationProfileIdSchema, InputPreparationProjectionSchema, InputPreparationPromptSnapshotSchema, InputPreparationReadbackSchema, InputPreparationReadinessReasonSchema, InputPreparationReceiptSummarySchema, InputPreparationReferenceSchema, InputPreparationRejectionReasonSchema, InputPreparationResidualKeySchema, InputPreparationResidualValueClassSchema, InputPreparationRuntimeIdentitySchema, InputPreparationSelectionSchema, InputPreparationSourceSchema, InputPreparationStateSchema, InputPreparationStatusQuerySchema, InputPreparationStatusSchema, InputPreparationUserMessageSchema, KNOWN_AGENT_EVENT_TYPES, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessageSendOutcomeSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, OUTBOUND_REFUSAL_REASONS, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, PROVIDER_PROVISIONING_DISPOSITIONS, PROVIDER_PROVISIONING_HOST_TERMINAL_CODES, PROVIDER_PROVISIONING_KEY_CHECK_RESULTS, PROVIDER_PROVISIONING_OPERATIONS, PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM, PROVIDER_PROVISIONING_REJECTION_CODES, PROVIDER_SECRET_SEALING_KEY_REGISTER_OPERATION, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PreparedAgentMemoryModeSchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, ProviderProvisioningAvailablePayloadSchema, ProviderProvisioningCompletionSchema, ProviderProvisioningDispositionSchema, ProviderProvisioningKeyCheckResultSchema, ProviderProvisioningKeyCheckSchema, ProviderProvisioningOperationDigestSchema, ProviderProvisioningOperationGenerationSchema, ProviderProvisioningOperationSchema, ProviderProvisioningProviderStatusSchema, ProviderProvisioningReadbackSchema, ProviderProvisioningRejectionCodeSchema, RESULT_DOCUMENT_MAX_BYTES, RESULT_ISSUES_MAX_BYTES, RESULT_ISSUES_MAX_COUNT, RESULT_JSON_MAX_DEPTH, RESULT_OUTCOME_MAX_BYTES, RESULT_SCHEMA_INSTANCE_TYPES, RESULT_SCHEMA_KEYWORDS, RESULT_SCHEMA_MAX_BYTES, RESULT_SCHEMA_MAX_DEPTH, ROUTINE_DAYS_OF_WEEK, RequiredToolsetsSchema, ResultDocumentSchemaSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferPreparedPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalAgentHomeMemoryChangeSchema, TerminalAgentHomeProjectionSchema, TerminalInferenceUsageSchema, TerminalPreparedObservationSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, WIRE_ADDITIONS, agentMemoryIntentFetchResponseSchemaFor, agentMemoryProjectionBase64UrlByteLength, botTurnOutcomeFragments, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokInputPreparationCompletionPath, byokInputPreparationStatusPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, checkResultSchema, composeBotTurnOutcomeSchema, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isPreparedAgentMemoryMode, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents, requiredReceiverCapabilities, resultOutcomeMaxBytes, validateResultOutcome };
|
|
2251
2544
|
//# sourceMappingURL=index.js.map
|
|
2252
2545
|
//# sourceMappingURL=index.js.map
|