@alva-ai/toolkit 0.28.1-beta.0 → 0.29.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/cli.d.ts CHANGED
@@ -549,6 +549,8 @@ interface PlaybookDraftResponse {
549
549
  playbook_path: string;
550
550
  }
551
551
  interface PlaybookReleaseRequest {
552
+ /** Explicit consent to deliver bundled non-public Feeds to the Playbook audience. */
553
+ confirm_bundled_feed_exposure?: boolean;
552
554
  name: string;
553
555
  version: string;
554
556
  feeds: Array<{
@@ -2351,12 +2353,56 @@ interface ThesisGetResponse extends ThesisResponse {
2351
2353
  author: ThesisAuthor;
2352
2354
  entities: ThesisEntity[];
2353
2355
  }
2356
+ interface ThesisResearchStatus {
2357
+ state: string;
2358
+ pending_work: number;
2359
+ read_complete: boolean;
2360
+ last_attempt_ms?: number;
2361
+ last_completed_ms?: number;
2362
+ }
2363
+ interface ThesisSignalEvidenceExcerpt {
2364
+ text: string;
2365
+ omitted_before: boolean;
2366
+ omitted_after: boolean;
2367
+ }
2368
+ interface ThesisSignalSource {
2369
+ title: string;
2370
+ url?: string;
2371
+ published_at_ms?: number;
2372
+ }
2373
+ interface ThesisSignal {
2374
+ id: ThesisID;
2375
+ thesis_id: ThesisID;
2376
+ author_version_id: ThesisID;
2377
+ statement_snapshot: string;
2378
+ stance: string;
2379
+ explanation: string;
2380
+ information_kind: string;
2381
+ evidence_excerpt?: ThesisSignalEvidenceExcerpt;
2382
+ source: ThesisSignalSource;
2383
+ }
2384
+ interface ThesisSignalEntry {
2385
+ feed_entry_id: ThesisID;
2386
+ cursor: string;
2387
+ signal: ThesisSignal;
2388
+ }
2389
+ interface ListThesisSignalsParams {
2390
+ first?: number;
2391
+ cursor?: string;
2392
+ }
2393
+ interface ThesisSignalsResponse {
2394
+ research: ThesisResearchStatus;
2395
+ entries: ThesisSignalEntry[];
2396
+ next_cursor: string;
2397
+ }
2354
2398
  interface CreateThesisParams {
2355
2399
  /** Caller-supplied, stable non-zero UUID. Reuse it only to resolve ambiguity. */
2356
2400
  request_id: string;
2357
2401
  body: string;
2358
2402
  title?: string;
2359
2403
  entity_ids?: ThesisID[];
2404
+ /** Exact STOCK ticker symbols resolved by Backend during creation. */
2405
+ tickers?: string[];
2360
2406
  /** Omitted means public, as defined by the REST contract. */
2361
2407
  visibility?: ThesisVisibility;
2362
2408
  }
@@ -2371,6 +2417,9 @@ interface UpdateThesisParams {
2371
2417
  visibility: ThesisVisibility;
2372
2418
  editorial?: boolean;
2373
2419
  }
2420
+ interface SetThesisVisibilityParams {
2421
+ visibility: ThesisVisibility;
2422
+ }
2374
2423
  interface CloseThesisParams {
2375
2424
  expected_author_version_id: ThesisID;
2376
2425
  note?: string;
@@ -2392,7 +2441,10 @@ declare class ThesesResource {
2392
2441
  constructor(client: AlvaClient);
2393
2442
  create(params: CreateThesisParams): Promise<ThesisResponse>;
2394
2443
  get(id: ThesisID): Promise<ThesisGetResponse>;
2444
+ getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
2445
+ signals(id: ThesisID, params?: ListThesisSignalsParams): Promise<ThesisSignalsResponse>;
2395
2446
  update(id: ThesisID, params: UpdateThesisParams): Promise<ThesisResponse>;
2447
+ setVisibility(id: ThesisID, params: SetThesisVisibilityParams): Promise<ThesisResponse>;
2396
2448
  close(id: ThesisID, params: CloseThesisParams): Promise<ThesisResponse>;
2397
2449
  delete(id: ThesisID): Promise<Record<string, never>>;
2398
2450
  rewrite(params: RewriteThesisParams): Promise<RewriteThesisResponse>;
package/dist/cli.js CHANGED
@@ -6521,7 +6521,8 @@ var ReleaseResource = class {
6521
6521
  version: params.version,
6522
6522
  feeds: params.feeds,
6523
6523
  changelog: params.changelog,
6524
- readme_url: params.readme_url
6524
+ readme_url: params.readme_url,
6525
+ confirm_bundled_feed_exposure: params.confirm_bundled_feed_exposure
6525
6526
  }
6526
6527
  });
6527
6528
  }
@@ -10048,6 +10049,47 @@ var ThesesResource = class {
10048
10049
  await this.client._request("GET", `/api/v1/theses/${requireID(id, "id")}`)
10049
10050
  );
10050
10051
  }
