@nylorun/runtime 0.26.0-beta → 0.28.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 +171 -0
- package/README.md +18 -14
- package/dist/adapters/execution/restate.d.ts +15 -18
- package/dist/adapters/execution/restate.js +31 -27
- package/dist/adapters/replication/pgoutput.d.ts +1 -1
- package/dist/adapters/replication/pgoutput.js +3 -2
- package/dist/adapters/sandbox/local.js +8 -5
- package/dist/adapters/sandbox/virtual.js +2 -2
- package/dist/adapters/streams/s2.d.ts +1 -1
- package/dist/adapters/streams/s2.js +18 -14
- package/dist/api/a2a/card.d.ts +4 -3
- package/dist/api/a2a/card.js +4 -4
- package/dist/api/a2a/endpoint.js +3 -4
- package/dist/api/a2a/protocol.js +4 -0
- package/dist/api/a2a/routes.d.ts +2 -6
- package/dist/api/a2a/routes.js +30 -25
- package/dist/api/ag-ui/endpoint.js +2 -3
- package/dist/api/ag-ui/routes.js +8 -11
- package/dist/api/components.d.ts +6789 -3405
- package/dist/api/components.js +43 -30
- package/dist/api/gate/keys.js +7 -4
- package/dist/api/gate/routes.d.ts +6 -2
- package/dist/api/gate/routes.js +15 -11
- package/dist/api/http/app.js +9 -4
- package/dist/api/http/body.d.ts +17 -3
- package/dist/api/http/body.js +35 -7
- package/dist/api/http/respond.js +6 -2
- package/dist/api/http/routes/access.js +5 -4
- package/dist/api/http/routes/agent-manifests.d.ts +10 -0
- package/dist/api/http/routes/agent-manifests.js +135 -0
- package/dist/api/http/routes/agents.d.ts +11 -0
- package/dist/api/http/routes/agents.js +418 -0
- package/dist/api/http/routes/artifacts.js +21 -9
- package/dist/api/http/routes/coverage.d.ts +4 -4
- package/dist/api/http/routes/coverage.js +13 -7
- package/dist/api/http/routes/files.d.ts +2 -1
- package/dist/api/http/routes/files.js +31 -5
- package/dist/api/http/routes/mcp.js +3 -3
- package/dist/api/http/routes/me.d.ts +1 -1
- package/dist/api/http/routes/me.js +1 -2
- package/dist/api/http/routes/memories.d.ts +9 -0
- package/dist/api/http/routes/memories.js +152 -0
- package/dist/api/http/routes/reads.d.ts +10 -111
- package/dist/api/http/routes/reads.js +51 -29
- package/dist/api/http/routes/sessions.js +26 -54
- package/dist/api/http/routes/tenant.d.ts +2 -2
- package/dist/api/http/routes/tenant.js +77 -24
- package/dist/api/http/routes/triggers.d.ts +10 -0
- package/dist/api/http/routes/triggers.js +180 -0
- package/dist/api/inbound-files.d.ts +3 -9
- package/dist/api/inbound-files.js +18 -24
- package/dist/api/openapi.js +73 -47
- package/dist/artifacts/disk.d.ts +10 -14
- package/dist/artifacts/disk.js +99 -95
- package/dist/artifacts/files.d.ts +13 -4
- package/dist/artifacts/files.js +27 -9
- package/dist/artifacts/folder-upload.d.ts +75 -0
- package/dist/artifacts/folder-upload.js +263 -0
- package/dist/artifacts/folders.d.ts +14 -8
- package/dist/artifacts/folders.js +19 -11
- package/dist/artifacts/links.js +7 -6
- package/dist/artifacts/parts.d.ts +9 -14
- package/dist/artifacts/parts.js +11 -9
- package/dist/artifacts/pipe.d.ts +15 -0
- package/dist/artifacts/pipe.js +71 -0
- package/dist/artifacts/quota.d.ts +36 -0
- package/dist/artifacts/quota.js +44 -0
- package/dist/artifacts/service.d.ts +25 -1
- package/dist/artifacts/service.js +72 -27
- package/dist/blob/fs.js +2 -1
- package/dist/blob/s3.d.ts +6 -2
- package/dist/blob/s3.js +9 -7
- package/dist/blob/types.d.ts +1 -1
- package/dist/blob/types.js +1 -1
- package/dist/core/flow-host.d.ts +0 -1
- package/dist/core/limits.d.ts +11 -35
- package/dist/core/limits.js +5 -73
- package/dist/core/sandbox-routes.js +0 -1
- package/dist/core/turn-manifest.d.ts +1 -2
- package/dist/core/turn-manifest.js +4 -28
- package/dist/execution/memory.d.ts +8 -5
- package/dist/execution/memory.js +8 -6
- package/dist/execution/types.d.ts +1 -6
- package/dist/execution/types.js +0 -5
- package/dist/gates/contract.d.ts +3 -2
- package/dist/gates/contract.js +1 -1
- package/dist/gates/egress-credentials.js +5 -4
- package/dist/gates/egress.d.ts +13 -13
- package/dist/gates/egress.js +19 -21
- package/dist/gates/fixture-model.js +13 -2
- package/dist/gates/handler.d.ts +1 -3
- package/dist/gates/handler.js +4 -3
- package/dist/gates/http-client.d.ts +4 -3
- package/dist/gates/http-client.js +5 -7
- package/dist/gates/http-tool.d.ts +24 -4
- package/dist/gates/http-tool.js +41 -13
- package/dist/gates/in-process.d.ts +2 -1
- package/dist/gates/in-process.js +17 -9
- package/dist/gates/inflight.d.ts +2 -2
- package/dist/gates/inflight.js +3 -2
- package/dist/gates/journal.js +5 -7
- package/dist/gates/mcp-handler.d.ts +4 -3
- package/dist/gates/mcp-handler.js +15 -5
- package/dist/gates/meter.js +6 -5
- package/dist/gates/model-gate.d.ts +11 -2
- package/dist/gates/policy.d.ts +34 -6
- package/dist/gates/policy.js +66 -18
- package/dist/gates/provider-gate.d.ts +22 -0
- package/dist/gates/provider-gate.js +30 -0
- package/dist/gates/tool-calls.d.ts +1 -3
- package/dist/gates/tool-calls.js +2 -3
- package/dist/gates/tool-client.d.ts +1 -1
- package/dist/gates/tool-client.js +5 -6
- package/dist/gates/tool-contract.d.ts +8 -5
- package/dist/gates/tool-contract.js +1 -1
- package/dist/gates/tool-gate.d.ts +18 -7
- package/dist/gates/tool-gate.js +49 -7
- package/dist/harness/calls.d.ts +27 -25
- package/dist/harness/calls.js +40 -46
- package/dist/harness/executors.d.ts +10 -3
- package/dist/harness/executors.js +53 -23
- package/dist/harness/main.js +2 -2
- package/dist/harness/pod.d.ts +2 -2
- package/dist/harness/pod.js +7 -6
- package/dist/harness/run-tokens.d.ts +4 -1
- package/dist/harness/run-tokens.js +6 -2
- package/dist/harness/service.d.ts +17 -14
- package/dist/harness/service.js +21 -35
- package/dist/harness/setup.d.ts +0 -2
- package/dist/harness/setup.js +21 -15
- package/dist/harness/ws-client.d.ts +2 -2
- package/dist/harness/ws-client.js +7 -5
- package/dist/harness/ws-port.d.ts +3 -4
- package/dist/harness/ws-port.js +3 -4
- package/dist/harness-api/artifacts.d.ts +20 -0
- package/dist/harness-api/artifacts.js +478 -0
- package/dist/harness-api/in-process.d.ts +2 -2
- package/dist/harness-api/in-process.js +18 -16
- package/dist/harness-api/record.d.ts +10 -9
- package/dist/harness-api/record.js +113 -157
- package/dist/harness-api/renew.d.ts +1 -1
- package/dist/harness-api/renew.js +2 -2
- package/dist/harness-api/server.d.ts +1 -16
- package/dist/harness-api/server.js +86 -73
- package/dist/harness-api/start.d.ts +27 -5
- package/dist/harness-api/start.js +102 -19
- package/dist/harness-api/tool-journal.d.ts +15 -10
- package/dist/harness-api/tool-journal.js +26 -24
- package/dist/harness-api/workspace.d.ts +0 -4
- package/dist/harness-api/workspace.js +4 -47
- package/dist/harness-api/ws-server.js +10 -10
- package/dist/host/create-host.js +2 -3
- package/dist/host/execution.js +2 -3
- package/dist/host/gates.d.ts +2 -9
- package/dist/host/gates.js +15 -12
- package/dist/host/http.d.ts +2 -4
- package/dist/host/http.js +5 -29
- package/dist/host/main.js +10 -3
- package/dist/host/operate.js +12 -3
- package/dist/host/stack-config.d.ts +11 -0
- package/dist/host/stack-config.js +21 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/infra/index.js +2 -1
- package/dist/infra/readiness.d.ts +0 -2
- package/dist/infra/readiness.js +4 -3
- package/dist/keys/client.d.ts +1 -0
- package/dist/keys/client.js +2 -3
- package/dist/keys/contract.d.ts +0 -2
- package/dist/keys/contract.js +0 -2
- package/dist/keys/egress-ca.d.ts +0 -2
- package/dist/keys/egress-ca.js +2 -3
- package/dist/keys/keys.d.ts +15 -4
- package/dist/keys/keys.js +22 -1
- package/dist/keys/webhooks.d.ts +25 -0
- package/dist/keys/webhooks.js +62 -0
- package/dist/keys/x509.d.ts +8 -4
- package/dist/keys/x509.js +14 -5
- package/dist/management-openapi.json +3043 -1954
- package/dist/mcp/connect.d.ts +35 -26
- package/dist/mcp/connect.js +112 -141
- package/dist/mcp/pool.d.ts +27 -22
- package/dist/mcp/pool.js +34 -48
- package/dist/mcp/preview.d.ts +12 -5
- package/dist/mcp/preview.js +43 -26
- package/dist/mcp/snapshot.d.ts +35 -86
- package/dist/mcp/snapshot.js +93 -135
- package/dist/memory/service.d.ts +97 -0
- package/dist/memory/service.js +335 -0
- package/dist/memory/tool.d.ts +36 -0
- package/dist/memory/tool.js +84 -0
- package/dist/model/auth-store.js +5 -3
- package/dist/model/capabilities.d.ts +1 -1
- package/dist/model/catalog.d.ts +9 -36
- package/dist/model/catalog.js +6 -33
- package/dist/model/descriptor.d.ts +51 -0
- package/dist/model/descriptor.js +83 -0
- package/dist/model/models.d.ts +0 -3
- package/dist/model/models.js +3 -5
- package/dist/model/native-blocks.js +1 -1
- package/dist/model/pi-model.d.ts +16 -5
- package/dist/model/pi-model.js +86 -105
- package/dist/openapi.json +13653 -9986
- package/dist/reads/cursor.js +3 -1
- package/dist/reads/types.d.ts +3 -3
- package/dist/record/agent.d.ts +27 -0
- package/dist/record/agent.js +46 -0
- package/dist/record/append.d.ts +34 -2
- package/dist/record/append.js +50 -1
- package/dist/record/index.d.ts +2 -2
- package/dist/record/index.js +2 -2
- package/dist/redact.d.ts +1 -1
- package/dist/redact.js +3 -2
- package/dist/sandbox/egress-token.d.ts +3 -3
- package/dist/sandbox/egress-token.js +3 -3
- package/dist/sandbox/join.js +8 -7
- package/dist/sandbox/manager.d.ts +41 -41
- package/dist/sandbox/manager.js +112 -44
- package/dist/sandbox/placement.d.ts +2 -2
- package/dist/sandbox/placement.js +7 -10
- package/dist/sandbox/pods/client.d.ts +1 -10
- package/dist/sandbox/pods/client.js +8 -4
- package/dist/sandbox/pods/lifecycle.d.ts +25 -17
- package/dist/sandbox/pods/lifecycle.js +51 -29
- package/dist/sandbox/pods/network-gate.d.ts +4 -5
- package/dist/sandbox/pods/network-gate.js +7 -7
- package/dist/sandbox/pods/reconcile.js +14 -3
- package/dist/sandbox/pods/spec.js +8 -5
- package/dist/sandbox/policy.d.ts +7 -1
- package/dist/sandbox/policy.js +10 -3
- package/dist/sandbox/resolve.d.ts +11 -6
- package/dist/sandbox/resolve.js +19 -9
- package/dist/sandbox/setup.d.ts +6 -2
- package/dist/sandbox/setup.js +47 -14
- package/dist/sandbox/share.d.ts +5 -14
- package/dist/sandbox/share.js +5 -34
- package/dist/sandbox/skills.d.ts +7 -13
- package/dist/sandbox/skills.js +16 -31
- package/dist/sandbox/tenant-config.d.ts +2 -2
- package/dist/sandbox/tenant-config.js +4 -3
- package/dist/sandbox/tools.d.ts +7 -1
- package/dist/sandbox/tools.js +26 -26
- package/dist/sandbox/types.d.ts +10 -3
- package/dist/sandbox/types.js +9 -0
- package/dist/store/postgres/connect.d.ts +6 -5
- package/dist/store/postgres/connect.js +14 -11
- package/dist/store/postgres/control.js +13 -13
- package/dist/store/postgres/drizzle/0028_artifact_write_keys.sql +2 -0
- package/dist/store/postgres/drizzle/0029_protocol_15.sql +11 -0
- package/dist/store/postgres/drizzle/0030_protocol_15_runtime_block.sql +11 -0
- package/dist/store/postgres/drizzle/0031_protocol_15_mcp_snapshot.sql +8 -0
- package/dist/store/postgres/drizzle/0032_agents.sql +54 -0
- package/dist/store/postgres/drizzle/0033_agent_versions.sql +7 -0
- package/dist/store/postgres/drizzle/0034_protocol_17_session_queue.sql +13 -0
- package/dist/store/postgres/drizzle/0035_t4_triggers.sql +41 -0
- package/dist/store/postgres/drizzle/0036_t5_memories.sql +30 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +63 -0
- package/dist/store/postgres/reads.js +17 -82
- package/dist/store/postgres/record-writer.d.ts +4 -4
- package/dist/store/postgres/record-writer.js +9 -9
- package/dist/store/postgres/schema.d.ts +1382 -151
- package/dist/store/postgres/schema.js +191 -37
- package/dist/store/postgres/store.js +384 -105
- package/dist/store/postgres/tenant.js +1 -2
- package/dist/store/types.d.ts +172 -57
- package/dist/store/types.js +0 -1
- package/dist/streams/relay/core.d.ts +3 -3
- package/dist/streams/relay/core.js +9 -10
- package/dist/tenant/advance.js +41 -39
- package/dist/tenant/agent-manifests.d.ts +72 -0
- package/dist/tenant/agent-manifests.js +359 -0
- package/dist/tenant/agent-versions.d.ts +126 -0
- package/dist/tenant/agent-versions.js +389 -0
- package/dist/tenant/agents.d.ts +230 -0
- package/dist/tenant/{environments.js → agents.js} +493 -328
- package/dist/tenant/auth.d.ts +1 -1
- package/dist/tenant/auth.js +3 -3
- package/dist/tenant/commands.d.ts +63 -2
- package/dist/tenant/commands.js +240 -90
- package/dist/tenant/context.d.ts +57 -33
- package/dist/tenant/context.js +6 -2
- package/dist/tenant/definition-files.d.ts +25 -4
- package/dist/tenant/definition-files.js +85 -47
- package/dist/tenant/effects.js +15 -51
- package/dist/tenant/ephemeral.js +2 -1
- package/dist/tenant/history.d.ts +1 -1
- package/dist/tenant/history.js +1 -1
- package/dist/tenant/host-token.d.ts +3 -3
- package/dist/tenant/host-token.js +11 -10
- package/dist/tenant/http.d.ts +5 -8
- package/dist/tenant/http.js +9 -0
- package/dist/tenant/identity-file.d.ts +29 -6
- package/dist/tenant/identity-file.js +45 -15
- package/dist/tenant/issuers.d.ts +5 -5
- package/dist/tenant/issuers.js +34 -26
- package/dist/tenant/jwt.d.ts +8 -2
- package/dist/tenant/jwt.js +10 -2
- package/dist/tenant/limits.d.ts +87 -0
- package/dist/tenant/limits.js +172 -0
- package/dist/tenant/memories.d.ts +38 -0
- package/dist/tenant/memories.js +119 -0
- package/dist/tenant/module.d.ts +4 -1
- package/dist/tenant/module.js +9 -8
- package/dist/tenant/outbound.d.ts +11 -14
- package/dist/tenant/outbound.js +10 -15
- package/dist/tenant/reset.js +2 -2
- package/dist/tenant/run-grants.d.ts +6 -0
- package/dist/tenant/run-grants.js +7 -2
- package/dist/tenant/run-token.d.ts +0 -4
- package/dist/tenant/run-token.js +6 -11
- package/dist/tenant/runtime-limits.d.ts +24 -0
- package/dist/tenant/runtime-limits.js +27 -0
- package/dist/tenant/runtime.d.ts +1 -1
- package/dist/tenant/runtime.js +38 -43
- package/dist/tenant/session-streams.js +7 -6
- package/dist/tenant/session.d.ts +1 -1
- package/dist/tenant/session.js +1 -1
- package/dist/tenant/sessions.d.ts +28 -45
- package/dist/tenant/sessions.js +89 -209
- package/dist/tenant/signing-keys.d.ts +1 -1
- package/dist/tenant/signing-keys.js +5 -6
- package/dist/tenant/status.js +10 -10
- package/dist/tenant/streams.js +18 -20
- package/dist/tenant/sweep.d.ts +1 -21
- package/dist/tenant/sweep.js +51 -51
- package/dist/tenant/transcript.d.ts +70 -23
- package/dist/tenant/transcript.js +28 -22
- package/dist/tenant/triggers.d.ts +143 -0
- package/dist/tenant/triggers.js +715 -0
- package/dist/tenant/turn-timing.d.ts +11 -1
- package/dist/tenant/turn-timing.js +3 -1
- package/dist/tenant/types.d.ts +9 -14
- package/dist/tenant/worker.d.ts +4 -10
- package/dist/tenant/worker.js +10 -14
- package/dist/traces/ids.js +5 -1
- package/dist/traces/map.d.ts +10 -7
- package/dist/traces/map.js +16 -12
- package/dist/traces/otlp.d.ts +3 -3
- package/dist/traces/otlp.js +5 -3
- package/dist/traces/projector.d.ts +9 -4
- package/dist/traces/projector.js +13 -7
- package/dist/traces/read.js +6 -1
- package/dist/tuning.d.ts +390 -0
- package/dist/tuning.js +677 -0
- package/dist/vault/headers.js +4 -2
- package/dist/vault/service.d.ts +13 -8
- package/dist/vault/service.js +61 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -12
- package/dist/api/http/routes/environment-manifests.d.ts +0 -9
- package/dist/api/http/routes/environment-manifests.js +0 -118
- package/dist/api/http/routes/environments.d.ts +0 -11
- package/dist/api/http/routes/environments.js +0 -332
- package/dist/artifacts/export.d.ts +0 -8
- package/dist/artifacts/export.js +0 -204
- package/dist/artifacts/media-types.d.ts +0 -30
- package/dist/artifacts/media-types.js +0 -137
- package/dist/artifacts/workspace.d.ts +0 -60
- package/dist/artifacts/workspace.js +0 -45
- package/dist/media.d.ts +0 -10
- package/dist/media.js +0 -58
- package/dist/record/environment.d.ts +0 -25
- package/dist/record/environment.js +0 -44
- package/dist/sandbox/runtime-tools.d.ts +0 -9
- package/dist/sandbox/runtime-tools.js +0 -16
- package/dist/sandbox/session-sandbox.d.ts +0 -16
- package/dist/sandbox/session-sandbox.js +0 -77
- package/dist/tenant/artifact-tool.d.ts +0 -13
- package/dist/tenant/artifact-tool.js +0 -243
- package/dist/tenant/environment-manifests.d.ts +0 -57
- package/dist/tenant/environment-manifests.js +0 -200
- package/dist/tenant/environments.d.ts +0 -174
- package/dist/tenant/skill-tool.d.ts +0 -20
- package/dist/tenant/skill-tool.js +0 -67
- package/dist/tenant/tool-results.d.ts +0 -57
- package/dist/tenant/tool-results.js +0 -298
- package/dist/tenant/tool-search.d.ts +0 -39
- package/dist/tenant/tool-search.js +0 -103
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tenant's Runtime limits (harness boundary S0), stored as Tenant setting `limits.config`
|
|
3
|
+
* (`GET`/`PUT /v1/tenant/limits`): what one record entry, model call, model file, tool answer,
|
|
4
|
+
* custom harness state and Harness API chunk may hold. Unset limits take their defaults
|
|
5
|
+
* (`RUNTIME_LIMIT_DEFAULTS`); none may pass its ceiling (`runtimeLimitIssues`), which the route
|
|
6
|
+
* checks before it writes.
|
|
7
|
+
*
|
|
8
|
+
* Read from Postgres where a limit is checked, never kept: the Record seam, the store's event
|
|
9
|
+
* write, the gates and the segment's `turn.start` each read it in their own transaction.
|
|
10
|
+
*/
|
|
11
|
+
import { type RuntimeLimits, type TenantLimitsConfig } from "@nylorun/core/contracts";
|
|
12
|
+
export declare const LIMITS_CONFIG_SETTING = "limits.config";
|
|
13
|
+
interface SettingsReader {
|
|
14
|
+
getSetting(key: string): Promise<string | undefined>;
|
|
15
|
+
}
|
|
16
|
+
interface SettingsWriter extends SettingsReader {
|
|
17
|
+
putSetting(key: string, value: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** The Tenant's stored limits; a stored value that does not parse counts as none set. */
|
|
20
|
+
export declare function readLimitsConfig(t: SettingsReader): Promise<TenantLimitsConfig>;
|
|
21
|
+
/** The Runtime limits in force: the Tenant's, with the default for each it leaves out. */
|
|
22
|
+
export declare function readRuntimeLimits(t: SettingsReader): Promise<RuntimeLimits>;
|
|
23
|
+
export declare function writeLimitsConfig(t: SettingsWriter, config: TenantLimitsConfig): Promise<void>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tenant's Runtime limits (harness boundary S0), stored as Tenant setting `limits.config`
|
|
3
|
+
* (`GET`/`PUT /v1/tenant/limits`): what one record entry, model call, model file, tool answer,
|
|
4
|
+
* custom harness state and Harness API chunk may hold. Unset limits take their defaults
|
|
5
|
+
* (`RUNTIME_LIMIT_DEFAULTS`); none may pass its ceiling (`runtimeLimitIssues`), which the route
|
|
6
|
+
* checks before it writes.
|
|
7
|
+
*
|
|
8
|
+
* Read from Postgres where a limit is checked, never kept: the Record seam, the store's event
|
|
9
|
+
* write, the gates and the segment's `turn.start` each read it in their own transaction.
|
|
10
|
+
*/
|
|
11
|
+
import { TenantLimitsConfigSchema, runtimeLimitsOf, } from "@nylorun/core/contracts";
|
|
12
|
+
export const LIMITS_CONFIG_SETTING = "limits.config";
|
|
13
|
+
/** The Tenant's stored limits; a stored value that does not parse counts as none set. */
|
|
14
|
+
export async function readLimitsConfig(t) {
|
|
15
|
+
const raw = await t.getSetting(LIMITS_CONFIG_SETTING);
|
|
16
|
+
if (raw === undefined)
|
|
17
|
+
return {};
|
|
18
|
+
const parsed = TenantLimitsConfigSchema.safeParse(JSON.parse(raw));
|
|
19
|
+
return parsed.success ? parsed.data : {};
|
|
20
|
+
}
|
|
21
|
+
/** The Runtime limits in force: the Tenant's, with the default for each it leaves out. */
|
|
22
|
+
export async function readRuntimeLimits(t) {
|
|
23
|
+
return runtimeLimitsOf((await readLimitsConfig(t)).limits);
|
|
24
|
+
}
|
|
25
|
+
export async function writeLimitsConfig(t, config) {
|
|
26
|
+
await t.putSetting(LIMITS_CONFIG_SETTING, JSON.stringify(TenantLimitsConfigSchema.parse(config)));
|
|
27
|
+
}
|
package/dist/tenant/runtime.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export type TenantOpenHooks = {
|
|
|
81
81
|
harnessTap?: MemoryPortsOptions["tap"];
|
|
82
82
|
/**
|
|
83
83
|
* Sandbox pods (F7.2): the sandboxes service (`NYLORUN_SANDBOXES_URL`) and the Runtime image
|
|
84
|
-
* pods copy the engine from. Without it, kind `pod` is `
|
|
84
|
+
* pods copy the engine from. Without it, kind `pod` is `agent_unavailable`.
|
|
85
85
|
*/
|
|
86
86
|
pods?: TenantPods;
|
|
87
87
|
/** How the trace route makes spans (R7.5): the Host's `OTEL_*` resource and content opt-ins. */
|
package/dist/tenant/runtime.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mkdirSync } from "node:fs";
|
|
2
|
-
import { resolveFlowLimits } from "../core/limits.js";
|
|
3
2
|
import { scriptedModel, toolFixtureModel, } from "../core/provider.js";
|
|
4
3
|
import { tenantModelGate } from "../gates/in-process.js";
|
|
5
4
|
import { createKekFile, readVaultKek } from "../vault/kek.js";
|
|
6
5
|
import { SigningKeys } from "./signing-keys.js";
|
|
6
|
+
import { readRuntimeLimits } from "./runtime-limits.js";
|
|
7
7
|
import { VaultService } from "../vault/service.js";
|
|
8
8
|
import { McpPool } from "../mcp/pool.js";
|
|
9
9
|
import { SandboxManager } from "../sandbox/manager.js";
|
|
@@ -20,7 +20,8 @@ import { advance } from "./advance.js";
|
|
|
20
20
|
import { sweep } from "./sweep.js";
|
|
21
21
|
import { TenantWorkers, WORKER_ID, } from "./worker.js";
|
|
22
22
|
import { authorize } from "./effects.js";
|
|
23
|
-
import { inProcessToolGate } from "../gates/tool-gate.js";
|
|
23
|
+
import { inProcessToolGate, openMcpThrough } from "../gates/tool-gate.js";
|
|
24
|
+
import { providerModelGate } from "../gates/provider-gate.js";
|
|
24
25
|
import { inProcessKeys } from "../keys/keys.js";
|
|
25
26
|
import { tenantApi } from "../api/http/app.js";
|
|
26
27
|
import { createFsBlobStore } from "../blob/index.js";
|
|
@@ -31,24 +32,17 @@ import { localWorkspace, remoteWorkspace, withPodWorkspaces, } from "../harness-
|
|
|
31
32
|
import { hostAuthority } from "../sandbox/join.js";
|
|
32
33
|
import { harnessOfToken } from "./harness-tokens.js";
|
|
33
34
|
import { reconcileSandbox } from "../sandbox/pods/reconcile.js";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
/** Default ownership lease of an advance; the heartbeat renews it every third. */
|
|
37
|
-
const DEFAULT_OWNER_LEASE_MS = 30_000;
|
|
35
|
+
import { fireTimer } from "./triggers.js";
|
|
36
|
+
import { hostTuning } from "../tuning.js";
|
|
38
37
|
function validateConfig(config) {
|
|
39
38
|
for (const key of ["leaseMs", "ownerLeaseMs", "sweepIntervalMs"]) {
|
|
40
39
|
const value = config[key];
|
|
41
40
|
if (value !== undefined && (!Number.isFinite(value) || value <= 0))
|
|
42
41
|
throw new Error(`${key} must be finite and positive`);
|
|
43
42
|
}
|
|
44
|
-
const flowLimits = resolveFlowLimits({
|
|
45
|
-
flow: config.flow,
|
|
46
|
-
env: config.flowEnv,
|
|
47
|
-
});
|
|
48
43
|
if ((config.model.kind === "fixture" || config.model.kind === "scripted") &&
|
|
49
44
|
config.mode === "shared")
|
|
50
45
|
throw new Error("fixture/scripted models require ephemeral or test mode");
|
|
51
|
-
return flowLimits;
|
|
52
46
|
}
|
|
53
47
|
export class TenantRuntime {
|
|
54
48
|
ctx;
|
|
@@ -81,7 +75,7 @@ export class TenantRuntime {
|
|
|
81
75
|
}
|
|
82
76
|
static async open(config, hooks) {
|
|
83
77
|
const envelope = hooks.envelope;
|
|
84
|
-
|
|
78
|
+
validateConfig(config);
|
|
85
79
|
const paths = config.paths;
|
|
86
80
|
mkdirSync(paths.root, { recursive: true });
|
|
87
81
|
mkdirSync(paths.home, { recursive: true });
|
|
@@ -128,6 +122,7 @@ export class TenantRuntime {
|
|
|
128
122
|
inProcessToolGate(config.delivery ?? {}, {
|
|
129
123
|
session: (sessionId) => opened.tx((t) => t.get("sessions", sessionId)),
|
|
130
124
|
authorize: (sessionId, request) => authorize(ctx, sessionId, request),
|
|
125
|
+
limits: () => opened.tx((t) => readRuntimeLimits(t)),
|
|
131
126
|
logger: config.logger,
|
|
132
127
|
});
|
|
133
128
|
const signingKeys = new SigningKeys({ tenantId: config.tenantId, kek: ensureKek });
|
|
@@ -144,13 +139,9 @@ export class TenantRuntime {
|
|
|
144
139
|
const preference = seededBackend ?? config.sandbox.backend;
|
|
145
140
|
// With a harness in this process, the Tenant's MCP pool and SandboxManager are its
|
|
146
141
|
// executors; otherwise the harness holds both (F6.2).
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
policy: config.delivery ?? {},
|
|
151
|
-
...(toolGate.openMcp ? { openRemote: (server) => toolGate.openMcp(server) } : {}),
|
|
152
|
-
})
|
|
153
|
-
: undefined;
|
|
142
|
+
// The pool opens every server through the Tool Gate: core never authorizes an MCP
|
|
143
|
+
// connection outside a gate (protocol 15).
|
|
144
|
+
const mcp = inProcess ? new McpPool({ openRemote: openMcpThrough(toolGate) }) : undefined;
|
|
154
145
|
const ephemeral = config.mode === "ephemeral";
|
|
155
146
|
const manager = inProcess
|
|
156
147
|
? new SandboxManager({
|
|
@@ -160,12 +151,6 @@ export class TenantRuntime {
|
|
|
160
151
|
defaultSandboxBackends({ root: paths.sandboxes }),
|
|
161
152
|
preference,
|
|
162
153
|
ephemeral,
|
|
163
|
-
definitionFile: async (sha256) => {
|
|
164
|
-
const bytes = await readDefinitionFile(blobs, sha256);
|
|
165
|
-
if (!bytes)
|
|
166
|
-
throw new Error(`The Object store has no bytes for ${sha256}`);
|
|
167
|
-
return bytes;
|
|
168
|
-
},
|
|
169
154
|
emit: async (sessionId, turnId, type, payload) => {
|
|
170
155
|
if (ctx.closed)
|
|
171
156
|
return;
|
|
@@ -201,9 +186,13 @@ export class TenantRuntime {
|
|
|
201
186
|
isPod: async (sandboxId) => (await opened.tx((t) => t.environment(sandboxId)))?.kind === "pod",
|
|
202
187
|
})
|
|
203
188
|
: workspaces;
|
|
204
|
-
|
|
189
|
+
// A model that is not the vault's (scripted, the fixture, an embedder's provider) is
|
|
190
|
+
// served by a gate over it, metered like any (protocol 15): no harness calls a provider.
|
|
191
|
+
const scripted = config.model.kind !== "vault";
|
|
205
192
|
let modelProvider;
|
|
206
|
-
if (
|
|
193
|
+
if (!scripted)
|
|
194
|
+
modelProvider = undefined;
|
|
195
|
+
else if (hooks.modelProvider)
|
|
207
196
|
modelProvider = hooks.modelProvider;
|
|
208
197
|
else if (config.model.kind === "scripted")
|
|
209
198
|
modelProvider = scriptedModel(config.model.output);
|
|
@@ -214,21 +203,23 @@ export class TenantRuntime {
|
|
|
214
203
|
const blobs = hooks.blobs ?? createFsBlobStore({ root: paths.blobs });
|
|
215
204
|
// With the gates service the loop never reads a model credential: only a Runtime
|
|
216
205
|
// without one (embedding, the ephemeral Runtime, tests) reads it here.
|
|
217
|
-
const modelGate =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
206
|
+
const modelGate = modelProvider
|
|
207
|
+
? providerModelGate(modelProvider, { store: opened, logger: config.logger })
|
|
208
|
+
: (hooks.modelGate ??
|
|
209
|
+
tenantModelGate({
|
|
210
|
+
store: opened,
|
|
211
|
+
kek: ensureKek,
|
|
212
|
+
root: paths.home,
|
|
213
|
+
logger: config.logger,
|
|
214
|
+
blobs,
|
|
215
|
+
}));
|
|
226
216
|
const sessionStreams = createSessionStreams();
|
|
227
217
|
const workers = hooks.execution?.workers ?? new TenantWorkers();
|
|
228
218
|
const local = hooks.execution
|
|
229
219
|
? undefined
|
|
230
220
|
: new MemoryExecution({
|
|
231
|
-
sweepIntervalMs: config.sweepIntervalMs ??
|
|
221
|
+
sweepIntervalMs: config.sweepIntervalMs ??
|
|
222
|
+
Math.min(config.leaseMs ?? Infinity, hostTuning().sweep.intervalMs),
|
|
232
223
|
// Close's `detach` step waits no longer for running work than for its advances.
|
|
233
224
|
stopGraceMs: workers.graceMs,
|
|
234
225
|
onError: (error) => config.logger.error("tenant execution failed", {
|
|
@@ -245,9 +236,7 @@ export class TenantRuntime {
|
|
|
245
236
|
vault,
|
|
246
237
|
...(mcp ? { mcp } : {}),
|
|
247
238
|
sandbox,
|
|
248
|
-
|
|
249
|
-
modelProvider,
|
|
250
|
-
useVaultModel,
|
|
239
|
+
scriptedModel: scripted,
|
|
251
240
|
modelGate,
|
|
252
241
|
toolGate,
|
|
253
242
|
get harness() {
|
|
@@ -260,11 +249,10 @@ export class TenantRuntime {
|
|
|
260
249
|
signingKeys,
|
|
261
250
|
keys,
|
|
262
251
|
blobs,
|
|
263
|
-
workspaces: sandboxWorkspaceReader(sandbox),
|
|
264
252
|
...(hooks.traces ? { traces: hooks.traces } : {}),
|
|
265
253
|
...(hooks.runGrants ? { runGrants: hooks.runGrants } : {}),
|
|
266
254
|
workerId: hooks.workerId ?? WORKER_ID,
|
|
267
|
-
ownerLeaseMs: config.ownerLeaseMs ??
|
|
255
|
+
ownerLeaseMs: config.ownerLeaseMs ?? hostTuning().tenant.ownerLeaseMs,
|
|
268
256
|
wake: async (sessionId, wake) => {
|
|
269
257
|
if (ctx.closing || ctx.closed)
|
|
270
258
|
return false;
|
|
@@ -279,6 +267,12 @@ export class TenantRuntime {
|
|
|
279
267
|
await execution.sandbox?.(config.tenantId, sandboxId, signal);
|
|
280
268
|
return true;
|
|
281
269
|
},
|
|
270
|
+
timer: async (key, at) => {
|
|
271
|
+
if (ctx.closing || ctx.closed)
|
|
272
|
+
return false;
|
|
273
|
+
await execution.timer(config.tenantId, key, at);
|
|
274
|
+
return true;
|
|
275
|
+
},
|
|
282
276
|
send: (request) => request.kind === "wake"
|
|
283
277
|
? ctx.wake(request.sessionId, request.wake)
|
|
284
278
|
: ctx.sandboxSignal(request.sandboxId, request.signal),
|
|
@@ -335,6 +329,7 @@ export class TenantRuntime {
|
|
|
335
329
|
advance: (sessionId, signal) => advance(ctx, sessionId, signal),
|
|
336
330
|
sweep: () => sweep(ctx),
|
|
337
331
|
sandbox: (sandboxId, trigger) => reconcileSandbox(ctx, sandboxId, trigger),
|
|
332
|
+
fire: (key) => fireTimer(ctx, key),
|
|
338
333
|
};
|
|
339
334
|
const unregister = workers.register(config.tenantId, worker);
|
|
340
335
|
detach = async () => {
|
|
@@ -372,7 +367,7 @@ export class TenantRuntime {
|
|
|
372
367
|
harness: harnessStatusOf(this.ctx),
|
|
373
368
|
};
|
|
374
369
|
}
|
|
375
|
-
drain(activeWork, timeoutMs =
|
|
370
|
+
drain(activeWork, timeoutMs = hostTuning().tenant.drainTimeoutMs) {
|
|
376
371
|
return drain(this.ctx, activeWork, timeoutMs);
|
|
377
372
|
}
|
|
378
373
|
/**
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import { historyCursor, historyResume } from "../reads/cursor.js";
|
|
22
22
|
import { decodeCursor, encodeCursor } from "../record/index.js";
|
|
23
23
|
import { sleep } from "../retry.js";
|
|
24
|
+
import { hostTuning } from "../tuning.js";
|
|
24
25
|
import { basinOf } from "../streams/basin.js";
|
|
25
26
|
import { sessionStream, } from "../streams/types.js";
|
|
26
27
|
import { fail } from "./http.js";
|
|
@@ -33,8 +34,6 @@ export function streamHolderOf(scope) {
|
|
|
33
34
|
export function createSessionStreams() {
|
|
34
35
|
return { wiring: undefined, generation: 0, sessions: new Map() };
|
|
35
36
|
}
|
|
36
|
-
const RETRY_MIN_MS = 100;
|
|
37
|
-
const RETRY_MAX_MS = 2000;
|
|
38
37
|
function frame(event) {
|
|
39
38
|
return `id: ${event.cursor}\nevent: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`;
|
|
40
39
|
}
|
|
@@ -66,7 +65,7 @@ export function openSse(request, response, onClose) {
|
|
|
66
65
|
"x-accel-buffering": "no",
|
|
67
66
|
});
|
|
68
67
|
response.flushHeaders();
|
|
69
|
-
const timer = setInterval(() => send(response, ": keepalive\n\n"),
|
|
68
|
+
const timer = setInterval(() => send(response, ": keepalive\n\n"), hostTuning().api.eventStreamKeepaliveMs);
|
|
70
69
|
timer.unref();
|
|
71
70
|
request.on("close", () => {
|
|
72
71
|
clearInterval(timer);
|
|
@@ -313,7 +312,9 @@ function runFeed(ctx, feed) {
|
|
|
313
312
|
const read = feed.read;
|
|
314
313
|
const signal = read.signal;
|
|
315
314
|
void (async () => {
|
|
316
|
-
|
|
315
|
+
// A failed read is retried after `streams.retry` (Host tuning), doubling.
|
|
316
|
+
const { minMs: retryMinMs, maxMs: retryMaxMs } = hostTuning().streams.retry;
|
|
317
|
+
let delay = retryMinMs;
|
|
317
318
|
while (!signal.aborted) {
|
|
318
319
|
const streams = ctx.sessionStreams.wiring?.streams;
|
|
319
320
|
if (!streams)
|
|
@@ -326,7 +327,7 @@ function runFeed(ctx, feed) {
|
|
|
326
327
|
if (record.seq < feed.next)
|
|
327
328
|
continue;
|
|
328
329
|
feed.next = record.seq + 1;
|
|
329
|
-
delay =
|
|
330
|
+
delay = retryMinMs;
|
|
330
331
|
for (const observer of feed.observers)
|
|
331
332
|
deliver(observer, record);
|
|
332
333
|
}
|
|
@@ -345,7 +346,7 @@ function runFeed(ctx, feed) {
|
|
|
345
346
|
if (!(await stillCurrent(ctx, feed)))
|
|
346
347
|
break;
|
|
347
348
|
await sleep(delay, signal);
|
|
348
|
-
delay = Math.min(delay * 2,
|
|
349
|
+
delay = Math.min(delay * 2, retryMaxMs);
|
|
349
350
|
}
|
|
350
351
|
if (signal.aborted || feed.read !== read)
|
|
351
352
|
return;
|
package/dist/tenant/session.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { AgentManifest } from "@nylorun/core/define";
|
|
10
10
|
import type { TurnManifestStore } from "../core/turn-manifest.js";
|
|
11
11
|
import type { Session } from "./context.js";
|
|
12
|
-
export { manifestFor
|
|
12
|
+
export { manifestFor } from "../mcp/snapshot.js";
|
|
13
13
|
/** Turn-manifest store backed by the session's `variants` map (no schema change). */
|
|
14
14
|
export declare function variantStore(session: Session): TurnManifestStore;
|
|
15
15
|
/** Manifest this turn's checkpoint is pinned to (session pin or a stored variant). */
|
package/dist/tenant/session.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Session resources: `PUT /v1/sessions/:id` (create, or find an identical one), the session list
|
|
3
|
+
* and the session view. A session runs on one Agent (protocol 16) and pins the manifest version
|
|
4
|
+
* the Agent runs when it opens; each turn takes the version the Agent runs then
|
|
5
|
+
* (`agent-versions.ts`). Reads use the store's typed queries; `PUT /v1/sessions/:id` runs in
|
|
6
|
+
* one transaction with the Agent's checks.
|
|
5
7
|
*/
|
|
6
|
-
import { type
|
|
8
|
+
import { type PutSessionRequest } from "@nylorun/core/contracts";
|
|
7
9
|
import type { Tx } from "../store/types.js";
|
|
8
10
|
import { type Session, type SessionAccess, type TenantContext } from "./context.js";
|
|
9
|
-
export declare function listDefinitions(ctx: TenantContext): Promise<{
|
|
10
|
-
agents: {
|
|
11
|
-
agentId: any;
|
|
12
|
-
manifest: any;
|
|
13
|
-
manifestHash: string;
|
|
14
|
-
implementationVersion: string;
|
|
15
|
-
}[];
|
|
16
|
-
}>;
|
|
17
|
-
/**
|
|
18
|
-
* The agents a token caller may see: id, name and description only, never
|
|
19
|
-
* instructions, tools or MCP servers, and only the agents allowed.
|
|
20
|
-
*/
|
|
21
|
-
export declare function listAgentsPublic(ctx: TenantContext, agents: ReadonlySet<string> | "*"): Promise<{
|
|
22
|
-
agents: {
|
|
23
|
-
agentId: string;
|
|
24
|
-
name?: any;
|
|
25
|
-
description?: any;
|
|
26
|
-
}[];
|
|
27
|
-
}>;
|
|
28
|
-
export declare function putDefinition(ctx: TenantContext, agentId: string, body: PutAgentRequest, options?: {
|
|
29
|
-
/** Run every check and save nothing (`?dryRun=true`, protocol 14). */
|
|
30
|
-
dryRun?: boolean;
|
|
31
|
-
}): Promise<{
|
|
32
|
-
agentId: string;
|
|
33
|
-
manifestHash: string;
|
|
34
|
-
implementationVersion: string;
|
|
35
|
-
dryRun?: boolean | undefined;
|
|
36
|
-
}>;
|
|
37
11
|
/**
|
|
38
|
-
* `access`, when the request acts for a person, limits the list to that person's sessions
|
|
39
|
-
* the
|
|
12
|
+
* `access`, when the request acts for a person, limits the list to that person's sessions on
|
|
13
|
+
* the Agents they may use.
|
|
40
14
|
*/
|
|
41
15
|
export declare function listSessions(ctx: TenantContext, agentId: string | null, access?: SessionAccess): Promise<{
|
|
42
16
|
sessions: {
|
|
@@ -48,26 +22,35 @@ export declare function listSessions(ctx: TenantContext, agentId: string | null,
|
|
|
48
22
|
}[];
|
|
49
23
|
}>;
|
|
50
24
|
/**
|
|
51
|
-
* Create a session
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* another owner.
|
|
25
|
+
* Create a session on an Agent, or find an identical one. `access`, when the request acts for a
|
|
26
|
+
* subject, must be the session's owner: another owner's session id is the 404 of a missing one
|
|
27
|
+
* (not the 409 of a mismatch), and so is an Agent whose owner guard names another owner.
|
|
55
28
|
*
|
|
56
|
-
* The session
|
|
57
|
-
* the session's, with the spec of the
|
|
58
|
-
*
|
|
29
|
+
* The session runs on its Agent for its life: the Agent's sandbox (kinds `virtual` and `pod`) is
|
|
30
|
+
* the session's, with the spec of what the Agent runs pinned now, and the Agent's vault holds the
|
|
31
|
+
* session's credentials. It pins the manifest version the Agent runs (`definition`), as the loop
|
|
32
|
+
* manifest that version's harness section makes, and the harness that section names (`pinOf`);
|
|
33
|
+
* a turn's first segment pins the version the Agent runs then (`repinTurn`).
|
|
59
34
|
*/
|
|
60
35
|
export declare function putSession(ctx: TenantContext, id: string, body: PutSessionRequest, access?: SessionAccess, options?: {
|
|
61
36
|
/**
|
|
62
37
|
* Create the session if it is missing and otherwise leave it as it is (an AG-UI thread's
|
|
63
|
-
* session): an existing one must have the same owner and
|
|
38
|
+
* session): an existing one must have the same owner and Agent, or it is a 404.
|
|
64
39
|
*/
|
|
65
40
|
createOnly?: boolean;
|
|
66
41
|
/**
|
|
67
|
-
* The
|
|
68
|
-
*
|
|
42
|
+
* The Agents the caller reaches (a token caller's grants, `agentGrantsOf`); undefined
|
|
43
|
+
* reaches every one. `agent` must name one of them.
|
|
69
44
|
*/
|
|
70
|
-
|
|
45
|
+
agentGrants?: readonly string[];
|
|
46
|
+
}): Promise<Session>;
|
|
47
|
+
/**
|
|
48
|
+
* `putSession`'s work in transaction `t`: also how a trigger's first run opens the session it
|
|
49
|
+
* names (track T4), in the run's transaction.
|
|
50
|
+
*/
|
|
51
|
+
export declare function openSessionIn(ctx: TenantContext, t: Tx, id: string, body: PutSessionRequest, access?: SessionAccess, options?: {
|
|
52
|
+
createOnly?: boolean;
|
|
53
|
+
agentGrants?: readonly string[];
|
|
71
54
|
}): Promise<Session>;
|
|
72
55
|
/** The session resource returned by `GET`/`PUT /v1/sessions/:id`. */
|
|
73
56
|
export declare function sessionView(t: Tx, s: Session): Promise<unknown>;
|