@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
|
@@ -54,7 +54,6 @@ export const tenant = nylorun.table("tenant", {
|
|
|
54
54
|
/** Earlier generations whose basins are still to be deleted. */
|
|
55
55
|
retiredGenerations: integer().array().notNull().default(sql `'{}'`),
|
|
56
56
|
}, () => [check("tenant_singleton_check", sql `singleton`)]);
|
|
57
|
-
export const definitions = documents("definitions");
|
|
58
57
|
const xid8 = customType({ dataType: () => "xid8" });
|
|
59
58
|
export const sessions = nylorun.table("sessions", {
|
|
60
59
|
id: textC().primaryKey(),
|
|
@@ -69,14 +68,17 @@ export const sessions = nylorun.table("sessions", {
|
|
|
69
68
|
ownerExpiresAt: timestamp({ withTimezone: true, mode: "date" }),
|
|
70
69
|
/** The session owner (`ownerUserId`), not the lease column `owner`. */
|
|
71
70
|
ownerUserId: field("->>'ownerUserId'"),
|
|
72
|
-
/** The
|
|
71
|
+
/** The Agent's environment the session runs on: its Agent's id (protocol 16). */
|
|
73
72
|
environmentId: field("->>'environmentId'"),
|
|
73
|
+
/** The agent manifest the session pinned a version of (protocol 16). */
|
|
74
|
+
manifestName: field("->'definition'->>'name'"),
|
|
74
75
|
}, (t) => [
|
|
75
76
|
index("sessions_created").on(t.createdAt.desc().nullsLast(), t.id.desc().nullsFirst()),
|
|
76
77
|
index("sessions_status").on(t.status, t.ownerExpiresAt),
|
|
77
78
|
index("sessions_agent").on(t.agentId),
|
|
78
79
|
index("sessions_owner_user").on(t.ownerUserId),
|
|
79
80
|
index("sessions_environment").on(t.environmentId),
|
|
81
|
+
index("sessions_manifest").on(t.manifestName),
|
|
80
82
|
]);
|
|
81
83
|
export const commands = documents("commands");
|
|
82
84
|
export const effects = nylorun.table("effects", {
|
|
@@ -108,13 +110,15 @@ export const principals = nylorun.table("principals", {
|
|
|
108
110
|
createdAt: text().notNull(),
|
|
109
111
|
});
|
|
110
112
|
/**
|
|
111
|
-
* An
|
|
112
|
-
*
|
|
113
|
+
* An Agent (protocol 16; an Environment from protocol 11): the live instance of one version of an
|
|
114
|
+
* agent manifest, with its id, kind, labels, the recipe its environment runs (its manifest
|
|
115
|
+
* version's runtime section resolved, `recipe`, and what the current compute runs, `applied`),
|
|
113
116
|
* the owner guard, and when it was last used. Kind `pod` adds the pod's lifecycle columns.
|
|
114
|
-
* Sessions name it by id (the session body's `environmentId`
|
|
115
|
-
* table, which holds the virtual backend's compute records, keyed by
|
|
117
|
+
* Sessions name it by id (the session body's `agentId`, and `environmentId` for its environment).
|
|
118
|
+
* Not the `sandboxes` document table, which holds the virtual backend's compute records, keyed by
|
|
119
|
+
* workspace key.
|
|
116
120
|
*/
|
|
117
|
-
export const
|
|
121
|
+
export const agents = nylorun.table("agents", {
|
|
118
122
|
id: textC().primaryKey(),
|
|
119
123
|
kind: text({ enum: ["virtual", "pod", "none"] }).notNull(),
|
|
120
124
|
/** `{ key: value }`, filtered through `nylorun.doc(labels)`. */
|
|
@@ -179,34 +183,150 @@ export const environments = nylorun.table("environments", {
|
|
|
179
183
|
*/
|
|
180
184
|
diskSeed: jsonText(),
|
|
181
185
|
/**
|
|
182
|
-
* The
|
|
183
|
-
*
|
|
186
|
+
* The agent manifest it was made from and the version of it that it runs (track T3 moves it:
|
|
187
|
+
* `PUT /v1/agents/{id}`, and a save of the manifest for a tracking one).
|
|
184
188
|
*/
|
|
185
|
-
manifestName: textC(),
|
|
186
|
-
manifestVersion: integer(),
|
|
187
|
-
/**
|
|
188
|
-
|
|
189
|
-
/** The
|
|
189
|
+
manifestName: textC().notNull(),
|
|
190
|
+
manifestVersion: integer().notNull(),
|
|
191
|
+
/** How it names the manifest: `tracking` (`name`) or `pinned` (`name@n`). */
|
|
192
|
+
manifestRef: text({ enum: ["tracking", "pinned"] }).notNull(),
|
|
193
|
+
/** The hash of the manifest version it runs. */
|
|
194
|
+
manifestHash: textC().notNull(),
|
|
195
|
+
/** `on`, or `off` once paused (track T6); nothing sets `off` yet. */
|
|
196
|
+
desiredState: text({ enum: ["on", "off"] }).notNull().default("on"),
|
|
197
|
+
/** The Agent it was forked from: `{ agent, disk }` (Q15). Never changed. */
|
|
190
198
|
forkedFrom: jsonText(),
|
|
199
|
+
/**
|
|
200
|
+
* The manifest version it is moving to while it is outdated (track T3, D73): it waits for its
|
|
201
|
+
* required secrets, or for its pod's next start. `manifestVersion` stays the one it runs.
|
|
202
|
+
*/
|
|
203
|
+
targetVersion: integer(),
|
|
204
|
+
/** A version that failed to start (T3): a tracking Agent does not move to it again on its own. */
|
|
205
|
+
failedVersion: integer(),
|
|
206
|
+
/**
|
|
207
|
+
* While a pod starts on a new version (T3): `{ from, startedAt }`, what it ran before, which a
|
|
208
|
+
* failed start reverts to. Cleared when the new pod's harness joins.
|
|
209
|
+
*/
|
|
210
|
+
startCheck: jsonText(),
|
|
191
211
|
}, (t) => [
|
|
192
|
-
check("
|
|
193
|
-
index("
|
|
212
|
+
check("agents_kind_check", sql `${t.kind} IN ('virtual', 'pod', 'none')`),
|
|
213
|
+
index("agents_manifest").on(t.manifestName, t.manifestVersion),
|
|
194
214
|
]);
|
|
195
215
|
/**
|
|
196
|
-
* An
|
|
197
|
-
*
|
|
198
|
-
*
|
|
216
|
+
* An Agent's triggers (track T4, D74): what its manifest's `runtime.triggers` declares is the
|
|
217
|
+
* manifest's; whether each one is on and when it fires next is the Agent's, here. A booked wake
|
|
218
|
+
* (D77) is a row of kind `wake` with id `wake:<sessionId>`. Postgres holds the truth: one
|
|
219
|
+
* durable timer per active trigger is armed from `nextFireAt`, and the sweep re-arms an overdue
|
|
220
|
+
* one, so the execution's timers can be rebuilt from these rows.
|
|
199
221
|
*/
|
|
200
|
-
export const
|
|
222
|
+
export const agentTriggers = nylorun.table("agent_triggers", {
|
|
223
|
+
agentId: textC().notNull(),
|
|
224
|
+
triggerId: textC().notNull(),
|
|
225
|
+
kind: text({ enum: ["schedule", "at", "webhook", "wake"] }).notNull(),
|
|
226
|
+
status: text({ enum: ["active", "paused", "completed"] }).notNull(),
|
|
227
|
+
/** `manual`, or `new` for a trigger an upgrade added. */
|
|
228
|
+
pausedReason: text(),
|
|
229
|
+
/** Bumped when its timing changes, so a timer armed for an older time does nothing. */
|
|
230
|
+
generation: integer().notNull().default(0),
|
|
231
|
+
/** When it fires next (ISO), while active; a schedule's includes its jitter. */
|
|
232
|
+
nextFireAt: textC(),
|
|
233
|
+
lastFireAt: textC(),
|
|
234
|
+
/** A webhook trigger's endpoint id (`wh_…`), kept across upgrades. */
|
|
235
|
+
endpointId: textC(),
|
|
236
|
+
/**
|
|
237
|
+
* A webhook trigger's signing secret, sealed with the Tenant's vault key: only the keys service
|
|
238
|
+
* opens it, to verify a delivery (D75).
|
|
239
|
+
*/
|
|
240
|
+
sealedSecret: jsonText(),
|
|
241
|
+
/** A booked wake's session, its note and the effect that booked it. */
|
|
242
|
+
sessionId: textC(),
|
|
243
|
+
note: text(),
|
|
244
|
+
effectId: text(),
|
|
245
|
+
createdAt: textC().notNull(),
|
|
246
|
+
updatedAt: textC().notNull(),
|
|
247
|
+
}, (t) => [
|
|
248
|
+
primaryKey({ name: "agent_triggers_pkey", columns: [t.agentId, t.triggerId] }),
|
|
249
|
+
index("agent_triggers_due").on(t.status, t.nextFireAt),
|
|
250
|
+
uniqueIndex("agent_triggers_endpoint").on(t.endpointId).where(sql `endpoint_id IS NOT NULL`),
|
|
251
|
+
]);
|
|
252
|
+
/**
|
|
253
|
+
* An Agent's memories (track T5, D72): one row per Markdown file under `/memories`, its content
|
|
254
|
+
* inline (the Runtime limit `memoryBytes`, 100 KB by default, bounds it). `version` counts the
|
|
255
|
+
* changes to this path; `description` is its frontmatter's, for the pinned index. A write locks the
|
|
256
|
+
* one row it changes, so writes to different memories never wait on each other.
|
|
257
|
+
*/
|
|
258
|
+
export const memories = nylorun.table("memories", {
|
|
259
|
+
agentId: textC().notNull(),
|
|
260
|
+
path: textC().notNull(),
|
|
261
|
+
content: text().notNull(),
|
|
262
|
+
contentSha256: text().notNull(),
|
|
263
|
+
bytes: integer().notNull(),
|
|
264
|
+
description: text(),
|
|
265
|
+
version: integer().notNull(),
|
|
266
|
+
updatedAt: textC().notNull(),
|
|
267
|
+
}, (t) => [primaryKey({ name: "memories_pkey", columns: [t.agentId, t.path] })]);
|
|
268
|
+
/**
|
|
269
|
+
* One row per change to an Agent's memories (D72): what changed it, the content it left (`null`
|
|
270
|
+
* for a delete), and who made it, with the session, turn and trigger run of a turn's write.
|
|
271
|
+
* Versions belong to the Agent, so they outlive a deleted memory; they go with the Agent. Ids
|
|
272
|
+
* increase with time (`newMemoryVersionId`), so they page newest first.
|
|
273
|
+
*/
|
|
274
|
+
export const memoryVersions = nylorun.table("memory_versions", {
|
|
275
|
+
id: textC().primaryKey(),
|
|
276
|
+
agentId: textC().notNull(),
|
|
277
|
+
path: textC().notNull(),
|
|
278
|
+
/** A rename's old path. */
|
|
279
|
+
fromPath: textC(),
|
|
280
|
+
operation: text({ enum: ["create", "str_replace", "insert", "delete", "rename"] }).notNull(),
|
|
281
|
+
content: text(),
|
|
282
|
+
contentSha256: text(),
|
|
283
|
+
bytes: integer(),
|
|
284
|
+
actor: text().notNull(),
|
|
285
|
+
sessionId: textC(),
|
|
286
|
+
turnId: textC(),
|
|
287
|
+
triggerRunId: textC(),
|
|
288
|
+
createdAt: textC().notNull(),
|
|
289
|
+
}, (t) => [index("memory_versions_agent").on(t.agentId, t.id), index("memory_versions_path").on(t.agentId, t.path, t.id)]);
|
|
290
|
+
/**
|
|
291
|
+
* Each run of an Agent's triggers (D74): one per fire, delivery or run by hand, keyed by what
|
|
292
|
+
* caused it (`runKey`: `fire:<trigger>:<due ms>`, `webhook:<trigger>:<delivery id>`,
|
|
293
|
+
* `manual:<trigger>:<idempotency key>`), so a repeated cause makes no second run. Kept for the
|
|
294
|
+
* Runtime limit `triggerRunRetentionMs`.
|
|
295
|
+
*/
|
|
296
|
+
export const triggerRuns = nylorun.table("trigger_runs", {
|
|
297
|
+
id: textC().primaryKey(),
|
|
298
|
+
agentId: textC().notNull(),
|
|
299
|
+
triggerId: textC().notNull(),
|
|
300
|
+
kind: text({ enum: ["schedule", "at", "webhook", "wake"] }).notNull(),
|
|
301
|
+
runKey: textC().notNull(),
|
|
302
|
+
dueAt: textC().notNull(),
|
|
303
|
+
firedAt: textC().notNull(),
|
|
304
|
+
late: boolean().notNull().default(false),
|
|
305
|
+
status: text({ enum: ["started", "queued", "skipped", "failed"] }).notNull(),
|
|
306
|
+
reason: text(),
|
|
307
|
+
sessionId: textC(),
|
|
308
|
+
turnId: textC(),
|
|
309
|
+
queuedMessageId: textC(),
|
|
310
|
+
}, (t) => [
|
|
311
|
+
uniqueIndex("trigger_runs_key").on(t.agentId, t.runKey),
|
|
312
|
+
index("trigger_runs_agent").on(t.agentId, t.id),
|
|
313
|
+
index("trigger_runs_fired").on(t.firedAt),
|
|
314
|
+
]);
|
|
315
|
+
/**
|
|
316
|
+
* An agent manifest's versions (protocol 16): a named, versioned document with a harness and a
|
|
317
|
+
* runtime section. A version is written once and never changed; a save whose body hashes the
|
|
318
|
+
* same as the latest writes nothing.
|
|
319
|
+
*/
|
|
320
|
+
export const agentManifests = nylorun.table("agent_manifests", {
|
|
201
321
|
name: textC().notNull(),
|
|
202
322
|
version: integer().notNull(),
|
|
203
|
-
/** The manifest (`
|
|
323
|
+
/** The manifest (`AgentManifestV8`) as saved. */
|
|
204
324
|
body: jsonText().notNull(),
|
|
205
325
|
hash: textC().notNull(),
|
|
206
326
|
/** `{ actor }`: the subject the save acted for, else `application`. */
|
|
207
327
|
savedBy: jsonText().notNull(),
|
|
208
328
|
createdAt: textC().notNull(),
|
|
209
|
-
}, (t) => [primaryKey({ name: "
|
|
329
|
+
}, (t) => [primaryKey({ name: "agent_manifests_pkey", columns: [t.name, t.version] })]);
|
|
210
330
|
/**
|
|
211
331
|
* A vault (D56): the host model's (`id = 'host'`), or one Environment's, created and deleted with
|
|
212
332
|
* it (`environment_id`, unique, deleted with the Environment's row). No other vault exists.
|
|
@@ -217,14 +337,14 @@ export const vaults = nylorun.table("vaults", {
|
|
|
217
337
|
/** JSON text, or null. */
|
|
218
338
|
metadataJson: text(),
|
|
219
339
|
createdAt: textC().notNull(),
|
|
220
|
-
/** The
|
|
340
|
+
/** The Agent the vault belongs to; null only for the host vault. */
|
|
221
341
|
environmentId: textC(),
|
|
222
342
|
}, (t) => [
|
|
223
343
|
uniqueIndex("vaults_environment").on(t.environmentId),
|
|
224
344
|
foreignKey({
|
|
225
345
|
name: "vaults_environment_id_fkey",
|
|
226
346
|
columns: [t.environmentId],
|
|
227
|
-
foreignColumns: [
|
|
347
|
+
foreignColumns: [agents.id],
|
|
228
348
|
}).onDelete("cascade"),
|
|
229
349
|
check("vaults_owner_check", sql `(${t.id} = 'host') = (${t.environmentId} IS NULL)`),
|
|
230
350
|
]);
|
|
@@ -316,7 +436,11 @@ export const modelUsage = nylorun.table("model_usage", {
|
|
|
316
436
|
txid: xid8().notNull().default(sql `pg_current_xact_id()`),
|
|
317
437
|
sessionId: textC().notNull(),
|
|
318
438
|
turnId: textC().notNull(),
|
|
319
|
-
|
|
439
|
+
/**
|
|
440
|
+
* The agent manifest the call's agent came from: the loop manifest's id, a version's name
|
|
441
|
+
* (protocol 16; the definition id before, under `agent_id`).
|
|
442
|
+
*/
|
|
443
|
+
manifestName: textC().notNull(),
|
|
320
444
|
provider: text(),
|
|
321
445
|
model: text(),
|
|
322
446
|
inputTokens: integer().notNull(),
|
|
@@ -339,23 +463,46 @@ export const modelUsage = nylorun.table("model_usage", {
|
|
|
339
463
|
index("model_usage_session").on(t.sessionId, t.createdAt, t.id),
|
|
340
464
|
index("model_usage_export").on(t.txid, t.id),
|
|
341
465
|
index("model_usage_effect").on(t.effectKey),
|
|
342
|
-
index("
|
|
466
|
+
index("model_usage_manifest").on(t.manifestName, t.createdAt),
|
|
343
467
|
index("model_usage_turn").on(t.turnId),
|
|
344
468
|
index("model_usage_created").on(t.createdAt),
|
|
345
469
|
]);
|
|
346
470
|
/**
|
|
347
471
|
* Model budgets (P1.3): hard caps the model gate checks before each call, at least one limit
|
|
348
|
-
* set. One row per scope: `turn` and `tenant` use `*`, `
|
|
472
|
+
* set. One row per scope: `turn` and `tenant` use `*`, `manifest` the agent manifest's name. `period` is the
|
|
349
473
|
* UTC `day` or `month` the spend is counted over, or null for `turn`.
|
|
350
474
|
*/
|
|
351
475
|
export const modelBudgets = nylorun.table("model_budgets", {
|
|
352
|
-
scope: text({ enum: ["tenant", "
|
|
476
|
+
scope: text({ enum: ["tenant", "manifest", "turn"] }).notNull(),
|
|
353
477
|
scopeId: textC().notNull(),
|
|
354
478
|
period: text({ enum: ["day", "month"] }),
|
|
355
479
|
limitUsd: doublePrecision(),
|
|
356
480
|
limitTokens: bigint({ mode: "number" }),
|
|
357
481
|
updatedAt: text().notNull(),
|
|
358
482
|
}, (t) => [primaryKey({ name: "model_budgets_pkey", columns: [t.scope, t.scopeId] })]);
|
|
483
|
+
/**
|
|
484
|
+
* Each session's queue (protocol 17, D76): messages that arrived while its turn ran or waited, in
|
|
485
|
+
* order (`seq`), until a turn takes them. A row holds the command as sent, the turn input its
|
|
486
|
+
* message gives the engine (file parts pinned when it was queued), and who sent it.
|
|
487
|
+
*/
|
|
488
|
+
export const sessionQueue = nylorun.table("session_queue", {
|
|
489
|
+
id: textC().primaryKey(),
|
|
490
|
+
sessionId: textC().notNull(),
|
|
491
|
+
seq: bigint({ mode: "number" }).notNull(),
|
|
492
|
+
/** The `message` command as sent (`command.message`'s payload when a turn takes it). */
|
|
493
|
+
command: jsonText().notNull(),
|
|
494
|
+
/** The engine's input for it: an agent's message input, or a workflow's input value. */
|
|
495
|
+
input: jsonText().notNull(),
|
|
496
|
+
/** The artifacts its file parts named, which the session may read again. */
|
|
497
|
+
fileArtifacts: jsonText().notNull(),
|
|
498
|
+
/** Who sent it (`EventWriter`). */
|
|
499
|
+
writer: jsonText().notNull(),
|
|
500
|
+
/** The W3C trace context it was sent with. */
|
|
501
|
+
trace: jsonText(),
|
|
502
|
+
/** What sent it when not a client (track T4): a trigger's run, or the session's own wake. */
|
|
503
|
+
cause: jsonText(),
|
|
504
|
+
createdAt: textC().notNull(),
|
|
505
|
+
}, (t) => [uniqueIndex("session_queue_order").on(t.sessionId, t.seq)]);
|
|
359
506
|
/**
|
|
360
507
|
* The Tool Gate's keyed MCP calls (F4.1 G3): one row per call, written by the gates service
|
|
361
508
|
* before it calls the server and given the answer after. A re-send whose row has an answer
|
|
@@ -390,7 +537,7 @@ export const artifacts = nylorun.table("artifacts", {
|
|
|
390
537
|
labelsJson: text(),
|
|
391
538
|
createdAt: textC().notNull(),
|
|
392
539
|
updatedAt: text().notNull(),
|
|
393
|
-
/** The
|
|
540
|
+
/** The Agent whose disk versions this folder holds (R2d step 3); one per Agent. */
|
|
394
541
|
environmentId: textC(),
|
|
395
542
|
}, (t) => [
|
|
396
543
|
index("artifacts_session").on(t.sessionId, t.createdAt, t.id),
|
|
@@ -409,8 +556,15 @@ export const artifactVersions = nylorun.table("artifact_versions", {
|
|
|
409
556
|
contentType: text().notNull(),
|
|
410
557
|
source: text({ enum: ["upload", "engine", "export", "snapshot"] }).notNull(),
|
|
411
558
|
createdAt: textC().notNull(),
|
|
559
|
+
/**
|
|
560
|
+
* The idempotency key of the harness write that stored the version (the artifact seam,
|
|
561
|
+
* protocol 15): the SHA-256 of its session and the harness's key, so a repeated write answers
|
|
562
|
+
* this version. Null for every other write.
|
|
563
|
+
*/
|
|
564
|
+
writeKey: textC(),
|
|
412
565
|
}, (t) => [
|
|
413
566
|
primaryKey({ name: "artifact_versions_pkey", columns: [t.artifactId, t.version] }),
|
|
567
|
+
uniqueIndex("artifact_versions_write_key").on(t.writeKey).where(sql `write_key IS NOT NULL`),
|
|
414
568
|
foreignKey({
|
|
415
569
|
name: "artifact_versions_artifact_id_fkey",
|
|
416
570
|
columns: [t.artifactId],
|
|
@@ -452,9 +606,9 @@ export const definitionFiles = nylorun.table("definition_files", {
|
|
|
452
606
|
createdAt: textC().notNull(),
|
|
453
607
|
});
|
|
454
608
|
/**
|
|
455
|
-
* Which
|
|
456
|
-
* and file, written when the
|
|
457
|
-
*
|
|
609
|
+
* Which agent manifest version names which definition file: one row per owner
|
|
610
|
+
* (`agent-manifest:<name>`), manifest hash and file, written when the version is saved. A later
|
|
611
|
+
* sweep deletes the files no version uses.
|
|
458
612
|
*/
|
|
459
613
|
export const definitionFileUses = nylorun.table("definition_file_uses", {
|
|
460
614
|
agentId: textC().notNull(),
|
|
@@ -534,16 +688,16 @@ export const sandboxSignals = nylorun.table("sandbox_signals", {
|
|
|
534
688
|
// ---------------------------------------------------------------------------
|
|
535
689
|
// nylorun_streams: the record
|
|
536
690
|
/**
|
|
537
|
-
* Each
|
|
538
|
-
*
|
|
691
|
+
* Each Agent's lifecycle stream (`nylorun.agent-event/1`), numbered from 0 per Agent id. Written
|
|
692
|
+
* only by the record module; not published to the stream relay.
|
|
539
693
|
*/
|
|
540
|
-
export const
|
|
541
|
-
|
|
694
|
+
export const agentEvents = nylorunStreams.table("agent_events", {
|
|
695
|
+
agentId: textC().notNull(),
|
|
542
696
|
seq: bigint({ mode: "number" }).notNull(),
|
|
543
697
|
type: text().notNull(),
|
|
544
698
|
body: jsonText().notNull(),
|
|
545
699
|
committedAt: timestamp({ withTimezone: true, mode: "string" }).notNull().defaultNow(),
|
|
546
|
-
}, (t) => [primaryKey({ name: "
|
|
700
|
+
}, (t) => [primaryKey({ name: "agent_events_pkey", columns: [t.agentId, t.seq] })]);
|
|
547
701
|
/** Each session's log head: the next seq and the basin generation its events go to. */
|
|
548
702
|
export const sessionLogHeads = nylorunStreams.table("session_log_heads", {
|
|
549
703
|
sessionId: textC().primaryKey(),
|