@h1r-ai/croche-cli 0.5.5 → 0.6.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 +267 -148
- package/THIRD-PARTY-NOTICES +7 -8
- package/dist/bin.js +29 -25
- package/dist/chunk-66EUX7EL.js +165 -0
- package/dist/chunk-DKT5HHSB.js +532 -0
- package/dist/chunk-K3UDT4EM.js +3110 -0
- package/dist/collector-credential.d.ts +9 -0
- package/dist/config-authoring.d.ts +19 -0
- package/dist/config-bases.d.ts +17 -0
- package/dist/config-push-base-35HX67AJ.js +2254 -0
- package/dist/config-push-base.d.ts +7 -0
- package/dist/control-address.d.ts +2 -0
- package/dist/control-server.d.ts +12 -15
- package/dist/control-server.js +9 -288
- package/dist/control-v2-auth.d.ts +24 -0
- package/dist/control-v2-capture.d.ts +34 -0
- package/dist/control-v2-json.d.ts +15 -0
- package/dist/control-v2-state.d.ts +90 -0
- package/dist/credentials.d.ts +2 -2
- package/dist/debugger/public/index.html +1 -0
- package/dist/debugger/public/stage-control.js +84 -0
- package/dist/debugger/public/stage-manifest.js +45 -0
- package/dist/debugger/public/stage-model.js +103 -0
- package/dist/debugger/public/stage-targets.js +18 -0
- package/dist/debugger/public/stage.css +459 -0
- package/dist/debugger/public/stage.html +17 -0
- package/dist/debugger/public/stage.js +113 -0
- package/dist/debugger/server/collector.js +42 -26
- package/dist/debugger/server/control-bridge.js +113 -0
- package/dist/debugger/server/server.js +10 -1
- package/dist/debugger/server/viewer-security.js +12 -0
- package/dist/debugger.d.ts +16 -6
- package/dist/index.d.ts +8 -1
- package/dist/index.js +17 -321
- package/dist/json-result.d.ts +2 -0
- package/package.json +2 -1
- package/dist/config.js +0 -100
- package/dist/control-client.js +0 -65
- package/dist/core-defaults.js +0 -2
- package/dist/credentials.js +0 -136
- package/dist/debug-keys.js +0 -141
- package/dist/debugger.js +0 -469
- package/dist/help.js +0 -158
- package/dist/text-file.js +0 -15
package/THIRD-PARTY-NOTICES
CHANGED
|
@@ -2638,7 +2638,7 @@ Used by:
|
|
|
2638
2638
|
- idna 1.1.0
|
|
2639
2639
|
- idna_adapter 1.2.2
|
|
2640
2640
|
- indexmap 2.14.2
|
|
2641
|
-
- js-sys 0.3.
|
|
2641
|
+
- js-sys 0.3.84
|
|
2642
2642
|
- linux-raw-sys 0.12.1
|
|
2643
2643
|
- log 0.4.34
|
|
2644
2644
|
- num-traits 0.2.19
|
|
@@ -2656,13 +2656,12 @@ Used by:
|
|
|
2656
2656
|
- url 2.5.8
|
|
2657
2657
|
- version_check 0.9.5
|
|
2658
2658
|
- wasi 0.11.1+wasi-snapshot-preview1
|
|
2659
|
-
- wasm-bindgen-
|
|
2660
|
-
- wasm-bindgen-
|
|
2661
|
-
- wasm-bindgen-macro
|
|
2662
|
-
- wasm-bindgen-
|
|
2663
|
-
- wasm-bindgen
|
|
2664
|
-
-
|
|
2665
|
-
- web-sys 0.3.81
|
|
2659
|
+
- wasm-bindgen-futures 0.4.57
|
|
2660
|
+
- wasm-bindgen-macro-support 0.2.107
|
|
2661
|
+
- wasm-bindgen-macro 0.2.107
|
|
2662
|
+
- wasm-bindgen-shared 0.2.107
|
|
2663
|
+
- wasm-bindgen 0.2.107
|
|
2664
|
+
- web-sys 0.3.84
|
|
2666
2665
|
|
|
2667
2666
|
Apache License
|
|
2668
2667
|
Version 2.0, January 2004
|
package/dist/bin.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
import {
|
|
3
|
+
startControlServer
|
|
4
|
+
} from "./chunk-DKT5HHSB.js";
|
|
5
|
+
import {
|
|
6
|
+
runCli
|
|
7
|
+
} from "./chunk-K3UDT4EM.js";
|
|
8
|
+
import "./chunk-66EUX7EL.js";
|
|
9
|
+
|
|
10
|
+
// src/bin.ts
|
|
11
|
+
import { createInterface } from "node:readline/promises";
|
|
12
|
+
process.exitCode = await runCli(process.argv.slice(2), { ...process.stdin.isTTY && process.stdout.isTTY ? { selectRuntime: async (runtimes) => {
|
|
13
|
+
process.stdout.write("Available local Runtimes\n" + runtimes.map((runtime, index) => ` ${index + 1}. ${runtime.label} (${runtime.id})`).join("\n") + "\n");
|
|
14
|
+
const reader = createInterface({ input: process.stdin, output: process.stdout });
|
|
15
|
+
try {
|
|
16
|
+
const choice = (await reader.question("Choose a number, or press Enter to cancel: ")).trim();
|
|
17
|
+
if (!choice) return;
|
|
18
|
+
const index = Number(choice) - 1;
|
|
19
|
+
if (!/^\d+$/.test(choice) || !runtimes[index]) throw new Error("Invalid selection.");
|
|
20
|
+
return runtimes[index].id;
|
|
21
|
+
} finally {
|
|
22
|
+
reader.close();
|
|
23
|
+
}
|
|
24
|
+
} } : {}, serveControl: async (options) => {
|
|
25
|
+
const server = await startControlServer(options);
|
|
26
|
+
const close = () => void server.close();
|
|
27
|
+
process.once("SIGINT", close);
|
|
28
|
+
process.once("SIGTERM", close);
|
|
29
|
+
return { url: server.url, local: true, authentication: "CROCHE_CONTROL_TOKEN", storage: "in-memory; Runtime owns durable input receipts" };
|
|
30
|
+
} });
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// src/control-address.ts
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
function remoteAddress(value) {
|
|
4
|
+
if (typeof value !== "string" || !isIP(value)) return;
|
|
5
|
+
if (isIP(value) === 4) return value === "0.0.0.0" || value.startsWith("127.") ? void 0 : value;
|
|
6
|
+
let normalized;
|
|
7
|
+
try {
|
|
8
|
+
normalized = new URL(`http://[${value}]/`).hostname.slice(1, -1);
|
|
9
|
+
} catch {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const halves = normalized.split("::"), left = halves[0] ? halves[0].split(":") : [], right = halves[1] ? halves[1].split(":") : [];
|
|
13
|
+
const words = (halves.length === 2 ? [...left, ...Array(8 - left.length - right.length).fill("0"), ...right] : left).map((word) => parseInt(word, 16));
|
|
14
|
+
if (words.every((n) => n === 0) || words.slice(0, 7).every((n) => n === 0) && words[7] === 1) return;
|
|
15
|
+
const embedded = words.slice(0, 5).every((n) => n === 0) && (words[5] === 0 || words[5] === 65535);
|
|
16
|
+
if (embedded && (words[6] === 0 && words[7] === 0 || words[6] >>> 8 === 127)) return;
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/control-v2-json.ts
|
|
21
|
+
var ControlError = class extends Error {
|
|
22
|
+
constructor(status, code) {
|
|
23
|
+
super(code);
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function refuse(status, code) {
|
|
29
|
+
throw new ControlError(status, code);
|
|
30
|
+
}
|
|
31
|
+
var reply = (value, status = 200) => Response.json(value, { status, headers: { "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff" } });
|
|
32
|
+
var object = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
33
|
+
var record = (v) => object(v) ? v : refuse(400, "invalid_request");
|
|
34
|
+
var id = (v) => typeof v === "string" && /^[A-Za-z0-9_.:-]{1,200}$/.test(v);
|
|
35
|
+
var count = (v) => Number.isSafeInteger(v) && Number(v) >= 0;
|
|
36
|
+
function same(a, b) {
|
|
37
|
+
if (a === b) return true;
|
|
38
|
+
if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((v, i) => same(v, b[i]));
|
|
39
|
+
if (object(a) && object(b)) return Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((k) => Object.hasOwn(b, k) && same(a[k], b[k]));
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function parse(text) {
|
|
43
|
+
let at = 0;
|
|
44
|
+
const white = () => {
|
|
45
|
+
while (/[\x20\t\r\n]/.test(text[at] ?? "!")) at++;
|
|
46
|
+
};
|
|
47
|
+
function string() {
|
|
48
|
+
const start = at++;
|
|
49
|
+
while (at < text.length) {
|
|
50
|
+
const c = text[at++];
|
|
51
|
+
if (c === "\\") {
|
|
52
|
+
at++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (c === '"') {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(text.slice(start, at));
|
|
58
|
+
} catch {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return refuse(400, "invalid_json");
|
|
64
|
+
}
|
|
65
|
+
function value(depth) {
|
|
66
|
+
if (depth > 64) refuse(400, "invalid_json");
|
|
67
|
+
white();
|
|
68
|
+
const c = text[at];
|
|
69
|
+
if (c === '"') return string();
|
|
70
|
+
if (c === "{") {
|
|
71
|
+
at++;
|
|
72
|
+
white();
|
|
73
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
74
|
+
if (text[at] === "}") {
|
|
75
|
+
at++;
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
for (; ; ) {
|
|
79
|
+
white();
|
|
80
|
+
if (text[at] !== '"') refuse(400, "invalid_json");
|
|
81
|
+
const key = string();
|
|
82
|
+
if (Object.hasOwn(out, key)) refuse(400, "invalid_json");
|
|
83
|
+
white();
|
|
84
|
+
if (text[at++] !== ":") refuse(400, "invalid_json");
|
|
85
|
+
out[key] = value(depth + 1);
|
|
86
|
+
white();
|
|
87
|
+
const separator = text[at++];
|
|
88
|
+
if (separator === "}") return out;
|
|
89
|
+
if (separator !== ",") refuse(400, "invalid_json");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (c === "[") {
|
|
93
|
+
at++;
|
|
94
|
+
white();
|
|
95
|
+
const out = [];
|
|
96
|
+
if (text[at] === "]") {
|
|
97
|
+
at++;
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
for (; ; ) {
|
|
101
|
+
out.push(value(depth + 1));
|
|
102
|
+
white();
|
|
103
|
+
const separator = text[at++];
|
|
104
|
+
if (separator === "]") return out;
|
|
105
|
+
if (separator !== ",") refuse(400, "invalid_json");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const token = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(text.slice(at))?.[0];
|
|
109
|
+
if (!token) refuse(400, "invalid_json");
|
|
110
|
+
at += token.length;
|
|
111
|
+
const result2 = JSON.parse(token);
|
|
112
|
+
if (typeof result2 === "number" && (!Number.isFinite(result2) || Number.isInteger(result2) && !Number.isSafeInteger(result2))) refuse(400, "invalid_json");
|
|
113
|
+
return result2;
|
|
114
|
+
}
|
|
115
|
+
const result = value(0);
|
|
116
|
+
white();
|
|
117
|
+
if (at !== text.length) refuse(400, "invalid_json");
|
|
118
|
+
return record(result);
|
|
119
|
+
}
|
|
120
|
+
async function body(request) {
|
|
121
|
+
const size = request.headers.get("Content-Length");
|
|
122
|
+
if (size !== null && (!/^\d+$/.test(size) || Number(size) > 1024 * 1024)) refuse(413, "request_too_large");
|
|
123
|
+
if (request.headers.get("Content-Type")?.split(";")[0].trim().toLowerCase() !== "application/json") refuse(415, "invalid_request");
|
|
124
|
+
const reader = request.body?.getReader();
|
|
125
|
+
if (!reader) refuse(400, "invalid_request");
|
|
126
|
+
let timer;
|
|
127
|
+
try {
|
|
128
|
+
return await Promise.race([(async () => {
|
|
129
|
+
const chunks = [];
|
|
130
|
+
let length = 0;
|
|
131
|
+
for (; ; ) {
|
|
132
|
+
const next = await reader.read();
|
|
133
|
+
if (next.done) break;
|
|
134
|
+
length += next.value.byteLength;
|
|
135
|
+
if (length > 1024 * 1024) refuse(413, "request_too_large");
|
|
136
|
+
chunks.push(next.value);
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
return parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, length)));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
if (e instanceof ControlError) throw e;
|
|
142
|
+
return refuse(400, "invalid_json");
|
|
143
|
+
}
|
|
144
|
+
})(), new Promise((_, reject) => {
|
|
145
|
+
timer = setTimeout(() => reject(new ControlError(408, "request_timeout")), 5e3);
|
|
146
|
+
})]);
|
|
147
|
+
} finally {
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
void reader.cancel().catch(() => {
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
remoteAddress,
|
|
156
|
+
ControlError,
|
|
157
|
+
refuse,
|
|
158
|
+
reply,
|
|
159
|
+
object,
|
|
160
|
+
record,
|
|
161
|
+
id,
|
|
162
|
+
count,
|
|
163
|
+
same,
|
|
164
|
+
body
|
|
165
|
+
};
|