@nylorun/runtime 0.13.0-beta → 0.14.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 +330 -0
- package/README.md +69 -15
- package/dist/adapters/execution/restate.d.ts +7 -2
- package/dist/adapters/execution/restate.js +38 -8
- package/dist/adapters/replication/pgoutput.d.ts +16 -0
- package/dist/adapters/replication/pgoutput.js +169 -0
- package/dist/adapters/streams/s2.js +37 -20
- package/dist/admin-openapi.json +1071 -0
- package/dist/api/a2a/card.d.ts +15 -0
- package/dist/api/a2a/card.js +24 -0
- package/dist/api/a2a/endpoint.d.ts +8 -0
- package/dist/api/a2a/endpoint.js +81 -0
- package/dist/api/a2a/protocol.d.ts +144 -0
- package/dist/api/a2a/protocol.js +188 -0
- package/dist/api/a2a/routes.d.ts +19 -0
- package/dist/api/a2a/routes.js +289 -0
- package/dist/api/a2a/tasks.d.ts +50 -0
- package/dist/api/a2a/tasks.js +186 -0
- package/dist/api/ag-ui/endpoint.d.ts +8 -0
- package/dist/api/ag-ui/endpoint.js +126 -0
- package/dist/api/ag-ui/history.d.ts +7 -0
- package/dist/api/ag-ui/history.js +60 -0
- package/dist/api/ag-ui/routes.d.ts +32 -0
- package/dist/api/ag-ui/routes.js +305 -0
- package/dist/api/ag-ui/session-id.d.ts +1 -0
- package/dist/api/ag-ui/session-id.js +12 -0
- package/dist/api/ag-ui/sse.d.ts +9 -0
- package/dist/api/ag-ui/sse.js +7 -0
- package/dist/api/ag-ui/translate.d.ts +38 -0
- package/dist/api/ag-ui/translate.js +222 -0
- package/dist/api/components.d.ts +7825 -0
- package/dist/api/components.js +83 -0
- package/dist/api/http/app.d.ts +18 -0
- package/dist/api/http/app.js +58 -0
- package/dist/api/http/body.d.ts +4 -0
- package/dist/api/http/body.js +37 -0
- package/dist/api/http/define.d.ts +39 -0
- package/dist/api/http/define.js +130 -0
- package/dist/api/http/respond.d.ts +9 -0
- package/dist/api/http/respond.js +44 -0
- package/dist/api/http/routes/access.d.ts +24 -0
- package/dist/api/http/routes/access.js +259 -0
- package/dist/api/http/routes/actions.d.ts +8 -0
- package/dist/api/http/routes/actions.js +76 -0
- package/dist/api/http/routes/endpoints.d.ts +7 -0
- package/dist/api/http/routes/endpoints.js +100 -0
- package/dist/api/http/routes/sessions.d.ts +3 -0
- package/dist/api/http/routes/sessions.js +205 -0
- package/dist/api/http/routes/tenant.d.ts +10 -0
- package/dist/api/http/routes/tenant.js +172 -0
- package/dist/api/http/routes/vaults.d.ts +8 -0
- package/dist/api/http/routes/vaults.js +167 -0
- package/dist/api/openapi.d.ts +19 -0
- package/dist/api/openapi.js +138 -0
- package/dist/api/route.d.ts +12 -0
- package/dist/api/route.js +4 -0
- package/dist/core/bearer.d.ts +8 -0
- package/dist/core/bearer.js +11 -0
- package/dist/core/flow-host.d.ts +7 -15
- package/dist/core/flow-host.js +16 -41
- package/dist/core/sandbox-routes.d.ts +12 -7
- package/dist/core/sandbox-routes.js +24 -25
- package/dist/execution/memory.d.ts +8 -5
- package/dist/execution/memory.js +33 -13
- package/dist/execution/types.d.ts +38 -6
- package/dist/execution/types.js +12 -3
- package/dist/host/admin-api.d.ts +22 -0
- package/dist/host/admin-api.js +178 -0
- package/dist/host/app.d.ts +34 -0
- package/dist/host/app.js +185 -0
- package/dist/host/config-for.d.ts +2 -0
- package/dist/host/config-for.js +1 -0
- package/dist/host/config.d.ts +11 -0
- package/dist/host/cors.d.ts +27 -0
- package/dist/host/cors.js +64 -0
- package/dist/host/create-host.d.ts +31 -3
- package/dist/host/create-host.js +168 -327
- package/dist/host/http.d.ts +14 -3
- package/dist/host/http.js +64 -23
- package/dist/host/main.js +55 -4
- package/dist/host/stack-config.d.ts +20 -0
- package/dist/host/stack-config.js +55 -0
- package/dist/mcp/pool.d.ts +19 -1
- package/dist/mcp/pool.js +60 -10
- package/dist/model/catalog.d.ts +2 -10
- package/dist/model/classify.d.ts +13 -0
- package/dist/model/classify.js +61 -0
- package/dist/model/models.d.ts +10 -1
- package/dist/model/models.js +14 -6
- package/dist/model/pi-model.d.ts +17 -2
- package/dist/model/pi-model.js +366 -222
- package/dist/openapi.json +25696 -0
- package/dist/sandbox/manager.d.ts +13 -1
- package/dist/sandbox/manager.js +8 -11
- package/dist/sandbox/resolve.d.ts +33 -0
- package/dist/sandbox/resolve.js +81 -0
- package/dist/sandbox/session-sandbox.d.ts +11 -0
- package/dist/sandbox/session-sandbox.js +51 -0
- package/dist/sandbox/share.d.ts +14 -2
- package/dist/sandbox/share.js +33 -3
- package/dist/sandbox/tenant-config.d.ts +37 -0
- package/dist/sandbox/tenant-config.js +51 -0
- package/dist/sandbox/tools.d.ts +7 -9
- package/dist/sandbox/tools.js +11 -3
- package/dist/sandbox/types.d.ts +8 -2
- package/dist/store/event.d.ts +19 -0
- package/dist/store/event.js +49 -0
- package/dist/store/memory.d.ts +20 -8
- package/dist/store/memory.js +265 -100
- package/dist/store/postgres/connect.d.ts +13 -0
- package/dist/store/postgres/connect.js +5 -0
- package/dist/store/postgres/migrations/003_subject_tokens.d.ts +8 -0
- package/dist/store/postgres/migrations/003_subject_tokens.js +42 -0
- package/dist/store/postgres/migrations/004_publishable_keys.d.ts +6 -0
- package/dist/store/postgres/migrations/004_publishable_keys.js +18 -0
- package/dist/store/postgres/migrations/005_action_endpoints.d.ts +6 -0
- package/dist/store/postgres/migrations/005_action_endpoints.js +32 -0
- package/dist/store/postgres/migrations/006_drop_executors.d.ts +11 -0
- package/dist/store/postgres/migrations/006_drop_executors.js +32 -0
- package/dist/store/postgres/migrations/007_event_time.d.ts +7 -0
- package/dist/store/postgres/migrations/007_event_time.js +14 -0
- package/dist/store/postgres/migrations/008_durable_streams.d.ts +13 -0
- package/dist/store/postgres/migrations/008_durable_streams.js +35 -0
- package/dist/store/postgres/migrations/index.d.ts +5 -1
- package/dist/store/postgres/migrations/index.js +22 -2
- package/dist/store/postgres/migrations/shared/index.d.ts +31 -0
- package/dist/store/postgres/migrations/shared/index.js +92 -0
- package/dist/store/postgres/record.d.ts +11 -0
- package/dist/store/postgres/record.js +64 -0
- package/dist/store/postgres/store.js +337 -95
- package/dist/store/postgres/tenants.js +14 -0
- package/dist/store/types.d.ts +176 -81
- package/dist/streams/basin.d.ts +18 -1
- package/dist/streams/basin.js +34 -2
- package/dist/streams/control.d.ts +18 -0
- package/dist/streams/control.js +29 -0
- package/dist/streams/memory.d.ts +3 -1
- package/dist/streams/memory.js +14 -8
- package/dist/streams/relay/core.d.ts +35 -0
- package/dist/streams/relay/core.js +366 -0
- package/dist/streams/relay/memory.d.ts +69 -0
- package/dist/streams/relay/memory.js +176 -0
- package/dist/streams/relay/types.d.ts +77 -0
- package/dist/streams/relay/types.js +7 -0
- package/dist/streams/types.d.ts +66 -36
- package/dist/streams/types.js +18 -53
- package/dist/tenant/access-policy.d.ts +30 -0
- package/dist/tenant/access-policy.js +52 -0
- package/dist/tenant/actions.d.ts +10 -149
- package/dist/tenant/actions.js +5 -167
- package/dist/tenant/advance.js +32 -0
- package/dist/tenant/auth.d.ts +19 -17
- package/dist/tenant/auth.js +90 -93
- package/dist/tenant/browser.d.ts +15 -0
- package/dist/tenant/browser.js +39 -0
- package/dist/tenant/commands.d.ts +18 -2
- package/dist/tenant/commands.js +107 -113
- package/dist/tenant/context.d.ts +75 -18
- package/dist/tenant/context.js +14 -10
- package/dist/tenant/delivery-token.d.ts +41 -0
- package/dist/tenant/delivery-token.js +105 -0
- package/dist/tenant/delivery.d.ts +62 -0
- package/dist/tenant/delivery.js +476 -0
- package/dist/tenant/effects.d.ts +5 -0
- package/dist/tenant/effects.js +78 -37
- package/dist/tenant/endpoints.d.ts +67 -0
- package/dist/tenant/endpoints.js +90 -0
- package/dist/tenant/ephemeral.d.ts +6 -0
- package/dist/tenant/ephemeral.js +60 -36
- package/dist/tenant/http.d.ts +8 -9
- package/dist/tenant/http.js +13 -27
- package/dist/tenant/jwt.d.ts +16 -0
- package/dist/tenant/jwt.js +50 -0
- package/dist/tenant/module.d.ts +3 -0
- package/dist/tenant/module.js +6 -12
- package/dist/tenant/outbound.d.ts +44 -0
- package/dist/tenant/outbound.js +127 -0
- package/dist/tenant/pool.d.ts +0 -2
- package/dist/tenant/pool.js +0 -18
- package/dist/tenant/reset.d.ts +0 -4
- package/dist/tenant/reset.js +0 -5
- package/dist/tenant/runtime.d.ts +10 -20
- package/dist/tenant/runtime.js +59 -42
- package/dist/tenant/scheduler.d.ts +7 -2
- package/dist/tenant/scheduler.js +7 -3
- package/dist/tenant/session-streams.d.ts +125 -0
- package/dist/tenant/session-streams.js +399 -0
- package/dist/tenant/sessions.d.ts +28 -4
- package/dist/tenant/sessions.js +118 -24
- package/dist/tenant/signing-keys.d.ts +55 -0
- package/dist/tenant/signing-keys.js +172 -0
- package/dist/tenant/slim.d.ts +8 -0
- package/dist/tenant/slim.js +21 -0
- package/dist/tenant/status.d.ts +0 -3
- package/dist/tenant/status.js +19 -12
- package/dist/tenant/streams.d.ts +60 -67
- package/dist/tenant/streams.js +140 -208
- package/dist/tenant/subject-limits.d.ts +16 -0
- package/dist/tenant/subject-limits.js +45 -0
- package/dist/tenant/sweep.d.ts +1 -10
- package/dist/tenant/sweep.js +29 -69
- package/dist/tenant/tokens.d.ts +14 -0
- package/dist/tenant/tokens.js +178 -0
- package/dist/tenant/transcript.d.ts +48 -5
- package/dist/tenant/transcript.js +58 -1
- package/dist/tenant/types.d.ts +29 -7
- package/dist/tenant/worker.d.ts +3 -1
- package/dist/tenant/worker.js +9 -3
- package/dist/vault/service.d.ts +18 -2
- package/dist/vault/service.js +57 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -8
- package/dist/core/executors.d.ts +0 -44
- package/dist/core/executors.js +0 -95
- package/dist/streams/relay.d.ts +0 -37
- package/dist/streams/relay.js +0 -254
- package/dist/tenant/live.d.ts +0 -92
- package/dist/tenant/live.js +0 -290
- package/dist/tenant/routes-tenant.d.ts +0 -12
- package/dist/tenant/routes-tenant.js +0 -137
- package/dist/tenant/routes.d.ts +0 -9
- package/dist/tenant/routes.js +0 -151
package/dist/tenant/routes.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
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
|
-
}
|