@alva-ai/toolkit 0.28.0 → 0.28.1-beta.1

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,84 @@ 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: [
6056
+ "request-id",
6057
+ "body",
6058
+ "title",
6059
+ "entity-ids",
6060
+ "tickers",
6061
+ "visibility"
6062
+ ]
6063
+ }),
6064
+ route("thesis get", "thesis get", { values: ["id"] }),
6065
+ route("thesis set-visibility", "thesis set-visibility", {
6066
+ values: ["id", "visibility"]
6067
+ }),
6068
+ route("thesis update", "thesis update", {
6069
+ values: [
6070
+ "id",
6071
+ "request-id",
6072
+ "expected-author-version-id",
6073
+ "body",
6074
+ "title",
6075
+ "entity-ids",
6076
+ "visibility"
6077
+ ],
6078
+ booleans: ["editorial"]
6079
+ }),
6080
+ route("thesis close", "thesis close", {
6081
+ values: ["id", "expected-author-version-id", "note"]
6082
+ }),
6083
+ route("thesis delete", "thesis delete", { values: ["id"] }),
6084
+ route("thesis rewrite", "thesis rewrite", { values: ["body", "mode"] }),
5995
6085
  route("account whoami", "whoami"),
5996
6086
  route("account credits wallet", "credits wallet"),
5997
6087
  route("account credits items", "credits items", {
@@ -6390,6 +6480,9 @@ Commands:
6390
6480
  markets Read market narrative and earnings context
6391
6481
  trading-pairs Discover and strictly verify canonical trading pairs
6392
6482
  automation Create and operate scheduled automations
6483
+ schedule Manage future messages for this Session Inbox
6484
+ steward Push steward reports for this Session Inbox (decide, forward, send, pending, briefed)
6485
+ thesis Create and manage authored theses
6393
6486
  playbooks Discover, build, release, and manage Playbooks
6394
6487
  alert Manage personal automation alert bindings
6395
6488
  for-you Read your For You publications (list)
@@ -6398,6 +6491,45 @@ Commands:
6398
6491
 
6399
6492
  Run 'alva <command> --help' for a command tree.`;
6400
6493
  var AGENT_COMMAND_HELP = {
6494
+ steward: `Usage: alva steward <subcommand> [options]
6495
+
6496
+ Report this push steward's decisions for Feed alerts routed to its Inbox and
6497
+ deliver messages to its own Channel. The host supplies the Inbox; no target,
6498
+ identity, profile or endpoint overrides are available.
6499
+
6500
+ decide --delivery-id <id> --decision <immediate|digest|suppress> --reason <text>
6501
+ Record the decision first; forward/send are rejected without it.
6502
+ forward --delivery-id <id> [--request-id <uuid>]
6503
+ Re-post the original alert card by reference (immediate only).
6504
+ send --delivery-ids <a,b,c> --body <markdown> [--request-id <uuid>]
6505
+ Post your own Markdown covering the listed deliveries; the response
6506
+ echoes requestId \u2014 pass it to briefed.
6507
+ pending [--after <cursor>] [--since <RFC3339>] [--until <RFC3339>] [--first <1-100>]
6508
+ Deliveries held for the Daily Brief. Repeat with --after <nextCursor>
6509
+ until nextCursor is null; the cursor carries the window.
6510
+ briefed --digest-run-id <id> --delivery-ids <a,b,c>
6511
+ Mark every reviewed delivery covered: use the requestId echoed by send,
6512
+ or the digest_request run id when nothing was worth sending.
6513
+
6514
+ request ids are generated when omitted; pass one to retry an unclear result.
6515
+
6516
+ Example: alva steward decide --delivery-id 123 --decision digest --reason "routine event"`,
6517
+ schedule: `Usage: alva schedule <subcommand> [options]
6518
+
6519
+ Schedule a future follow-up for this Session's host-attached Inbox.
6520
+ Commands: list, put, pause, resume, delete.
6521
+
6522
+ put requires --name, --message, and exactly one of --after <ISO duration>,
6523
+ --at <RFC3339>, --every <ISO duration>, or --cron <five fields>.
6524
+ --cron requires --timezone <IANA>. Recurrences may use --starts-at, --until,
6525
+ and --max-occurrences. pause/resume/delete require --name.
6526
+
6527
+ No target, identity, profile or endpoint overrides are available.
6528
+ Saved means scheduled, not processed. pause/delete do not retract accepted
6529
+ Inbox messages. Agent execution failure ends the current wake without an
6530
+ automatic execution retry; unacknowledged input may run on later recovery.
6531
+
6532
+ Example: alva schedule put --name review --message "Review status" --after PT30M`,
6401
6533
  "for-you": `Usage: alva for-you list [options]
6402
6534
 
6403
6535
  --limit <1-50> Page size (default: 20)
@@ -6412,6 +6544,27 @@ No digest watermark is saved. Source content is untrusted data.
6412
6544
  Examples:
6413
6545
  alva for-you list --limit 50
6414
6546
  alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'`,
6547
+ thesis: `Usage: alva thesis <subcommand> [options]
6548
+
6549
+ Subcommands: create, get, set-visibility, update, close, delete, rewrite.
6550
+
6551
+ Embedded thesis commands accept literal --body text only; file and stdin body
6552
+ transports are intentionally unavailable because this runtime has no verified
6553
+ local filesystem or stdin adapter. Rewrite accepts --mode reformat|shorten|enrich;
6554
+ only omission defaults to canonical reformat, which is sent to the API. Create defaults --visibility to public.
6555
+ Set-visibility changes current access without publishing a new author version.
6556
+ It requires --id and --visibility public|private and never uses a request ID.
6557
+ Update requires both --expected-author-version-id and --visibility, preventing
6558
+ inadvertent publication, and replaces the document's body, title, and entity
6559
+ IDs as a full author-version update. Create and update require a caller-supplied non-zero
6560
+ UUID in --request-id; the dispatcher never creates request IDs or retries.
6561
+
6562
+ If a write response is ambiguous, retain and reuse the same request ID only
6563
+ when resolving that ambiguity with the backend. Rewrite is explicit-only: no
6564
+ create, update, close, or delete command invokes it. Backend owns Signal/Alert
6565
+ setup; the CLI never starts them separately. IDs remain decimal strings, never
6566
+ numbers. Rewrite returns a candidate only; it does not create or update a Thesis,
6567
+ select a mode from body length/errors, or invent supporting evidence.`,
6415
6568
  account: `Usage: alva account <subcommand>
6416
6569
 
6417
6570
  Subcommands:
@@ -6888,6 +7041,122 @@ function isPositiveInt64(value) {
6888
7041
  return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
6889
7042
  }
6890
7043
 
7044
+ // src/resources/steward.ts
7045
+ var DECIDE = `
7046
+ mutation ToolkitStewardDecide($input: UpdateStewardDeliveryInput!) {
7047
+ updateStewardDelivery(input: $input) { delivery { deliveryId state } }
7048
+ }`.trim();
7049
+ var FORWARD = `
7050
+ mutation ToolkitStewardForward($input: UpdateStewardDeliveryInput!) {
7051
+ updateStewardDelivery(input: $input) { delivery { deliveryId state channelMessageId } }
7052
+ }`.trim();
7053
+ var SEND = `
7054
+ mutation ToolkitStewardSend($input: PostStewardMessageInput!) {
7055
+ postStewardMessage(input: $input) { message { channelMessageId requestId } }
7056
+ }`.trim();
7057
+ var PENDING = `
7058
+ query ToolkitStewardPending($inboxPath: String!, $input: StewardDigestPendingInput) {
7059
+ viewer {
7060
+ stewardDigestPending(inboxPath: $inboxPath, input: $input) {
7061
+ edges {
7062
+ cursor
7063
+ node { deliveryId feedEntryId source { kind id } decisionReason consumedAtMs }
7064
+ }
7065
+ pageInfo { hasNextPage endCursor }
7066
+ windowSinceMs
7067
+ windowUntilMs
7068
+ }
7069
+ }
7070
+ }`.trim();
7071
+ var BRIEFED = `
7072
+ mutation ToolkitStewardBriefed($input: CompleteStewardBriefInput!) {
7073
+ completeStewardBrief(input: $input) { ok }
7074
+ }`.trim();
7075
+ var DECISIONS = /* @__PURE__ */ new Set([
7076
+ "immediate",
7077
+ "digest",
7078
+ "suppress"
7079
+ ]);
7080
+ function invalid(message) {
7081
+ return new AlvaError("INVALID_ARGUMENT", message, 400);
7082
+ }
7083
+ function requireDecision(value) {
7084
+ if (!DECISIONS.has(value))
7085
+ throw invalid("decision must be one of immediate, digest, suppress");
7086
+ return value;
7087
+ }
7088
+
7089
+ // src/resources/schedules.ts
7090
+ var SCHEDULE_FIELDS = `
7091
+ id
7092
+ name
7093
+ rule { kind atMs everyIntervalSeconds cronExpression cronTimezone }
7094
+ bounds { startsAtMs untilMs maxOccurrences }
7095
+ message { text }
7096
+ status
7097
+ failureCode
7098
+ failureAtMs
7099
+ occurrencesUsed
7100
+ nextFireAtMs
7101
+ createdAtMs
7102
+ updatedAtMs
7103
+ `;
7104
+ var LIST_SCHEDULES = `
7105
+ query ToolkitListAgentSchedules($channelId: ID!, $after: String) {
7106
+ viewer { channel(id: $channelId) {
7107
+ schedules(input: { first: 64, after: $after }) {
7108
+ edges { node { channel { id } ${SCHEDULE_FIELDS} } }
7109
+ pageInfo { hasNextPage endCursor }
7110
+ }
7111
+ } }
7112
+ }`.trim();
7113
+ var UPDATE_SCHEDULE = `
7114
+ mutation ToolkitUpdateAgentSchedule($input: UpdateChannelScheduleInput!) {
7115
+ updateChannelSchedule(input: $input) {
7116
+ schedule { channel { id } ${SCHEDULE_FIELDS} }
7117
+ deleted
7118
+ }
7119
+ }`.trim();
7120
+ var LIST_SESSION_SCHEDULES = `
7121
+ query ToolkitListSessionSchedules($inboxPath: String!, $after: String) {
7122
+ viewer { sessionSchedules(inboxPath: $inboxPath, input: { first: 64, after: $after }) {
7123
+ edges { node { ${SCHEDULE_FIELDS} } }
7124
+ pageInfo { hasNextPage endCursor }
7125
+ } }
7126
+ }`.trim();
7127
+ var UPDATE_SESSION_SCHEDULE = `
7128
+ mutation ToolkitUpdateSessionSchedule($input: UpdateSessionScheduleInput!) {
7129
+ updateSessionSchedule(input: $input) {
7130
+ schedule { ${SCHEDULE_FIELDS} }
7131
+ deleted
7132
+ }
7133
+ }`.trim();
7134
+ var AGENT_CHANNEL = `
7135
+ query ToolkitAgentChannel {
7136
+ viewer { channels { id kind } }
7137
+ }`.trim();
7138
+ var RFC3339 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))$/i;
7139
+ 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;
7140
+ function parseRfc3339Milliseconds(value) {
7141
+ return timestampMilliseconds(value, true);
7142
+ }
7143
+ function timestampMilliseconds(value, fractional = false) {
7144
+ const match = (fractional ? RFC3339_FRACTIONAL : RFC3339).exec(value);
7145
+ if (!match) throw invalid2("timestamp must be RFC3339 with a timezone");
7146
+ const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
7147
+ const offsetHour = Number(match[8] ?? 0);
7148
+ const offsetMinute = Number(match[9] ?? 0);
7149
+ const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
7150
+ const result = Date.parse(value);
7151
+ 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) {
7152
+ throw invalid2("timestamp must be RFC3339 with a timezone");
7153
+ }
7154
+ return result;
7155
+ }
7156
+ function invalid2(message) {
7157
+ return new AlvaError("INVALID_ARGUMENT", message, 400);
7158
+ }
7159
+
6891
7160
  // src/cli/commandDefinitions.ts
6892
7161
  function command(path, {
6893
7162
  values = [],
@@ -7007,10 +7276,11 @@ var COMMAND_DEFINITIONS = [
7007
7276
  values: ["id", "workflow-run-id"]
7008
7277
  }),
7009
7278
  command("deploy run-logs", { values: ["id", "run-id"] }),
7010
- command("schedule list", { values: ["channel-id"] }),
7279
+ command("schedule list", { values: ["channel-id", "inbox-path"] }),
7011
7280
  command("schedule put", {
7012
7281
  values: [
7013
7282
  "channel-id",
7283
+ "inbox-path",
7014
7284
  "name",
7015
7285
  "message",
7016
7286
  "at",
@@ -7023,9 +7293,59 @@ var COMMAND_DEFINITIONS = [
7023
7293
  "max-occurrences"
7024
7294
  ]
7025
7295
  }),
7026
- command("schedule pause", { values: ["channel-id", "name"] }),
7027
- command("schedule resume", { values: ["channel-id", "name"] }),
7028
- command("schedule delete", { values: ["channel-id", "name"] }),
7296
+ command("schedule pause", { values: ["channel-id", "inbox-path", "name"] }),
7297
+ command("schedule resume", { values: ["channel-id", "inbox-path", "name"] }),
7298
+ command("schedule delete", { values: ["channel-id", "inbox-path", "name"] }),
7299
+ command("steward decide", {
7300
+ values: ["inbox-path", "delivery-id", "decision", "reason"]
7301
+ }),
7302
+ command("steward forward", {
7303
+ values: ["inbox-path", "delivery-id", "request-id"]
7304
+ }),
7305
+ command("steward send", {
7306
+ values: ["inbox-path", "body", "delivery-ids", "request-id"]
7307
+ }),
7308
+ command("steward pending", {
7309
+ values: ["inbox-path", "after", "since", "until", "first"]
7310
+ }),
7311
+ command("steward briefed", {
7312
+ values: ["inbox-path", "delivery-ids", "digest-run-id"]
7313
+ }),
7314
+ command("thesis create", {
7315
+ values: [
7316
+ "request-id",
7317
+ "body",
7318
+ "body-file",
7319
+ "title",
7320
+ "entity-ids",
7321
+ "tickers",
7322
+ "visibility"
7323
+ ],
7324
+ booleans: ["body-stdin"]
7325
+ }),
7326
+ command("thesis get", { values: ["id"] }),
7327
+ command("thesis set-visibility", { values: ["id", "visibility"] }),
7328
+ command("thesis update", {
7329
+ values: [
7330
+ "id",
7331
+ "request-id",
7332
+ "expected-author-version-id",
7333
+ "body",
7334
+ "body-file",
7335
+ "title",
7336
+ "entity-ids",
7337
+ "visibility"
7338
+ ],
7339
+ booleans: ["body-stdin", "editorial"]
7340
+ }),
7341
+ command("thesis close", {
7342
+ values: ["id", "expected-author-version-id", "note"]
7343
+ }),
7344
+ command("thesis delete", { values: ["id"] }),
7345
+ command("thesis rewrite", {
7346
+ values: ["body", "body-file", "mode"],
7347
+ booleans: ["body-stdin"]
7348
+ }),
7029
7349
  command("service-account create", { values: ["name"] }),
7030
7350
  command("service-account list"),
7031
7351
  command("service-account delete", { values: ["id"] }),
@@ -11149,7 +11469,7 @@ function formatTradingPairResolved(result) {
11149
11469
  }
11150
11470
 
11151
11471
  // src/cli/dispatch.ts
11152
- var CLI_VERSION = true ? "0.28.0" : "dev";
11472
+ var CLI_VERSION = true ? "0.28.1-beta.1" : "dev";
11153
11473
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
11154
11474
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
11155
11475
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -11183,6 +11503,41 @@ function isVersionOlderThan(a, b) {
11183
11503
  return false;
11184
11504
  }
11185
11505
  var COMMAND_HELP = {
11506
+ steward: `Usage: alva steward <subcommand> [options]
11507
+
11508
+ Report a push steward's decisions for Feed alerts routed to its Session Inbox,
11509
+ forward or send messages to the steward's own Channel, and run the Daily Brief.
11510
+ Embedded commands target the host-attached Inbox; the terminal CLI requires
11511
+ --inbox-path.
11512
+
11513
+ Subcommands:
11514
+ decide Record the decision for one delivery (required before forward/send)
11515
+ forward Re-post the original alert card by reference (immediate only)
11516
+ send Post steward-authored Markdown covering the listed deliveries
11517
+ pending Page deliveries decided "digest" that no brief has covered yet
11518
+ briefed Record that a Daily Brief covered the listed deliveries
11519
+
11520
+ Flags:
11521
+ --inbox-path <path> Steward Session Inbox (terminal CLI only)
11522
+ --delivery-id <id> One delivery (decide, forward)
11523
+ --delivery-ids <a,b,c> Comma-separated deliveries (send, briefed)
11524
+ --decision <immediate|digest|suppress>
11525
+ --reason <text> Short audit note stored with the decision
11526
+ --body <markdown> Message body (send)
11527
+ --request-id <uuid> Idempotency key; generated when omitted
11528
+ --after <cursor> Opaque cursor from the previous page's nextCursor (pending)
11529
+ --since <RFC3339> First page only: lower bound on decision time (pending)
11530
+ --until <RFC3339> First page only: fixed upper bound of the Brief window; later pages inherit it through the cursor (pending)
11531
+ --first <n> Page size, 1-100 (pending)
11532
+ --digest-run-id <id> The request id echoed by the send that carried these deliveries (briefed)
11533
+
11534
+ Examples (terminal; the embedded Agent tool omits --inbox-path):
11535
+ 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%"
11536
+ alva steward forward --inbox-path <inbox> --delivery-id 123
11537
+ alva steward send --inbox-path <inbox> --delivery-ids 124,125 --body "Two related moves..."
11538
+ alva steward pending --inbox-path <inbox> --until 2026-09-15T13:00:00Z
11539
+ alva steward pending --inbox-path <inbox> --after <nextCursor from the previous page>
11540
+ alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
11186
11541
  configure: `Usage: alva configure --api-key <key> [--base-url <url>] [--profile <name>]
11187
11542
 
11188
11543
  Save API credentials to ~/.config/alva/config.json (mode 0600).
@@ -11527,7 +11882,7 @@ Build-time verify (fire once, then poll up to 5 minutes):
11527
11882
  --run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
11528
11883
  schedule: `Usage: alva schedule <subcommand> [options]
11529
11884
 
11530
- Manage named future and recurring work for an Alva Channel Agent.
11885
+ Manage named future and recurring work for an Alva Channel Agent or Session Inbox.
11531
11886
 
11532
11887
  Subcommands:
11533
11888
  list List schedules
@@ -11538,6 +11893,7 @@ Subcommands:
11538
11893
 
11539
11894
  Common flags:
11540
11895
  --channel-id <id> Target Channel; omit for your Agent Channel
11896
+ --inbox-path <path> Existing Session Inbox; mutually exclusive with --channel-id
11541
11897
  --name <name> Stable schedule name
11542
11898
 
11543
11899
  Put flags:
@@ -11553,6 +11909,7 @@ Examples:
11553
11909
  alva schedule put --name review --message "Review status" --after PT30M
11554
11910
  alva schedule put --name market-open --message "Review the open" --cron "30 9 * * 1-5" --timezone America/New_York
11555
11911
  alva schedule list
11912
+ alva schedule put --inbox-path /alva/home/alice/session.inbox.jsonl --name review --message "Review status" --after PT30M
11556
11913
  alva schedule pause --name market-open`,
11557
11914
  "service-account": `Usage: alva service-account <subcommand> [options]
11558
11915
 
@@ -12422,7 +12779,59 @@ Subcommands:
12422
12779
 
12423
12780
  Examples:
12424
12781
  alva arrays token ensure
12425
- alva arrays token status`
12782
+ alva arrays token status`,
12783
+ thesis: `Usage: alva thesis <subcommand> [options]
12784
+
12785
+ Create, read, update, close, delete, or explicitly rewrite an authored thesis.
12786
+ Backend owns Signal/Alert setup; the CLI never starts them separately.
12787
+ Create and update never rewrite text automatically.
12788
+
12789
+ Subcommands:
12790
+ create Create a thesis
12791
+ get Get one thesis
12792
+ set-visibility Change current access without publishing a version
12793
+ update Replaces document fields: body, title, entities, visibility (all sent in full)
12794
+ close Close the current author version with an optional note
12795
+ delete Delete a thesis
12796
+ rewrite Explicitly request a candidate body rewrite; never called by another command
12797
+
12798
+ Body input (create, update, rewrite): choose exactly one:
12799
+ --body <text> Literal text
12800
+ --body-file <path> Local UTF-8 text file (terminal CLI only; malformed bytes fail)
12801
+ --body-stdin Read UTF-8 text from stdin (terminal CLI only; malformed bytes fail)
12802
+
12803
+ Create and update require --request-id: a caller-supplied non-zero UUID. The
12804
+ toolkit does not generate or retry request IDs. If a response is ambiguous
12805
+ after a write, reuse the same request ID only after resolving that ambiguity with
12806
+ the backend; do not send a fresh ID. Create defaults --visibility to public.
12807
+ Update requires --visibility explicitly so it cannot inadvertently publish.
12808
+
12809
+ Other flags:
12810
+ create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--visibility <value>]
12811
+ get --id <signed-int64-decimal>
12812
+ set-visibility --id <id> --visibility public|private
12813
+ update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--editorial]
12814
+ close --id <id> --expected-author-version-id <id> [--note <text>]
12815
+ delete --id <id>
12816
+ rewrite --body ... [--mode reformat|shorten|enrich]
12817
+
12818
+ Rewrite mode defaults only when omitted, and the toolkit always sends the
12819
+ canonical default \`reformat\`. \`shorten\` removes redundancy while retaining the
12820
+ core view, reasons, and qualifiers. \`enrich\` only expands supplied reasoning;
12821
+ it must not invent factual evidence, numbers, or citations. Rewrite returns a
12822
+ candidate only: it never creates, updates, retries, or chooses a mode from body
12823
+ length or errors.
12824
+
12825
+ IDs are decimal strings, never JavaScript numbers; provide at most 20 entity
12826
+ IDs. Body text must be nonblank,
12827
+ valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
12828
+ 500 UTF-8 bytes. Text is passed without trimming or newline conversion.
12829
+
12830
+ Examples:
12831
+ alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two'
12832
+ alva thesis set-visibility --id 9223372036854775807 --visibility private
12833
+ alva thesis update --id 9223372036854775807 --request-id 123e4567-e89b-42d3-a456-426614174000 --expected-author-version-id 9223372036854775806 --body-file ./thesis.md --visibility private
12834
+ printf '%s' 'Draft body' | alva thesis rewrite --body-stdin --mode shorten`
12426
12835
  };
12427
12836
  function boolFlag(val) {
12428
12837
  if (val === "true") return true;
@@ -12773,6 +13182,22 @@ function feedVisibility(val) {
12773
13182
  "feed"
12774
13183
  );
12775
13184
  }
13185
+ function thesisVisibility(value) {
13186
+ if (value === "public" || value === "private") return value;
13187
+ throw new CliUsageError(
13188
+ `--visibility must be public or private for 'thesis', got '${value}'`,
13189
+ "thesis"
13190
+ );
13191
+ }
13192
+ function thesisRewriteMode(value) {
13193
+ if (value === "reformat" || value === "shorten" || value === "enrich") {
13194
+ return value;
13195
+ }
13196
+ throw new CliUsageError(
13197
+ `--mode must be reformat, shorten, or enrich for 'thesis rewrite', got '${value}'`,
13198
+ "thesis"
13199
+ );
13200
+ }
12776
13201
  function parseCreditsTimestamp(value, flag, command2) {
12777
13202
  const trimmed = value.trim();
12778
13203
  if (/^\d+$/.test(trimmed)) {
@@ -12809,8 +13234,20 @@ function parseCreditsDurationMs(value) {
12809
13234
  }
12810
13235
  return durationMs;
12811
13236
  }
12812
- async function scheduleChannelId(client, flags) {
12813
- return flags["channel-id"] ?? client.schedules.agentChannelId();
13237
+ async function scheduleTarget(client, flags) {
13238
+ if (flags["inbox-path"] !== void 0) {
13239
+ if (flags["channel-id"] !== void 0)
13240
+ throw new CliUsageError(
13241
+ "--inbox-path and --channel-id are mutually exclusive",
13242
+ "schedule"
13243
+ );
13244
+ if (flags["inbox-path"] === "")
13245
+ throw new CliUsageError("--inbox-path must not be empty", "schedule");
13246
+ return { inboxPath: flags["inbox-path"] };
13247
+ }
13248
+ return {
13249
+ channelId: flags["channel-id"] ?? await client.schedules.agentChannelId()
13250
+ };
12814
13251
  }
12815
13252
  function scheduleRuleFromFlags(flags) {
12816
13253
  const selected = ["after", "at", "every", "cron"].filter(
@@ -13003,6 +13440,85 @@ function readLocalTextFile(path, command2, flag, deps) {
13003
13440
  }
13004
13441
  return deps.localFiles.readText(path);
13005
13442
  }
13443
+ async function thesisBodyFromFlags(flags, command2, deps) {
13444
+ const sources = [
13445
+ flags.body !== void 0 ? "body" : void 0,
13446
+ flags["body-file"] !== void 0 ? "body-file" : void 0,
13447
+ flags["body-stdin"] === "true" ? "body-stdin" : void 0
13448
+ ].filter((source) => source !== void 0);
13449
+ if (sources.length !== 1) {
13450
+ throw new CliUsageError(
13451
+ `${command2} requires exactly one of --body, --body-file, or --body-stdin`,
13452
+ "thesis"
13453
+ );
13454
+ }
13455
+ if (sources[0] === "body") return flags.body;
13456
+ if (sources[0] === "body-file") {
13457
+ assertLocalFileAvailable(command2, "--body-file", deps);
13458
+ if (!deps?.localFiles) {
13459
+ throw new Error("Local file access requires a Node.js runtime adapter.");
13460
+ }
13461
+ return strictThesisUTF8(
13462
+ deps.localFiles.readBytes(flags["body-file"]),
13463
+ command2,
13464
+ "--body-file"
13465
+ );
13466
+ }
13467
+ if (deps?.runtime === "jagent") {
13468
+ throw localFileUnsupported(command2, "--body-stdin");
13469
+ }
13470
+ if (!deps?.readStdinBytes) {
13471
+ throw new Error("Thesis stdin requires a Node.js byte-stdin adapter.");
13472
+ }
13473
+ return strictThesisUTF8(await deps.readStdinBytes(), command2, "--body-stdin");
13474
+ }
13475
+ function thesisEntityIDs(flags) {
13476
+ const raw = flags["entity-ids"];
13477
+ if (raw === void 0 || raw === "") return [];
13478
+ const entityIDs = raw.split(",").map((id) => id.trim());
13479
+ if (entityIDs.some((id) => id === "")) {
13480
+ throw new CliUsageError(
13481
+ "--entity-ids must not contain empty IDs",
13482
+ "thesis"
13483
+ );
13484
+ }
13485
+ return entityIDs;
13486
+ }
13487
+ function thesisTickers(flags) {
13488
+ const raw = flags.tickers;
13489
+ if (raw === void 0) return void 0;
13490
+ const tickers = raw.split(",").map((ticker) => ticker.trim());
13491
+ if (tickers.some((ticker) => ticker === "")) {
13492
+ throw new CliUsageError(
13493
+ "--tickers must not contain empty tickers",
13494
+ "thesis"
13495
+ );
13496
+ }
13497
+ return tickers;
13498
+ }
13499
+ function strictThesisUTF8(value, command2, flag) {
13500
+ const bytes = toByteView(value);
13501
+ if (bytes === void 0) {
13502
+ throw new Error(`${flag} requires a byte-capable Node.js runtime adapter.`);
13503
+ }
13504
+ try {
13505
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
13506
+ bytes
13507
+ );
13508
+ } catch {
13509
+ throw new CliUsageError(
13510
+ `${flag} must contain valid UTF-8 for '${command2}'`,
13511
+ "thesis"
13512
+ );
13513
+ }
13514
+ }
13515
+ function toByteView(value) {
13516
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
13517
+ if (ArrayBuffer.isView(value)) {
13518
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
13519
+ }
13520
+ return void 0;
13521
+ }
13006
13522
  function readLocalFileBytes(path, command2, flag, deps) {
13007
13523
  assertLocalFileAvailable(command2, flag, deps);
13008
13524
  if (!deps?.localFiles) {
@@ -13424,8 +13940,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13424
13940
  }
13425
13941
  switch (subcommand) {
13426
13942
  case "list": {
13427
- const channelId = await scheduleChannelId(client, flags);
13428
- return client.schedules.list({ channelId });
13943
+ return client.schedules.list(await scheduleTarget(client, flags));
13429
13944
  }
13430
13945
  case "put": {
13431
13946
  const rule = scheduleRuleFromFlags(flags);
@@ -13438,9 +13953,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13438
13953
  }
13439
13954
  const name = requireFlag(flags, "name", "schedule put");
13440
13955
  const text = requireFlag(flags, "message", "schedule put");
13441
- const channelId = await scheduleChannelId(client, flags);
13956
+ const target = await scheduleTarget(client, flags);
13442
13957
  return client.schedules.put({
13443
- channelId,
13958
+ ...target,
13444
13959
  name,
13445
13960
  text,
13446
13961
  rule,
@@ -13449,25 +13964,25 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13449
13964
  }
13450
13965
  case "pause": {
13451
13966
  const name = requireFlag(flags, "name", "schedule pause");
13452
- const channelId = await scheduleChannelId(client, flags);
13967
+ const target = await scheduleTarget(client, flags);
13453
13968
  return client.schedules.pause({
13454
- channelId,
13969
+ ...target,
13455
13970
  name
13456
13971
  });
13457
13972
  }
13458
13973
  case "resume": {
13459
13974
  const name = requireFlag(flags, "name", "schedule resume");
13460
- const channelId = await scheduleChannelId(client, flags);
13975
+ const target = await scheduleTarget(client, flags);
13461
13976
  return client.schedules.resume({
13462
- channelId,
13977
+ ...target,
13463
13978
  name
13464
13979
  });
13465
13980
  }
13466
13981
  case "delete": {
13467
13982
  const name = requireFlag(flags, "name", "schedule delete");
13468
- const channelId = await scheduleChannelId(client, flags);
13983
+ const target = await scheduleTarget(client, flags);
13469
13984
  await client.schedules.delete({
13470
- channelId,
13985
+ ...target,
13471
13986
  name
13472
13987
  });
13473
13988
  return { deleted: true };
@@ -13479,6 +13994,143 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13479
13994
  );
13480
13995
  }
13481
13996
  }
13997
+ case "steward": {
13998
+ if (!subcommand) {
13999
+ throw new CliUsageError("Missing subcommand for steward", "steward");
14000
+ }
14001
+ const inboxPath = requireFlag(
14002
+ flags,
14003
+ "inbox-path",
14004
+ `steward ${subcommand}`
14005
+ );
14006
+ const ids = (name) => requireFlag(flags, name, `steward ${subcommand}`).split(",").map((value) => value.trim()).filter((value) => value !== "");
14007
+ switch (subcommand) {
14008
+ case "decide":
14009
+ return client.steward.decide({
14010
+ inboxPath,
14011
+ deliveryId: requireFlag(flags, "delivery-id", "steward decide"),
14012
+ decision: requireDecision(
14013
+ requireFlag(flags, "decision", "steward decide")
14014
+ ),
14015
+ reason: requireFlag(flags, "reason", "steward decide")
14016
+ });
14017
+ case "forward":
14018
+ return client.steward.forward({
14019
+ inboxPath,
14020
+ deliveryId: requireFlag(flags, "delivery-id", "steward forward"),
14021
+ requestId: flags["request-id"]
14022
+ });
14023
+ case "send":
14024
+ return client.steward.send({
14025
+ inboxPath,
14026
+ body: requireFlag(flags, "body", "steward send"),
14027
+ deliveryIds: ids("delivery-ids"),
14028
+ requestId: flags["request-id"]
14029
+ });
14030
+ case "pending": {
14031
+ const parseTime = (name) => {
14032
+ const value = flags[name];
14033
+ if (value === void 0) return void 0;
14034
+ try {
14035
+ return parseRfc3339Milliseconds(value);
14036
+ } catch {
14037
+ throw new CliUsageError(
14038
+ `--${name} must be an RFC3339 timestamp with a timezone`,
14039
+ "steward"
14040
+ );
14041
+ }
14042
+ };
14043
+ const first = flags.first === void 0 ? void 0 : Number(flags.first);
14044
+ return client.steward.pending({
14045
+ inboxPath,
14046
+ after: flags.after,
14047
+ sinceMs: parseTime("since"),
14048
+ untilMs: parseTime("until"),
14049
+ first
14050
+ });
14051
+ }
14052
+ case "briefed":
14053
+ return client.steward.briefed({
14054
+ inboxPath,
14055
+ deliveryIds: ids("delivery-ids"),
14056
+ digestRunId: requireFlag(flags, "digest-run-id", "steward briefed")
14057
+ });
14058
+ default:
14059
+ throw new CliUsageError(
14060
+ `Unknown subcommand: steward ${subcommand}`,
14061
+ "steward"
14062
+ );
14063
+ }
14064
+ }
14065
+ case "thesis": {
14066
+ if (!subcommand) {
14067
+ throw new CliUsageError("Missing subcommand for thesis", "thesis");
14068
+ }
14069
+ switch (subcommand) {
14070
+ case "create":
14071
+ return client.theses.create({
14072
+ request_id: requireFlag(flags, "request-id", "thesis create"),
14073
+ body: await thesisBodyFromFlags(flags, "thesis create", deps),
14074
+ title: flags.title ?? "",
14075
+ entity_ids: thesisEntityIDs(flags),
14076
+ tickers: thesisTickers(flags),
14077
+ visibility: flags.visibility === void 0 ? "public" : thesisVisibility(flags.visibility)
14078
+ });
14079
+ case "get":
14080
+ return client.theses.get(requireFlag(flags, "id", "thesis get"));
14081
+ case "set-visibility":
14082
+ return client.theses.setVisibility(
14083
+ requireFlag(flags, "id", "thesis set-visibility"),
14084
+ {
14085
+ visibility: thesisVisibility(
14086
+ requireFlag(flags, "visibility", "thesis set-visibility")
14087
+ )
14088
+ }
14089
+ );
14090
+ case "update":
14091
+ return client.theses.update(
14092
+ requireFlag(flags, "id", "thesis update"),
14093
+ {
14094
+ request_id: requireFlag(flags, "request-id", "thesis update"),
14095
+ expected_author_version_id: requireFlag(
14096
+ flags,
14097
+ "expected-author-version-id",
14098
+ "thesis update"
14099
+ ),
14100
+ body: await thesisBodyFromFlags(flags, "thesis update", deps),
14101
+ title: flags.title ?? "",
14102
+ entity_ids: thesisEntityIDs(flags),
14103
+ visibility: thesisVisibility(
14104
+ requireFlag(flags, "visibility", "thesis update")
14105
+ ),
14106
+ editorial: boolFlag(flags.editorial) ?? false
14107
+ }
14108
+ );
14109
+ case "close":
14110
+ return client.theses.close(requireFlag(flags, "id", "thesis close"), {
14111
+ expected_author_version_id: requireFlag(
14112
+ flags,
14113
+ "expected-author-version-id",
14114
+ "thesis close"
14115
+ ),
14116
+ note: flags.note
14117
+ });
14118
+ case "delete":
14119
+ return client.theses.delete(
14120
+ requireFlag(flags, "id", "thesis delete")
14121
+ );
14122
+ case "rewrite":
14123
+ return client.theses.rewrite({
14124
+ body: await thesisBodyFromFlags(flags, "thesis rewrite", deps),
14125
+ mode: flags.mode === void 0 ? "reformat" : thesisRewriteMode(flags.mode)
14126
+ });
14127
+ default:
14128
+ throw new CliUsageError(
14129
+ `Unknown subcommand: thesis ${subcommand}`,
14130
+ "thesis"
14131
+ );
14132
+ }
14133
+ }
13482
14134
  case "service-account": {
13483
14135
  if (!subcommand)
13484
14136
  throw new CliUsageError(
@@ -15191,7 +15843,18 @@ async function dispatchEmbedded(client, args, meta, deps) {
15191
15843
  async function dispatchEmbeddedTarget(client, parsed, meta, deps) {
15192
15844
  const definition = embeddedCommandDefinition(parsed.path);
15193
15845
  let target;
15194
- if (definition.action === "notification-set-preference") {
15846
+ if (definition.action === "schedule-self" || definition.action === "steward-self") {
15847
+ const family = parsed.path[0];
15848
+ if (!client.originInboxPath)
15849
+ throw new CliUsageError(
15850
+ `${family} requires a host-attached Session Inbox`,
15851
+ family
15852
+ );
15853
+ target = {
15854
+ ...parsed,
15855
+ flags: { ...parsed.flags, "inbox-path": client.originInboxPath }
15856
+ };
15857
+ } else if (definition.action === "notification-set-preference") {
15195
15858
  const value = parsed.flags["session-completed"];
15196
15859
  if (value !== "enabled" && value !== "disabled") {
15197
15860
  throw new CliUsageError(