@nebutra/agent-runtime 0.2.1 → 2.0.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/LICENSE +21 -676
- package/README.md +33 -10
- package/dist/adapters/index.d.ts +24 -5
- package/dist/adapters/index.js +27 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/{chunk-KCNN4QUQ.js → chunk-5UGIUYJR.js} +4 -4
- package/dist/chunk-7ELA4SWE.js +73 -0
- package/dist/chunk-7ELA4SWE.js.map +1 -0
- package/dist/chunk-Q62VKHIT.js +178 -0
- package/dist/chunk-Q62VKHIT.js.map +1 -0
- package/dist/chunk-VXILZAXK.js +541 -0
- package/dist/chunk-VXILZAXK.js.map +1 -0
- package/dist/command-exec.d.ts +45 -0
- package/dist/command-exec.js +15 -0
- package/dist/command-exec.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +81 -28
- package/dist/index.js.map +1 -1
- package/dist/orchestration.d.ts +42 -1
- package/dist/orchestration.js +7 -3
- package/dist/pulsar.js +2 -2
- package/dist/sandbox-DfcRttXt.d.ts +219 -0
- package/dist/sandbox.d.ts +2 -64
- package/dist/sandbox.js +25 -3
- package/package.json +81 -30
- package/.turbo/turbo-build.log +0 -130
- package/.turbo/turbo-test.log +0 -47
- package/.turbo/turbo-typecheck.log +0 -4
- package/CHANGELOG.md +0 -250
- package/dist/chunk-MUF7ZZTO.js +0 -57
- package/dist/chunk-MUF7ZZTO.js.map +0 -1
- package/dist/chunk-MX2WL43P.js +0 -90
- package/dist/chunk-MX2WL43P.js.map +0 -1
- package/examples/pulsar-quickstart.ts +0 -35
- package/examples/resume-branch.ts +0 -45
- package/examples/subagent-fanout.ts +0 -20
- package/src/adapters/dispatcher-sse.test.ts +0 -218
- package/src/adapters/dispatcher-sse.ts +0 -222
- package/src/adapters/index.ts +0 -18
- package/src/adapters/mcp-catalog.test.ts +0 -213
- package/src/adapters/mcp-catalog.ts +0 -188
- package/src/adapters/prisma-rollout.test.ts +0 -153
- package/src/adapters/prisma-rollout.ts +0 -104
- package/src/agent-runtime.test.ts +0 -176
- package/src/artifact-stream.test.ts +0 -330
- package/src/artifact-stream.ts +0 -453
- package/src/channel-gateway.test.ts +0 -432
- package/src/channel-gateway.ts +0 -357
- package/src/cli.ts +0 -49
- package/src/code-review.test.ts +0 -501
- package/src/code-review.ts +0 -495
- package/src/command-suggestions.test.ts +0 -251
- package/src/command-suggestions.ts +0 -338
- package/src/commands.test.ts +0 -184
- package/src/commands.ts +0 -140
- package/src/commit-message.test.ts +0 -249
- package/src/commit-message.ts +0 -180
- package/src/context-compaction.test.ts +0 -522
- package/src/context-compaction.ts +0 -438
- package/src/definitions.test.ts +0 -78
- package/src/definitions.ts +0 -190
- package/src/deployment-status.test.ts +0 -215
- package/src/deployment-status.ts +0 -227
- package/src/design-context.test.ts +0 -195
- package/src/design-context.ts +0 -198
- package/src/dispatcher.test.ts +0 -234
- package/src/dispatcher.ts +0 -189
- package/src/durable-turn.test.ts +0 -209
- package/src/durable-turn.ts +0 -135
- package/src/edit-planner.test.ts +0 -204
- package/src/edit-planner.ts +0 -325
- package/src/fuzzy-match.test.ts +0 -311
- package/src/fuzzy-match.ts +0 -444
- package/src/hook-pipeline.test.ts +0 -279
- package/src/hook-pipeline.ts +0 -373
- package/src/inbound-admission.test.ts +0 -394
- package/src/inbound-admission.ts +0 -246
- package/src/index.ts +0 -49
- package/src/loop.test.ts +0 -161
- package/src/loop.ts +0 -211
- package/src/mcp-bridge.test.ts +0 -165
- package/src/mcp-bridge.ts +0 -81
- package/src/memory-provider.test.ts +0 -232
- package/src/memory-provider.ts +0 -257
- package/src/model.ts +0 -168
- package/src/orchestration.test.ts +0 -53
- package/src/orchestration.ts +0 -146
- package/src/permission-ruleset.test.ts +0 -301
- package/src/permission-ruleset.ts +0 -1
- package/src/policy.ts +0 -151
- package/src/project-repo.test.ts +0 -232
- package/src/project-repo.ts +0 -311
- package/src/protocol.ts +0 -159
- package/src/pulsar.test.ts +0 -156
- package/src/pulsar.ts +0 -322
- package/src/rollout-store-persistent.test.ts +0 -217
- package/src/rollout-store-persistent.ts +0 -166
- package/src/rollout.ts +0 -150
- package/src/sandbox.ts +0 -113
- package/src/session-share.test.ts +0 -360
- package/src/session-share.ts +0 -310
- package/src/skill-distillation.test.ts +0 -177
- package/src/skill-distillation.ts +0 -369
- package/src/skills.test.ts +0 -277
- package/src/skills.ts +0 -277
- package/src/subagents.test.ts +0 -290
- package/src/subagents.ts +0 -332
- package/src/tools.test.ts +0 -12
- package/src/tools.ts +0 -129
- package/src/workbench.test.ts +0 -0
- package/src/workbench.ts +0 -0
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -36
- /package/dist/{chunk-KCNN4QUQ.js.map → chunk-5UGIUYJR.js.map} +0 -0
package/dist/orchestration.d.ts
CHANGED
|
@@ -5,6 +5,32 @@ interface BudgetCap {
|
|
|
5
5
|
readonly costUsd: number;
|
|
6
6
|
readonly tokenLimit: number;
|
|
7
7
|
}
|
|
8
|
+
/** Thinking/reasoning effort for a node (maps to provider reasoning controls). */
|
|
9
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
10
|
+
/** Output modality a node produces. Mirrors @nebutra/ai-providers ModelModality. */
|
|
11
|
+
type ModelModality = "text" | "image" | "video" | "audio" | "embedding";
|
|
12
|
+
/**
|
|
13
|
+
* Per-node model selection — the full model meta-info a node can declare. ALL
|
|
14
|
+
* fields optional; an unset field inherits the run-level default
|
|
15
|
+
* (WorkflowDefinition.defaultModel / runTurn config). The executor resolves
|
|
16
|
+
* these HINTS against @nebutra/ai-providers/catalog (listModelsByModality /
|
|
17
|
+
* resolveFrontierModel) to a concrete model — so a node can either PIN one
|
|
18
|
+
* (`id`) or DESCRIBE what it needs ("the latest fast text model with vision").
|
|
19
|
+
*/
|
|
20
|
+
interface NodeModelSpec {
|
|
21
|
+
/** Explicit pin: preset alias (`flagship`/`reasoning`/`fast`) or `provider/model` id. */
|
|
22
|
+
readonly id?: string;
|
|
23
|
+
/** Thinking effort: `low` → cheap/quick, `xhigh` → deepest reasoning. */
|
|
24
|
+
readonly reasoningEffort?: ReasoningEffort;
|
|
25
|
+
/** Output modality — selects a model of this modality when `id` is unset. */
|
|
26
|
+
readonly modality?: ModelModality;
|
|
27
|
+
/** Capabilities the selected model MUST have (e.g. a node needing image input). */
|
|
28
|
+
readonly capabilities?: {
|
|
29
|
+
readonly vision?: boolean;
|
|
30
|
+
readonly toolCall?: boolean;
|
|
31
|
+
readonly reasoning?: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
8
34
|
interface Brief {
|
|
9
35
|
readonly id: string;
|
|
10
36
|
readonly objective: string;
|
|
@@ -14,6 +40,8 @@ interface Brief {
|
|
|
14
40
|
readonly boundaries: readonly string[];
|
|
15
41
|
readonly budget: BudgetCap;
|
|
16
42
|
readonly dependsOn?: readonly string[];
|
|
43
|
+
/** Per-node model meta-info (id/preset · thinking effort · modality · capabilities). */
|
|
44
|
+
readonly model?: NodeModelSpec;
|
|
17
45
|
}
|
|
18
46
|
type DispatchStrategy = "auto" | "sequential" | "fanout";
|
|
19
47
|
interface DispatchPlan {
|
|
@@ -36,8 +64,21 @@ interface SubagentCostReport {
|
|
|
36
64
|
readonly maxDurationMs: number;
|
|
37
65
|
readonly subagents: number;
|
|
38
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Dependency-resolved execution WAVES — the agent node-topology scheduler. Each
|
|
69
|
+
* wave is the set of briefs whose dependencies are satisfied by earlier waves;
|
|
70
|
+
* waves run in order, briefs within a wave run in parallel. Input order is
|
|
71
|
+
* preserved within a wave.
|
|
72
|
+
*/
|
|
73
|
+
declare function planWaves(briefs: readonly Brief[]): readonly (readonly Brief[])[];
|
|
39
74
|
declare function planSubagentDispatch(briefs: readonly Brief[], options?: DispatchPlanOptions): DispatchPlan;
|
|
40
75
|
declare function fanOutSubagents(briefs: readonly Brief[], run: (brief: Brief) => Promise<SubagentResult>): Promise<readonly SubagentResult[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Execute briefs as a dependency graph: each wave runs in parallel, waves run
|
|
78
|
+
* sequentially. The node-topology execution path — `fanOutSubagents` is the
|
|
79
|
+
* degenerate single-wave (all-independent) case of this.
|
|
80
|
+
*/
|
|
81
|
+
declare function runAgentWaves(briefs: readonly Brief[], run: (brief: Brief) => Promise<SubagentResult>): Promise<readonly SubagentResult[]>;
|
|
41
82
|
declare function costReport(results: readonly SubagentResult[]): SubagentCostReport;
|
|
42
83
|
|
|
43
|
-
export { type Brief, type BudgetCap, type DispatchPlan, type DispatchPlanOptions, type DispatchStrategy, type SubagentCostReport, type SubagentResult, costReport, fanOutSubagents, planSubagentDispatch };
|
|
84
|
+
export { type Brief, type BudgetCap, type DispatchPlan, type DispatchPlanOptions, type DispatchStrategy, type ModelModality, type NodeModelSpec, type ReasoningEffort, type SubagentCostReport, type SubagentResult, costReport, fanOutSubagents, planSubagentDispatch, planWaves, runAgentWaves };
|
package/dist/orchestration.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
costReport,
|
|
3
3
|
fanOutSubagents,
|
|
4
|
-
planSubagentDispatch
|
|
5
|
-
|
|
4
|
+
planSubagentDispatch,
|
|
5
|
+
planWaves,
|
|
6
|
+
runAgentWaves
|
|
7
|
+
} from "./chunk-Q62VKHIT.js";
|
|
6
8
|
import "./chunk-424PT5DM.js";
|
|
7
9
|
export {
|
|
8
10
|
costReport,
|
|
9
11
|
fanOutSubagents,
|
|
10
|
-
planSubagentDispatch
|
|
12
|
+
planSubagentDispatch,
|
|
13
|
+
planWaves,
|
|
14
|
+
runAgentWaves
|
|
11
15
|
};
|
|
12
16
|
//# sourceMappingURL=orchestration.js.map
|
package/dist/pulsar.js
CHANGED
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
Pulsar,
|
|
3
3
|
PulsarBuilder,
|
|
4
4
|
PulsarThread
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5UGIUYJR.js";
|
|
6
6
|
import "./chunk-D4YAPLOW.js";
|
|
7
7
|
import "./chunk-37BBB2P2.js";
|
|
8
|
-
import "./chunk-4Y25ZTKI.js";
|
|
9
8
|
import "./chunk-6EGG2OZC.js";
|
|
10
9
|
import "./chunk-CGRCUKGT.js";
|
|
10
|
+
import "./chunk-4Y25ZTKI.js";
|
|
11
11
|
import "./chunk-424PT5DM.js";
|
|
12
12
|
export {
|
|
13
13
|
Pulsar,
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { CapabilityPolicy } from './policy.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Carina native transport: newline-delimited JSON-RPC 2.0 over a Unix socket
|
|
5
|
+
* (same wire as @carina/sdk and `carina-daemon -socket`).
|
|
6
|
+
*
|
|
7
|
+
* Node-only — not for edge runtimes without `node:net`.
|
|
8
|
+
*/
|
|
9
|
+
declare const defaultCarinaSocketPath: () => string;
|
|
10
|
+
/** Production co-deploy layout on the Sailor ECS api host. */
|
|
11
|
+
declare const CODEPLOY_CARINA_SOCKET_PATH = "/var/carina/run/daemon.sock";
|
|
12
|
+
declare const CODEPLOY_CARINA_WORKSPACE_ROOT = "/var/carina/ws";
|
|
13
|
+
declare const CODEPLOY_CARINA_STATE_DIR = "/var/carina/state";
|
|
14
|
+
declare const CODEPLOY_CARINA_BIN_DIR = "/var/carina/bin";
|
|
15
|
+
declare class CarinaNdjsonError extends Error {
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly code?: string | undefined;
|
|
18
|
+
constructor(message: string, status: number, code?: string | undefined);
|
|
19
|
+
}
|
|
20
|
+
type NdjsonRpcClient = {
|
|
21
|
+
call: <T>(method: string, params: Record<string, unknown>) => Promise<T>;
|
|
22
|
+
close: () => void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Create a reusable NDJSON JSON-RPC client for a Carina unix socket.
|
|
26
|
+
*/
|
|
27
|
+
declare function createCarinaNdjsonClient(socketPath: string, callTimeoutMs?: number): NdjsonRpcClient;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* External-sandbox delegation seam (PORT — capability #11).
|
|
31
|
+
*
|
|
32
|
+
* Governance decision (dual-track, ExternalSandbox posture): this multi-tenant
|
|
33
|
+
* web runtime NEVER executes untrusted code itself and introduces no isolation
|
|
34
|
+
* infrastructure. It only:
|
|
35
|
+
* 1. carries the capability policy (see ./policy),
|
|
36
|
+
* 2. delegates execution to an external isolator behind this interface
|
|
37
|
+
* (Track B = **Carina** upstream kernel),
|
|
38
|
+
* 3. records the outcome as a `command_execution` item (see ./model).
|
|
39
|
+
*
|
|
40
|
+
* The upstream OS enforcers (Seatbelt / Landlock / bubblewrap / Windows
|
|
41
|
+
* restricted token) are deliberately NOT ported — they are single-host and
|
|
42
|
+
* out of scope for a multi-tenant web product.
|
|
43
|
+
*
|
|
44
|
+
* @see docs/architecture/2026-08-03-carina-track-b-upstream.md
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
interface SandboxExecRequest {
|
|
48
|
+
/** Mandatory tenant scope — every delegated exec is tenant-bound. */
|
|
49
|
+
readonly tenantId: string;
|
|
50
|
+
readonly threadId: string;
|
|
51
|
+
readonly command: string;
|
|
52
|
+
/** The capabilities the external isolator must honor. */
|
|
53
|
+
readonly capabilityPolicy: CapabilityPolicy;
|
|
54
|
+
/** Optional inputs the executor should materialize before running. */
|
|
55
|
+
readonly inputs?: Readonly<Record<string, string>>;
|
|
56
|
+
}
|
|
57
|
+
interface SandboxExecResult {
|
|
58
|
+
readonly exitCode: number;
|
|
59
|
+
readonly aggregatedOutput: string;
|
|
60
|
+
/** Identifier of the isolator that actually ran the command. */
|
|
61
|
+
readonly executedOn: string;
|
|
62
|
+
/** Carina permission decision id when present (audit correlation). */
|
|
63
|
+
readonly decisionId?: string;
|
|
64
|
+
/** Host correlation id sent on the wire (JSON-RPC id or extension). */
|
|
65
|
+
readonly correlationId?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The only thing Track A depends on for execution. Implemented by a decoupled
|
|
69
|
+
* isolator over Carina's public RPC catalog; never implemented in-process here.
|
|
70
|
+
*/
|
|
71
|
+
interface ExternalSandbox {
|
|
72
|
+
exec(request: SandboxExecRequest): Promise<SandboxExecResult>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fail-closed default. Wiring this in production requires a real
|
|
76
|
+
* {@link ExternalSandbox}; absent one, untrusted code never runs — by design.
|
|
77
|
+
*/
|
|
78
|
+
declare class NoExecutorConfiguredError extends Error {
|
|
79
|
+
constructor();
|
|
80
|
+
}
|
|
81
|
+
declare const REFUSING_SANDBOX: ExternalSandbox;
|
|
82
|
+
declare class SandboxDelegationError extends Error {
|
|
83
|
+
readonly status: number;
|
|
84
|
+
readonly code?: string | undefined;
|
|
85
|
+
constructor(message: string, status: number, code?: string | undefined);
|
|
86
|
+
}
|
|
87
|
+
declare class CarinaProtocolError extends Error {
|
|
88
|
+
constructor(message: string);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Generic HTTP POST of a Sailor-shaped body. Prefer {@link createCarinaSandbox}
|
|
92
|
+
* for production Track B — Carina owns the kernel and speaks JSON-RPC.
|
|
93
|
+
*/
|
|
94
|
+
declare function createHttpSandbox(baseUrl: string, fetchImpl?: typeof fetch, path?: string): ExternalSandbox;
|
|
95
|
+
/** Minimum `protocol_version` we accept from `gateway.hello` (Carina catalog). */
|
|
96
|
+
declare const CARINA_MIN_PROTOCOL_VERSION = 1;
|
|
97
|
+
type CarinaSandboxOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* HTTP JSON-RPC base URL (optional if {@link socketPath} is set).
|
|
100
|
+
* Prefer unix socket co-deploy on the same host as the gateway.
|
|
101
|
+
*/
|
|
102
|
+
readonly baseUrl?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Native Carina unix socket path (NDJSON JSON-RPC). Preferred for same-host
|
|
105
|
+
* co-deploy — full command.exec authority (TCP diagnostic is read-limited).
|
|
106
|
+
*/
|
|
107
|
+
readonly socketPath?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Gateway token for HTTP transport only. Never a local owner unlock token.
|
|
110
|
+
*/
|
|
111
|
+
readonly token?: string;
|
|
112
|
+
readonly fetchImpl?: typeof fetch;
|
|
113
|
+
/**
|
|
114
|
+
* Path under baseUrl for JSON-RPC POST. Default `""` posts to baseUrl itself.
|
|
115
|
+
*/
|
|
116
|
+
readonly rpcPath?: string;
|
|
117
|
+
/** Fail closed if hello reports a lower protocol_version. Default {@link CARINA_MIN_PROTOCOL_VERSION}. */
|
|
118
|
+
readonly minProtocolVersion?: number;
|
|
119
|
+
/** Skip gateway.hello (tests only). Production should leave this false. */
|
|
120
|
+
readonly skipHello?: boolean;
|
|
121
|
+
/** Label when the wire body has no node id. */
|
|
122
|
+
readonly executedOn?: string;
|
|
123
|
+
/** Map Sailor thread → Carina `session_id`. Default: `threadId`. */
|
|
124
|
+
readonly resolveSessionId?: (request: SandboxExecRequest) => string;
|
|
125
|
+
/**
|
|
126
|
+
* Optional client metadata sent on hello (discovery only — not an auth grant).
|
|
127
|
+
*/
|
|
128
|
+
readonly clientId?: string;
|
|
129
|
+
/**
|
|
130
|
+
* When true, `command.exec` that returns `requires_approval` will call
|
|
131
|
+
* `governance.approval.resolve` (approve=true) once and retry. Default false
|
|
132
|
+
* (fail closed). Operators set via CARINA_AUTO_APPROVE=1 for unattended nodes.
|
|
133
|
+
*/
|
|
134
|
+
readonly autoApproveOnRequire?: boolean;
|
|
135
|
+
};
|
|
136
|
+
type CarinaEnsureSessionRequest = {
|
|
137
|
+
/** Sailor thread id — used as cache key and default correlation. */
|
|
138
|
+
readonly threadId: string;
|
|
139
|
+
/** Absolute workspace path on the Carina host (catalog-required). */
|
|
140
|
+
readonly workspaceRoot: string;
|
|
141
|
+
readonly tenantId?: string;
|
|
142
|
+
readonly profile?: string;
|
|
143
|
+
/** Carina session approval_mode when supported by the daemon. */
|
|
144
|
+
readonly approvalMode?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Track-B handle: {@link ExternalSandbox} plus host session lifecycle.
|
|
148
|
+
* `command.exec` requires a Carina session; call {@link CarinaSandbox.ensureSession}
|
|
149
|
+
* before the first exec for a thread (or let {@link registerCommandExecTool} do it).
|
|
150
|
+
*/
|
|
151
|
+
type CarinaApprovalResolveRequest = {
|
|
152
|
+
readonly decisionId: string;
|
|
153
|
+
readonly approve: boolean;
|
|
154
|
+
readonly approver?: string;
|
|
155
|
+
readonly scope?: "once" | "session" | "project";
|
|
156
|
+
};
|
|
157
|
+
interface CarinaSandbox extends ExternalSandbox {
|
|
158
|
+
/**
|
|
159
|
+
* Create (or reuse cached) Carina session for a Sailor thread.
|
|
160
|
+
* Maps `threadId` → Carina `session_id` for subsequent `command.exec`.
|
|
161
|
+
*/
|
|
162
|
+
ensureSession(request: CarinaEnsureSessionRequest): Promise<string>;
|
|
163
|
+
/** Peek cached Carina session id for a Sailor thread, if any. */
|
|
164
|
+
resolveMappedSessionId(threadId: string): string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Host HITL: map product approve/deny → Carina `governance.approval.resolve`.
|
|
167
|
+
*/
|
|
168
|
+
resolveApproval(request: CarinaApprovalResolveRequest): Promise<unknown>;
|
|
169
|
+
/** Lightweight connectivity probe (`gateway.hello`). */
|
|
170
|
+
probe(): Promise<{
|
|
171
|
+
protocolVersion: number;
|
|
172
|
+
ok: true;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Track-B adapter: Sailor control plane → **Carina** public RPC catalog (v0.8.x).
|
|
177
|
+
*
|
|
178
|
+
* Mapping (Sailor → Carina, never the reverse ownership):
|
|
179
|
+
* - `threadId` → `command.exec` `session_id` (via ensureSession cache, else threadId)
|
|
180
|
+
* - `command` → `argv` via `/bin/sh -c` (kernel still gates the joined command string)
|
|
181
|
+
* - denied / requires_approval → {@link SandboxDelegationError} (fail closed)
|
|
182
|
+
* - allowed + CommandResult → {@link SandboxExecResult}
|
|
183
|
+
* - host lifecycle → `session.create` via {@link CarinaSandbox.ensureSession}
|
|
184
|
+
*
|
|
185
|
+
* Kernel protocol is maintained in `Nebutra/carina`. This file only maps.
|
|
186
|
+
*
|
|
187
|
+
* @see docs/architecture/2026-08-03-carina-track-b-upstream.md
|
|
188
|
+
*/
|
|
189
|
+
declare function createCarinaSandbox(options: CarinaSandboxOptions): CarinaSandbox;
|
|
190
|
+
/** Guard: reject the most dangerous posture unless explicitly opted in. */
|
|
191
|
+
declare function assertSafePosture(policy: CapabilityPolicy, allowDanger?: boolean): void;
|
|
192
|
+
/** Env bag for Carina host config. Compatible with `process.env`. */
|
|
193
|
+
type CarinaEnv = Readonly<Record<string, string | undefined>>;
|
|
194
|
+
/**
|
|
195
|
+
* Resolve workspace path for a tenant/thread.
|
|
196
|
+
* Order: CARINA_WORKSPACE_MAP[tenant] → TEMPLATE → CARINA_WORKSPACE_ROOT.
|
|
197
|
+
*/
|
|
198
|
+
declare function resolveCarinaWorkspaceRoot(tenantId: string, env?: CarinaEnv, threadId?: string): string | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Co-deploy is on unless explicitly disabled (`CARINA_CODEPLOY=0|false`).
|
|
201
|
+
* Same-host default: unix socket {@link CODEPLOY_CARINA_SOCKET_PATH}.
|
|
202
|
+
*/
|
|
203
|
+
declare function isCarinaCodeployEnabled(env?: CarinaEnv): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve Track-B sandbox from environment.
|
|
206
|
+
*
|
|
207
|
+
* Priority:
|
|
208
|
+
* 1. `CARINA_JSONRPC_URL` → HTTP JSON-RPC
|
|
209
|
+
* 2. `CARINA_DAEMON_SOCK` → unix NDJSON
|
|
210
|
+
* 3. co-deploy default → {@link CODEPLOY_CARINA_SOCKET_PATH}
|
|
211
|
+
* 4. developer home socket → `~/.carina/daemon.sock` when co-deploy and no prod path intent
|
|
212
|
+
* 5. otherwise {@link REFUSING_SANDBOX}
|
|
213
|
+
*/
|
|
214
|
+
declare function resolveCarinaSandboxFromEnv(env?: CarinaEnv, overrides?: Partial<CarinaSandboxOptions>): ExternalSandbox;
|
|
215
|
+
/** Default workspace when co-deploy is enabled and no override is set. */
|
|
216
|
+
declare function resolveCarinaWorkspaceRootWithCodeploy(tenantId: string, env?: CarinaEnv, threadId?: string): string | undefined;
|
|
217
|
+
declare function isCarinaSandbox(sandbox: ExternalSandbox): sandbox is CarinaSandbox;
|
|
218
|
+
|
|
219
|
+
export { CARINA_MIN_PROTOCOL_VERSION as C, type ExternalSandbox as E, type NdjsonRpcClient as N, REFUSING_SANDBOX as R, SandboxDelegationError as S, CODEPLOY_CARINA_BIN_DIR as a, CODEPLOY_CARINA_SOCKET_PATH as b, CODEPLOY_CARINA_STATE_DIR as c, CODEPLOY_CARINA_WORKSPACE_ROOT as d, type CarinaApprovalResolveRequest as e, type CarinaEnsureSessionRequest as f, type CarinaEnv as g, CarinaNdjsonError as h, CarinaProtocolError as i, type CarinaSandbox as j, type CarinaSandboxOptions as k, NoExecutorConfiguredError as l, type SandboxExecRequest as m, type SandboxExecResult as n, assertSafePosture as o, createCarinaNdjsonClient as p, createCarinaSandbox as q, createHttpSandbox as r, defaultCarinaSocketPath as s, isCarinaCodeployEnabled as t, isCarinaSandbox as u, resolveCarinaSandboxFromEnv as v, resolveCarinaWorkspaceRoot as w, resolveCarinaWorkspaceRootWithCodeploy as x };
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,65 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './policy.js';
|
|
2
|
+
export { C as CARINA_MIN_PROTOCOL_VERSION, b as CODEPLOY_CARINA_SOCKET_PATH, d as CODEPLOY_CARINA_WORKSPACE_ROOT, e as CarinaApprovalResolveRequest, f as CarinaEnsureSessionRequest, g as CarinaEnv, i as CarinaProtocolError, j as CarinaSandbox, k as CarinaSandboxOptions, E as ExternalSandbox, l as NoExecutorConfiguredError, R as REFUSING_SANDBOX, S as SandboxDelegationError, m as SandboxExecRequest, n as SandboxExecResult, o as assertSafePosture, q as createCarinaSandbox, r as createHttpSandbox, s as defaultCarinaSocketPath, t as isCarinaCodeployEnabled, u as isCarinaSandbox, v as resolveCarinaSandboxFromEnv, w as resolveCarinaWorkspaceRoot, x as resolveCarinaWorkspaceRootWithCodeploy } from './sandbox-DfcRttXt.js';
|
|
2
3
|
import 'zod';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* External-sandbox delegation seam (PORT — capability #11).
|
|
6
|
-
*
|
|
7
|
-
* Governance decision (dual-track, ExternalSandbox posture): this multi-tenant
|
|
8
|
-
* web runtime NEVER executes untrusted code itself and introduces no isolation
|
|
9
|
-
* infrastructure. It only:
|
|
10
|
-
* 1. carries the capability policy (see ./policy),
|
|
11
|
-
* 2. delegates execution to an external isolator behind this interface
|
|
12
|
-
* (a self-hosted kernel sidecar — Track B — or any other executor),
|
|
13
|
-
* 3. records the outcome as a `command_execution` item (see ./model).
|
|
14
|
-
*
|
|
15
|
-
* The upstream OS enforcers (Seatbelt / Landlock / bubblewrap / Windows
|
|
16
|
-
* restricted token) are deliberately NOT ported — they are single-host and
|
|
17
|
-
* out of scope for a multi-tenant web product.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
interface SandboxExecRequest {
|
|
21
|
-
/** Mandatory tenant scope — every delegated exec is tenant-bound. */
|
|
22
|
-
readonly tenantId: string;
|
|
23
|
-
readonly threadId: string;
|
|
24
|
-
readonly command: string;
|
|
25
|
-
/** The capabilities the external isolator must honor. */
|
|
26
|
-
readonly capabilityPolicy: CapabilityPolicy;
|
|
27
|
-
/** Optional inputs the executor should materialize before running. */
|
|
28
|
-
readonly inputs?: Readonly<Record<string, string>>;
|
|
29
|
-
}
|
|
30
|
-
interface SandboxExecResult {
|
|
31
|
-
readonly exitCode: number;
|
|
32
|
-
readonly aggregatedOutput: string;
|
|
33
|
-
/** Identifier of the isolator that actually ran the command. */
|
|
34
|
-
readonly executedOn: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* The only thing Track A depends on for execution. Implemented by a decoupled
|
|
38
|
-
* isolator over the ./protocol contract; never implemented in-process here.
|
|
39
|
-
*/
|
|
40
|
-
interface ExternalSandbox {
|
|
41
|
-
exec(request: SandboxExecRequest): Promise<SandboxExecResult>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Fail-closed default. Wiring this in production requires a real
|
|
45
|
-
* {@link ExternalSandbox}; absent one, untrusted code never runs — by design.
|
|
46
|
-
*/
|
|
47
|
-
declare class NoExecutorConfiguredError extends Error {
|
|
48
|
-
constructor();
|
|
49
|
-
}
|
|
50
|
-
declare const REFUSING_SANDBOX: ExternalSandbox;
|
|
51
|
-
declare class SandboxDelegationError extends Error {
|
|
52
|
-
readonly status: number;
|
|
53
|
-
constructor(message: string, status: number);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The concrete Track-B coupling: delegate execution over HTTP to the decoupled
|
|
57
|
-
* Rust isolator (`backends/rust/sandbox`, `POST /api/v1/sandbox/exec`). The
|
|
58
|
-
* isolator is fail-closed; a non-2xx (e.g. 403 refusal) is surfaced as an
|
|
59
|
-
* error and never coerced into a fabricated result.
|
|
60
|
-
*/
|
|
61
|
-
declare function createHttpSandbox(baseUrl: string, fetchImpl?: typeof fetch): ExternalSandbox;
|
|
62
|
-
/** Guard: reject the most dangerous posture unless explicitly opted in. */
|
|
63
|
-
declare function assertSafePosture(policy: CapabilityPolicy, allowDanger?: boolean): void;
|
|
64
|
-
|
|
65
|
-
export { type ExternalSandbox, NoExecutorConfiguredError, REFUSING_SANDBOX, SandboxDelegationError, type SandboxExecRequest, type SandboxExecResult, assertSafePosture, createHttpSandbox };
|
package/dist/sandbox.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CARINA_MIN_PROTOCOL_VERSION,
|
|
3
|
+
CODEPLOY_CARINA_SOCKET_PATH,
|
|
4
|
+
CODEPLOY_CARINA_WORKSPACE_ROOT,
|
|
5
|
+
CarinaProtocolError,
|
|
2
6
|
NoExecutorConfiguredError,
|
|
3
7
|
REFUSING_SANDBOX,
|
|
4
8
|
SandboxDelegationError,
|
|
5
9
|
assertSafePosture,
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
createCarinaSandbox,
|
|
11
|
+
createHttpSandbox,
|
|
12
|
+
defaultCarinaSocketPath,
|
|
13
|
+
isCarinaCodeployEnabled,
|
|
14
|
+
isCarinaSandbox,
|
|
15
|
+
resolveCarinaSandboxFromEnv,
|
|
16
|
+
resolveCarinaWorkspaceRoot,
|
|
17
|
+
resolveCarinaWorkspaceRootWithCodeploy
|
|
18
|
+
} from "./chunk-VXILZAXK.js";
|
|
8
19
|
import "./chunk-424PT5DM.js";
|
|
9
20
|
export {
|
|
21
|
+
CARINA_MIN_PROTOCOL_VERSION,
|
|
22
|
+
CODEPLOY_CARINA_SOCKET_PATH,
|
|
23
|
+
CODEPLOY_CARINA_WORKSPACE_ROOT,
|
|
24
|
+
CarinaProtocolError,
|
|
10
25
|
NoExecutorConfiguredError,
|
|
11
26
|
REFUSING_SANDBOX,
|
|
12
27
|
SandboxDelegationError,
|
|
13
28
|
assertSafePosture,
|
|
14
|
-
|
|
29
|
+
createCarinaSandbox,
|
|
30
|
+
createHttpSandbox,
|
|
31
|
+
defaultCarinaSocketPath,
|
|
32
|
+
isCarinaCodeployEnabled,
|
|
33
|
+
isCarinaSandbox,
|
|
34
|
+
resolveCarinaSandboxFromEnv,
|
|
35
|
+
resolveCarinaWorkspaceRoot,
|
|
36
|
+
resolveCarinaWorkspaceRootWithCodeploy
|
|
15
37
|
};
|
|
16
38
|
//# sourceMappingURL=sandbox.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebutra/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"nebutra": {
|
|
8
|
+
"graph": "runtime",
|
|
8
9
|
"status": "wip",
|
|
9
10
|
"productionReady": false,
|
|
10
11
|
"requires": [
|
|
@@ -22,43 +23,90 @@
|
|
|
22
23
|
"surface": "agent-runtime",
|
|
23
24
|
"summary": "Multi-tenant agent-runtime grammar: thread/turn/item model, approval+capability policy, tool/MCP abstraction, event-sourced rollout, external-sandbox delegation seam"
|
|
24
25
|
},
|
|
25
|
-
"main": "./
|
|
26
|
-
"types": "./
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
27
28
|
"exports": {
|
|
28
|
-
".":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"./
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"./
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./model": {
|
|
35
|
+
"types": "./dist/model.d.ts",
|
|
36
|
+
"import": "./dist/model.js",
|
|
37
|
+
"default": "./dist/model.js"
|
|
38
|
+
},
|
|
39
|
+
"./protocol": {
|
|
40
|
+
"types": "./dist/protocol.d.ts",
|
|
41
|
+
"import": "./dist/protocol.js",
|
|
42
|
+
"default": "./dist/protocol.js"
|
|
43
|
+
},
|
|
44
|
+
"./pulsar": {
|
|
45
|
+
"types": "./dist/pulsar.d.ts",
|
|
46
|
+
"import": "./dist/pulsar.js",
|
|
47
|
+
"default": "./dist/pulsar.js"
|
|
48
|
+
},
|
|
49
|
+
"./orchestration": {
|
|
50
|
+
"types": "./dist/orchestration.d.ts",
|
|
51
|
+
"import": "./dist/orchestration.js",
|
|
52
|
+
"default": "./dist/orchestration.js"
|
|
53
|
+
},
|
|
54
|
+
"./policy": {
|
|
55
|
+
"types": "./dist/policy.d.ts",
|
|
56
|
+
"import": "./dist/policy.js",
|
|
57
|
+
"default": "./dist/policy.js"
|
|
58
|
+
},
|
|
59
|
+
"./tools": {
|
|
60
|
+
"types": "./dist/tools.d.ts",
|
|
61
|
+
"import": "./dist/tools.js",
|
|
62
|
+
"default": "./dist/tools.js"
|
|
63
|
+
},
|
|
64
|
+
"./rollout": {
|
|
65
|
+
"types": "./dist/rollout.d.ts",
|
|
66
|
+
"import": "./dist/rollout.js",
|
|
67
|
+
"default": "./dist/rollout.js"
|
|
68
|
+
},
|
|
69
|
+
"./sandbox": {
|
|
70
|
+
"types": "./dist/sandbox.d.ts",
|
|
71
|
+
"import": "./dist/sandbox.js",
|
|
72
|
+
"default": "./dist/sandbox.js"
|
|
73
|
+
},
|
|
74
|
+
"./adapters": {
|
|
75
|
+
"types": "./dist/adapters/index.d.ts",
|
|
76
|
+
"import": "./dist/adapters/index.js",
|
|
77
|
+
"default": "./dist/adapters/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./adapters/mcp-catalog": {
|
|
80
|
+
"types": "./dist/adapters/mcp-catalog.d.ts",
|
|
81
|
+
"import": "./dist/adapters/mcp-catalog.js",
|
|
82
|
+
"default": "./dist/adapters/mcp-catalog.js"
|
|
83
|
+
},
|
|
84
|
+
"./adapters/dispatcher-sse": {
|
|
85
|
+
"types": "./dist/adapters/dispatcher-sse.d.ts",
|
|
86
|
+
"import": "./dist/adapters/dispatcher-sse.js",
|
|
87
|
+
"default": "./dist/adapters/dispatcher-sse.js"
|
|
88
|
+
},
|
|
89
|
+
"./adapters/prisma-rollout": {
|
|
90
|
+
"types": "./dist/adapters/prisma-rollout.d.ts",
|
|
91
|
+
"import": "./dist/adapters/prisma-rollout.js",
|
|
92
|
+
"default": "./dist/adapters/prisma-rollout.js"
|
|
93
|
+
}
|
|
41
94
|
},
|
|
42
95
|
"dependencies": {
|
|
96
|
+
"p-limit": "^7.3.0",
|
|
43
97
|
"zod": "^4.3.6",
|
|
44
|
-
"@nebutra/
|
|
45
|
-
"@nebutra/
|
|
46
|
-
"@nebutra/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"@nebutra/mcp": "0.
|
|
50
|
-
},
|
|
51
|
-
"peerDependenciesMeta": {
|
|
52
|
-
"@nebutra/mcp": {
|
|
53
|
-
"optional": true
|
|
54
|
-
}
|
|
98
|
+
"@nebutra/agents": "2.0.0",
|
|
99
|
+
"@nebutra/ai-primitives": "0.1.3",
|
|
100
|
+
"@nebutra/capability-kit": "2.0.0",
|
|
101
|
+
"@nebutra/execution-policy": "2.0.0",
|
|
102
|
+
"@nebutra/graph-model": "2.0.0",
|
|
103
|
+
"@nebutra/mcp": "2.0.0"
|
|
55
104
|
},
|
|
56
105
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^
|
|
106
|
+
"@types/node": "^25.9.1",
|
|
58
107
|
"tsup": "^8.5.1",
|
|
59
108
|
"typescript": "^5.9.3",
|
|
60
|
-
"vitest": "^4.0.18"
|
|
61
|
-
"@nebutra/mcp": "0.1.2"
|
|
109
|
+
"vitest": "^4.0.18"
|
|
62
110
|
},
|
|
63
111
|
"homepage": "https://github.com/Nebutra/Nebutra-Sailor/tree/main/packages/ai/agent-runtime#readme",
|
|
64
112
|
"repository": {
|
|
@@ -72,6 +120,9 @@
|
|
|
72
120
|
"publishConfig": {
|
|
73
121
|
"access": "public"
|
|
74
122
|
},
|
|
123
|
+
"files": [
|
|
124
|
+
"dist"
|
|
125
|
+
],
|
|
75
126
|
"scripts": {
|
|
76
127
|
"build": "tsup",
|
|
77
128
|
"dev": "tsup --watch",
|