@bytesbrains/cruise 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{budget-FIRNSN67.mjs → budget-IIC4NJUU.mjs} +6 -5
  2. package/dist/{chunk-FGLMW5IY.mjs → chunk-2Z62Z53P.mjs} +2 -2
  3. package/dist/chunk-5AFYJTLS.mjs +62 -0
  4. package/dist/{chunk-WS6NFRIU.mjs → chunk-5LRJO4Z3.mjs} +1 -1
  5. package/dist/chunk-7ZUKADIS.mjs +131 -0
  6. package/dist/{chunk-LALZUKEC.mjs → chunk-A4DIVNYV.mjs} +1 -0
  7. package/dist/chunk-CDBZLSL7.mjs +65 -0
  8. package/dist/chunk-D3K25SBO.mjs +69 -0
  9. package/dist/chunk-NR4K7AUA.mjs +17 -0
  10. package/dist/{chunk-GUZNI3NS.mjs → chunk-PNJVYZ3Y.mjs} +3 -56
  11. package/dist/chunk-TJR2U73N.mjs +12 -0
  12. package/dist/{chunk-THEXUHQC.mjs → chunk-UBM65ZNR.mjs} +1 -0
  13. package/dist/{chunk-JZPUTXM7.mjs → chunk-Y2I46CTD.mjs} +113 -1
  14. package/dist/{compress-3DWG35BY.mjs → compress-QAEEBNVF.mjs} +1 -2
  15. package/dist/{conformance-NPFDYCQL.mjs → conformance-H2DRKMVX.mjs} +4 -5
  16. package/dist/cruise.mjs +132 -32
  17. package/dist/demo-seed-PRVDIWCM.mjs +59 -0
  18. package/dist/doctor-LVMXEX35.mjs +802 -0
  19. package/dist/{fallback-P5KK55M4.mjs → fallback-HRVI5XCK.mjs} +7 -6
  20. package/dist/journey-JXQ3VYCT.mjs +136 -0
  21. package/dist/{keys-FWPQPMTW.mjs → keys-S5QOOVMS.mjs} +3 -4
  22. package/dist/{ledger-XBGWXY6C.mjs → ledger-DWOMA7WD.mjs} +2 -3
  23. package/dist/{member-ZBV4YG2M.mjs → member-R7HUJK45.mjs} +1 -2
  24. package/dist/metrics-LCO4YNPW.mjs +144 -0
  25. package/dist/{report-VRYJ3W5L.mjs → report-CLNJPK6Z.mjs} +2 -3
  26. package/dist/secrets-check-6PWXXJM7.mjs +65 -0
  27. package/dist/{service-key-N2RZ7FMZ.mjs → service-key-E6SGTLWA.mjs} +1 -2
  28. package/dist/{smoke-ZNYX6RO5.mjs → smoke-DFNUPTZ7.mjs} +1 -2
  29. package/dist/staging-seed-647DRUW5.mjs +41 -0
  30. package/dist/{sweep-SZX7OIDK.mjs → sweep-5O32ZU4T.mjs} +2 -3
  31. package/dist/{tenant-4YDGI23Q.mjs → tenant-DRN6BAOI.mjs} +13 -9
  32. package/dist/{tier-4L3SPLFP.mjs → tier-JSY5OU65.mjs} +1 -2
  33. package/package.json +3 -3
  34. package/dist/chunk-7NQHBXVZ.mjs +0 -104
  35. package/dist/chunk-ICJVJSTC.mjs +0 -42
  36. package/dist/chunk-N3YKWKOA.mjs +0 -9