10052
+ async getVersion(id, authorVersionID) {
10053
+ this.client._requireAuth();
10054
+ const thesisID = requireID(id, "id");
10055
+ const versionID = requireID(authorVersionID, "author_version_id");
10056
+ const response = thesisResponse(
10057
+ await this.client._request(
10058
+ "GET",
10059
+ `/api/v1/theses/${thesisID}/versions/${versionID}`
10060
+ )
10061
+ );
10062
+ if (response.thesis.id !== thesisID || response.thesis.author_version_id !== versionID) {
10063
+ throw invalidResponse2(
10064
+ "version response must match the requested thesis and author version"
10065
+ );
10066
+ }
10067
+ return response;
10068
+ }
10069
+ async signals(id, params = {}) {
10070
+ this.client._requireAuth();
10071
+ const first = params.first ?? 20;
10072
+ if (!Number.isInteger(first) || first < 1 || first > 50) {
10073
+ throw invalidArgument("first must be an integer between 1 and 50");
10074
+ }
10075
+ if (params.cursor !== void 0 && typeof params.cursor !== "string") {
10076
+ throw invalidArgument("cursor must be a string");
10077
+ }
10078
+ return thesisSignalsResponse(
10079
+ await this.client._request(
10080
+ "GET",
10081
+ `/api/v1/theses/${requireID(id, "id")}/signals`,
10082
+ {
10083
+ query: {
10084
+ first,
10085
+ ...params.cursor === void 0 ? {} : { cursor: params.cursor }
10086
+ }
10087
+ }
10088
+ ),
10089
+ id,
10090
+ first
10091
+ );
10092
+ }
10051
10093
  async update(id, params) {
10052
10094
  this.client._requireAuth();
10053
10095
  const body = updateBody(params);
@@ -10061,6 +10103,27 @@ var ThesesResource = class {
10061
10103
  )
10062
10104
  );
10063
10105
  }
