@h-rig/provider-plugin 0.0.6-alpha.157 → 0.0.6-alpha.159
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/bin/rig-agent-dispatch.d.ts +2 -0
- package/dist/bin/rig-agent-dispatch.js +863 -0
- package/dist/src/agent-harness/agent-mode.d.ts +1 -0
- package/dist/src/agent-harness/agent-mode.js +48 -0
- package/dist/src/agent-harness/agent-wrapper.d.ts +53 -0
- package/dist/src/agent-harness/agent-wrapper.js +916 -0
- package/dist/src/agent-harness/controlled-bash.d.ts +3 -0
- package/dist/src/agent-harness/controlled-bash.js +45 -0
- package/dist/src/agent-harness/git-ops.d.ts +2 -0
- package/dist/src/agent-harness/git-ops.js +27 -0
- package/dist/src/agent-harness/repo-ops.d.ts +8 -0
- package/dist/src/agent-harness/repo-ops.js +471 -0
- package/dist/src/agent-harness/rig-agent-entrypoint.d.ts +1 -0
- package/dist/src/agent-harness/rig-agent-entrypoint.js +1277 -0
- package/dist/src/agent-harness/rig-agent.d.ts +2 -0
- package/dist/src/agent-harness/rig-agent.js +1244 -0
- package/dist/src/agent-harness/runtime-snapshot-config.d.ts +2 -0
- package/dist/src/agent-harness/runtime-snapshot-config.js +25 -0
- package/dist/src/agent-harness/task-data.d.ts +2 -0
- package/dist/src/agent-harness/task-data.js +12 -0
- package/dist/src/agent-harness/task-ops.d.ts +10 -0
- package/dist/src/agent-harness/task-ops.js +53 -0
- package/dist/src/index.js +3366 -16
- package/dist/src/pi-settings-materializer.d.ts +10 -0
- package/dist/src/pi-settings-materializer.js +52 -0
- package/dist/src/plugin.d.ts +9 -2
- package/dist/src/plugin.js +3360 -8
- package/dist/src/service.d.ts +1 -1
- package/dist/src/session-asset-materializer-service.d.ts +13 -0
- package/dist/src/session-asset-materializer-service.js +124 -0
- package/dist/src/skill-materializer.d.ts +25 -0
- package/dist/src/skill-materializer.js +46 -0
- package/dist/src/tooling/binary-build-worker.d.ts +1 -0
- package/dist/src/tooling/binary-build-worker.js +323 -0
- package/dist/src/tooling/browser-tool-entrypoint.d.ts +2 -0
- package/dist/src/tooling/browser-tool-entrypoint.js +125 -0
- package/dist/src/tooling/browser-tools.d.ts +3 -0
- package/dist/src/tooling/browser-tools.js +27 -0
- package/dist/src/tooling/claude-router-binary.d.ts +3 -0
- package/dist/src/tooling/claude-router-binary.js +381 -0
- package/dist/src/tooling/claude-router.d.ts +22 -0
- package/dist/src/tooling/claude-router.js +524 -0
- package/dist/src/tooling/embedded-native-assets.d.ts +7 -0
- package/dist/src/tooling/embedded-native-assets.js +6 -0
- package/dist/src/tooling/file-tools.d.ts +5 -0
- package/dist/src/tooling/file-tools.js +224 -0
- package/dist/src/tooling/gateway.d.ts +4 -0
- package/dist/src/tooling/gateway.js +430 -0
- package/dist/src/tooling/native-extract.d.ts +2 -0
- package/dist/src/tooling/native-extract.js +44 -0
- package/dist/src/tooling/runtime-binary-build.d.ts +88 -0
- package/dist/src/tooling/runtime-binary-build.js +480 -0
- package/dist/src/tooling/shell-tools.d.ts +5 -0
- package/dist/src/tooling/shell-tools.js +217 -0
- package/native/darwin-arm64/rig-shell +0 -0
- package/native/darwin-arm64/rig-shell.build-manifest.json +4 -0
- package/native/darwin-arm64/rig-tools +0 -0
- package/native/darwin-arm64/rig-tools.build-manifest.json +4 -0
- package/native/darwin-x64/rig-shell +0 -0
- package/native/darwin-x64/rig-tools +0 -0
- package/native/linux-arm64/rig-shell +0 -0
- package/native/linux-arm64/rig-tools +0 -0
- package/native/linux-x64/rig-shell +0 -0
- package/native/linux-x64/rig-tools +0 -0
- package/native/win32-x64/rig-shell.exe +0 -0
- package/native/win32-x64/rig-tools.exe +0 -0
- package/package.json +54 -5
- package/dist/src/claude-stream-records.d.ts +0 -24
- package/dist/src/claude-stream-records.js +0 -158
- package/dist/src/codex-app-server.d.ts +0 -16
- package/dist/src/codex-app-server.js +0 -548
- package/dist/src/codex-exec-records.d.ts +0 -27
- package/dist/src/codex-exec-records.js +0 -203
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/provider-plugin/src/tooling/shell-tools.ts
|
|
3
|
+
import { chmodSync, copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
4
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
5
|
+
import { basename, dirname, resolve as resolve2 } from "path";
|
|
6
|
+
import { RUNTIME_SHELL_TOOL_NAMES } from "@rig/contracts";
|
|
7
|
+
|
|
8
|
+
// packages/provider-plugin/src/tooling/native-extract.ts
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "fs";
|
|
10
|
+
import { tmpdir } from "os";
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
|
|
13
|
+
// packages/provider-plugin/src/tooling/embedded-native-assets.ts
|
|
14
|
+
var embeddedNatives = null;
|
|
15
|
+
|
|
16
|
+
// packages/provider-plugin/src/tooling/native-extract.ts
|
|
17
|
+
var sharedNativeOutputDir = resolve(tmpdir(), "rig-native");
|
|
18
|
+
var extractionCache = {};
|
|
19
|
+
function extractEmbeddedNative(name) {
|
|
20
|
+
if (name in extractionCache) {
|
|
21
|
+
return extractionCache[name] ?? null;
|
|
22
|
+
}
|
|
23
|
+
const entry = embeddedNatives?.[name];
|
|
24
|
+
if (!entry) {
|
|
25
|
+
extractionCache[name] = null;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const targetPath = resolve(sharedNativeOutputDir, entry.fileName);
|
|
30
|
+
mkdirSync(sharedNativeOutputDir, { recursive: true });
|
|
31
|
+
const upToDate = existsSync(targetPath) && statSync(targetPath).size === entry.size;
|
|
32
|
+
if (!upToDate) {
|
|
33
|
+
const bytes = readFileSync(entry.filePath);
|
|
34
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp`;
|
|
35
|
+
writeFileSync(tempPath, bytes, { mode: 493 });
|
|
36
|
+
renameSync(tempPath, targetPath);
|
|
37
|
+
}
|
|
38
|
+
extractionCache[name] = targetPath;
|
|
39
|
+
} catch {
|
|
40
|
+
extractionCache[name] = null;
|
|
41
|
+
}
|
|
42
|
+
return extractionCache[name] ?? null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// packages/provider-plugin/src/tooling/shell-tools.ts
|
|
46
|
+
var sharedNativeShellOutputDir = resolve2(tmpdir2(), "rig-native");
|
|
47
|
+
var sharedNativeShellOutputPath = resolve2(sharedNativeShellOutputDir, `rig-shell-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
|
|
48
|
+
function runtimeRigShellFileName() {
|
|
49
|
+
return `rig-shell${process.platform === "win32" ? ".exe" : ""}`;
|
|
50
|
+
}
|
|
51
|
+
async function ensureRigShellBinaryPath(outputPath = sharedNativeShellOutputPath) {
|
|
52
|
+
const explicitBin = process.env.RIG_NATIVE_SHELL_BIN?.trim();
|
|
53
|
+
if (explicitBin && existsSync2(explicitBin)) {
|
|
54
|
+
return explicitBin;
|
|
55
|
+
}
|
|
56
|
+
const embedded = extractEmbeddedNative("rig-shell");
|
|
57
|
+
if (embedded) {
|
|
58
|
+
return embedded;
|
|
59
|
+
}
|
|
60
|
+
const sourcePath = resolveRigShellSourcePath();
|
|
61
|
+
if (!sourcePath) {
|
|
62
|
+
const bundledBinary = resolveBundledRigShellBinaryPath();
|
|
63
|
+
if (bundledBinary) {
|
|
64
|
+
return bundledBinary;
|
|
65
|
+
}
|
|
66
|
+
throw new Error("rig-shell.zig source file not found.");
|
|
67
|
+
}
|
|
68
|
+
const zigBinary = Bun.which("zig");
|
|
69
|
+
if (!zigBinary) {
|
|
70
|
+
throw new Error("zig is required to build the native Rig shell.");
|
|
71
|
+
}
|
|
72
|
+
mkdirSync2(dirname(outputPath), { recursive: true });
|
|
73
|
+
const sourceDigest = await sha256File(sourcePath);
|
|
74
|
+
const buildKey = JSON.stringify({
|
|
75
|
+
version: 1,
|
|
76
|
+
zigBinary,
|
|
77
|
+
platform: process.platform,
|
|
78
|
+
arch: process.arch,
|
|
79
|
+
sourcePath,
|
|
80
|
+
sourceDigest
|
|
81
|
+
});
|
|
82
|
+
const manifestPath = nativeBuildManifestPath(outputPath);
|
|
83
|
+
const needsBuild = !existsSync2(outputPath) || !await hasMatchingNativeBuildManifest(manifestPath, buildKey);
|
|
84
|
+
if (!needsBuild) {
|
|
85
|
+
return outputPath;
|
|
86
|
+
}
|
|
87
|
+
const build = Bun.spawn([
|
|
88
|
+
zigBinary,
|
|
89
|
+
"build-exe",
|
|
90
|
+
sourcePath,
|
|
91
|
+
"-O",
|
|
92
|
+
"ReleaseFast",
|
|
93
|
+
`-femit-bin=${outputPath}`
|
|
94
|
+
], {
|
|
95
|
+
cwd: dirname(sourcePath),
|
|
96
|
+
stdout: "pipe",
|
|
97
|
+
stderr: "pipe"
|
|
98
|
+
});
|
|
99
|
+
const [exitCode, stdout, stderr] = await Promise.all([
|
|
100
|
+
build.exited,
|
|
101
|
+
new Response(build.stdout).text(),
|
|
102
|
+
new Response(build.stderr).text()
|
|
103
|
+
]);
|
|
104
|
+
if (exitCode !== 0 || !existsSync2(outputPath)) {
|
|
105
|
+
const details = [stderr.trim(), stdout.trim()].filter(Boolean).join(`
|
|
106
|
+
`);
|
|
107
|
+
throw new Error(`Failed to build native Rig shell: ${details || `zig exited with code ${exitCode}`}`);
|
|
108
|
+
}
|
|
109
|
+
await Bun.write(manifestPath, `${JSON.stringify({ version: 1, buildKey }, null, 2)}
|
|
110
|
+
`);
|
|
111
|
+
return outputPath;
|
|
112
|
+
}
|
|
113
|
+
async function materializeRigShellBinary(targetDir) {
|
|
114
|
+
const sourcePath = await ensureRigShellBinaryPath();
|
|
115
|
+
const targetPath = resolve2(targetDir, runtimeRigShellFileName());
|
|
116
|
+
mkdirSync2(targetDir, { recursive: true });
|
|
117
|
+
const sourceDigest = await sha256File(sourcePath);
|
|
118
|
+
const buildKey = JSON.stringify({
|
|
119
|
+
version: 1,
|
|
120
|
+
sourcePath,
|
|
121
|
+
sourceDigest
|
|
122
|
+
});
|
|
123
|
+
const needsCopy = !existsSync2(targetPath) || !await hasMatchingNativeBuildManifest(nativeBuildManifestPath(targetPath), buildKey);
|
|
124
|
+
if (needsCopy) {
|
|
125
|
+
copyFileSync(sourcePath, targetPath);
|
|
126
|
+
chmodSync(targetPath, 493);
|
|
127
|
+
await Bun.write(nativeBuildManifestPath(targetPath), `${JSON.stringify({ version: 1, buildKey }, null, 2)}
|
|
128
|
+
`);
|
|
129
|
+
}
|
|
130
|
+
return targetPath;
|
|
131
|
+
}
|
|
132
|
+
function resolveRigShellSourcePath() {
|
|
133
|
+
for (const candidate of rigShellSourceCandidates()) {
|
|
134
|
+
if (candidate && existsSync2(candidate)) {
|
|
135
|
+
return candidate;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
function resolveBundledRigShellBinaryPath() {
|
|
141
|
+
for (const candidate of rigShellBinaryCandidates()) {
|
|
142
|
+
if (candidate && existsSync2(candidate)) {
|
|
143
|
+
return candidate;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function rigShellSourceCandidates() {
|
|
149
|
+
const execDir = process.execPath?.trim() ? dirname(process.execPath.trim()) : "";
|
|
150
|
+
const cwd = process.cwd()?.trim() || "";
|
|
151
|
+
const projectRoot = process.env.PROJECT_RIG_ROOT?.trim() || "";
|
|
152
|
+
const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim() || "";
|
|
153
|
+
return [...new Set([
|
|
154
|
+
process.env.RIG_NATIVE_SHELL_SOURCE?.trim() || "",
|
|
155
|
+
cwd ? resolve2(cwd, "packages/provider-plugin/native/rig-shell.zig") : "",
|
|
156
|
+
projectRoot ? resolve2(projectRoot, "packages/provider-plugin/native/rig-shell.zig") : "",
|
|
157
|
+
hostProjectRoot ? resolve2(hostProjectRoot, "packages/provider-plugin/native/rig-shell.zig") : "",
|
|
158
|
+
execDir ? resolve2(execDir, "..", "..", "packages/provider-plugin/native/rig-shell.zig") : "",
|
|
159
|
+
execDir ? resolve2(execDir, "..", "native", "rig-shell.zig") : "",
|
|
160
|
+
resolve2(import.meta.dir, "../../native/rig-shell.zig")
|
|
161
|
+
].filter(Boolean))];
|
|
162
|
+
}
|
|
163
|
+
function nativePackageBinaryCandidates(fromDir, fileName) {
|
|
164
|
+
const candidates = [];
|
|
165
|
+
let cursor = resolve2(fromDir);
|
|
166
|
+
for (let index = 0;index < 8; index += 1) {
|
|
167
|
+
candidates.push(resolve2(cursor, "native", `${process.platform}-${process.arch}`, fileName), resolve2(cursor, "native", `${process.platform}-${process.arch}`, "bin", fileName), resolve2(cursor, "native", fileName), resolve2(cursor, "native", "bin", fileName));
|
|
168
|
+
const parent = dirname(cursor);
|
|
169
|
+
if (parent === cursor)
|
|
170
|
+
break;
|
|
171
|
+
cursor = parent;
|
|
172
|
+
}
|
|
173
|
+
return candidates;
|
|
174
|
+
}
|
|
175
|
+
function rigShellBinaryCandidates() {
|
|
176
|
+
const execDir = process.execPath?.trim() ? dirname(process.execPath.trim()) : "";
|
|
177
|
+
const fileName = runtimeRigShellFileName();
|
|
178
|
+
return [...new Set([
|
|
179
|
+
process.env.RIG_NATIVE_SHELL_BIN?.trim() || "",
|
|
180
|
+
...nativePackageBinaryCandidates(import.meta.dir, fileName),
|
|
181
|
+
execDir ? resolve2(execDir, fileName) : "",
|
|
182
|
+
execDir ? resolve2(execDir, "..", fileName) : "",
|
|
183
|
+
execDir ? resolve2(execDir, "..", "bin", fileName) : ""
|
|
184
|
+
].filter(Boolean))];
|
|
185
|
+
}
|
|
186
|
+
function runtimeToolGatewayNames() {
|
|
187
|
+
return [...RUNTIME_SHELL_TOOL_NAMES];
|
|
188
|
+
}
|
|
189
|
+
function shellBinaryBasename(path) {
|
|
190
|
+
return basename(path);
|
|
191
|
+
}
|
|
192
|
+
function nativeBuildManifestPath(outputPath) {
|
|
193
|
+
return `${outputPath}.build-manifest.json`;
|
|
194
|
+
}
|
|
195
|
+
async function hasMatchingNativeBuildManifest(manifestPath, buildKey) {
|
|
196
|
+
if (!existsSync2(manifestPath)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const manifest = await Bun.file(manifestPath).json();
|
|
201
|
+
return manifest.version === 1 && manifest.buildKey === buildKey;
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function sha256File(path) {
|
|
207
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
208
|
+
hasher.update(await Bun.file(path).arrayBuffer());
|
|
209
|
+
return hasher.digest("hex");
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
shellBinaryBasename,
|
|
213
|
+
runtimeToolGatewayNames,
|
|
214
|
+
runtimeRigShellFileName,
|
|
215
|
+
materializeRigShellBinary,
|
|
216
|
+
ensureRigShellBinaryPath
|
|
217
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/provider-plugin",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.159",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "First-party agent-harness provider capability plugin for Rig.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
|
-
"README.md"
|
|
9
|
+
"README.md",
|
|
10
|
+
"native"
|
|
10
11
|
],
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
@@ -20,6 +21,54 @@
|
|
|
20
21
|
"./index": {
|
|
21
22
|
"types": "./dist/src/index.d.ts",
|
|
22
23
|
"import": "./dist/src/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./agent-harness/rig-agent": {
|
|
26
|
+
"types": "./dist/src/agent-harness/rig-agent.d.ts",
|
|
27
|
+
"import": "./dist/src/agent-harness/rig-agent.js"
|
|
28
|
+
},
|
|
29
|
+
"./agent-harness/rig-agent-entrypoint": {
|
|
30
|
+
"types": "./dist/src/agent-harness/rig-agent-entrypoint.d.ts",
|
|
31
|
+
"import": "./dist/src/agent-harness/rig-agent-entrypoint.js"
|
|
32
|
+
},
|
|
33
|
+
"./agent-harness/agent-wrapper": {
|
|
34
|
+
"types": "./dist/src/agent-harness/agent-wrapper.d.ts",
|
|
35
|
+
"import": "./dist/src/agent-harness/agent-wrapper.js"
|
|
36
|
+
},
|
|
37
|
+
"./tooling/gateway": {
|
|
38
|
+
"types": "./dist/src/tooling/gateway.d.ts",
|
|
39
|
+
"import": "./dist/src/tooling/gateway.js"
|
|
40
|
+
},
|
|
41
|
+
"./pi-settings-materializer": {
|
|
42
|
+
"types": "./dist/src/pi-settings-materializer.d.ts",
|
|
43
|
+
"import": "./dist/src/pi-settings-materializer.js"
|
|
44
|
+
},
|
|
45
|
+
"./skill-materializer": {
|
|
46
|
+
"types": "./dist/src/skill-materializer.d.ts",
|
|
47
|
+
"import": "./dist/src/skill-materializer.js"
|
|
48
|
+
},
|
|
49
|
+
"./tooling/browser-tools": {
|
|
50
|
+
"types": "./dist/src/tooling/browser-tools.d.ts",
|
|
51
|
+
"import": "./dist/src/tooling/browser-tools.js"
|
|
52
|
+
},
|
|
53
|
+
"./tooling/browser-tool-entrypoint": {
|
|
54
|
+
"types": "./dist/src/tooling/browser-tool-entrypoint.d.ts",
|
|
55
|
+
"import": "./dist/src/tooling/browser-tool-entrypoint.js"
|
|
56
|
+
},
|
|
57
|
+
"./tooling/claude-router": {
|
|
58
|
+
"types": "./dist/src/tooling/claude-router.d.ts",
|
|
59
|
+
"import": "./dist/src/tooling/claude-router.js"
|
|
60
|
+
},
|
|
61
|
+
"./tooling/claude-router-binary": {
|
|
62
|
+
"types": "./dist/src/tooling/claude-router-binary.d.ts",
|
|
63
|
+
"import": "./dist/src/tooling/claude-router-binary.js"
|
|
64
|
+
},
|
|
65
|
+
"./tooling/shell-tools": {
|
|
66
|
+
"types": "./dist/src/tooling/shell-tools.d.ts",
|
|
67
|
+
"import": "./dist/src/tooling/shell-tools.js"
|
|
68
|
+
},
|
|
69
|
+
"./tooling/file-tools": {
|
|
70
|
+
"types": "./dist/src/tooling/file-tools.d.ts",
|
|
71
|
+
"import": "./dist/src/tooling/file-tools.js"
|
|
23
72
|
}
|
|
24
73
|
},
|
|
25
74
|
"engines": {
|
|
@@ -29,8 +78,8 @@
|
|
|
29
78
|
"module": "./dist/src/index.js",
|
|
30
79
|
"types": "./dist/src/index.d.ts",
|
|
31
80
|
"dependencies": {
|
|
32
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
33
|
-
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.
|
|
34
|
-
"@rig/
|
|
81
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.159",
|
|
82
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.159",
|
|
83
|
+
"@rig/skill-loader": "npm:@h-rig/skill-loader@0.0.6-alpha.159"
|
|
35
84
|
}
|
|
36
85
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { EngineRunLog } from "@rig/contracts";
|
|
2
|
-
type ClaudeStreamStatus = EngineRunLog["status"];
|
|
3
|
-
export type PendingClaudeToolUse = {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string | null;
|
|
6
|
-
input: unknown;
|
|
7
|
-
timestamp: string;
|
|
8
|
-
record: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
type BuildClaudeLogsFromRecordInput = {
|
|
11
|
-
runId: string;
|
|
12
|
-
record: Record<string, unknown>;
|
|
13
|
-
createdAtFallback: string;
|
|
14
|
-
status: ClaudeStreamStatus;
|
|
15
|
-
pendingToolUses: Map<string, PendingClaudeToolUse>;
|
|
16
|
-
includeMessageLogs?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare function buildClaudeLogsFromRecord(input: BuildClaudeLogsFromRecordInput): EngineRunLog[];
|
|
19
|
-
export declare function flushPendingClaudeToolUseLogs(input: {
|
|
20
|
-
runId: string;
|
|
21
|
-
status: ClaudeStreamStatus;
|
|
22
|
-
pendingToolUses: Map<string, PendingClaudeToolUse>;
|
|
23
|
-
}): EngineRunLog[];
|
|
24
|
-
export {};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/provider-plugin/src/claude-stream-records.ts
|
|
3
|
-
function asRecord(value) {
|
|
4
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
5
|
-
}
|
|
6
|
-
function normalizeString(value) {
|
|
7
|
-
if (typeof value !== "string") {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const trimmed = value.trim();
|
|
11
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
12
|
-
}
|
|
13
|
-
function normalizeIsoTimestamp(value) {
|
|
14
|
-
const normalized = normalizeString(value);
|
|
15
|
-
if (!normalized) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const timestamp = Date.parse(normalized);
|
|
19
|
-
return Number.isNaN(timestamp) ? null : new Date(timestamp).toISOString();
|
|
20
|
-
}
|
|
21
|
-
function buildClaudeLogsFromRecord(input) {
|
|
22
|
-
const logs = [];
|
|
23
|
-
const entryType = normalizeString(input.record.type);
|
|
24
|
-
const createdAt = normalizeIsoTimestamp(input.record.timestamp) ?? input.createdAtFallback;
|
|
25
|
-
if (entryType === "summary") {
|
|
26
|
-
return logs;
|
|
27
|
-
}
|
|
28
|
-
if (entryType === "system" || entryType === "result") {
|
|
29
|
-
logs.push({
|
|
30
|
-
id: normalizeString(input.record.uuid) ?? `${input.runId}-claude-${Date.now()}`,
|
|
31
|
-
runId: input.runId,
|
|
32
|
-
title: entryType === "result" ? "Agent result" : "Agent session initialized",
|
|
33
|
-
detail: JSON.stringify(input.record),
|
|
34
|
-
tone: entryType === "result" && input.record.is_error === true ? "error" : "info",
|
|
35
|
-
status: input.status,
|
|
36
|
-
payload: input.record,
|
|
37
|
-
createdAt
|
|
38
|
-
});
|
|
39
|
-
return logs;
|
|
40
|
-
}
|
|
41
|
-
const message = asRecord(input.record.message);
|
|
42
|
-
if (!message) {
|
|
43
|
-
return logs;
|
|
44
|
-
}
|
|
45
|
-
const role = normalizeString(message.role) ?? entryType ?? "assistant";
|
|
46
|
-
const content = Array.isArray(message.content) ? message.content : [];
|
|
47
|
-
for (const item of content) {
|
|
48
|
-
const contentRecord = asRecord(item);
|
|
49
|
-
if (!contentRecord) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const contentType = normalizeString(contentRecord.type);
|
|
53
|
-
if (contentType === "tool_use") {
|
|
54
|
-
const toolUseId = normalizeString(contentRecord.id) ?? normalizeString(contentRecord.tool_use_id);
|
|
55
|
-
if (!toolUseId) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
input.pendingToolUses.set(toolUseId, {
|
|
59
|
-
id: toolUseId,
|
|
60
|
-
name: normalizeString(contentRecord.name) ?? normalizeString(contentRecord.tool_name),
|
|
61
|
-
input: contentRecord.input ?? contentRecord.tool_input ?? {},
|
|
62
|
-
timestamp: createdAt,
|
|
63
|
-
record: contentRecord
|
|
64
|
-
});
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (contentType === "tool_result") {
|
|
68
|
-
const toolUseId = normalizeString(contentRecord.tool_use_id);
|
|
69
|
-
const pending = toolUseId ? input.pendingToolUses.get(toolUseId) ?? null : null;
|
|
70
|
-
if (pending && toolUseId) {
|
|
71
|
-
input.pendingToolUses.delete(toolUseId);
|
|
72
|
-
}
|
|
73
|
-
logs.push({
|
|
74
|
-
id: toolUseId ? `${input.runId}-claude-tool-${toolUseId}` : normalizeString(input.record.uuid) ?? `${input.runId}-claude-${Date.now()}`,
|
|
75
|
-
runId: input.runId,
|
|
76
|
-
title: "Tool activity",
|
|
77
|
-
detail: JSON.stringify({
|
|
78
|
-
type: "claude_tool_activity",
|
|
79
|
-
session_id: normalizeString(input.record.sessionId) ?? normalizeString(input.record.session_id),
|
|
80
|
-
uuid: normalizeString(input.record.uuid),
|
|
81
|
-
tool_use_id: toolUseId,
|
|
82
|
-
tool_name: pending?.name ?? null,
|
|
83
|
-
tool_input: pending?.input ?? null,
|
|
84
|
-
tool_result: contentRecord.content ?? contentRecord,
|
|
85
|
-
is_error: contentRecord.is_error === true,
|
|
86
|
-
raw: {
|
|
87
|
-
toolUse: pending?.record ?? null,
|
|
88
|
-
toolResult: contentRecord
|
|
89
|
-
}
|
|
90
|
-
}),
|
|
91
|
-
tone: contentRecord.is_error === true ? "error" : "tool",
|
|
92
|
-
status: input.status,
|
|
93
|
-
payload: {
|
|
94
|
-
toolUseId,
|
|
95
|
-
toolName: pending?.name ?? null,
|
|
96
|
-
toolInput: pending?.input ?? null,
|
|
97
|
-
content: contentRecord.content ?? null,
|
|
98
|
-
isError: contentRecord.is_error === true
|
|
99
|
-
},
|
|
100
|
-
createdAt: pending?.timestamp ?? createdAt
|
|
101
|
-
});
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (!input.includeMessageLogs) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
logs.push({
|
|
108
|
-
id: normalizeString(input.record.uuid) ? `${normalizeString(input.record.uuid)}:${contentType ?? "content"}:${logs.length + 1}` : `${input.runId}-claude-${Date.now()}-${logs.length + 1}`,
|
|
109
|
-
runId: input.runId,
|
|
110
|
-
title: role === "assistant" ? "Assistant output" : role === "user" ? "Tool activity" : "Agent output",
|
|
111
|
-
detail: JSON.stringify({
|
|
112
|
-
type: role,
|
|
113
|
-
message: {
|
|
114
|
-
role,
|
|
115
|
-
content: [contentRecord]
|
|
116
|
-
},
|
|
117
|
-
session_id: normalizeString(input.record.sessionId) ?? normalizeString(input.record.session_id),
|
|
118
|
-
uuid: normalizeString(input.record.uuid)
|
|
119
|
-
}),
|
|
120
|
-
tone: contentType === "text" ? "info" : "tool",
|
|
121
|
-
status: input.status,
|
|
122
|
-
payload: contentRecord,
|
|
123
|
-
createdAt
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return logs;
|
|
127
|
-
}
|
|
128
|
-
function flushPendingClaudeToolUseLogs(input) {
|
|
129
|
-
const logs = [];
|
|
130
|
-
for (const pending of input.pendingToolUses.values()) {
|
|
131
|
-
logs.push({
|
|
132
|
-
id: `${input.runId}-claude-tool-${pending.id}`,
|
|
133
|
-
runId: input.runId,
|
|
134
|
-
title: "Tool activity",
|
|
135
|
-
detail: JSON.stringify({
|
|
136
|
-
type: "claude_tool_use",
|
|
137
|
-
tool_use_id: pending.id,
|
|
138
|
-
tool_name: pending.name,
|
|
139
|
-
tool_input: pending.input,
|
|
140
|
-
raw: pending.record
|
|
141
|
-
}),
|
|
142
|
-
tone: "tool",
|
|
143
|
-
status: input.status,
|
|
144
|
-
payload: {
|
|
145
|
-
toolUseId: pending.id,
|
|
146
|
-
toolName: pending.name,
|
|
147
|
-
toolInput: pending.input
|
|
148
|
-
},
|
|
149
|
-
createdAt: pending.timestamp
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
input.pendingToolUses.clear();
|
|
153
|
-
return logs;
|
|
154
|
-
}
|
|
155
|
-
export {
|
|
156
|
-
flushPendingClaudeToolUseLogs,
|
|
157
|
-
buildClaudeLogsFromRecord
|
|
158
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const CODEX_APP_SERVER_TASK_RUN_SENTINEL = "__rig_codex_app_server_task_run__";
|
|
2
|
-
export type CodexAppServerTaskRunConfig = {
|
|
3
|
-
model?: string;
|
|
4
|
-
prompt: string;
|
|
5
|
-
runtimeMode: string;
|
|
6
|
-
interactionMode?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function buildCodexAppServerArgs(): string[];
|
|
9
|
-
export declare function parseCodexAppServerTaskRunArgs(argv: string[]): CodexAppServerTaskRunConfig | null;
|
|
10
|
-
export declare function runCodexAppServerTaskRun(options: {
|
|
11
|
-
codexBinary: string;
|
|
12
|
-
launchArgs: string[];
|
|
13
|
-
cwd: string;
|
|
14
|
-
env: Record<string, string | undefined>;
|
|
15
|
-
config: CodexAppServerTaskRunConfig;
|
|
16
|
-
}): Promise<number>;
|