@h-rig/runtime 0.0.6-alpha.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/README.md +27 -0
- package/dist/bin/rig-agent-dispatch.js +9615 -0
- package/dist/bin/rig-agent.js +9512 -0
- package/dist/bin/rig-browser-tool.js +269 -0
- package/dist/src/agent-mode.js +48 -0
- package/dist/src/baked-secrets.js +121 -0
- package/dist/src/binary-build-worker.js +312 -0
- package/dist/src/binary-run.js +540 -0
- package/dist/src/boundaries.js +1 -0
- package/dist/src/build-time-config.js +25 -0
- package/dist/src/control-plane/agent-roles.js +27 -0
- package/dist/src/control-plane/agent-wrapper.js +9621 -0
- package/dist/src/control-plane/authority-files.js +582 -0
- package/dist/src/control-plane/browser-contract.js +135 -0
- package/dist/src/control-plane/controlled-bash.js +1111 -0
- package/dist/src/control-plane/errors.js +13 -0
- package/dist/src/control-plane/harness-main.js +10828 -0
- package/dist/src/control-plane/hook-materializer.js +75 -0
- package/dist/src/control-plane/hooks/audit-trail.js +353 -0
- package/dist/src/control-plane/hooks/completion-verification.js +7552 -0
- package/dist/src/control-plane/hooks/import-guard.js +890 -0
- package/dist/src/control-plane/hooks/inject-context.js +4189 -0
- package/dist/src/control-plane/hooks/post-edit-lint.js +43 -0
- package/dist/src/control-plane/hooks/safety-guard.js +910 -0
- package/dist/src/control-plane/hooks/scope-guard.js +907 -0
- package/dist/src/control-plane/hooks/shared.js +44 -0
- package/dist/src/control-plane/hooks/submodule-branch.js +7797 -0
- package/dist/src/control-plane/hooks/task-runtime-start.js +7799 -0
- package/dist/src/control-plane/hooks/test-integrity-guard.js +891 -0
- package/dist/src/control-plane/materialize-task-config.js +453 -0
- package/dist/src/control-plane/memory-sync/cli.js +2019 -0
- package/dist/src/control-plane/memory-sync/db.js +753 -0
- package/dist/src/control-plane/memory-sync/embed.js +281 -0
- package/dist/src/control-plane/memory-sync/index.js +2049 -0
- package/dist/src/control-plane/memory-sync/query.js +294 -0
- package/dist/src/control-plane/memory-sync/read.js +784 -0
- package/dist/src/control-plane/memory-sync/types.js +6 -0
- package/dist/src/control-plane/memory-sync/write.js +1547 -0
- package/dist/src/control-plane/native/git-native.js +490 -0
- package/dist/src/control-plane/native/git-ops.js +2860 -0
- package/dist/src/control-plane/native/harness-cli.js +9721 -0
- package/dist/src/control-plane/native/pr-automation.js +373 -0
- package/dist/src/control-plane/native/profile-ops.js +481 -0
- package/dist/src/control-plane/native/repo-ops.js +2342 -0
- package/dist/src/control-plane/native/root-resolver.js +66 -0
- package/dist/src/control-plane/native/run-ops.js +3281 -0
- package/dist/src/control-plane/native/runtime-native-sidecar.js +299 -0
- package/dist/src/control-plane/native/runtime-native.js +392 -0
- package/dist/src/control-plane/native/scope-rules.js +17 -0
- package/dist/src/control-plane/native/task-ops.js +6320 -0
- package/dist/src/control-plane/native/task-state.js +1512 -0
- package/dist/src/control-plane/native/utils.js +535 -0
- package/dist/src/control-plane/native/validator-binaries.js +889 -0
- package/dist/src/control-plane/native/validator.js +2197 -0
- package/dist/src/control-plane/native/verifier.js +3249 -0
- package/dist/src/control-plane/native/workspace-ops.js +1635 -0
- package/dist/src/control-plane/plugin-host-context.js +334 -0
- package/dist/src/control-plane/project-main-pre-run-sync.js +630 -0
- package/dist/src/control-plane/provider/claude-stream-records.js +158 -0
- package/dist/src/control-plane/provider/codex-app-server.js +885 -0
- package/dist/src/control-plane/provider/codex-exec-records.js +203 -0
- package/dist/src/control-plane/provider/rig-task-run-skill.js +39 -0
- package/dist/src/control-plane/provider/runtime-instructions.js +96 -0
- package/dist/src/control-plane/remote.js +854 -0
- package/dist/src/control-plane/repos/index.js +473 -0
- package/dist/src/control-plane/repos/layout.js +124 -0
- package/dist/src/control-plane/repos/mirror/bootstrap.js +268 -0
- package/dist/src/control-plane/repos/mirror/refresh.js +398 -0
- package/dist/src/control-plane/repos/mirror/state.js +167 -0
- package/dist/src/control-plane/repos/registry.js +77 -0
- package/dist/src/control-plane/repos/types.js +1 -0
- package/dist/src/control-plane/runtime/agent-mode.js +48 -0
- package/dist/src/control-plane/runtime/baked-secrets.js +120 -0
- package/dist/src/control-plane/runtime/claude-tool-router-binary.js +343 -0
- package/dist/src/control-plane/runtime/claude-tool-router.js +520 -0
- package/dist/src/control-plane/runtime/context.js +216 -0
- package/dist/src/control-plane/runtime/events.js +218 -0
- package/dist/src/control-plane/runtime/guard-types.js +6 -0
- package/dist/src/control-plane/runtime/guard.js +880 -0
- package/dist/src/control-plane/runtime/image/fingerprint-sidecar.js +1194 -0
- package/dist/src/control-plane/runtime/image/index.js +2255 -0
- package/dist/src/control-plane/runtime/image-fingerprint-sidecar.js +1191 -0
- package/dist/src/control-plane/runtime/image.js +2255 -0
- package/dist/src/control-plane/runtime/index.js +8511 -0
- package/dist/src/control-plane/runtime/isolation/discovery.js +599 -0
- package/dist/src/control-plane/runtime/isolation/home.js +1217 -0
- package/dist/src/control-plane/runtime/isolation/index.js +8193 -0
- package/dist/src/control-plane/runtime/isolation/runner.js +2651 -0
- package/dist/src/control-plane/runtime/isolation/shared.js +501 -0
- package/dist/src/control-plane/runtime/isolation/toolchain.js +1892 -0
- package/dist/src/control-plane/runtime/isolation/types.js +1 -0
- package/dist/src/control-plane/runtime/isolation/worktree.js +509 -0
- package/dist/src/control-plane/runtime/isolation.js +8193 -0
- package/dist/src/control-plane/runtime/overlay.js +67 -0
- package/dist/src/control-plane/runtime/plugin-mode.js +41 -0
- package/dist/src/control-plane/runtime/plugins.js +1131 -0
- package/dist/src/control-plane/runtime/provisioning-env.js +220 -0
- package/dist/src/control-plane/runtime/queue.js +8358 -0
- package/dist/src/control-plane/runtime/rig-shell.js +205 -0
- package/dist/src/control-plane/runtime/rig-tools.js +182 -0
- package/dist/src/control-plane/runtime/runner-context.js +1 -0
- package/dist/src/control-plane/runtime/runtime-paths.js +184 -0
- package/dist/src/control-plane/runtime/sandbox/backend-bwrap.js +311 -0
- package/dist/src/control-plane/runtime/sandbox/backend-none.js +21 -0
- package/dist/src/control-plane/runtime/sandbox/backend-seatbelt.js +268 -0
- package/dist/src/control-plane/runtime/sandbox/backend.js +1718 -0
- package/dist/src/control-plane/runtime/sandbox/orchestrator.js +1745 -0
- package/dist/src/control-plane/runtime/sandbox/utils.js +137 -0
- package/dist/src/control-plane/runtime/sandbox-backend-bwrap.js +311 -0
- package/dist/src/control-plane/runtime/sandbox-backend-none.js +21 -0
- package/dist/src/control-plane/runtime/sandbox-backend-seatbelt.js +268 -0
- package/dist/src/control-plane/runtime/sandbox-backend.js +1718 -0
- package/dist/src/control-plane/runtime/sandbox-orchestrator.js +1745 -0
- package/dist/src/control-plane/runtime/sandbox-utils.js +137 -0
- package/dist/src/control-plane/runtime/snapshot/index.js +454 -0
- package/dist/src/control-plane/runtime/snapshot/sidecar.js +502 -0
- package/dist/src/control-plane/runtime/snapshot/task-run.js +1578 -0
- package/dist/src/control-plane/runtime/snapshot-sidecar.js +498 -0
- package/dist/src/control-plane/runtime/snapshot.js +454 -0
- package/dist/src/control-plane/runtime/task-run-snapshot.js +1578 -0
- package/dist/src/control-plane/runtime/tool-gateway.js +422 -0
- package/dist/src/control-plane/runtime/tooling/browser-tools.js +32 -0
- package/dist/src/control-plane/runtime/tooling/claude-router-binary.js +343 -0
- package/dist/src/control-plane/runtime/tooling/claude-router.js +524 -0
- package/dist/src/control-plane/runtime/tooling/file-tools.js +182 -0
- package/dist/src/control-plane/runtime/tooling/gateway.js +422 -0
- package/dist/src/control-plane/runtime/tooling/index.js +1290 -0
- package/dist/src/control-plane/runtime/tooling/shell.js +205 -0
- package/dist/src/control-plane/runtime/types.js +1 -0
- package/dist/src/control-plane/setup-version.js +14 -0
- package/dist/src/control-plane/state-sync/index.js +1509 -0
- package/dist/src/control-plane/state-sync/read.js +856 -0
- package/dist/src/control-plane/state-sync/reconcile.js +260 -0
- package/dist/src/control-plane/state-sync/repo.js +302 -0
- package/dist/src/control-plane/state-sync/types.js +111 -0
- package/dist/src/control-plane/state-sync/write.js +1469 -0
- package/dist/src/control-plane/task-fields.js +38 -0
- package/dist/src/control-plane/task-source-bootstrap.js +46 -0
- package/dist/src/control-plane/task-source.js +30 -0
- package/dist/src/control-plane/tasks/legacy-task-config-source.js +130 -0
- package/dist/src/control-plane/tasks/plugin-task-source.js +103 -0
- package/dist/src/control-plane/tasks/source-aware-task-config-source.js +611 -0
- package/dist/src/control-plane/tasks/source-lifecycle.js +1093 -0
- package/dist/src/control-plane/tasks/task-record-reader.js +9 -0
- package/dist/src/control-plane/validators/boundary/public-apis.js +107 -0
- package/dist/src/control-plane/validators/integration/_shared.js +51 -0
- package/dist/src/control-plane/validators/integration/adm-audit-http.js +85 -0
- package/dist/src/control-plane/validators/integration/adm-auth-http.js +78 -0
- package/dist/src/control-plane/validators/integration/adm-issuer-http.js +80 -0
- package/dist/src/control-plane/validators/integration/adm-migration.js +78 -0
- package/dist/src/control-plane/validators/integration/adm-scaffold.js +78 -0
- package/dist/src/control-plane/validators/runtime-registration.js +64 -0
- package/dist/src/control-plane/validators/shared.js +683 -0
- package/dist/src/events.js +218 -0
- package/dist/src/execution.js +35 -0
- package/dist/src/index.js +1633 -0
- package/dist/src/layout.js +145 -0
- package/dist/src/local-server.js +202 -0
- package/dist/src/plugins.js +329 -0
- package/dist/src/remote-http.js +83 -0
- package/dist/src/runtime-context.js +216 -0
- package/dist/src/types.js +1 -0
- package/native/darwin-arm64/bin/rig-git +0 -0
- package/native/darwin-arm64/bin/rig-shell +0 -0
- package/native/darwin-arm64/bin/rig-tools +0 -0
- package/native/darwin-arm64/lib/runtime-native-darwin-arm64.dylib +0 -0
- package/native/darwin-arm64/lib/runtime-native.dylib +0 -0
- package/native/darwin-arm64/manifest.json +1 -0
- package/native/linux-x64/bin/rig-git +0 -0
- package/native/linux-x64/bin/rig-shell +0 -0
- package/native/linux-x64/bin/rig-tools +0 -0
- package/native/linux-x64/lib/runtime-native-linux-x64.so +0 -0
- package/native/linux-x64/lib/runtime-native.so +0 -0
- package/native/linux-x64/manifest.json +1 -0
- package/package.json +74 -0
- package/skills/rig-task-run.md +71 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/runtime/src/control-plane/provider/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
|
+
};
|