@wayai/cli 0.3.348 → 0.3.350
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +301 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22453,12 +22453,13 @@ async function setWayToken(token) {
|
|
|
22453
22453
|
].join("\n")
|
|
22454
22454
|
);
|
|
22455
22455
|
}
|
|
22456
|
-
return;
|
|
22456
|
+
return "keyring";
|
|
22457
22457
|
} catch (err) {
|
|
22458
22458
|
console.warn(`wayai: keyring write failed (${err.message}); falling back to file storage.`);
|
|
22459
22459
|
}
|
|
22460
22460
|
}
|
|
22461
22461
|
writeFileFallback({ token });
|
|
22462
|
+
return "file";
|
|
22462
22463
|
}
|
|
22463
22464
|
async function setOAuthTokens(access_token, refresh_token, expires_at) {
|
|
22464
22465
|
const keyring = await getKeyring();
|
|
@@ -22470,13 +22471,14 @@ async function setOAuthTokens(access_token, refresh_token, expires_at) {
|
|
|
22470
22471
|
await keyring.setPassword(KEYRING_SERVICE, KEY_OAUTH_REFRESH, refresh_token);
|
|
22471
22472
|
}
|
|
22472
22473
|
writeMetadataExpiresAt(expires_at);
|
|
22473
|
-
return;
|
|
22474
|
+
return "keyring";
|
|
22474
22475
|
} catch (err) {
|
|
22475
22476
|
if (err instanceof StaleKeyringSlotError) throw err;
|
|
22476
22477
|
console.warn(`wayai: keyring write failed (${err.message}); falling back to file storage.`);
|
|
22477
22478
|
}
|
|
22478
22479
|
}
|
|
22479
22480
|
writeFileFallback({ access_token, refresh_token, token_expires_at: expires_at });
|
|
22481
|
+
return "file";
|
|
22480
22482
|
}
|
|
22481
22483
|
async function keyringMayHoldToken() {
|
|
22482
22484
|
const keyring = await getStrictKeyring();
|
|
@@ -22942,7 +22944,10 @@ function parseApiUrl(args2) {
|
|
|
22942
22944
|
}
|
|
22943
22945
|
function envTokenOverrideWarning(override2) {
|
|
22944
22946
|
if (!override2) return null;
|
|
22945
|
-
return "Warning: WAYAI_TOKEN is set in this shell and takes precedence over the
|
|
22947
|
+
return "Warning: WAYAI_TOKEN is set in this shell and takes precedence over the stored login, so commands will keep authenticating as that token \u2014 not the login you just completed. Run `unset WAYAI_TOKEN` to use it.";
|
|
22948
|
+
}
|
|
22949
|
+
function tokenStoredLine(location) {
|
|
22950
|
+
return location === "keyring" ? "Token stored in OS keyring; metadata at ~/.wayai/config.json" : "Token stored in ~/.wayai/config.json (file fallback: the OS keyring was unavailable)";
|
|
22946
22951
|
}
|
|
22947
22952
|
function missingRefreshTokenWarning(refreshToken) {
|
|
22948
22953
|
if (refreshToken) return null;
|
|
@@ -22996,10 +23001,10 @@ Open this URL in your browser to log in:
|
|
|
22996
23001
|
redirectUri
|
|
22997
23002
|
);
|
|
22998
23003
|
const expiresAt = expiresInToIso(tokens2.expires_in);
|
|
22999
|
-
await setOAuthTokens(tokens2.access_token, tokens2.refresh_token, expiresAt);
|
|
23004
|
+
const stored = await setOAuthTokens(tokens2.access_token, tokens2.refresh_token, expiresAt);
|
|
23000
23005
|
writeConfig({ api_url: apiUrl, token_expires_at: expiresAt });
|
|
23001
23006
|
console.log("\nLogin successful!");
|
|
23002
|
-
console.log(
|
|
23007
|
+
console.log(tokenStoredLine(stored));
|
|
23003
23008
|
const refreshWarning = missingRefreshTokenWarning(tokens2.refresh_token);
|
|
23004
23009
|
if (refreshWarning) console.warn(`
|
|
23005
23010
|
${refreshWarning}`);
|
|
@@ -23030,9 +23035,10 @@ async function loginWithToken(apiUrl) {
|
|
|
23030
23035
|
console.error(`Token validation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
23031
23036
|
process.exit(1);
|
|
23032
23037
|
}
|
|
23033
|
-
await setWayToken(token);
|
|
23038
|
+
const stored = await setWayToken(token);
|
|
23034
23039
|
writeConfig({ api_url: apiUrl });
|
|
23035
|
-
console.log(
|
|
23040
|
+
console.log(`
|
|
23041
|
+
Login successful! ${tokenStoredLine(stored)}`);
|
|
23036
23042
|
const overrideWarning = envTokenOverrideWarning(envTokenOverride());
|
|
23037
23043
|
if (overrideWarning) console.warn(`
|
|
23038
23044
|
${overrideWarning}`);
|
|
@@ -26335,7 +26341,7 @@ var init_helpers = __esm({
|
|
|
26335
26341
|
init_base_id();
|
|
26336
26342
|
init_expected();
|
|
26337
26343
|
init_utils();
|
|
26338
|
-
BASE_SECRET_STORAGE_WHY = "
|
|
26344
|
+
BASE_SECRET_STORAGE_WHY = "the credentials vault does not hold this kind of secret yet";
|
|
26339
26345
|
DURATION_RE = /^(\d+)([smhd])$/;
|
|
26340
26346
|
DURATION_UNIT_MS = {
|
|
26341
26347
|
s: 1e3,
|
|
@@ -26975,6 +26981,250 @@ var init_triggers = __esm({
|
|
|
26975
26981
|
}
|
|
26976
26982
|
});
|
|
26977
26983
|
|
|
26984
|
+
// src/data/commands/credentials.ts
|
|
26985
|
+
import { Command as Command2 } from "commander";
|
|
26986
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
26987
|
+
function withValueSourceOptions(cmd, what) {
|
|
26988
|
+
return cmd.option(
|
|
26989
|
+
"--file <path>",
|
|
26990
|
+
`Read ${what} from a file and base64-encode it (certificates, keystores, service-account JSON)`
|
|
26991
|
+
).option("--value-stdin", `Read ${what} from stdin (recommended for CI)`).option("--value-prompt", `Prompt for ${what}, masked`);
|
|
26992
|
+
}
|
|
26993
|
+
async function resolveValue(opts, label3) {
|
|
26994
|
+
if (opts.file !== void 0) {
|
|
26995
|
+
if (opts.valueStdin || opts.valuePrompt) {
|
|
26996
|
+
throw expected("--file cannot be combined with --value-stdin or --value-prompt \u2014 pass one.");
|
|
26997
|
+
}
|
|
26998
|
+
try {
|
|
26999
|
+
return readFileSync15(opts.file).toString("base64");
|
|
27000
|
+
} catch (e) {
|
|
27001
|
+
throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
|
|
27002
|
+
}
|
|
27003
|
+
}
|
|
27004
|
+
return readSecret(
|
|
27005
|
+
{
|
|
27006
|
+
stdin: opts.valueStdin,
|
|
27007
|
+
prompt: opts.valuePrompt,
|
|
27008
|
+
stdinFlag: "--value-stdin",
|
|
27009
|
+
promptHint: "--value-prompt"
|
|
27010
|
+
},
|
|
27011
|
+
label3
|
|
27012
|
+
);
|
|
27013
|
+
}
|
|
27014
|
+
function credentialPath(base, id) {
|
|
27015
|
+
const root = `/v1/${pathSegment(base, "base id")}/credentials`;
|
|
27016
|
+
return id === void 0 ? root : `${root}/${pathSegment(id, "credential id")}`;
|
|
27017
|
+
}
|
|
27018
|
+
function refusalReason(err) {
|
|
27019
|
+
const reason3 = dataErrorDetails(err)?.reason;
|
|
27020
|
+
return typeof reason3 === "string" ? reason3 : null;
|
|
27021
|
+
}
|
|
27022
|
+
async function assertStorageOn(client, path55, body) {
|
|
27023
|
+
try {
|
|
27024
|
+
await client.request("POST", path55, body);
|
|
27025
|
+
} catch (err) {
|
|
27026
|
+
if (refusalReason(err) === VALUE_MISSING) return;
|
|
27027
|
+
if (refusalReason(err) === STORAGE_OFF) {
|
|
27028
|
+
throw expected(`${refusalMessage(err)} Nothing was read or stored.`);
|
|
27029
|
+
}
|
|
27030
|
+
throw err;
|
|
27031
|
+
}
|
|
27032
|
+
throw new Error("The credential service accepted a request that carried no value.");
|
|
27033
|
+
}
|
|
27034
|
+
function refusalMessage(err) {
|
|
27035
|
+
return dataErrorMessage(err) ?? (err instanceof Error ? err.message : String(err));
|
|
27036
|
+
}
|
|
27037
|
+
function parseRule(raw) {
|
|
27038
|
+
return raw === void 0 ? void 0 : parseData(raw, "--rule");
|
|
27039
|
+
}
|
|
27040
|
+
function parseProposedSources(raw) {
|
|
27041
|
+
if (raw === void 0) return void 0;
|
|
27042
|
+
const parsed = parseData(raw, "--proposed-sources");
|
|
27043
|
+
if (!Array.isArray(parsed)) throw expected("--proposed-sources must be a JSON list of sources, as a record type carries them.");
|
|
27044
|
+
return parsed;
|
|
27045
|
+
}
|
|
27046
|
+
function statedFromStored(policy) {
|
|
27047
|
+
const scopes = policy?.scopes;
|
|
27048
|
+
if (!Array.isArray(scopes) || scopes.length === 0) return null;
|
|
27049
|
+
return {
|
|
27050
|
+
scopes: scopes.map((scope) => ({
|
|
27051
|
+
origin: scope.origin,
|
|
27052
|
+
path: scope.path,
|
|
27053
|
+
match: scope.match,
|
|
27054
|
+
methods: scope.methods
|
|
27055
|
+
}))
|
|
27056
|
+
};
|
|
27057
|
+
}
|
|
27058
|
+
function overStoredLimit(err) {
|
|
27059
|
+
if (refusalReason(err) !== RULE_REFUSED) return false;
|
|
27060
|
+
const refusals = dataErrorDetails(err)?.refusals;
|
|
27061
|
+
return Array.isArray(refusals) && refusals.some((r) => r?.code === "too_many_scopes" || r?.code === "policy_too_large");
|
|
27062
|
+
}
|
|
27063
|
+
function sourceNamesCredential(source, name) {
|
|
27064
|
+
const ref = `${CREDENTIAL_REF}${name}`;
|
|
27065
|
+
const s = source;
|
|
27066
|
+
if (s?.auth?.secret_ref === ref) return true;
|
|
27067
|
+
return (s?.injections ?? []).some((i) => i?.target === "header" && i.secret_ref === ref);
|
|
27068
|
+
}
|
|
27069
|
+
function isUncoveredCredentialRefusal(err) {
|
|
27070
|
+
return refusalReason(err) === RULE_NOT_COVERING;
|
|
27071
|
+
}
|
|
27072
|
+
function rotatableInRefusal(message) {
|
|
27073
|
+
const found = /* @__PURE__ */ new Map();
|
|
27074
|
+
for (const m of message.matchAll(/credential '([^']+)' \(POST …\/credentials\/([^/\s)]+)\/rotate\)/g)) {
|
|
27075
|
+
found.set(m[2], { id: m[2], name: m[1] });
|
|
27076
|
+
}
|
|
27077
|
+
return [...found.values()];
|
|
27078
|
+
}
|
|
27079
|
+
async function reenterRefusedCredentials(client, base, message, pushedSources) {
|
|
27080
|
+
const named = rotatableInRefusal(message);
|
|
27081
|
+
if (named.length === 0) return false;
|
|
27082
|
+
const held = await client.request("GET", credentialPath(base));
|
|
27083
|
+
const refused = named.filter((c) => (Array.isArray(held) ? held : []).some((row) => row.id === c.id && row.name === c.name && row.policy) && pushedSources.some((source) => sourceNamesCredential(source, c.name)));
|
|
27084
|
+
if (refused.length === 0) return false;
|
|
27085
|
+
if (!isInteractive()) {
|
|
27086
|
+
for (const c of refused) {
|
|
27087
|
+
console.error(
|
|
27088
|
+
`To send credential '${sanitizeTerminalText(c.name)}' there, enter its value again: run \`wayai push\` in a terminal, or \`wayai bases credentials rotate ${sanitizeTerminalText(c.id)} --base ${sanitizeTerminalText(base)} --value-stdin --proposed-sources @<file>\` with a JSON list of the sources in your files that place it, then push again.`
|
|
27089
|
+
);
|
|
27090
|
+
}
|
|
27091
|
+
return false;
|
|
27092
|
+
}
|
|
27093
|
+
for (const c of refused) {
|
|
27094
|
+
const name = sanitizeTerminalText(c.name);
|
|
27095
|
+
if (!await confirm(`Enter the value of credential '${name}' again, so it may go where this change sends it?`)) return false;
|
|
27096
|
+
const path55 = `${credentialPath(base, c.id)}/rotate`;
|
|
27097
|
+
await assertStorageOn(client, path55, {});
|
|
27098
|
+
const value = await readSecret(
|
|
27099
|
+
{ stdin: false, prompt: true, stdinFlag: "--value-stdin", promptHint: "--value-prompt" },
|
|
27100
|
+
`Value of credential '${name}'`
|
|
27101
|
+
);
|
|
27102
|
+
await client.request("POST", path55, {
|
|
27103
|
+
value,
|
|
27104
|
+
proposed_sources: pushedSources.filter((source) => sourceNamesCredential(source, c.name))
|
|
27105
|
+
});
|
|
27106
|
+
console.log(`Rotated credential '${name}': its rule now covers this change.`);
|
|
27107
|
+
}
|
|
27108
|
+
return true;
|
|
27109
|
+
}
|
|
27110
|
+
function buildBasesCredentialsCommand() {
|
|
27111
|
+
const credentials = withBaseOption(
|
|
27112
|
+
new Command2("credentials").description("Manage a base's integration credentials")
|
|
27113
|
+
);
|
|
27114
|
+
withValueSourceOptions(
|
|
27115
|
+
credentials.command("create").description(
|
|
27116
|
+
"Store a credential a source of this base names (value read from stdin, a masked prompt, or --file), with the rule derived from those sources"
|
|
27117
|
+
).requiredOption("--name <name>", "Credential name \u2014 what a credential:<name> reference resolves").option("--content-type <mime>", "MIME type of the value (e.g. application/x-pkcs12)").option(
|
|
27118
|
+
"--expires-at <date>",
|
|
27119
|
+
"Expiry as ISO-8601 (e.g. 2027-01-01T00:00:00Z) \u2014 informational; nothing is auto-disabled"
|
|
27120
|
+
).option(
|
|
27121
|
+
"--rule <json>",
|
|
27122
|
+
'A wider rule than the derived one, inline or @file: {"scopes":[{"origin","path","match":"prefix"|"exact","methods"}]}'
|
|
27123
|
+
),
|
|
27124
|
+
"the credential value"
|
|
27125
|
+
).action(async function(opts) {
|
|
27126
|
+
const base = requireBase(this);
|
|
27127
|
+
const rule = parseRule(opts.rule);
|
|
27128
|
+
const client = await createDataClient();
|
|
27129
|
+
await assertStorageOn(client, credentialPath(base), { name: opts.name });
|
|
27130
|
+
const body = {
|
|
27131
|
+
name: opts.name,
|
|
27132
|
+
value: await resolveValue(opts, "Credential value")
|
|
27133
|
+
};
|
|
27134
|
+
if (opts.contentType) body.content_type = opts.contentType;
|
|
27135
|
+
if (opts.expiresAt) body.expires_at = opts.expiresAt;
|
|
27136
|
+
if (rule) body.rule = rule;
|
|
27137
|
+
printOutput(await client.request("POST", credentialPath(base), body), outputFormat(this));
|
|
27138
|
+
});
|
|
27139
|
+
credentials.command("list").description("List this base's credentials and the rule each was stored with (values are never returned)").action(async function() {
|
|
27140
|
+
const base = requireBase(this);
|
|
27141
|
+
const client = await createDataClient();
|
|
27142
|
+
printOutput(
|
|
27143
|
+
await client.request("GET", credentialPath(base)),
|
|
27144
|
+
outputFormat(this)
|
|
27145
|
+
);
|
|
27146
|
+
});
|
|
27147
|
+
credentials.command("get <id>").description("Get credential metadata and its stored rule (the value is never returned)").action(async function(id) {
|
|
27148
|
+
const base = requireBase(this);
|
|
27149
|
+
const client = await createDataClient();
|
|
27150
|
+
printOutput(
|
|
27151
|
+
await client.request("GET", credentialPath(base, id)),
|
|
27152
|
+
outputFormat(this)
|
|
27153
|
+
);
|
|
27154
|
+
});
|
|
27155
|
+
withValueSourceOptions(
|
|
27156
|
+
credentials.command("rotate <id>").description("Enter a new value, under the rule derived again from the sources (never auto-generates)").option("--expires-at <date>", "Set the rotated credential's new expiry (ISO-8601)").option("--rule <json>", "A wider rule than the derived one, inline or @file (as create takes it)").option("--keep-rule", "State the rule the credential is stored with again, as the wider rule").option(
|
|
27157
|
+
"--proposed-sources <json>",
|
|
27158
|
+
"Sources a refused save proposed, as a JSON list, inline or @file: the rule then covers them too (no source is saved)"
|
|
27159
|
+
),
|
|
27160
|
+
"the new credential value"
|
|
27161
|
+
).action(async function(id, opts) {
|
|
27162
|
+
const base = requireBase(this);
|
|
27163
|
+
if (opts.rule !== void 0 && opts.keepRule) throw expected("--rule cannot be combined with --keep-rule \u2014 pass one.");
|
|
27164
|
+
let rule = parseRule(opts.rule);
|
|
27165
|
+
const proposed = parseProposedSources(opts.proposedSources);
|
|
27166
|
+
const client = await createDataClient();
|
|
27167
|
+
const path55 = `${credentialPath(base, id)}/rotate`;
|
|
27168
|
+
await assertStorageOn(client, path55, {});
|
|
27169
|
+
const storedRule = async () => statedFromStored((await client.request("GET", credentialPath(base, id)))?.policy);
|
|
27170
|
+
if (opts.keepRule) {
|
|
27171
|
+
rule = await storedRule() ?? void 0;
|
|
27172
|
+
if (!rule) throw expected("This credential holds no stored rule to keep. Nothing was read or stored.");
|
|
27173
|
+
}
|
|
27174
|
+
const body = { value: await resolveValue(opts, "New credential value") };
|
|
27175
|
+
if (opts.expiresAt) body.expires_at = opts.expiresAt;
|
|
27176
|
+
if (rule) body.rule = rule;
|
|
27177
|
+
if (proposed) body.proposed_sources = proposed;
|
|
27178
|
+
try {
|
|
27179
|
+
printOutput(await client.request("POST", path55, body), outputFormat(this));
|
|
27180
|
+
} catch (err) {
|
|
27181
|
+
if (!rule && overStoredLimit(err) && await storedRule()) {
|
|
27182
|
+
throw expected(
|
|
27183
|
+
`${refusalMessage(err)} It is stored under a wider rule: if that rule still covers every use the sources make, run the rotation again with --keep-rule to state it again; otherwise pass --rule with one that does.`
|
|
27184
|
+
);
|
|
27185
|
+
}
|
|
27186
|
+
throw err;
|
|
27187
|
+
}
|
|
27188
|
+
});
|
|
27189
|
+
credentials.command("set-sync <id>").description("Set the promote-time publish flag \u2014 has no effect: promotion carries no credential").option("--no-sync-to-production", "Do not publish this credential on promote (has no effect)").action(() => {
|
|
27190
|
+
throw expected("Promotion carries no base credential, so the publish flag has no effect. Nothing was changed.");
|
|
27191
|
+
});
|
|
27192
|
+
credentials.command("delete <id>").description("Delete a direct credential").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
27193
|
+
const base = requireBase(this);
|
|
27194
|
+
if (!opts.yes) {
|
|
27195
|
+
if (!isInteractive()) {
|
|
27196
|
+
throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
|
|
27197
|
+
}
|
|
27198
|
+
if (!await confirm(`Delete credential ${id} on base ${base}? This cannot be undone.`)) {
|
|
27199
|
+
console.log("Aborted");
|
|
27200
|
+
return;
|
|
27201
|
+
}
|
|
27202
|
+
}
|
|
27203
|
+
const client = await createDataClient();
|
|
27204
|
+
await client.request("DELETE", credentialPath(base, id));
|
|
27205
|
+
printOutput({ id, deleted: true }, outputFormat(this));
|
|
27206
|
+
});
|
|
27207
|
+
return credentials;
|
|
27208
|
+
}
|
|
27209
|
+
var STORAGE_OFF, VALUE_MISSING, RULE_NOT_COVERING, RULE_REFUSED, CREDENTIAL_REF;
|
|
27210
|
+
var init_credentials = __esm({
|
|
27211
|
+
"src/data/commands/credentials.ts"() {
|
|
27212
|
+
"use strict";
|
|
27213
|
+
init_api_client();
|
|
27214
|
+
init_client();
|
|
27215
|
+
init_output();
|
|
27216
|
+
init_helpers();
|
|
27217
|
+
init_utils();
|
|
27218
|
+
init_expected();
|
|
27219
|
+
init_terminal_output();
|
|
27220
|
+
STORAGE_OFF = "secret_storage_unavailable";
|
|
27221
|
+
VALUE_MISSING = "credential_value_not_storable";
|
|
27222
|
+
RULE_NOT_COVERING = "credential_rule_not_covering";
|
|
27223
|
+
RULE_REFUSED = "credential_rule_refused";
|
|
27224
|
+
CREDENTIAL_REF = "credential:";
|
|
27225
|
+
}
|
|
27226
|
+
});
|
|
27227
|
+
|
|
26978
27228
|
// src/data/config-as-code/sync.ts
|
|
26979
27229
|
var sync_exports = {};
|
|
26980
27230
|
__export(sync_exports, {
|
|
@@ -27016,6 +27266,19 @@ async function mirrorLinkedProduction(client, basesDir, originId) {
|
|
|
27016
27266
|
);
|
|
27017
27267
|
}
|
|
27018
27268
|
}
|
|
27269
|
+
async function applyRefusedCredentialsAgain(client, baseId, config) {
|
|
27270
|
+
try {
|
|
27271
|
+
return await applyConfig(client, baseId, config);
|
|
27272
|
+
} catch (err) {
|
|
27273
|
+
if (!isUncoveredCredentialRefusal(err)) throw err;
|
|
27274
|
+
const message = refusalMessage(err);
|
|
27275
|
+
console.error(`
|
|
27276
|
+
${RED}${sanitizeTerminalText(message)}${RESET}`);
|
|
27277
|
+
const sources = config.record_types.flatMap((rt) => rt.sources ?? []);
|
|
27278
|
+
if (!await reenterRefusedCredentials(client, baseId, message, sources)) throw err;
|
|
27279
|
+
return applyConfig(client, baseId, config);
|
|
27280
|
+
}
|
|
27281
|
+
}
|
|
27019
27282
|
async function pullBase(gitRootOrNull, selector, args2) {
|
|
27020
27283
|
const { autoConfirm } = parseArgs5(args2);
|
|
27021
27284
|
const gitRoot = requireGitRoot(gitRootOrNull);
|
|
@@ -27158,7 +27421,7 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
|
|
|
27158
27421
|
return;
|
|
27159
27422
|
}
|
|
27160
27423
|
}
|
|
27161
|
-
const result = await
|
|
27424
|
+
const result = await applyRefusedCredentialsAgain(client, baseId, config);
|
|
27162
27425
|
warnUnsignedTriggers(result.unsigned_triggers);
|
|
27163
27426
|
const removals = collectRemovals(diff);
|
|
27164
27427
|
if (removals.length > 0) {
|
|
@@ -27202,6 +27465,7 @@ var init_sync = __esm({
|
|
|
27202
27465
|
init_base_workspace();
|
|
27203
27466
|
init_types2();
|
|
27204
27467
|
init_triggers();
|
|
27468
|
+
init_credentials();
|
|
27205
27469
|
}
|
|
27206
27470
|
});
|
|
27207
27471
|
|
|
@@ -36787,7 +37051,7 @@ var init_eval_results = __esm({
|
|
|
36787
37051
|
|
|
36788
37052
|
// src/lib/call-eval/caller-audio.ts
|
|
36789
37053
|
import { createHash as createHash4 } from "crypto";
|
|
36790
|
-
import { mkdirSync as mkdirSync16, readFileSync as
|
|
37054
|
+
import { mkdirSync as mkdirSync16, readFileSync as readFileSync19, renameSync as renameSync8, writeFileSync as writeFileSync9 } from "fs";
|
|
36791
37055
|
import { homedir as homedir6 } from "os";
|
|
36792
37056
|
import { dirname as dirname18, isAbsolute as isAbsolute2, join as join40, resolve as resolve16 } from "path";
|
|
36793
37057
|
function parseWav(buf, name = "clip") {
|
|
@@ -36881,7 +37145,7 @@ var init_caller_audio = __esm({
|
|
|
36881
37145
|
if (!path55) throw new Error(`Line ${line.n} has no clip: give --clips <dir>, or a "clip" for it in the plan.`);
|
|
36882
37146
|
let buf;
|
|
36883
37147
|
try {
|
|
36884
|
-
buf =
|
|
37148
|
+
buf = readFileSync19(path55);
|
|
36885
37149
|
} catch {
|
|
36886
37150
|
throw new Error(`Line ${line.n}'s clip ${path55} cannot be read.`);
|
|
36887
37151
|
}
|
|
@@ -36925,7 +37189,7 @@ ${text5}`).digest("hex");
|
|
|
36925
37189
|
}
|
|
36926
37190
|
async readOrSynthesize(line, path55) {
|
|
36927
37191
|
try {
|
|
36928
|
-
return pcmClip(
|
|
37192
|
+
return pcmClip(readFileSync19(path55));
|
|
36929
37193
|
} catch {
|
|
36930
37194
|
}
|
|
36931
37195
|
const res = await this.doFetch("https://api.openai.com/v1/audio/speech", {
|
|
@@ -38431,7 +38695,7 @@ __export(eval_call_exports, {
|
|
|
38431
38695
|
printEvalCallHelp: () => printEvalCallHelp,
|
|
38432
38696
|
suiteExitCode: () => suiteExitCode
|
|
38433
38697
|
});
|
|
38434
|
-
import { accessSync, constants as fsConstants, existsSync as existsSync17, readFileSync as
|
|
38698
|
+
import { accessSync, constants as fsConstants, existsSync as existsSync17, readFileSync as readFileSync20, statSync as statSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
38435
38699
|
import { dirname as dirname19, resolve as resolve17 } from "path";
|
|
38436
38700
|
function fail(message) {
|
|
38437
38701
|
throw new Error(message);
|
|
@@ -38589,7 +38853,7 @@ async function evalCallCommand(argv) {
|
|
|
38589
38853
|
let plan;
|
|
38590
38854
|
try {
|
|
38591
38855
|
options = parseEvalCallArgs(args2);
|
|
38592
|
-
plan = options.planPath ? parseCallPlan(JSON.parse(
|
|
38856
|
+
plan = options.planPath ? parseCallPlan(JSON.parse(readFileSync20(options.planPath, "utf8"))) : { lines: {} };
|
|
38593
38857
|
} catch (err) {
|
|
38594
38858
|
console.error(extractApiMessage(err));
|
|
38595
38859
|
process.exit(1);
|
|
@@ -45256,7 +45520,7 @@ var init_file_map = __esm({
|
|
|
45256
45520
|
});
|
|
45257
45521
|
|
|
45258
45522
|
// ../../packages/core/dist/contracts/vault.js
|
|
45259
|
-
var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, VAULT_BASE_SOURCE_MAX_REFS, VAULT_VALUE_MAX_BYTES, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, GITHUB_APP_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultMetaResponseSchema, vaultRefreshResponseSchema, vaultMintResponseSchema, vaultSignEnvelopeSchema, VAULT_SIGN_MAX_BODY_BYTES, vaultSignResponseSchema;
|
|
45523
|
+
var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, VAULT_BASE_SOURCE_MAX_REFS, VAULT_VALUE_MAX_BYTES, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, GITHUB_APP_VAULT_GATE_ID, BASE_SOURCE_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultMetaResponseSchema, vaultRefreshResponseSchema, vaultMintResponseSchema, vaultSignEnvelopeSchema, VAULT_SIGN_MAX_BODY_BYTES, vaultSignResponseSchema;
|
|
45260
45524
|
var init_vault = __esm({
|
|
45261
45525
|
"../../packages/core/dist/contracts/vault.js"() {
|
|
45262
45526
|
"use strict";
|
|
@@ -45327,6 +45591,7 @@ var init_vault = __esm({
|
|
|
45327
45591
|
vaultAutomationStaticEnvelopeSchema = external_exports.object({}).strict();
|
|
45328
45592
|
AUTOMATION_WEBHOOK_VAULT_GATE_ID = "c2d6f1a4-7e3b-4f1a-9b8d-6a1f4e7c3b20";
|
|
45329
45593
|
GITHUB_APP_VAULT_GATE_ID = "fff3a999-e46a-483d-a50b-ab9d01bcb707";
|
|
45594
|
+
BASE_SOURCE_VAULT_GATE_ID = "bdf54b42-0f2c-4627-8474-a442f725d0ce";
|
|
45330
45595
|
vaultVerifyResponseSchema = external_exports.object({});
|
|
45331
45596
|
vaultVersionSchema = external_exports.number().int().positive();
|
|
45332
45597
|
vaultPutResponseSchema = external_exports.object({ version: vaultVersionSchema });
|
|
@@ -47688,7 +47953,7 @@ Usage:
|
|
|
47688
47953
|
|
|
47689
47954
|
wayai admin vault-gate status [--json] Print the vault_connector_ids list (on production it decides only Instagram's and base credentials' gates: the backend's vault-gate.ts)
|
|
47690
47955
|
wayai admin vault-gate add <connector> [--yes] [--json]
|
|
47691
|
-
List a connector: a vault connector's name (e.g. telegram, whatsapp, instagram, or openai for its LLM, STT and TTS ids, never GPT-Live's) or one catalog id (GPT-Live's only so); prints before and after, confirms unless --yes
|
|
47956
|
+
List a connector: a vault connector's name (e.g. telegram, whatsapp, instagram, base_source for new base credentials, or openai for its LLM, STT and TTS ids, never GPT-Live's) or one catalog id (GPT-Live's only so); prints before and after, confirms unless --yes
|
|
47692
47957
|
wayai admin vault-gate remove <connector> [--yes] [--json]
|
|
47693
47958
|
Stop listing it: its new credentials no longer go to the vault (on production only Instagram's and base credentials' gates read the list)
|
|
47694
47959
|
|
|
@@ -47938,7 +48203,8 @@ var init_admin = __esm({
|
|
|
47938
48203
|
["resend", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000001"]],
|
|
47939
48204
|
["claude_managed_agents", ["4b8eeecf-a835-444a-abed-516d0a29cee2"]],
|
|
47940
48205
|
["github_app", [GITHUB_APP_VAULT_GATE_ID]],
|
|
47941
|
-
["api_channel", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000003"]]
|
|
48206
|
+
["api_channel", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000003"]],
|
|
48207
|
+
["base_source", [BASE_SOURCE_VAULT_GATE_ID]]
|
|
47942
48208
|
]);
|
|
47943
48209
|
VAULT_GATE_BY_ID_ONLY = /* @__PURE__ */ new Map([
|
|
47944
48210
|
["01e7b19c-bc94-43f4-a780-ad5a22fb7127", "openai"]
|
|
@@ -48410,9 +48676,9 @@ var init_update = __esm({
|
|
|
48410
48676
|
});
|
|
48411
48677
|
|
|
48412
48678
|
// src/data/commands/actions.ts
|
|
48413
|
-
import { Command as
|
|
48679
|
+
import { Command as Command3 } from "commander";
|
|
48414
48680
|
function buildActionsCommand() {
|
|
48415
|
-
const actions = new
|
|
48681
|
+
const actions = new Command3("actions").description(
|
|
48416
48682
|
"Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
|
|
48417
48683
|
);
|
|
48418
48684
|
actions.command("upsert <id>").description(
|
|
@@ -48481,8 +48747,8 @@ var init_actions = __esm({
|
|
|
48481
48747
|
});
|
|
48482
48748
|
|
|
48483
48749
|
// src/data/commands/attachments.ts
|
|
48484
|
-
import { Command as
|
|
48485
|
-
import { readFileSync as
|
|
48750
|
+
import { Command as Command4 } from "commander";
|
|
48751
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
48486
48752
|
function findAttachmentByFilename(attachments, filename) {
|
|
48487
48753
|
return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
|
|
48488
48754
|
}
|
|
@@ -48508,7 +48774,7 @@ function uploadPathFrom(uploadUrl) {
|
|
|
48508
48774
|
return uploadUrl;
|
|
48509
48775
|
}
|
|
48510
48776
|
function buildAttachmentsCommand() {
|
|
48511
|
-
const attachments = new
|
|
48777
|
+
const attachments = new Command4("attachments").description("Manage record attachments");
|
|
48512
48778
|
attachments.command("upload <record_type> <id>").description(
|
|
48513
48779
|
"Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
|
|
48514
48780
|
).requiredOption("--filename <name>", "File name or path (e.g. docs/guide.md)").option("--content-type <type>", "MIME type", "application/octet-stream").option("--file <path>", "Local file to upload (skips presigned URL output, uploads directly)").action(async function(recordType2, id, opts) {
|
|
@@ -48523,7 +48789,7 @@ function buildAttachmentsCommand() {
|
|
|
48523
48789
|
printOutput(data, outputFormat(this));
|
|
48524
48790
|
return;
|
|
48525
48791
|
}
|
|
48526
|
-
const body =
|
|
48792
|
+
const body = readFileSync23(opts.file);
|
|
48527
48793
|
await client.upload(uploadPathFrom(data?.upload_url), body, opts.contentType);
|
|
48528
48794
|
printOutput({ ...data, uploaded: true }, outputFormat(this));
|
|
48529
48795
|
});
|
|
@@ -48588,9 +48854,9 @@ var init_attachments = __esm({
|
|
|
48588
48854
|
});
|
|
48589
48855
|
|
|
48590
48856
|
// src/data/commands/batch.ts
|
|
48591
|
-
import { Command as
|
|
48857
|
+
import { Command as Command5 } from "commander";
|
|
48592
48858
|
function buildBasesBatchCommand() {
|
|
48593
|
-
return withBaseOption(new
|
|
48859
|
+
return withBaseOption(new Command5("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
|
|
48594
48860
|
const base = pathSegment(requireBase(this), "--base");
|
|
48595
48861
|
const operations = parseData(opts.operations, "--operations");
|
|
48596
48862
|
const client = await createDataClient();
|
|
@@ -48619,7 +48885,7 @@ import { createReadStream } from "fs";
|
|
|
48619
48885
|
import { access, constants as constants2, stat } from "fs/promises";
|
|
48620
48886
|
import { createInterface as createInterface3 } from "readline";
|
|
48621
48887
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
48622
|
-
import { Command as
|
|
48888
|
+
import { Command as Command6 } from "commander";
|
|
48623
48889
|
function isRetryable(err) {
|
|
48624
48890
|
if (isNetworkError(err)) return true;
|
|
48625
48891
|
if (!(err instanceof ApiError)) return false;
|
|
@@ -48695,7 +48961,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
|
|
|
48695
48961
|
return res.session;
|
|
48696
48962
|
}
|
|
48697
48963
|
function buildBasesImportCommand() {
|
|
48698
|
-
const importCmd = withBaseOption(new
|
|
48964
|
+
const importCmd = withBaseOption(new Command6("import")).description(
|
|
48699
48965
|
"Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
|
|
48700
48966
|
);
|
|
48701
48967
|
importCmd.command("run <record_type>").description(
|
|
@@ -48939,7 +49205,7 @@ var init_import = __esm({
|
|
|
48939
49205
|
});
|
|
48940
49206
|
|
|
48941
49207
|
// src/data/commands/providers.ts
|
|
48942
|
-
import { Command as
|
|
49208
|
+
import { Command as Command7 } from "commander";
|
|
48943
49209
|
import { writeFileSync as writeFileSync13 } from "fs";
|
|
48944
49210
|
function providerSegment(provider) {
|
|
48945
49211
|
if (!VALID_PROVIDERS.includes(provider)) {
|
|
@@ -48948,7 +49214,7 @@ function providerSegment(provider) {
|
|
|
48948
49214
|
return pathSegment(provider, "provider");
|
|
48949
49215
|
}
|
|
48950
49216
|
function buildBasesProvidersCommand() {
|
|
48951
|
-
const providers = withBaseOption(new
|
|
49217
|
+
const providers = withBaseOption(new Command7("providers")).description(
|
|
48952
49218
|
"Import/export tool definitions between LLM providers and record types"
|
|
48953
49219
|
);
|
|
48954
49220
|
providers.command("import <provider>").description(`Import tool definitions as record types. Providers: ${VALID_PROVIDERS_HELP}`).requiredOption("--tools <json>", "Tool definitions (inline JSON or @filename)").action(async function(provider, opts) {
|
|
@@ -49018,83 +49284,9 @@ var init_providers = __esm({
|
|
|
49018
49284
|
}
|
|
49019
49285
|
});
|
|
49020
49286
|
|
|
49021
|
-
// src/data/commands/credentials.ts
|
|
49022
|
-
import { Command as Command7 } from "commander";
|
|
49023
|
-
function withValueSourceOptions(cmd, what) {
|
|
49024
|
-
return cmd.option("--file <path>", `Read ${what} from a file (unavailable for now)`).option("--value-stdin", `Read ${what} from stdin (unavailable for now)`).option("--value-prompt", `Prompt for ${what}, masked (unavailable for now)`);
|
|
49025
|
-
}
|
|
49026
|
-
function credentialPath(base, id) {
|
|
49027
|
-
const root = `/v1/${pathSegment(base, "base id")}/credentials`;
|
|
49028
|
-
return id === void 0 ? root : `${root}/${pathSegment(id, "credential id")}`;
|
|
49029
|
-
}
|
|
49030
|
-
function buildBasesCredentialsCommand() {
|
|
49031
|
-
const credentials = withBaseOption(
|
|
49032
|
-
new Command7("credentials").description("Manage a base's integration credentials")
|
|
49033
|
-
);
|
|
49034
|
-
withValueSourceOptions(
|
|
49035
|
-
credentials.command("create").description("Store a credential on this base \u2014 unavailable for now").option("--name <name>", "Credential name").option("--content-type <mime>", "MIME type of the value").option("--expires-at <date>", "Expiry as ISO-8601").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)"),
|
|
49036
|
-
"the credential value"
|
|
49037
|
-
).action(() => {
|
|
49038
|
-
throw expected(STORAGE_UNAVAILABLE);
|
|
49039
|
-
});
|
|
49040
|
-
credentials.command("list").description("List this base's credentials (values are never returned)").action(async function() {
|
|
49041
|
-
const base = requireBase(this);
|
|
49042
|
-
const client = await createDataClient();
|
|
49043
|
-
printOutput(
|
|
49044
|
-
await client.request("GET", credentialPath(base)),
|
|
49045
|
-
outputFormat(this)
|
|
49046
|
-
);
|
|
49047
|
-
});
|
|
49048
|
-
credentials.command("get <id>").description("Get credential metadata (the value is never returned)").action(async function(id) {
|
|
49049
|
-
const base = requireBase(this);
|
|
49050
|
-
const client = await createDataClient();
|
|
49051
|
-
printOutput(
|
|
49052
|
-
await client.request("GET", credentialPath(base, id)),
|
|
49053
|
-
outputFormat(this)
|
|
49054
|
-
);
|
|
49055
|
-
});
|
|
49056
|
-
withValueSourceOptions(
|
|
49057
|
-
credentials.command("rotate <id>").description("Install a new value \u2014 unavailable for now").option("--expires-at <date>", "Set the rotated credential's new expiry (ISO-8601)"),
|
|
49058
|
-
"the new credential value"
|
|
49059
|
-
).action(() => {
|
|
49060
|
-
throw expected(STORAGE_UNAVAILABLE);
|
|
49061
|
-
});
|
|
49062
|
-
credentials.command("set-sync <id>").description("Set the promote-time publish flag \u2014 unavailable for now: promotion carries no credential").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)").action(() => {
|
|
49063
|
-
throw expected("Promotion carries no base credential for now, so the publish flag has no effect. Nothing was changed.");
|
|
49064
|
-
});
|
|
49065
|
-
credentials.command("delete <id>").description("Delete a direct credential").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
49066
|
-
const base = requireBase(this);
|
|
49067
|
-
if (!opts.yes) {
|
|
49068
|
-
if (!isInteractive()) {
|
|
49069
|
-
throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
|
|
49070
|
-
}
|
|
49071
|
-
if (!await confirm(`Delete credential ${id} on base ${base}? This cannot be undone.`)) {
|
|
49072
|
-
console.log("Aborted");
|
|
49073
|
-
return;
|
|
49074
|
-
}
|
|
49075
|
-
}
|
|
49076
|
-
const client = await createDataClient();
|
|
49077
|
-
await client.request("DELETE", credentialPath(base, id));
|
|
49078
|
-
printOutput({ id, deleted: true }, outputFormat(this));
|
|
49079
|
-
});
|
|
49080
|
-
return credentials;
|
|
49081
|
-
}
|
|
49082
|
-
var STORAGE_UNAVAILABLE;
|
|
49083
|
-
var init_credentials = __esm({
|
|
49084
|
-
"src/data/commands/credentials.ts"() {
|
|
49085
|
-
"use strict";
|
|
49086
|
-
init_client();
|
|
49087
|
-
init_output();
|
|
49088
|
-
init_helpers();
|
|
49089
|
-
init_utils();
|
|
49090
|
-
init_expected();
|
|
49091
|
-
STORAGE_UNAVAILABLE = `Storing a base credential is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
|
|
49092
|
-
}
|
|
49093
|
-
});
|
|
49094
|
-
|
|
49095
49287
|
// src/data/commands/sql.ts
|
|
49096
49288
|
import { Command as Command8 } from "commander";
|
|
49097
|
-
import { readFileSync as
|
|
49289
|
+
import { readFileSync as readFileSync24 } from "fs";
|
|
49098
49290
|
function buildBasesSqlCommand() {
|
|
49099
49291
|
return withBaseOption(new Command8("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
|
|
49100
49292
|
"--param <kv...>",
|
|
@@ -49104,7 +49296,7 @@ function buildBasesSqlCommand() {
|
|
|
49104
49296
|
let query;
|
|
49105
49297
|
if (opts.file) {
|
|
49106
49298
|
try {
|
|
49107
|
-
query =
|
|
49299
|
+
query = readFileSync24(opts.file, "utf-8").trim();
|
|
49108
49300
|
} catch (e) {
|
|
49109
49301
|
throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
|
|
49110
49302
|
}
|
|
@@ -49783,7 +49975,7 @@ var init_file_types = __esm({
|
|
|
49783
49975
|
|
|
49784
49976
|
// src/data/commands/files.ts
|
|
49785
49977
|
import { Command as Command12 } from "commander";
|
|
49786
|
-
import { readFileSync as
|
|
49978
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
|
|
49787
49979
|
import { basename as basename31 } from "path";
|
|
49788
49980
|
function renderFileDiff(fileType, filePath3, from, to, d) {
|
|
49789
49981
|
console.log(sanitizeTerminalText(`${fileType}/${filePath3}: v${from} \u2192 v${to}`));
|
|
@@ -49840,7 +50032,7 @@ function buildFilesCommand() {
|
|
|
49840
50032
|
label: opts.label,
|
|
49841
50033
|
metadata: opts.metadata === void 0 ? void 0 : parseData(opts.metadata, "--metadata")
|
|
49842
50034
|
});
|
|
49843
|
-
const body =
|
|
50035
|
+
const body = readFileSync25(opts.file);
|
|
49844
50036
|
const client = await createDataClient();
|
|
49845
50037
|
printOutput(
|
|
49846
50038
|
await client.upload(
|
|
@@ -50803,7 +50995,7 @@ init_errors3();
|
|
|
50803
50995
|
init_mask_secrets();
|
|
50804
50996
|
init_utils();
|
|
50805
50997
|
init_registry();
|
|
50806
|
-
import { readFileSync as
|
|
50998
|
+
import { readFileSync as readFileSync26 } from "fs";
|
|
50807
50999
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
50808
51000
|
import { dirname as dirname22, join as join49 } from "path";
|
|
50809
51001
|
|
|
@@ -50961,7 +51153,7 @@ Run \`wayai admin skill install\` to update.`);
|
|
|
50961
51153
|
|
|
50962
51154
|
// src/index.ts
|
|
50963
51155
|
var __dirname = dirname22(fileURLToPath2(import.meta.url));
|
|
50964
|
-
var pkg = JSON.parse(
|
|
51156
|
+
var pkg = JSON.parse(readFileSync26(join49(__dirname, "..", "package.json"), "utf-8"));
|
|
50965
51157
|
var [, , command, ...args] = process.argv;
|
|
50966
51158
|
var isBackgroundRefresh = command === REFRESH_COMMAND;
|
|
50967
51159
|
if (!isBackgroundRefresh) initSentry(command, pkg.version);
|