@alva-ai/toolkit 0.28.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/dist/dispatch.js CHANGED
@@ -5944,6 +5944,18 @@ var require_dist = __commonJS({
5944
5944
  });
5945
5945
 
5946
5946
  // src/error.ts
5947
+ var AlvaError = class extends Error {
5948
+ code;
5949
+ status;
5950
+ details;
5951
+ constructor(code, message, status, details) {
5952
+ super(message);
5953
+ this.name = "AlvaError";
5954
+ this.code = code;
5955
+ this.status = status;
5956
+ this.details = details;
5957
+ }
5958
+ };
5947
5959
  var CliUsageError = class extends Error {
5948
5960
  command;
5949
5961
  constructor(message, command2) {
@@ -5992,6 +6004,74 @@ function action(path, options, actionName) {
5992
6004
  return { ...embeddedCommand(path, options), action: actionName };
5993
6005
  }
5994
6006
  var EMBEDDED_COMMAND_DEFINITIONS = [
6007
+ action("schedule list", {}, "schedule-self"),
6008
+ action(
6009
+ "schedule put",
6010
+ {
6011
+ values: [
6012
+ "name",
6013
+ "message",
6014
+ "after",
6015
+ "at",
6016
+ "every",
6017
+ "cron",
6018
+ "timezone",
6019
+ "starts-at",
6020
+ "until",
6021
+ "max-occurrences"
6022
+ ]
6023
+ },
6024
+ "schedule-self"
6025
+ ),
6026
+ action("schedule pause", { values: ["name"] }, "schedule-self"),
6027
+ action("schedule resume", { values: ["name"] }, "schedule-self"),
6028
+ action("schedule delete", { values: ["name"] }, "schedule-self"),
6029
+ action(
6030
+ "steward decide",
6031
+ { values: ["delivery-id", "decision", "reason"] },
6032
+ "steward-self"
6033
+ ),
6034
+ action(
6035
+ "steward forward",
6036
+ { values: ["delivery-id", "request-id"] },
6037
+ "steward-self"
6038
+ ),
6039
+ action(
6040
+ "steward send",
6041
+ { values: ["body", "delivery-ids", "request-id"] },
6042
+ "steward-self"
6043
+ ),
6044
+ action(
6045
+ "steward pending",
6046
+ { values: ["after", "since", "until", "first"] },
6047
+ "steward-self"
6048
+ ),
6049
+ action(
6050
+ "steward briefed",
6051
+ { values: ["delivery-ids", "digest-run-id"] },
6052
+ "steward-self"
6053
+ ),
6054
+ route("thesis create", "thesis create", {
6055
+ values: ["request-id", "body", "title", "entity-ids", "visibility"]
6056
+ }),
6057
+ route("thesis get", "thesis get", { values: ["id"] }),
6058
+ route("thesis update", "thesis update", {
6059
+ values: [
6060
+ "id",
6061
+ "request-id",
6062
+ "expected-author-version-id",
6063
+ "body",
6064
+ "title",
6065
+ "entity-ids",
6066
+ "visibility"
6067
+ ],
6068
+ booleans: ["editorial"]
6069
+ }),
6070
+ route("thesis close", "thesis close", {
6071
+ values: ["id", "expected-author-version-id", "note"]
6072
+ }),
6073
+ route("thesis delete", "thesis delete", { values: ["id"] }),
6074
+ route("thesis rewrite", "thesis rewrite", { values: ["body", "mode"] }),
5995
6075
  route("account whoami", "whoami"),
5996
6076
  route("account credits wallet", "credits wallet"),
5997
6077
  route("account credits items", "credits items", {
@@ -6390,6 +6470,9 @@ Commands:
6390
6470
  markets Read market narrative and earnings context
6391
6471
  trading-pairs Discover and strictly verify canonical trading pairs
6392
6472
  automation Create and operate scheduled automations
6473
+ schedule Manage future messages for this Session Inbox
6474
+ steward Push steward reports for this Session Inbox (decide, forward, send, pending, briefed)
6475
+ thesis Create and manage authored theses
6393
6476
  playbooks Discover, build, release, and manage Playbooks
6394
6477
  alert Manage personal automation alert bindings
6395
6478
  for-you Read your For You publications (list)
@@ -6398,6 +6481,45 @@ Commands:
6398
6481
 
6399
6482
  Run 'alva <command> --help' for a command tree.`;
6400
6483
  var AGENT_COMMAND_HELP = {
6484
+ steward: `Usage: alva steward <subcommand> [options]
6485
+
6486
+ Report this push steward's decisions for Feed alerts routed to its Inbox and
6487
+ deliver messages to its own Channel. The host supplies the Inbox; no target,
6488
+ identity, profile or endpoint overrides are available.
6489
+
6490
+ decide --delivery-id <id> --decision <immediate|digest|suppress> --reason <text>
6491
+ Record the decision first; forward/send are rejected without it.
6492
+ forward --delivery-id <id> [--request-id <uuid>]
6493
+ Re-post the original alert card by reference (immediate only).
6494
+ send --delivery-ids <a,b,c> --body <markdown> [--request-id <uuid>]
6495
+ Post your own Markdown covering the listed deliveries; the response
6496
+ echoes requestId \u2014 pass it to briefed.
6497
+ pending [--after <cursor>] [--since <RFC3339>] [--until <RFC3339>] [--first <1-100>]
6498
+ Deliveries held for the Daily Brief. Repeat with --after <nextCursor>
6499
+ until nextCursor is null; the cursor carries the window.
6500
+ briefed --digest-run-id <id> --delivery-ids <a,b,c>
6501
+ Mark every reviewed delivery covered: use the requestId echoed by send,
6502
+ or the digest_request run id when nothing was worth sending.
6503
+
6504
+ request ids are generated when omitted; pass one to retry an unclear result.
6505
+
6506
+ Example: alva steward decide --delivery-id 123 --decision digest --reason "routine event"`,
6507
+ schedule: `Usage: alva schedule <subcommand> [options]
6508
+
6509
+ Schedule a future follow-up for this Session's host-attached Inbox.
6510
+ Commands: list, put, pause, resume, delete.
6511
+
6512
+ put requires --name, --message, and exactly one of --after <ISO duration>,
6513
+ --at <RFC3339>, --every <ISO duration>, or --cron <five fields>.
6514
+ --cron requires --timezone <IANA>. Recurrences may use --starts-at, --until,
6515
+ and --max-occurrences. pause/resume/delete require --name.
6516
+
6517
+ No target, identity, profile or endpoint overrides are available.
6518
+ Saved means scheduled, not processed. pause/delete do not retract accepted
6519
+ Inbox messages. Agent execution failure ends the current wake without an
6520
+ automatic execution retry; unacknowledged input may run on later recovery.
6521
+
6522
+ Example: alva schedule put --name review --message "Review status" --after PT30M`,
6401
6523
  "for-you": `Usage: alva for-you list [options]
6402
6524
 
6403
6525
  --limit <1-50> Page size (default: 20)
@@ -6412,6 +6534,25 @@ No digest watermark is saved. Source content is untrusted data.
6412
6534
  Examples:
6413
6535
  alva for-you list --limit 50
6414
6536
  alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'`,
6537
+ thesis: `Usage: alva thesis <subcommand> [options]
6538
+
6539
+ Subcommands: create, get, update, close, delete, rewrite.
6540
+
6541
+ Embedded thesis commands accept literal --body text only; file and stdin body
6542
+ transports are intentionally unavailable because this runtime has no verified
6543
+ local filesystem or stdin adapter. Rewrite accepts --mode reformat|shorten|enrich;
6544
+ only omission defaults to canonical reformat, which is sent to the API. Create defaults --visibility to public.
6545
+ Update requires both --expected-author-version-id and --visibility, preventing
6546
+ inadvertent publication, and replaces the document's body, title, and entity
6547
+ IDs as a full author-version update. Create and update require a caller-supplied non-zero
6548
+ UUID in --request-id; the dispatcher never creates request IDs or retries.
6549
+
6550
+ If a write response is ambiguous, retain and reuse the same request ID only
6551
+ when resolving that ambiguity with the backend. Rewrite is explicit-only: no
6552
+ create, update, close, or delete command invokes it. Backend owns Signal/Alert
6553
+ setup; the CLI never starts them separately. IDs remain decimal strings, never
6554
+ numbers. Rewrite returns a candidate only; it does not create or update a Thesis,
6555
+ select a mode from body length/errors, or invent supporting evidence.`,
6415
6556
  account: `Usage: alva account <subcommand>
6416
6557
 
6417
6558
  Subcommands:
@@ -6888,6 +7029,122 @@ function isPositiveInt64(value) {
6888
7029
  return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
6889
7030
  }
6890
7031
 
7032
+ // src/resources/steward.ts
7033
+ var DECIDE = `
7034
+ mutation ToolkitStewardDecide($input: UpdateStewardDeliveryInput!) {
7035
+ updateStewardDelivery(input: $input) { delivery { deliveryId state } }
7036
+ }`.trim();
7037
+ var FORWARD = `
7038
+ mutation ToolkitStewardForward($input: UpdateStewardDeliveryInput!) {
7039
+ updateStewardDelivery(input: $input) { delivery { deliveryId state channelMessageId } }
7040
+ }`.trim();
7041
+ var SEND = `
7042
+ mutation ToolkitStewardSend($input: PostStewardMessageInput!) {
7043
+ postStewardMessage(input: $input) { message { channelMessageId requestId } }
7044
+ }`.trim();
7045
+ var PENDING = `
7046
+ query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInput) {
7047
+ viewer {
7048
+ stewardDigestPending(inboxPath: $inboxPath, input: $input) {
7049
+ edges {
7050
+ cursor
7051
+ node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
7052
+ }
7053
+ pageInfo { hasNextPage endCursor }
7054
+ windowSinceMs
7055
+ windowUntilMs
7056
+ }
7057
+ }
7058
+ }`.trim();
7059
+ var BRIEFED = `
7060
+ mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
7061
+ completeStewardBrief(input: $input) { ok }
7062
+ }`.trim();
7063
+ var DECISIONS = /* @__PURE__ */ new Set([
7064
+ "immediate",
7065
+ "digest",
7066
+ "suppress"
7067
+ ]);
7068
+ function invalid(message) {
7069
+ return new AlvaError("INVALID_ARGUMENT", message, 400);
7070
+ }
7071
+ function requireDecision(value) {
7072
+ if (!DECISIONS.has(value))
7073
+ throw invalid("decision must be one of immediate, digest, suppress");
7074
+ return value;
7075
+ }
7076
+
7077
+ // src/resources/schedules.ts
7078
+ var SCHEDULE_FIELDS = `
7079
+ id
7080
+ name
7081
+ rule { kind atMs everyIntervalSeconds cronExpression cronTimezone }
7082
+ bounds { startsAtMs untilMs maxOccurrences }
7083
+ message { text }
7084
+ status
7085
+ failureCode
7086
+ failureAtMs
7087
+ occurrencesUsed
7088
+ nextFireAtMs
7089
+ createdAtMs
7090
+ updatedAtMs
7091
+ `;
7092
+ var LIST_SCHEDULES = `
7093
+ query ToolkitListAgentSchedules($channelId: ID!, $after: String) {
7094
+ viewer { channel(id: $channelId) {
7095
+ schedules(input: { first: 64, after: $after }) {
7096
+ edges { node { channel { id } ${SCHEDULE_FIELDS} } }
7097
+ pageInfo { hasNextPage endCursor }
7098
+ }
7099
+ } }
7100
+ }`.trim();
7101
+ var UPDATE_SCHEDULE = `
7102
+ mutation ToolkitUpdateAgentSchedule($input: UpdateChannelScheduleInput!) {
7103
+ updateChannelSchedule(input: $input) {
7104
+ schedule { channel { id } ${SCHEDULE_FIELDS} }
7105
+ deleted
7106
+ }
7107
+ }`.trim();
7108
+ var LIST_SESSION_SCHEDULES = `
7109
+ query ToolkitListSessionSchedules($inboxPath: String!, $after: String) {
7110
+ viewer { sessionSchedules(inboxPath: $inboxPath, input: { first: 64, after: $after }) {
7111
+ edges { node { ${SCHEDULE_FIELDS} } }
7112
+ pageInfo { hasNextPage endCursor }
7113
+ } }
7114
+ }`.trim();
7115
+ var UPDATE_SESSION_SCHEDULE = `
7116
+ mutation ToolkitUpdateSessionSchedule($input: UpdateSessionScheduleInput!) {
7117
+ updateSessionSchedule(input: $input) {
7118
+ schedule { ${SCHEDULE_FIELDS} }
7119
+ deleted
7120
+ }
7121
+ }`.trim();
7122
+ var AGENT_CHANNEL = `
7123
+ query ToolkitAgentChannel {
7124
+ viewer { channels { id kind } }
7125
+ }`.trim();
7126
+ var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
7127
+ 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;
7128
+ function parseRfc3339Milliseconds(value) {
7129
+ return timestampMilliseconds(value, true);
7130
+ }
7131
+ function timestampMilliseconds(value, fractional = false) {
7132
+ const match = (fractional ? RFC3339_FRACTIONAL : RFC3339).exec(value);
7133
+ if (!match) throw invalid2("timestamp must be RFC3339 with a timezone");
7134
+ const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
7135
+ const offsetHour = Number(match[8] ?? 0);
7136
+ const offsetMinute = Number(match[9] ?? 0);
7137
+ const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
7138
+ const result = Date.parse(value);
7139
+ if (!Number.isFinite(result) || year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 || day > daysInMonth || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59) {
7140
+ throw invalid2("timestamp must be RFC3339 with a timezone");
7141
+ }
7142
+ return result;
7143
+ }
7144
+ function invalid2(message) {
7145
+ return new AlvaError("INVALID_ARGUMENT", message, 400);
7146
+ }
7147
+
6891
7148
  // src/cli/commandDefinitions.ts
6892
7149
  function command(path, {
6893
7150
  values = [],
@@ -7007,10 +7264,11 @@ var COMMAND_DEFINITIONS = [
7007
7264
  values: ["id", "workflow-run-id"]
7008
7265
  }),
7009
7266
  command("deploy run-logs", { values: ["id", "run-id"] }),
7010
- command("schedule list", { values: ["channel-id"] }),
7267
+ command("schedule list", { values: ["channel-id", "inbox-path"] }),
7011
7268
  command("schedule put", {
7012
7269
  values: [
7013
7270
  "channel-id",
7271
+ "inbox-path",
7014
7272
  "name",
7015
7273
  "message",
7016
7274
  "at",
@@ -7023,9 +7281,57 @@ var COMMAND_DEFINITIONS = [
7023
7281
  "max-occurrences"
7024
7282
  ]
7025
7283
  }),
7026
- command("schedule pause", { values: ["channel-id", "name"] }),
7027
- command("schedule resume", { values: ["channel-id", "name"] }),
7028
- command("schedule delete", { values: ["channel-id", "name"] }),
7284
+ command("schedule pause", { values: ["channel-id", "inbox-path", "name"] }),
7285
+ command("schedule resume", { values: ["channel-id", "inbox-path", "name"] }),
7286
+ command("schedule delete", { values: ["channel-id", "inbox-path", "name"] }),
7287
+ command("steward decide", {
7288
+ values: ["inbox-path", "delivery-id", "decision", "reason"]
7289
+ }),
7290
+ command("steward forward", {
7291
+ values: ["inbox-path", "delivery-id", "request-id"]
7292
+ }),
7293
+ command("steward send", {
7294
+ values: ["inbox-path", "body", "delivery-ids", "request-id"]
7295
+ }),
7296
+ command("steward pending", {
7297
+ values: ["inbox-path", "after", "since", "until", "first"]
7298
+ }),
7299
+ command("steward briefed", {
7300
+ values: ["inbox-path", "delivery-ids", "digest-run-id"]
7301
+ }),
7302
+ command("thesis create", {
7303
+ values: [
7304
+ "request-id",
7305
+ "body",
7306
+ "body-file",
7307
+ "title",
7308
+ "entity-ids",
7309
+ "visibility"
7310
+ ],
7311
+ booleans: ["body-stdin"]
7312
+ }),
7313
+ command("thesis get", { values: ["id"] }),
7314
+ command("thesis update", {
7315
+ values: [
7316
+ "id",
7317
+ "request-id",
7318
+ "expected-author-version-id",
7319
+ "body",
7320
+ "body-file",
7321
+ "title",
7322
+ "entity-ids",
7323
+ "visibility"
7324
+ ],
7325
+ booleans: ["body-stdin", "editorial"]
7326
+ }),
7327
+ command("thesis close", {
7328
+ values: ["id", "expected-author-version-id", "note"]
7329
+ }),
7330
+ command("thesis delete", { values: ["id"] }),
7331
+ command("thesis rewrite", {
7332
+ values: ["body", "body-file", "mode"],
7333
+ booleans: ["body-stdin"]
7334
+ }),
7029
7335
  command("service-account create", { values: ["name"] }),
7030
7336
  command("service-account list"),
7031
7337
  command("service-account delete", { values: ["id"] }),
@@ -11149,7 +11455,7 @@ function formatTradingPairResolved(result) {
11149
11455
  }
11150
11456
 
11151
11457
  // src/cli/dispatch.ts
11152
- var CLI_VERSION = true ? "0.28.0" : "dev";
11458
+ var CLI_VERSION = true ? "0.28.1-beta.0" : "dev";
11153
11459
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
11154
11460
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
11155
11461
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -11183,6 +11489,41 @@ function isVersionOlderThan(a, b) {
11183
11489
  return false;
11184
11490
  }
11185
11491
  var COMMAND_HELP = {
11492
+ steward: `Usage: alva steward <subcommand> [options]
11493
+
11494
+ Report a push steward's decisions for Feed alerts routed to its Session Inbox,
11495
+ forward or send messages to the steward's own Channel, and run the Daily Brief.
11496
+ Embedded commands target the host-attached Inbox; the terminal CLI requires
11497
+ --inbox-path.
11498
+
11499
+ Subcommands:
11500
+ decide Record the decision for one delivery (required before forward/send)
11501
+ forward Re-post the original alert card by reference (immediate only)
11502
+ send Post steward-authored Markdown covering the listed deliveries
11503
+ pending Page deliveries decided "digest" that no brief has covered yet
11504
+ briefed Record that a Daily Brief covered the listed deliveries
11505
+
11506
+ Flags:
11507
+ --inbox-path <path> Steward Session Inbox (terminal CLI only)
11508
+ --delivery-id <id> One delivery (decide, forward)
11509
+ --delivery-ids <a,b,c> Comma-separated deliveries (send, briefed)
11510
+ --decision <immediate|digest|suppress>
11511
+ --reason <text> Short audit note stored with the decision
11512
+ --body <markdown> Message body (send)
11513
+ --request-id <uuid> Idempotency key; generated when omitted
11514
+ --after <cursor> Opaque cursor from the previous page's nextCursor (pending)
11515
+ --since <RFC3339> First page only: lower bound on decision time (pending)
11516
+ --until <RFC3339> First page only: fixed upper bound of the Brief window; later pages inherit it through the cursor (pending)
11517
+ --first <n> Page size, 1-100 (pending)
11518
+ --digest-run-id <id> The request id echoed by the send that carried these deliveries (briefed)
11519
+
11520
+ Examples (terminal; the embedded Agent tool omits --inbox-path):
11521
+ 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%"
11522
+ alva steward forward --inbox-path <inbox> --delivery-id 123
11523
+ alva steward send --inbox-path <inbox> --delivery-ids 124,125 --body "Two related moves..."
11524
+ alva steward pending --inbox-path <inbox> --until 2026-09-15T13:00:00Z
11525
+ alva steward pending --inbox-path <inbox> --after <nextCursor from the previous page>
11526
+ alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
11186
11527
  configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
11187
11528
 
11188
11529
  Save API credentials to ~/.config/alva/config.json (mode 0600).
@@ -11527,7 +11868,7 @@ Build-time verify (fire once, then poll up to 5 minutes):
11527
11868
  --run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
11528
11869
  schedule: `Usage: alva schedule <subcommand> [options]
11529
11870
 
11530
- Manage named future and recurring work for an Alva Channel Agent.
11871
+ Manage named future and recurring work for an Alva Channel Agent or Session Inbox.
11531
11872
 
11532
11873
  Subcommands:
11533
11874
  list List schedules
@@ -11538,6 +11879,7 @@ Subcommands:
11538
11879
 
11539
11880
  Common flags:
11540
11881
  --channel-id <id> Target Channel; omit for your Agent Channel
11882
+ --inbox-path <path> Existing Session Inbox; mutually exclusive with --channel-id
11541
11883
  --name <name> Stable schedule name
11542
11884
 
11543
11885
  Put flags:
@@ -11553,6 +11895,7 @@ Examples:
11553
11895
  alva schedule put --name review --message "Review status" --after PT30M
11554
11896
  alva schedule put --name market-open --message "Review the open" --cron "30 9 * * 1-5" --timezone America/New_York
11555
11897
  alva schedule list
11898
+ alva schedule put --inbox-path /alva/home/alice/session.inbox.jsonl --name review --message "Review status" --after PT30M
11556
11899
  alva schedule pause --name market-open`,
11557
11900
  "service-account": `Usage: alva service-account <subcommand> [options]
11558
11901
 
@@ -12422,7 +12765,56 @@ Subcommands:
12422
12765
 
12423
12766
  Examples:
12424
12767
  alva arrays token ensure
12425
- alva arrays token status`
12768
+ alva arrays token status`,
12769
+ thesis: `Usage: alva thesis <subcommand> [options]
12770
+
12771
+ Create, read, update, close, delete, or explicitly rewrite an authored thesis.
12772
+ Backend owns Signal/Alert setup; the CLI never starts them separately.
12773
+ Create and update never rewrite text automatically.
12774
+
12775
+ Subcommands:
12776
+ create Create a thesis
12777
+ get Get one thesis
12778
+ update Replaces document fields: body, title, entities, visibility (all sent in full)
12779
+ close Close the current author version with an optional note
12780
+ delete Delete a thesis
12781
+ rewrite Explicitly request a candidate body rewrite; never called by another command
12782
+
12783
+ Body input (create, update, rewrite): choose exactly one:
12784
+ --body <text> Literal text
12785
+ --body-file <path> Local UTF-8 text file (terminal CLI only; malformed bytes fail)
12786
+ --body-stdin Read UTF-8 text from stdin (terminal CLI only; malformed bytes fail)
12787
+
12788
+ Create and update require --request-id: a caller-supplied non-zero UUID. The
12789
+ toolkit does not generate or retry request IDs. If a response is ambiguous
12790
+ after a write, reuse the same request ID only after resolving that ambiguity with
12791
+ the backend; do not send a fresh ID. Create defaults --visibility to public.
12792
+ Update requires --visibility explicitly so it cannot inadvertently publish.
12793
+
12794
+ Other flags:
12795
+ create --request-id <uuid> --body ... [--title <text>] [--entity-ids <id,id>] [--visibility <value>]
12796
+ get --id <signed-int64-decimal>
12797
+ update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--editorial]
12798
+ close --id <id> --expected-author-version-id <id> [--note <text>]
12799
+ delete --id <id>
12800
+ rewrite --body ... [--mode reformat|shorten|enrich]
12801
+
12802
+ Rewrite mode defaults only when omitted, and the toolkit always sends the
12803
+ canonical default \`reformat\`. \`shorten\` removes redundancy while retaining the
12804
+ core view, reasons, and qualifiers. \`enrich\` only expands supplied reasoning;
12805
+ it must not invent factual evidence, numbers, or citations. Rewrite returns a
12806
+ candidate only: it never creates, updates, retries, or chooses a mode from body
12807
+ length or errors.
12808
+
12809
+ IDs are decimal strings, never JavaScript numbers; provide at most 20 entity
12810
+ IDs. Body text must be nonblank,
12811
+ valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
12812
+ 500 UTF-8 bytes. Text is passed without trimming or newline conversion.
12813
+
12814
+ Examples:
12815
+ alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two'
12816
+ alva thesis update --id 9223372036854775807 --request-id 123e4567-e89b-42d3-a456-426614174000 --expected-author-version-id 9223372036854775806 --body-file ./thesis.md --visibility private
12817
+ printf '%s' 'Draft body' | alva thesis rewrite --body-stdin --mode shorten`
12426
12818
  };
12427
12819
  function boolFlag(val) {
12428
12820
  if (val === "true") return true;
@@ -12773,6 +13165,22 @@ function feedVisibility(val) {
12773
13165
  "feed"
12774
13166
  );
12775
13167
  }
13168
+ function thesisVisibility(value) {
13169
+ if (value === "public" || value === "private") return value;
13170
+ throw new CliUsageError(
13171
+ `--visibility must be public or private for 'thesis', got '${value}'`,
13172
+ "thesis"
13173
+ );
13174
+ }
13175
+ function thesisRewriteMode(value) {
13176
+ if (value === "reformat" || value === "shorten" || value === "enrich") {
13177
+ return value;
13178
+ }
13179
+ throw new CliUsageError(
13180
+ `--mode must be reformat, shorten, or enrich for 'thesis rewrite', got '${value}'`,
13181
+ "thesis"
13182
+ );
13183
+ }
12776
13184
  function parseCreditsTimestamp(value, flag, command2) {
12777
13185
  const trimmed = value.trim();
12778
13186
  if (/^\d+$/.test(trimmed)) {
@@ -12809,8 +13217,20 @@ function parseCreditsDurationMs(value) {
12809
13217
  }
12810
13218
  return durationMs;
12811
13219
  }
12812
- async function scheduleChannelId(client, flags) {
12813
- return flags["channel-id"] ?? client.schedules.agentChannelId();
13220
+ async function scheduleTarget(client, flags) {
13221
+ if (flags["inbox-path"] !== void 0) {
13222
+ if (flags["channel-id"] !== void 0)
13223
+ throw new CliUsageError(
13224
+ "--inbox-path and --channel-id are mutually exclusive",
13225
+ "schedule"
13226
+ );
13227
+ if (flags["inbox-path"] === "")
13228
+ throw new CliUsageError("--inbox-path must not be empty", "schedule");
13229
+ return { inboxPath: flags["inbox-path"] };
13230
+ }
13231
+ return {
13232
+ channelId: flags["channel-id"] ?? await client.schedules.agentChannelId()
13233
+ };
12814
13234
  }
12815
13235
  function scheduleRuleFromFlags(flags) {
12816
13236
  const selected = ["after", "at", "every", "cron"].filter(
@@ -13003,6 +13423,73 @@ function readLocalTextFile(path, command2, flag, deps) {
13003
13423
  }
13004
13424
  return deps.localFiles.readText(path);
13005
13425
  }
13426
+ async function thesisBodyFromFlags(flags, command2, deps) {
13427
+ const sources = [
13428
+ flags.body !== void 0 ? "body" : void 0,
13429
+ flags["body-file"] !== void 0 ? "body-file" : void 0,
13430
+ flags["body-stdin"] === "true" ? "body-stdin" : void 0
13431
+ ].filter((source) => source !== void 0);
13432
+ if (sources.length !== 1) {
13433
+ throw new CliUsageError(
13434
+ `${command2} requires exactly one of --body, --body-file, or --body-stdin`,
13435
+ "thesis"
13436
+ );
13437
+ }
13438
+ if (sources[0] === "body") return flags.body;
13439
+ if (sources[0] === "body-file") {
13440
+ assertLocalFileAvailable(command2, "--body-file", deps);
13441
+ if (!deps?.localFiles) {
13442
+ throw new Error("Local file access requires a Node.js runtime adapter.");
13443
+ }
13444
+ return strictThesisUTF8(
13445
+ deps.localFiles.readBytes(flags["body-file"]),
13446
+ command2,
13447
+ "--body-file"
13448
+ );
13449
+ }
13450
+ if (deps?.runtime === "jagent") {
13451
+ throw localFileUnsupported(command2, "--body-stdin");
13452
+ }
13453
+ if (!deps?.readStdinBytes) {
13454
+ throw new Error("Thesis stdin requires a Node.js byte-stdin adapter.");
13455
+ }
13456
+ return strictThesisUTF8(await deps.readStdinBytes(), command2, "--body-stdin");
13457
+ }
13458
+ function thesisEntityIDs(flags) {
13459
+ const raw = flags["entity-ids"];
13460
+ if (raw === void 0 || raw === "") return [];
13461
+ const entityIDs = raw.split(",").map((id) => id.trim());
13462
+ if (entityIDs.some((id) => id === "")) {
13463
+ throw new CliUsageError(
13464
+ "--entity-ids must not contain empty IDs",
13465
+ "thesis"
13466
+ );
13467
+ }
13468
+ return entityIDs;
13469
+ }
13470
+ function strictThesisUTF8(value, command2, flag) {
13471
+ const bytes = toByteView(value);
13472
+ if (bytes === void 0) {
13473
+ throw new Error(`${flag} requires a byte-capable Node.js runtime adapter.`);
13474
+ }
13475
+ try {
13476
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
13477
+ bytes
13478
+ );
13479
+ } catch {
13480
+ throw new CliUsageError(
13481
+ `${flag} must contain valid UTF-8 for '${command2}'`,
13482
+ "thesis"
13483
+ );
13484
+ }
13485
+ }
13486
+ function toByteView(value) {
13487
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
13488
+ if (ArrayBuffer.isView(value)) {
13489
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
13490
+ }
13491
+ return void 0;
13492
+ }
13006
13493
  function readLocalFileBytes(path, command2, flag, deps) {
13007
13494
  assertLocalFileAvailable(command2, flag, deps);
13008
13495
  if (!deps?.localFiles) {
@@ -13424,8 +13911,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13424
13911
  }
13425
13912
  switch (subcommand) {
13426
13913
  case "list": {
13427
- const channelId = await scheduleChannelId(client, flags);
13428
- return client.schedules.list({ channelId });
13914
+ return client.schedules.list(await scheduleTarget(client, flags));
13429
13915
  }
13430
13916
  case "put": {
13431
13917
  const rule = scheduleRuleFromFlags(flags);
@@ -13438,9 +13924,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13438
13924
  }
13439
13925
  const name = requireFlag(flags, "name", "schedule put");
13440
13926
  const text = requireFlag(flags, "message", "schedule put");
13441
- const channelId = await scheduleChannelId(client, flags);
13927
+ const target = await scheduleTarget(client, flags);
13442
13928
  return client.schedules.put({
13443
- channelId,
13929
+ ...target,
13444
13930
  name,
13445
13931
  text,
13446
13932
  rule,
@@ -13449,25 +13935,25 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13449
13935
  }
13450
13936
  case "pause": {
13451
13937
  const name = requireFlag(flags, "name", "schedule pause");
13452
- const channelId = await scheduleChannelId(client, flags);
13938
+ const target = await scheduleTarget(client, flags);
13453
13939
  return client.schedules.pause({
13454
- channelId,
13940
+ ...target,
13455
13941
  name
13456
13942
  });
13457
13943
  }
13458
13944
  case "resume": {
13459
13945
  const name = requireFlag(flags, "name", "schedule resume");
13460
- const channelId = await scheduleChannelId(client, flags);
13946
+ const target = await scheduleTarget(client, flags);
13461
13947
  return client.schedules.resume({
13462
- channelId,
13948
+ ...target,
13463
13949
  name
13464
13950
  });
13465
13951
  }
13466
13952
  case "delete": {
13467
13953
  const name = requireFlag(flags, "name", "schedule delete");
13468
- const channelId = await scheduleChannelId(client, flags);
13954
+ const target = await scheduleTarget(client, flags);
13469
13955
  await client.schedules.delete({
13470
- channelId,
13956
+ ...target,
13471
13957
  name
13472
13958
  });
13473
13959
  return { deleted: true };
@@ -13479,6 +13965,133 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13479
13965
  );
13480
13966
  }
13481
13967
  }
13968
+ case "steward": {
13969
+ if (!subcommand) {
13970
+ throw new CliUsageError("Missing subcommand for steward", "steward");
13971
+ }
13972
+ const inboxPath = requireFlag(
13973
+ flags,
13974
+ "inbox-path",
13975
+ `steward ${subcommand}`
13976
+ );
13977
+ const ids = (name) => requireFlag(flags, name, `steward ${subcommand}`).split(",").map((value) => value.trim()).filter((value) => value !== "");
13978
+ switch (subcommand) {
13979
+ case "decide":
13980
+ return client.steward.decide({
13981
+ inboxPath,
13982
+ deliveryId: requireFlag(flags, "delivery-id", "steward decide"),
13983
+ decision: requireDecision(
13984
+ requireFlag(flags, "decision", "steward decide")
13985
+ ),
13986
+ reason: requireFlag(flags, "reason", "steward decide")
13987
+ });
13988
+ case "forward":
13989
+ return client.steward.forward({
13990
+ inboxPath,
13991
+ deliveryId: requireFlag(flags, "delivery-id", "steward forward"),
13992
+ requestId: flags["request-id"]
13993
+ });
13994
+ case "send":
13995
+ return client.steward.send({
13996
+ inboxPath,
13997
+ body: requireFlag(flags, "body", "steward send"),
13998
+ deliveryIds: ids("delivery-ids"),
13999
+ requestId: flags["request-id"]
14000
+ });
14001
+ case "pending": {
14002
+ const parseTime = (name) => {
14003
+ const value = flags[name];
14004
+ if (value === void 0) return void 0;
14005
+ try {
14006
+ return parseRfc3339Milliseconds(value);
14007
+ } catch {
14008
+ throw new CliUsageError(
14009
+ `--${name} must be an RFC3339 timestamp with a timezone`,
14010
+ "steward"
14011
+ );
14012
+ }
14013
+ };
14014
+ const first = flags.first === void 0 ? void 0 : Number(flags.first);
14015
+ return client.steward.pending({
14016
+ inboxPath,
14017
+ after: flags.after,
14018
+ sinceMs: parseTime("since"),
14019
+ untilMs: parseTime("until"),
14020
+ first
14021
+ });
14022
+ }
14023
+ case "briefed":
14024
+ return client.steward.briefed({
14025
+ inboxPath,
14026
+ deliveryIds: ids("delivery-ids"),
14027
+ digestRunId: requireFlag(flags, "digest-run-id", "steward briefed")
14028
+ });
14029
+ default:
14030
+ throw new CliUsageError(
14031
+ `Unknown subcommand: steward ${subcommand}`,
14032
+ "steward"
14033
+ );
14034
+ }
14035
+ }
14036
+ case "thesis": {
14037
+ if (!subcommand) {
14038
+ throw new CliUsageError("Missing subcommand for thesis", "thesis");
14039
+ }
14040
+ switch (subcommand) {
14041
+ case "create":
14042
+ return client.theses.create({
14043
+ request_id: requireFlag(flags, "request-id", "thesis create"),
14044
+ body: await thesisBodyFromFlags(flags, "thesis create", deps),
14045
+ title: flags.title ?? "",
14046
+ entity_ids: thesisEntityIDs(flags),
14047
+ visibility: flags.visibility === void 0 ? "public" : thesisVisibility(flags.visibility)
14048
+ });
14049
+ case "get":
14050
+ return client.theses.get(requireFlag(flags, "id", "thesis get"));
14051
+ case "update":
14052
+ return client.theses.update(
14053
+ requireFlag(flags, "id", "thesis update"),
14054
+ {
14055
+ request_id: requireFlag(flags, "request-id", "thesis update"),
14056
+ expected_author_version_id: requireFlag(
14057
+ flags,
14058
+ "expected-author-version-id",
14059
+ "thesis update"
14060
+ ),
14061
+ body: await thesisBodyFromFlags(flags, "thesis update", deps),
14062
+ title: flags.title ?? "",
14063
+ entity_ids: thesisEntityIDs(flags),
14064
+ visibility: thesisVisibility(
14065
+ requireFlag(flags, "visibility", "thesis update")
14066
+ ),
14067
+ editorial: boolFlag(flags.editorial) ?? false
14068
+ }
14069
+ );
14070
+ case "close":
14071
+ return client.theses.close(requireFlag(flags, "id", "thesis close"), {
14072
+ expected_author_version_id: requireFlag(
14073
+ flags,
14074
+ "expected-author-version-id",
14075
+ "thesis close"
14076
+ ),
14077
+ note: flags.note
14078
+ });
14079
+ case "delete":
14080
+ return client.theses.delete(
14081
+ requireFlag(flags, "id", "thesis delete")
14082
+ );
14083
+ case "rewrite":
14084
+ return client.theses.rewrite({
14085
+ body: await thesisBodyFromFlags(flags, "thesis rewrite", deps),
14086
+ mode: flags.mode === void 0 ? "reformat" : thesisRewriteMode(flags.mode)
14087
+ });
14088
+ default:
14089
+ throw new CliUsageError(
14090
+ `Unknown subcommand: thesis ${subcommand}`,
14091
+ "thesis"
14092
+ );
14093
+ }
14094
+ }
13482
14095
  case "service-account": {
13483
14096
  if (!subcommand)
13484
14097
  throw new CliUsageError(
@@ -15191,7 +15804,18 @@ async function dispatchEmbedded(client, args, meta, deps) {
15191
15804
  async function dispatchEmbeddedTarget(client, parsed, meta, deps) {
15192
15805
  const definition = embeddedCommandDefinition(parsed.path);
15193
15806
  let target;
15194
- if (definition.action === "notification-set-preference") {
15807
+ if (definition.action === "schedule-self" || definition.action === "steward-self") {
15808
+ const family = parsed.path[0];
15809
+ if (!client.originInboxPath)
15810
+ throw new CliUsageError(
15811
+ `${family} requires a host-attached Session Inbox`,
15812
+ family
15813
+ );
15814
+ target = {
15815
+ ...parsed,
15816
+ flags: { ...parsed.flags, "inbox-path": client.originInboxPath }
15817
+ };
15818
+ } else if (definition.action === "notification-set-preference") {
15195
15819
  const value = parsed.flags["session-completed"];
15196
15820
  if (value !== "enabled" && value !== "disabled") {
15197
15821
  throw new CliUsageError(