@alva-ai/toolkit 0.28.0-beta.0 → 0.28.1-beta.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 +4 -1
- package/dist/browser.global.js +52 -16
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +190 -8
- package/dist/cli.js +993 -44
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +190 -8
- package/dist/dispatch.js +644 -20
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +613 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +189 -9
- package/dist/index.d.ts +189 -9
- package/dist/index.js +611 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9200,7 +9200,6 @@ var MarketsResource = class {
|
|
|
9200
9200
|
// src/resources/schedules.ts
|
|
9201
9201
|
var SCHEDULE_FIELDS = `
|
|
9202
9202
|
id
|
|
9203
|
-
channel { id }
|
|
9204
9203
|
name
|
|
9205
9204
|
rule { kind atMs everyIntervalSeconds cronExpression cronTimezone }
|
|
9206
9205
|
bounds { startsAtMs untilMs maxOccurrences }
|
|
@@ -9217,7 +9216,7 @@ var LIST_SCHEDULES = `
|
|
|
9217
9216
|
query ToolkitListAgentSchedules($channelId: ID!, $after: String) {
|
|
9218
9217
|
viewer { channel(id: $channelId) {
|
|
9219
9218
|
schedules(input: { first: 64, after: $after }) {
|
|
9220
|
-
edges { node { ${SCHEDULE_FIELDS} } }
|
|
9219
|
+
edges { node { channel { id } ${SCHEDULE_FIELDS} } }
|
|
9221
9220
|
pageInfo { hasNextPage endCursor }
|
|
9222
9221
|
}
|
|
9223
9222
|
} }
|
|
@@ -9225,6 +9224,20 @@ query ToolkitListAgentSchedules($channelId: ID!, $after: String) {
|
|
|
9225
9224
|
var UPDATE_SCHEDULE = `
|
|
9226
9225
|
mutation ToolkitUpdateAgentSchedule($input: UpdateChannelScheduleInput!) {
|
|
9227
9226
|
updateChannelSchedule(input: $input) {
|
|
9227
|
+
schedule { channel { id } ${SCHEDULE_FIELDS} }
|
|
9228
|
+
deleted
|
|
9229
|
+
}
|
|
9230
|
+
}`.trim();
|
|
9231
|
+
var LIST_SESSION_SCHEDULES = `
|
|
9232
|
+
query ToolkitListSessionSchedules($inboxPath: String!, $after: String) {
|
|
9233
|
+
viewer { sessionSchedules(inboxPath: $inboxPath, input: { first: 64, after: $after }) {
|
|
9234
|
+
edges { node { ${SCHEDULE_FIELDS} } }
|
|
9235
|
+
pageInfo { hasNextPage endCursor }
|
|
9236
|
+
} }
|
|
9237
|
+
}`.trim();
|
|
9238
|
+
var UPDATE_SESSION_SCHEDULE = `
|
|
9239
|
+
mutation ToolkitUpdateSessionSchedule($input: UpdateSessionScheduleInput!) {
|
|
9240
|
+
updateSessionSchedule(input: $input) {
|
|
9228
9241
|
schedule { ${SCHEDULE_FIELDS} }
|
|
9229
9242
|
deleted
|
|
9230
9243
|
}
|
|
@@ -9235,6 +9248,7 @@ query ToolkitAgentChannel {
|
|
|
9235
9248
|
}`.trim();
|
|
9236
9249
|
var SCHEDULE_NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
9237
9250
|
var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
9251
|
+
var RFC3339_FRACTIONAL = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(Z|[+-](\d{2}):(\d{2}))$/i;
|
|
9238
9252
|
var ISO_DURATION = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
9239
9253
|
var GRAPHQL_STATUS_BY_CODE = {
|
|
9240
9254
|
INVALID_ARGUMENT: 400,
|
|
@@ -9258,16 +9272,17 @@ var SchedulesResource = class {
|
|
|
9258
9272
|
client;
|
|
9259
9273
|
async list(params) {
|
|
9260
9274
|
this.client._requireAuth();
|
|
9261
|
-
const
|
|
9275
|
+
const target = targetInput(params);
|
|
9276
|
+
const inbox = "inboxPath" in target;
|
|
9262
9277
|
const schedules = [];
|
|
9263
9278
|
let after = null;
|
|
9264
9279
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
9265
9280
|
for (; ; ) {
|
|
9266
9281
|
const data = await this.graphql(
|
|
9267
|
-
LIST_SCHEDULES,
|
|
9268
|
-
{
|
|
9282
|
+
inbox ? LIST_SESSION_SCHEDULES : LIST_SCHEDULES,
|
|
9283
|
+
{ ...target, after }
|
|
9269
9284
|
);
|
|
9270
|
-
const connection2 = data.viewer?.channel?.schedules;
|
|
9285
|
+
const connection2 = inbox ? data.viewer?.sessionSchedules : data.viewer?.channel?.schedules;
|
|
9271
9286
|
if (!connection2?.edges) throw scheduleNotFound();
|
|
9272
9287
|
for (const edge of connection2.edges) {
|
|
9273
9288
|
if (!edge?.node) throw scheduleEmptyResponse();
|
|
@@ -9283,15 +9298,14 @@ var SchedulesResource = class {
|
|
|
9283
9298
|
async put(params) {
|
|
9284
9299
|
this.client._requireAuth();
|
|
9285
9300
|
const input = {
|
|
9286
|
-
|
|
9301
|
+
...targetInput(params),
|
|
9287
9302
|
name: requireName(params.name),
|
|
9288
9303
|
definition: {
|
|
9289
9304
|
...ruleInput(params.rule, params.bounds),
|
|
9290
9305
|
message: { text: requireText(params.text) }
|
|
9291
9306
|
}
|
|
9292
9307
|
};
|
|
9293
|
-
const
|
|
9294
|
-
const schedule = data.updateChannelSchedule?.schedule;
|
|
9308
|
+
const schedule = (await this.update(input))?.schedule;
|
|
9295
9309
|
if (!schedule) throw scheduleEmptyResponse();
|
|
9296
9310
|
return fromWireSchedule(schedule);
|
|
9297
9311
|
}
|
|
@@ -9303,11 +9317,11 @@ var SchedulesResource = class {
|
|
|
9303
9317
|
}
|
|
9304
9318
|
async delete(params) {
|
|
9305
9319
|
this.client._requireAuth();
|
|
9306
|
-
const
|
|
9307
|
-
|
|
9320
|
+
const result = await this.update({
|
|
9321
|
+
...managementInput(params),
|
|
9322
|
+
lifecycle: "REMOVED"
|
|
9308
9323
|
});
|
|
9309
|
-
if (
|
|
9310
|
-
throw scheduleEmptyResponse();
|
|
9324
|
+
if (result?.deleted !== true) throw scheduleEmptyResponse();
|
|
9311
9325
|
}
|
|
9312
9326
|
/** Resolve the authenticated viewer's unique Agent Channel for CLI defaults. */
|
|
9313
9327
|
async agentChannelId() {
|
|
@@ -9321,13 +9335,15 @@ var SchedulesResource = class {
|
|
|
9321
9335
|
}
|
|
9322
9336
|
async manage(lifecycle, params) {
|
|
9323
9337
|
this.client._requireAuth();
|
|
9324
|
-
const
|
|
9325
|
-
input: { ...managementInput(params), lifecycle }
|
|
9326
|
-
});
|
|
9327
|
-
const schedule = data.updateChannelSchedule?.schedule;
|
|
9338
|
+
const schedule = (await this.update({ ...managementInput(params), lifecycle }))?.schedule;
|
|
9328
9339
|
if (!schedule) throw scheduleEmptyResponse();
|
|
9329
9340
|
return fromWireSchedule(schedule);
|
|
9330
9341
|
}
|
|
9342
|
+
async update(input) {
|
|
9343
|
+
const inbox = "inboxPath" in input;
|
|
9344
|
+
const data = await this.graphql(inbox ? UPDATE_SESSION_SCHEDULE : UPDATE_SCHEDULE, { input });
|
|
9345
|
+
return inbox ? data.updateSessionSchedule : data.updateChannelSchedule;
|
|
9346
|
+
}
|
|
9331
9347
|
async graphql(query, variables) {
|
|
9332
9348
|
const response = await this.client._request("POST", "/query", {
|
|
9333
9349
|
body: variables === void 0 ? { query } : { query, variables }
|
|
@@ -9478,10 +9494,24 @@ function fromWireRule(rule) {
|
|
|
9478
9494
|
}
|
|
9479
9495
|
function managementInput(params) {
|
|
9480
9496
|
return {
|
|
9481
|
-
|
|
9497
|
+
...targetInput(params),
|
|
9482
9498
|
name: requireName(params.name)
|
|
9483
9499
|
};
|
|
9484
9500
|
}
|
|
9501
|
+
function targetInput(target) {
|
|
9502
|
+
if (target.channelId !== void 0 === (target.inboxPath !== void 0))
|
|
9503
|
+
throw invalid("exactly one of channelId or inboxPath is required");
|
|
9504
|
+
if (target.channelId !== void 0)
|
|
9505
|
+
return { channelId: channelID(target.channelId) };
|
|
9506
|
+
const path = target.inboxPath;
|
|
9507
|
+
const size = typeof path === "string" ? utf8Size(path) : void 0;
|
|
9508
|
+
if (typeof path !== "string" || size === void 0 || size > 2048 || !path.startsWith("/") || path.includes("\0") || path.slice(1).split("/").some((segment) => segment === "" || segment === "." || segment === ".."))
|
|
9509
|
+
throw invalid("inboxPath must be a canonical absolute ALFS Inbox path");
|
|
9510
|
+
const transcript = path.endsWith(".inbox.jsonl") ? path.slice(0, -".inbox.jsonl".length) + ".jsonl" : path.endsWith(".inbox") && !path.endsWith(".jsonl.inbox") ? path.slice(0, -".inbox".length) : void 0;
|
|
9511
|
+
if (transcript === void 0 || /\.inbox(?:\.jsonl)?$/.test(transcript) || /\.lock(?:\.recovery|\.heartbeat-[^/]+|\.stale-[^/]+)?$/.test(transcript) || transcript.endsWith("/.jsonl"))
|
|
9512
|
+
throw invalid("inboxPath must identify a standard Session Inbox sidecar");
|
|
9513
|
+
return { inboxPath: path };
|
|
9514
|
+
}
|
|
9485
9515
|
function channelID(value) {
|
|
9486
9516
|
if (typeof value === "number" && (!Number.isSafeInteger(value) || value <= 0)) {
|
|
9487
9517
|
throw invalid(
|
|
@@ -9526,8 +9556,11 @@ function durationMilliseconds(value, minimumSeconds) {
|
|
|
9526
9556
|
if (!Number.isSafeInteger(result)) throw invalid("duration is out of range");
|
|
9527
9557
|
return result;
|
|
9528
9558
|
}
|
|
9529
|
-
function
|
|
9530
|
-
|
|
9559
|
+
function parseRfc3339Milliseconds(value) {
|
|
9560
|
+
return timestampMilliseconds(value, true);
|
|
9561
|
+
}
|
|
9562
|
+
function timestampMilliseconds(value, fractional = false) {
|
|
9563
|
+
const match = (fractional ? RFC3339_FRACTIONAL : RFC3339).exec(value);
|
|
9531
9564
|
if (!match) throw invalid("timestamp must be RFC3339 with a timezone");
|
|
9532
9565
|
const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
|
|
9533
9566
|
const offsetHour = Number(match[8] ?? 0);
|
|
@@ -9570,6 +9603,243 @@ function scheduleEmptyResponse() {
|
|
|
9570
9603
|
);
|
|
9571
9604
|
}
|
|
9572
9605
|
|
|
9606
|
+
// src/resources/steward.ts
|
|
9607
|
+
var GRAPHQL_STATUS_BY_CODE2 = {
|
|
9608
|
+
INVALID_ARGUMENT: 400,
|
|
9609
|
+
UNAUTHENTICATED: 401,
|
|
9610
|
+
PERMISSION_DENIED: 403,
|
|
9611
|
+
NOT_FOUND: 404,
|
|
9612
|
+
ALREADY_EXISTS: 409,
|
|
9613
|
+
ABORTED: 409,
|
|
9614
|
+
FAILED_PRECONDITION: 412,
|
|
9615
|
+
RESOURCE_EXHAUSTED: 429,
|
|
9616
|
+
INTERNAL: 500,
|
|
9617
|
+
UNKNOWN: 500,
|
|
9618
|
+
DATA_LOSS: 500,
|
|
9619
|
+
UNAVAILABLE: 503,
|
|
9620
|
+
DEADLINE_EXCEEDED: 504
|
|
9621
|
+
};
|
|
9622
|
+
var DECIDE = `
|
|
9623
|
+
mutation ToolkitStewardDecide($input: UpdateStewardDeliveryInput!) {
|
|
9624
|
+
updateStewardDelivery(input: $input) { delivery { deliveryId state } }
|
|
9625
|
+
}`.trim();
|
|
9626
|
+
var FORWARD = `
|
|
9627
|
+
mutation ToolkitStewardForward($input: UpdateStewardDeliveryInput!) {
|
|
9628
|
+
updateStewardDelivery(input: $input) { delivery { deliveryId state channelMessageId } }
|
|
9629
|
+
}`.trim();
|
|
9630
|
+
var SEND = `
|
|
9631
|
+
mutation ToolkitStewardSend($input: PostStewardMessageInput!) {
|
|
9632
|
+
postStewardMessage(input: $input) { message { channelMessageId requestId } }
|
|
9633
|
+
}`.trim();
|
|
9634
|
+
var PENDING = `
|
|
9635
|
+
query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInput) {
|
|
9636
|
+
viewer {
|
|
9637
|
+
stewardDigestPending(inboxPath: $inboxPath, input: $input) {
|
|
9638
|
+
edges {
|
|
9639
|
+
cursor
|
|
9640
|
+
node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
|
|
9641
|
+
}
|
|
9642
|
+
pageInfo { hasNextPage endCursor }
|
|
9643
|
+
windowSinceMs
|
|
9644
|
+
windowUntilMs
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
}`.trim();
|
|
9648
|
+
var BRIEFED = `
|
|
9649
|
+
mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
|
|
9650
|
+
completeStewardBrief(input: $input) { ok }
|
|
9651
|
+
}`.trim();
|
|
9652
|
+
var DECISIONS = /* @__PURE__ */ new Set([
|
|
9653
|
+
"immediate",
|
|
9654
|
+
"digest",
|
|
9655
|
+
"suppress"
|
|
9656
|
+
]);
|
|
9657
|
+
var DELIVERY_ID = /^[1-9][0-9]{0,18}$/;
|
|
9658
|
+
function invalid2(message) {
|
|
9659
|
+
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
9660
|
+
}
|
|
9661
|
+
function requireInboxPath(target) {
|
|
9662
|
+
if (!target || typeof target.inboxPath !== "string" || target.inboxPath === "")
|
|
9663
|
+
throw invalid2("steward commands require the steward Session Inbox path");
|
|
9664
|
+
return target.inboxPath;
|
|
9665
|
+
}
|
|
9666
|
+
function requireDeliveryId(value, label = "delivery id") {
|
|
9667
|
+
if (!DELIVERY_ID.test(value))
|
|
9668
|
+
throw invalid2(`${label} must be a positive integer`);
|
|
9669
|
+
return value;
|
|
9670
|
+
}
|
|
9671
|
+
function requireDeliveryIds(values) {
|
|
9672
|
+
if (values.length === 0)
|
|
9673
|
+
throw invalid2("at least one delivery id is required");
|
|
9674
|
+
const unique = /* @__PURE__ */ new Set();
|
|
9675
|
+
for (const value of values) {
|
|
9676
|
+
requireDeliveryId(value);
|
|
9677
|
+
if (unique.has(value)) throw invalid2(`duplicate delivery id ${value}`);
|
|
9678
|
+
unique.add(value);
|
|
9679
|
+
}
|
|
9680
|
+
return [...unique];
|
|
9681
|
+
}
|
|
9682
|
+
function requireDecision(value) {
|
|
9683
|
+
if (!DECISIONS.has(value))
|
|
9684
|
+
throw invalid2("decision must be one of immediate, digest, suppress");
|
|
9685
|
+
return value;
|
|
9686
|
+
}
|
|
9687
|
+
function generateRequestId() {
|
|
9688
|
+
const webcrypto = globalThis.crypto;
|
|
9689
|
+
if (typeof webcrypto?.randomUUID === "function")
|
|
9690
|
+
return webcrypto.randomUUID();
|
|
9691
|
+
const bytes = new Uint8Array(16);
|
|
9692
|
+
if (typeof webcrypto?.getRandomValues === "function") {
|
|
9693
|
+
webcrypto.getRandomValues(bytes);
|
|
9694
|
+
} else {
|
|
9695
|
+
for (let i = 0; i < bytes.length; i += 1)
|
|
9696
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
9697
|
+
}
|
|
9698
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
9699
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
9700
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(
|
|
9701
|
+
""
|
|
9702
|
+
);
|
|
9703
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
9704
|
+
}
|
|
9705
|
+
function requireRequestId(value) {
|
|
9706
|
+
if (value === void 0) return generateRequestId();
|
|
9707
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
9708
|
+
value
|
|
9709
|
+
))
|
|
9710
|
+
throw invalid2("request id must be a UUID");
|
|
9711
|
+
return value;
|
|
9712
|
+
}
|
|
9713
|
+
function emptyResponse() {
|
|
9714
|
+
return new AlvaError("EMPTY_RESPONSE", "steward response was empty", 502);
|
|
9715
|
+
}
|
|
9716
|
+
var StewardResource = class {
|
|
9717
|
+
constructor(client) {
|
|
9718
|
+
this.client = client;
|
|
9719
|
+
}
|
|
9720
|
+
client;
|
|
9721
|
+
async decide(params) {
|
|
9722
|
+
this.client._requireAuth();
|
|
9723
|
+
const reason = params.reason?.trim();
|
|
9724
|
+
if (!reason) throw invalid2("a decision reason is required");
|
|
9725
|
+
const data = await this.graphql(DECIDE, {
|
|
9726
|
+
input: {
|
|
9727
|
+
inboxPath: requireInboxPath(params),
|
|
9728
|
+
deliveryId: requireDeliveryId(params.deliveryId),
|
|
9729
|
+
decision: {
|
|
9730
|
+
decision: requireDecision(params.decision).toUpperCase(),
|
|
9731
|
+
reason
|
|
9732
|
+
}
|
|
9733
|
+
}
|
|
9734
|
+
});
|
|
9735
|
+
const delivery = data.updateStewardDelivery?.delivery;
|
|
9736
|
+
if (!delivery) throw emptyResponse();
|
|
9737
|
+
return { state: delivery.state };
|
|
9738
|
+
}
|
|
9739
|
+
async forward(params) {
|
|
9740
|
+
this.client._requireAuth();
|
|
9741
|
+
const data = await this.graphql(FORWARD, {
|
|
9742
|
+
input: {
|
|
9743
|
+
inboxPath: requireInboxPath(params),
|
|
9744
|
+
deliveryId: requireDeliveryId(params.deliveryId),
|
|
9745
|
+
forward: { requestId: requireRequestId(params.requestId) }
|
|
9746
|
+
}
|
|
9747
|
+
});
|
|
9748
|
+
const delivery = data.updateStewardDelivery?.delivery;
|
|
9749
|
+
if (!delivery || !delivery.channelMessageId) throw emptyResponse();
|
|
9750
|
+
return {
|
|
9751
|
+
channelMessageId: delivery.channelMessageId,
|
|
9752
|
+
state: delivery.state
|
|
9753
|
+
};
|
|
9754
|
+
}
|
|
9755
|
+
async send(params) {
|
|
9756
|
+
this.client._requireAuth();
|
|
9757
|
+
if (typeof params.body !== "string" || params.body.trim() === "")
|
|
9758
|
+
throw invalid2("a message body is required");
|
|
9759
|
+
const data = await this.graphql(SEND, {
|
|
9760
|
+
input: {
|
|
9761
|
+
inboxPath: requireInboxPath(params),
|
|
9762
|
+
requestId: requireRequestId(params.requestId),
|
|
9763
|
+
body: params.body,
|
|
9764
|
+
deliveryIds: requireDeliveryIds(params.deliveryIds)
|
|
9765
|
+
}
|
|
9766
|
+
});
|
|
9767
|
+
const message = data.postStewardMessage?.message;
|
|
9768
|
+
if (!message) throw emptyResponse();
|
|
9769
|
+
return message;
|
|
9770
|
+
}
|
|
9771
|
+
async pending(params) {
|
|
9772
|
+
this.client._requireAuth();
|
|
9773
|
+
const first = params.first ?? 50;
|
|
9774
|
+
if (!Number.isInteger(first) || first < 1 || first > 100)
|
|
9775
|
+
throw invalid2("first must be an integer between 1 and 100");
|
|
9776
|
+
const input = { first };
|
|
9777
|
+
if (params.after !== void 0 && params.after !== "") {
|
|
9778
|
+
input.after = params.after;
|
|
9779
|
+
} else {
|
|
9780
|
+
for (const [label, value] of [
|
|
9781
|
+
["sinceMs", params.sinceMs],
|
|
9782
|
+
["untilMs", params.untilMs]
|
|
9783
|
+
]) {
|
|
9784
|
+
if (value !== void 0 && (!Number.isSafeInteger(value) || value <= 0))
|
|
9785
|
+
throw invalid2(`${label} must be a positive safe integer timestamp`);
|
|
9786
|
+
}
|
|
9787
|
+
if (params.sinceMs !== void 0 && params.untilMs !== void 0 && params.untilMs <= params.sinceMs)
|
|
9788
|
+
throw invalid2("untilMs must be after sinceMs");
|
|
9789
|
+
if (params.sinceMs !== void 0) input.sinceMs = params.sinceMs;
|
|
9790
|
+
if (params.untilMs !== void 0) input.untilMs = params.untilMs;
|
|
9791
|
+
}
|
|
9792
|
+
const data = await this.graphql(PENDING, { inboxPath: requireInboxPath(params), input });
|
|
9793
|
+
const page = data.viewer?.stewardDigestPending;
|
|
9794
|
+
if (!page || !Array.isArray(page.edges)) throw emptyResponse();
|
|
9795
|
+
const windowSinceMs = page.windowSinceMs ?? 0;
|
|
9796
|
+
const windowUntilMs = page.windowUntilMs ?? 0;
|
|
9797
|
+
if (!Number.isSafeInteger(windowSinceMs) || !Number.isSafeInteger(windowUntilMs) || windowSinceMs <= 0 || windowUntilMs <= windowSinceMs)
|
|
9798
|
+
throw emptyResponse();
|
|
9799
|
+
const items = page.edges.map((edge) => edge.node);
|
|
9800
|
+
const nextCursor = page.pageInfo?.hasNextPage === true && page.pageInfo.endCursor ? page.pageInfo.endCursor : null;
|
|
9801
|
+
return {
|
|
9802
|
+
items,
|
|
9803
|
+
nextCursor,
|
|
9804
|
+
windowSinceMs,
|
|
9805
|
+
windowUntilMs
|
|
9806
|
+
};
|
|
9807
|
+
}
|
|
9808
|
+
async briefed(params) {
|
|
9809
|
+
this.client._requireAuth();
|
|
9810
|
+
const digestRunId = params.digestRunId?.trim();
|
|
9811
|
+
if (!digestRunId) throw invalid2("a digest run id is required");
|
|
9812
|
+
const data = await this.graphql(BRIEFED, {
|
|
9813
|
+
input: {
|
|
9814
|
+
inboxPath: requireInboxPath(params),
|
|
9815
|
+
deliveryIds: requireDeliveryIds(params.deliveryIds),
|
|
9816
|
+
digestRunId
|
|
9817
|
+
}
|
|
9818
|
+
});
|
|
9819
|
+
if (data.completeStewardBrief?.ok !== true) throw emptyResponse();
|
|
9820
|
+
return { ok: true };
|
|
9821
|
+
}
|
|
9822
|
+
async graphql(query, variables) {
|
|
9823
|
+
const response = await this.client._request("POST", "/query", {
|
|
9824
|
+
body: { query, variables }
|
|
9825
|
+
});
|
|
9826
|
+
if (!response || typeof response !== "object") throw emptyResponse();
|
|
9827
|
+
if (response.errors?.length) {
|
|
9828
|
+
const codes = response.errors.map((error) => error.extensions?.code);
|
|
9829
|
+
const canonicalCode = new Set(codes).size === 1 && typeof codes[0] === "string" ? codes[0] : void 0;
|
|
9830
|
+
const canonicalStatus = canonicalCode ? GRAPHQL_STATUS_BY_CODE2[canonicalCode] : void 0;
|
|
9831
|
+
throw new AlvaError(
|
|
9832
|
+
canonicalCode !== void 0 && canonicalStatus !== void 0 ? canonicalCode : "GRAPHQL_ERROR",
|
|
9833
|
+
response.errors.map((error) => error.message).filter((message) => typeof message === "string").join("; ") || "GraphQL request failed",
|
|
9834
|
+
canonicalStatus ?? 502,
|
|
9835
|
+
{ errors: response.errors }
|
|
9836
|
+
);
|
|
9837
|
+
}
|
|
9838
|
+
if (!response.data) throw emptyResponse();
|
|
9839
|
+
return response.data;
|
|
9840
|
+
}
|
|
9841
|
+
};
|
|
9842
|
+
|
|
9573
9843
|
// src/resources/tradingPairs.ts
|
|
9574
9844
|
function isRecord(value) {
|
|
9575
9845
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -9755,14 +10025,320 @@ var TradingPairsResource = class {
|
|
|
9755
10025
|
}
|
|
9756
10026
|
};
|
|
9757
10027
|
|
|
10028
|
+
// src/resources/theses.ts
|
|
10029
|
+
var MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
10030
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10031
|
+
var UNPAIRED_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
10032
|
+
var encoder = new TextEncoder();
|
|
10033
|
+
var ThesesResource = class {
|
|
10034
|
+
constructor(client) {
|
|
10035
|
+
this.client = client;
|
|
10036
|
+
}
|
|
10037
|
+
client;
|
|
10038
|
+
async create(params) {
|
|
10039
|
+
this.client._requireAuth();
|
|
10040
|
+
const body = createBody(params);
|
|
10041
|
+
return thesisResponse(
|
|
10042
|
+
await this.client._request("POST", "/api/v1/theses", { body })
|
|
10043
|
+
);
|
|
10044
|
+
}
|
|
10045
|
+
async get(id) {
|
|
10046
|
+
this.client._requireAuth();
|
|
10047
|
+
return thesisGetResponse(
|
|
10048
|
+
await this.client._request("GET", `/api/v1/theses/${requireID(id, "id")}`)
|
|
10049
|
+
);
|
|
10050
|
+
}
|
|
10051
|
+
async update(id, params) {
|
|
10052
|
+
this.client._requireAuth();
|
|
10053
|
+
const body = updateBody(params);
|
|
10054
|
+
return thesisResponse(
|
|
10055
|
+
await this.client._request(
|
|
10056
|
+
"PUT",
|
|
10057
|
+
`/api/v1/theses/${requireID(id, "id")}`,
|
|
10058
|
+
{
|
|
10059
|
+
body
|
|
10060
|
+
}
|
|
10061
|
+
)
|
|
10062
|
+
);
|
|
10063
|
+
}
|
|
10064
|
+
async close(id, params) {
|
|
10065
|
+
this.client._requireAuth();
|
|
10066
|
+
const body = {
|
|
10067
|
+
expected_author_version_id: requireID(
|
|
10068
|
+
params.expected_author_version_id,
|
|
10069
|
+
"expected_author_version_id"
|
|
10070
|
+
)
|
|
10071
|
+
};
|
|
10072
|
+
if (params.note !== void 0) body.note = requireText2(params.note, "note");
|
|
10073
|
+
return thesisResponse(
|
|
10074
|
+
await this.client._request(
|
|
10075
|
+
"POST",
|
|
10076
|
+
`/api/v1/theses/${requireID(id, "id")}/close`,
|
|
10077
|
+
{ body }
|
|
10078
|
+
)
|
|
10079
|
+
);
|
|
10080
|
+
}
|
|
10081
|
+
async delete(id) {
|
|
10082
|
+
this.client._requireAuth();
|
|
10083
|
+
const response = await this.client._request(
|
|
10084
|
+
"DELETE",
|
|
10085
|
+
`/api/v1/theses/${requireID(id, "id")}`
|
|
10086
|
+
);
|
|
10087
|
+
if (response === void 0) return {};
|
|
10088
|
+
if (!isRecord2(response) || Object.keys(response).length !== 0) {
|
|
10089
|
+
throw invalidResponse2("delete response must be {}");
|
|
10090
|
+
}
|
|
10091
|
+
return {};
|
|
10092
|
+
}
|
|
10093
|
+
async rewrite(params) {
|
|
10094
|
+
this.client._requireAuth();
|
|
10095
|
+
const body = requireBody(params.body);
|
|
10096
|
+
const mode = params.mode === void 0 ? "reformat" : requireRewriteMode(params.mode);
|
|
10097
|
+
const response = await this.client._request(
|
|
10098
|
+
"POST",
|
|
10099
|
+
"/api/v1/theses/rewrite",
|
|
10100
|
+
{
|
|
10101
|
+
body: { body, mode }
|
|
10102
|
+
}
|
|
10103
|
+
);
|
|
10104
|
+
if (!isRecord2(response) || typeof response.body !== "string") {
|
|
10105
|
+
throw invalidResponse2("rewrite response must contain a string body");
|
|
10106
|
+
}
|
|
10107
|
+
return { body: responseBody(response.body) };
|
|
10108
|
+
}
|
|
10109
|
+
};
|
|
10110
|
+
function createBody(params) {
|
|
10111
|
+
return {
|
|
10112
|
+
request_id: requireRequestID(params.request_id),
|
|
10113
|
+
body: requireBody(params.body),
|
|
10114
|
+
title: requireTitle(params.title ?? ""),
|
|
10115
|
+
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
10116
|
+
visibility: requireVisibility(params.visibility ?? "public")
|
|
10117
|
+
};
|
|
10118
|
+
}
|
|
10119
|
+
function updateBody(params) {
|
|
10120
|
+
return {
|
|
10121
|
+
request_id: requireRequestID(params.request_id),
|
|
10122
|
+
expected_author_version_id: requireID(
|
|
10123
|
+
params.expected_author_version_id,
|
|
10124
|
+
"expected_author_version_id"
|
|
10125
|
+
),
|
|
10126
|
+
body: requireBody(params.body),
|
|
10127
|
+
title: requireTitle(params.title ?? ""),
|
|
10128
|
+
entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
|
|
10129
|
+
visibility: requireVisibility(params.visibility),
|
|
10130
|
+
editorial: params.editorial ?? false
|
|
10131
|
+
};
|
|
10132
|
+
}
|
|
10133
|
+
function thesisResponse(response) {
|
|
10134
|
+
if (!isRecord2(response) || !isRecord2(response.thesis)) {
|
|
10135
|
+
throw invalidResponse2("response must contain thesis");
|
|
10136
|
+
}
|
|
10137
|
+
const thesis = response.thesis;
|
|
10138
|
+
const value = {
|
|
10139
|
+
id: responseID(thesis.id, "thesis.id"),
|
|
10140
|
+
author_version_id: responseID(
|
|
10141
|
+
thesis.author_version_id,
|
|
10142
|
+
"thesis.author_version_id"
|
|
10143
|
+
),
|
|
10144
|
+
material_version_id: responseID(
|
|
10145
|
+
thesis.material_version_id,
|
|
10146
|
+
"thesis.material_version_id"
|
|
10147
|
+
),
|
|
10148
|
+
title: responseTitle(thesis.title),
|
|
10149
|
+
body: responseBody(thesis.body),
|
|
10150
|
+
entity_ids: responseIDs(thesis.entity_ids, "thesis.entity_ids"),
|
|
10151
|
+
visibility: responseVisibility(thesis.visibility),
|
|
10152
|
+
closed: responseBoolean(thesis.closed, "thesis.closed"),
|
|
10153
|
+
closing_note: responseClosingNote(thesis.closing_note),
|
|
10154
|
+
author_kind: responseText(thesis.author_kind, "thesis.author_kind"),
|
|
10155
|
+
author_ref: responseText(thesis.author_ref, "thesis.author_ref")
|
|
10156
|
+
};
|
|
10157
|
+
return { thesis: value };
|
|
10158
|
+
}
|
|
10159
|
+
function thesisGetResponse(response) {
|
|
10160
|
+
const base = thesisResponse(response);
|
|
10161
|
+
if (!isRecord2(response) || !isRecord2(response.author)) {
|
|
10162
|
+
throw invalidResponse2("response must contain author");
|
|
10163
|
+
}
|
|
10164
|
+
const authorRecord = response.author;
|
|
10165
|
+
const author = {
|
|
10166
|
+
id: responseID(authorRecord.id, "author.id"),
|
|
10167
|
+
kind: responseText(authorRecord.kind, "author.kind"),
|
|
10168
|
+
display_name: responseText(
|
|
10169
|
+
authorRecord.display_name,
|
|
10170
|
+
"author.display_name"
|
|
10171
|
+
),
|
|
10172
|
+
avatar_url: responseText(authorRecord.avatar_url, "author.avatar_url"),
|
|
10173
|
+
username: responseText(authorRecord.username, "author.username")
|
|
10174
|
+
};
|
|
10175
|
+
if (!Array.isArray(response.entities)) {
|
|
10176
|
+
throw invalidResponse2("response must contain entities");
|
|
10177
|
+
}
|
|
10178
|
+
if (response.entities.length !== base.thesis.entity_ids.length) {
|
|
10179
|
+
throw invalidResponse2("entities must match thesis.entity_ids");
|
|
10180
|
+
}
|
|
10181
|
+
const entities = response.entities.map((item, index) => {
|
|
10182
|
+
if (!isRecord2(item))
|
|
10183
|
+
throw invalidResponse2(`entities[${index}] must be an object`);
|
|
10184
|
+
const entity = {
|
|
10185
|
+
id: responseID(item.id, `entities[${index}].id`),
|
|
10186
|
+
ticker: responseText(item.ticker, `entities[${index}].ticker`),
|
|
10187
|
+
name: responseText(item.name, `entities[${index}].name`),
|
|
10188
|
+
icon_url: responseText(item.icon_url, `entities[${index}].icon_url`),
|
|
10189
|
+
kind: responseText(item.kind, `entities[${index}].kind`)
|
|
10190
|
+
};
|
|
10191
|
+
if (entity.id !== base.thesis.entity_ids[index]) {
|
|
10192
|
+
throw invalidResponse2("entities must preserve thesis.entity_ids order");
|
|
10193
|
+
}
|
|
10194
|
+
return entity;
|
|
10195
|
+
});
|
|
10196
|
+
return { thesis: base.thesis, author, entities };
|
|
10197
|
+
}
|
|
10198
|
+
function requireRequestID(value) {
|
|
10199
|
+
if (!UUID.test(value) || /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(value)) {
|
|
10200
|
+
throw invalidArgument("request_id must be a non-zero RFC 4122 UUID");
|
|
10201
|
+
}
|
|
10202
|
+
return value;
|
|
10203
|
+
}
|
|
10204
|
+
function requireID(value, field) {
|
|
10205
|
+
if (typeof value !== "string" || !/^[1-9]\d*$/.test(value)) {
|
|
10206
|
+
throw invalidArgument(`${field} must be a positive int64 decimal string`);
|
|
10207
|
+
}
|
|
10208
|
+
const parsed = BigInt(value);
|
|
10209
|
+
if (parsed > MAX_SIGNED_INT64) {
|
|
10210
|
+
throw invalidArgument(`${field} must be a positive int64 decimal string`);
|
|
10211
|
+
}
|
|
10212
|
+
return value;
|
|
10213
|
+
}
|
|
10214
|
+
function requireIDs(value, field) {
|
|
10215
|
+
if (!Array.isArray(value)) throw invalidArgument(`${field} must be an array`);
|
|
10216
|
+
if (value.length > 20) {
|
|
10217
|
+
throw invalidArgument(`${field} must contain at most 20 IDs`);
|
|
10218
|
+
}
|
|
10219
|
+
return value.map((item, index) => requireID(item, `${field}[${index}]`));
|
|
10220
|
+
}
|
|
10221
|
+
function requireBody(value) {
|
|
10222
|
+
const body = requireText2(value, "body");
|
|
10223
|
+
if (body.trim().length === 0) throw invalidArgument("body must not be blank");
|
|
10224
|
+
if (encoder.encode(body).byteLength > 65536) {
|
|
10225
|
+
throw invalidArgument("body must be at most 65536 UTF-8 bytes");
|
|
10226
|
+
}
|
|
10227
|
+
return body;
|
|
10228
|
+
}
|
|
10229
|
+
function requireTitle(value) {
|
|
10230
|
+
const title = requireText2(value, "title");
|
|
10231
|
+
if (encoder.encode(title).byteLength > 500) {
|
|
10232
|
+
throw invalidArgument("title must be at most 500 UTF-8 bytes");
|
|
10233
|
+
}
|
|
10234
|
+
return title;
|
|
10235
|
+
}
|
|
10236
|
+
function requireVisibility(value) {
|
|
10237
|
+
const visibility = requireText2(value, "visibility");
|
|
10238
|
+
if (visibility !== "public" && visibility !== "private") {
|
|
10239
|
+
throw invalidArgument("visibility must be public or private");
|
|
10240
|
+
}
|
|
10241
|
+
return visibility;
|
|
10242
|
+
}
|
|
10243
|
+
function requireRewriteMode(value) {
|
|
10244
|
+
const mode = requireText2(value, "mode");
|
|
10245
|
+
if (mode === "reformat" || mode === "shorten" || mode === "enrich") {
|
|
10246
|
+
return mode;
|
|
10247
|
+
}
|
|
10248
|
+
throw invalidArgument("mode must be reformat, shorten, or enrich");
|
|
10249
|
+
}
|
|
10250
|
+
function requireText2(value, field) {
|
|
10251
|
+
if (typeof value !== "string")
|
|
10252
|
+
throw invalidArgument(`${field} must be a string`);
|
|
10253
|
+
if (UNPAIRED_SURROGATE.test(value)) {
|
|
10254
|
+
throw invalidArgument(`${field} contains invalid Unicode`);
|
|
10255
|
+
}
|
|
10256
|
+
if ((field === "body" || field === "title" || field === "note") && value.includes("\0")) {
|
|
10257
|
+
throw invalidArgument(`${field} must not contain NUL`);
|
|
10258
|
+
}
|
|
10259
|
+
return value;
|
|
10260
|
+
}
|
|
10261
|
+
function responseID(value, field) {
|
|
10262
|
+
if (typeof value === "number") {
|
|
10263
|
+
throw invalidResponse2(
|
|
10264
|
+
`${field} must be a decimal string; numeric IDs are unsafe`
|
|
10265
|
+
);
|
|
10266
|
+
}
|
|
10267
|
+
try {
|
|
10268
|
+
return requireID(value, field);
|
|
10269
|
+
} catch {
|
|
10270
|
+
throw invalidResponse2(`${field} must be a positive int64 decimal string`);
|
|
10271
|
+
}
|
|
10272
|
+
}
|
|
10273
|
+
function responseIDs(value, field) {
|
|
10274
|
+
if (!Array.isArray(value)) throw invalidResponse2(`${field} must be an array`);
|
|
10275
|
+
if (value.length > 20) {
|
|
10276
|
+
throw invalidResponse2(`${field} must contain at most 20 IDs`);
|
|
10277
|
+
}
|
|
10278
|
+
return value.map((item, index) => responseID(item, `${field}[${index}]`));
|
|
10279
|
+
}
|
|
10280
|
+
function responseText(value, field) {
|
|
10281
|
+
try {
|
|
10282
|
+
return requireText2(value, field);
|
|
10283
|
+
} catch {
|
|
10284
|
+
throw invalidResponse2(`${field} must be valid text`);
|
|
10285
|
+
}
|
|
10286
|
+
}
|
|
10287
|
+
function responseClosingNote(value) {
|
|
10288
|
+
try {
|
|
10289
|
+
return requireText2(value, "note");
|
|
10290
|
+
} catch {
|
|
10291
|
+
throw invalidResponse2("thesis.closing_note must be valid text");
|
|
10292
|
+
}
|
|
10293
|
+
}
|
|
10294
|
+
function responseBoolean(value, field) {
|
|
10295
|
+
if (typeof value !== "boolean")
|
|
10296
|
+
throw invalidResponse2(`${field} must be boolean`);
|
|
10297
|
+
return value;
|
|
10298
|
+
}
|
|
10299
|
+
function responseVisibility(value) {
|
|
10300
|
+
try {
|
|
10301
|
+
return requireVisibility(value);
|
|
10302
|
+
} catch {
|
|
10303
|
+
throw invalidResponse2("thesis.visibility must be public or private");
|
|
10304
|
+
}
|
|
10305
|
+
}
|
|
10306
|
+
function responseBody(value) {
|
|
10307
|
+
try {
|
|
10308
|
+
return requireBody(value);
|
|
10309
|
+
} catch {
|
|
10310
|
+
throw invalidResponse2(
|
|
10311
|
+
"response body must be nonblank valid text at most 65536 UTF-8 bytes"
|
|
10312
|
+
);
|
|
10313
|
+
}
|
|
10314
|
+
}
|
|
10315
|
+
function responseTitle(value) {
|
|
10316
|
+
try {
|
|
10317
|
+
return requireTitle(value);
|
|
10318
|
+
} catch {
|
|
10319
|
+
throw invalidResponse2(
|
|
10320
|
+
"response title must be valid text at most 500 UTF-8 bytes"
|
|
10321
|
+
);
|
|
10322
|
+
}
|
|
10323
|
+
}
|
|
10324
|
+
function isRecord2(value) {
|
|
10325
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10326
|
+
}
|
|
10327
|
+
function invalidArgument(message) {
|
|
10328
|
+
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
10329
|
+
}
|
|
10330
|
+
function invalidResponse2(message) {
|
|
10331
|
+
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
10332
|
+
}
|
|
10333
|
+
|
|
9758
10334
|
// src/client.ts
|
|
9759
10335
|
var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
|
|
9760
10336
|
var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
|
|
9761
|
-
function
|
|
10337
|
+
function isRecord3(value) {
|
|
9762
10338
|
return typeof value === "object" && value !== null;
|
|
9763
10339
|
}
|
|
9764
10340
|
function stringField(value, field) {
|
|
9765
|
-
if (!
|
|
10341
|
+
if (!isRecord3(value)) return void 0;
|
|
9766
10342
|
const fieldValue = value[field];
|
|
9767
10343
|
return typeof fieldValue === "string" && fieldValue ? fieldValue : void 0;
|
|
9768
10344
|
}
|
|
@@ -9776,7 +10352,7 @@ function describeCause(cause) {
|
|
|
9776
10352
|
if (cause.message) details.message = cause.message;
|
|
9777
10353
|
const code = stringField(cause, "code");
|
|
9778
10354
|
if (code) details.code = code;
|
|
9779
|
-
} else if (
|
|
10355
|
+
} else if (isRecord3(cause)) {
|
|
9780
10356
|
const code = stringField(cause, "code");
|
|
9781
10357
|
const name = stringField(cause, "name");
|
|
9782
10358
|
const message = stringField(cause, "message");
|
|
@@ -9804,7 +10380,7 @@ function describeFetchFailure(err) {
|
|
|
9804
10380
|
details.message = String(err);
|
|
9805
10381
|
}
|
|
9806
10382
|
const { message: causeMessage, details: causeDetails } = describeCause(
|
|
9807
|
-
|
|
10383
|
+
isRecord3(err) ? err.cause : void 0
|
|
9808
10384
|
);
|
|
9809
10385
|
if (causeDetails) {
|
|
9810
10386
|
details.cause = causeDetails;
|
|
@@ -9835,6 +10411,8 @@ var AlvaClient = class {
|
|
|
9835
10411
|
originSessionId;
|
|
9836
10412
|
/** Session profile kind associated with originSessionId. */
|
|
9837
10413
|
originSessionKind;
|
|
10414
|
+
/** Host-attached file Session target, distinct from the chat origin header. */
|
|
10415
|
+
originInboxPath;
|
|
9838
10416
|
_fs;
|
|
9839
10417
|
_run;
|
|
9840
10418
|
_deploy;
|
|
@@ -9865,7 +10443,9 @@ var AlvaClient = class {
|
|
|
9865
10443
|
_credits;
|
|
9866
10444
|
_markets;
|
|
9867
10445
|
_schedules;
|
|
10446
|
+
_steward;
|
|
9868
10447
|
_tradingPairs;
|
|
10448
|
+
_theses;
|
|
9869
10449
|
constructor(config) {
|
|
9870
10450
|
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
9871
10451
|
this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
|
|
@@ -9878,6 +10458,7 @@ var AlvaClient = class {
|
|
|
9878
10458
|
this.signal = config.signal;
|
|
9879
10459
|
this.originSessionId = config.originSessionId;
|
|
9880
10460
|
this.originSessionKind = config.originSessionKind;
|
|
10461
|
+
this.originInboxPath = config.originInboxPath;
|
|
9881
10462
|
}
|
|
9882
10463
|
get fs() {
|
|
9883
10464
|
return this._fs ??= new FsResource(this);
|
|
@@ -9969,6 +10550,12 @@ var AlvaClient = class {
|
|
|
9969
10550
|
get schedules() {
|
|
9970
10551
|
return this._schedules ??= new SchedulesResource(this);
|
|
9971
10552
|
}
|
|
10553
|
+
get steward() {
|
|
10554
|
+
return this._steward ??= new StewardResource(this);
|
|
10555
|
+
}
|
|
10556
|
+
get theses() {
|
|
10557
|
+
return this._theses ??= new ThesesResource(this);
|
|
10558
|
+
}
|
|
9972
10559
|
_requireAuth() {
|
|
9973
10560
|
if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
|
|
9974
10561
|
throw new AlvaError(
|
|
@@ -10389,10 +10976,11 @@ var COMMAND_DEFINITIONS = [
|
|
|
10389
10976
|
values: ["id", "workflow-run-id"]
|
|
10390
10977
|
}),
|
|
10391
10978
|
command("deploy run-logs", { values: ["id", "run-id"] }),
|
|
10392
|
-
command("schedule list", { values: ["channel-id"] }),
|
|
10979
|
+
command("schedule list", { values: ["channel-id", "inbox-path"] }),
|
|
10393
10980
|
command("schedule put", {
|
|
10394
10981
|
values: [
|
|
10395
10982
|
"channel-id",
|
|
10983
|
+
"inbox-path",
|
|
10396
10984
|
"name",
|
|
10397
10985
|
"message",
|
|
10398
10986
|
"at",
|
|
@@ -10405,9 +10993,57 @@ var COMMAND_DEFINITIONS = [
|
|
|
10405
10993
|
"max-occurrences"
|
|
10406
10994
|
]
|
|
10407
10995
|
}),
|
|
10408
|
-
command("schedule pause", { values: ["channel-id", "name"] }),
|
|
10409
|
-
command("schedule resume", { values: ["channel-id", "name"] }),
|
|
10410
|
-
command("schedule delete", { values: ["channel-id", "name"] }),
|
|
10996
|
+
command("schedule pause", { values: ["channel-id", "inbox-path", "name"] }),
|
|
10997
|
+
command("schedule resume", { values: ["channel-id", "inbox-path", "name"] }),
|
|
10998
|
+
command("schedule delete", { values: ["channel-id", "inbox-path", "name"] }),
|
|
10999
|
+
command("steward decide", {
|
|
11000
|
+
values: ["inbox-path", "delivery-id", "decision", "reason"]
|
|
11001
|
+
}),
|
|
11002
|
+
command("steward forward", {
|
|
11003
|
+
values: ["inbox-path", "delivery-id", "request-id"]
|
|
11004
|
+
}),
|
|
11005
|
+
command("steward send", {
|
|
11006
|
+
values: ["inbox-path", "body", "delivery-ids", "request-id"]
|
|
11007
|
+
}),
|
|
11008
|
+
command("steward pending", {
|
|
11009
|
+
values: ["inbox-path", "after", "since", "until", "first"]
|
|
11010
|
+
}),
|
|
11011
|
+
command("steward briefed", {
|
|
11012
|
+
values: ["inbox-path", "delivery-ids", "digest-run-id"]
|
|
11013
|
+
}),
|
|
11014
|
+
command("thesis create", {
|
|
11015
|
+
values: [
|
|
11016
|
+
"request-id",
|
|
11017
|
+
"body",
|
|
11018
|
+
"body-file",
|
|
11019
|
+
"title",
|
|
11020
|
+
"entity-ids",
|
|
11021
|
+
"visibility"
|
|
11022
|
+
],
|
|
11023
|
+
booleans: ["body-stdin"]
|
|
11024
|
+
}),
|
|
11025
|
+
command("thesis get", { values: ["id"] }),
|
|
11026
|
+
command("thesis update", {
|
|
11027
|
+
values: [
|
|
11028
|
+
"id",
|
|
11029
|
+
"request-id",
|
|
11030
|
+
"expected-author-version-id",
|
|
11031
|
+
"body",
|
|
11032
|
+
"body-file",
|
|
11033
|
+
"title",
|
|
11034
|
+
"entity-ids",
|
|
11035
|
+
"visibility"
|
|
11036
|
+
],
|
|
11037
|
+
booleans: ["body-stdin", "editorial"]
|
|
11038
|
+
}),
|
|
11039
|
+
command("thesis close", {
|
|
11040
|
+
values: ["id", "expected-author-version-id", "note"]
|
|
11041
|
+
}),
|
|
11042
|
+
command("thesis delete", { values: ["id"] }),
|
|
11043
|
+
command("thesis rewrite", {
|
|
11044
|
+
values: ["body", "body-file", "mode"],
|
|
11045
|
+
booleans: ["body-stdin"]
|
|
11046
|
+
}),
|
|
10411
11047
|
command("service-account create", { values: ["name"] }),
|
|
10412
11048
|
command("service-account list"),
|
|
10413
11049
|
command("service-account delete", { values: ["id"] }),
|
|
@@ -15076,7 +15712,7 @@ function formatTradingPairResolved(result) {
|
|
|
15076
15712
|
}
|
|
15077
15713
|
|
|
15078
15714
|
// src/cli/dispatch.ts
|
|
15079
|
-
var CLI_VERSION = true ? "0.28.
|
|
15715
|
+
var CLI_VERSION = true ? "0.28.1-beta.0" : "dev";
|
|
15080
15716
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
15081
15717
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
15082
15718
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -15119,6 +15755,8 @@ Commands:
|
|
|
15119
15755
|
run Execute code in the Alva runtime
|
|
15120
15756
|
deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)
|
|
15121
15757
|
schedule Agent-owned named schedules (list, put, pause, resume, delete)
|
|
15758
|
+
steward Push steward reports for a Session Inbox (decide, forward, send, pending, briefed)
|
|
15759
|
+
thesis Authored thesis lifecycle (create, get, update, close, delete, rewrite)
|
|
15122
15760
|
service-account Restricted run-as identities (create, list, delete, grant, revoke)
|
|
15123
15761
|
release Feed and playbook releases (feed, playbook-draft, playbook)
|
|
15124
15762
|
lint Design-system lint (playbook)
|
|
@@ -15164,6 +15802,41 @@ Quick start:
|
|
|
15164
15802
|
alva configure --api-key alva_your_key_here
|
|
15165
15803
|
alva whoami`;
|
|
15166
15804
|
var COMMAND_HELP = {
|
|
15805
|
+
steward: `Usage: alva steward <subcommand> [options]
|
|
15806
|
+
|
|
15807
|
+
Report a push steward's decisions for Feed alerts routed to its Session Inbox,
|
|
15808
|
+
forward or send messages to the steward's own Channel, and run the Daily Brief.
|
|
15809
|
+
Embedded commands target the host-attached Inbox; the terminal CLI requires
|
|
15810
|
+
--inbox-path.
|
|
15811
|
+
|
|
15812
|
+
Subcommands:
|
|
15813
|
+
decide Record the decision for one delivery (required before forward/send)
|
|
15814
|
+
forward Re-post the original alert card by reference (immediate only)
|
|
15815
|
+
send Post steward-authored Markdown covering the listed deliveries
|
|
15816
|
+
pending Page deliveries decided "digest" that no brief has covered yet
|
|
15817
|
+
briefed Record that a Daily Brief covered the listed deliveries
|
|
15818
|
+
|
|
15819
|
+
Flags:
|
|
15820
|
+
--inbox-path <path> Steward Session Inbox (terminal CLI only)
|
|
15821
|
+
--delivery-id <id> One delivery (decide, forward)
|
|
15822
|
+
--delivery-ids <a,b,c> Comma-separated deliveries (send, briefed)
|
|
15823
|
+
--decision <immediate|digest|suppress>
|
|
15824
|
+
--reason <text> Short audit note stored with the decision
|
|
15825
|
+
--body <markdown> Message body (send)
|
|
15826
|
+
--request-id <uuid> Idempotency key; generated when omitted
|
|
15827
|
+
--after <cursor> Opaque cursor from the previous page's nextCursor (pending)
|
|
15828
|
+
--since <RFC3339> First page only: lower bound on decision time (pending)
|
|
15829
|
+
--until <RFC3339> First page only: fixed upper bound of the Brief window; later pages inherit it through the cursor (pending)
|
|
15830
|
+
--first <n> Page size, 1-100 (pending)
|
|
15831
|
+
--digest-run-id <id> The request id echoed by the send that carried these deliveries (briefed)
|
|
15832
|
+
|
|
15833
|
+
Examples (terminal; the embedded Agent tool omits --inbox-path):
|
|
15834
|
+
alva steward decide --inbox-path /alva/home/alice/agents/steward-9/.pi/agent/sessions/main.inbox.jsonl --delivery-id 123 --decision immediate --reason "guidance cut 15%"
|
|
15835
|
+
alva steward forward --inbox-path <inbox> --delivery-id 123
|
|
15836
|
+
alva steward send --inbox-path <inbox> --delivery-ids 124,125 --body "Two related moves..."
|
|
15837
|
+
alva steward pending --inbox-path <inbox> --until 2026-09-15T13:00:00Z
|
|
15838
|
+
alva steward pending --inbox-path <inbox> --after <nextCursor from the previous page>
|
|
15839
|
+
alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
|
|
15167
15840
|
configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
|
|
15168
15841
|
|
|
15169
15842
|
Save API credentials to ~/.config/alva/config.json (mode 0600).
|
|
@@ -15508,7 +16181,7 @@ Build-time verify (fire once, then poll up to 5 minutes):
|
|
|
15508
16181
|
--run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
|
|
15509
16182
|
schedule: `Usage: alva schedule <subcommand> [options]
|
|
15510
16183
|
|
|
15511
|
-
Manage named future and recurring work for an Alva Channel Agent.
|
|
16184
|
+
Manage named future and recurring work for an Alva Channel Agent or Session Inbox.
|
|
15512
16185
|
|
|
15513
16186
|
Subcommands:
|
|
15514
16187
|
list List schedules
|
|
@@ -15519,6 +16192,7 @@ Subcommands:
|
|
|
15519
16192
|
|
|
15520
16193
|
Common flags:
|
|
15521
16194
|
--channel-id <id> Target Channel; omit for your Agent Channel
|
|
16195
|
+
--inbox-path <path> Existing Session Inbox; mutually exclusive with --channel-id
|
|
15522
16196
|
--name <name> Stable schedule name
|
|
15523
16197
|
|
|
15524
16198
|
Put flags:
|
|
@@ -15534,6 +16208,7 @@ Examples:
|
|
|
15534
16208
|
alva schedule put --name review --message "Review status" --after PT30M
|
|
15535
16209
|
alva schedule put --name market-open --message "Review the open" --cron "30 9 * * 1-5" --timezone America/New_York
|
|
15536
16210
|
alva schedule list
|
|
16211
|
+
alva schedule put --inbox-path /alva/home/alice/session.inbox.jsonl --name review --message "Review status" --after PT30M
|
|
15537
16212
|
alva schedule pause --name market-open`,
|
|
15538
16213
|
"service-account": `Usage: alva service-account <subcommand> [options]
|
|
15539
16214
|
|
|
@@ -16403,7 +17078,56 @@ Subcommands:
|
|
|
16403
17078
|
|
|
16404
17079
|
Examples:
|
|
16405
17080
|
alva arrays token ensure
|
|
16406
|
-
alva arrays token status
|
|
17081
|
+
alva arrays token status`,
|
|
17082
|
+
thesis: `Usage: alva thesis <subcommand> [options]
|
|
17083
|
+
|
|
17084
|
+
Create, read, update, close, delete, or explicitly rewrite an authored thesis.
|
|
17085
|
+
Backend owns Signal/Alert setup; the CLI never starts them separately.
|
|
17086
|
+
Create and update never rewrite text automatically.
|
|
17087
|
+
|
|
17088
|
+
Subcommands:
|
|
17089
|
+
create Create a thesis
|
|
17090
|
+
get Get one thesis
|
|
17091
|
+
update Replaces document fields: body, title, entities, visibility (all sent in full)
|
|
17092
|
+
close Close the current author version with an optional note
|
|
17093
|
+
delete Delete a thesis
|
|
17094
|
+
rewrite Explicitly request a candidate body rewrite; never called by another command
|
|
17095
|
+
|
|
17096
|
+
Body input (create, update, rewrite): choose exactly one:
|
|
17097
|
+
--body <text> Literal text
|
|
17098
|
+
--body-file <path> Local UTF-8 text file (terminal CLI only; malformed bytes fail)
|
|
17099
|
+
--body-stdin Read UTF-8 text from stdin (terminal CLI only; malformed bytes fail)
|
|
17100
|
+
|
|
17101
|
+
Create and update require --request-id: a caller-supplied non-zero UUID. The
|
|
17102
|
+
toolkit does not generate or retry request IDs. If a response is ambiguous
|
|
17103
|
+
after a write, reuse the same request ID only after resolving that ambiguity with
|
|
17104
|
+
the backend; do not send a fresh ID. Create defaults --visibility to public.
|
|
17105
|
+
Update requires --visibility explicitly so it cannot inadvertently publish.
|
|
17106
|
+
|
|
17107
|
+
Other flags:
|
|
17108
|
+
create --request-id <uuid> --body ... [--title <text>] [--entity-ids <id,id>] [--visibility <value>]
|
|
17109
|
+
get --id <signed-int64-decimal>
|
|
17110
|
+
update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--editorial]
|
|
17111
|
+
close --id <id> --expected-author-version-id <id> [--note <text>]
|
|
17112
|
+
delete --id <id>
|
|
17113
|
+
rewrite --body ... [--mode reformat|shorten|enrich]
|
|
17114
|
+
|
|
17115
|
+
Rewrite mode defaults only when omitted, and the toolkit always sends the
|
|
17116
|
+
canonical default \`reformat\`. \`shorten\` removes redundancy while retaining the
|
|
17117
|
+
core view, reasons, and qualifiers. \`enrich\` only expands supplied reasoning;
|
|
17118
|
+
it must not invent factual evidence, numbers, or citations. Rewrite returns a
|
|
17119
|
+
candidate only: it never creates, updates, retries, or chooses a mode from body
|
|
17120
|
+
length or errors.
|
|
17121
|
+
|
|
17122
|
+
IDs are decimal strings, never JavaScript numbers; provide at most 20 entity
|
|
17123
|
+
IDs. Body text must be nonblank,
|
|
17124
|
+
valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
|
|
17125
|
+
500 UTF-8 bytes. Text is passed without trimming or newline conversion.
|
|
17126
|
+
|
|
17127
|
+
Examples:
|
|
17128
|
+
alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two'
|
|
17129
|
+
alva thesis update --id 9223372036854775807 --request-id 123e4567-e89b-42d3-a456-426614174000 --expected-author-version-id 9223372036854775806 --body-file ./thesis.md --visibility private
|
|
17130
|
+
printf '%s' 'Draft body' | alva thesis rewrite --body-stdin --mode shorten`
|
|
16407
17131
|
};
|
|
16408
17132
|
function parseFlags(argv) {
|
|
16409
17133
|
const flags = {};
|
|
@@ -16782,6 +17506,22 @@ function feedVisibility(val) {
|
|
|
16782
17506
|
"feed"
|
|
16783
17507
|
);
|
|
16784
17508
|
}
|
|
17509
|
+
function thesisVisibility(value) {
|
|
17510
|
+
if (value === "public" || value === "private") return value;
|
|
17511
|
+
throw new CliUsageError(
|
|
17512
|
+
`--visibility must be public or private for 'thesis', got '${value}'`,
|
|
17513
|
+
"thesis"
|
|
17514
|
+
);
|
|
17515
|
+
}
|
|
17516
|
+
function thesisRewriteMode(value) {
|
|
17517
|
+
if (value === "reformat" || value === "shorten" || value === "enrich") {
|
|
17518
|
+
return value;
|
|
17519
|
+
}
|
|
17520
|
+
throw new CliUsageError(
|
|
17521
|
+
`--mode must be reformat, shorten, or enrich for 'thesis rewrite', got '${value}'`,
|
|
17522
|
+
"thesis"
|
|
17523
|
+
);
|
|
17524
|
+
}
|
|
16785
17525
|
function parseCreditsTimestamp(value, flag, command2) {
|
|
16786
17526
|
const trimmed = value.trim();
|
|
16787
17527
|
if (/^\d+$/.test(trimmed)) {
|
|
@@ -16818,8 +17558,20 @@ function parseCreditsDurationMs(value) {
|
|
|
16818
17558
|
}
|
|
16819
17559
|
return durationMs;
|
|
16820
17560
|
}
|
|
16821
|
-
async function
|
|
16822
|
-
|
|
17561
|
+
async function scheduleTarget(client, flags) {
|
|
17562
|
+
if (flags["inbox-path"] !== void 0) {
|
|
17563
|
+
if (flags["channel-id"] !== void 0)
|
|
17564
|
+
throw new CliUsageError(
|
|
17565
|
+
"--inbox-path and --channel-id are mutually exclusive",
|
|
17566
|
+
"schedule"
|
|
17567
|
+
);
|
|
17568
|
+
if (flags["inbox-path"] === "")
|
|
17569
|
+
throw new CliUsageError("--inbox-path must not be empty", "schedule");
|
|
17570
|
+
return { inboxPath: flags["inbox-path"] };
|
|
17571
|
+
}
|
|
17572
|
+
return {
|
|
17573
|
+
channelId: flags["channel-id"] ?? await client.schedules.agentChannelId()
|
|
17574
|
+
};
|
|
16823
17575
|
}
|
|
16824
17576
|
function scheduleRuleFromFlags(flags) {
|
|
16825
17577
|
const selected = ["after", "at", "every", "cron"].filter(
|
|
@@ -17012,6 +17764,73 @@ function readLocalTextFile(path, command2, flag, deps) {
|
|
|
17012
17764
|
}
|
|
17013
17765
|
return deps.localFiles.readText(path);
|
|
17014
17766
|
}
|
|
17767
|
+
async function thesisBodyFromFlags(flags, command2, deps) {
|
|
17768
|
+
const sources = [
|
|
17769
|
+
flags.body !== void 0 ? "body" : void 0,
|
|
17770
|
+
flags["body-file"] !== void 0 ? "body-file" : void 0,
|
|
17771
|
+
flags["body-stdin"] === "true" ? "body-stdin" : void 0
|
|
17772
|
+
].filter((source) => source !== void 0);
|
|
17773
|
+
if (sources.length !== 1) {
|
|
17774
|
+
throw new CliUsageError(
|
|
17775
|
+
`${command2} requires exactly one of --body, --body-file, or --body-stdin`,
|
|
17776
|
+
"thesis"
|
|
17777
|
+
);
|
|
17778
|
+
}
|
|
17779
|
+
if (sources[0] === "body") return flags.body;
|
|
17780
|
+
if (sources[0] === "body-file") {
|
|
17781
|
+
assertLocalFileAvailable(command2, "--body-file", deps);
|
|
17782
|
+
if (!deps?.localFiles) {
|
|
17783
|
+
throw new Error("Local file access requires a Node.js runtime adapter.");
|
|
17784
|
+
}
|
|
17785
|
+
return strictThesisUTF8(
|
|
17786
|
+
deps.localFiles.readBytes(flags["body-file"]),
|
|
17787
|
+
command2,
|
|
17788
|
+
"--body-file"
|
|
17789
|
+
);
|
|
17790
|
+
}
|
|
17791
|
+
if (deps?.runtime === "jagent") {
|
|
17792
|
+
throw localFileUnsupported(command2, "--body-stdin");
|
|
17793
|
+
}
|
|
17794
|
+
if (!deps?.readStdinBytes) {
|
|
17795
|
+
throw new Error("Thesis stdin requires a Node.js byte-stdin adapter.");
|
|
17796
|
+
}
|
|
17797
|
+
return strictThesisUTF8(await deps.readStdinBytes(), command2, "--body-stdin");
|
|
17798
|
+
}
|
|
17799
|
+
function thesisEntityIDs(flags) {
|
|
17800
|
+
const raw = flags["entity-ids"];
|
|
17801
|
+
if (raw === void 0 || raw === "") return [];
|
|
17802
|
+
const entityIDs = raw.split(",").map((id) => id.trim());
|
|
17803
|
+
if (entityIDs.some((id) => id === "")) {
|
|
17804
|
+
throw new CliUsageError(
|
|
17805
|
+
"--entity-ids must not contain empty IDs",
|
|
17806
|
+
"thesis"
|
|
17807
|
+
);
|
|
17808
|
+
}
|
|
17809
|
+
return entityIDs;
|
|
17810
|
+
}
|
|
17811
|
+
function strictThesisUTF8(value, command2, flag) {
|
|
17812
|
+
const bytes = toByteView(value);
|
|
17813
|
+
if (bytes === void 0) {
|
|
17814
|
+
throw new Error(`${flag} requires a byte-capable Node.js runtime adapter.`);
|
|
17815
|
+
}
|
|
17816
|
+
try {
|
|
17817
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
17818
|
+
bytes
|
|
17819
|
+
);
|
|
17820
|
+
} catch {
|
|
17821
|
+
throw new CliUsageError(
|
|
17822
|
+
`${flag} must contain valid UTF-8 for '${command2}'`,
|
|
17823
|
+
"thesis"
|
|
17824
|
+
);
|
|
17825
|
+
}
|
|
17826
|
+
}
|
|
17827
|
+
function toByteView(value) {
|
|
17828
|
+
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
17829
|
+
if (ArrayBuffer.isView(value)) {
|
|
17830
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
17831
|
+
}
|
|
17832
|
+
return void 0;
|
|
17833
|
+
}
|
|
17015
17834
|
function readLocalFileBytes(path, command2, flag, deps) {
|
|
17016
17835
|
assertLocalFileAvailable(command2, flag, deps);
|
|
17017
17836
|
if (!deps?.localFiles) {
|
|
@@ -17458,8 +18277,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
17458
18277
|
}
|
|
17459
18278
|
switch (subcommand) {
|
|
17460
18279
|
case "list": {
|
|
17461
|
-
|
|
17462
|
-
return client.schedules.list({ channelId });
|
|
18280
|
+
return client.schedules.list(await scheduleTarget(client, flags));
|
|
17463
18281
|
}
|
|
17464
18282
|
case "put": {
|
|
17465
18283
|
const rule = scheduleRuleFromFlags(flags);
|
|
@@ -17472,9 +18290,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
17472
18290
|
}
|
|
17473
18291
|
const name = requireFlag(flags, "name", "schedule put");
|
|
17474
18292
|
const text = requireFlag(flags, "message", "schedule put");
|
|
17475
|
-
const
|
|
18293
|
+
const target = await scheduleTarget(client, flags);
|
|
17476
18294
|
return client.schedules.put({
|
|
17477
|
-
|
|
18295
|
+
...target,
|
|
17478
18296
|
name,
|
|
17479
18297
|
text,
|
|
17480
18298
|
rule,
|
|
@@ -17483,25 +18301,25 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
17483
18301
|
}
|
|
17484
18302
|
case "pause": {
|
|
17485
18303
|
const name = requireFlag(flags, "name", "schedule pause");
|
|
17486
|
-
const
|
|
18304
|
+
const target = await scheduleTarget(client, flags);
|
|
17487
18305
|
return client.schedules.pause({
|
|
17488
|
-
|
|
18306
|
+
...target,
|
|
17489
18307
|
name
|
|
17490
18308
|
});
|
|
17491
18309
|
}
|
|
17492
18310
|
case "resume": {
|
|
17493
18311
|
const name = requireFlag(flags, "name", "schedule resume");
|
|
17494
|
-
const
|
|
18312
|
+
const target = await scheduleTarget(client, flags);
|
|
17495
18313
|
return client.schedules.resume({
|
|
17496
|
-
|
|
18314
|
+
...target,
|
|
17497
18315
|
name
|
|
17498
18316
|
});
|
|
17499
18317
|
}
|
|
17500
18318
|
case "delete": {
|
|
17501
18319
|
const name = requireFlag(flags, "name", "schedule delete");
|
|
17502
|
-
const
|
|
18320
|
+
const target = await scheduleTarget(client, flags);
|
|
17503
18321
|
await client.schedules.delete({
|
|
17504
|
-
|
|
18322
|
+
...target,
|
|
17505
18323
|
name
|
|
17506
18324
|
});
|
|
17507
18325
|
return { deleted: true };
|
|
@@ -17513,6 +18331,133 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
17513
18331
|
);
|
|
17514
18332
|
}
|
|
17515
18333
|
}
|
|
18334
|
+
case "steward": {
|
|
18335
|
+
if (!subcommand) {
|
|
18336
|
+
throw new CliUsageError("Missing subcommand for steward", "steward");
|
|
18337
|
+
}
|
|
18338
|
+
const inboxPath = requireFlag(
|
|
18339
|
+
flags,
|
|
18340
|
+
"inbox-path",
|
|
18341
|
+
`steward ${subcommand}`
|
|
18342
|
+
);
|
|
18343
|
+
const ids = (name) => requireFlag(flags, name, `steward ${subcommand}`).split(",").map((value) => value.trim()).filter((value) => value !== "");
|
|
18344
|
+
switch (subcommand) {
|
|
18345
|
+
case "decide":
|
|
18346
|
+
return client.steward.decide({
|
|
18347
|
+
inboxPath,
|
|
18348
|
+
deliveryId: requireFlag(flags, "delivery-id", "steward decide"),
|
|
18349
|
+
decision: requireDecision(
|
|
18350
|
+
requireFlag(flags, "decision", "steward decide")
|
|
18351
|
+
),
|
|
18352
|
+
reason: requireFlag(flags, "reason", "steward decide")
|
|
18353
|
+
});
|
|
18354
|
+
case "forward":
|
|
18355
|
+
return client.steward.forward({
|
|
18356
|
+
inboxPath,
|
|
18357
|
+
deliveryId: requireFlag(flags, "delivery-id", "steward forward"),
|
|
18358
|
+
requestId: flags["request-id"]
|
|
18359
|
+
});
|
|
18360
|
+
case "send":
|
|
18361
|
+
return client.steward.send({
|
|
18362
|
+
inboxPath,
|
|
18363
|
+
body: requireFlag(flags, "body", "steward send"),
|
|
18364
|
+
deliveryIds: ids("delivery-ids"),
|
|
18365
|
+
requestId: flags["request-id"]
|
|
18366
|
+
});
|
|
18367
|
+
case "pending": {
|
|
18368
|
+
const parseTime = (name) => {
|
|
18369
|
+
const value = flags[name];
|
|
18370
|
+
if (value === void 0) return void 0;
|
|
18371
|
+
try {
|
|
18372
|
+
return parseRfc3339Milliseconds(value);
|
|
18373
|
+
} catch {
|
|
18374
|
+
throw new CliUsageError(
|
|
18375
|
+
`--${name} must be an RFC3339 timestamp with a timezone`,
|
|
18376
|
+
"steward"
|
|
18377
|
+
);
|
|
18378
|
+
}
|
|
18379
|
+
};
|
|
18380
|
+
const first = flags.first === void 0 ? void 0 : Number(flags.first);
|
|
18381
|
+
return client.steward.pending({
|
|
18382
|
+
inboxPath,
|
|
18383
|
+
after: flags.after,
|
|
18384
|
+
sinceMs: parseTime("since"),
|
|
18385
|
+
untilMs: parseTime("until"),
|
|
18386
|
+
first
|
|
18387
|
+
});
|
|
18388
|
+
}
|
|
18389
|
+
case "briefed":
|
|
18390
|
+
return client.steward.briefed({
|
|
18391
|
+
inboxPath,
|
|
18392
|
+
deliveryIds: ids("delivery-ids"),
|
|
18393
|
+
digestRunId: requireFlag(flags, "digest-run-id", "steward briefed")
|
|
18394
|
+
});
|
|
18395
|
+
default:
|
|
18396
|
+
throw new CliUsageError(
|
|
18397
|
+
`Unknown subcommand: steward ${subcommand}`,
|
|
18398
|
+
"steward"
|
|
18399
|
+
);
|
|
18400
|
+
}
|
|
18401
|
+
}
|
|
18402
|
+
case "thesis": {
|
|
18403
|
+
if (!subcommand) {
|
|
18404
|
+
throw new CliUsageError("Missing subcommand for thesis", "thesis");
|
|
18405
|
+
}
|
|
18406
|
+
switch (subcommand) {
|
|
18407
|
+
case "create":
|
|
18408
|
+
return client.theses.create({
|
|
18409
|
+
request_id: requireFlag(flags, "request-id", "thesis create"),
|
|
18410
|
+
body: await thesisBodyFromFlags(flags, "thesis create", deps),
|
|
18411
|
+
title: flags.title ?? "",
|
|
18412
|
+
entity_ids: thesisEntityIDs(flags),
|
|
18413
|
+
visibility: flags.visibility === void 0 ? "public" : thesisVisibility(flags.visibility)
|
|
18414
|
+
});
|
|
18415
|
+
case "get":
|
|
18416
|
+
return client.theses.get(requireFlag(flags, "id", "thesis get"));
|
|
18417
|
+
case "update":
|
|
18418
|
+
return client.theses.update(
|
|
18419
|
+
requireFlag(flags, "id", "thesis update"),
|
|
18420
|
+
{
|
|
18421
|
+
request_id: requireFlag(flags, "request-id", "thesis update"),
|
|
18422
|
+
expected_author_version_id: requireFlag(
|
|
18423
|
+
flags,
|
|
18424
|
+
"expected-author-version-id",
|
|
18425
|
+
"thesis update"
|
|
18426
|
+
),
|
|
18427
|
+
body: await thesisBodyFromFlags(flags, "thesis update", deps),
|
|
18428
|
+
title: flags.title ?? "",
|
|
18429
|
+
entity_ids: thesisEntityIDs(flags),
|
|
18430
|
+
visibility: thesisVisibility(
|
|
18431
|
+
requireFlag(flags, "visibility", "thesis update")
|
|
18432
|
+
),
|
|
18433
|
+
editorial: boolFlag(flags.editorial) ?? false
|
|
18434
|
+
}
|
|
18435
|
+
);
|
|
18436
|
+
case "close":
|
|
18437
|
+
return client.theses.close(requireFlag(flags, "id", "thesis close"), {
|
|
18438
|
+
expected_author_version_id: requireFlag(
|
|
18439
|
+
flags,
|
|
18440
|
+
"expected-author-version-id",
|
|
18441
|
+
"thesis close"
|
|
18442
|
+
),
|
|
18443
|
+
note: flags.note
|
|
18444
|
+
});
|
|
18445
|
+
case "delete":
|
|
18446
|
+
return client.theses.delete(
|
|
18447
|
+
requireFlag(flags, "id", "thesis delete")
|
|
18448
|
+
);
|
|
18449
|
+
case "rewrite":
|
|
18450
|
+
return client.theses.rewrite({
|
|
18451
|
+
body: await thesisBodyFromFlags(flags, "thesis rewrite", deps),
|
|
18452
|
+
mode: flags.mode === void 0 ? "reformat" : thesisRewriteMode(flags.mode)
|
|
18453
|
+
});
|
|
18454
|
+
default:
|
|
18455
|
+
throw new CliUsageError(
|
|
18456
|
+
`Unknown subcommand: thesis ${subcommand}`,
|
|
18457
|
+
"thesis"
|
|
18458
|
+
);
|
|
18459
|
+
}
|
|
18460
|
+
}
|
|
17516
18461
|
case "service-account": {
|
|
17517
18462
|
if (!subcommand)
|
|
17518
18463
|
throw new CliUsageError(
|
|
@@ -18948,9 +19893,12 @@ function configureFetchTimeout(timeoutMs) {
|
|
|
18948
19893
|
configuredRunFetchTimeoutMs = timeoutMs;
|
|
18949
19894
|
}
|
|
18950
19895
|
async function readAllStdin() {
|
|
19896
|
+
return Buffer.from(await readAllStdinBytes()).toString("utf8");
|
|
19897
|
+
}
|
|
19898
|
+
async function readAllStdinBytes() {
|
|
18951
19899
|
const chunks = [];
|
|
18952
19900
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
18953
|
-
return Buffer.concat(chunks)
|
|
19901
|
+
return Buffer.concat(chunks);
|
|
18954
19902
|
}
|
|
18955
19903
|
var nodeRuntimeDeps = {
|
|
18956
19904
|
runtime: "nodejs",
|
|
@@ -18962,6 +19910,7 @@ var nodeRuntimeDeps = {
|
|
|
18962
19910
|
writeBytes: (path, data) => fs.writeFileSync(path, data)
|
|
18963
19911
|
},
|
|
18964
19912
|
readStdin: readAllStdin,
|
|
19913
|
+
readStdinBytes: readAllStdinBytes,
|
|
18965
19914
|
randomUUID: () => crypto3.randomUUID(),
|
|
18966
19915
|
configureFetchTimeout,
|
|
18967
19916
|
writeBrokerResult: async (envelope, exitCode) => {
|