barebox 0.14.0 → 0.16.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.
package/types/prompt.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /** @typedef {{ id: string, agent?: string, method: string, url: string, rule: string, letter: string, bodyPreview?: string, expiresAt?: string|null, floor?: { kind: string, entry: string }, effect?: import('./effect.js').Effect, keyLast4?: string, modelKey?: 'none'|'other' }} AskRecord */
1
+ /** @typedef {{ id: string, agent?: string, method: string, url: string, rule: string, letter: string, bodyPreview?: string, expiresAt?: string|null, floor?: { kind: string, entry: string }, effect?: import('./effect.js').Effect, keyLast4?: string, modelKey?: 'none'|'other', profile?: string }} AskRecord */
2
2
  /**
3
3
  * The `To:` / `Amount:` / `Currency:` lines of a floor request, or one `Effect:` line saying why none was read.
4
4
  * Up to LIST_MAX fields are all listed; more than that lists none (too many to tell the real one).
@@ -8,6 +8,15 @@
8
8
  * @returns {string[]} zero or more lines
9
9
  */
10
10
  export function effectLines(effect: AskRecord["effect"], color: boolean): string[];
11
+ /**
12
+ * The URL of an ask, sanitized. For a first-contact host ask (`flags.newHost`) everything after the
13
+ * scheme (userinfo, host, path and query) has card numbers masked, then is cut to 200 characters and the
14
+ * full length is added, so a long URL is visible but bounded. The question's header line shows the true host.
15
+ *
16
+ * @param {AskRecord} ask the parked request
17
+ * @returns {string} the URL text, safe for a terminal
18
+ */
19
+ export function askUrl(ask: AskRecord): string;
11
20
  /**
12
21
  * The ` floor=<kind> entry=<entry>` tail of a one-line ask (`sbx pending`, the non-terminal `ask` line); empty without a floor hit.
13
22
  *
@@ -86,4 +95,5 @@ export type AskRecord = {
86
95
  effect?: import("./effect.js").Effect;
87
96
  keyLast4?: string;
88
97
  modelKey?: "none" | "other";
98
+ profile?: string;
89
99
  };
package/types/proxy.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  * @property {{ matcher: { match: (method: string, url: string) => { key: string, source: string } }, tools: Record<string, any> }} [labels] the loaded label files (see `loadLabels`); omitted means no labels, only the built-in model endpoints
11
11
  * @property {string[]} [allowLocal] exact `host:port` pairs (the `localLlm` setting) that may pass the wall's private/loopback check; any other local destination is still denied
12
12
  * @property {{ pay?: string[], send?: string[] }} [floor] the config `floor` key (M11): a write to a listed host or `*.domain`, or a request matching a listed `"METHOD host/path"`, asks in every mode (the gate flag `floor`); the question shows the recipient, amount and currency found in the body. Omitted means no floor lists.
13
+ * @property {{ allow?: string[], deny?: string[], unknown?: 'ask' | 'deny' | 'allow' }} [hosts] M14: `deny` hosts (exact or `*.domain`) are refused before DNS in every mode; `allow` hosts never get the first-contact ask; any other host follows `unknown`: `'ask'` asks once per host (allow for this run, or deny), `'deny'` refuses it at once, `'allow'` (the default here) lets it through. Model endpoint hosts, each secret's hosts and the `allowLocal` hosts are never asked. Needs `gateFor` for `'ask'`; without it `'ask'` refuses.
13
14
  * @property {HoldOptions} [hold] hold queue config (deadline, caps, ask seam)
14
15
  * @property {number} [upstreamTimeoutMs] give up on an upstream response after this (default 120000)
15
16
  * @property {object} [unsafeTestOnly] TEST-ONLY escape hatch: everything under
@@ -21,7 +22,7 @@
21
22
  * DNS stub: replaces the wall's resolver so rebinding is testable. Production omits it.
22
23
  * @property {import('./secrets.js').Secret[]} [secrets] the loaded secrets (`loadSecrets`): a request carrying a secret's placeholder in a header gets the real value there only after the gate allowed it and only for a bound host; for any other host it is refused `403 denied: secret.host`. The value never reaches the audit file, an ask or an error body.
23
24
  * @property {number} [clientIdleMs] kill a client tunnel idle this long; never fires mid-request (default 60000)
24
- * @property {(entry: Record<string, unknown>) => Record<string, unknown>} [redact] log redaction hook, applied after built-in secret scrubbing; its result becomes the `meta` of an `annotate` line (default: identity)
25
+ * @property {(entry: Record<string, unknown>) => Record<string, unknown>} [redact] log redaction hook, applied after built-in secret scrubbing; its result becomes the `meta` of an `annotate` line, and the `url` it sees already has userinfo and card numbers masked (default: identity)
25
26
  */
26
27
  /**
27
28
  * Anything with bareguard's `check`: a `Gate`, or a plain object for tests. An
@@ -61,7 +62,7 @@
61
62
  * @typedef {ReturnType<typeof createProxy>} Proxy
62
63
  */
63
64
  /**
64
- * Start the front-door proxy. Every request is audited with its method and URL, and a request with a body also with its byte count and SHA-256 (never headers or body text); bytes go upstream untouched. Requests the hold rule
65
+ * Start the front-door proxy. Every request is audited with its method and URL, and a request with a body also with its byte count and SHA-256 (never headers or body text); barebox's own audit lines mask userinfo and card numbers in the URL, the gate's decision lines keep it as sent; bytes go upstream untouched. Requests the hold rule
65
66
  * flags park for a human decision instead of forwarding.
66
67
  *
67
68
  * @param {ProxyOptions} opts
@@ -82,6 +83,11 @@ export function createProxy(opts: ProxyOptions): {
82
83
  addAgent: (name: any) => string;
83
84
  removeAgent: (name: any) => void;
84
85
  pending: () => import("./holds.js").HeldRequest[];
86
+ /** M14: hosts a person allowed this run, and hosts refused by `unknown: 'deny'`; each sorted and unique. @returns {{ allowed: string[], refused: string[] }} */
87
+ hostsReport: () => {
88
+ allowed: string[];
89
+ refused: string[];
90
+ };
85
91
  readonly caFile: string;
86
92
  };
87
93
  /**
@@ -137,6 +143,14 @@ export type ProxyOptions = {
137
143
  pay?: string[];
138
144
  send?: string[];
139
145
  } | undefined;
146
+ /**
147
+ * M14: `deny` hosts (exact or `*.domain`) are refused before DNS in every mode; `allow` hosts never get the first-contact ask; any other host follows `unknown`: `'ask'` asks once per host (allow for this run, or deny), `'deny'` refuses it at once, `'allow'` (the default here) lets it through. Model endpoint hosts, each secret's hosts and the `allowLocal` hosts are never asked. Needs `gateFor` for `'ask'`; without it `'ask'` refuses.
148
+ */
149
+ hosts?: {
150
+ allow?: string[];
151
+ deny?: string[];
152
+ unknown?: "ask" | "deny" | "allow";
153
+ } | undefined;
140
154
  /**
141
155
  * hold queue config (deadline, caps, ask seam)
142
156
  */
@@ -170,7 +184,7 @@ export type ProxyOptions = {
170
184
  */
171
185
  clientIdleMs?: number | undefined;
172
186
  /**
173
- * log redaction hook, applied after built-in secret scrubbing; its result becomes the `meta` of an `annotate` line (default: identity)
187
+ * log redaction hook, applied after built-in secret scrubbing; its result becomes the `meta` of an `annotate` line, and the `url` it sees already has userinfo and card numbers masked (default: identity)
174
188
  */
175
189
  redact?: ((entry: Record<string, unknown>) => Record<string, unknown>) | undefined;
176
190
  };
package/types/run.d.ts CHANGED
@@ -30,6 +30,7 @@
30
30
  * @property {{ matcher: any, tools: Record<string, any>, dirs?: string[] }} [labels] the loaded label files (`loadLabels`); their folders are masked from the sandbox
31
31
  * @property {string[]} [allowLocal] exact `host:port` pairs (for example a local model server) that may pass the wall's private/loopback check (the `localLlm` setting)
32
32
  * @property {{ pay?: string[], send?: string[] }} [floor] the config `floor` key (M11): hosts, `*.domain` or `"METHOD host/path"` entries that ask in every mode, `trust` included (see `createProxy`)
33
+ * @property {{ allow?: string[], deny?: string[], unknown?: 'ask'|'deny' }} [hosts] the config `hosts` key (M14): `deny` hosts are refused before DNS in every mode; `allow` hosts never get the first-contact ask; any other host asks once (`unknown` `ask`, the default) or is refused (`deny`). `trust` lets other hosts through, a `deny` host still refused (see `createProxy`)
33
34
  * @property {object} [unsafeTestOnly] TEST-ONLY escape hatch, forwarded to the proxy (see `createProxy`): everything under it weakens the sandbox wall
34
35
  * @property {NodeJS.WritableStream} [stdout] where the agent's stdout goes (default process.stdout)
35
36
  * @property {NodeJS.WritableStream} [stderr] where the agent's stderr goes (default process.stderr)
@@ -54,6 +55,7 @@
54
55
  * @param {{ matcher: any, tools: Record<string, any>, dirs?: string[] }|null} [opts.labels] the loaded label files (`loadLabels`); their folders are masked from the sandbox
55
56
  * @param {string[]} [opts.allowLocal] exact `host:port` pairs (for example a local model server) that may pass the wall's private/loopback check (the `localLlm` setting)
56
57
  * @param {{ pay?: string[], send?: string[] }|null} [opts.floor] the config `floor` key (M11): hosts, `*.domain` or `"METHOD host/path"` entries that ask in every mode, `trust` included (see `createProxy`)
58
+ * @param {{ allow?: string[], deny?: string[], unknown?: 'ask'|'deny' }|null} [opts.hosts] the config `hosts` key (M14); see {@link RunOptions}
57
59
  * @param {object|null} [opts.unsafeTestOnly] TEST-ONLY escape hatch, forwarded to the proxy (see `createProxy`)
58
60
  * @param {NodeJS.WritableStream|null} [opts.stdout] where the agent's stdout goes (default process.stdout)
59
61
  * @param {NodeJS.WritableStream|null} [opts.stderr] where the agent's stderr goes (default process.stderr)
@@ -61,14 +63,14 @@
61
63
  * @param {{ pass?: string[], set?: Record<string, string> }|null} [opts.env] the sandbox's environment (M5), the config `env` shape; see {@link RunOptions}
62
64
  * @param {boolean} [opts.overlay] when true, mount a per-run overlay upper over the project instead of binding it read-only; the result's `diff` lists the run's changes for commit/rollback
63
65
  * @param {string[]} [opts.overlayIgnore] path segments invisible to the overlay (default `node_modules`; see overlay.js Q3)
64
- * @returns {Promise<{ exit: number, asks: AskRecord[], audit: string, diff: import('./overlay.js').OverlayChange[], runtime: string }>} the agent process exit code, the collected ask records, the JSONL audit log path, the run's overlay diff (M4), and the runtime dir addressing it
66
+ * @returns {Promise<{ exit: number, asks: AskRecord[], audit: string, diff: import('./overlay.js').OverlayChange[], runtime: string, hosts: { allowed: string[], refused: string[] } }>} the agent process exit code, the collected ask records, the JSONL audit log path, the run's overlay diff (M4), the runtime dir addressing it, and the hosts a person allowed or `unknown: 'deny'` refused (M14)
65
67
  * @when Reach for this to HARNESS-ONLY run one sandboxed agent start-to-finish in a single call: it starts the proxy, sandboxes the command, answers holds, and returns the exit code with the ask and audit trail (plus the overlay diff once M4 exists).
66
68
  * @fails Rejects on a missing/unreadable `proj`, an empty `command`, a bad `mode`, a misshapen `onAsk`, a `secrets` entry with no value (a `fromEnv` variable missing from this process's environment; the message names the secret, never a value), a proxy that never becomes ready, a `launch` that throws (uncommitted overlay changes, a runtime inside the project — the proxy is closed first), or an overlay diff that cannot be read. The agent's own nonzero exit is returned as `exit`, never thrown.
67
69
  * @example
68
70
  * import { run } from "barebox";
69
71
  * const { exit, asks, audit } = await run({ proj: "/tmp/proj", command: ["bash", "-c", "echo hi"] });
70
72
  */
71
- export function run({ proj, command, mode, onAsk, onEvent, runtime, agent, timeoutMs, heldBodyMaxBytes, allowLocal, floor, labels, unsafeTestOnly, stdout, stderr, overlay, overlayIgnore, secrets, env }: {
73
+ export function run({ proj, command, mode, onAsk, onEvent, runtime, agent, timeoutMs, heldBodyMaxBytes, allowLocal, floor, hosts, labels, unsafeTestOnly, stdout, stderr, overlay, overlayIgnore, secrets, env }: {
72
74
  proj: string;
73
75
  command: string[];
74
76
  mode?: string | undefined;
@@ -88,6 +90,11 @@ export function run({ proj, command, mode, onAsk, onEvent, runtime, agent, timeo
88
90
  pay?: string[];
89
91
  send?: string[];
90
92
  } | null | undefined;
93
+ hosts?: {
94
+ allow?: string[];
95
+ deny?: string[];
96
+ unknown?: "ask" | "deny";
97
+ } | null | undefined;
91
98
  unsafeTestOnly?: object | null;
92
99
  stdout?: NodeJS.WritableStream | null | undefined;
93
100
  stderr?: NodeJS.WritableStream | null | undefined;
@@ -108,6 +115,10 @@ export function run({ proj, command, mode, onAsk, onEvent, runtime, agent, timeo
108
115
  audit: string;
109
116
  diff: import("./overlay.js").OverlayChange[];
110
117
  runtime: string;
118
+ hosts: {
119
+ allowed: string[];
120
+ refused: string[];
121
+ };
111
122
  }>;
112
123
  /**
113
124
  * A collected ask record: the parked ask plus how it was decided.
@@ -217,6 +228,14 @@ export type RunOptions = {
217
228
  pay?: string[];
218
229
  send?: string[];
219
230
  } | undefined;
231
+ /**
232
+ * the config `hosts` key (M14): `deny` hosts are refused before DNS in every mode; `allow` hosts never get the first-contact ask; any other host asks once (`unknown` `ask`, the default) or is refused (`deny`). `trust` lets other hosts through, a `deny` host still refused (see `createProxy`)
233
+ */
234
+ hosts?: {
235
+ allow?: string[];
236
+ deny?: string[];
237
+ unknown?: "ask" | "deny";
238
+ } | undefined;
220
239
  /**
221
240
  * TEST-ONLY escape hatch, forwarded to the proxy (see `createProxy`): everything under it weakens the sandbox wall
222
241
  */