@nylorun/runtime 0.10.0-beta → 0.12.0-beta
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/CHANGELOG.md +86 -0
- package/README.md +53 -51
- package/dist/adapters/execution/restate.d.ts +130 -0
- package/dist/adapters/execution/restate.js +442 -0
- package/dist/adapters/sandbox/virtual.js +1 -1
- package/dist/adapters/streams/s2.d.ts +18 -0
- package/dist/adapters/streams/s2.js +361 -0
- package/dist/core/executors.d.ts +4 -1
- package/dist/core/executors.js +20 -1
- package/dist/core/flow-host.d.ts +93 -132
- package/dist/core/flow-host.js +282 -547
- package/dist/core/sandbox-routes.d.ts +13 -4
- package/dist/core/sandbox-routes.js +14 -12
- package/dist/execution/memory.d.ts +54 -0
- package/dist/execution/memory.js +217 -0
- package/dist/execution/types.d.ts +125 -0
- package/dist/execution/types.js +52 -0
- package/dist/host/config-for.d.ts +2 -1
- package/dist/host/config-for.js +3 -21
- package/dist/host/config.d.ts +0 -8
- package/dist/host/create-host.d.ts +36 -1
- package/dist/host/create-host.js +51 -24
- package/dist/host/execution.d.ts +61 -0
- package/dist/host/execution.js +69 -0
- package/dist/host/http.d.ts +4 -0
- package/dist/host/http.js +6 -0
- package/dist/host/index.d.ts +3 -1
- package/dist/host/index.js +2 -0
- package/dist/host/main.js +106 -47
- package/dist/host/stack-config.d.ts +72 -0
- package/dist/host/stack-config.js +193 -0
- package/dist/index.d.ts +1 -1
- package/dist/infra/database.d.ts +16 -0
- package/dist/infra/database.js +31 -0
- package/dist/infra/execution.d.ts +39 -0
- package/dist/infra/execution.js +68 -0
- package/dist/infra/index.d.ts +42 -0
- package/dist/infra/index.js +56 -0
- package/dist/infra/readiness.d.ts +33 -0
- package/dist/infra/readiness.js +53 -0
- package/dist/infra/streams.d.ts +17 -0
- package/dist/infra/streams.js +33 -0
- package/dist/infra/workers.d.ts +39 -0
- package/dist/infra/workers.js +31 -0
- package/dist/model/pi-model.d.ts +2 -2
- package/dist/model/pi-model.js +5 -5
- package/dist/sandbox/manager.d.ts +26 -8
- package/dist/sandbox/manager.js +95 -47
- package/dist/sandbox/select.d.ts +1 -1
- package/dist/sandbox/select.js +4 -5
- package/dist/sandbox/types.d.ts +2 -2
- package/dist/store/canonical.d.ts +5 -0
- package/dist/store/canonical.js +17 -0
- package/dist/store/cursor.d.ts +9 -0
- package/dist/store/cursor.js +18 -0
- package/dist/store/memory.d.ts +57 -0
- package/dist/store/memory.js +645 -0
- package/dist/store/ownership.d.ts +19 -0
- package/dist/store/ownership.js +33 -0
- package/dist/store/postgres/connect.d.ts +25 -0
- package/dist/store/postgres/connect.js +25 -0
- package/dist/store/postgres/locking.d.ts +16 -0
- package/dist/store/postgres/locking.js +22 -0
- package/dist/store/postgres/migrations/001_initial.d.ts +27 -0
- package/dist/store/postgres/migrations/001_initial.js +196 -0
- package/dist/store/postgres/migrations/002_session_owner.d.ts +6 -0
- package/dist/store/postgres/migrations/002_session_owner.js +13 -0
- package/dist/store/postgres/migrations/index.d.ts +49 -0
- package/dist/store/postgres/migrations/index.js +76 -0
- package/dist/store/postgres/names.d.ts +11 -0
- package/dist/store/postgres/names.js +42 -0
- package/dist/store/postgres/store.d.ts +11 -0
- package/dist/store/postgres/store.js +797 -0
- package/dist/store/postgres/tenants.d.ts +90 -0
- package/dist/store/postgres/tenants.js +214 -0
- package/dist/store/types.d.ts +442 -0
- package/dist/store/types.js +10 -0
- package/dist/streams/basin.d.ts +23 -0
- package/dist/streams/basin.js +51 -0
- package/dist/streams/memory.d.ts +25 -0
- package/dist/streams/memory.js +124 -0
- package/dist/streams/relay.d.ts +37 -0
- package/dist/streams/relay.js +254 -0
- package/dist/streams/types.d.ts +115 -0
- package/dist/streams/types.js +86 -0
- package/dist/tenant/actions.d.ts +153 -0
- package/dist/tenant/actions.js +191 -0
- package/dist/tenant/advance.d.ts +15 -0
- package/dist/tenant/advance.js +439 -0
- package/dist/tenant/auth.d.ts +32 -0
- package/dist/tenant/auth.js +169 -0
- package/dist/tenant/commands.d.ts +3 -0
- package/dist/tenant/commands.js +393 -0
- package/dist/tenant/context.d.ts +147 -0
- package/dist/tenant/context.js +48 -0
- package/dist/tenant/effects.d.ts +20 -0
- package/dist/tenant/effects.js +564 -0
- package/dist/tenant/envelope.d.ts +0 -3
- package/dist/tenant/envelope.js +2 -34
- package/dist/tenant/ephemeral.d.ts +15 -4
- package/dist/tenant/ephemeral.js +106 -38
- package/dist/tenant/http.d.ts +38 -0
- package/dist/tenant/http.js +53 -0
- package/dist/tenant/live.d.ts +92 -0
- package/dist/tenant/live.js +290 -0
- package/dist/tenant/model-setting.d.ts +16 -0
- package/dist/tenant/model-setting.js +12 -0
- package/dist/tenant/module.d.ts +29 -8
- package/dist/tenant/module.js +165 -158
- package/dist/tenant/paths.d.ts +12 -8
- package/dist/tenant/paths.js +38 -12
- package/dist/tenant/principals.d.ts +12 -13
- package/dist/tenant/principals.js +50 -38
- package/dist/tenant/quarantine-error.d.ts +1 -1
- package/dist/tenant/quarantine-error.js +2 -8
- package/dist/tenant/quarantine.d.ts +0 -8
- package/dist/tenant/quarantine.js +8 -30
- package/dist/tenant/reset.d.ts +7 -6
- package/dist/tenant/reset.js +7 -51
- package/dist/tenant/routes-tenant.d.ts +12 -0
- package/dist/tenant/routes-tenant.js +137 -0
- package/dist/tenant/routes.d.ts +9 -0
- package/dist/tenant/routes.js +151 -0
- package/dist/tenant/runtime.d.ts +59 -58
- package/dist/tenant/runtime.js +243 -2201
- package/dist/tenant/scheduler.d.ts +25 -0
- package/dist/tenant/scheduler.js +84 -0
- package/dist/tenant/session.d.ts +60 -0
- package/dist/tenant/session.js +94 -0
- package/dist/tenant/sessions.d.ts +40 -0
- package/dist/tenant/sessions.js +163 -0
- package/dist/tenant/status.d.ts +13 -4
- package/dist/tenant/status.js +76 -41
- package/dist/tenant/store-memory.d.ts +9 -12
- package/dist/tenant/store-memory.js +79 -68
- package/dist/tenant/store-pg.d.ts +15 -0
- package/dist/tenant/store-pg.js +140 -0
- package/dist/tenant/streams.d.ts +126 -0
- package/dist/tenant/streams.js +419 -0
- package/dist/tenant/sweep.d.ts +15 -0
- package/dist/tenant/sweep.js +122 -0
- package/dist/tenant/transcript.d.ts +104 -0
- package/dist/tenant/transcript.js +58 -0
- package/dist/tenant/types.d.ts +101 -15
- package/dist/tenant/types.js +23 -1
- package/dist/tenant/worker.d.ts +84 -0
- package/dist/tenant/worker.js +189 -0
- package/dist/vault/service.d.ts +44 -31
- package/dist/vault/service.js +454 -360
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -14
- package/dist/adapters/sandbox/microsandbox.d.ts +0 -2
- package/dist/adapters/sandbox/microsandbox.js +0 -238
- package/dist/core/store.d.ts +0 -32
- package/dist/core/store.js +0 -143
- package/dist/launcher/commands.d.ts +0 -24
- package/dist/launcher/commands.js +0 -260
- package/dist/launcher/ensure-config.d.ts +0 -16
- package/dist/launcher/ensure-config.js +0 -79
- package/dist/launcher/errors.d.ts +0 -12
- package/dist/launcher/errors.js +0 -22
- package/dist/launcher/host-config.d.ts +0 -17
- package/dist/launcher/host-config.js +0 -64
- package/dist/launcher/host-state.d.ts +0 -17
- package/dist/launcher/host-state.js +0 -61
- package/dist/launcher/lifecycle.d.ts +0 -66
- package/dist/launcher/lifecycle.js +0 -407
- package/dist/launcher/locks.d.ts +0 -26
- package/dist/launcher/locks.js +0 -117
- package/dist/launcher/logs.d.ts +0 -18
- package/dist/launcher/logs.js +0 -117
- package/dist/launcher/main.d.ts +0 -2
- package/dist/launcher/main.js +0 -66
- package/dist/launcher/output.d.ts +0 -11
- package/dist/launcher/output.js +0 -68
- package/dist/launcher/paths.d.ts +0 -20
- package/dist/launcher/paths.js +0 -36
- package/dist/launcher/probe.d.ts +0 -23
- package/dist/launcher/probe.js +0 -72
- package/dist/launcher/protocol.d.ts +0 -62
- package/dist/launcher/protocol.js +0 -1
- package/dist/launcher/schema-guard.d.ts +0 -6
- package/dist/launcher/schema-guard.js +0 -36
- package/dist/launcher/spawn.d.ts +0 -22
- package/dist/launcher/spawn.js +0 -85
- package/dist/launcher/status.d.ts +0 -6
- package/dist/launcher/status.js +0 -65
- package/dist/tenant/migration.d.ts +0 -16
- package/dist/tenant/migration.js +0 -116
- package/dist/tenant/schema.d.ts +0 -23
- package/dist/tenant/schema.js +0 -151
- package/dist/tenant/store-fs.d.ts +0 -16
- package/dist/tenant/store-fs.js +0 -205
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { PutAgentRequestSchema, PutSessionRequestSchema, RegisterExecutorsRequestSchema, SessionCommandSchema, } from "@nylorun/core/contracts";
|
|
2
|
+
import { VaultError } from "../vault/error.js";
|
|
3
|
+
import { SandboxRouteError, handleSessionSandboxTool, } from "../core/sandbox-routes.js";
|
|
4
|
+
import { loadSession, sessionOf } from "./context.js";
|
|
5
|
+
import { HttpError, OpaqueAuthError, fail, readBody, requestAborted, } from "./http.js";
|
|
6
|
+
import { authenticate, authorize, ownerOf, requireApplication, requirePrincipal, } from "./auth.js";
|
|
7
|
+
import { command } from "./commands.js";
|
|
8
|
+
import { actionSandboxTool, deleteExecutor, listExecutors, listPendingActions, registerExecutors, sandboxRouteDeps, updateAction, } from "./actions.js";
|
|
9
|
+
import { listDefinitions, listSessions, putDefinition, putSession, sessionView, } from "./sessions.js";
|
|
10
|
+
import { readHistory, requestCursor, streamExecutorWork, streamSessionEvents, } from "./live.js";
|
|
11
|
+
import { dispatchTenant, dispatchVault } from "./routes-tenant.js";
|
|
12
|
+
export async function handle(ctx, request, response, _url) {
|
|
13
|
+
const json = (value, status = 200) => {
|
|
14
|
+
const payload = JSON.stringify(value);
|
|
15
|
+
response.writeHead(status, {
|
|
16
|
+
"content-type": "application/json",
|
|
17
|
+
"content-length": Buffer.byteLength(payload),
|
|
18
|
+
});
|
|
19
|
+
response.end(payload);
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const url = _url ?? new URL(request.url ?? "/", "http://runtime");
|
|
23
|
+
const path = url.pathname
|
|
24
|
+
.split("/")
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.map(decodeURIComponent);
|
|
27
|
+
const method = request.method;
|
|
28
|
+
const scope = await authenticate(ctx, request);
|
|
29
|
+
if (path[0] !== "v1")
|
|
30
|
+
fail(404, "Route not found");
|
|
31
|
+
authorize(scope, method, path);
|
|
32
|
+
// Set when the request acts for a subject: only the subject's own sessions are reachable.
|
|
33
|
+
const owner = ownerOf(scope);
|
|
34
|
+
if (path[1] === "executors" && path[2] === "connect" && method === "GET") {
|
|
35
|
+
if (scope.kind !== "executor")
|
|
36
|
+
return fail(403, "Executor credential required");
|
|
37
|
+
streamExecutorWork(ctx.live, request, response, scope.executor.tokenHash);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (path[1] === "actions") {
|
|
41
|
+
if (scope.kind !== "executor")
|
|
42
|
+
return fail(403, "Executor credential required");
|
|
43
|
+
if (path.length === 2 && method === "GET")
|
|
44
|
+
return json(await listPendingActions(ctx, scope.executor));
|
|
45
|
+
const actionId = path[2];
|
|
46
|
+
if (!actionId)
|
|
47
|
+
fail(404, "Action not found");
|
|
48
|
+
if (method === "POST" &&
|
|
49
|
+
path[3] === "sandbox" &&
|
|
50
|
+
path[4] &&
|
|
51
|
+
path.length === 5)
|
|
52
|
+
return json(await actionSandboxTool(ctx, scope, actionId, path[4], request));
|
|
53
|
+
const body = await readBody(request);
|
|
54
|
+
return json(await updateAction(ctx, scope, actionId, method, path[3], body));
|
|
55
|
+
}
|
|
56
|
+
if (path[1] === "sessions" &&
|
|
57
|
+
path[2] &&
|
|
58
|
+
path[3] === "commands" &&
|
|
59
|
+
method === "POST")
|
|
60
|
+
return json(await command(ctx, path[2], SessionCommandSchema.parse(await readBody(request)), scope));
|
|
61
|
+
if (path[1] === "vaults")
|
|
62
|
+
return json(await dispatchVault(ctx, scope, method, path, url, request));
|
|
63
|
+
if (path[1] === "tenant")
|
|
64
|
+
return json(await dispatchTenant(ctx, scope, method, path, request));
|
|
65
|
+
const principalId = requirePrincipal(scope);
|
|
66
|
+
if (path[1] === "executors" && path.length === 2 && method === "GET")
|
|
67
|
+
return json(listExecutors(ctx));
|
|
68
|
+
// The length guard matters: the connect branch above only matches GET, so without it a
|
|
69
|
+
// PUT to /v1/executors/connect would register an agent literally named "connect".
|
|
70
|
+
if (path[1] === "executors" && path.length === 2 && method === "PUT")
|
|
71
|
+
return json(await registerExecutors(ctx, principalId, RegisterExecutorsRequestSchema.parse(await readBody(request))));
|
|
72
|
+
if (path[1] === "executors" &&
|
|
73
|
+
path.length === 3 &&
|
|
74
|
+
path[2] &&
|
|
75
|
+
method === "DELETE")
|
|
76
|
+
return json(await deleteExecutor(ctx, path[2]));
|
|
77
|
+
if (path[1] === "agents" && path.length === 2 && method === "GET")
|
|
78
|
+
return json(await listDefinitions(ctx));
|
|
79
|
+
if (path[1] === "sessions" && path.length === 2 && method === "GET")
|
|
80
|
+
return json(await listSessions(ctx, url.searchParams.get("agentId"), owner));
|
|
81
|
+
if (path[1] === "agents" &&
|
|
82
|
+
path[2] &&
|
|
83
|
+
path.length === 3 &&
|
|
84
|
+
method === "PUT")
|
|
85
|
+
return json(await putDefinition(ctx, path[2], PutAgentRequestSchema.parse(await readBody(request))));
|
|
86
|
+
if (path[1] === "sessions" && path[2]) {
|
|
87
|
+
const id = path[2];
|
|
88
|
+
if (method === "PUT" && path.length === 3) {
|
|
89
|
+
const body = PutSessionRequestSchema.parse(await readBody(request));
|
|
90
|
+
const session = await putSession(ctx, id, body, owner);
|
|
91
|
+
return json(await ctx.store.tx((t) => sessionView(t, session)));
|
|
92
|
+
}
|
|
93
|
+
if (method === "GET" && path.length === 3)
|
|
94
|
+
return json(await ctx.store.tx(async (t) => sessionView(t, await sessionOf(t, id, owner))));
|
|
95
|
+
// Every other session route needs the session to exist.
|
|
96
|
+
await loadSession(ctx, id, owner);
|
|
97
|
+
const cursor = requestCursor(request, url);
|
|
98
|
+
if (method === "GET" && path[3] === "items")
|
|
99
|
+
return json(await readHistory(ctx, id, cursor, url.searchParams.get("agent") ?? undefined));
|
|
100
|
+
if (method === "GET" && path[3] === "events") {
|
|
101
|
+
await streamSessionEvents(ctx, request, response, id, cursor);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (method === "POST" &&
|
|
105
|
+
path[3] === "sandbox" &&
|
|
106
|
+
path[4] &&
|
|
107
|
+
path.length === 5) {
|
|
108
|
+
requireApplication(scope);
|
|
109
|
+
try {
|
|
110
|
+
const outcome = await handleSessionSandboxTool(sandboxRouteDeps(ctx), id, path[4], await readBody(request), requestAborted(request));
|
|
111
|
+
return json(outcome);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof SandboxRouteError)
|
|
115
|
+
fail(error.status, error.message);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
fail(404, "Route not found");
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (response.headersSent) {
|
|
124
|
+
response.end();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (error instanceof OpaqueAuthError) {
|
|
128
|
+
json(error.body, error.status);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const status = error instanceof HttpError ||
|
|
132
|
+
error instanceof VaultError ||
|
|
133
|
+
error instanceof SandboxRouteError
|
|
134
|
+
? error.status
|
|
135
|
+
: error?.name === "ZodError" ||
|
|
136
|
+
error?.message === "Invalid cursor"
|
|
137
|
+
? 400
|
|
138
|
+
: 500;
|
|
139
|
+
const rejection = error instanceof HttpError ? error.rejection : {};
|
|
140
|
+
json({
|
|
141
|
+
status: "rejected",
|
|
142
|
+
code: status === 500
|
|
143
|
+
? "internal_error"
|
|
144
|
+
: rejection.code ?? "request_rejected",
|
|
145
|
+
message: status === 500 ? "Runtime request failed" : error.message,
|
|
146
|
+
...(rejection.details === undefined
|
|
147
|
+
? {}
|
|
148
|
+
: { details: rejection.details }),
|
|
149
|
+
}, status);
|
|
150
|
+
}
|
|
151
|
+
}
|
package/dist/tenant/runtime.d.ts
CHANGED
|
@@ -1,80 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Composition root of an open Tenant: validates the config, opens the Session Store and the
|
|
3
|
+
* vault key, builds the services and the `TenantContext`, wires the seams, registers the
|
|
4
|
+
* Tenant's Worker handlers and arms its sweep, and implements `TenantHandle` (handle,
|
|
5
|
+
* summary, drain, close) by delegating to the Tenant modules.
|
|
6
|
+
*
|
|
7
|
+
* Seams wired here: `wireStreams()` connects the store's commits to Durable Streams (the
|
|
8
|
+
* relay, and the history, SSE, work and control readers); `wake` goes to the
|
|
9
|
+
* `DurableExecution`, whose handlers (`worker.ts`) call `advance` and `sweep`; `abortLocal`
|
|
10
|
+
* aborts an advance running on this process. The sweep also drains the outbox.
|
|
11
|
+
*
|
|
12
|
+
* Execution: the Host passes one `TenantExecution` for every Tenant it opens
|
|
13
|
+
* (`TenantOpenHooks.execution`); without one, the Tenant runs its own in-process
|
|
14
|
+
* `MemoryExecution`. No lock file: several processes may open a Tenant, and ownership of each
|
|
15
|
+
* session (§10.6) keeps its advances apart.
|
|
16
|
+
*/
|
|
17
|
+
import type { ServerResponse, IncomingMessage } from "node:http";
|
|
4
18
|
import type { TenantEnvelope } from "@nylorun/core/contracts";
|
|
19
|
+
import { type ModelProvider } from "../core/provider.js";
|
|
5
20
|
import { type AuthorizeResult } from "../vault/service.js";
|
|
21
|
+
import type { DurableStreams } from "../streams/types.js";
|
|
22
|
+
import type { OpenedTenant, TenantConfig, TenantHandle, TenantSummary } from "./types.js";
|
|
23
|
+
import { type StreamsStatus } from "./streams.js";
|
|
24
|
+
import { type TenantExecution, type TenantWorker } from "./worker.js";
|
|
6
25
|
/** TENANTS-CCR: test/injection hooks until TenantConfig gains them. */
|
|
7
26
|
export type TenantOpenHooks = {
|
|
8
27
|
modelProvider?: ModelProvider;
|
|
9
28
|
vaultKek?: Buffer | string | null;
|
|
10
29
|
/** When true, create the KEK file on first vault write (tests / new Tenants). */
|
|
11
30
|
createKekIfMissing?: boolean;
|
|
12
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The Host's Durable Session Execution and the registry its handlers dispatch through.
|
|
33
|
+
* The Host starts it; the Tenant registers its worker and arms its sweep. Without one,
|
|
34
|
+
* the Tenant starts and stops its own in-process `MemoryExecution`.
|
|
35
|
+
*/
|
|
36
|
+
execution?: TenantExecution;
|
|
37
|
+
/** The Worker id written as session owner. Defaults to this process's `WORKER_ID`. */
|
|
38
|
+
workerId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Durable Streams for this Tenant, owned by the caller (the Host's S2 streams). Without
|
|
41
|
+
* them the Tenant creates its own in-process `MemoryStreams`, whose history does not
|
|
42
|
+
* survive a restart (tests, and a Host without S2).
|
|
43
|
+
*/
|
|
44
|
+
streams?: DurableStreams;
|
|
45
|
+
} & OpenedTenant;
|
|
13
46
|
export declare class TenantRuntime implements TenantHandle {
|
|
14
|
-
private readonly
|
|
15
|
-
private readonly store;
|
|
16
|
-
private readonly vault;
|
|
17
|
-
private kek;
|
|
18
|
-
private readonly kekPath;
|
|
19
|
-
private readonly running;
|
|
20
|
-
private readonly pending;
|
|
21
|
-
private readonly observers;
|
|
22
|
-
private readonly executorStreams;
|
|
23
|
-
private readonly registry;
|
|
24
|
-
private readonly mcp;
|
|
25
|
-
private readonly sandbox;
|
|
26
|
-
private closing;
|
|
27
|
-
private closed;
|
|
28
|
-
private readonly lockPath?;
|
|
29
|
-
private readonly timer;
|
|
30
|
-
private readonly modelProvider;
|
|
31
|
-
private readonly useVaultModel;
|
|
32
|
-
private readonly createKekIfMissing;
|
|
33
|
-
private readonly flowLimits;
|
|
47
|
+
private readonly ctx;
|
|
34
48
|
readonly envelope: TenantEnvelope;
|
|
49
|
+
/** This Tenant's Worker handlers, as registered with the execution. */
|
|
50
|
+
readonly worker: TenantWorker;
|
|
51
|
+
private readonly detach;
|
|
52
|
+
/** How long close waits for running advances: the execution's advance grace period. */
|
|
53
|
+
private readonly closeGraceMs;
|
|
35
54
|
private constructor();
|
|
36
|
-
static open(config: TenantConfig, hooks
|
|
37
|
-
|
|
38
|
-
private publish;
|
|
39
|
-
private send;
|
|
40
|
-
private notify;
|
|
41
|
-
/**
|
|
42
|
-
* Manifest v4 replaced beforeModelCall/afterModelCall with scoped hooks. Turns started under
|
|
43
|
-
* an older manifest cannot continue, and their hook actions no longer parse, so end them.
|
|
44
|
-
*/
|
|
45
|
-
private retireLegacyHooks;
|
|
46
|
-
private expireClaims;
|
|
47
|
-
private schedule;
|
|
48
|
-
private execute;
|
|
49
|
-
private invokeModel;
|
|
50
|
-
private resolveEffect;
|
|
51
|
-
/** Journal and dispatch a new flow effect (agent / tool node / fn / verify). */
|
|
52
|
-
private resolveNewFlowEffect;
|
|
53
|
-
private scope;
|
|
54
|
-
private scoped;
|
|
55
|
-
private requireApplication;
|
|
56
|
-
private sandboxRouteDeps;
|
|
57
|
-
private body;
|
|
58
|
-
private command;
|
|
59
|
-
private sse;
|
|
60
|
-
handle(request: IncomingMessage, response: ServerResponse, _url?: URL): Promise<void>;
|
|
61
|
-
private view;
|
|
62
|
-
private prepareMcp;
|
|
63
|
-
private callMcpTool;
|
|
64
|
-
private callSandboxTool;
|
|
55
|
+
static open(config: TenantConfig, hooks: TenantOpenHooks): Promise<TenantRuntime>;
|
|
56
|
+
handle(request: IncomingMessage, response: ServerResponse, url?: URL): Promise<void>;
|
|
65
57
|
authorize(sessionId: string, request: {
|
|
66
58
|
url: string;
|
|
67
59
|
serverName?: string;
|
|
68
60
|
}): Promise<AuthorizeResult>;
|
|
69
|
-
|
|
70
|
-
private dispatchTenant;
|
|
71
|
-
private dispatchVault;
|
|
72
|
-
summary(): TenantSummary;
|
|
61
|
+
summary(): Promise<TenantSummary>;
|
|
73
62
|
drain(activeWork: "drain" | "cancel", timeoutMs?: number): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Aborts the advance of `sessionId` if it runs on this process. Cancel calls it after
|
|
65
|
+
* committing `cancelled`; the control stream calls it for cancels made elsewhere.
|
|
66
|
+
*/
|
|
67
|
+
abortLocal(sessionId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* The Durable Streams seam's status for Tenant status and readiness: S2 reachability, the
|
|
70
|
+
* basin, outbox depth and relay lag (`streamsStatus` in `tenant/streams.ts`).
|
|
71
|
+
*/
|
|
72
|
+
streamsStatus(): Promise<StreamsStatus>;
|
|
73
|
+
/** Adds a callback to the Tenant sweep. Returns a function that removes it. */
|
|
74
|
+
onSweep(hook: () => Promise<void>): () => void;
|
|
74
75
|
close(): Promise<void>;
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Open a Tenant Runtime from an explicit `TenantConfig`. No listen() (A1).
|
|
78
79
|
* Implements `OpenTenantRuntime`.
|
|
79
80
|
*/
|
|
80
|
-
export declare function openTenantRuntime(config: TenantConfig, hooks
|
|
81
|
+
export declare function openTenantRuntime(config: TenantConfig, hooks: TenantOpenHooks): Promise<TenantHandle>;
|