@alva-ai/toolkit 0.35.0 → 0.36.0-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/cli.d.ts CHANGED
@@ -2743,14 +2743,87 @@ interface RelatedThesesPage {
2743
2743
  }[];
2744
2744
  nextCursor: string | null;
2745
2745
  }
2746
+ interface ThesisReturnParams {
2747
+ /** Revalue at the latest prices and include each Update's positions. */
2748
+ detail?: boolean;
2749
+ }
2750
+ /** A position of one Update, as ThesisPositionReturn in GraphQL. */
2751
+ interface ThesisPositionReturn {
2752
+ entityId: string;
2753
+ symbol: string;
2754
+ direction: 'BULLISH' | 'BEARISH';
2755
+ startPrice: number | null;
2756
+ startAtMs: number | null;
2757
+ endPrice: number | null;
2758
+ endAtMs: number | null;
2759
+ end: 'PENDING' | 'NEXT_UPDATE' | 'LATEST';
2760
+ positionReturn: number;
2761
+ currency: string;
2762
+ }
2763
+ /** One Update on the return chart. */
2764
+ interface ThesisUpdateReturn {
2765
+ authorVersionId: string;
2766
+ publishedAtMs: number;
2767
+ startValue: number;
2768
+ updateReturn: number | null;
2769
+ positions: ThesisPositionReturn[];
2770
+ }
2771
+ /** The Thesis return; values are fractions (0.05 is +5%). */
2772
+ interface ThesisReturnValue {
2773
+ live: boolean;
2774
+ value: number;
2775
+ firstFillAtMs: number | null;
2776
+ pricedAtMs: number | null;
2777
+ stale: boolean;
2778
+ computedAtMs: number;
2779
+ updates: ThesisUpdateReturn[];
2780
+ }
2781
+ interface ThesisReturnResult {
2782
+ playbookId: string;
2783
+ /** UNSET, ON or OFF; null when the current publication is not readable. */
2784
+ returnTracking: 'UNSET' | 'ON' | 'OFF' | null;
2785
+ /** Null when the Thesis is not tracked. */
2786
+ thesisReturn: ThesisReturnValue | null;
2787
+ }
2746
2788
 
2747
2789
  /** Thesis IDs are signed int64 values represented losslessly as decimal strings. */
2748
2790
  type ThesisID = string;
2749
2791
  type ThesisVisibility = 'public' | 'private' | 'paid';
2750
- type ThesisAssetStance = 'unknown' | 'bullish' | 'bearish';
2792
+ /** unknown: not judged; none: judged without a current long or short. */
2793
+ type ThesisAssetStance = 'unknown' | 'bullish' | 'bearish' | 'none';
2751
2794
  interface ThesisEntityStance {
2752
2795
  entity_id: ThesisID;
2753
2796
  stance: ThesisAssetStance;
2797
+ /** Full direction in responses; stance reports none as unknown there. */
2798
+ direction?: ThesisAssetStance;
2799
+ }
2800
+ /** GraphQL direction, including NONE. */
2801
+ type ThesisDirection = 'UNKNOWN' | 'BULLISH' | 'BEARISH' | 'NONE';
2802
+ interface ThesisSelectedDirection {
2803
+ entityId: ThesisID;
2804
+ direction: ThesisDirection;
2805
+ }
2806
+ type ThesisReturnTracking = 'UNSET' | 'ON' | 'OFF';
2807
+ /** What publishing the selected entities with their directions would store. */
2808
+ interface ThesisReturnPreview {
2809
+ /** The Thesis's return switch now; UNSET for a new Thesis. */
2810
+ tracking: ThesisReturnTracking;
2811
+ /** Ask the author whether to keep the return on. */
2812
+ askSwitch: boolean;
2813
+ /** Directions publishing would store; UNKNOWN could not be judged. */
2814
+ directions: ThesisSelectedDirection[];
2815
+ /** Exits that keep the previous direction (last-leg rule). */
2816
+ keptEntityIds: ThesisID[];
2817
+ /** Publishing this draft fails with THESIS_RETURN_LAST_LEG. */
2818
+ lastLegRemoved: boolean;
2819
+ }
2820
+ interface ThesisAssetCandidatesParams {
2821
+ /** Known catalog IDs to classify; with discover false, only these. */
2822
+ entityIds?: ThesisID[];
2823
+ /** The Thesis being updated: its current directions seed carried tickers. */
2824
+ thesisId?: ThesisID;
2825
+ /** False skips ticker discovery. Defaults to true. */
2826
+ discover?: boolean;
2754
2827
  }