10106
+ async setVisibility(id, params) {
10107
+ this.client._requireAuth();
10108
+ if (!params) {
10109
+ throw invalidArgument("params is required");
10110
+ }
10111
+ const thesisID = requireID(id, "id");
10112
+ const visibility = requireVisibility(params.visibility);
10113
+ const response = thesisResponse(
10114
+ await this.client._request(
10115
+ "POST",
10116
+ `/api/v1/theses/${thesisID}/visibility`,
10117
+ { body: { visibility } }
10118
+ )
10119
+ );
10120
+ if (response.thesis.id !== thesisID || response.thesis.visibility !== visibility) {
10121
+ throw invalidResponse2(
10122
+ "visibility response must match the requested thesis and visibility"
10123
+ );
10124
+ }
10125
+ return response;
10126
+ }
10064
10127
  async close(id, params) {
10065
10128
  this.client._requireAuth();
10066
10129
  const body = {
@@ -10108,13 +10171,16 @@ var ThesesResource = class {
10108
10171
  }
10109
10172
  };
10110
10173
  function createBody(params) {
10111
- return {
10174
+ const body = {
10112
10175
  request_id: requireRequestID(params.request_id),
10113
10176
  body: requireBody(params.body),
10114
10177
  title: requireTitle(params.title ?? ""),
10115
10178
  entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
10116
10179
  visibility: requireVisibility(params.visibility ?? "public")
10117
10180
  };
10181
+ if (params.tickers !== void 0)
10182
+ body.tickers = requireTickers(params.tickers);
10183
+ return body;
10118
10184
  }
10119
10185
  function updateBody(params) {
10120
10186
  return {
@@ -10195,6 +10261,112 @@ function thesisGetResponse(response) {
10195
10261
  });
10196
10262
  return { thesis: base.thesis, author, entities };
10197
10263
  }
10264
+ function thesisSignalsResponse(response, thesisID, first) {
10265
+ if (!isRecord2(response) || !isRecord2(response.research) || !Array.isArray(response.entries) || response.entries.length > first) {
10266
+ throw invalidResponse2("invalid Signal history response");
10267
+ }
10268
+ const research = response.research;
10269
+ const status = {
10270
+ state: responseText(research.state, "research.state"),
10271
+ pending_work: responseNonnegativeInteger(
10272
+ research.pending_work,
10273
+ "research.pending_work"
10274
+ ),
10275
+ read_complete: responseBoolean(
10276
+ research.read_complete,
10277
+ "research.read_complete"
10278
+ )
10279
+ };
10280
+ if (research.last_attempt_ms !== void 0)
10281
+ status.last_attempt_ms = responseNonnegativeInteger(
10282
+ research.last_attempt_ms,
10283
+ "research.last_attempt_ms"
10284
+ );
10285
+ if (research.last_completed_ms !== void 0)
10286
+ status.last_completed_ms = responseNonnegativeInteger(
10287
+ research.last_completed_ms,
10288
+ "research.last_completed_ms"
10289
+ );
10290
+ const entries = response.entries.map((raw) => {
10291
+ if (!isRecord2(raw) || !isRecord2(raw.signal) || !isRecord2(raw.signal.source)) {
10292
+ throw invalidResponse2("entry must include a Signal and source");
10293
+ }
10294
+ const signal = raw.signal;
10295
+ const source = signal.source;
10296
+ const signalID = responseID(signal.thesis_id, "signal.thesis_id");
10297
+ if (signalID !== thesisID)
10298
+ throw invalidResponse2("Signal belongs to another Thesis");
10299
+ const cursor = responseNonemptyText(raw.cursor, "entry.cursor");
10300
+ const mappedSource = {
10301
+ title: responseText(source.title, "source.title")
10302
+ };
10303
+ if (source.url !== void 0)
10304
+ mappedSource.url = responseText(source.url, "source.url");
10305
+ if (source.published_at_ms !== void 0)
10306
+ mappedSource.published_at_ms = responseNonnegativeInteger(
10307
+ source.published_at_ms,
10308
+ "source.published_at_ms"
10309
+ );
10310
+ const mappedSignal = {
10311
+ id: responseID(signal.id, "signal.id"),
10312
+ thesis_id: signalID,
10313
+ author_version_id: responseID(
10314
+ signal.author_version_id,
10315
+ "signal.author_version_id"
10316
+ ),
10317
+ statement_snapshot: responseNonemptyText(
10318
+ signal.statement_snapshot,
10319
+ "signal.statement_snapshot"
10320
+ ),
10321
+ stance: responseText(signal.stance, "signal.stance"),
10322
+ explanation: responseText(signal.explanation, "signal.explanation"),
10323
+ information_kind: responseText(
10324
+ signal.information_kind,
10325
+ "signal.information_kind"
10326
+ ),
10327
+ source: mappedSource
10328
+ };
10329
+ if (signal.evidence_excerpt !== void 0) {
10330
+ if (!isRecord2(signal.evidence_excerpt))
10331
+ throw invalidResponse2("invalid evidence excerpt");
10332
+ mappedSignal.evidence_excerpt = {
10333
+ text: responseNonemptyText(
10334
+ signal.evidence_excerpt.text,
10335
+ "evidence_excerpt.text"
10336
+ ),
10337
+ omitted_before: responseBoolean(
10338
+ signal.evidence_excerpt.omitted_before,
10339
+ "evidence_excerpt.omitted_before"
10340
+ ),
10341
+ omitted_after: responseBoolean(
10342
+ signal.evidence_excerpt.omitted_after,
10343
+ "evidence_excerpt.omitted_after"
10344
+ )
10345
+ };
10346
+ }
10347
+ return {
10348
+ feed_entry_id: responseID(raw.feed_entry_id, "feed_entry_id"),
10349
+ cursor,
10350
+ signal: mappedSignal
10351
+ };
10352
+ });
10353
+ const nextCursor = responseText(response.next_cursor, "next_cursor");
10354
+ if (nextCursor && nextCursor !== entries[entries.length - 1]?.cursor) {
10355
+ throw invalidResponse2("next_cursor must match the final entry");
10356
+ }
10357
+ return { research: status, entries, next_cursor: nextCursor };
10358
+ }
10359
+ function responseNonnegativeInteger(value, field) {
10360
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
10361
+ throw invalidResponse2(field + " must be a nonnegative safe integer");
10362
+ }
10363
+ return value;
10364
+ }
10365
+ function responseNonemptyText(value, field) {
10366
+ const valueText = responseText(value, field);
10367
+ if (!valueText.trim()) throw invalidResponse2(field + " must be nonempty");
10368
+ return valueText;
10369
+ }
10198
10370
  function requireRequestID(value) {
10199
10371
  if (!UUID.test(value) || /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(value)) {
10200
10372
  throw invalidArgument("request_id must be a non-zero RFC 4122 UUID");
@@ -10218,6 +10390,19 @@ function requireIDs(value, field) {
10218
10390
  }
10219
10391
  return value.map((item, index) => requireID(item, `${field}[${index}]`));
10220
10392
  }
10393
+ function requireTickers(value) {
10394
+ if (!Array.isArray(value)) throw invalidArgument("tickers must be an array");
10395
+ if (value.length > 100) {
10396
+ throw invalidArgument("tickers must contain at most 100 values");
10397
+ }
10398
+ return value.map((item, index) => {
10399
+ const ticker = requireText2(item, `tickers[${index}]`);
10400
+ if (ticker.trim() === "" || ticker.includes("\0")) {
10401
+ throw invalidArgument(`tickers[${index}] must be non-empty`);
10402
+ }
10403
+ return ticker;
10404
+ });
10405
+ }
10221
10406
  function requireBody(value) {
10222
10407
  const body = requireText2(value, "body");
10223
10408
  if (body.trim().length === 0) throw invalidArgument("body must not be blank");
@@ -11018,11 +11203,17 @@ var COMMAND_DEFINITIONS = [
11018
11203
  "body-file",
11019
11204
  "title",
11020
11205
  "entity-ids",
11206
+ "tickers",
11021
11207
  "visibility"
11022
11208
  ],
11023
11209
  booleans: ["body-stdin"]
11024
11210
  }),
11025
11211
  command("thesis get", { values: ["id"] }),
11212
+ command("thesis version get", {
11213
+ values: ["id", "author-version-id"]
11214
+ }),
11215
+ command("thesis signals", { values: ["id", "first", "cursor"] }),
11216
+ command("thesis set-visibility", { values: ["id", "visibility"] }),
11026
11217
  command("thesis update", {
11027
11218
  values: [
11028
11219
  "id",
@@ -11176,7 +11367,7 @@ var COMMAND_DEFINITIONS = [
11176
11367
  }),
11177
11368
  command("release playbook", {
11178
11369
  values: ["name", "version", "feeds", "changelog", "readme-url"],
11179
- booleans: ["bypass-lint"]
11370
+ booleans: ["bypass-lint", "confirm-bundled-feed-exposure"]
11180
11371
  }),
11181
11372
  command("lint playbook", {
11182
11373
  values: ["format"],
@@ -15712,7 +15903,7 @@ function formatTradingPairResolved(result) {
15712
15903
  }
15713
15904
 
15714
15905
  // src/cli/dispatch.ts
15715
- var CLI_VERSION = true ? "0.28.1-beta.0" : "dev";
15906
+ var CLI_VERSION = true ? "0.29.0" : "dev";
15716
15907
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
15717
15908
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
15718
15909
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -15756,7 +15947,7 @@ Commands:
15756
15947
  deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)
15757
15948
  schedule Agent-owned named schedules (list, put, pause, resume, delete)
15758
15949
  steward Push steward reports for a Session Inbox (decide, forward, send, pending, briefed)
15759
- thesis Authored thesis lifecycle (create, get, update, close, delete, rewrite)
15950
+ thesis Authored thesis lifecycle (create, get, signals, set-visibility, update, close, delete, rewrite)
15760
15951
  service-account Restricted run-as identities (create, list, delete, grant, revoke)
15761
15952
  release Feed and playbook releases (feed, playbook-draft, playbook)
15762
15953
  lint Design-system lint (playbook)
@@ -16589,6 +16780,9 @@ Playbook-draft flags:
16589
16780
  with skill tags; re-draft replaces the tag set.
16590
16781
 
16591
16782
  Playbook flags:
16783
+ --confirm-bundled-feed-exposure
16784
+ Confirm delivery of bundled non-public Feeds to
16785
+ the Playbook audience. Defaults to unconfirmed.
16592
16786
  --name <name> Playbook name, must already exist as draft (required)
16593
16787
  --version <version> Semantic version, e.g. "v1.0.0" (required)
16594
16788
  --feeds <json> JSON array of {feed_id, feed_major?} (required)
@@ -17081,13 +17275,16 @@ Examples:
17081
17275
  alva arrays token status`,
17082
17276
  thesis: `Usage: alva thesis <subcommand> [options]
17083
17277
 
17084
- Create, read, update, close, delete, or explicitly rewrite an authored thesis.
17278
+ Create, read, inspect Signals and exact author versions, update, close, delete, or explicitly rewrite an authored thesis.
17085
17279
  Backend owns Signal/Alert setup; the CLI never starts them separately.
17086
17280
  Create and update never rewrite text automatically.
17087
17281
 
17088
17282
  Subcommands:
17089
17283
  create Create a thesis
17090
17284
  get Get one thesis
17285
+ version get Get one exact author version
17286
+ signals Read published Signal history
17287
+ set-visibility Change current access without publishing a version
17091
17288
  update Replaces document fields: body, title, entities, visibility (all sent in full)
17092
17289
  close Close the current author version with an optional note
17093
17290
  delete Delete a thesis
@@ -17105,8 +17302,11 @@ the backend; do not send a fresh ID. Create defaults --visibility to public.
17105
17302
  Update requires --visibility explicitly so it cannot inadvertently publish.
17106
17303
 
17107
17304
  Other flags:
17108
- create --request-id <uuid> --body ... [--title <text>] [--entity-ids <id,id>] [--visibility <value>]
17305
+ create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--visibility <value>]
17109
17306
  get --id <signed-int64-decimal>
17307
+ version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
17308
+ signals --id <id> [--first <1-50>] [--cursor <opaque-cursor>]
17309
+ set-visibility --id <id> --visibility public|private
17110
17310
  update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--editorial]
17111
17311
  close --id <id> --expected-author-version-id <id> [--note <text>]
17112
17312
  delete --id <id>
@@ -17126,6 +17326,7 @@ valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
17126
17326
 
17127
17327
  Examples:
17128
17328
  alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two'
17329
+ alva thesis set-visibility --id 9223372036854775807 --visibility private
17129
17330
  alva thesis update --id 9223372036854775807 --request-id 123e4567-e89b-42d3-a456-426614174000 --expected-author-version-id 9223372036854775806 --body-file ./thesis.md --visibility private
17130
17331
  printf '%s' 'Draft body' | alva thesis rewrite --body-stdin --mode shorten`
17131
17332
  };
@@ -17808,6 +18009,18 @@ function thesisEntityIDs(flags) {
17808
18009
  }
17809
18010
  return entityIDs;
17810
18011
  }
18012
+ function thesisTickers(flags) {
18013
+ const raw = flags.tickers;
18014
+ if (raw === void 0) return void 0;
18015
+ const tickers = raw.split(",").map((ticker) => ticker.trim());
18016
+ if (tickers.some((ticker) => ticker === "")) {
18017
+ throw new CliUsageError(
18018
+ "--tickers must not contain empty tickers",
18019
+ "thesis"
18020
+ );
18021
+ }
18022
+ return tickers;
18023
+ }
17811
18024
  function strictThesisUTF8(value, command2, flag) {
17812
18025
  const bytes = toByteView(value);
17813
18026
  if (bytes === void 0) {
@@ -18410,10 +18623,33 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
18410
18623
  body: await thesisBodyFromFlags(flags, "thesis create", deps),
18411
18624
  title: flags.title ?? "",
18412
18625
  entity_ids: thesisEntityIDs(flags),
18626
+ tickers: thesisTickers(flags),
18413
18627
  visibility: flags.visibility === void 0 ? "public" : thesisVisibility(flags.visibility)
18414
18628
  });
18415
18629
  case "get":
18416
18630
  return client.theses.get(requireFlag(flags, "id", "thesis get"));
18631
+ case "version":
18632
+ return client.theses.getVersion(
18633
+ requireFlag(flags, "id", "thesis version get"),
18634
+ requireFlag(flags, "author-version-id", "thesis version get")
18635
+ );
18636
+ case "signals":
18637
+ return client.theses.signals(
18638
+ requireFlag(flags, "id", "thesis signals"),
18639
+ {
18640
+ first: flags.first === void 0 ? void 0 : Number(flags.first),
18641
+ cursor: flags.cursor
18642
+ }
18643
+ );
18644
+ case "set-visibility":
18645
+ return client.theses.setVisibility(
18646
+ requireFlag(flags, "id", "thesis set-visibility"),
18647
+ {
18648
+ visibility: thesisVisibility(
18649
+ requireFlag(flags, "visibility", "thesis set-visibility")
18650
+ )
18651
+ }
18652
+ );
18417
18653
  case "update":
18418
18654
  return client.theses.update(
18419
18655
  requireFlag(flags, "id", "thesis update"),
@@ -18935,7 +19171,10 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
18935
19171
  version,
18936
19172
  feeds: jsonParse(feedsRaw),
18937
19173
  changelog,
18938
- readme_url: readmeUrl
19174
+ readme_url: readmeUrl,
19175
+ confirm_bundled_feed_exposure: boolFlag(
19176
+ flags["confirm-bundled-feed-exposure"]
19177
+ )
18939
19178
  });
18940
19179
  }
18941
19180
  default: