@relayflows/sdk 2.0.21 → 2.0.23
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/agent-artifacts.d.ts +18 -9
- package/dist/agent-artifacts.d.ts.map +1 -1
- package/dist/agent-artifacts.js +27 -11
- package/dist/agent-artifacts.js.map +1 -1
- package/dist/agent-transcript.d.ts +186 -0
- package/dist/agent-transcript.d.ts.map +1 -0
- package/dist/agent-transcript.js +585 -0
- package/dist/agent-transcript.js.map +1 -0
- package/dist/authored-flow-error.d.ts +33 -1
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js +20 -1
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +4 -1
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-node-entry.js +5 -1
- package/dist/authored-node-entry.js.map +1 -1
- package/dist/authored-node-runner.d.ts +11 -0
- package/dist/authored-node-runner.d.ts.map +1 -1
- package/dist/authored-node-runner.js +30 -1
- package/dist/authored-node-runner.js.map +1 -1
- package/dist/authored-root.js +3 -1
- package/dist/authored-root.js.map +1 -1
- package/dist/authored-source-authority.js +13 -0
- package/dist/authored-source-authority.js.map +1 -1
- package/dist/authored-step-index.d.ts +82 -0
- package/dist/authored-step-index.d.ts.map +1 -0
- package/dist/authored-step-index.js +120 -0
- package/dist/authored-step-index.js.map +1 -0
- package/dist/authored-step-output.d.ts +23 -2
- package/dist/authored-step-output.d.ts.map +1 -1
- package/dist/authored-step-output.js +47 -5
- package/dist/authored-step-output.js.map +1 -1
- package/dist/authored-worker-step.d.ts +10 -2
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +81 -7
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +67 -12
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cloud-read.d.ts +31 -0
- package/dist/cli/cloud-read.d.ts.map +1 -0
- package/dist/cli/cloud-read.js +482 -0
- package/dist/cli/cloud-read.js.map +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +53 -24
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/status.d.ts +43 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +321 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/step-failure.d.ts +26 -0
- package/dist/cli/step-failure.d.ts.map +1 -1
- package/dist/cli/step-failure.js +99 -10
- package/dist/cli/step-failure.js.map +1 -1
- package/dist/cli-commands.d.ts +41 -0
- package/dist/cli-commands.d.ts.map +1 -1
- package/dist/cli-commands.js +33 -0
- package/dist/cli-commands.js.map +1 -1
- package/dist/cli.d.ts +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -1
- package/dist/cloud-http.d.ts +12 -0
- package/dist/cloud-http.d.ts.map +1 -1
- package/dist/cloud-http.js +14 -6
- package/dist/cloud-http.js.map +1 -1
- package/dist/cloud-read.d.ts +154 -0
- package/dist/cloud-read.d.ts.map +1 -0
- package/dist/cloud-read.js +373 -0
- package/dist/cloud-read.js.map +1 -0
- package/dist/cloud-transcript.d.ts +94 -0
- package/dist/cloud-transcript.d.ts.map +1 -0
- package/dist/cloud-transcript.js +342 -0
- package/dist/cloud-transcript.js.map +1 -0
- package/dist/communication/environment.d.ts +3 -0
- package/dist/communication/environment.d.ts.map +1 -0
- package/dist/communication/environment.js +34 -0
- package/dist/communication/environment.js.map +1 -0
- package/dist/communication/history.d.ts +6 -0
- package/dist/communication/history.d.ts.map +1 -0
- package/dist/communication/history.js +38 -0
- package/dist/communication/history.js.map +1 -0
- package/dist/communication/local.d.ts +6 -0
- package/dist/communication/local.d.ts.map +1 -0
- package/dist/communication/local.js +56 -0
- package/dist/communication/local.js.map +1 -0
- package/dist/communication/preflight.d.ts +6 -0
- package/dist/communication/preflight.d.ts.map +1 -0
- package/dist/communication/preflight.js +37 -0
- package/dist/communication/preflight.js.map +1 -0
- package/dist/communication/projection.d.ts +8 -0
- package/dist/communication/projection.d.ts.map +1 -0
- package/dist/communication/projection.js +23 -0
- package/dist/communication/projection.js.map +1 -0
- package/dist/communication/relay.d.ts +78 -0
- package/dist/communication/relay.d.ts.map +1 -0
- package/dist/communication/relay.js +89 -0
- package/dist/communication/relay.js.map +1 -0
- package/dist/communication/session.d.ts +24 -0
- package/dist/communication/session.d.ts.map +1 -0
- package/dist/communication/session.js +100 -0
- package/dist/communication/session.js.map +1 -0
- package/dist/communication/spec.d.ts +20 -0
- package/dist/communication/spec.d.ts.map +1 -0
- package/dist/communication/spec.js +113 -0
- package/dist/communication/spec.js.map +1 -0
- package/dist/communication/tool.d.ts +3 -0
- package/dist/communication/tool.d.ts.map +1 -0
- package/dist/communication/tool.js +23 -0
- package/dist/communication/tool.js.map +1 -0
- package/dist/communication/tools.d.ts +11 -0
- package/dist/communication/tools.d.ts.map +1 -0
- package/dist/communication/tools.js +65 -0
- package/dist/communication/tools.js.map +1 -0
- package/dist/communication/worker.d.ts +6 -0
- package/dist/communication/worker.d.ts.map +1 -0
- package/dist/communication/worker.js +120 -0
- package/dist/communication/worker.js.map +1 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +8 -1
- package/dist/compile.js.map +1 -1
- package/dist/failure-kinds.d.ts +30 -2
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +9 -0
- package/dist/failure-kinds.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/journal-client.d.ts +4 -1
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +11 -2
- package/dist/journal-client.js.map +1 -1
- package/dist/journal-reader.d.ts +1 -1
- package/dist/journal-reader.d.ts.map +1 -1
- package/dist/journal-reader.js +3 -1
- package/dist/journal-reader.js.map +1 -1
- package/dist/llm-worker.d.ts.map +1 -1
- package/dist/llm-worker.js +12 -1
- package/dist/llm-worker.js.map +1 -1
- package/dist/permissions-preflight.d.ts +22 -0
- package/dist/permissions-preflight.d.ts.map +1 -0
- package/dist/permissions-preflight.js +49 -0
- package/dist/permissions-preflight.js.map +1 -0
- package/dist/preflight.d.ts +13 -2
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +29 -6
- package/dist/preflight.js.map +1 -1
- package/dist/protocol.d.ts +39 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/pty-sidechannel.d.ts +7 -0
- package/dist/pty-sidechannel.d.ts.map +1 -1
- package/dist/pty-sidechannel.js.map +1 -1
- package/dist/redact.d.ts +16 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +104 -0
- package/dist/redact.js.map +1 -0
- package/dist/run-state.d.ts +124 -0
- package/dist/run-state.d.ts.map +1 -0
- package/dist/run-state.js +368 -0
- package/dist/run-state.js.map +1 -0
- package/dist/spec.d.ts +24 -1
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/step-env.d.ts +25 -0
- package/dist/step-env.d.ts.map +1 -0
- package/dist/step-env.js +34 -0
- package/dist/step-env.js.map +1 -0
- package/dist/transcript-tail.d.ts +54 -0
- package/dist/transcript-tail.d.ts.map +1 -0
- package/dist/transcript-tail.js +176 -0
- package/dist/transcript-tail.js.map +1 -0
- package/dist/worker-cli.d.ts +10 -0
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +138 -17
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker-usage.d.ts +7 -2
- package/dist/worker-usage.d.ts.map +1 -1
- package/dist/worker-usage.js +21 -3
- package/dist/worker-usage.js.map +1 -1
- package/dist/worker.d.ts +1 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +41 -7
- package/dist/worker.js.map +1 -1
- package/dist/wrapper-runtime.d.ts +7 -1
- package/dist/wrapper-runtime.d.ts.map +1 -1
- package/dist/wrapper-runtime.js +7 -1
- package/dist/wrapper-runtime.js.map +1 -1
- package/dist/wrapper-session.d.ts +8 -0
- package/dist/wrapper-session.d.ts.map +1 -1
- package/dist/wrapper-session.js +156 -23
- package/dist/wrapper-session.js.map +1 -1
- package/package.json +14 -2
- package/src/agent-artifacts.ts +27 -11
- package/src/agent-transcript.ts +651 -0
- package/src/authored-flow-error.ts +17 -0
- package/src/authored-flow-executor.ts +4 -1
- package/src/authored-node-entry.ts +5 -1
- package/src/authored-node-runner.ts +33 -1
- package/src/authored-root.ts +2 -1
- package/src/authored-source-authority.ts +13 -0
- package/src/authored-step-index.ts +157 -0
- package/src/authored-step-output.ts +66 -14
- package/src/authored-worker-step.ts +88 -15
- package/src/cli/check.ts +69 -11
- package/src/cli/cloud-read.ts +518 -0
- package/src/cli/run.ts +43 -24
- package/src/cli/status.ts +349 -0
- package/src/cli/step-failure.ts +100 -10
- package/src/cli-commands.ts +33 -0
- package/src/cli.ts +27 -0
- package/src/cloud-http.ts +32 -6
- package/src/cloud-read.ts +515 -0
- package/src/cloud-transcript.ts +422 -0
- package/src/communication/environment.ts +33 -0
- package/src/communication/history.ts +38 -0
- package/src/communication/local.ts +41 -0
- package/src/communication/preflight.ts +34 -0
- package/src/communication/projection.ts +23 -0
- package/src/communication/relay.ts +102 -0
- package/src/communication/session.ts +84 -0
- package/src/communication/spec.ts +106 -0
- package/src/communication/tool.ts +22 -0
- package/src/communication/tools.ts +50 -0
- package/src/communication/worker.ts +95 -0
- package/src/compile.ts +4 -1
- package/src/failure-kinds.ts +31 -1
- package/src/index.ts +10 -1
- package/src/journal-client.ts +12 -2
- package/src/journal-reader.ts +4 -2
- package/src/llm-worker.ts +12 -1
- package/src/permissions-preflight.ts +53 -0
- package/src/preflight.ts +42 -7
- package/src/protocol.ts +15 -0
- package/src/pty-sidechannel.ts +7 -0
- package/src/redact.ts +106 -0
- package/src/run-state.ts +468 -0
- package/src/spec.ts +18 -1
- package/src/step-env.ts +47 -0
- package/src/transcript-tail.ts +193 -0
- package/src/worker-cli.ts +139 -18
- package/src/worker-usage.ts +26 -3
- package/src/worker.ts +42 -6
- package/src/wrapper-runtime.ts +7 -1
- package/src/wrapper-session.ts +159 -24
|
@@ -4,15 +4,24 @@
|
|
|
4
4
|
* Content, not mtime: a fast rewrite inside the filesystem's timestamp
|
|
5
5
|
* resolution must still count as a change — the same rule
|
|
6
6
|
* `examples/research/shims/agent-cli.ts`'s `snapshot()` uses for the same
|
|
7
|
-
* "did the agent actually write something" question.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
7
|
+
* "did the agent actually write something" question.
|
|
8
|
+
*
|
|
9
|
+
* Dotfiles and dot-directories ARE eligible. `.workflow-artifacts/` is the
|
|
10
|
+
* conventional place a flow tells its agents to write, and a blanket dot-prefix
|
|
11
|
+
* skip made every review, report and evidence file written there invisible to
|
|
12
|
+
* the journal — and so to an `artifact_exists` gate naming one, which could
|
|
13
|
+
* then never pass. Only the three names in `SKIPPED_ENTRY_NAMES` are excluded:
|
|
14
|
+
* `.git`, the default `.relayflowd` data dir, and `node_modules`. A data dir
|
|
15
|
+
* the caller named explicitly is not one of those; the caller drops that whole
|
|
16
|
+
* subtree from the diff instead (`worker-cli.ts`).
|
|
17
|
+
*
|
|
18
|
+
* Only regular files are signed; symlinks are not followed and directories are
|
|
19
|
+
* descended, not recorded. A missing `dir` (an agent step whose cwd does not
|
|
20
|
+
* exist yet) yields an empty snapshot rather than throwing. Only a vanished
|
|
21
|
+
* path (`ENOENT`) is ever swallowed this way; any other filesystem error
|
|
22
|
+
* (permissions, `ENOTDIR`, `EISDIR`, ...) propagates, because a step whose
|
|
23
|
+
* artifact scan silently dropped files it could not read must not report a
|
|
24
|
+
* successful, incomplete `artifacts` list as if it were the truth.
|
|
16
25
|
*/
|
|
17
26
|
export declare function snapshotWorkspaceFiles(dir: string): Promise<Map<string, string>>;
|
|
18
27
|
/** `dir`-relative paths present in `after` that are new or changed since `before`, sorted. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-artifacts.d.ts","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-artifacts.d.ts","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAItF;AAsCD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAMpG"}
|
package/dist/agent-artifacts.js
CHANGED
|
@@ -4,22 +4,38 @@ import { join, relative, sep } from 'node:path';
|
|
|
4
4
|
function isEnoent(error) {
|
|
5
5
|
return error instanceof Error && error.code === 'ENOENT';
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Entry names never walked and never reported, matched exactly, at any depth,
|
|
9
|
+
* before the entry's type is consulted — so a `.git` *file* (a worktree's
|
|
10
|
+
* gitdir pointer) is skipped as surely as a `.git` directory. Exact names, not
|
|
11
|
+
* prefixes: `.github`, `.relayflowd-notes` and every other author-chosen name
|
|
12
|
+
* that merely starts the same way stays eligible.
|
|
13
|
+
*/
|
|
14
|
+
const SKIPPED_ENTRY_NAMES = new Set(['.git', '.relayflowd', 'node_modules']);
|
|
8
15
|
/**
|
|
9
16
|
* A recursive snapshot of every regular file under `dir`, keyed by its
|
|
10
17
|
* `dir`-relative POSIX path, valued by a content signature (size + sha256).
|
|
11
18
|
* Content, not mtime: a fast rewrite inside the filesystem's timestamp
|
|
12
19
|
* resolution must still count as a change — the same rule
|
|
13
20
|
* `examples/research/shims/agent-cli.ts`'s `snapshot()` uses for the same
|
|
14
|
-
* "did the agent actually write something" question.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* "did the agent actually write something" question.
|
|
22
|
+
*
|
|
23
|
+
* Dotfiles and dot-directories ARE eligible. `.workflow-artifacts/` is the
|
|
24
|
+
* conventional place a flow tells its agents to write, and a blanket dot-prefix
|
|
25
|
+
* skip made every review, report and evidence file written there invisible to
|
|
26
|
+
* the journal — and so to an `artifact_exists` gate naming one, which could
|
|
27
|
+
* then never pass. Only the three names in `SKIPPED_ENTRY_NAMES` are excluded:
|
|
28
|
+
* `.git`, the default `.relayflowd` data dir, and `node_modules`. A data dir
|
|
29
|
+
* the caller named explicitly is not one of those; the caller drops that whole
|
|
30
|
+
* subtree from the diff instead (`worker-cli.ts`).
|
|
31
|
+
*
|
|
32
|
+
* Only regular files are signed; symlinks are not followed and directories are
|
|
33
|
+
* descended, not recorded. A missing `dir` (an agent step whose cwd does not
|
|
34
|
+
* exist yet) yields an empty snapshot rather than throwing. Only a vanished
|
|
35
|
+
* path (`ENOENT`) is ever swallowed this way; any other filesystem error
|
|
36
|
+
* (permissions, `ENOTDIR`, `EISDIR`, ...) propagates, because a step whose
|
|
37
|
+
* artifact scan silently dropped files it could not read must not report a
|
|
38
|
+
* successful, incomplete `artifacts` list as if it were the truth.
|
|
23
39
|
*/
|
|
24
40
|
export async function snapshotWorkspaceFiles(dir) {
|
|
25
41
|
const out = new Map();
|
|
@@ -37,7 +53,7 @@ async function walk(root, current, out) {
|
|
|
37
53
|
throw error;
|
|
38
54
|
}
|
|
39
55
|
for (const entry of entries) {
|
|
40
|
-
if (
|
|
56
|
+
if (SKIPPED_ENTRY_NAMES.has(entry.name))
|
|
41
57
|
continue;
|
|
42
58
|
const path = join(current, entry.name);
|
|
43
59
|
if (entry.isDirectory()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-artifacts.js","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"agent-artifacts.js","sourceRoot":"","sources":["../src/agent-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAA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CAAC;QACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzH,CAAC;AACH,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAAC,MAA2B,EAAE,KAA0B;IACxF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC;QACtC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type SidechannelContext } from './pty-sidechannel.js';
|
|
2
|
+
/**
|
|
3
|
+
* Per-attempt agent transcript: the redacted, capped `stream-json` file the
|
|
4
|
+
* worker writes beside the PTY socket, and the ≤ 8 KiB digest of it that rides
|
|
5
|
+
* in `trajectory_tail` on every completion.
|
|
6
|
+
*
|
|
7
|
+
* Every bound below is enforced here and stated in what it produces — a
|
|
8
|
+
* marker line at a seam, a suffix on a cut string, a boolean on the digest —
|
|
9
|
+
* so a reader is told what was dropped rather than left to guess.
|
|
10
|
+
*/
|
|
11
|
+
/** Cap on one attempt's transcript file: the first 128 KiB whole, then a rolling tail. */
|
|
12
|
+
export declare const TRANSCRIPT_FILE_MAX_BYTES: number;
|
|
13
|
+
export declare const TRANSCRIPT_HEAD_BYTES: number;
|
|
14
|
+
export declare const TRANSCRIPT_TAIL_BYTES: number;
|
|
15
|
+
/** Cap on any one string leaf inside a frame (tool results, thinking, text). */
|
|
16
|
+
export declare const TRANSCRIPT_STRING_MAX_BYTES: number;
|
|
17
|
+
/**
|
|
18
|
+
* Cap on the serialized digest. Half the kernel's 16 KiB `trajectory_tail`
|
|
19
|
+
* boundary (relayflowd/src/server.rs), leaving room for the `relay_task`
|
|
20
|
+
* sibling the worker already journals.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TRANSCRIPT_DIGEST_MAX_BYTES: number;
|
|
23
|
+
/** Cap on an llm step's `trajectory_tail.error`; over 16 KiB the kernel refuses the completion. */
|
|
24
|
+
export declare const LLM_ERROR_MAX_BYTES: number;
|
|
25
|
+
export declare const FINAL_TEXT_MAX_BYTES: number;
|
|
26
|
+
export declare const FAILURE_EXCERPT_MAX_BYTES = 1024;
|
|
27
|
+
export declare const TOOL_INPUT_EXCERPT_MAX_CHARS = 120;
|
|
28
|
+
/**
|
|
29
|
+
* Cap on any single provider-supplied identifier copied into `result`
|
|
30
|
+
* (`model`, `session_id`, `stop_reason`, `subtype`, `claude_code_version`) and
|
|
31
|
+
* on a tool name. These are attacker-influenceable strings that no reduction
|
|
32
|
+
* step in `boundTranscriptDigest` trims, so they are bounded where they enter.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DIGEST_LABEL_MAX_BYTES = 256;
|
|
35
|
+
/**
|
|
36
|
+
* Bytes reserved inside `TRANSCRIPT_FILE_MAX_BYTES` for the
|
|
37
|
+
* `relayflow.truncated` marker, so a full head plus a full tail plus the
|
|
38
|
+
* marker still fits the stated per-attempt cap. The marker serializes to
|
|
39
|
+
* well under this even with 20-digit counters.
|
|
40
|
+
*/
|
|
41
|
+
export declare const TRUNCATION_MARKER_RESERVE = 256;
|
|
42
|
+
export declare const TOOL_COUNTS_MAX = 32;
|
|
43
|
+
export declare const TOOL_LAST_CALLS_MAX = 20;
|
|
44
|
+
export declare const ARTIFACT_PATHS_MAX = 50;
|
|
45
|
+
export interface TranscriptFile {
|
|
46
|
+
path: string;
|
|
47
|
+
/** Bytes the redacted transcript would have occupied without the file cap. */
|
|
48
|
+
bytes_total: number;
|
|
49
|
+
bytes_kept: number;
|
|
50
|
+
frames_total: number;
|
|
51
|
+
frames_kept: number;
|
|
52
|
+
truncated: boolean;
|
|
53
|
+
sha256: string;
|
|
54
|
+
}
|
|
55
|
+
export interface TranscriptToolCall {
|
|
56
|
+
seq: number;
|
|
57
|
+
name: string;
|
|
58
|
+
input_excerpt: string;
|
|
59
|
+
result_bytes?: number;
|
|
60
|
+
is_error?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface TranscriptDigest {
|
|
63
|
+
attempt?: number;
|
|
64
|
+
exit_code?: number | null;
|
|
65
|
+
file?: TranscriptFile;
|
|
66
|
+
result?: {
|
|
67
|
+
provider: 'claude' | 'codex';
|
|
68
|
+
model?: string;
|
|
69
|
+
claude_code_version?: string;
|
|
70
|
+
session_id?: string;
|
|
71
|
+
subtype?: string;
|
|
72
|
+
is_error?: boolean;
|
|
73
|
+
stop_reason?: string;
|
|
74
|
+
num_turns?: number;
|
|
75
|
+
duration_ms?: number;
|
|
76
|
+
duration_api_ms?: number;
|
|
77
|
+
total_cost_usd?: number;
|
|
78
|
+
usage?: {
|
|
79
|
+
input?: number;
|
|
80
|
+
output?: number;
|
|
81
|
+
cache_read?: number;
|
|
82
|
+
cache_creation?: number;
|
|
83
|
+
thinking?: number;
|
|
84
|
+
};
|
|
85
|
+
permission_denials?: number;
|
|
86
|
+
};
|
|
87
|
+
tools?: {
|
|
88
|
+
counts: Array<{
|
|
89
|
+
name: string;
|
|
90
|
+
calls: number;
|
|
91
|
+
errors: number;
|
|
92
|
+
}>;
|
|
93
|
+
last_calls: TranscriptToolCall[];
|
|
94
|
+
total_calls: number;
|
|
95
|
+
shown_calls: number;
|
|
96
|
+
/** False when the provider's frames are only counted, not paired (Codex). */
|
|
97
|
+
complete: boolean;
|
|
98
|
+
};
|
|
99
|
+
final_text?: string;
|
|
100
|
+
final_text_truncated?: boolean;
|
|
101
|
+
failure?: {
|
|
102
|
+
kind: 'result' | 'tool_result' | 'stderr';
|
|
103
|
+
excerpt: string;
|
|
104
|
+
truncated?: boolean;
|
|
105
|
+
};
|
|
106
|
+
artifacts?: {
|
|
107
|
+
count: number;
|
|
108
|
+
paths: string[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Set when even the ordered reductions left the digest over its cap and it
|
|
112
|
+
* was cut back to fixed-size fields — every provider-supplied string but a
|
|
113
|
+
* bounded file path is gone. A reader is told rather than left guessing.
|
|
114
|
+
*/
|
|
115
|
+
core_only?: boolean;
|
|
116
|
+
}
|
|
117
|
+
type RecordValue = Record<string, unknown>;
|
|
118
|
+
/** `…/runs/<runId>/steps/<stepId>/attempt-<n>.transcript.jsonl`, beside the PTY socket. */
|
|
119
|
+
export declare function transcriptPath(context: Pick<SidechannelContext, 'dataDir' | 'runId' | 'stepId'>, attempt: number): string;
|
|
120
|
+
/**
|
|
121
|
+
* Relay-issued token prefixes, shared with `redactRelayError` (worker-cli.ts).
|
|
122
|
+
* The tail must be at least 8 characters so journal keys such as `at_ms` are
|
|
123
|
+
* not mistaken for tokens.
|
|
124
|
+
*/
|
|
125
|
+
export declare const RELAY_TOKEN_PATTERN: RegExp;
|
|
126
|
+
export type Redactor = (text: string) => string;
|
|
127
|
+
/**
|
|
128
|
+
* One redactor for one environment: the values of secret-named variables are
|
|
129
|
+
* resolved once, so a writer redacting thousands of strings does not rescan
|
|
130
|
+
* `process.env` for each.
|
|
131
|
+
*/
|
|
132
|
+
export declare function createRedactor(env?: NodeJS.ProcessEnv): Redactor;
|
|
133
|
+
/** Redact one string against `env` (D6 rules 2–4). */
|
|
134
|
+
export declare function redactText(text: string, env?: NodeJS.ProcessEnv): string;
|
|
135
|
+
/** Cut `text` to at most `maxBytes` of UTF-8 on a code-point boundary. */
|
|
136
|
+
export declare function utf8Head(text: string, maxBytes: number): string;
|
|
137
|
+
/** The last `maxBytes` of `text`, on a code-point boundary. */
|
|
138
|
+
export declare function utf8Tail(text: string, maxBytes: number): string;
|
|
139
|
+
/** Head-cut with the truncation stated in the value itself. */
|
|
140
|
+
export declare function boundedText(text: string, maxBytes: number, label?: string): {
|
|
141
|
+
text: string;
|
|
142
|
+
truncated: boolean;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Redact and bound every string leaf of a parsed frame, and reduce the
|
|
146
|
+
* `system/init` frame to its whitelist. Unknown frame types are kept as they
|
|
147
|
+
* are, minus the same string treatment.
|
|
148
|
+
*/
|
|
149
|
+
export declare function reduceFrame(frame: unknown, redact: Redactor): unknown;
|
|
150
|
+
export interface TranscriptWriter {
|
|
151
|
+
/** One stdout line, without its newline. Never throws; a failed file is reported by `close`. */
|
|
152
|
+
write(line: string): void;
|
|
153
|
+
/** Flush the tail, finish the file, and describe it — `undefined` when the file could not be written. */
|
|
154
|
+
close(): Promise<TranscriptFile | undefined>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Open the per-attempt transcript file. The first `TRANSCRIPT_HEAD_BYTES` are
|
|
158
|
+
* written as they arrive, so a crash mid-run still leaves the start of the
|
|
159
|
+
* transcript on disk; past that a ring of the last `TRANSCRIPT_TAIL_BYTES`
|
|
160
|
+
* is kept and flushed on close, behind one `relayflow.truncated` marker line
|
|
161
|
+
* that says how much fell between them.
|
|
162
|
+
*/
|
|
163
|
+
export declare function openTranscriptWriter(path: string, env?: NodeJS.ProcessEnv): Promise<TranscriptWriter | undefined>;
|
|
164
|
+
/**
|
|
165
|
+
* Build the digest from the frames `decodeProviderResult` already parsed.
|
|
166
|
+
* Claude: `tool_use` blocks are paired with `tool_result` blocks by
|
|
167
|
+
* `tool_use_id`; `init` supplies model and version. Codex: `item.completed`
|
|
168
|
+
* items are counted by `item.type` only, so `tools.complete` is false.
|
|
169
|
+
* `failure` is filled only when the attempt did not succeed.
|
|
170
|
+
*/
|
|
171
|
+
export declare function buildTranscriptDigest(frames: RecordValue[], kind: 'claude' | 'codex', outcome: {
|
|
172
|
+
exit_code: number | null;
|
|
173
|
+
stderr_tail: string;
|
|
174
|
+
}, env?: NodeJS.ProcessEnv): Pick<TranscriptDigest, 'result' | 'tools' | 'final_text' | 'final_text_truncated' | 'failure'>;
|
|
175
|
+
/** Serialized size of the digest as it will be journaled. */
|
|
176
|
+
export declare function digestBytes(digest: TranscriptDigest): number;
|
|
177
|
+
/**
|
|
178
|
+
* Shrink the digest until it serializes to at most `TRANSCRIPT_DIGEST_MAX_BYTES`,
|
|
179
|
+
* in a fixed order: recent tool calls, artifact paths, final text, failure
|
|
180
|
+
* excerpt, tool counts. Each cut leaves its mark — `shown_calls` under
|
|
181
|
+
* `total_calls`, `artifacts.count` above `paths.length`, `final_text_truncated`,
|
|
182
|
+
* `failure.truncated` — so a reader knows the digest is not the whole account.
|
|
183
|
+
*/
|
|
184
|
+
export declare function boundTranscriptDigest(digest: TranscriptDigest): TranscriptDigest;
|
|
185
|
+
export {};
|
|
186
|
+
//# sourceMappingURL=agent-transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-transcript.d.ts","sourceRoot":"","sources":["../src/agent-transcript.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;;;;;;;GAQG;AAEH,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB,QAAc,CAAC;AACrD,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAChD,eAAO,MAAM,qBAAqB,QAAoD,CAAC;AACvF,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,QAAY,CAAC;AACrD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAW,CAAC;AACpD,mGAAmG;AACnG,eAAO,MAAM,mBAAmB,QAAW,CAAC;AAE5C,eAAO,MAAM,oBAAoB,QAAW,CAAC;AAC7C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD;;;;;GAKG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