@addai/node 0.4.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 +96 -0
- package/dist/agent-auth.d.ts +9 -0
- package/dist/agent-auth.js +96 -0
- package/dist/attachments.d.ts +20 -0
- package/dist/attachments.js +164 -0
- package/dist/capabilities.d.ts +64 -0
- package/dist/capabilities.js +406 -0
- package/dist/claude-binary.d.ts +16 -0
- package/dist/claude-binary.js +145 -0
- package/dist/claude-config.d.ts +11 -0
- package/dist/claude-config.js +144 -0
- package/dist/claude-print.d.ts +35 -0
- package/dist/claude-print.js +312 -0
- package/dist/claude-spawn.d.ts +40 -0
- package/dist/claude-spawn.js +220 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +137 -0
- package/dist/codex-binary.d.ts +4 -0
- package/dist/codex-binary.js +70 -0
- package/dist/codex-spawn.d.ts +47 -0
- package/dist/codex-spawn.js +320 -0
- package/dist/command-runner.d.ts +9 -0
- package/dist/command-runner.js +592 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +38 -0
- package/dist/control-server.d.ts +5 -0
- package/dist/control-server.js +292 -0
- package/dist/diskguard.d.ts +96 -0
- package/dist/diskguard.js +435 -0
- package/dist/error-classify.d.ts +20 -0
- package/dist/error-classify.js +159 -0
- package/dist/events.d.ts +26 -0
- package/dist/events.js +97 -0
- package/dist/gemini-binary.d.ts +4 -0
- package/dist/gemini-binary.js +64 -0
- package/dist/gemini-spawn.d.ts +52 -0
- package/dist/gemini-spawn.js +369 -0
- package/dist/git-identity.d.ts +18 -0
- package/dist/git-identity.js +104 -0
- package/dist/grok-binary.d.ts +4 -0
- package/dist/grok-binary.js +70 -0
- package/dist/grok-spawn.d.ts +41 -0
- package/dist/grok-spawn.js +495 -0
- package/dist/guardrails.d.ts +32 -0
- package/dist/guardrails.js +125 -0
- package/dist/hang-watchdog.d.ts +17 -0
- package/dist/hang-watchdog.js +48 -0
- package/dist/harness-registry.d.ts +55 -0
- package/dist/harness-registry.js +180 -0
- package/dist/heartbeat.d.ts +13 -0
- package/dist/heartbeat.js +95 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +440 -0
- package/dist/install.d.ts +63 -0
- package/dist/install.js +467 -0
- package/dist/jsonl-tail.d.ts +20 -0
- package/dist/jsonl-tail.js +192 -0
- package/dist/kimi-binary.d.ts +4 -0
- package/dist/kimi-binary.js +68 -0
- package/dist/kimi-spawn.d.ts +47 -0
- package/dist/kimi-spawn.js +319 -0
- package/dist/lockfile.d.ts +30 -0
- package/dist/lockfile.js +169 -0
- package/dist/mcp-config.d.ts +23 -0
- package/dist/mcp-config.js +133 -0
- package/dist/memory-capture.d.ts +20 -0
- package/dist/memory-capture.js +45 -0
- package/dist/memory-pack.d.ts +34 -0
- package/dist/memory-pack.js +171 -0
- package/dist/model-filter.d.ts +4 -0
- package/dist/model-filter.js +34 -0
- package/dist/node-health.d.ts +18 -0
- package/dist/node-health.js +74 -0
- package/dist/pairing.d.ts +20 -0
- package/dist/pairing.js +129 -0
- package/dist/paths.d.ts +9 -0
- package/dist/paths.js +48 -0
- package/dist/precompact-hook.d.ts +27 -0
- package/dist/precompact-hook.js +136 -0
- package/dist/projects.d.ts +25 -0
- package/dist/projects.js +255 -0
- package/dist/prompt-keystrokes.d.ts +3 -0
- package/dist/prompt-keystrokes.js +56 -0
- package/dist/pty-helper.d.ts +26 -0
- package/dist/pty-helper.js +156 -0
- package/dist/request-pump.d.ts +12 -0
- package/dist/request-pump.js +249 -0
- package/dist/run-retry.d.ts +28 -0
- package/dist/run-retry.js +81 -0
- package/dist/self-update.d.ts +75 -0
- package/dist/self-update.js +192 -0
- package/dist/session-runner.d.ts +130 -0
- package/dist/session-runner.js +2271 -0
- package/dist/sleep-detector.d.ts +11 -0
- package/dist/sleep-detector.js +32 -0
- package/dist/state-migrate.d.ts +8 -0
- package/dist/state-migrate.js +91 -0
- package/dist/store.d.ts +5 -0
- package/dist/store.js +82 -0
- package/dist/supabase-client.d.ts +15 -0
- package/dist/supabase-client.js +119 -0
- package/dist/time-context.d.ts +10 -0
- package/dist/time-context.js +71 -0
- package/dist/tokens.d.ts +4 -0
- package/dist/tokens.js +33 -0
- package/dist/tui/app.d.ts +35 -0
- package/dist/tui/app.js +82 -0
- package/dist/tui/console-capture.d.ts +13 -0
- package/dist/tui/console-capture.js +62 -0
- package/dist/tui/dashboard.d.ts +42 -0
- package/dist/tui/dashboard.js +205 -0
- package/dist/tui/data.d.ts +57 -0
- package/dist/tui/data.js +62 -0
- package/dist/tui/harnesses.d.ts +16 -0
- package/dist/tui/harnesses.js +354 -0
- package/dist/tui/render.d.ts +21 -0
- package/dist/tui/render.js +116 -0
- package/dist/tui/requests.d.ts +18 -0
- package/dist/tui/requests.js +127 -0
- package/dist/tui/run.d.ts +13 -0
- package/dist/tui/run.js +178 -0
- package/dist/tui/transcript.d.ts +39 -0
- package/dist/tui/transcript.js +234 -0
- package/dist/tui.d.ts +1 -0
- package/dist/tui.js +314 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +3 -0
- package/dist/win.d.ts +67 -0
- package/dist/win.js +317 -0
- package/package.json +60 -0
- package/scripts/fix-pty-helper.js +28 -0
- package/scripts/precompact-capture.js +292 -0
- package/scripts/smoke-test.sh +74 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** How this daemon was launched — decides how to respawn it. */
|
|
2
|
+
export type LaunchMode =
|
|
3
|
+
/** `npm i -g @addai/node` → a versioned dir under a global prefix. */
|
|
4
|
+
'global'
|
|
5
|
+
/** `npx @addai/node` → a throwaway dir under npm's _npx cache. */
|
|
6
|
+
| 'npx'
|
|
7
|
+
/** `node dist/cli.js` from a git checkout — restart only, never version-bump. */
|
|
8
|
+
| 'source';
|
|
9
|
+
export interface RespawnPlan {
|
|
10
|
+
/** Executable to spawn. */
|
|
11
|
+
file: string;
|
|
12
|
+
/** Argv for it. */
|
|
13
|
+
args: string[];
|
|
14
|
+
/** Whether a global install must succeed first for the version to change. */
|
|
15
|
+
installFirst: boolean;
|
|
16
|
+
/** False when the launch mode cannot change version (source checkouts). */
|
|
17
|
+
canChangeVersion: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const PACKAGE_NAME = "@addai/node";
|
|
20
|
+
/**
|
|
21
|
+
* Classify the launch from the running script's path.
|
|
22
|
+
*
|
|
23
|
+
* npx caches each invocation under `<npm-cache>/_npx/<hash>/node_modules/…`,
|
|
24
|
+
* so that segment is the reliable npx tell on every platform (checked first:
|
|
25
|
+
* an npx dir also contains `node_modules`, so a node_modules-based `global`
|
|
26
|
+
* test would swallow it). A global install lives under a prefix's
|
|
27
|
+
* `node_modules/@addai/node`. Anything else — most importantly
|
|
28
|
+
* `node dist/cli.js` in a git worktree — is a source checkout.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectLaunchMode(entryPath: string): LaunchMode;
|
|
31
|
+
/**
|
|
32
|
+
* Argv for the replacement daemon.
|
|
33
|
+
*
|
|
34
|
+
* - `global`: npm overwrites the package in place, so re-execing the SAME
|
|
35
|
+
* entry path picks up the new code. (Re-resolving through the shim would
|
|
36
|
+
* also work but adds a Windows .cmd hop for no benefit.)
|
|
37
|
+
* - `npx`: the current entry lives in a cache dir pinned to the OLD version,
|
|
38
|
+
* so re-execing it would relaunch the old code forever. Go back through
|
|
39
|
+
* npx with an explicit version spec instead.
|
|
40
|
+
* - `source`: re-exec the same entry. A checkout's version comes from git,
|
|
41
|
+
* not npm, so this is a restart — never a version change.
|
|
42
|
+
*/
|
|
43
|
+
export declare function planRespawn(mode: LaunchMode, entryPath: string, targetVersion: string, execPath?: string,
|
|
44
|
+
/** Args the daemon was started WITH, after the entry path (process.argv
|
|
45
|
+
* slice(2)) — carried across the restart so a node launched as
|
|
46
|
+
* `… cli.js run --foo` doesn't silently come back up without them. */
|
|
47
|
+
userArgs?: string[]): RespawnPlan;
|
|
48
|
+
export interface RestartHandoff {
|
|
49
|
+
command_id: string;
|
|
50
|
+
from_version: string;
|
|
51
|
+
target_version: string;
|
|
52
|
+
mode: LaunchMode;
|
|
53
|
+
at: string;
|
|
54
|
+
/** Runs that finished during the drain, and runs still going when the
|
|
55
|
+
* drain ceiling expired — carried so the roll reports whether it left
|
|
56
|
+
* work unfinished rather than claiming a clean restart either way. */
|
|
57
|
+
drained?: number;
|
|
58
|
+
timed_out?: number;
|
|
59
|
+
}
|
|
60
|
+
export declare function handoffPath(runtimeDir: string): string;
|
|
61
|
+
export declare function writeHandoff(runtimeDir: string, h: RestartHandoff): void;
|
|
62
|
+
/** Reads and DELETES the handoff — it must never be replayed twice. */
|
|
63
|
+
export declare function takeHandoff(runtimeDir: string): RestartHandoff | null;
|
|
64
|
+
/**
|
|
65
|
+
* `npm i -g <pkg>@<version>`. Returns null on success, else the reason.
|
|
66
|
+
* Never throws — a failed install must leave the CURRENT daemon running
|
|
67
|
+
* rather than take the node down.
|
|
68
|
+
*/
|
|
69
|
+
export declare function installGlobal(targetVersion: string, timeoutMs?: number): Promise<string | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Spawn the replacement daemon fully detached, so it survives this process's
|
|
72
|
+
* exit. stdio is redirected to the daemon log (inheriting our stdio would tie
|
|
73
|
+
* the child to a terminal that is about to go away).
|
|
74
|
+
*/
|
|
75
|
+
export declare function spawnReplacement(plan: RespawnPlan, logPath: string, cwd?: string): void;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Remote restart / self-update.
|
|
3
|
+
//
|
|
4
|
+
// Until now a runtime change only reached the fleet if somebody walked to
|
|
5
|
+
// each AiNode and restarted the daemon by hand — which is why the fleet sat
|
|
6
|
+
// on 0.2.51/0.2.52/0.2.53 for days after 0.2.55 shipped. This module lets an
|
|
7
|
+
// `update_runtime` command (issued from Entity Studio, executed by
|
|
8
|
+
// command-runner) drain the node gracefully, install the requested version,
|
|
9
|
+
// and re-exec itself.
|
|
10
|
+
//
|
|
11
|
+
// The daemon is NOT supervised on any of our nodes — nothing restarts it if
|
|
12
|
+
// it merely exits. So the restart is a self-respawn: we spawn a DETACHED
|
|
13
|
+
// child that outlives us, then exit. Getting the child's argv right depends
|
|
14
|
+
// on how this daemon was started, hence the launch detection below.
|
|
15
|
+
//
|
|
16
|
+
// Truth contract (same shape as the harness-login flow): the command is NOT
|
|
17
|
+
// completed by the process that exits. It is left `running` with a
|
|
18
|
+
// handoff file on disk, and the NEWLY STARTED daemon completes it on boot
|
|
19
|
+
// with the version it actually came up as. A restart that never comes back
|
|
20
|
+
// therefore never reports success.
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
37
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
+
var ownKeys = function(o) {
|
|
39
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
+
var ar = [];
|
|
41
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
return function (mod) {
|
|
47
|
+
if (mod && mod.__esModule) return mod;
|
|
48
|
+
var result = {};
|
|
49
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
+
__setModuleDefault(result, mod);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
})();
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.PACKAGE_NAME = void 0;
|
|
56
|
+
exports.detectLaunchMode = detectLaunchMode;
|
|
57
|
+
exports.planRespawn = planRespawn;
|
|
58
|
+
exports.handoffPath = handoffPath;
|
|
59
|
+
exports.writeHandoff = writeHandoff;
|
|
60
|
+
exports.takeHandoff = takeHandoff;
|
|
61
|
+
exports.installGlobal = installGlobal;
|
|
62
|
+
exports.spawnReplacement = spawnReplacement;
|
|
63
|
+
const child_process_1 = require("child_process");
|
|
64
|
+
const fs = __importStar(require("fs"));
|
|
65
|
+
const path = __importStar(require("path"));
|
|
66
|
+
const win_1 = require("./win");
|
|
67
|
+
exports.PACKAGE_NAME = '@addai/node';
|
|
68
|
+
/**
|
|
69
|
+
* Classify the launch from the running script's path.
|
|
70
|
+
*
|
|
71
|
+
* npx caches each invocation under `<npm-cache>/_npx/<hash>/node_modules/…`,
|
|
72
|
+
* so that segment is the reliable npx tell on every platform (checked first:
|
|
73
|
+
* an npx dir also contains `node_modules`, so a node_modules-based `global`
|
|
74
|
+
* test would swallow it). A global install lives under a prefix's
|
|
75
|
+
* `node_modules/@addai/node`. Anything else — most importantly
|
|
76
|
+
* `node dist/cli.js` in a git worktree — is a source checkout.
|
|
77
|
+
*/
|
|
78
|
+
function detectLaunchMode(entryPath) {
|
|
79
|
+
const p = entryPath.replace(/\\/g, '/');
|
|
80
|
+
if (/\/_npx\//.test(p))
|
|
81
|
+
return 'npx';
|
|
82
|
+
if (p.includes(`/node_modules/${exports.PACKAGE_NAME}/`))
|
|
83
|
+
return 'global';
|
|
84
|
+
return 'source';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Argv for the replacement daemon.
|
|
88
|
+
*
|
|
89
|
+
* - `global`: npm overwrites the package in place, so re-execing the SAME
|
|
90
|
+
* entry path picks up the new code. (Re-resolving through the shim would
|
|
91
|
+
* also work but adds a Windows .cmd hop for no benefit.)
|
|
92
|
+
* - `npx`: the current entry lives in a cache dir pinned to the OLD version,
|
|
93
|
+
* so re-execing it would relaunch the old code forever. Go back through
|
|
94
|
+
* npx with an explicit version spec instead.
|
|
95
|
+
* - `source`: re-exec the same entry. A checkout's version comes from git,
|
|
96
|
+
* not npm, so this is a restart — never a version change.
|
|
97
|
+
*/
|
|
98
|
+
function planRespawn(mode, entryPath, targetVersion, execPath = process.execPath,
|
|
99
|
+
/** Args the daemon was started WITH, after the entry path (process.argv
|
|
100
|
+
* slice(2)) — carried across the restart so a node launched as
|
|
101
|
+
* `… cli.js run --foo` doesn't silently come back up without them. */
|
|
102
|
+
userArgs = []) {
|
|
103
|
+
const spec = `${exports.PACKAGE_NAME}@${targetVersion || 'latest'}`;
|
|
104
|
+
if (mode === 'npx') {
|
|
105
|
+
const inv = (0, win_1.resolveCliInvocation)('npx', ['-y', spec, ...userArgs]);
|
|
106
|
+
return { file: inv.file, args: inv.args, installFirst: false, canChangeVersion: true };
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
file: execPath,
|
|
110
|
+
args: [entryPath, ...userArgs],
|
|
111
|
+
installFirst: mode === 'global',
|
|
112
|
+
canChangeVersion: mode === 'global',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function handoffPath(runtimeDir) {
|
|
116
|
+
return path.join(runtimeDir, 'restart.json');
|
|
117
|
+
}
|
|
118
|
+
function writeHandoff(runtimeDir, h) {
|
|
119
|
+
fs.mkdirSync(runtimeDir, { recursive: true });
|
|
120
|
+
fs.writeFileSync(handoffPath(runtimeDir), JSON.stringify(h), 'utf8');
|
|
121
|
+
}
|
|
122
|
+
/** Reads and DELETES the handoff — it must never be replayed twice. */
|
|
123
|
+
function takeHandoff(runtimeDir) {
|
|
124
|
+
const f = handoffPath(runtimeDir);
|
|
125
|
+
try {
|
|
126
|
+
const raw = fs.readFileSync(f, 'utf8');
|
|
127
|
+
try {
|
|
128
|
+
fs.unlinkSync(f);
|
|
129
|
+
}
|
|
130
|
+
catch { /* already gone */ }
|
|
131
|
+
const parsed = JSON.parse(raw);
|
|
132
|
+
return parsed && typeof parsed.command_id === 'string' ? parsed : null;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `npm i -g <pkg>@<version>`. Returns null on success, else the reason.
|
|
140
|
+
* Never throws — a failed install must leave the CURRENT daemon running
|
|
141
|
+
* rather than take the node down.
|
|
142
|
+
*/
|
|
143
|
+
async function installGlobal(targetVersion, timeoutMs = 5 * 60_000) {
|
|
144
|
+
const spec = `${exports.PACKAGE_NAME}@${targetVersion || 'latest'}`;
|
|
145
|
+
const inv = (0, win_1.resolveCliInvocation)('npm', ['i', '-g', spec]);
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
let stderr = '';
|
|
148
|
+
let settled = false;
|
|
149
|
+
const done = (v) => { if (!settled) {
|
|
150
|
+
settled = true;
|
|
151
|
+
resolve(v);
|
|
152
|
+
} };
|
|
153
|
+
try {
|
|
154
|
+
const child = (0, child_process_1.spawn)(inv.file, inv.args, { windowsHide: true, env: process.env });
|
|
155
|
+
const timer = setTimeout(() => { try {
|
|
156
|
+
child.kill('SIGKILL');
|
|
157
|
+
}
|
|
158
|
+
catch { /* gone */ } done(`npm i -g ${spec} timed out`); }, timeoutMs);
|
|
159
|
+
timer.unref?.();
|
|
160
|
+
child.stderr?.on('data', b => { stderr += b.toString('utf8'); });
|
|
161
|
+
child.on('error', err => { clearTimeout(timer); done(`npm i -g failed to start: ${err.message}`); });
|
|
162
|
+
child.on('exit', code => {
|
|
163
|
+
clearTimeout(timer);
|
|
164
|
+
done(code === 0 ? null : `npm i -g ${spec} exited ${code}: ${stderr.trim().slice(-400)}`);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
done(`npm i -g failed to start: ${err.message}`);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Spawn the replacement daemon fully detached, so it survives this process's
|
|
174
|
+
* exit. stdio is redirected to the daemon log (inheriting our stdio would tie
|
|
175
|
+
* the child to a terminal that is about to go away).
|
|
176
|
+
*/
|
|
177
|
+
function spawnReplacement(plan, logPath, cwd) {
|
|
178
|
+
let out = 'ignore';
|
|
179
|
+
try {
|
|
180
|
+
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
181
|
+
out = fs.openSync(logPath, 'a');
|
|
182
|
+
}
|
|
183
|
+
catch { /* no log → /dev/null is still better than not restarting */ }
|
|
184
|
+
const child = (0, child_process_1.spawn)(plan.file, plan.args, {
|
|
185
|
+
detached: true,
|
|
186
|
+
windowsHide: true,
|
|
187
|
+
cwd,
|
|
188
|
+
env: process.env,
|
|
189
|
+
stdio: ['ignore', out, out],
|
|
190
|
+
});
|
|
191
|
+
child.unref();
|
|
192
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { RuntimePermissionMode, RuntimeEffortLevel } from './types';
|
|
2
|
+
/** Shape of a row returned by runtime_pick_next_request. */
|
|
3
|
+
export interface RuntimeRequestRow {
|
|
4
|
+
id: string;
|
|
5
|
+
runtime_id: string;
|
|
6
|
+
project_id: string | null;
|
|
7
|
+
agent: 'claude' | 'claude-tui' | 'claude-bypass' | 'codex' | 'kimi' | 'gemini' | 'grok';
|
|
8
|
+
mode: 'tui' | 'print';
|
|
9
|
+
model: string | null;
|
|
10
|
+
effort: RuntimeEffortLevel | null;
|
|
11
|
+
permission_mode: RuntimePermissionMode | null;
|
|
12
|
+
prompt: string | null;
|
|
13
|
+
/** Execution timeout in seconds from the dispatching node. null/0 =
|
|
14
|
+
* unlimited — the agent runs until it finishes naturally (print exits /
|
|
15
|
+
* TUI goes idle). When set, the daemon kills the agent after this long
|
|
16
|
+
* and completes the request with whatever output it produced so far. */
|
|
17
|
+
timeout_seconds: number | null;
|
|
18
|
+
resume_session_id: string | null;
|
|
19
|
+
working_directory: string | null;
|
|
20
|
+
/** Ephemeral git clone for "one-off repo" chats. When set + project_id
|
|
21
|
+
* is null, the daemon clones the repo into the session cwd before
|
|
22
|
+
* spawning the agent. No project row created. */
|
|
23
|
+
ephemeral_git_remote: string | null;
|
|
24
|
+
ephemeral_git_branch: string | null;
|
|
25
|
+
ephemeral_git_credential_id: string | null;
|
|
26
|
+
/** Multi-repo variant: array of { remote, branch?, credential_id? }.
|
|
27
|
+
* When this has >=2 entries the daemon creates a session workspace
|
|
28
|
+
* cwd and clones each repo into a subdirectory of it (named after
|
|
29
|
+
* the repo). When it has 0 or 1 entry the daemon falls back to the
|
|
30
|
+
* singular ephemeral_git_remote path above — chats from older
|
|
31
|
+
* Studio builds still work unchanged. */
|
|
32
|
+
ephemeral_git_remotes: Array<{
|
|
33
|
+
remote: string;
|
|
34
|
+
branch?: string | null;
|
|
35
|
+
credential_id?: string | null;
|
|
36
|
+
}> | null;
|
|
37
|
+
mcp_mode: 'inherit' | 'none' | 'override';
|
|
38
|
+
mcps_override: string[];
|
|
39
|
+
skills_override: string[];
|
|
40
|
+
packages_override: string[];
|
|
41
|
+
/** Studio entities (presets) carry a system prompt that the agent should
|
|
42
|
+
* honor on each turn. Wired through via chat_send. */
|
|
43
|
+
system_prompt: string | null;
|
|
44
|
+
/** Restricted tool list (claude only). Null = use defaults. */
|
|
45
|
+
allowed_tools: string[] | null;
|
|
46
|
+
/** Where the request came from. 'flow' = single-turn (auto-close after
|
|
47
|
+
* turn_complete so the engine can resume). 'chat' = stay open for
|
|
48
|
+
* follow-up turns until the user explicitly ends the session.
|
|
49
|
+
* 'widgetstudio' = Widget Studio vibecode session (triggers the
|
|
50
|
+
* widget-vibecode-resume callback + injects streaming env vars). */
|
|
51
|
+
issued_via: string | null;
|
|
52
|
+
/** Per-session env-var overrides keyed by MCP slug. The daemon merges
|
|
53
|
+
* these into each MCP's env at install time, taking precedence over
|
|
54
|
+
* credential-supplied values. Used by widgetstudio for dynamic streaming
|
|
55
|
+
* auth tokens (request id) that can't live in a static vault credential.
|
|
56
|
+
* Shape: { "<mcp_slug>": { "<ENV>": "val" } } */
|
|
57
|
+
mcp_env_overrides: Record<string, Record<string, string>> | null;
|
|
58
|
+
/** Per-skill variable values keyed by skill id → { varName: value }.
|
|
59
|
+
* Forwarded to install() and substituted into each skill's {{var.<name>}}
|
|
60
|
+
* tokens before SKILL.md is written. Optional — older rows omit it and
|
|
61
|
+
* the daemon defaults to {} (no substitution beyond skill defaults). */
|
|
62
|
+
skill_var_values?: Record<string, Record<string, string>> | null;
|
|
63
|
+
/** Self-improve flag for autonomous entities. When truthy AND the run
|
|
64
|
+
* reaches a `completed` terminal status, the daemon fires a best-effort
|
|
65
|
+
* POST to the `entity-self-improve` edge function so the entity can
|
|
66
|
+
* update its own skill based on what just happened in the run. Optional
|
|
67
|
+
* on the row — older Studio/flows builds simply omit it and the hook is
|
|
68
|
+
* a no-op. Populated by the Studio dispatch side from
|
|
69
|
+
* entity_studio_entities.self_improve. */
|
|
70
|
+
self_improve?: boolean | null;
|
|
71
|
+
/** The owning Studio entity profile id (= entity_studio_entities.id).
|
|
72
|
+
*
|
|
73
|
+
* Runtime "entity_id alias" fix (final phase-3 review finding): the row
|
|
74
|
+
* this daemon actually gets from `runtime_pick_next_request` (studio
|
|
75
|
+
* repo, supabase/migrations/20260718101000_memory_v3_pick_member.sql)
|
|
76
|
+
* is the BARE `entity_runtime_requests` rowtype — no jsonb aliasing — so
|
|
77
|
+
* PostgREST serializes the owning-entity column under its real name,
|
|
78
|
+
* `entity_studio_entity_id`. THAT is the field to read at pick-row call
|
|
79
|
+
* sites (see resolvePackEntityId in memory-pack.ts). `entity_id` below
|
|
80
|
+
* is kept only as a secondary fallback for shapes that DO alias it (e.g.
|
|
81
|
+
* `runtime_request_get_meta`, which returns `entity_id` via
|
|
82
|
+
* jsonb_build_object — see notifySelfImproveIfEnabled/
|
|
83
|
+
* notifyCaptureIfEnabled below, which read it from that RPC's response
|
|
84
|
+
* and are unaffected by this fix). Both optional; null for non-entity
|
|
85
|
+
* runs. */
|
|
86
|
+
entity_studio_entity_id?: string | null;
|
|
87
|
+
entity_id?: string | null;
|
|
88
|
+
/** user_profiles.id of the requesting member (memory_v3, T2). Stamped by
|
|
89
|
+
* the dispatch fns and surfaced by runtime_pick_next_request; null on
|
|
90
|
+
* memberless surfaces and rows from older Studio builds. */
|
|
91
|
+
member_profile_id?: string | null;
|
|
92
|
+
/** Guardrails recursion guard — true on checker requests and internal
|
|
93
|
+
* dispatches. The for-request RPC re-checks server-side; this field just
|
|
94
|
+
* saves the RPC round-trip. Optional: older Studio builds omit it. */
|
|
95
|
+
guardrails_skip?: boolean | null;
|
|
96
|
+
/** Attempts already burned on this request (shared counter with the
|
|
97
|
+
* server-side stale-reclaim). Drives the retry backoff step; the cap is
|
|
98
|
+
* enforced server-side in runtime_request_mark_retry. Optional: rows
|
|
99
|
+
* from older schemas omit it. */
|
|
100
|
+
retry_count?: number | null;
|
|
101
|
+
/** Ladder hops already burned on this request (shared counter with the
|
|
102
|
+
* server-side failover RPC). Drives the runtime_request_failover_agent
|
|
103
|
+
* decision to hop provider vs. dead-letter. Optional: rows from older
|
|
104
|
+
* schemas omit it. */
|
|
105
|
+
ladder_hops?: number | null;
|
|
106
|
+
/** Phase 4 T7 — NOT a DB column. Set in-process by runRequest() right
|
|
107
|
+
* after the memory-pack fetch resolves (applyMemoryPack's onFlagged
|
|
108
|
+
* callback reuses the SAME round trip entity-memory-pack already makes
|
|
109
|
+
* every turn — no extra network call, no daemon-side memory_v2 lookup).
|
|
110
|
+
* Read by runClaudeTui() to decide whether to write the per-session
|
|
111
|
+
* PreCompact capture hook. Undefined for every run where the pack fetch
|
|
112
|
+
* never fired (non-entity runs) — those never get the hook, same as
|
|
113
|
+
* before this field existed. */
|
|
114
|
+
memoryV2Flagged?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export declare function notifyFlowsIfFlowRequest(requestId: string): Promise<void>;
|
|
117
|
+
export declare function notifyWidgetstudioIfWidgetRequest(requestId: string): Promise<void>;
|
|
118
|
+
export declare function notifySelfImproveIfEnabled(requestId: string): Promise<void>;
|
|
119
|
+
/** A stored resume id is only valid TOGETHER WITH the cwd it was created in:
|
|
120
|
+
* claude looks its transcript up under a cwd-derived project dir, grok buckets
|
|
121
|
+
* its session store by cwd. So when the recorded working_directory is gone and
|
|
122
|
+
* we could not re-create it (it belongs to another machine, or to this machine
|
|
123
|
+
* before the runtime home moved — e.g. ~/.entities-runtime → ~/.ainode), the
|
|
124
|
+
* session id is dead: resuming it can only fail with "No conversation found
|
|
125
|
+
* with session ID: <id>". Start fresh instead of burning an attempt on a
|
|
126
|
+
* guaranteed error and making the user read a failure we already expect.
|
|
127
|
+
*
|
|
128
|
+
* Exported for tests. */
|
|
129
|
+
export declare function resumeSessionIsVoid(workingDirectory: string | null | undefined, resumeSessionId: string | null | undefined, cwdSubstituted: boolean): boolean;
|
|
130
|
+
export declare function runRequest(req: RuntimeRequestRow): Promise<void>;
|