@@ -1,104 +0,0 @@
1
- #!/usr/bin/env node
2
- // Built by packages/cli/build.ts.
3
- import {
4
- HttpD1,
5
- LocalD1
6
- } from "./chunk-JZPUTXM7.mjs";
7
-
8
- // scripts/cli-support.ts
9
- import { readFileSync } from "node:fs";
10
- import path from "node:path";
11
-
12
- // scripts/wrangler-config.ts
13
- function stripJsonc(raw) {
14
- return JSON.parse(raw.replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\/\*[\s\S]*?\*\//g, ""));
15
- }
16
- function resolveScope(config, environment) {
17
- const root = config;
18
- const scope = environment === "top" ? root : root.env?.[environment];
19
- if (!scope) throw new Error(`No such environment in wrangler.jsonc: ${environment}`);
20
- return scope;
21
- }
22
- function resolveWorker(config, environment) {
23
- const root = config;
24
- const scope = resolveScope(config, environment);
25
- const scriptName = scope.name ?? root.name;
26
- if (!scriptName) throw new Error(`No worker name for environment: ${environment}`);
27
- if (!root.account_id) throw new Error("No account_id in wrangler.jsonc");
28
- return { accountId: root.account_id, scriptName };
29
- }
30
- function resolveDatabaseId(config, environment) {
31
- const databaseId = resolveScope(config, environment).d1_databases?.[0]?.database_id;
32
- if (!databaseId) throw new Error(`No d1_databases entry for environment: ${environment}`);
33
- return databaseId;
34
- }
35
-
36
- // scripts/cli-support.ts
37
- function parseArgs(argv) {
38
- const args = {};
39
- for (let i = 0; i < argv.length; i++) {
40
- const token = argv[i];
41
- if (!token?.startsWith("--")) continue;
42
- const name = token.slice(2);
43
- const next = argv[i + 1];
44
- if (next === void 0 || next.startsWith("--")) args[name] = true;
45
- else {
46
- args[name] = next;
47
- i++;
48
- }
49
- }
50
- return args;
51
- }
52
- function requireString(args, name) {
53
- const value = args[name];
54
- if (typeof value !== "string" || value.length === 0) throw new Error(`Missing required --${name}`);
55
- return value;
56
- }
57
- function optionalNumber(args, name) {
58
- const value = args[name];
59
- if (typeof value !== "string") return null;
60
- const parsed = Number(value);
61
- if (!Number.isFinite(parsed)) throw new Error(`--${name} must be a number, got ${value}`);
62
- return parsed;
63
- }
64
- function loadWranglerConfig() {
65
- return stripJsonc(readFileSync(path.join(import.meta.dirname, "..", "wrangler.jsonc"), "utf8"));
66
- }
67
- function requireToken() {
68
- const token = process.env.CLOUDFLARE_API_TOKEN;
69
- if (!token) throw new Error("CLOUDFLARE_API_TOKEN is not set");
70
- return token;
71
- }
72
- function connect(environment) {
73
- if (environment === LOCAL_ENVIRONMENT) return new LocalD1();
74
- const token = requireToken();
75
- if (environment === CLOUDFLARE_ENVIRONMENT) {
76
- const accountId2 = process.env.CRUISE_D1_ACCOUNT_ID;
77
- const databaseId = process.env.CRUISE_D1_DATABASE_ID;
78
- if (!accountId2 || !databaseId) throw new Error("--env cloudflare needs CRUISE_D1_ACCOUNT_ID and CRUISE_D1_DATABASE_ID");
79
- return new HttpD1(accountId2, databaseId, token);
80
- }
81
- const config = loadWranglerConfig();
82
- const { accountId } = resolveWorker(config, environment);
83
- return new HttpD1(accountId, resolveDatabaseId(config, environment), token);
84
- }
85
- var LOCAL_ENVIRONMENT = "local";
86
- var CLOUDFLARE_ENVIRONMENT = "cloudflare";
87
- function environmentOf(args) {
88
- return typeof args.env === "string" ? args.env : "staging";
89
- }
90
- function run(main) {
91
- main().catch((error) => {
92
- console.error(error instanceof Error ? error.message : error);
93
- process.exitCode = 1;
94
- });
95
- }
96
-
97
- export {
98
- parseArgs,
99
- requireString,
100
- optionalNumber,
101
- connect,
102
- environmentOf,
103
- run
104
- };
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
- // Built by packages/cli/build.ts.
3
-
4
- // src/pricing-usage.ts
5
- var IMPLAUSIBLE_TOKENS = 1e8;
6
- function tokenCount(value) {
7
- if (typeof value !== "number") return null;
8
- if (!Number.isSafeInteger(value)) return null;
9
- if (value < 0 || value > IMPLAUSIBLE_TOKENS) return null;
10
- return value;
11
- }
12
- function usageFromJson(body) {
13
- const usage = body?.usage;
14
- if (!usage) return null;
15
- const prompt = tokenCount(usage.prompt_tokens);
16
- const completion = tokenCount(usage.completion_tokens);
17
- if (prompt === null || completion === null) {
18
- console.warn(
19
- `Refusing implausible usage from upstream: prompt=${String(usage.prompt_tokens)} completion=${String(usage.completion_tokens)}. Recorded as no_usage and charged the reservation.`
20
- );
21
- return null;
22
- }
23
- const reasoning = usage.completion_tokens_details?.reasoning_tokens;
24
- const cached = usage.prompt_tokens_details?.cached_tokens ?? usage.prompt_cache_hit_tokens;
25
- const searches = tokenCount(usage.server_tool_use?.web_search_requests ?? usage.num_search_queries);
26
- const contextSize = typeof usage.search_context_size === "string" ? usage.search_context_size : void 0;
27
- return {
28
- prompt_tokens: prompt,
29
- completion_tokens: completion,
30
- // These two only ever refine a figure already accepted, so an implausible
31
- // value drops to zero rather than discarding the whole reading.
32
- reasoning_tokens: tokenCount(reasoning) ?? 0,
33
- cached_input_tokens: tokenCount(cached) ?? 0,
34
- ...searches === null ? {} : { web_search_requests: searches },
35
- ...contextSize === void 0 ? {} : { search_context_size: contextSize }
36
- };
37
- }
38
-
39
- export {
40
- tokenCount,
41
- usageFromJson
42
- };
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- // Built by packages/cli/build.ts.
3
-
4
- // src/demo-catalogue.ts
5
- var DEMO_ENVIRONMENT = "demo";
6
-
7
- export {
8
- DEMO_ENVIRONMENT
9
- };