2755
2828
  interface ThesisAssetCandidate {
2756
2829
  entityId: ThesisID;
@@ -2767,6 +2840,8 @@ interface ThesisAssetMention {
2767
2840
  }
2768
2841
  interface ThesisAssetCandidatesResponse {
2769
2842
  mentions: ThesisAssetMention[];
2843
+ /** Null only from a server without the preview. */
2844
+ returnPreview: ThesisReturnPreview | null;
2770
2845
  }
2771
2846
  /** Canonical server-supported candidate rewrite operation. */
2772
2847
  type ThesisRewriteMode = 'reformat' | 'shorten' | 'enrich';
@@ -2870,6 +2945,8 @@ interface CreateThesisParams {
2870
2945
  tickers?: string[];
2871
2946
  /** Omitted means public, as defined by the REST contract. */
2872
2947
  visibility?: 'public' | 'private';
2948
+ /** Thesis return switch; omitted keeps the default (on). */
2949
+ track_return?: boolean;
2873
2950
  }
2874
2951
  interface UpdateThesisParams {
2875
2952
  /** Full media replacement; pass current medias for a text-only update. */
@@ -2884,9 +2961,10 @@ interface UpdateThesisParams {
2884
2961
  entity_stances?: ThesisEntityStance[];
2885
2962
  /** Required so an update cannot inadvertently publish a private thesis. */
2886
2963
  visibility: ThesisVisibility;
2887
- editorial?: boolean;
2888
2964
  archived?: boolean;
2889
2965
  note?: string;
2966
+ /** Thesis return switch; omitted keeps the current decision or default. */
2967
+ track_return?: boolean;
2890
2968
  }
2891
2969
  interface SetThesisArchivedParams {
2892
2970
  /** Caller-supplied, stable non-zero UUID for this archive transition. */
@@ -2909,10 +2987,6 @@ interface ThesisSignalEnabledResponse {
2909
2987
  interface SetThesisVisibilityParams {
2910
2988
  visibility: 'public' | 'private';
2911
2989
  }
2912
- interface CloseThesisParams {
2913
- expected_author_version_id: ThesisID;
2914
- note?: string;
2915
- }
2916
2990
  interface RewriteThesisParams {
2917
2991
  body: string;
2918
2992
  /** Omitted selects the canonical `reformat` mode. */
@@ -2932,7 +3006,9 @@ declare class ThesesResource {
2932
3006
  list(params: ListThesesParams): Promise<ThesisListPage>;
2933
3007
  /** Related publications always use the current source version. */
2934
3008
  related(id: ThesisID, params?: ThesisPageParams): Promise<RelatedThesesPage>;
2935
- assetCandidates(text: string): Promise<ThesisAssetCandidatesResponse>;
3009
+ assetCandidates(text: string, params?: ThesisAssetCandidatesParams): Promise<ThesisAssetCandidatesResponse>;
3010
+ /** The Thesis return of a Playbook's current publication; detail revalues it. */
3011
+ thesisReturn(id: ThesisID, params?: ThesisReturnParams): Promise<ThesisReturnResult>;
2936
3012
  create(params: CreateThesisParams): Promise<ThesisResponse>;
2937
3013
  get(id: ThesisID): Promise<ThesisGetResponse>;
2938
3014
  getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
@@ -2944,8 +3020,6 @@ declare class ThesesResource {
2944
3020
  versions: Thesis[];
2945
3021
  next_cursor: string;
2946
3022
  }>;
2947
- /** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
2948
- deleteUpdate(id: ThesisID, authorVersionID: ThesisID, expectedAuthorVersionID: ThesisID): Promise<ThesisResponse>;
2949
3023
  signals(id: ThesisID, params?: ListThesisSignalsParams): Promise<ThesisSignalsResponse>;
2950
3024
  update(id: ThesisID, params: UpdateThesisParams): Promise<ThesisResponse>;
2951
3025
  /** Archive or restore the current version without asking callers to resend its body. */
@@ -2953,8 +3027,6 @@ declare class ThesesResource {
2953
3027
  setStarred(id: ThesisID, isStarred: boolean): Promise<ThesisStarredResponse>;
2954
3028
  setSignalEnabled(id: ThesisID, enabled: boolean): Promise<ThesisSignalEnabledResponse>;
2955
3029
  setVisibility(id: ThesisID, params: SetThesisVisibilityParams): Promise<ThesisResponse>;
2956
- close(id: ThesisID, params: CloseThesisParams): Promise<ThesisResponse>;
2957
- delete(id: ThesisID): Promise<Record<string, never>>;
2958
3030
  rewrite(params: RewriteThesisParams): Promise<RewriteThesisResponse>;
2959
3031
  }
2960
3032
 
package/dist/cli.js CHANGED
@@ -11148,6 +11148,58 @@ function nextCursor(page) {
11148
11148
  throw invalid3();
11149
11149
  return info.hasNextPage ? info.endCursor : null;
11150
11150
  }
11151
+ var RETURN_QUERY = `query ToolkitThesisReturn($id: ID!, $detail: Boolean!) {
11152
+ node(id: $id) { ... on Playbook { latestRelease { thesisPublication {
11153
+ returnTracking
11154
+ thesisReturn(detail: $detail) {
11155
+ live value firstFillAtMs pricedAtMs stale computedAtMs
11156
+ updates { authorVersionId publishedAtMs startValue updateReturn
11157
+ positions { entityId symbol direction startPrice startAtMs endPrice endAtMs end positionReturn currency } }
11158
+ }
11159
+ } } } }
11160
+ }`;
11161
+ async function thesisReturn(client, id, params = {}) {
11162
+ if (!isPositiveInt64(id))
11163
+ throw argument("id must be an internal positive int64 Playbook ID");
11164
+ if (params.detail !== void 0 && typeof params.detail !== "boolean")
11165
+ throw argument("detail must be a boolean");
11166
+ client._requireAuth();
11167
+ const data = await graphql(client, RETURN_QUERY, {
11168
+ id: `Playbook:${id}`,
11169
+ detail: params.detail ?? false
11170
+ });
11171
+ if (data.node === null) throw notFound();
11172
+ if (!record2(data.node)) throw invalid3();
11173
+ const release = data.node.latestRelease;
11174
+ if (release === null || release === void 0)
11175
+ return { playbookId: id, returnTracking: null, thesisReturn: null };
11176
+ if (!record2(release)) throw invalid3();
11177
+ const publication = release.thesisPublication;
11178
+ if (publication === null)
11179
+ return { playbookId: id, returnTracking: null, thesisReturn: null };
11180
+ if (!record2(publication)) throw invalid3();
11181
+ const tracking = publication.returnTracking;
11182
+ if (tracking !== null && !["UNSET", "ON", "OFF"].includes(tracking))
11183
+ throw invalid3();
11184
+ const value = publication.thesisReturn;
11185
+ if (value !== null && !validThesisReturn(value)) throw invalid3();
11186
+ return {
11187
+ playbookId: id,
11188
+ returnTracking: tracking,
11189
+ thesisReturn: value
11190
+ };
11191
+ }
11192
+ function validThesisReturn(value) {
11193
+ if (!record2(value) || typeof value.live !== "boolean" || typeof value.value !== "number" || typeof value.stale !== "boolean" || typeof value.computedAtMs !== "number" || !Array.isArray(value.updates))
11194
+ return false;
11195
+ return value.updates.every(
11196
+ (update) => record2(update) && nonempty(update.authorVersionId) && typeof update.publishedAtMs === "number" && typeof update.startValue === "number" && Array.isArray(update.positions) && update.positions.every(
11197
+ (position) => record2(position) && nonempty(position.symbol) && ["BULLISH", "BEARISH"].includes(position.direction) && ["PENDING", "NEXT_UPDATE", "LATEST"].includes(
11198
+ position.end
11199
+ ) && typeof position.positionReturn === "number"
11200
+ )
11201
+ );
11202
+ }
11151
11203
  async function graphql(client, document, variables) {
11152
11204
  const response = await client._request("POST", "/query", {
11153
11205
  body: { query: document, variables }
@@ -11233,17 +11285,29 @@ var ThesesResource = class {
11233
11285
  related(id, params = {}) {
11234
11286
  return relatedTheses(this.client, id, params);
11235
11287
  }
11236
- async assetCandidates(text) {
11288
+ async assetCandidates(text, params = {}) {
11237
11289
  this.client._requireAuth();
11238
11290
  const source = requireBody(text);
11291
+ const input = {
11292
+ text: source,
11293
+ selectedEntityIds: requireIDs(params.entityIds ?? [], "entityIds")
11294
+ };
11295
+ if (params.thesisId !== void 0)
11296
+ input.thesisId = requireID(params.thesisId, "thesisId");
11297
+ if (params.discover !== void 0) {
11298
+ if (typeof params.discover !== "boolean")
11299
+ throw invalidArgument("discover must be a boolean");
11300
+ input.discover = params.discover;
11301
+ }
11239
11302
  const response = await this.client._request("POST", "/query", {
11240
11303
  body: {
11241
11304
  query: `query ThesisAssetCandidates($input: ThesisAssetCandidatesInput!) {
11242
11305
  viewer { thesisAssetCandidates(input: $input) {
11243
11306
  mentions { quote ticker resolution stance candidates { entityId ticker name kind } }
11307
+ returnPreview { tracking askSwitch directions { entityId direction } keptEntityIds lastLegRemoved }
11244
11308
  } }
11245
11309
  }`,
11246
- variables: { input: { text: source } }
11310
+ variables: { input }
11247
11311
  }
11248
11312
  });
11249
11313
  if (Array.isArray(response?.errors) && response.errors.length > 0) {
@@ -11281,7 +11345,11 @@ var ThesesResource = class {
11281
11345
  });
11282
11346
  return { ...item, candidates };
11283
11347
  });
11284
- return { mentions };
11348
+ return { mentions, returnPreview: returnPreview(result.returnPreview) };
11349
+ }
11350
+ /** The Thesis return of a Playbook's current publication; detail revalues it. */
11351
+ thesisReturn(id, params = {}) {
11352
+ return thesisReturn(this.client, id, params);
11285
11353
  }
11286
11354
  async create(params) {
11287
11355
  this.client._requireAuth();
@@ -11343,30 +11411,6 @@ var ThesesResource = class {
11343
11411
  throw invalidResponse4("Update list must match requested Thesis");
11344
11412
  return { versions, next_cursor: response.next_cursor };
11345
11413
  }
11346
- /** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
11347
- async deleteUpdate(id, authorVersionID, expectedAuthorVersionID) {
11348
- this.client._requireAuth();
11349
- const thesisID = requireID(id, "id");
11350
- const versionID = requireID(authorVersionID, "author_version_id");
11351
- const expected = requireID(
11352
- expectedAuthorVersionID,
11353
- "expected_author_version_id"
11354
- );
11355
- const response = thesisResponse(
11356
- await this.client._request(
11357
- "DELETE",
11358
- `/api/v1/theses/${thesisID}/versions/${versionID}`,
11359
- {
11360
- query: { expected_author_version_id: expected }
11361
- }
11362
- )
11363
- );
11364
- if (response.thesis.id !== thesisID)
11365
- throw invalidResponse4(
11366
- "delete Update response must match requested Thesis"
11367
- );
11368
- return response;
11369
- }
11370
11414
  async signals(id, params = {}) {
11371
11415
  this.client._requireAuth();
11372
11416
  const first = params.first ?? 20;
@@ -11542,35 +11586,6 @@ var ThesesResource = class {
11542
11586
  }
11543
11587
  return response;
11544
11588
  }
11545
- async close(id, params) {
11546
- this.client._requireAuth();
11547
- const body = {
11548
- expected_author_version_id: requireID(
11549
- params.expected_author_version_id,
11550
- "expected_author_version_id"
11551
- )
11552
- };
11553
- if (params.note !== void 0) body.note = requireText2(params.note, "note");
11554
- return thesisResponse(
11555
- await this.client._request(
11556
- "POST",
11557
- `/api/v1/theses/${requireID(id, "id")}/close`,
11558
- { body }
11559
- )
11560
- );
11561
- }
11562
- async delete(id) {
11563
- this.client._requireAuth();
11564
- const response = await this.client._request(
11565
- "DELETE",
11566
- `/api/v1/theses/${requireID(id, "id")}`
11567
- );
11568
- if (response === void 0) return {};
11569
- if (!isRecord2(response) || Object.keys(response).length !== 0) {
11570
- throw invalidResponse4("delete response must be {}");
11571
- }
11572
- return {};
11573
- }
11574
11589
  async rewrite(params) {
11575
11590
  this.client._requireAuth();
11576
11591
  const body = requireBody(params.body);
@@ -11613,6 +11628,8 @@ function createBody(params) {
11613
11628
  }
11614
11629
  if (params.tickers !== void 0)
11615
11630
  body.tickers = requireTickers(params.tickers);
11631
+ if (params.track_return !== void 0)
11632
+ body.track_return = requireTrackReturn(params.track_return);
11616
11633
  if (params.entity_stances !== void 0) {
11617
11634
  body.entity_stances = requireEntityStances(
11618
11635
  params.entity_stances,
@@ -11621,6 +11638,52 @@ function createBody(params) {
11621
11638
  }
11622
11639
  return body;
11623
11640
  }
11641
+ var ENTITY_STANCES = [
11642
+ "unknown",
11643
+ "bullish",
11644
+ "bearish",
11645
+ "none"
11646
+ ];
11647
+ var THESIS_DIRECTIONS = [
11648
+ "UNKNOWN",
11649
+ "BULLISH",
11650
+ "BEARISH",
11651
+ "NONE"
11652
+ ];
11653
+ var RETURN_TRACKING = ["UNSET", "ON", "OFF"];
11654
+ function requireTrackReturn(value) {
11655
+ if (typeof value !== "boolean")
11656
+ throw invalidArgument("track_return must be a boolean");
11657
+ return value;
11658
+ }
11659
+ function selectedDirections(value, field) {
11660
+ if (!Array.isArray(value)) throw invalidResponse4(`${field} must be an array`);
11661
+ return value.map((item, index) => {
11662
+ if (!isRecord2(item) || !THESIS_DIRECTIONS.includes(item.direction))
11663
+ throw invalidResponse4(`${field}[${index}] is invalid`);
11664
+ return {
11665
+ entityId: responseID(item.entityId, `${field}[${index}].entityId`),
11666
+ direction: item.direction
11667
+ };
11668
+ });
11669
+ }
11670
+ function returnPreview(value) {
11671
+ if (value === null || value === void 0) return null;
11672
+ if (!isRecord2(value) || !RETURN_TRACKING.includes(value.tracking) || typeof value.askSwitch !== "boolean" || typeof value.lastLegRemoved !== "boolean" || !Array.isArray(value.keptEntityIds))
11673
+ throw invalidResponse4("returnPreview is invalid");
11674
+ return {
11675
+ tracking: value.tracking,
11676
+ askSwitch: value.askSwitch,
11677
+ directions: selectedDirections(
11678
+ value.directions,
11679
+ "returnPreview.directions"
11680
+ ),
11681
+ keptEntityIds: value.keptEntityIds.map(
11682
+ (id, index) => responseID(id, `returnPreview.keptEntityIds[${index}]`)
11683
+ ),
11684
+ lastLegRemoved: value.lastLegRemoved
11685
+ };
11686
+ }
11624
11687
  function requireEntityStances(value, entityIDs) {
11625
11688
  if (!Array.isArray(value) || value.length > MAX_ENTITY_IDS)
11626
11689
  throw invalidArgument("entity_stances must contain at most 100 values");
@@ -11638,7 +11701,7 @@ function requireEntityStances(value, entityIDs) {
11638
11701
  "entity stance must reference one unique entity_id"
11639
11702
  );
11640
11703
  seen.add(entityID);
11641
- if (!["unknown", "bullish", "bearish"].includes(item.stance))
11704
+ if (!ENTITY_STANCES.includes(item.stance))
11642
11705
  throw invalidArgument(`entity_stances[${index}].stance is invalid`);
11643
11706
  return { entity_id: entityID, stance: item.stance };
11644
11707
  });
@@ -11653,8 +11716,7 @@ function updateBody(params) {
11653
11716
  body: requireBody(params.body),
11654
11717
  title: requireTitle(params.title ?? ""),
11655
11718
  entity_ids: requireIDs(params.entity_ids ?? [], "entity_ids"),
11656
- visibility: requireVisibility(params.visibility),
11657
- editorial: params.editorial ?? false
11719
+ visibility: requireVisibility(params.visibility)
11658
11720
  };
11659
11721
  if (params.medias !== void 0) {
11660
11722
  if (!Array.isArray(params.medias) || params.medias.length > 20)
@@ -11669,6 +11731,8 @@ function updateBody(params) {
11669
11731
  body.archived = params.archived;
11670
11732
  }
11671
11733
  if (params.note !== void 0) body.note = requireText2(params.note, "note");
11734
+ if (params.track_return !== void 0)
11735
+ body.track_return = requireTrackReturn(params.track_return);
11672
11736
  if (params.entity_stances !== void 0) {
11673
11737
  body.entity_stances = requireEntityStances(
11674
11738
  params.entity_stances,
@@ -11731,9 +11795,20 @@ function thesisResponse(response) {
11731
11795
  const entityID = responseID(item.entity_id, "entity_stances.entity_id");
11732
11796
  if (!value.entity_ids.includes(entityID))
11733
11797
  throw invalidResponse4("entity stance must reference a thesis entity");
11734
- if (!["unknown", "bullish", "bearish"].includes(item.stance))
11798
+ if (!ENTITY_STANCES.includes(item.stance))
11735
11799
  throw invalidResponse4("thesis.entity_stances contains invalid stance");
11736
- return { entity_id: entityID, stance: item.stance };
11800
+ const stance = {
11801
+ entity_id: entityID,
11802
+ stance: item.stance
11803
+ };
11804
+ if (item.direction !== void 0) {
11805
+ if (!ENTITY_STANCES.includes(item.direction))
11806
+ throw invalidResponse4(
11807
+ "thesis.entity_stances contains invalid direction"
11808
+ );
11809
+ stance.direction = item.direction;
11810
+ }
11811
+ return stance;
11737
11812
  });
11738
11813
  }
11739
11814
  return { thesis: value };
@@ -12584,7 +12659,8 @@ var AlvaClient = class {
12584
12659
  throw new AlvaError(
12585
12660
  data.error.code ?? "UNKNOWN",
12586
12661
  data.error.message ?? `HTTP ${response.status}`,
12587
- response.status
12662
+ response.status,
12663
+ data.details
12588
12664
  );
12589
12665
  }
12590
12666
  } catch (e) {
@@ -12906,11 +12982,16 @@ var COMMAND_DEFINITIONS = [
12906
12982
  "entity-ids",
12907
12983
  "entity-stances",
12908
12984
  "tickers",
12909
- "visibility"
12985
+ "visibility",
12986
+ "track-return"
12910
12987
  ],
12911
12988
  booleans: ["body-stdin"]
12912
12989
  }),
12913
- command("thesis asset-candidates", { values: ["text"] }),
12990
+ command("thesis asset-candidates", {
12991
+ values: ["text", "entity-ids", "thesis-id"],
12992
+ booleans: ["no-discovery"]
12993
+ }),
12994
+ command("thesis return", { values: ["id"], booleans: ["detail"] }),
12914
12995
  command("thesis list", {
12915
12996
  values: [
12916
12997
  "person",
@@ -12926,9 +13007,6 @@ var COMMAND_DEFINITIONS = [
12926
13007
  command("thesis related", { values: ["id", "first", "cursor"] }),
12927
13008
  command("thesis get", { values: ["id"] }),
12928
13009
  command("thesis version list", { values: ["id", "first", "cursor"] }),
12929
- command("thesis version delete", {
12930
- values: ["id", "author-version-id", "expected-author-version-id"]
12931
- }),
12932
13010
  command("thesis version get", {
12933
13011
  values: ["id", "author-version-id"]
12934
13012
  }),
@@ -12950,14 +13028,11 @@ var COMMAND_DEFINITIONS = [
12950
13028
  "entity-ids",
12951
13029
  "entity-stances",
12952
13030
  "medias",
12953
- "visibility"
13031
+ "visibility",
13032
+ "track-return"
12954
13033
  ],
12955
- booleans: ["body-stdin", "editorial"]
12956
- }),
12957
- command("thesis close", {
12958
- values: ["id", "expected-author-version-id", "note"]
13034
+ booleans: ["body-stdin"]
12959
13035
  }),
12960
- command("thesis delete", { values: ["id"] }),
12961
13036
  command("thesis rewrite", {
12962
13037
  values: ["body", "body-file", "mode"],
12963
13038
  booleans: ["body-stdin"]
@@ -17644,7 +17719,7 @@ function formatTradingPairResolved(result) {
17644
17719
  }
17645
17720
 
17646
17721
  // src/cli/dispatch.ts
17647
- var CLI_VERSION = true ? "0.35.0" : "dev";
17722
+ var CLI_VERSION = true ? "0.36.0-beta.0" : "dev";
17648
17723
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
17649
17724
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
17650
17725
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -19118,7 +19193,7 @@ Examples:
19118
19193
  alva arrays token status`,
19119
19194
  thesis: `Usage: alva thesis <subcommand> [options]
19120
19195
 
19121
- Create, read, inspect Signals and exact author versions, update, close, delete, or explicitly rewrite an authored thesis.
19196
+ Create, read, inspect Signals and exact author versions, publish Updates to, or explicitly rewrite an authored thesis.
19122
19197
  Backend owns Signal/Alert setup; the CLI never starts them separately.
19123
19198
  Create and update never rewrite text automatically.
19124
19199
 
@@ -19129,7 +19204,6 @@ Subcommands:
19129
19204
  get Get one thesis
19130
19205
  version get Get one exact author version
19131
19206
  version list List visible Updates with editorial revisions folded together
19132
- version delete Delete one Update; restore prior content if it is current
19133
19207
  signals Read published Signal history
19134
19208
  set-visibility Change current access without publishing a version
19135
19209
  archive Archive the current author version
@@ -19137,9 +19211,7 @@ Subcommands:
19137
19211
  star Add the Thesis to your bookmarks
19138
19212
  unstar Remove the Thesis from your bookmarks
19139
19213
  set-signal-enabled Enable or disable managed Signal research
19140
- update Replaces document fields: body, title, entities, visibility (all sent in full)
19141
- close Close the current author version with an optional note
19142
- delete Delete a thesis
19214
+ update Publish a new Update replacing body, title, entities, visibility (all sent in full)
19143
19215
  rewrite Explicitly request a candidate body rewrite; never called by another command
19144
19216
 
19145
19217
  Body input (create, update, rewrite): choose exactly one:
@@ -19154,7 +19226,7 @@ the backend; do not send a fresh ID. Create defaults --visibility to public.
19154
19226
  Update requires --visibility explicitly so it cannot inadvertently publish.
19155
19227
 
19156
19228
  Other flags:
19157
- create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
19229
+ create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>] [--track-return true|false]
19158
19230
  Images: public creation only, at most 20 in display order. Upload selected files
19159
19231
  with the existing host upload tool after publication confirmation. Private
19160
19232
  images and local/ALFS paths are not supported; this flag does not upload.
@@ -19172,12 +19244,14 @@ Other flags:
19172
19244
  publication.playbookId is the ID for get/version/signals/related;
19173
19245
  publication=null means no readable snapshot. Author lists include the
19174
19246
  signed-in owner's private Theses (visibility private).
19175
- asset-candidates --text <unsaved thesis text>
19247
+ asset-candidates --text <unsaved thesis text> [--entity-ids <id,id>] [--thesis-id <id>] [--no-discovery]
19248
+ --no-discovery only classifies --entity-ids (no ticker discovery) and
19249
+ returns returnPreview: the directions publishing would store, the return
19250
+ switch (askSwitch) and lastLegRemoved. --thesis-id seeds an Update.
19251
+ return --id <id> [--detail] the Thesis return; --detail adds each Update's positions
19176
19252
  get --id <signed-int64-decimal>
19177
19253
  version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
19178
19254
  version list --id <id> [--first <1-100>] [--cursor <next_cursor>]
19179
- version delete --id <id> --author-version-id <selected> --expected-author-version-id <current>
19180
- Cannot remove the last Update. Never falls back to whole-Thesis deletion.
19181
19255
  signals --id <id> [--first <1-50>] [--cursor <opaque-cursor>]
19182
19256
  set-visibility --id <id> --visibility public|private
19183
19257
  archive --id <id> --request-id <uuid> [--note <text>]
@@ -19198,13 +19272,12 @@ Maintenance behavior:
19198
19272
  set-signal-enabled changes managed Signal research without deleting history.
19199
19273
  The command returns enabled, research_paused, archived, and author version
19200
19274
  state; GraphQL errors and noncanonical error codes fail closed.
19201
- update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--entity-stances <json>] [--medias <json-array>] [--editorial]
19275
+ update --id <id> --request-id <uuid> --expected-author-version-id <id> --body ... --visibility <value> [--title <text>] [--entity-ids <id,id>] [--entity-stances <json>] [--medias <json-array>] [--track-return true|false]
19202
19276
  For text edits, pass current medias unchanged; omission clears media.
19203
19277
 
19204
19278
  Only editing the body? Resubmit the existing entity IDs and directions.
19205
- Omitted directions become unknown; explicit unknown clears a direction.
19206
- close --id <id> --expected-author-version-id <id> [--note <text>]
19207
- delete --id <id>
19279
+ On an Update, an omitted or unknown direction of a carried ticker keeps its
19280
+ previous direction; none is an exit.
19208
19281
  rewrite --body ... [--mode reformat|shorten|enrich]
19209
19282
 
19210
19283
  Rewrite mode defaults only when omitted, and the toolkit always sends the
@@ -20096,6 +20169,17 @@ function thesisImages(flags) {
20096
20169
  "thesis"
20097
20170
  );
20098
20171
  }
20172
+ function thesisTrackReturn(flags, command2) {
20173
+ const raw = flags["track-return"];
20174
+ if (raw === void 0) return void 0;
20175
+ const parsed = boolFlag(raw);
20176
+ if (parsed === void 0)
20177
+ throw new CliUsageError(
20178
+ `--track-return must be true or false for ${command2}`,
20179
+ "thesis"
20180
+ );
20181
+ return parsed;
20182
+ }
20099
20183
  function thesisEntityStances(flags) {
20100
20184
  const raw = flags["entity-stances"];
20101
20185
  if (raw === void 0) return void 0;
@@ -20774,11 +20858,22 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
20774
20858
  entity_ids: thesisEntityIDs(flags),
20775
20859
  entity_stances: thesisEntityStances(flags),
20776
20860
  tickers: thesisTickers(flags),
20777
- visibility: flags.visibility === void 0 ? "public" : thesisCreateVisibility(flags.visibility)
20861
+ visibility: flags.visibility === void 0 ? "public" : thesisCreateVisibility(flags.visibility),
20862
+ track_return: thesisTrackReturn(flags, "thesis create")
20778
20863
  });
20779
20864
  case "asset-candidates":
20780
20865
  return client.theses.assetCandidates(
20781
- requireFlag(flags, "text", "thesis asset-candidates")
20866
+ requireFlag(flags, "text", "thesis asset-candidates"),
20867
+ {
20868
+ entityIds: thesisEntityIDs(flags),
20869
+ thesisId: flags["thesis-id"],
20870
+ discover: boolFlag(flags["no-discovery"]) !== true
20871
+ }
20872
+ );
20873
+ case "return":
20874
+ return client.theses.thesisReturn(
20875
+ requireFlag(flags, "id", "thesis return"),
20876
+ { detail: boolFlag(flags.detail) === true }
20782
20877
  );
20783
20878
  case "list": {
20784
20879
  const params = {
@@ -20825,17 +20920,6 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
20825
20920
  }
20826
20921
  );
20827
20922
  }
20828
- if (parsedCommand.path[2] === "delete") {
20829
- return client.theses.deleteUpdate(
20830
- requireFlag(flags, "id", "thesis version delete"),
20831
- requireFlag(flags, "author-version-id", "thesis version delete"),
20832
- requireFlag(
20833
- flags,
20834
- "expected-author-version-id",
20835
- "thesis version delete"
20836
- )
20837
- );
20838
- }
20839
20923
  return client.theses.getVersion(
20840
20924
  requireFlag(flags, "id", "thesis version get"),
20841
20925
  requireFlag(flags, "author-version-id", "thesis version get")
@@ -20908,22 +20992,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
20908
20992
  visibility: thesisVisibility(
20909
20993
  requireFlag(flags, "visibility", "thesis update")
20910
20994
  ),
20911
- editorial: boolFlag(flags.editorial) ?? false
20995
+ track_return: thesisTrackReturn(flags, "thesis update")
20912
20996
  }
20913
20997
  );
20914
- case "close":
20915
- return client.theses.close(requireFlag(flags, "id", "thesis close"), {
20916
- expected_author_version_id: requireFlag(
20917
- flags,
20918
- "expected-author-version-id",
20919
- "thesis close"
20920
- ),
20921
- note: flags.note
20922
- });
20923
- case "delete":
20924
- return client.theses.delete(
20925
- requireFlag(flags, "id", "thesis delete")
20926
- );
20927
20998
  case "rewrite":
20928
20999
  return client.theses.rewrite({
20929
21000
  body: await thesisBodyFromFlags(flags, "thesis rewrite", deps),