@alva-ai/toolkit 0.38.0-beta.1 → 0.38.0-beta.2
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 +4 -1
- package/dist/browser.global.js +30 -30
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +77 -22
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +5 -1
- package/dist/dispatch.js +33 -21
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +17 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -2265,6 +2265,10 @@ interface Thesis {
|
|
|
2265
2265
|
interface ThesisResponse {
|
|
2266
2266
|
thesis: Thesis;
|
|
2267
2267
|
}
|
|
2268
|
+
/** A created Thesis and its clickable web url, e.g. `https://alva.ai/thesis/123`. */
|
|
2269
|
+
interface ThesisCreateResponse extends ThesisResponse {
|
|
2270
|
+
url: string;
|
|
2271
|
+
}
|
|
2268
2272
|
interface ThesisAuthor {
|
|
2269
2273
|
id: ThesisID;
|
|
2270
2274
|
kind: string;
|
|
@@ -2427,7 +2431,7 @@ declare class ThesesResource {
|
|
|
2427
2431
|
* things the Thesis depends on, or that would show it right or wrong.
|
|
2428
2432
|
*/
|
|
2429
2433
|
watchpoints(id: ThesisID): Promise<ThesisWatchpointsResult>;
|
|
2430
|
-
create(params: CreateThesisParams): Promise<
|
|
2434
|
+
create(params: CreateThesisParams): Promise<ThesisCreateResponse>;
|
|
2431
2435
|
get(id: ThesisID): Promise<ThesisGetResponse>;
|
|
2432
2436
|
getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
|
|
2433
2437
|
/** Lists reader-visible Updates, with editorial revisions folded together. */
|
package/dist/cli.js
CHANGED
|
@@ -7250,6 +7250,20 @@ function graphQLErrorMessage(errors) {
|
|
|
7250
7250
|
return messages.length > 0 ? messages.join("; ") : "GraphQL request failed";
|
|
7251
7251
|
}
|
|
7252
7252
|
|
|
7253
|
+
// src/resources/webOrigin.ts
|
|
7254
|
+
function webOriginFromApiBase(apiBaseUrl) {
|
|
7255
|
+
try {
|
|
7256
|
+
const host = new URL(apiBaseUrl).hostname;
|
|
7257
|
+
const match = /^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(host);
|
|
7258
|
+
if (match) {
|
|
7259
|
+
const env = match[1].toLowerCase();
|
|
7260
|
+
return env === "prd" ? "https://alva.ai" : `https://${env}.alva.ai`;
|
|
7261
|
+
}
|
|
7262
|
+
} catch {
|
|
7263
|
+
}
|
|
7264
|
+
return "https://alva.ai";
|
|
7265
|
+
}
|
|
7266
|
+
|
|
7253
7267
|
// src/resources/playbooks.ts
|
|
7254
7268
|
var PLAYBOOK_VISIBILITIES = [
|
|
7255
7269
|
"public",
|
|
@@ -7401,18 +7415,6 @@ var PlaybooksResource = class {
|
|
|
7401
7415
|
);
|
|
7402
7416
|
}
|
|
7403
7417
|
};
|
|
7404
|
-
function webOriginFromApiBase(apiBaseUrl) {
|
|
7405
|
-
try {
|
|
7406
|
-
const host = new URL(apiBaseUrl).hostname;
|
|
7407
|
-
const match = /^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(host);
|
|
7408
|
-
if (match) {
|
|
7409
|
-
const env = match[1].toLowerCase();
|
|
7410
|
-
return env === "prd" ? "https://alva.ai" : `https://${env}.alva.ai`;
|
|
7411
|
-
}
|
|
7412
|
-
} catch {
|
|
7413
|
-
}
|
|
7414
|
-
return "https://alva.ai";
|
|
7415
|
-
}
|
|
7416
7418
|
function toAgentPlaybook(raw, webOrigin) {
|
|
7417
7419
|
const username = raw.creator?.name ?? "";
|
|
7418
7420
|
const name = raw.name ?? "";
|
|
@@ -9226,7 +9228,8 @@ var ThesesResource = class {
|
|
|
9226
9228
|
await this.client._request("POST", "/api/v1/theses", { body })
|
|
9227
9229
|
);
|
|
9228
9230
|
requireKeptWeights(body.entity_stances, response.thesis.entity_stances);
|
|
9229
|
-
|
|
9231
|
+
const webOrigin = webOriginFromApiBase(this.client.baseUrl);
|
|
9232
|
+
return { ...response, url: `${webOrigin}/thesis/${response.thesis.id}` };
|
|
9230
9233
|
}
|
|
9231
9234
|
async get(id) {
|
|
9232
9235
|
this.client._requireAuth();
|
|
@@ -12959,6 +12962,41 @@ function getProfile(config, profileName) {
|
|
|
12959
12962
|
}
|
|
12960
12963
|
return {};
|
|
12961
12964
|
}
|
|
12965
|
+
async function assertConfigWritable(deps) {
|
|
12966
|
+
const path = configPath(deps);
|
|
12967
|
+
const cannot = (action, err) => {
|
|
12968
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
12969
|
+
return new Error(
|
|
12970
|
+
`Cannot ${action} ${path} (${reason}), where login stores the key. Allow reading and writing there and run \`alva auth login\` again; nothing was signed in.`
|
|
12971
|
+
);
|
|
12972
|
+
};
|
|
12973
|
+
let exists = true;
|
|
12974
|
+
try {
|
|
12975
|
+
await deps.readFile(path);
|
|
12976
|
+
} catch (err) {
|
|
12977
|
+
if (err?.code !== "ENOENT") {
|
|
12978
|
+
throw cannot("read", err);
|
|
12979
|
+
}
|
|
12980
|
+
exists = false;
|
|
12981
|
+
}
|
|
12982
|
+
try {
|
|
12983
|
+
if (exists) {
|
|
12984
|
+
await deps.writeFile(path, "", { mode: 384, flag: "a" });
|
|
12985
|
+
} else {
|
|
12986
|
+
await deps.mkdir(configDir(deps), { recursive: true });
|
|
12987
|
+
await deps.writeFile(
|
|
12988
|
+
path,
|
|
12989
|
+
JSON.stringify({ profiles: {} }, null, 2) + "\n",
|
|
12990
|
+
{
|
|
12991
|
+
mode: 384,
|
|
12992
|
+
flag: "wx"
|
|
12993
|
+
}
|
|
12994
|
+
);
|
|
12995
|
+
}
|
|
12996
|
+
} catch (err) {
|
|
12997
|
+
throw cannot("write", err);
|
|
12998
|
+
}
|
|
12999
|
+
}
|
|
12962
13000
|
async function writeConfig(config, deps, profileName = "default") {
|
|
12963
13001
|
const path = configPath(deps);
|
|
12964
13002
|
const dir = configDir(deps);
|
|
@@ -14076,6 +14114,7 @@ async function handleAuthLogin(args, deps) {
|
|
|
14076
14114
|
const oobRedirectUrl = deriveOobRedirectUrl(authUrl);
|
|
14077
14115
|
const timeout = d.timeout ?? 12e4;
|
|
14078
14116
|
const mintedKeyName = d.keyName?.(flags.agent);
|
|
14117
|
+
await assertConfigWritable(d.writeConfigDeps);
|
|
14079
14118
|
const state = d.generateState();
|
|
14080
14119
|
const codeVerifier = d.generateCodeVerifier();
|
|
14081
14120
|
const codeChallenge = deriveChallenge(codeVerifier);
|
|
@@ -14136,7 +14175,11 @@ async function handleAuthLogin(args, deps) {
|
|
|
14136
14175
|
keyName: mintedKeyName
|
|
14137
14176
|
}).then(async (apiKey) => {
|
|
14138
14177
|
if (settled) return;
|
|
14139
|
-
await writeConfig(
|
|
14178
|
+
await writeConfig(
|
|
14179
|
+
{ apiKey, baseUrl },
|
|
14180
|
+
d.writeConfigDeps,
|
|
14181
|
+
profileName
|
|
14182
|
+
);
|
|
14140
14183
|
settle(() => {
|
|
14141
14184
|
server.close();
|
|
14142
14185
|
resolve({ status: "logged_in", apiKey, profile: profileName });
|
|
@@ -14209,7 +14252,11 @@ async function handleAuthLogin(args, deps) {
|
|
|
14209
14252
|
keyName: mintedKeyName
|
|
14210
14253
|
});
|
|
14211
14254
|
if (settled) return;
|
|
14212
|
-
await writeConfig(
|
|
14255
|
+
await writeConfig(
|
|
14256
|
+
{ apiKey, baseUrl },
|
|
14257
|
+
d.writeConfigDeps,
|
|
14258
|
+
profileName
|
|
14259
|
+
);
|
|
14213
14260
|
settle(() => {
|
|
14214
14261
|
server.close();
|
|
14215
14262
|
resolve({ status: "logged_in", apiKey, profile: profileName });
|
|
@@ -14312,6 +14359,7 @@ async function handleAuthLoginNoBrowser(args, deps) {
|
|
|
14312
14359
|
const authUrl = flags["auth-url"] || DEFAULT_AUTH_URL;
|
|
14313
14360
|
const baseUrl = flags["base-url"] || DEFAULT_BASE_URL2;
|
|
14314
14361
|
const oobRedirectUrl = d.oobRedirectUrl || deriveOobRedirectUrl(authUrl);
|
|
14362
|
+
await assertConfigWritable(d.writeConfigDeps);
|
|
14315
14363
|
const state = d.generateState();
|
|
14316
14364
|
const codeVerifier = d.generateCodeVerifier();
|
|
14317
14365
|
const codeChallenge = deriveChallenge(codeVerifier);
|
|
@@ -14352,7 +14400,7 @@ async function handleAuthLoginNoBrowser(args, deps) {
|
|
|
14352
14400
|
fetch: d.fetch,
|
|
14353
14401
|
keyName: d.keyName?.(flags.agent)
|
|
14354
14402
|
});
|
|
14355
|
-
await writeConfig({ apiKey }, d.writeConfigDeps, profileName);
|
|
14403
|
+
await writeConfig({ apiKey, baseUrl }, d.writeConfigDeps, profileName);
|
|
14356
14404
|
return { status: "logged_in", apiKey, profile: profileName };
|
|
14357
14405
|
} catch (err) {
|
|
14358
14406
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -18044,7 +18092,7 @@ function formatTradingPairResolved(result) {
|
|
|
18044
18092
|
}
|
|
18045
18093
|
|
|
18046
18094
|
// src/cli/dispatch.ts
|
|
18047
|
-
var CLI_VERSION = true ? "0.38.0-beta.
|
|
18095
|
+
var CLI_VERSION = true ? "0.38.0-beta.2" : "dev";
|
|
18048
18096
|
var DEFAULT_RUN_TIMEOUT_MS = 6e5;
|
|
18049
18097
|
var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
|
|
18050
18098
|
var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
|
|
@@ -19532,6 +19580,7 @@ Create and update never rewrite text automatically.
|
|
|
19532
19580
|
|
|
19533
19581
|
Subcommands:
|
|
19534
19582
|
create Create a thesis
|
|
19583
|
+
asset-candidates Read catalog IDs and the directions publishing would store, without publishing
|
|
19535
19584
|
list Read theses by author or market entity
|
|
19536
19585
|
related Read related current publications
|
|
19537
19586
|
get Get one thesis
|
|
@@ -19539,6 +19588,7 @@ Subcommands:
|
|
|
19539
19588
|
version list List visible Updates with editorial revisions folded together
|
|
19540
19589
|
signals Read published Signal history
|
|
19541
19590
|
watchpoints List a Thesis's current watchpoints
|
|
19591
|
+
return Read the Thesis return
|
|
19542
19592
|
set-visibility Change current access without publishing a version
|
|
19543
19593
|
archive Archive the current author version
|
|
19544
19594
|
star Add the Thesis to your bookmarks
|
|
@@ -19557,11 +19607,12 @@ Body input (create, update, rewrite): choose exactly one:
|
|
|
19557
19607
|
Create and update require --request-id: a caller-supplied non-zero UUID. The
|
|
19558
19608
|
toolkit does not generate or retry request IDs. If a response is ambiguous
|
|
19559
19609
|
after a write, reuse the same request ID only after resolving that ambiguity with
|
|
19560
|
-
the backend; do not send a fresh ID. Create
|
|
19561
|
-
|
|
19610
|
+
the backend; do not send a fresh ID. Create and update require --visibility
|
|
19611
|
+
explicitly so neither can publish by accident. Create returns the Thesis's web
|
|
19612
|
+
url.
|
|
19562
19613
|
|
|
19563
19614
|
Other flags:
|
|
19564
|
-
create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>]
|
|
19615
|
+
create --request-id <uuid> --body ... [--images <json-array-of-https-urls>] [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] --visibility public|private [--track-return true|false] [--signal-kinds <kind,kind>] [--signal-min-importance all|notable|major]
|
|
19565
19616
|
Signals: omit both to show every Signal. Kinds: fundamentals, macro,
|
|
19566
19617
|
technicals, commentary; with only one flag the other keeps its default.
|
|
19567
19618
|
Images: public creation only, at most 20 in display order. Upload selected files
|
|
@@ -19585,6 +19636,8 @@ Other flags:
|
|
|
19585
19636
|
--no-discovery only classifies --entity-ids (no ticker discovery) and
|
|
19586
19637
|
returns returnPreview: the directions publishing would store, the return
|
|
19587
19638
|
switch (askSwitch) and lastLegRemoved. --thesis-id seeds an Update.
|
|
19639
|
+
A mention resolved UNRESOLVED or a direction UNKNOWN is an answer, not
|
|
19640
|
+
an error: the text names no catalog asset or no clear direction.
|
|
19588
19641
|
return --id <id> [--detail] the Thesis return; --detail adds each Update's positions
|
|
19589
19642
|
get --id <signed-int64-decimal>
|
|
19590
19643
|
version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
|
|
@@ -19650,7 +19703,7 @@ valid Unicode, and at most 65536 UTF-8 bytes; title is optional and at most
|
|
|
19650
19703
|
500 UTF-8 bytes. Text is passed without trimming or newline conversion.
|
|
19651
19704
|
|
|
19652
19705
|
Examples:
|
|
19653
|
-
alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two'
|
|
19706
|
+
alva thesis create --request-id 123e4567-e89b-42d3-a456-426614174000 --body $'line one\\r\\nline two' --visibility private
|
|
19654
19707
|
alva thesis set-visibility --id 9223372036854775807 --visibility private
|
|
19655
19708
|
alva thesis update --id 9223372036854775807 --request-id 123e4567-e89b-42d3-a456-426614174000 --expected-author-version-id 9223372036854775806 --body-file ./thesis.md --visibility private
|
|
19656
19709
|
printf '%s' 'Draft body' | alva thesis rewrite --body-stdin --mode shorten`
|
|
@@ -21248,7 +21301,9 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
|
|
|
21248
21301
|
entity_ids: thesisEntityIDs(flags),
|
|
21249
21302
|
entity_stances: thesisEntityStances(flags),
|
|
21250
21303
|
tickers: thesisTickers(flags),
|
|
21251
|
-
visibility:
|
|
21304
|
+
visibility: thesisCreateVisibility(
|
|
21305
|
+
requireFlag(flags, "visibility", "thesis create")
|
|
21306
|
+
),
|
|
21252
21307
|
track_return: thesisTrackReturn(flags, "thesis create"),
|
|
21253
21308
|
signal_preferences: thesisCreateSignalPreferences(flags)
|
|
21254
21309
|
});
|