@tangle-network/agent-app 0.45.25 → 0.45.27
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/assistant/index.js +5 -5
- package/dist/chat-routes/index.js +21 -21
- package/dist/chat-store/index.js +2 -2
- package/dist/{chunk-B2UEW62O.js → chunk-5ZTFZBS6.js} +4 -4
- package/dist/chunk-N3G3FSM4.js +509 -0
- package/dist/chunk-N3G3FSM4.js.map +1 -0
- package/dist/chunk-NEJ7OMQS.js +351 -0
- package/dist/chunk-NEJ7OMQS.js.map +1 -0
- package/dist/{chunk-KOMP6NDW.js → chunk-ODYE4A7L.js} +6 -6
- package/dist/{chunk-7V2I3JGZ.js → chunk-OTLEYHOG.js} +50 -12
- package/dist/chunk-OTLEYHOG.js.map +1 -0
- package/dist/chunk-WD2B6HGY.js +1046 -0
- package/dist/chunk-WD2B6HGY.js.map +1 -0
- package/dist/design-canvas-react/index.js +4 -4
- package/dist/run-tEsZUhAf.d.ts +40 -0
- package/dist/sandbox/index.d.ts +53 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/signoff/cli.d.ts +12 -0
- package/dist/signoff/cli.js +166 -0
- package/dist/signoff/cli.js.map +1 -0
- package/dist/signoff/index.d.ts +430 -0
- package/dist/signoff/index.js +63 -0
- package/dist/signoff/index.js.map +1 -0
- package/dist/signoff/proof-cli.d.ts +1 -0
- package/dist/signoff/proof-cli.js +92 -0
- package/dist/signoff/proof-cli.js.map +1 -0
- package/dist/signoff/proof.d.ts +515 -0
- package/dist/signoff/proof.js +148 -0
- package/dist/signoff/proof.js.map +1 -0
- package/dist/spend/cli.d.ts +1 -0
- package/dist/spend/cli.js +119 -0
- package/dist/spend/cli.js.map +1 -0
- package/dist/spend/index.d.ts +640 -0
- package/dist/spend/index.js +196 -0
- package/dist/spend/index.js.map +1 -0
- package/dist/stream/index.js +14 -14
- package/dist/teams/index.js +9 -9
- package/dist/teams/invitations-api.js +7 -7
- package/dist/types-U7Nz-txa.d.ts +233 -0
- package/dist/web-react/index.js +11 -11
- package/package.json +22 -3
- package/dist/chunk-7V2I3JGZ.js.map +0 -1
- /package/dist/{chunk-B2UEW62O.js.map → chunk-5ZTFZBS6.js.map} +0 -0
- /package/dist/{chunk-KOMP6NDW.js.map → chunk-ODYE4A7L.js.map} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
formatSpendReport,
|
|
4
|
+
reconcileSpend,
|
|
5
|
+
spendReportToJson
|
|
6
|
+
} from "../chunk-NEJ7OMQS.js";
|
|
7
|
+
|
|
8
|
+
// src/spend/cli-args.ts
|
|
9
|
+
import { pathToFileURL } from "url";
|
|
10
|
+
import { resolve } from "path";
|
|
11
|
+
var SpendUsageError = class extends Error {
|
|
12
|
+
};
|
|
13
|
+
var DEFAULT_CONFIG_FILE = "spend.config.mjs";
|
|
14
|
+
var USAGE = [
|
|
15
|
+
"agent-app-spend-check \u2014 reconcile settled sandbox compute against what this product asked for.",
|
|
16
|
+
"",
|
|
17
|
+
"Usage: agent-app-spend-check [--config <file>] [--json] [--as-of <iso>] [--skip <check,check>]",
|
|
18
|
+
"",
|
|
19
|
+
` --config <file> Config module. Default ${DEFAULT_CONFIG_FILE}.`,
|
|
20
|
+
" --json Emit the report as JSON instead of a table.",
|
|
21
|
+
' --as-of <iso> Treat this instant as "now". Default: the current time.',
|
|
22
|
+
" --skip <checks> Comma-separated check ids to leave out.",
|
|
23
|
+
"",
|
|
24
|
+
"The config module default-exports (or exports as `config`) the reconcile options,",
|
|
25
|
+
"or a function returning them. It supplies the two things this package cannot:",
|
|
26
|
+
"the product's own expectation store, and an authenticated fetch of its settled",
|
|
27
|
+
"ledger rows. Scope that fetch to boxes this product owns.",
|
|
28
|
+
"",
|
|
29
|
+
"Exit 0 = clean, 1 = findings, 2 = usage or config error."
|
|
30
|
+
].join("\n");
|
|
31
|
+
function parseSpendArgs(argv) {
|
|
32
|
+
let configFile = DEFAULT_CONFIG_FILE;
|
|
33
|
+
let json = false;
|
|
34
|
+
let asOf;
|
|
35
|
+
let skip = [];
|
|
36
|
+
for (let i = 0; i < argv.length; i++) {
|
|
37
|
+
const arg = argv[i];
|
|
38
|
+
if (arg === "--json") {
|
|
39
|
+
json = true;
|
|
40
|
+
} else if (arg === "--config") {
|
|
41
|
+
const value = argv[++i];
|
|
42
|
+
if (!value) throw new SpendUsageError("--config needs a file path");
|
|
43
|
+
configFile = value;
|
|
44
|
+
} else if (arg === "--as-of") {
|
|
45
|
+
const value = argv[++i];
|
|
46
|
+
if (!value) throw new SpendUsageError("--as-of needs an ISO instant");
|
|
47
|
+
const parsed = Date.parse(value);
|
|
48
|
+
if (Number.isNaN(parsed)) throw new SpendUsageError(`--as-of is not a date: ${value}`);
|
|
49
|
+
asOf = parsed;
|
|
50
|
+
} else if (arg === "--skip") {
|
|
51
|
+
const value = argv[++i];
|
|
52
|
+
if (!value) throw new SpendUsageError("--skip needs a comma-separated list of check ids");
|
|
53
|
+
skip = value.split(",").map((part) => part.trim()).filter(Boolean);
|
|
54
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
55
|
+
throw new SpendUsageError("help");
|
|
56
|
+
} else if (arg !== void 0) {
|
|
57
|
+
throw new SpendUsageError(`unrecognized argument: ${arg}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { configFile, json, asOf, skip };
|
|
61
|
+
}
|
|
62
|
+
async function loadSpendConfig(configFile) {
|
|
63
|
+
const resolved = resolve(process.cwd(), configFile);
|
|
64
|
+
let module;
|
|
65
|
+
try {
|
|
66
|
+
module = await import(pathToFileURL(resolved).href);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw new SpendUsageError(
|
|
69
|
+
`could not load ${resolved}: ${err instanceof Error ? err.message : String(err)}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const exported = module.default ?? module.config;
|
|
73
|
+
const value = typeof exported === "function" ? await exported() : exported;
|
|
74
|
+
if (!value || typeof value !== "object") {
|
|
75
|
+
throw new SpendUsageError(`${resolved} must export reconcile options as \`default\` or \`config\``);
|
|
76
|
+
}
|
|
77
|
+
const options = value;
|
|
78
|
+
if (!Array.isArray(options.rows)) {
|
|
79
|
+
throw new SpendUsageError(`${resolved} must supply \`rows\` \u2014 the product's own settled-ledger fetch`);
|
|
80
|
+
}
|
|
81
|
+
if (!options.store) {
|
|
82
|
+
throw new SpendUsageError(`${resolved} must supply \`store\` \u2014 the product's expectation ledger`);
|
|
83
|
+
}
|
|
84
|
+
return options;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/spend/cli.ts
|
|
88
|
+
async function main() {
|
|
89
|
+
const args = parseSpendArgs(process.argv.slice(2));
|
|
90
|
+
const config = await loadSpendConfig(args.configFile);
|
|
91
|
+
const report = await reconcileSpend({
|
|
92
|
+
...config,
|
|
93
|
+
...args.asOf !== void 0 ? { asOf: args.asOf } : {},
|
|
94
|
+
...args.skip.length > 0 ? { skip: args.skip } : {}
|
|
95
|
+
});
|
|
96
|
+
const rendered = args.json ? spendReportToJson(report) : formatSpendReport(report);
|
|
97
|
+
if (report.ok) process.stdout.write(`${rendered}
|
|
98
|
+
`);
|
|
99
|
+
else process.stderr.write(`${rendered}
|
|
100
|
+
`);
|
|
101
|
+
return report.ok ? 0 : 1;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
process.exit(await main());
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (err instanceof SpendUsageError) {
|
|
107
|
+
process.stderr.write(`${err.message === "help" ? "" : `${err.message}
|
|
108
|
+
|
|
109
|
+
`}${USAGE}
|
|
110
|
+
`);
|
|
111
|
+
process.exit(2);
|
|
112
|
+
}
|
|
113
|
+
process.stderr.write(
|
|
114
|
+
`agent-app-spend-check failed: ${err instanceof Error ? err.message : String(err)}
|
|
115
|
+
`
|
|
116
|
+
);
|
|
117
|
+
process.exit(2);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/spend/cli-args.ts","../../src/spend/cli.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url'\nimport { resolve } from 'node:path'\nimport type { ReconcileSpendOptions } from './reconcile'\n\n/** A usage or config problem — exit code 2, never a finding. */\nexport class SpendUsageError extends Error {}\n\nconst DEFAULT_CONFIG_FILE = 'spend.config.mjs'\n\nexport const USAGE = [\n 'agent-app-spend-check — reconcile settled sandbox compute against what this product asked for.',\n '',\n 'Usage: agent-app-spend-check [--config <file>] [--json] [--as-of <iso>] [--skip <check,check>]',\n '',\n ` --config <file> Config module. Default ${DEFAULT_CONFIG_FILE}.`,\n ' --json Emit the report as JSON instead of a table.',\n ' --as-of <iso> Treat this instant as \"now\". Default: the current time.',\n ' --skip <checks> Comma-separated check ids to leave out.',\n '',\n 'The config module default-exports (or exports as `config`) the reconcile options,',\n 'or a function returning them. It supplies the two things this package cannot:',\n 'the product\\'s own expectation store, and an authenticated fetch of its settled',\n 'ledger rows. Scope that fetch to boxes this product owns.',\n '',\n 'Exit 0 = clean, 1 = findings, 2 = usage or config error.',\n].join('\\n')\n\nexport interface SpendCliArgs {\n readonly configFile: string\n readonly json: boolean\n readonly asOf: number | undefined\n readonly skip: readonly string[]\n}\n\n/** Parse argv. Split out of `cli.ts` so it is testable without a `process.exit`. */\nexport function parseSpendArgs(argv: readonly string[]): SpendCliArgs {\n let configFile = DEFAULT_CONFIG_FILE\n let json = false\n let asOf: number | undefined\n let skip: string[] = []\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]\n if (arg === '--json') {\n json = true\n } else if (arg === '--config') {\n const value = argv[++i]\n if (!value) throw new SpendUsageError('--config needs a file path')\n configFile = value\n } else if (arg === '--as-of') {\n const value = argv[++i]\n if (!value) throw new SpendUsageError('--as-of needs an ISO instant')\n const parsed = Date.parse(value)\n if (Number.isNaN(parsed)) throw new SpendUsageError(`--as-of is not a date: ${value}`)\n asOf = parsed\n } else if (arg === '--skip') {\n const value = argv[++i]\n if (!value) throw new SpendUsageError('--skip needs a comma-separated list of check ids')\n skip = value.split(',').map((part) => part.trim()).filter(Boolean)\n } else if (arg === '--help' || arg === '-h') {\n throw new SpendUsageError('help')\n } else if (arg !== undefined) {\n throw new SpendUsageError(`unrecognized argument: ${arg}`)\n }\n }\n\n return { configFile, json, asOf, skip }\n}\n\n/**\n * Load the product's reconcile options.\n *\n * A function export is awaited, so a config can open its database connection and\n * mint its platform credential at load time rather than at module scope.\n */\nexport async function loadSpendConfig(configFile: string): Promise<ReconcileSpendOptions> {\n const resolved = resolve(process.cwd(), configFile)\n let module: Record<string, unknown>\n try {\n module = (await import(pathToFileURL(resolved).href)) as Record<string, unknown>\n } catch (err) {\n throw new SpendUsageError(\n `could not load ${resolved}: ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n const exported = module.default ?? module.config\n const value = typeof exported === 'function' ? await (exported as () => unknown)() : exported\n if (!value || typeof value !== 'object') {\n throw new SpendUsageError(`${resolved} must export reconcile options as \\`default\\` or \\`config\\``)\n }\n const options = value as Partial<ReconcileSpendOptions>\n if (!Array.isArray(options.rows)) {\n throw new SpendUsageError(`${resolved} must supply \\`rows\\` — the product's own settled-ledger fetch`)\n }\n if (!options.store) {\n throw new SpendUsageError(`${resolved} must supply \\`store\\` — the product's expectation ledger`)\n }\n return options as ReconcileSpendOptions\n}\n","#!/usr/bin/env node\n/**\n * `agent-app-spend-check` — reconcile what the platform charged for sandbox\n * compute against what this product believes it asked for.\n *\n * Runs in the CONSUMER's repo, on a schedule, over the consumer's own ledger\n * fetch and expectation store — the two things this package deliberately does\n * not reach for. Add it next to the other gates:\n *\n * \"scripts\": { \"spend-check\": \"agent-app-spend-check\" }\n *\n * Exits 1 on any finding, 0 when clean, 2 on a usage or config error. It never\n * disputes, refunds, or writes anything; the output is evidence a human acts on.\n */\nimport { SpendUsageError, USAGE, loadSpendConfig, parseSpendArgs } from './cli-args'\nimport { reconcileSpend } from './reconcile'\nimport { formatSpendReport, spendReportToJson } from './report'\nimport type { SpendCheckId } from './types'\n\nasync function main(): Promise<number> {\n const args = parseSpendArgs(process.argv.slice(2))\n const config = await loadSpendConfig(args.configFile)\n const report = await reconcileSpend({\n ...config,\n ...(args.asOf !== undefined ? { asOf: args.asOf } : {}),\n ...(args.skip.length > 0 ? { skip: args.skip as SpendCheckId[] } : {}),\n })\n const rendered = args.json ? spendReportToJson(report) : formatSpendReport(report)\n // A clean report is routine output; a failing one belongs on stderr so a cron\n // that only forwards stderr still delivers the alert.\n if (report.ok) process.stdout.write(`${rendered}\\n`)\n else process.stderr.write(`${rendered}\\n`)\n return report.ok ? 0 : 1\n}\n\ntry {\n process.exit(await main())\n} catch (err) {\n if (err instanceof SpendUsageError) {\n process.stderr.write(`${err.message === 'help' ? '' : `${err.message}\\n\\n`}${USAGE}\\n`)\n process.exit(2)\n }\n process.stderr.write(\n `agent-app-spend-check failed: ${err instanceof Error ? err.message : String(err)}\\n`,\n )\n process.exit(2)\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AAIjB,IAAM,kBAAN,cAA8B,MAAM;AAAC;AAE5C,IAAM,sBAAsB;AAErB,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,8CAA8C,mBAAmB;AAAA,EACjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAUJ,SAAS,eAAe,MAAuC;AACpE,MAAI,aAAa;AACjB,MAAI,OAAO;AACX,MAAI;AACJ,MAAI,OAAiB,CAAC;AAEtB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,UAAU;AACpB,aAAO;AAAA,IACT,WAAW,QAAQ,YAAY;AA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