@alva-ai/toolkit 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/browser.global.js +63 -24
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +137 -1
- package/dist/cli.js +377 -40
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +137 -1
- package/dist/dispatch.js +174 -17
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +294 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -2
- package/dist/index.d.ts +138 -2
- package/dist/index.js +294 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6707,6 +6707,166 @@ function connection(value) {
|
|
|
6707
6707
|
return invalidResponse();
|
|
6708
6708
|
return value;
|
|
6709
6709
|
}
|
|
6710
|
+
var THESIS_RECOMMENDATION_QUERY = `
|
|
6711
|
+
query ToolkitForYouTheses($input: ThesisRecommendationInput) {
|
|
6712
|
+
viewer {
|
|
6713
|
+
thesisRecommendations(input: $input) {
|
|
6714
|
+
listId pageCursor nextCursor exhausted scanLimited
|
|
6715
|
+
pageInfo { startCursor endCursor hasNextPage hasPreviousPage }
|
|
6716
|
+
edges {
|
|
6717
|
+
cursor
|
|
6718
|
+
node {
|
|
6719
|
+
itemKey
|
|
6720
|
+
publication {
|
|
6721
|
+
thesisId playbookId authorVersionId materialVersionId itemKey
|
|
6722
|
+
title body publishedAtMs changeKind visibility
|
|
6723
|
+
closed archived note closingNote researchPaused
|
|
6724
|
+
entityIds categoryIds
|
|
6725
|
+
entityStances { entityId stance }
|
|
6726
|
+
entities { id ticker name }
|
|
6727
|
+
publisher {
|
|
6728
|
+
id displayName avatarUrl bio followersCount
|
|
6729
|
+
viewerState { following }
|
|
6730
|
+
}
|
|
6731
|
+
medias { type coverUrl url }
|
|
6732
|
+
signalFeed { id }
|
|
6733
|
+
snapshotRelease {
|
|
6734
|
+
versionId materialVersionId publishedAtMs changeKind
|
|
6735
|
+
sourceRefs {
|
|
6736
|
+
title sourceKind sourceContentId publicUrl sourceTimeMs locator
|
|
6737
|
+
}
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
`.trim();
|
|
6746
|
+
function validateForYouThesesParams(params) {
|
|
6747
|
+
if (!record(params)) throw new Error("Thesis parameters must be an object");
|
|
6748
|
+
const first = params.first === void 0 ? 10 : params.first;
|
|
6749
|
+
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 10) {
|
|
6750
|
+
throw new Error("first must be an integer between 1 and 10");
|
|
6751
|
+
}
|
|
6752
|
+
if (params.after !== void 0 && (typeof params.after !== "string" || !params.after.trim())) {
|
|
6753
|
+
throw new Error("after must be a non-empty cursor");
|
|
6754
|
+
}
|
|
6755
|
+
}
|
|
6756
|
+
function graphqlViewerField(response, field) {
|
|
6757
|
+
if (!record(response)) {
|
|
6758
|
+
throw new AlvaError(
|
|
6759
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
6760
|
+
`GraphQL returned an invalid viewer.${field} response`,
|
|
6761
|
+
502
|
|
6762
|
+
);
|
|
6763
|
+
}
|
|
6764
|
+
if (response.errors !== void 0) {
|
|
6765
|
+
if (!Array.isArray(response.errors)) {
|
|
6766
|
+
throw new AlvaError(
|
|
6767
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
6768
|
+
`GraphQL returned an invalid viewer.${field} response`,
|
|
6769
|
+
502
|
|
6770
|
+
);
|
|
6771
|
+
}
|
|
6772
|
+
if (response.errors.length > 0) {
|
|
6773
|
+
const messages = response.errors.flatMap(
|
|
6774
|
+
(error) => record(error) && typeof error.message === "string" ? [error.message] : []
|
|
6775
|
+
);
|
|
6776
|
+
throw new AlvaError(
|
|
6777
|
+
"GRAPHQL_ERROR",
|
|
6778
|
+
messages.join("; ") || "GraphQL request failed",
|
|
6779
|
+
400,
|
|
6780
|
+
{ errors: response.errors }
|
|
6781
|
+
);
|
|
6782
|
+
}
|
|
6783
|
+
}
|
|
6784
|
+
if (!record(response.data) || !record(response.data.viewer) || response.data.viewer[field] == null) {
|
|
6785
|
+
throw new AlvaError(
|
|
6786
|
+
"GRAPHQL_EMPTY_RESPONSE",
|
|
6787
|
+
`GraphQL response did not include viewer.${field}`,
|
|
6788
|
+
502
|
|
6789
|
+
);
|
|
6790
|
+
}
|
|
6791
|
+
return response.data.viewer[field];
|
|
6792
|
+
}
|
|
6793
|
+
function invalidPage() {
|
|
6794
|
+
throw new AlvaError(
|
|
6795
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
6796
|
+
"GraphQL returned an invalid Thesis recommendation page",
|
|
6797
|
+
502
|
|
6798
|
+
);
|
|
6799
|
+
}
|
|
6800
|
+
function positiveInt64List(value) {
|
|
6801
|
+
return Array.isArray(value) && value.every(isPositiveInt64);
|
|
6802
|
+
}
|
|
6803
|
+
function stanceList(value) {
|
|
6804
|
+
return Array.isArray(value) && value.every(
|
|
6805
|
+
(item) => record(item) && isPositiveInt64(item.entityId) && typeof item.stance === "string" && item.stance.trim() !== ""
|
|
6806
|
+
);
|
|
6807
|
+
}
|
|
6808
|
+
function entityList(value) {
|
|
6809
|
+
return Array.isArray(value) && value.every(
|
|
6810
|
+
(item) => record(item) && typeof item.id === "string" && item.id.trim() !== "" && typeof item.ticker === "string" && typeof item.name === "string"
|
|
6811
|
+
);
|
|
6812
|
+
}
|
|
6813
|
+
function mediaList(value) {
|
|
6814
|
+
return Array.isArray(value) && value.every(
|
|
6815
|
+
(item) => record(item) && typeof item.type === "string" && item.type.trim() !== "" && typeof item.coverUrl === "string" && (item.url === null || typeof item.url === "string")
|
|
6816
|
+
);
|
|
6817
|
+
}
|
|
6818
|
+
function sourceRefList(value) {
|
|
6819
|
+
return Array.isArray(value) && value.every(
|
|
6820
|
+
(item) => record(item) && (item.title === null || typeof item.title === "string") && typeof item.sourceKind === "string" && typeof item.sourceContentId === "string" && typeof item.publicUrl === "string" && nullableMs(item.sourceTimeMs) && typeof item.locator === "string"
|
|
6821
|
+
);
|
|
6822
|
+
}
|
|
6823
|
+
function nullableMs(value) {
|
|
6824
|
+
return value === null || typeof value === "number" && Number.isFinite(value);
|
|
6825
|
+
}
|
|
6826
|
+
function snapshot(value) {
|
|
6827
|
+
return record(value) && isPositiveInt64(value.versionId) && isPositiveInt64(value.materialVersionId) && typeof value.publishedAtMs === "number" && Number.isFinite(value.publishedAtMs) && typeof value.changeKind === "string" && value.changeKind.trim() !== "" && sourceRefList(value.sourceRefs);
|
|
6828
|
+
}
|
|
6829
|
+
function publisher(value) {
|
|
6830
|
+
return record(value) && typeof value.id === "string" && value.id.trim() !== "" && typeof value.displayName === "string" && typeof value.avatarUrl === "string" && typeof value.bio === "string" && typeof value.followersCount === "number" && Number.isInteger(value.followersCount) && record(value.viewerState) && (value.viewerState.following === null || typeof value.viewerState.following === "boolean");
|
|
6831
|
+
}
|
|
6832
|
+
function publication(value) {
|
|
6833
|
+
if (!record(value)) return false;
|
|
6834
|
+
for (const field of [
|
|
6835
|
+
"thesisId",
|
|
6836
|
+
"playbookId",
|
|
6837
|
+
"authorVersionId",
|
|
6838
|
+
"materialVersionId"
|
|
6839
|
+
]) {
|
|
6840
|
+
if (!isPositiveInt64(value[field])) return false;
|
|
6841
|
+
}
|
|
6842
|
+
if (typeof value.itemKey !== "string" || !value.itemKey.trim() || typeof value.title !== "string" || typeof value.body !== "string" || typeof value.publishedAtMs !== "number" || !Number.isFinite(value.publishedAtMs) || typeof value.changeKind !== "string" || !value.changeKind.trim() || typeof value.visibility !== "string" || typeof value.note !== "string" || typeof value.closingNote !== "string") {
|
|
6843
|
+
return false;
|
|
6844
|
+
}
|
|
6845
|
+
for (const field of ["closed", "archived", "researchPaused"]) {
|
|
6846
|
+
if (typeof value[field] !== "boolean") return false;
|
|
6847
|
+
}
|
|
6848
|
+
if (!positiveInt64List(value.entityIds) || !positiveInt64List(value.categoryIds) || !stanceList(value.entityStances) || !entityList(value.entities) || !mediaList(value.medias) || !publisher(value.publisher) || !snapshot(value.snapshotRelease)) {
|
|
6849
|
+
return false;
|
|
6850
|
+
}
|
|
6851
|
+
return value.signalFeed === null || record(value.signalFeed) && isPositiveInt64(value.signalFeed.id);
|
|
6852
|
+
}
|
|
6853
|
+
function recommendationPage(value) {
|
|
6854
|
+
if (!record(value) || !Array.isArray(value.edges) || !record(value.pageInfo) || typeof value.listId !== "string" || typeof value.pageCursor !== "string" || typeof value.exhausted !== "boolean" || typeof value.scanLimited !== "boolean" || value.nextCursor !== null && typeof value.nextCursor !== "string") {
|
|
6855
|
+
return invalidPage();
|
|
6856
|
+
}
|
|
6857
|
+
const page = value.pageInfo;
|
|
6858
|
+
if (typeof page.startCursor !== "string" || typeof page.endCursor !== "string" || typeof page.hasNextPage !== "boolean" || typeof page.hasPreviousPage !== "boolean" || page.hasNextPage !== (value.nextCursor !== null)) {
|
|
6859
|
+
return invalidPage();
|
|
6860
|
+
}
|
|
6861
|
+
for (const edge of value.edges) {
|
|
6862
|
+
if (!record(edge) || typeof edge.cursor !== "string" || !edge.cursor.trim() || !record(edge.node) || typeof edge.node.itemKey !== "string" || !edge.node.itemKey.trim() || !publication(edge.node.publication)) {
|
|
6863
|
+
return invalidPage();
|
|
6864
|
+
}
|
|
6865
|
+
}
|
|
6866
|
+
const first = value.edges[0];
|
|
6867
|
+
if (page.startCursor !== (first?.cursor ?? "")) return invalidPage();
|
|
6868
|
+
return value;
|
|
6869
|
+
}
|
|
6710
6870
|
var ForYouResource = class {
|
|
6711
6871
|
constructor(client) {
|
|
6712
6872
|
this.client = client;
|
|
@@ -6729,29 +6889,29 @@ var ForYouResource = class {
|
|
|
6729
6889
|
}
|
|
6730
6890
|
}
|
|
6731
6891
|
});
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6892
|
+
return connection(graphqlViewerField(response, "forYou"));
|
|
6893
|
+
}
|
|
6894
|
+
/**
|
|
6895
|
+
* One ranked page of Thesis recommendations -- the stream the Feed App reads,
|
|
6896
|
+
* which is not the chronological `list` stream. Page to `exhausted` and filter
|
|
6897
|
+
* on `publication.publishedAtMs` yourself; the order is slot-mixed, so a time
|
|
6898
|
+
* bound is never a reason to stop paging. Publications the viewer already saw
|
|
6899
|
+
* are withheld by an upstream cooldown, so a window read is "recommended and
|
|
6900
|
+
* recent", not every publication in the window.
|
|
6901
|
+
*/
|
|
6902
|
+
async theses(params = {}) {
|
|
6903
|
+
validateForYouThesesParams(params);
|
|
6904
|
+
this.client._requireAuth();
|
|
6905
|
+
const response = await this.client._request("POST", "/query", {
|
|
6906
|
+
body: {
|
|
6907
|
+
query: THESIS_RECOMMENDATION_QUERY,
|
|
6908
|
+
variables: {
|
|
6909
|
+
input: { first: params.first ?? 10, after: params.after }
|
|
6910
|
+
}
|
|
6745
6911
|
}
|
|
6746
|
-
}
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
"GRAPHQL_EMPTY_RESPONSE",
|
|
6750
|
-
"GraphQL response did not include viewer.forYou",
|
|
6751
|
-
502
|
|
6752
|
-
);
|
|
6753
|
-
}
|
|
6754
|
-
return connection(response.data.viewer.forYou);
|
|
6912
|
+
});
|
|
6913
|
+
const field = graphqlViewerField(response, "thesisRecommendations");
|
|
6914
|
+
return recommendationPage(field);
|
|
6755
6915
|
}
|
|
6756
6916
|
};
|
|
6757
6917
|
|
|
@@ -9669,9 +9829,7 @@ function requireDeliveryId(value, label = "delivery id") {
|
|
|
9669
9829
|
throw invalid2(`${label} must be a positive integer`);
|
|
9670
9830
|
return value;
|
|
9671
9831
|
}
|
|
9672
|
-
function
|
|
9673
|
-
if (values.length === 0)
|
|
9674
|
-
throw invalid2("at least one delivery id is required");
|
|
9832
|
+
function normalizeDeliveryIds(values) {
|
|
9675
9833
|
const unique = /* @__PURE__ */ new Set();
|
|
9676
9834
|
for (const value of values) {
|
|
9677
9835
|
requireDeliveryId(value);
|
|
@@ -9680,6 +9838,11 @@ function requireDeliveryIds(values) {
|
|
|
9680
9838
|
}
|
|
9681
9839
|
return [...unique];
|
|
9682
9840
|
}
|
|
9841
|
+
function requireDeliveryIds(values) {
|
|
9842
|
+
if (values.length === 0)
|
|
9843
|
+
throw invalid2("at least one delivery id is required");
|
|
9844
|
+
return normalizeDeliveryIds(values);
|
|
9845
|
+
}
|
|
9683
9846
|
function requireDecision(value) {
|
|
9684
9847
|
if (!DECISIONS.has(value))
|
|
9685
9848
|
throw invalid2("decision must be one of immediate, digest, suppress");
|
|
@@ -9762,7 +9925,10 @@ var StewardResource = class {
|
|
|
9762
9925
|
inboxPath: requireInboxPath(params),
|
|
9763
9926
|
requestId: requireRequestId(params.requestId),
|
|
9764
9927
|
body: params.body,
|
|
9765
|
-
|
|
9928
|
+
// A For-You-only Brief covers no ledger delivery, so an empty (or
|
|
9929
|
+
// omitted) set is valid here; the backend accepts it. `briefed` still
|
|
9930
|
+
// requires ids.
|
|
9931
|
+
deliveryIds: normalizeDeliveryIds(params.deliveryIds ?? [])
|
|
9766
9932
|
}
|
|
9767
9933
|
});
|
|
9768
9934
|
const message = data.postStewardMessage?.message;
|
|
@@ -10036,6 +10202,56 @@ var ThesesResource = class {
|
|
|
10036
10202
|
this.client = client;
|
|
10037
10203
|
}
|
|
10038
10204
|
client;
|
|
10205
|
+
async assetCandidates(text) {
|
|
10206
|
+
this.client._requireAuth();
|
|
10207
|
+
const source = requireBody(text);
|
|
10208
|
+
const response = await this.client._request("POST", "/query", {
|
|
10209
|
+
body: {
|
|
10210
|
+
query: `query ThesisAssetCandidates($input: ThesisAssetCandidatesInput!) {
|
|
10211
|
+
viewer { thesisAssetCandidates(input: $input) {
|
|
10212
|
+
mentions { quote ticker resolution stance candidates { entityId ticker name kind } }
|
|
10213
|
+
} }
|
|
10214
|
+
}`,
|
|
10215
|
+
variables: { input: { text: source } }
|
|
10216
|
+
}
|
|
10217
|
+
});
|
|
10218
|
+
if (Array.isArray(response?.errors) && response.errors.length > 0) {
|
|
10219
|
+
throw new AlvaError("GRAPHQL_ERROR", "Asset extraction failed", 400, {
|
|
10220
|
+
errors: response.errors
|
|
10221
|
+
});
|
|
10222
|
+
}
|
|
10223
|
+
const data = response?.data;
|
|
10224
|
+
const viewer = isRecord2(data) ? data.viewer : void 0;
|
|
10225
|
+
const result = isRecord2(viewer) ? viewer.thesisAssetCandidates : void 0;
|
|
10226
|
+
if (!isRecord2(result) || !Array.isArray(result.mentions)) {
|
|
10227
|
+
throw invalidResponse2("asset candidates response must contain mentions");
|
|
10228
|
+
}
|
|
10229
|
+
const mentions = result.mentions.map((item, index) => {
|
|
10230
|
+
if (!isRecord2(item) || typeof item.quote !== "string" || typeof item.ticker !== "string" || !["RESOLVED", "AMBIGUOUS", "UNRESOLVED"].includes(
|
|
10231
|
+
item.resolution
|
|
10232
|
+
) || !["UNKNOWN", "BULLISH", "BEARISH"].includes(item.stance) || !Array.isArray(item.candidates)) {
|
|
10233
|
+
throw invalidResponse2(`asset mention ${index} is invalid`);
|
|
10234
|
+
}
|
|
10235
|
+
const candidates = item.candidates.map((candidate) => {
|
|
10236
|
+
if (!isRecord2(candidate) || typeof candidate.ticker !== "string" || typeof candidate.name !== "string" || !["STOCK", "ETF", "CRYPTO", "INDEX"].includes(
|
|
10237
|
+
candidate.kind
|
|
10238
|
+
)) {
|
|
10239
|
+
throw invalidResponse2(`asset mention ${index} has invalid candidate`);
|
|
10240
|
+
}
|
|
10241
|
+
return {
|
|
10242
|
+
entityId: responseID(
|
|
10243
|
+
candidate.entityId,
|
|
10244
|
+
`asset mention ${index} candidate.entityId`
|
|
10245
|
+
),
|
|
10246
|
+
ticker: candidate.ticker,
|
|
10247
|
+
name: candidate.name,
|
|
10248
|
+
kind: candidate.kind
|
|
10249
|
+
};
|
|
10250
|
+
});
|
|
10251
|
+
return { ...item, candidates };
|
|
10252
|
+
});
|
|
10253
|
+
return { mentions };
|
|
10254
|
+
}
|
|
10039
10255
|
async create(params) {
|
|
10040
10256
|
this.client._requireAuth();
|
|
10041
10257
|
const body = createBody(params);
|
|
@@ -10180,8 +10396,36 @@ function createBody(params) {
|
|
|
10180
10396
|
};
|
|
10181
10397
|
if (params.tickers !== void 0)
|
|
10182
10398
|
body.tickers = requireTickers(params.tickers);
|
|
10399
|
+
if (params.entity_stances !== void 0) {
|
|
10400
|
+
body.entity_stances = requireEntityStances(
|
|
10401
|
+
params.entity_stances,
|
|
10402
|
+
body.entity_ids
|
|
10403
|
+
);
|
|
10404
|
+
}
|
|
10183
10405
|
return body;
|
|
10184
10406
|
}
|
|
10407
|
+
function requireEntityStances(value, entityIDs) {
|
|
10408
|
+
if (!Array.isArray(value) || value.length > MAX_ENTITY_IDS)
|
|
10409
|
+
throw invalidArgument("entity_stances must contain at most 100 values");
|
|
10410
|
+
const allowed = new Set(entityIDs);
|
|
10411
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10412
|
+
return value.map((item, index) => {
|
|
10413
|
+
if (!isRecord2(item))
|
|
10414
|
+
throw invalidArgument(`entity_stances[${index}] must be an object`);
|
|
10415
|
+
const entityID = requireID(
|
|
10416
|
+
item.entity_id,
|
|
10417
|
+
`entity_stances[${index}].entity_id`
|
|
10418
|
+
);
|
|
10419
|
+
if (!allowed.has(entityID) || seen.has(entityID))
|
|
10420
|
+
throw invalidArgument(
|
|
10421
|
+
"entity stance must reference one unique entity_id"
|
|
10422
|
+
);
|
|
10423
|
+
seen.add(entityID);
|
|
10424
|
+
if (!["unknown", "bullish", "bearish"].includes(item.stance))
|
|
10425
|
+
throw invalidArgument(`entity_stances[${index}].stance is invalid`);
|
|
10426
|
+
return { entity_id: entityID, stance: item.stance };
|
|
10427
|
+
});
|
|
10428
|
+
}
|
|
10185
10429
|
function updateBody(params) {
|
|
10186
10430
|
return {
|
|
10187
10431
|
request_id: requireRequestID(params.request_id),
|
|
@@ -10220,6 +10464,20 @@ function thesisResponse(response) {
|
|
|
10220
10464
|
author_kind: responseText(thesis.author_kind, "thesis.author_kind"),
|
|
10221
10465
|
author_ref: responseText(thesis.author_ref, "thesis.author_ref")
|
|
10222
10466
|
};
|
|
10467
|
+
if (thesis.entity_stances !== void 0) {
|
|
10468
|
+
if (!Array.isArray(thesis.entity_stances))
|
|
10469
|
+
throw invalidResponse2("thesis.entity_stances must be an array");
|
|
10470
|
+
value.entity_stances = thesis.entity_stances.map((item) => {
|
|
10471
|
+
if (!isRecord2(item))
|
|
10472
|
+
throw invalidResponse2("thesis.entity_stances contains invalid entry");
|
|
10473
|
+
const entityID = responseID(item.entity_id, "entity_stances.entity_id");
|
|
10474
|
+
if (!value.entity_ids.includes(entityID))
|
|
10475
|
+
throw invalidResponse2("entity stance must reference a thesis entity");
|
|
10476
|
+
if (!["unknown", "bullish", "bearish"].includes(item.stance))
|
|
10477
|
+
throw invalidResponse2("thesis.entity_stances contains invalid stance");
|
|
10478
|
+
return { entity_id: entityID, stance: item.stance };
|
|
10479
|
+
});
|
|
10480
|
+
}
|
|
10223
10481
|
return { thesis: value };
|
|
10224
10482
|
}
|
|
10225
10483
|
function thesisGetResponse(response) {
|
|
@@ -10383,10 +10641,13 @@ function requireID(value, field) {
|
|
|
10383
10641
|
}
|
|
10384
10642
|
return value;
|
|
10385
10643
|
}
|
|
10644
|
+
var MAX_ENTITY_IDS = 100;
|
|
10386
10645
|
function requireIDs(value, field) {
|
|
10387
10646
|
if (!Array.isArray(value)) throw invalidArgument(`${field} must be an array`);
|
|
10388
|
-
if (value.length >
|
|
10389
|
-
throw invalidArgument(
|
|
10647
|
+
if (value.length > MAX_ENTITY_IDS) {
|
|
10648
|
+
throw invalidArgument(
|
|
10649
|
+
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
10650
|
+
);
|
|
10390
10651
|
}
|
|
10391
10652
|
return value.map((item, index) => requireID(item, `${field}[${index}]`));
|
|
10392
10653
|
}
|
|
@@ -10457,8 +10718,10 @@ function responseID(value, field) {
|
|
|
10457
10718
|
}
|
|
10458
10719
|
function responseIDs(value, field) {
|
|
10459
10720
|
if (!Array.isArray(value)) throw invalidResponse2(`${field} must be an array`);
|
|
10460
|
-
if (value.length >
|
|
10461
|
-
throw invalidResponse2(
|
|
10721
|
+
if (value.length > MAX_ENTITY_IDS) {
|
|
10722
|
+
throw invalidResponse2(
|
|
10723
|
+
`${field} must contain at most ${MAX_ENTITY_IDS} IDs`
|
|
10724
|
+
);
|
|
10462
10725
|
}
|
|
10463
10726
|
return value.map((item, index) => responseID(item, `${field}[${index}]`));
|
|
10464
10727
|
}
|
|
@@ -11203,11 +11466,13 @@ var COMMAND_DEFINITIONS = [
|
|
|
11203
11466
|
"body-file",
|
|
11204
11467
|
"title",
|
|
11205
11468
|
"entity-ids",
|
|
11469
|
+
"entity-stances",
|
|
11206
11470
|
"tickers",
|
|
11207
11471
|
"visibility"
|
|
11208
11472
|
],
|
|
11209
11473
|
booleans: ["body-stdin"]
|
|
11210
11474
|
}),
|
|
11475
|
+
command("thesis asset-candidates", { values: ["text"] }),
|
|
11211
11476
|
command("thesis get", { values: ["id"] }),
|
|
11212
11477
|
command("thesis version get", {
|
|
11213
11478
|
values: ["id", "author-version-id"]
|
|
@@ -11294,6 +11559,7 @@ var COMMAND_DEFINITIONS = [
|
|
|
11294
11559
|
command("for-you list", {
|
|
11295
11560
|
values: ["limit", "cursor", "newer-than", "feed-id"]
|
|
11296
11561
|
}),
|
|
11562
|
+
command("for-you theses", { values: ["limit", "cursor"] }),
|
|
11297
11563
|
command("credits items", {
|
|
11298
11564
|
values: ["last", "start", "end", "session-id", "first", "after"],
|
|
11299
11565
|
booleans: ["today"]
|
|
@@ -15903,7 +16169,7 @@ function formatTradingPairResolved(result) {
|
|
|
15903
16169
|
}
|
|
15904
16170
|
|
|
15905
16171
|
// src/cli/dispatch.ts
|
|
15906
|
-
var CLI_VERSION = true ? "0.
|
|
16172
|
+
var CLI_VERSION = true ? "0.31.0" : "dev";
|
|
15907
16173
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
15908
16174
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
15909
16175
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -16010,7 +16276,7 @@ Subcommands:
|
|
|
16010
16276
|
Flags:
|
|
16011
16277
|
--inbox-path <path> Steward Session Inbox (terminal CLI only)
|
|
16012
16278
|
--delivery-id <id> One delivery (decide, forward)
|
|
16013
|
-
--delivery-ids <a,b,c> Comma-separated deliveries (send
|
|
16279
|
+
--delivery-ids <a,b,c> Comma-separated deliveries (briefed; optional for send \u2014 omit for a For-You-only Brief)
|
|
16014
16280
|
--decision <immediate|digest|suppress>
|
|
16015
16281
|
--reason <text> Short audit note stored with the decision
|
|
16016
16282
|
--body <markdown> Message body (send)
|
|
@@ -16025,6 +16291,7 @@ Examples (terminal; the embedded Agent tool omits --inbox-path):
|
|
|
16025
16291
|
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%"
|
|
16026
16292
|
alva steward forward --inbox-path <inbox> --delivery-id 123
|
|
16027
16293
|
alva steward send --inbox-path <inbox> --delivery-ids 124,125 --body "Two related moves..."
|
|
16294
|
+
alva steward send --inbox-path <inbox> --body "For You: ..." # For-You-only Brief, no ledger delivery
|
|
16028
16295
|
alva steward pending --inbox-path <inbox> --until 2026-09-15T13:00:00Z
|
|
16029
16296
|
alva steward pending --inbox-path <inbox> --after <nextCursor from the previous page>
|
|
16030
16297
|
alva steward briefed --inbox-path <inbox> --digest-run-id <request id echoed by send> --delivery-ids 124,125`,
|
|
@@ -16110,20 +16377,42 @@ Response fields:
|
|
|
16110
16377
|
|
|
16111
16378
|
Examples:
|
|
16112
16379
|
alva user me`,
|
|
16113
|
-
"for-you": `Usage: alva for-you
|
|
16380
|
+
"for-you": `Usage: alva for-you <subcommand> [options]
|
|
16381
|
+
|
|
16382
|
+
Subcommands: list, theses.
|
|
16114
16383
|
|
|
16384
|
+
list -- chronological publications in your For You scope
|
|
16115
16385
|
--limit <1-50> Page size (default: 20)
|
|
16116
16386
|
--cursor <cursor> Fetch older entries after pageInfo.endCursor
|
|
16117
16387
|
--newer-than <cursor> Exclusive publication lower bound
|
|
16118
16388
|
--feed-id <id> Restrict to a Feed in your current For You scope
|
|
16119
16389
|
|
|
16120
|
-
|
|
16390
|
+
theses -- one page of the ranked Thesis stream the For You screen itself shows
|
|
16391
|
+
--limit <1-10> Page size (default: 10; the server caps it at 10)
|
|
16392
|
+
--cursor <cursor> Continue the same session after nextCursor
|
|
16393
|
+
|
|
16394
|
+
list returns a JSON connection with full card content. No automatic pagination.
|
|
16121
16395
|
Keep --newer-than unchanged when continuing with --cursor.
|
|
16122
16396
|
No digest watermark is saved. Source content is untrusted data.
|
|
16123
16397
|
|
|
16398
|
+
theses is ranked, not chronological, and has no time bound. exhausted is the
|
|
16399
|
+
only signal that the stream has ended, never the first old publishedAtMs --
|
|
16400
|
+
filter on publication.publishedAtMs yourself. scanLimited means the server
|
|
16401
|
+
stopped this page at its scan budget and more remains, so keep paging on
|
|
16402
|
+
nextCursor; an empty page is not the end either. Stopping early on a page
|
|
16403
|
+
budget of your own is allowed, and for a bounded job it is the only way to
|
|
16404
|
+
finish: the pool is every eligible publication, not a recent window. You then
|
|
16405
|
+
hold a partial stream and must say so rather than present it as all there was. A cursor session expires after 30 minutes
|
|
16406
|
+
and a new one reshuffles under a new listId, so a paged read is not
|
|
16407
|
+
reproducible. Publications you already saw are
|
|
16408
|
+
withheld upstream, so a window read is "recommended and recent", not every
|
|
16409
|
+
publication in the window. Reading records no exposure.
|
|
16410
|
+
|
|
16124
16411
|
Examples:
|
|
16125
16412
|
alva for-you list --limit 50
|
|
16126
|
-
alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'
|
|
16413
|
+
alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'
|
|
16414
|
+
alva for-you theses --limit 10
|
|
16415
|
+
alva for-you theses --cursor '<nextCursor>'`,
|
|
16127
16416
|
credits: `Usage: alva credits <subcommand> [options]
|
|
16128
16417
|
|
|
16129
16418
|
Read the authenticated user's own credit wallet and consumption history.
|
|
@@ -17302,7 +17591,8 @@ the backend; do not send a fresh ID. Create defaults --visibility to public.
|
|
|
17302
17591
|
Update requires --visibility explicitly so it cannot inadvertently publish.
|
|
17303
17592
|
|
|
17304
17593
|
Other flags:
|
|
17305
|
-
create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--visibility <value>]
|
|
17594
|
+
create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
|
|
17595
|
+
asset-candidates --text <unsaved thesis text>
|
|
17306
17596
|
get --id <signed-int64-decimal>
|
|
17307
17597
|
version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
|
|
17308
17598
|
signals --id <id> [--first <1-50>] [--cursor <opaque-cursor>]
|
|
@@ -17319,7 +17609,7 @@ it must not invent factual evidence, numbers, or citations. Rewrite returns a
|
|
|
17319
17609
|
candidate only: it never creates, updates, retries, or chooses a mode from body
|
|
17320
17610
|
length or errors.
|
|
17321
17611
|
|
|
17322
|
-
IDs are decimal strings, never JavaScript numbers; provide at most
|
|
17612
|
+
IDs are decimal strings, never JavaScript numbers; provide at most 100 entity
|
|
17323
17613
|
IDs. Body text must be nonblank,
|
|
17324
17614
|
valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
|
|
17325
17615
|
500 UTF-8 bytes. Text is passed without trimming or newline conversion.
|
|
@@ -18021,6 +18311,19 @@ function thesisTickers(flags) {
|
|
|
18021
18311
|
}
|
|
18022
18312
|
return tickers;
|
|
18023
18313
|
}
|
|
18314
|
+
function thesisEntityStances(flags) {
|
|
18315
|
+
const raw = flags["entity-stances"];
|
|
18316
|
+
if (raw === void 0) return void 0;
|
|
18317
|
+
let parsed;
|
|
18318
|
+
try {
|
|
18319
|
+
parsed = JSON.parse(raw);
|
|
18320
|
+
} catch {
|
|
18321
|
+
throw new CliUsageError("--entity-stances must be a JSON array", "thesis");
|
|
18322
|
+
}
|
|
18323
|
+
if (!Array.isArray(parsed))
|
|
18324
|
+
throw new CliUsageError("--entity-stances must be a JSON array", "thesis");
|
|
18325
|
+
return parsed;
|
|
18326
|
+
}
|
|
18024
18327
|
function strictThesisUTF8(value, command2, flag) {
|
|
18025
18328
|
const bytes = toByteView(value);
|
|
18026
18329
|
if (bytes === void 0) {
|
|
@@ -18553,7 +18856,12 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18553
18856
|
"inbox-path",
|
|
18554
18857
|
`steward ${subcommand}`
|
|
18555
18858
|
);
|
|
18556
|
-
const
|
|
18859
|
+
const splitIds = (raw) => raw.split(",").map((value) => value.trim()).filter((value) => value !== "");
|
|
18860
|
+
const ids = (name) => splitIds(requireFlag(flags, name, `steward ${subcommand}`));
|
|
18861
|
+
const optionalIds = (name) => {
|
|
18862
|
+
const raw = flags[name];
|
|
18863
|
+
return raw === void 0 ? [] : splitIds(raw);
|
|
18864
|
+
};
|
|
18557
18865
|
switch (subcommand) {
|
|
18558
18866
|
case "decide":
|
|
18559
18867
|
return client.steward.decide({
|
|
@@ -18574,7 +18882,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18574
18882
|
return client.steward.send({
|
|
18575
18883
|
inboxPath,
|
|
18576
18884
|
body: requireFlag(flags, "body", "steward send"),
|
|
18577
|
-
deliveryIds:
|
|
18885
|
+
deliveryIds: optionalIds("delivery-ids"),
|
|
18578
18886
|
requestId: flags["request-id"]
|
|
18579
18887
|
});
|
|
18580
18888
|
case "pending": {
|
|
@@ -18623,9 +18931,14 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18623
18931
|
body: await thesisBodyFromFlags(flags, "thesis create", deps),
|
|
18624
18932
|
title: flags.title ?? "",
|
|
18625
18933
|
entity_ids: thesisEntityIDs(flags),
|
|
18934
|
+
entity_stances: thesisEntityStances(flags),
|
|
18626
18935
|
tickers: thesisTickers(flags),
|
|
18627
18936
|
visibility: flags.visibility === void 0 ? "public" : thesisVisibility(flags.visibility)
|
|
18628
18937
|
});
|
|
18938
|
+
case "asset-candidates":
|
|
18939
|
+
return client.theses.assetCandidates(
|
|
18940
|
+
requireFlag(flags, "text", "thesis asset-candidates")
|
|
18941
|
+
);
|
|
18629
18942
|
case "get":
|
|
18630
18943
|
return client.theses.get(requireFlag(flags, "id", "thesis get"));
|
|
18631
18944
|
case "version":
|
|
@@ -18846,8 +19159,32 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18846
19159
|
}
|
|
18847
19160
|
}
|
|
18848
19161
|
case "for-you": {
|
|
19162
|
+
if (subcommand === "theses") {
|
|
19163
|
+
const params2 = {
|
|
19164
|
+
first: optionalBoundedIntegerFlag(
|
|
19165
|
+
flags,
|
|
19166
|
+
"limit",
|
|
19167
|
+
"for-you theses",
|
|
19168
|
+
1,
|
|
19169
|
+
10
|
|
19170
|
+
),
|
|
19171
|
+
after: flags.cursor
|
|
19172
|
+
};
|
|
19173
|
+
try {
|
|
19174
|
+
validateForYouThesesParams(params2);
|
|
19175
|
+
} catch (error) {
|
|
19176
|
+
throw new CliUsageError(
|
|
19177
|
+
error instanceof Error ? error.message : String(error),
|
|
19178
|
+
"for-you"
|
|
19179
|
+
);
|
|
19180
|
+
}
|
|
19181
|
+
return client.forYou.theses(params2);
|
|
19182
|
+
}
|
|
18849
19183
|
if (subcommand !== "list") {
|
|
18850
|
-
throw new CliUsageError(
|
|
19184
|
+
throw new CliUsageError(
|
|
19185
|
+
"Expected for-you list or for-you theses",
|
|
19186
|
+
"for-you"
|
|
19187
|
+
);
|
|
18851
19188
|
}
|
|
18852
19189
|
const params = {
|
|
18853
19190
|
first: optionalBoundedIntegerFlag(
|