@alva-ai/toolkit 0.31.0 → 0.32.0-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/README.md +61 -1
- package/dist/browser.global.js +76 -44
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +174 -66
- package/dist/cli.js +607 -99
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +174 -66
- package/dist/dispatch.js +355 -42
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +443 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -67
- package/dist/index.d.ts +175 -67
- package/dist/index.js +442 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6627,6 +6627,89 @@ function requireFeedID(id) {
|
|
|
6627
6627
|
return id;
|
|
6628
6628
|
}
|
|
6629
6629
|
|
|
6630
|
+
// src/resources/thesisPublication.ts
|
|
6631
|
+
function record(value) {
|
|
6632
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6633
|
+
}
|
|
6634
|
+
function isPositiveInt64(value) {
|
|
6635
|
+
return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
|
|
6636
|
+
}
|
|
6637
|
+
var THESIS_PUBLICATION_FIELDS = `
|
|
6638
|
+
thesisId playbookId authorVersionId materialVersionId itemKey
|
|
6639
|
+
title body publishedAtMs changeKind visibility
|
|
6640
|
+
closed archived note closingNote researchPaused
|
|
6641
|
+
entityIds categoryIds
|
|
6642
|
+
entityStances { entityId stance }
|
|
6643
|
+
entities { id ticker name }
|
|
6644
|
+
publisher {
|
|
6645
|
+
__typename id displayName avatarUrl bio followersCount
|
|
6646
|
+
viewerState { following }
|
|
6647
|
+
... on Person { slug }
|
|
6648
|
+
... on PublicUser { username }
|
|
6649
|
+
}
|
|
6650
|
+
medias { type coverUrl url }
|
|
6651
|
+
signalFeed { id }
|
|
6652
|
+
snapshotRelease {
|
|
6653
|
+
versionId materialVersionId publishedAtMs changeKind
|
|
6654
|
+
sourceRefs {
|
|
6655
|
+
title sourceKind sourceContentId publicUrl sourceTimeMs locator
|
|
6656
|
+
}
|
|
6657
|
+
}
|
|
6658
|
+
`;
|
|
6659
|
+
function positiveInt64List(value) {
|
|
6660
|
+
return Array.isArray(value) && value.every(isPositiveInt64);
|
|
6661
|
+
}
|
|
6662
|
+
function stanceList(value) {
|
|
6663
|
+
return Array.isArray(value) && value.every(
|
|
6664
|
+
(item) => record(item) && isPositiveInt64(item.entityId) && typeof item.stance === "string" && item.stance.trim() !== ""
|
|
6665
|
+
);
|
|
6666
|
+
}
|
|
6667
|
+
function entityList(value) {
|
|
6668
|
+
return Array.isArray(value) && value.every(
|
|
6669
|
+
(item) => record(item) && typeof item.id === "string" && item.id.trim() !== "" && typeof item.ticker === "string" && typeof item.name === "string"
|
|
6670
|
+
);
|
|
6671
|
+
}
|
|
6672
|
+
function mediaList(value) {
|
|
6673
|
+
return Array.isArray(value) && value.every(
|
|
6674
|
+
(item) => record(item) && typeof item.type === "string" && item.type.trim() !== "" && typeof item.coverUrl === "string" && (item.url === null || typeof item.url === "string")
|
|
6675
|
+
);
|
|
6676
|
+
}
|
|
6677
|
+
function sourceRefList(value) {
|
|
6678
|
+
return Array.isArray(value) && value.every(
|
|
6679
|
+
(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"
|
|
6680
|
+
);
|
|
6681
|
+
}
|
|
6682
|
+
function nullableMs(value) {
|
|
6683
|
+
return value === null || typeof value === "number" && Number.isFinite(value);
|
|
6684
|
+
}
|
|
6685
|
+
function snapshot(value) {
|
|
6686
|
+
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);
|
|
6687
|
+
}
|
|
6688
|
+
function publisher(value) {
|
|
6689
|
+
return record(value) && (value.__typename === "Person" && typeof value.slug === "string" || value.__typename === "PublicUser" && typeof value.username === "string") && 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");
|
|
6690
|
+
}
|
|
6691
|
+
function isThesisPublication(value) {
|
|
6692
|
+
if (!record(value)) return false;
|
|
6693
|
+
for (const field of [
|
|
6694
|
+
"thesisId",
|
|
6695
|
+
"playbookId",
|
|
6696
|
+
"authorVersionId",
|
|
6697
|
+
"materialVersionId"
|
|
6698
|
+
]) {
|
|
6699
|
+
if (!isPositiveInt64(value[field])) return false;
|
|
6700
|
+
}
|
|
6701
|
+
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") {
|
|
6702
|
+
return false;
|
|
6703
|
+
}
|
|
6704
|
+
for (const field of ["closed", "archived", "researchPaused"]) {
|
|
6705
|
+
if (typeof value[field] !== "boolean") return false;
|
|
6706
|
+
}
|
|
6707
|
+
if (!positiveInt64List(value.entityIds) || !positiveInt64List(value.categoryIds) || !stanceList(value.entityStances) || !entityList(value.entities) || !mediaList(value.medias) || !publisher(value.publisher) || !snapshot(value.snapshotRelease)) {
|
|
6708
|
+
return false;
|
|
6709
|
+
}
|
|
6710
|
+
return value.signalFeed === null || record(value.signalFeed) && isPositiveInt64(value.signalFeed.id);
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6630
6713
|
// src/resources/forYou.ts
|
|
6631
6714
|
var FOR_YOU_QUERY = `
|
|
6632
6715
|
query ToolkitForYou($input: FeedEntryConnectionInput) {
|
|
@@ -6656,9 +6739,6 @@ query ToolkitForYou($input: FeedEntryConnectionInput) {
|
|
|
6656
6739
|
}
|
|
6657
6740
|
}
|
|
6658
6741
|
`.trim();
|
|
6659
|
-
function record(value) {
|
|
6660
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6661
|
-
}
|
|
6662
6742
|
function validateForYouListParams(params) {
|
|
6663
6743
|
if (!record(params)) throw new Error("For You parameters must be an object");
|
|
6664
6744
|
const first = params.first === void 0 ? 20 : params.first;
|
|
@@ -6675,9 +6755,6 @@ function validateForYouListParams(params) {
|
|
|
6675
6755
|
throw new Error("feedId must be a positive decimal int64 string");
|
|
6676
6756
|
}
|
|
6677
6757
|
}
|
|
6678
|
-
function isPositiveInt64(value) {
|
|
6679
|
-
return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
|
|
6680
|
-
}
|
|
6681
6758
|
function invalidResponse() {
|
|
6682
6759
|
throw new AlvaError(
|
|
6683
6760
|
"GRAPHQL_INVALID_RESPONSE",
|
|
@@ -6718,24 +6795,7 @@ query ToolkitForYouTheses($input: ThesisRecommendationInput) {
|
|
|
6718
6795
|
node {
|
|
6719
6796
|
itemKey
|
|
6720
6797
|
publication {
|
|
6721
|
-
|
|
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
|
-
}
|
|
6798
|
+
${THESIS_PUBLICATION_FIELDS}
|
|
6739
6799
|
}
|
|
6740
6800
|
}
|
|
6741
6801
|
}
|
|
@@ -6797,59 +6857,6 @@ function invalidPage() {
|
|
|
6797
6857
|
502
|
|
6798
6858
|
);
|
|
6799
6859
|
}
|
|
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
6860
|
function recommendationPage(value) {
|
|
6854
6861
|
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
6862
|
return invalidPage();
|
|
@@ -6859,7 +6866,7 @@ function recommendationPage(value) {
|
|
|
6859
6866
|
return invalidPage();
|
|
6860
6867
|
}
|
|
6861
6868
|
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() || !
|
|
6869
|
+
if (!record(edge) || typeof edge.cursor !== "string" || !edge.cursor.trim() || !record(edge.node) || typeof edge.node.itemKey !== "string" || !edge.node.itemKey.trim() || !isThesisPublication(edge.node.publication)) {
|
|
6863
6870
|
return invalidPage();
|
|
6864
6871
|
}
|
|
6865
6872
|
}
|
|
@@ -9964,10 +9971,10 @@ var StewardResource = class {
|
|
|
9964
9971
|
if (!Number.isSafeInteger(windowSinceMs) || !Number.isSafeInteger(windowUntilMs) || windowSinceMs <= 0 || windowUntilMs <= windowSinceMs)
|
|
9965
9972
|
throw emptyResponse();
|
|
9966
9973
|
const items = page.edges.map((edge) => edge.node);
|
|
9967
|
-
const
|
|
9974
|
+
const nextCursor2 = page.pageInfo?.hasNextPage === true && page.pageInfo.endCursor ? page.pageInfo.endCursor : null;
|
|
9968
9975
|
return {
|
|
9969
9976
|
items,
|
|
9970
|
-
nextCursor,
|
|
9977
|
+
nextCursor: nextCursor2,
|
|
9971
9978
|
windowSinceMs,
|
|
9972
9979
|
windowUntilMs
|
|
9973
9980
|
};
|
|
@@ -10192,6 +10199,249 @@ var TradingPairsResource = class {
|
|
|
10192
10199
|
}
|
|
10193
10200
|
};
|
|
10194
10201
|
|
|
10202
|
+
// src/resources/thesisReads.ts
|
|
10203
|
+
var PAGE = "pageInfo { endCursor hasNextPage }";
|
|
10204
|
+
var PERSON = "__typename id slug displayName bio";
|
|
10205
|
+
var USER = "__typename id username displayName bio";
|
|
10206
|
+
var ENTITY = "__typename id ticker name kind assetClass venue { id name }";
|
|
10207
|
+
var AUTHOR_THESES = `theses(input: $input) {
|
|
10208
|
+
edges { cursor node { id latestRelease { thesisPublication { ${THESIS_PUBLICATION_FIELDS} } } } }
|
|
10209
|
+
${PAGE}
|
|
10210
|
+
}`;
|
|
10211
|
+
var PERSON_QUERY = `query ToolkitPersonTheses($slug: String!, $input: ProfileThesisConnectionInput) {
|
|
10212
|
+
scope: person(slug: $slug) { ${PERSON} ${AUTHOR_THESES} }
|
|
10213
|
+
}`;
|
|
10214
|
+
var USER_QUERY = `query ToolkitUserTheses($username: String!, $input: ProfileThesisConnectionInput) {
|
|
10215
|
+
scope: publicUser(username: $username) { ${USER} ${AUTHOR_THESES} }
|
|
10216
|
+
}`;
|
|
10217
|
+
var ENTITY_QUERY = `query ToolkitEntityTheses($id: ID!, $input: EntityThesisConnectionInput) {
|
|
10218
|
+
market { scope: entity(input: { id: $id }) { ${ENTITY}
|
|
10219
|
+
theses(input: $input) { edges { cursor node { ${THESIS_PUBLICATION_FIELDS} } } ${PAGE} }
|
|
10220
|
+
} }
|
|
10221
|
+
}`;
|
|
10222
|
+
var PEOPLE_QUERY = `query ToolkitThesisPeople($query: String!) {
|
|
10223
|
+
search: people(input: { query: $query, first: 50 }) {
|
|
10224
|
+
edges { node { ${PERSON} } } pageInfo { hasNextPage }
|
|
10225
|
+
}
|
|
10226
|
+
}`;
|
|
10227
|
+
var ENTITIES_QUERY = `query ToolkitThesisEntities($query: String!) {
|
|
10228
|
+
market { search: entities(input: { query: $query, first: 50, byPrefix: false }) {
|
|
10229
|
+
edges { node { ${ENTITY} } } pageInfo { hasNextPage }
|
|
10230
|
+
} }
|
|
10231
|
+
}`;
|
|
10232
|
+
var RELATED_QUERY = `query ToolkitRelatedTheses($id: ID!, $input: RelatedThesisInput) {
|
|
10233
|
+
node(id: $id) { ... on Playbook { relatedTheses(input: $input) {
|
|
10234
|
+
state nextCursor
|
|
10235
|
+
edges { cursor node { itemKey score publication { ${THESIS_PUBLICATION_FIELDS} } } }
|
|
10236
|
+
} } }
|
|
10237
|
+
}`;
|
|
10238
|
+
var SELECTORS = [
|
|
10239
|
+
"person",
|
|
10240
|
+
"personName",
|
|
10241
|
+
"user",
|
|
10242
|
+
"ticker",
|
|
10243
|
+
"entityId"
|
|
10244
|
+
];
|
|
10245
|
+
function validateThesisPageParams(params) {
|
|
10246
|
+
if (!record(params)) throw argument("Thesis parameters must be an object");
|
|
10247
|
+
const first = params.first === void 0 ? 10 : params.first;
|
|
10248
|
+
if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
|
|
10249
|
+
throw argument("first must be an integer between 1 and 50");
|
|
10250
|
+
}
|
|
10251
|
+
if (params.cursor !== void 0 && !nonempty(params.cursor)) {
|
|
10252
|
+
throw argument("cursor must be non-empty");
|
|
10253
|
+
}
|
|
10254
|
+
}
|
|
10255
|
+
function validateListThesesParams(params) {
|
|
10256
|
+
validateThesisPageParams(params);
|
|
10257
|
+
const chosen = SELECTORS.filter((key) => params[key] !== void 0);
|
|
10258
|
+
if (chosen.length !== 1) {
|
|
10259
|
+
throw argument(
|
|
10260
|
+
"Choose exactly one of person, personName, user, ticker or entityId"
|
|
10261
|
+
);
|
|
10262
|
+
}
|
|
10263
|
+
if (!nonempty(params[chosen[0]]))
|
|
10264
|
+
throw argument(`${chosen[0]} must be non-empty`);
|
|
10265
|
+
if (params.entityId !== void 0 && !isPositiveInt64(params.entityId)) {
|
|
10266
|
+
throw argument("entityId must be a positive int64 string");
|
|
10267
|
+
}
|
|
10268
|
+
if (params.status !== void 0 && params.status !== "ACTIVE" && params.status !== "ARCHIVED") {
|
|
10269
|
+
throw argument("status must be ACTIVE or ARCHIVED");
|
|
10270
|
+
}
|
|
10271
|
+
if (params.status !== void 0 && (params.ticker !== void 0 || params.entityId !== void 0)) {
|
|
10272
|
+
throw argument("status applies only to author lists");
|
|
10273
|
+
}
|
|
10274
|
+
}
|
|
10275
|
+
async function listTheses(client, params) {
|
|
10276
|
+
validateListThesesParams(params);
|
|
10277
|
+
client._requireAuth();
|
|
10278
|
+
const input = { first: params.first ?? 10, after: params.cursor };
|
|
10279
|
+
const entityId = params.ticker === void 0 ? params.entityId : (await resolveUnique(client, ENTITIES_QUERY, params.ticker, "Entity")).id;
|
|
10280
|
+
if (entityId !== void 0) {
|
|
10281
|
+
const data2 = await graphql(client, ENTITY_QUERY, { id: entityId, input });
|
|
10282
|
+
if (!record(data2.market)) throw invalid3();
|
|
10283
|
+
return thesisPage(
|
|
10284
|
+
data2.market.scope,
|
|
10285
|
+
(node) => isThesisPublication(node) ? { playbookId: node.playbookId, publication: node } : void 0
|
|
10286
|
+
);
|
|
10287
|
+
}
|
|
10288
|
+
const profileInput = { ...input, status: params.status };
|
|
10289
|
+
const slug = params.personName === void 0 ? params.person : (await resolveUnique(client, PEOPLE_QUERY, params.personName, "Person")).slug;
|
|
10290
|
+
const data = slug === void 0 ? await graphql(client, USER_QUERY, {
|
|
10291
|
+
username: params.user,
|
|
10292
|
+
input: profileInput
|
|
10293
|
+
}) : await graphql(client, PERSON_QUERY, { slug, input: profileInput });
|
|
10294
|
+
return thesisPage(data.scope, (node) => {
|
|
10295
|
+
if (!isPositiveInt64(node.id)) return void 0;
|
|
10296
|
+
const release = node.latestRelease;
|
|
10297
|
+
if (release === null) return { playbookId: node.id, publication: null };
|
|
10298
|
+
if (!record(release)) return void 0;
|
|
10299
|
+
const publication = release.thesisPublication;
|
|
10300
|
+
if (publication !== null && !isThesisPublication(publication))
|
|
10301
|
+
return void 0;
|
|
10302
|
+
return { playbookId: node.id, publication };
|
|
10303
|
+
});
|
|
10304
|
+
}
|
|
10305
|
+
async function relatedTheses(client, id, params = {}) {
|
|
10306
|
+
validateThesisPageParams(params);
|
|
10307
|
+
if (!isPositiveInt64(id))
|
|
10308
|
+
throw argument("id must be an internal positive int64 Playbook ID");
|
|
10309
|
+
client._requireAuth();
|
|
10310
|
+
const data = await graphql(client, RELATED_QUERY, {
|
|
10311
|
+
id: `Playbook:${id}`,
|
|
10312
|
+
input: { first: params.first ?? 10, after: params.cursor }
|
|
10313
|
+
});
|
|
10314
|
+
if (data.node === null) throw notFound();
|
|
10315
|
+
if (!record(data.node)) throw invalid3();
|
|
10316
|
+
const value = data.node.relatedTheses;
|
|
10317
|
+
if (!record(value) || !["GENERATING", "READY", "FAILED"].includes(value.state) || value.nextCursor !== null && !nonempty(value.nextCursor))
|
|
10318
|
+
throw invalid3();
|
|
10319
|
+
for (const edge of edges(value)) {
|
|
10320
|
+
if (!nonempty(edge.node.itemKey) || typeof edge.node.score !== "number" || !isThesisPublication(edge.node.publication))
|
|
10321
|
+
throw invalid3();
|
|
10322
|
+
}
|
|
10323
|
+
return {
|
|
10324
|
+
state: value.state,
|
|
10325
|
+
edges: value.edges,
|
|
10326
|
+
nextCursor: value.nextCursor
|
|
10327
|
+
};
|
|
10328
|
+
}
|
|
10329
|
+
function thesisPage(value, readNode) {
|
|
10330
|
+
if (value === null) throw notFound();
|
|
10331
|
+
const scope = readScope(value);
|
|
10332
|
+
if (!record(value) || !record(value.theses)) throw invalid3();
|
|
10333
|
+
const page = value.theses;
|
|
10334
|
+
const items = edges(page).map((edge) => {
|
|
10335
|
+
const node = readNode(edge.node);
|
|
10336
|
+
if (node === void 0) throw invalid3();
|
|
10337
|
+
return { cursor: edge.cursor, node };
|
|
10338
|
+
});
|
|
10339
|
+
return { scope, edges: items, nextCursor: nextCursor(page) };
|
|
10340
|
+
}
|
|
10341
|
+
async function resolveUnique(client, document, text, kind) {
|
|
10342
|
+
const data = await graphql(client, document, { query: text });
|
|
10343
|
+
const search = record(data.market) ? data.market.search : data.search;
|
|
10344
|
+
if (!record(search) || !Array.isArray(search.edges) || !record(search.pageInfo))
|
|
10345
|
+
throw invalid3();
|
|
10346
|
+
const candidates = search.edges.map(
|
|
10347
|
+
(edge) => readScope(record(edge) ? edge.node : void 0)
|
|
10348
|
+
);
|
|
10349
|
+
if (!candidates.every((c) => c.__typename === kind))
|
|
10350
|
+
throw invalid3();
|
|
10351
|
+
const more = search.pageInfo.hasNextPage === true;
|
|
10352
|
+
if (candidates.length === 1 && !more) return candidates[0];
|
|
10353
|
+
if (candidates.length === 0 && !more) throw notFound();
|
|
10354
|
+
throw new AlvaError(
|
|
10355
|
+
"AMBIGUOUS_IDENTITY",
|
|
10356
|
+
// ALPI Dispatch currently forwards only Error.message, not details.
|
|
10357
|
+
// Keep candidate identities available through that existing boundary too.
|
|
10358
|
+
`Choose an exact identity before reading theses. Candidates: ${JSON.stringify(candidates)}${more ? " More matches exist; refine the name or ticker." : ""}`,
|
|
10359
|
+
400,
|
|
10360
|
+
{ candidates, more }
|
|
10361
|
+
);
|
|
10362
|
+
}
|
|
10363
|
+
function readScope(value) {
|
|
10364
|
+
if (!record(value) || !nonempty(value.id)) throw invalid3();
|
|
10365
|
+
if (value.__typename === "Entity") {
|
|
10366
|
+
if (!["ticker", "name", "kind", "assetClass"].every(
|
|
10367
|
+
(key) => typeof value[key] === "string"
|
|
10368
|
+
) || value.venue !== null && (!record(value.venue) || !nonempty(value.venue.id) || typeof value.venue.name !== "string"))
|
|
10369
|
+
throw invalid3();
|
|
10370
|
+
} else if (typeof value.displayName !== "string" || typeof value.bio !== "string" || !(value.__typename === "Person" && nonempty(value.slug) || value.__typename === "PublicUser" && nonempty(value.username))) {
|
|
10371
|
+
throw invalid3();
|
|
10372
|
+
}
|
|
10373
|
+
const scope = { ...value };
|
|
10374
|
+
delete scope.theses;
|
|
10375
|
+
return scope;
|
|
10376
|
+
}
|
|
10377
|
+
function edges(value) {
|
|
10378
|
+
if (!Array.isArray(value.edges) || !value.edges.every(
|
|
10379
|
+
(edge) => record(edge) && nonempty(edge.cursor) && record(edge.node)
|
|
10380
|
+
))
|
|
10381
|
+
throw invalid3();
|
|
10382
|
+
return value.edges;
|
|
10383
|
+
}
|
|
10384
|
+
function nextCursor(page) {
|
|
10385
|
+
const info = page.pageInfo;
|
|
10386
|
+
if (!record(info) || typeof info.hasNextPage !== "boolean" || info.hasNextPage && !nonempty(info.endCursor))
|
|
10387
|
+
throw invalid3();
|
|
10388
|
+
return info.hasNextPage ? info.endCursor : null;
|
|
10389
|
+
}
|
|
10390
|
+
async function graphql(client, document, variables) {
|
|
10391
|
+
const response = await client._request("POST", "/query", {
|
|
10392
|
+
body: { query: document, variables }
|
|
10393
|
+
});
|
|
10394
|
+
if (!record(response)) throw invalid3();
|
|
10395
|
+
if (response.errors !== void 0) {
|
|
10396
|
+
if (!Array.isArray(response.errors)) throw invalid3();
|
|
10397
|
+
if (response.errors.length) {
|
|
10398
|
+
const messages = response.errors.flatMap(
|
|
10399
|
+
(error) => record(error) && typeof error.message === "string" ? [error.message] : []
|
|
10400
|
+
);
|
|
10401
|
+
const codes = new Set(
|
|
10402
|
+
response.errors.map(
|
|
10403
|
+
(error) => record(error) && record(error.extensions) ? error.extensions.code : void 0
|
|
10404
|
+
)
|
|
10405
|
+
);
|
|
10406
|
+
const [code] = codes;
|
|
10407
|
+
const status = codes.size === 1 && typeof code === "string" ? CANONICAL_STATUS.get(code) : void 0;
|
|
10408
|
+
throw new AlvaError(
|
|
10409
|
+
status === void 0 ? "GRAPHQL_ERROR" : String(code),
|
|
10410
|
+
messages.join("; ") || "GraphQL request failed",
|
|
10411
|
+
status ?? 400,
|
|
10412
|
+
{ errors: response.errors }
|
|
10413
|
+
);
|
|
10414
|
+
}
|
|
10415
|
+
}
|
|
10416
|
+
if (!record(response.data)) throw invalid3();
|
|
10417
|
+
return response.data;
|
|
10418
|
+
}
|
|
10419
|
+
var CANONICAL_STATUS = /* @__PURE__ */ new Map([
|
|
10420
|
+
["NOT_FOUND", 404],
|
|
10421
|
+
["PERMISSION_DENIED", 403],
|
|
10422
|
+
["UNAUTHENTICATED", 401]
|
|
10423
|
+
]);
|
|
10424
|
+
function nonempty(value) {
|
|
10425
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
10426
|
+
}
|
|
10427
|
+
function argument(message) {
|
|
10428
|
+
return new AlvaError("INVALID_ARGUMENT", message, 400);
|
|
10429
|
+
}
|
|
10430
|
+
function invalid3() {
|
|
10431
|
+
return new AlvaError(
|
|
10432
|
+
"GRAPHQL_INVALID_RESPONSE",
|
|
10433
|
+
"Invalid Thesis read response",
|
|
10434
|
+
502
|
|
10435
|
+
);
|
|
10436
|
+
}
|
|
10437
|
+
function notFound() {
|
|
10438
|
+
return new AlvaError(
|
|
10439
|
+
"NOT_FOUND",
|
|
10440
|
+
"No visible matching identity or Thesis found",
|
|
10441
|
+
404
|
|
10442
|
+
);
|
|
10443
|
+
}
|
|
10444
|
+
|
|
10195
10445
|
// src/resources/theses.ts
|
|
10196
10446
|
var MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
10197
10447
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -10202,6 +10452,14 @@ var ThesesResource = class {
|
|
|
10202
10452
|
this.client = client;
|
|
10203
10453
|
}
|
|
10204
10454
|
client;
|
|
10455
|
+
/** One visible page; no automatic pagination or content truncation. */
|
|
10456
|
+
list(params) {
|
|
10457
|
+
return listTheses(this.client, params);
|
|
10458
|
+
}
|
|
10459
|
+
/** Related publications always use the current source version. */
|
|
10460
|
+
related(id, params = {}) {
|
|
10461
|
+
return relatedTheses(this.client, id, params);
|
|
10462
|
+
}
|
|
10205
10463
|
async assetCandidates(text) {
|
|
10206
10464
|
this.client._requireAuth();
|
|
10207
10465
|
const source = requireBody(text);
|
|
@@ -10608,11 +10866,11 @@ function thesisSignalsResponse(response, thesisID, first) {
|
|
|
10608
10866
|
signal: mappedSignal
|
|
10609
10867
|
};
|
|
10610
10868
|
});
|
|
10611
|
-
const
|
|
10612
|
-
if (
|
|
10869
|
+
const nextCursor2 = responseText(response.next_cursor, "next_cursor");
|
|
10870
|
+
if (nextCursor2 && nextCursor2 !== entries[entries.length - 1]?.cursor) {
|
|
10613
10871
|
throw invalidResponse2("next_cursor must match the final entry");
|
|
10614
10872
|
}
|
|
10615
|
-
return { research: status, entries, next_cursor:
|
|
10873
|
+
return { research: status, entries, next_cursor: nextCursor2 };
|
|
10616
10874
|
}
|
|
10617
10875
|
function responseNonnegativeInteger(value, field) {
|
|
10618
10876
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
@@ -10779,6 +11037,101 @@ function invalidResponse2(message) {
|
|
|
10779
11037
|
return new AlvaError("INVALID_RESPONSE", message, 502);
|
|
10780
11038
|
}
|
|
10781
11039
|
|
|
11040
|
+
// src/resources/companyNews.ts
|
|
11041
|
+
var CREATE_COMPANY_NEWS = `mutation CreateCompanyNews($input: CompanyNewsFeedInput!) {
|
|
11042
|
+
companyNews {
|
|
11043
|
+
createFeed(input: $input) { id producer { id } }
|
|
11044
|
+
}
|
|
11045
|
+
}`;
|
|
11046
|
+
var GRAPHQL_STATUS_BY_CODE3 = {
|
|
11047
|
+
INVALID_ARGUMENT: 400,
|
|
11048
|
+
UNAUTHENTICATED: 401,
|
|
11049
|
+
PERMISSION_DENIED: 403,
|
|
11050
|
+
NOT_FOUND: 404,
|
|
11051
|
+
ALREADY_EXISTS: 409,
|
|
11052
|
+
ABORTED: 409,
|
|
11053
|
+
FAILED_PRECONDITION: 412,
|
|
11054
|
+
RESOURCE_EXHAUSTED: 429,
|
|
11055
|
+
INTERNAL: 500,
|
|
11056
|
+
UNKNOWN: 500,
|
|
11057
|
+
DATA_LOSS: 500,
|
|
11058
|
+
UNAVAILABLE: 503,
|
|
11059
|
+
DEADLINE_EXCEEDED: 504
|
|
11060
|
+
};
|
|
11061
|
+
function validateCompanyNewsCreateParams(params) {
|
|
11062
|
+
if (typeof params?.name !== "string" || params.name.trim() !== params.name || !/^[a-zA-Z0-9][a-zA-Z0-9-]{0,63}$/.test(params.name) || params.name === "news-lane") {
|
|
11063
|
+
throw new AlvaError(
|
|
11064
|
+
"INVALID_ARGUMENT",
|
|
11065
|
+
"name must be 1-64 alphanumeric/hyphen characters and distinct from news-lane",
|
|
11066
|
+
400
|
|
11067
|
+
);
|
|
11068
|
+
}
|
|
11069
|
+
if (!Array.isArray(params.tickers) || params.tickers.length < 1 || params.tickers.length > 1e3 || params.tickers.some(
|
|
11070
|
+
(ticker) => typeof ticker !== "string" || ticker.trim() !== ticker || !/^[A-Z0-9][A-Z0-9.-]{0,19}$/.test(ticker)
|
|
11071
|
+
) || new Set(params.tickers).size !== params.tickers.length) {
|
|
11072
|
+
throw new AlvaError(
|
|
11073
|
+
"INVALID_ARGUMENT",
|
|
11074
|
+
"tickers must contain 1-1000 unique uppercase symbols",
|
|
11075
|
+
400
|
|
11076
|
+
);
|
|
11077
|
+
}
|
|
11078
|
+
for (const [name, maximum] of [
|
|
11079
|
+
["initial_lookback_hours", 168],
|
|
11080
|
+
["page_size", 100]
|
|
11081
|
+
]) {
|
|
11082
|
+
const value = params[name];
|
|
11083
|
+
if (value !== void 0 && (!Number.isInteger(value) || value < 0 || value > maximum)) {
|
|
11084
|
+
throw new AlvaError(
|
|
11085
|
+
"INVALID_ARGUMENT",
|
|
11086
|
+
`${name} must be an integer from 0 to ${maximum} (0 selects the default)`,
|
|
11087
|
+
400
|
|
11088
|
+
);
|
|
11089
|
+
}
|
|
11090
|
+
}
|
|
11091
|
+
}
|
|
11092
|
+
var CompanyNewsResource = class {
|
|
11093
|
+
constructor(client) {
|
|
11094
|
+
this.client = client;
|
|
11095
|
+
}
|
|
11096
|
+
client;
|
|
11097
|
+
async create(params) {
|
|
11098
|
+
this.client._requireAuth();
|
|
11099
|
+
validateCompanyNewsCreateParams(params);
|
|
11100
|
+
const body = {
|
|
11101
|
+
name: params.name,
|
|
11102
|
+
tickers: params.tickers,
|
|
11103
|
+
...params.initial_lookback_hours === void 0 ? {} : { initialLookbackHours: params.initial_lookback_hours },
|
|
11104
|
+
...params.page_size === void 0 ? {} : { pageSize: params.page_size }
|
|
11105
|
+
};
|
|
11106
|
+
const graph = await this.client._request("POST", "/query", {
|
|
11107
|
+
body: { query: CREATE_COMPANY_NEWS, variables: { input: body } }
|
|
11108
|
+
});
|
|
11109
|
+
if (Array.isArray(graph?.errors) && graph.errors.length > 0) {
|
|
11110
|
+
const codes = graph.errors.map((error) => error?.extensions?.code);
|
|
11111
|
+
const code = typeof codes[0] === "string" && codes.every((value) => value === codes[0]) ? codes[0] : "GRAPHQL_ERROR";
|
|
11112
|
+
throw new AlvaError(
|
|
11113
|
+
code,
|
|
11114
|
+
graph.errors.map((error) => error?.message).filter(Boolean).join("; ") || "Company News creation failed",
|
|
11115
|
+
GRAPHQL_STATUS_BY_CODE3[code] ?? 502,
|
|
11116
|
+
{ errors: graph.errors }
|
|
11117
|
+
);
|
|
11118
|
+
}
|
|
11119
|
+
const feed = graph?.data?.companyNews?.createFeed;
|
|
11120
|
+
const response = { feed_id: feed?.id, cronjob_id: feed?.producer?.id };
|
|
11121
|
+
if (typeof response !== "object" || response === null || !("feed_id" in response) || !validID(response.feed_id) || !("cronjob_id" in response) || !validID(response.cronjob_id)) {
|
|
11122
|
+
throw new AlvaError(
|
|
11123
|
+
"INVALID_RESPONSE",
|
|
11124
|
+
"company news response must contain decimal int64 feed_id and cronjob_id strings",
|
|
11125
|
+
502
|
|
11126
|
+
);
|
|
11127
|
+
}
|
|
11128
|
+
return { feed_id: response.feed_id, cronjob_id: response.cronjob_id };
|
|
11129
|
+
}
|
|
11130
|
+
};
|
|
11131
|
+
function validID(value) {
|
|
11132
|
+
return typeof value === "string" && value.trim() === value && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
|
|
11133
|
+
}
|
|
11134
|
+
|
|
10782
11135
|
// src/client.ts
|
|
10783
11136
|
var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
|
|
10784
11137
|
var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
|
|
@@ -10894,6 +11247,7 @@ var AlvaClient = class {
|
|
|
10894
11247
|
_steward;
|
|
10895
11248
|
_tradingPairs;
|
|
10896
11249
|
_theses;
|
|
11250
|
+
_companyNews;
|
|
10897
11251
|
constructor(config) {
|
|
10898
11252
|
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
10899
11253
|
this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
|
|
@@ -11004,6 +11358,9 @@ var AlvaClient = class {
|
|
|
11004
11358
|
get theses() {
|
|
11005
11359
|
return this._theses ??= new ThesesResource(this);
|
|
11006
11360
|
}
|
|
11361
|
+
get companyNews() {
|
|
11362
|
+
return this._companyNews ??= new CompanyNewsResource(this);
|
|
11363
|
+
}
|
|
11007
11364
|
_requireAuth() {
|
|
11008
11365
|
if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
|
|
11009
11366
|
throw new AlvaError(
|
|
@@ -11459,6 +11816,9 @@ var COMMAND_DEFINITIONS = [
|
|
|
11459
11816
|
command("steward briefed", {
|
|
11460
11817
|
values: ["inbox-path", "delivery-ids", "digest-run-id"]
|
|
11461
11818
|
}),
|
|
11819
|
+
command("company-news create", {
|
|
11820
|
+
values: ["name", "tickers", "initial-lookback-hours", "page-size"]
|
|
11821
|
+
}),
|
|
11462
11822
|
command("thesis create", {
|
|
11463
11823
|
values: [
|
|
11464
11824
|
"request-id",
|
|
@@ -11473,6 +11833,19 @@ var COMMAND_DEFINITIONS = [
|
|
|
11473
11833
|
booleans: ["body-stdin"]
|
|
11474
11834
|
}),
|
|
11475
11835
|
command("thesis asset-candidates", { values: ["text"] }),
|
|
11836
|
+
command("thesis list", {
|
|
11837
|
+
values: [
|
|
11838
|
+
"person",
|
|
11839
|
+
"person-name",
|
|
11840
|
+
"user",
|
|
11841
|
+
"ticker",
|
|
11842
|
+
"entity-id",
|
|
11843
|
+
"status",
|
|
11844
|
+
"first",
|
|
11845
|
+
"cursor"
|
|
11846
|
+
]
|
|
11847
|
+
}),
|
|
11848
|
+
command("thesis related", { values: ["id", "first", "cursor"] }),
|
|
11476
11849
|
command("thesis get", { values: ["id"] }),
|
|
11477
11850
|
command("thesis version get", {
|
|
11478
11851
|
values: ["id", "author-version-id"]
|
|
@@ -16169,7 +16542,7 @@ function formatTradingPairResolved(result) {
|
|
|
16169
16542
|
}
|
|
16170
16543
|
|
|
16171
16544
|
// src/cli/dispatch.ts
|
|
16172
|
-
var CLI_VERSION = true ? "0.
|
|
16545
|
+
var CLI_VERSION = true ? "0.32.0-beta.1" : "dev";
|
|
16173
16546
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
16174
16547
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
16175
16548
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -16213,7 +16586,8 @@ Commands:
|
|
|
16213
16586
|
deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)
|
|
16214
16587
|
schedule Agent-owned named schedules (list, put, pause, resume, delete)
|
|
16215
16588
|
steward Push steward reports for a Session Inbox (decide, forward, send, pending, briefed)
|
|
16216
|
-
thesis
|
|
16589
|
+
thesis Read published viewpoints and manage authored theses
|
|
16590
|
+
company-news Create a backend-managed multi-ticker News Feed
|
|
16217
16591
|
service-account Restricted run-as identities (create, list, delete, grant, revoke)
|
|
16218
16592
|
release Feed and playbook releases (feed, playbook-draft, playbook)
|
|
16219
16593
|
lint Design-system lint (playbook)
|
|
@@ -16259,6 +16633,27 @@ Quick start:
|
|
|
16259
16633
|
alva configure --api-key alva_your_key_here
|
|
16260
16634
|
alva whoami`;
|
|
16261
16635
|
var COMMAND_HELP = {
|
|
16636
|
+
"company-news": `Usage: alva company-news create --name <name> --tickers <NVDA,AMD> [options]
|
|
16637
|
+
|
|
16638
|
+
Create one private, backend-managed Feed covering all supplied tickers.
|
|
16639
|
+
No script upload, entry path or cron deployment is required.
|
|
16640
|
+
|
|
16641
|
+
Options:
|
|
16642
|
+
--name <name> Owner-local name (1-64 alphanumeric/hyphen characters; not news-lane)
|
|
16643
|
+
--tickers <A,B,C> 1-1000 unique uppercase symbols
|
|
16644
|
+
--initial-lookback-hours <0-168> Initial history window (default: 24; 0 selects default)
|
|
16645
|
+
--page-size <0-100> Editorial batch size (default: 20; 0 selects default)
|
|
16646
|
+
|
|
16647
|
+
New feeds are paused. Returns decimal-string feed_id and cronjob_id.
|
|
16648
|
+
Creation does not run the model or resume the producer. After reviewing the
|
|
16649
|
+
configuration, use 'alva feed resume --id <feed_id>' to start paid execution.
|
|
16650
|
+
Model credits are charged to the authenticated creator, not the platform.
|
|
16651
|
+
This is pull-only: starting the producer does not enable push notifications.
|
|
16652
|
+
Retry an unclear result with the same name and configuration; an existing
|
|
16653
|
+
feed's current activation state is preserved. Different configuration conflicts.
|
|
16654
|
+
The backend and database migration must be deployed; no script fallback is used.
|
|
16655
|
+
|
|
16656
|
+
Example: alva company-news create --name my-company-news --tickers NVDA,AMD`,
|
|
16262
16657
|
steward: `Usage: alva steward <subcommand> [options]
|
|
16263
16658
|
|
|
16264
16659
|
Report a push steward's decisions for Feed alerts routed to its Session Inbox,
|
|
@@ -16535,7 +16930,8 @@ At least one of --code, --local-file, or --entry-path is required.
|
|
|
16535
16930
|
These three options are mutually exclusive.
|
|
16536
16931
|
|
|
16537
16932
|
Response fields:
|
|
16538
|
-
result
|
|
16933
|
+
result The script's return value. Return objects directly; a script
|
|
16934
|
+
returning JSON.stringify(x) is shown as x.
|
|
16539
16935
|
logs Captured stderr output
|
|
16540
16936
|
status "completed" or "failed"
|
|
16541
16937
|
error Error message (when status is "failed")
|
|
@@ -16557,13 +16953,14 @@ Constraints:
|
|
|
16557
16953
|
|
|
16558
16954
|
Examples:
|
|
16559
16955
|
alva run --code "1 + 2 + 3;"
|
|
16560
|
-
alva run --code "
|
|
16956
|
+
alva run --code "require('env').args;" --args '{"symbol":"BTC"}'
|
|
16561
16957
|
alva run --entry-path "~/feeds/my-feed/v1/src/index.js"
|
|
16562
16958
|
alva run --entry-path "~/tasks/analyze/src/index.js" --args '{"symbol":"NVDA","limit":50}'
|
|
16563
16959
|
alva run --local-file ./my-script.js --args '{"symbol":"BTC"}'
|
|
16564
16960
|
printf '%s' '{"symbol":"BTC"}' | alva run --local-file ./my-script.js --args-stdin
|
|
16565
16961
|
alva run --entry-path "~/tasks/heavy/src/index.js" --max-heap-size-mb 1024
|
|
16566
|
-
alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000
|
|
16962
|
+
alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000
|
|
16963
|
+
alva run --local-file ./research.js > research.json && jq -c '.result.income[:4]' research.json`,
|
|
16567
16964
|
deploy: `Usage: alva deploy <subcommand> [options]
|
|
16568
16965
|
|
|
16569
16966
|
Manage scheduled cronjobs that run your scripts on a cron schedule.
|
|
@@ -17570,6 +17967,8 @@ Create and update never rewrite text automatically.
|
|
|
17570
17967
|
|
|
17571
17968
|
Subcommands:
|
|
17572
17969
|
create Create a thesis
|
|
17970
|
+
list Read theses by author or market entity
|
|
17971
|
+
related Read related current publications
|
|
17573
17972
|
get Get one thesis
|
|
17574
17973
|
version get Get one exact author version
|
|
17575
17974
|
signals Read published Signal history
|
|
@@ -17592,6 +17991,20 @@ Update requires --visibility explicitly so it cannot inadvertently publish.
|
|
|
17592
17991
|
|
|
17593
17992
|
Other flags:
|
|
17594
17993
|
create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
|
|
17994
|
+
list --person <slug> | --person-name <name> | --user <username>
|
|
17995
|
+
| --ticker <ticker> | --entity-id <id>
|
|
17996
|
+
[--status ACTIVE|ARCHIVED] [--first 10] [--cursor <nextCursor>]
|
|
17997
|
+
Choose one selector; --status is for author lists only (default ACTIVE).
|
|
17998
|
+
Name/ticker ambiguity returns candidates; retry with an exact slug or entity ID.
|
|
17999
|
+
A publisher's __typename picks its selector: Person --person <slug>,
|
|
18000
|
+
PublicUser --user <username>.
|
|
18001
|
+
related --id <playbook-id> [--first 10] [--cursor <nextCursor>]
|
|
18002
|
+
Uses the source's current version; state is GENERATING, READY or FAILED.
|
|
18003
|
+
list/related read one page (default 10, maximum 50) with full bodies. Pass
|
|
18004
|
+
nextCursor to --cursor while it is non-null, even after an empty page.
|
|
18005
|
+
publication.playbookId is the ID for get/version/signals/related;
|
|
18006
|
+
publication=null means no readable snapshot. Author lists include the
|
|
18007
|
+
signed-in owner's private Theses (visibility private).
|
|
17595
18008
|
asset-candidates --text <unsaved thesis text>
|
|
17596
18009
|
get --id <signed-int64-decimal>
|
|
17597
18010
|
version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
|
|
@@ -17623,14 +18036,14 @@ Examples:
|
|
|
17623
18036
|
function parseFlags(argv) {
|
|
17624
18037
|
const flags = {};
|
|
17625
18038
|
for (let index = 0; index < argv.length; index++) {
|
|
17626
|
-
const
|
|
17627
|
-
if (!
|
|
17628
|
-
const equalsIndex =
|
|
18039
|
+
const argument2 = argv[index];
|
|
18040
|
+
if (!argument2.startsWith("--")) continue;
|
|
18041
|
+
const equalsIndex = argument2.indexOf("=");
|
|
17629
18042
|
if (equalsIndex !== -1) {
|
|
17630
|
-
flags[
|
|
18043
|
+
flags[argument2.slice(2, equalsIndex)] = argument2.slice(equalsIndex + 1);
|
|
17631
18044
|
continue;
|
|
17632
18045
|
}
|
|
17633
|
-
const name =
|
|
18046
|
+
const name = argument2.slice(2);
|
|
17634
18047
|
if (BOOLEAN_FLAGS.has(name)) {
|
|
17635
18048
|
flags[name] = "true";
|
|
17636
18049
|
continue;
|
|
@@ -17707,6 +18120,16 @@ function requirePositiveIntegerStringFlag(flags, name, command2) {
|
|
|
17707
18120
|
}
|
|
17708
18121
|
return val;
|
|
17709
18122
|
}
|
|
18123
|
+
function requireFeedIDFlag(flags, command2) {
|
|
18124
|
+
const value = requirePositiveIntegerStringFlag(flags, "id", command2);
|
|
18125
|
+
if (value.length > 19 || value.trim() !== value || BigInt(value) > 9223372036854775807n) {
|
|
18126
|
+
throw new CliUsageError(
|
|
18127
|
+
`--id must be a positive decimal int64 for '${command2}'`,
|
|
18128
|
+
"feed"
|
|
18129
|
+
);
|
|
18130
|
+
}
|
|
18131
|
+
return value;
|
|
18132
|
+
}
|
|
17710
18133
|
function optionalBoundedIntegerFlag(flags, name, command2, min, max) {
|
|
17711
18134
|
const val = flags[name];
|
|
17712
18135
|
if (val === void 0) return void 0;
|
|
@@ -18248,6 +18671,24 @@ function assertLocalFileAvailable(command2, flag, deps) {
|
|
|
18248
18671
|
throw localFileUnsupported(command2, flag);
|
|
18249
18672
|
}
|
|
18250
18673
|
}
|
|
18674
|
+
function decodeRunResult(result) {
|
|
18675
|
+
let value;
|
|
18676
|
+
try {
|
|
18677
|
+
value = JSON.parse(result);
|
|
18678
|
+
} catch {
|
|
18679
|
+
return result;
|
|
18680
|
+
}
|
|
18681
|
+
let inner = value;
|
|
18682
|
+
while (typeof inner === "string") {
|
|
18683
|
+
try {
|
|
18684
|
+
inner = JSON.parse(inner);
|
|
18685
|
+
} catch {
|
|
18686
|
+
break;
|
|
18687
|
+
}
|
|
18688
|
+
if (inner !== null && typeof inner === "object") return inner;
|
|
18689
|
+
}
|
|
18690
|
+
return value;
|
|
18691
|
+
}
|
|
18251
18692
|
function readLocalTextFile(path, command2, flag, deps) {
|
|
18252
18693
|
assertLocalFileAvailable(command2, flag, deps);
|
|
18253
18694
|
if (!deps?.localFiles) {
|
|
@@ -18670,7 +19111,8 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18670
19111
|
);
|
|
18671
19112
|
}
|
|
18672
19113
|
}
|
|
18673
|
-
|
|
19114
|
+
const response = serializedArgs === void 0 ? await client.run.execute(params) : await client.run._executeSerializedArgs(params, serializedArgs);
|
|
19115
|
+
return { ...response, result: decodeRunResult(response.result) };
|
|
18674
19116
|
}
|
|
18675
19117
|
case "deploy": {
|
|
18676
19118
|
if (!subcommand)
|
|
@@ -18920,6 +19362,38 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18920
19362
|
);
|
|
18921
19363
|
}
|
|
18922
19364
|
}
|
|
19365
|
+
case "company-news": {
|
|
19366
|
+
if (subcommand !== "create") {
|
|
19367
|
+
throw new CliUsageError("Expected company-news create", "company-news");
|
|
19368
|
+
}
|
|
19369
|
+
const params = {
|
|
19370
|
+
name: requireFlag(flags, "name", "company-news create"),
|
|
19371
|
+
tickers: requireFlag(flags, "tickers", "company-news create").split(",").map((ticker) => ticker.trim())
|
|
19372
|
+
};
|
|
19373
|
+
for (const [flag, field] of [
|
|
19374
|
+
["initial-lookback-hours", "initial_lookback_hours"],
|
|
19375
|
+
["page-size", "page_size"]
|
|
19376
|
+
]) {
|
|
19377
|
+
const value = flags[flag];
|
|
19378
|
+
if (value === void 0) continue;
|
|
19379
|
+
if (!/^\d+$/.test(value)) {
|
|
19380
|
+
throw new CliUsageError(
|
|
19381
|
+
`--${flag} must be a nonnegative integer`,
|
|
19382
|
+
"company-news"
|
|
19383
|
+
);
|
|
19384
|
+
}
|
|
19385
|
+
params[field] = Number(value);
|
|
19386
|
+
}
|
|
19387
|
+
try {
|
|
19388
|
+
validateCompanyNewsCreateParams(params);
|
|
19389
|
+
} catch (error) {
|
|
19390
|
+
throw new CliUsageError(
|
|
19391
|
+
error instanceof Error ? error.message : "Invalid company news configuration",
|
|
19392
|
+
"company-news"
|
|
19393
|
+
);
|
|
19394
|
+
}
|
|
19395
|
+
return client.companyNews.create(params);
|
|
19396
|
+
}
|
|
18923
19397
|
case "thesis": {
|
|
18924
19398
|
if (!subcommand) {
|
|
18925
19399
|
throw new CliUsageError("Missing subcommand for thesis", "thesis");
|
|
@@ -18939,6 +19413,39 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
18939
19413
|
return client.theses.assetCandidates(
|
|
18940
19414
|
requireFlag(flags, "text", "thesis asset-candidates")
|
|
18941
19415
|
);
|
|
19416
|
+
case "list": {
|
|
19417
|
+
const params = {
|
|
19418
|
+
person: flags.person,
|
|
19419
|
+
personName: flags["person-name"],
|
|
19420
|
+
user: flags.user,
|
|
19421
|
+
ticker: flags.ticker,
|
|
19422
|
+
entityId: flags["entity-id"],
|
|
19423
|
+
status: flags.status,
|
|
19424
|
+
first: flags.first === void 0 ? void 0 : Number(flags.first),
|
|
19425
|
+
cursor: flags.cursor
|
|
19426
|
+
};
|
|
19427
|
+
try {
|
|
19428
|
+
validateListThesesParams(params);
|
|
19429
|
+
} catch (error) {
|
|
19430
|
+
throw new CliUsageError(error.message, "thesis");
|
|
19431
|
+
}
|
|
19432
|
+
return client.theses.list(params);
|
|
19433
|
+
}
|
|
19434
|
+
case "related": {
|
|
19435
|
+
const params = {
|
|
19436
|
+
first: flags.first === void 0 ? void 0 : Number(flags.first),
|
|
19437
|
+
cursor: flags.cursor
|
|
19438
|
+
};
|
|
19439
|
+
try {
|
|
19440
|
+
validateThesisPageParams(params);
|
|
19441
|
+
} catch (error) {
|
|
19442
|
+
throw new CliUsageError(error.message, "thesis");
|
|
19443
|
+
}
|
|
19444
|
+
return client.theses.related(
|
|
19445
|
+
requireFlag(flags, "id", "thesis related"),
|
|
19446
|
+
params
|
|
19447
|
+
);
|
|
19448
|
+
}
|
|
18942
19449
|
case "get":
|
|
18943
19450
|
return client.theses.get(requireFlag(flags, "id", "thesis get"));
|
|
18944
19451
|
case "version":
|
|
@@ -19063,19 +19570,19 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
19063
19570
|
});
|
|
19064
19571
|
case "stop":
|
|
19065
19572
|
return client.feed.stop({
|
|
19066
|
-
id:
|
|
19573
|
+
id: requireFeedIDFlag(flags, "feed stop")
|
|
19067
19574
|
});
|
|
19068
19575
|
case "resume":
|
|
19069
19576
|
return client.feed.resume({
|
|
19070
|
-
id:
|
|
19577
|
+
id: requireFeedIDFlag(flags, "feed resume")
|
|
19071
19578
|
});
|
|
19072
19579
|
case "delete":
|
|
19073
19580
|
return client.feed.delete({
|
|
19074
|
-
id:
|
|
19581
|
+
id: requireFeedIDFlag(flags, "feed delete")
|
|
19075
19582
|
});
|
|
19076
19583
|
case "set-visibility":
|
|
19077
19584
|
return client.feed.setVisibility({
|
|
19078
|
-
id:
|
|
19585
|
+
id: requireFeedIDFlag(flags, "feed set-visibility"),
|
|
19079
19586
|
visibility: feedVisibility(
|
|
19080
19587
|
requireFlag(flags, "visibility", "feed set-visibility")
|
|
19081
19588
|
)
|
|
@@ -20637,7 +21144,8 @@ async function main() {
|
|
|
20637
21144
|
} else if (typeof result === "string") {
|
|
20638
21145
|
process.stdout.write(result);
|
|
20639
21146
|
} else if (result !== void 0) {
|
|
20640
|
-
process.stdout.
|
|
21147
|
+
const indent = process.stdout.isTTY ? 2 : void 0;
|
|
21148
|
+
process.stdout.write(JSON.stringify(result, null, indent) + "\n");
|
|
20641
21149
|
}
|
|
20642
21150
|
} catch (error) {
|
|
20643
21151
|
if (error instanceof CliUsageError) {
|