@nylorun/runtime 0.27.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.
Files changed (148) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/api/a2a/card.d.ts +4 -3
  3. package/dist/api/a2a/card.js +3 -3
  4. package/dist/api/a2a/routes.js +18 -7
  5. package/dist/api/ag-ui/routes.js +4 -7
  6. package/dist/api/components.d.ts +5823 -2720
  7. package/dist/api/components.js +39 -30
  8. package/dist/api/http/app.js +9 -4
  9. package/dist/api/http/body.d.ts +2 -0
  10. package/dist/api/http/body.js +20 -0
  11. package/dist/api/http/routes/agent-manifests.d.ts +10 -0
  12. package/dist/api/http/routes/agent-manifests.js +135 -0
  13. package/dist/api/http/routes/agents.d.ts +11 -0
  14. package/dist/api/http/routes/agents.js +418 -0
  15. package/dist/api/http/routes/artifacts.js +2 -2
  16. package/dist/api/http/routes/coverage.d.ts +4 -4
  17. package/dist/api/http/routes/coverage.js +12 -6
  18. package/dist/api/http/routes/files.js +1 -1
  19. package/dist/api/http/routes/mcp.js +2 -2
  20. package/dist/api/http/routes/me.d.ts +1 -1
  21. package/dist/api/http/routes/me.js +1 -2
  22. package/dist/api/http/routes/memories.d.ts +9 -0
  23. package/dist/api/http/routes/memories.js +152 -0
  24. package/dist/api/http/routes/reads.d.ts +1 -137
  25. package/dist/api/http/routes/reads.js +2 -8
  26. package/dist/api/http/routes/sessions.js +21 -50
  27. package/dist/api/http/routes/tenant.js +8 -8
  28. package/dist/api/http/routes/triggers.d.ts +10 -0
  29. package/dist/api/http/routes/triggers.js +180 -0
  30. package/dist/api/openapi.js +69 -47
  31. package/dist/artifacts/disk.d.ts +10 -10
  32. package/dist/artifacts/disk.js +27 -27
  33. package/dist/artifacts/quota.d.ts +1 -1
  34. package/dist/artifacts/quota.js +2 -2
  35. package/dist/artifacts/service.js +2 -2
  36. package/dist/core/flow-host.d.ts +0 -1
  37. package/dist/gates/egress-credentials.js +1 -1
  38. package/dist/gates/egress.d.ts +5 -5
  39. package/dist/gates/egress.js +6 -6
  40. package/dist/gates/http-tool.js +1 -1
  41. package/dist/gates/meter.js +6 -5
  42. package/dist/gates/policy.d.ts +8 -3
  43. package/dist/gates/policy.js +7 -2
  44. package/dist/harness/pod.d.ts +2 -0
  45. package/dist/harness/setup.js +17 -6
  46. package/dist/harness-api/record.js +11 -0
  47. package/dist/harness-api/server.js +4 -0
  48. package/dist/harness-api/start.d.ts +11 -7
  49. package/dist/harness-api/start.js +49 -5
  50. package/dist/harness-api/workspace.js +2 -2
  51. package/dist/host/http.d.ts +2 -2
  52. package/dist/host/http.js +5 -2
  53. package/dist/keys/keys.d.ts +15 -4
  54. package/dist/keys/keys.js +16 -0
  55. package/dist/keys/webhooks.d.ts +25 -0
  56. package/dist/keys/webhooks.js +62 -0
  57. package/dist/management-openapi.json +245 -123
  58. package/dist/mcp/preview.js +7 -7
  59. package/dist/memory/service.d.ts +97 -0
  60. package/dist/memory/service.js +335 -0
  61. package/dist/memory/tool.d.ts +36 -0
  62. package/dist/memory/tool.js +84 -0
  63. package/dist/openapi.json +12837 -8790
  64. package/dist/reads/types.d.ts +3 -3
  65. package/dist/record/agent.d.ts +27 -0
  66. package/dist/record/agent.js +46 -0
  67. package/dist/record/index.d.ts +1 -1
  68. package/dist/record/index.js +1 -1
  69. package/dist/sandbox/join.js +5 -5
  70. package/dist/sandbox/placement.d.ts +1 -1
  71. package/dist/sandbox/placement.js +3 -3
  72. package/dist/sandbox/pods/lifecycle.d.ts +6 -6
  73. package/dist/sandbox/pods/lifecycle.js +6 -6
  74. package/dist/sandbox/pods/reconcile.js +10 -2
  75. package/dist/sandbox/resolve.d.ts +3 -3
  76. package/dist/sandbox/resolve.js +7 -7
  77. package/dist/sandbox/setup.d.ts +3 -1
  78. package/dist/sandbox/setup.js +14 -4
  79. package/dist/store/postgres/drizzle/0032_agents.sql +54 -0
  80. package/dist/store/postgres/drizzle/0033_agent_versions.sql +7 -0
  81. package/dist/store/postgres/drizzle/0034_protocol_17_session_queue.sql +13 -0
  82. package/dist/store/postgres/drizzle/0035_t4_triggers.sql +41 -0
  83. package/dist/store/postgres/drizzle/0036_t5_memories.sql +30 -0
  84. package/dist/store/postgres/drizzle/meta/_journal.json +35 -0
  85. package/dist/store/postgres/reads.js +13 -86
  86. package/dist/store/postgres/record-writer.d.ts +4 -4
  87. package/dist/store/postgres/record-writer.js +9 -9
  88. package/dist/store/postgres/schema.d.ts +1373 -161
  89. package/dist/store/postgres/schema.js +184 -37
  90. package/dist/store/postgres/store.js +329 -79
  91. package/dist/store/postgres/tenant.js +1 -2
  92. package/dist/store/types.d.ts +155 -50
  93. package/dist/store/types.js +0 -1
  94. package/dist/tenant/advance.js +20 -8
  95. package/dist/tenant/agent-manifests.d.ts +72 -0
  96. package/dist/tenant/agent-manifests.js +359 -0
  97. package/dist/tenant/agent-versions.d.ts +126 -0
  98. package/dist/tenant/agent-versions.js +389 -0
  99. package/dist/tenant/agents.d.ts +230 -0
  100. package/dist/tenant/{environments.js → agents.js} +464 -320
  101. package/dist/tenant/auth.d.ts +1 -1
  102. package/dist/tenant/auth.js +3 -3
  103. package/dist/tenant/commands.d.ts +63 -2
  104. package/dist/tenant/commands.js +240 -83
  105. package/dist/tenant/context.d.ts +46 -19
  106. package/dist/tenant/context.js +6 -2
  107. package/dist/tenant/effects.js +7 -16
  108. package/dist/tenant/identity-file.d.ts +6 -6
  109. package/dist/tenant/identity-file.js +12 -10
  110. package/dist/tenant/issuers.js +3 -3
  111. package/dist/tenant/limits.d.ts +0 -3
  112. package/dist/tenant/limits.js +0 -3
  113. package/dist/tenant/memories.d.ts +38 -0
  114. package/dist/tenant/memories.js +119 -0
  115. package/dist/tenant/reset.js +2 -2
  116. package/dist/tenant/run-grants.d.ts +6 -0
  117. package/dist/tenant/run-grants.js +4 -0
  118. package/dist/tenant/runtime.d.ts +1 -1
  119. package/dist/tenant/runtime.js +8 -0
  120. package/dist/tenant/sessions.d.ts +28 -45
  121. package/dist/tenant/sessions.js +85 -208
  122. package/dist/tenant/status.js +6 -7
  123. package/dist/tenant/sweep.js +12 -3
  124. package/dist/tenant/transcript.d.ts +16 -16
  125. package/dist/tenant/triggers.d.ts +143 -0
  126. package/dist/tenant/triggers.js +715 -0
  127. package/dist/tenant/turn-timing.d.ts +11 -1
  128. package/dist/tenant/turn-timing.js +3 -1
  129. package/dist/tenant/worker.d.ts +2 -0
  130. package/dist/tenant/worker.js +5 -0
  131. package/dist/traces/map.d.ts +1 -1
  132. package/dist/traces/map.js +7 -1
  133. package/dist/tuning.d.ts +7 -0
  134. package/dist/tuning.js +19 -0
  135. package/dist/vault/service.d.ts +13 -8
  136. package/dist/vault/service.js +61 -17
  137. package/dist/version.d.ts +1 -1
  138. package/dist/version.js +1 -1
  139. package/package.json +13 -12
  140. package/dist/api/http/routes/environment-manifests.d.ts +0 -9
  141. package/dist/api/http/routes/environment-manifests.js +0 -118
  142. package/dist/api/http/routes/environments.d.ts +0 -11
  143. package/dist/api/http/routes/environments.js +0 -332
  144. package/dist/record/environment.d.ts +0 -27
  145. package/dist/record/environment.js +0 -46
  146. package/dist/tenant/environment-manifests.d.ts +0 -57
  147. package/dist/tenant/environment-manifests.js +0 -208
  148. package/dist/tenant/environments.d.ts +0 -172
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.28.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 22c61ce: Protocol 16, Agents from one manifest (track T2), a fresh start. An agent manifest (v8) is one versioned document at `/v1/agent-manifests/{name}` with a `harness` section (what runs inside the loop, including the harness's id) and a `runtime` section (what an environment manifest said). The Runtime checks the two against each other when it is saved (`422 manifest_inconsistent` with `details.gaps`), in place of `requires` at session open. Agent definitions and environment manifests are gone.
8
+
9
+ Environments are Agents: `/v1/agents/{id}` and its sub-routes, made from a saved manifest only (`manifest: "name"` tracks it, `"name@n"` pins a version; either resolves once, into `resolvedVersion`), with a derived `state` (`working`, `sleeping`, `input_required`, `failing`, `paused`) and `attention`. Every session runs on one Agent (`PUT /v1/sessions/{id} { agent, ownerUserId }`) and pins its manifest version. No session is special (D71). Error codes, events (`agent.*`), scopes (`agents:write`, `agent-manifests:write`) and identity-file grants (`agents`) say Agent; model budget scope `agent` is `manifest`. Harness API 5: `turn.start.agent` replaces `turn.start.environment`, with `definition` and `loop`. Migration 0032 closes older sessions (`protocol_16`) and drops Environments with their disks and vaults.
10
+
11
+ The SDK has `client.agentManifests`, `client.agents` and `composeManifest(dir)` for three-file authoring; the CLI has `nylorun apply`, `nylorun agent-manifests`, `nylorun agents` and `nylorun migrate v8`; Studio has an Agents screen, an Agent page and an Agent manifests screen. See MIGRATION.md.
12
+
13
+ - 1ded443: Track T3, Agents that evolve: an Agent moves between versions of its manifest in place, with its id, disk, vault and sessions. `PUT /v1/agents/{id}` with another version moves it (`?dryRun=true` answers the plan, `AgentMovePlan`), and saving a manifest moves every Agent that tracks it. A harness-only change applies at once; a runtime change a pod applies only when it starts (image, resources, network, setup, files) leaves the Agent outdated (`targetVersion`, `waitingFor: "start"`) until its pod's next start, on the same volume; a version that adds a required secret waits for its value (`waitingFor: "secrets"`, state `input_required`). Its manifest's name, kind, harness and storage are fixed: `409 agent_fixed_field` replaces `409 agent_upgrade_unavailable`. Only secrets that fill a slot of the running version are used; others stay in the vault, dormant. New events `agent.outdated` and `agent.version_changed`, `GET /v1/agents?outdated=true`, and the save plan's `moves` and `agents_move` warning. Migration 0033 adds the Agent's target and failed versions and its start check.
14
+ - 76dcd11: Track T3, the next start and its check: a pod Agent's start on a new version is checked until the new pod's harness joins (`startCheck` on the Agent). A failed setup, a failed pod, or a start slower than the Host's `tenant.upgradeStartMs` (10 minutes) takes the Agent back to the version it ran, its definition and not its disk, records `agent.start_failed`, and names the version `failedVersion` (state `failing`), which a tracking Agent does not move to again. A new version's setup runs on the same volume when its commands or files changed (`setupHash` in the setup plan and the volume's marker). While a pod waits to start on a new version it idles at most `tenant.upgradeIdleMs` (1 minute). `POST /v1/agents/{id}/restart` applies a pending version now; `retry: true` tries the failed version again.
15
+ - 4fa160d: Agent memory, storage and API (track T5, D72). An agent manifest's `harness.memory` (`access`: `read_write` or `read_only`; `instructions`, at most 4,096 characters) turns on the Agent's memory: Markdown files under `/memories` it keeps across sessions, wakes and upgrades. The Runtime keeps them in Postgres (`memories`, `memory_versions`, migration 0036) with a version per change and who made it. `GET /v1/agents/{id}/memories` lists them (`pathPrefix`), `GET`, `PUT` (whole content, with an optional `contentSha256` precondition: `409 memory_conflict`) and `DELETE /v1/agents/{id}/memories/{path}` read, write and delete one (or a folder), and `GET /v1/agents/{id}/memory_versions` and `.../memory_versions/{versionId}` page the versions. A fork copies the memories (the fork plan adds `memories`); a delete removes them. `@nylorun/core` adds `memoryPathOf`, `memoryDescriptionOf` and the memory contracts; new Runtime limits `memoryBytes` (100 KB) and `memoriesPerAgent` (10,000); new error code `memory_conflict`. The SDK adds `client.agents.memories`; the CLI adds `nylorun agents memories ls|cat|put|rm|versions`. The model's `memory` tool arrives in the next steps of T5.
16
+ - 9fed948: The `memory` tool's calls (track T5, D72). A new effect target, `{kind: "runtime", operation: "memory"}` (additive on Harness API 5), carries Anthropic's memory tool input (`command`: `view`, `create`, `str_replace`, `insert`, `delete`, `rename`, and its parameters); core serves it in the intent's own transaction, so a replayed turn applies a write once. A malformed call fails with text for the model and changes nothing; a write from a `read_only` agent or a sub-agent is `memory.forbidden`. Each write is a memory version naming the turn's manifest version, session, turn and the trigger run that started the turn, with a new session event `memory.updated` and Agent event `agent.memory_updated`. `turn.start.memory` (`TurnMemorySchema`) carries the Agent's memory access, instructions and the index a harness pins, newest first, within the new Runtime limits `memoryIndexLines` (200) and `memoryIndexBytes` (25 KiB).
17
+ - ffeb3bb: `schedule_wake` (track T4, D77). An agent manifest's `runtime.selfWake: true` offers the agent `schedule_wake`: `{in | at, note}` books its session's next turn, replacing the booking before, and `{cancel: true}` removes it. The Runtime serves the call in its own transaction (a new effect target, `{kind: "runtime", operation: "schedule_wake"}`, additive on Harness API 5; `turn.start.agent.selfWake` tells a harness to offer it), so a replayed turn books once. The booking fires as a trigger run of kind `wake`, its note the turn's message with `cause.kind: "self"`. New session events `wake.booked` and `wake.cancelled`, tool call kind `runtime`, and Runtime limits `wakeMaxAheadMs` and `wakeNoteChars`.
18
+ - 9e60e40: Protocol 17, a queue per session (track T4, D76). A message sent while the session's turn runs or waits is queued (`{status: "queued", queuedMessageId, position}`, `message.queued`) and starts the next turn when this one ends, with every queued message, each its own user message (`queue.taken`); a cancel ends the turn, not the queue. `delivery: "reject"` keeps the refusal, now `409 session_busy`, and a protocol 16 client's messages default to it, so the Host serves protocol 16 and 17. The queue holds at most the Runtime limit `sessionQueuedMessages` (`429 queue_full`), and session reads count `queuedMessages`. Our engine takes `{kind: "messages", messages}` as a turn's input. The SDK's `input` and `inputParts` take `delivery`, and the CLI's `sessions send` takes `--reject-if-busy`. See MIGRATION.md.
19
+ - f85483d: Triggers (track T4, D74). An agent manifest's `runtime.triggers` declares `schedule` (cron with an IANA `timezone`) and `at` triggers, each with the session its runs go to (a session id, opened on the first run, or `new` for a session per run) and its prompt. They start active with a new Agent, fire on a durable timer per trigger with Postgres as the truth (one late fire after downtime, never a backfill, a fixed jitter per trigger), and each fire is a run (`started`, `queued`, `skipped` or `failed`, with a reason) at `GET /v1/agents/{id}/runs`. A schedule adds at most one queued message to a busy session. `GET /v1/agents/{id}/triggers` and `POST .../triggers/{triggerId}/pause`, `/resume` and `/run` (with an `Idempotency-Key`); Agent reads add `nextWakeAt`, and the Agent's stream adds `agent.run`, `agent.trigger_paused` and `agent.trigger_resumed`. New Runtime limits: `triggersPerAgent`, `triggerMinIntervalMs` and `triggerRunRetentionMs` (with floors), `triggerRunsPerHour`, `triggerJitterPercent`, `triggerJitterMaxMs`, `triggerPromptChars`; Host tuning `triggers.lateGraceMs` and `triggers.intervalCheckFires`. The SDK's `client.agents` adds `triggers`, `pauseTrigger`, `resumeTrigger`, `runTrigger` and `runs`; the CLI adds `nylorun agents triggers` and `nylorun agents runs`.
20
+ - 3a575d7: Track T3, versions per turn: a turn's first segment takes the manifest version its session's Agent runs then, so a session moves with its Agent between turns and keeps one version through every segment, approval and rollover of a turn. A turn whose message named a variant, and a flow's sessions, keep the version they pinned; a changed loop manifest drops the session's MCP snapshot. The turn span names the version (`nylorun.manifest.version`). Our engine takes a new version's output schema at the next turn.
21
+ - ae54de7: Webhook triggers (track T4, D75). A `webhook: "standard-webhooks"` trigger has an endpoint, `POST /v1/webhooks/{endpointId}`, an anonymous, unversioned route that takes any body up to the new Runtime limit `webhookBodyBytes` and verifies Standard Webhooks (`webhook-id`, `webhook-timestamp` within the Host's `triggers.webhookToleranceMs`, `webhook-signature`) in the keys service, which alone opens the trigger's sealed secret; anything else is `401` and writes nothing. A delivery runs the trigger once per `webhook-id` (`202 {runId, status}`); a paused trigger answers a signed one `409 trigger_paused`. `POST /v1/agents/{id}/triggers/{triggerId}/secret` makes or replaces the `whsec_` secret, shown once (`agent.trigger_secret_rotated`); trigger reads show `webhookUrl` and `secretSet`. The payload reaches the model under the trigger's prompt in a labelled `<trigger-payload>` block. The SDK adds `agents.rotateWebhookSecret`, and the CLI `nylorun agents triggers new-secret`.
22
+
23
+ ### Patch Changes
24
+
25
+ - bf942ed: Our engine offers the `memory` tool (track T5, D72). An agent whose version sets `harness.memory` gets one `memory` tool with Anthropic's memory tool schema (`view`, `create`, `str_replace`, `insert`, `delete`, `rename`; `view` only for a `read_only` agent and an agent used as a tool), our memory rules followed by the agent's `instructions`, and its memory index pinned after the instructions as user-role context: kept for the session so the prompt prefix stays cacheable (`ExecutionState.pinned`), and re-pinned after a compaction. Each command's parameters are checked before a call is sent (`checkMemoryCall` in `@nylorun/core/contracts`, which the Runtime also uses), and a call named `memory.<command>` or `memory/<command>` runs as `memory` with that command (`memoryAliasOf`). `ModelRequest.pinned` carries the pinned text; `memoryTool` and `memoryIndexBlock` are exported for your own harness.
26
+ - Pin core to the tested release.
27
+ - Pin harness to the tested release.
28
+ - Updated dependencies [218b078]
29
+ - Updated dependencies [22c61ce]
30
+ - Updated dependencies [1ded443]
31
+ - Updated dependencies [76dcd11]
32
+ - Updated dependencies [bf942ed]
33
+ - Updated dependencies [4fa160d]
34
+ - Updated dependencies [9fed948]
35
+ - Updated dependencies [ffeb3bb]
36
+ - Updated dependencies [9e60e40]
37
+ - Updated dependencies [f85483d]
38
+ - Updated dependencies [3a575d7]
39
+ - Updated dependencies [ae54de7]
40
+ - Updated dependencies
41
+ - @nylorun/core@0.24.0-beta
42
+ - @nylorun/harness@0.29.0-beta
43
+
3
44
  ## 0.27.0-beta
4
45
 
5
46
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The Agent Card of one agent, from its manifest: name, description and one skill, never its
3
- * instructions, tools or MCP servers. The Runtime does not know where callers reach it, so
2
+ * The Agent Card of one Agent, from its manifest version: its id as the name, the manifest's
3
+ * description and one skill, never its instructions, tools or MCP servers. The Runtime does not know where callers reach it, so
4
4
  * `supportedInterfaces` is empty: whoever publishes the card (the gateway in v1) adds its own
5
5
  * URL, provider and security schemes.
6
6
  */
@@ -10,7 +10,8 @@ export interface CardDefinition {
10
10
  name?: unknown;
11
11
  description?: unknown;
12
12
  };
13
- readonly implementationVersion: string;
13
+ /** The manifest version the Agent runs, as `name@version`. */
14
+ readonly version: string;
14
15
  }
15
16
  import type { ModelInput } from "@nylorun/core/contracts";
16
17
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The Agent Card of one agent, from its manifest: name, description and one skill, never its
3
- * instructions, tools or MCP servers. The Runtime does not know where callers reach it, so
2
+ * The Agent Card of one Agent, from its manifest version: its id as the name, the manifest's
3
+ * description and one skill, never its instructions, tools or MCP servers. The Runtime does not know where callers reach it, so
4
4
  * `supportedInterfaces` is empty: whoever publishes the card (the gateway in v1) adds its own
5
5
  * URL, provider and security schemes.
6
6
  */
@@ -39,7 +39,7 @@ export function agentCard(agentId, definition, inputModes = MODES) {
39
39
  name,
40
40
  description,
41
41
  supportedInterfaces: [],
42
- version: definition.implementationVersion,
42
+ version: definition.version,
43
43
  capabilities: { streaming: false, pushNotifications: false, extendedAgentCard: false },
44
44
  defaultInputModes: [...inputModes],
45
45
  defaultOutputModes: MODES,
@@ -25,7 +25,8 @@ import { SETTLED_EVENTS, buildTask, contextSessionId, newContextId, parseTaskId,
25
25
  import { currentModelDescriptor } from "../../model/descriptor.js";
26
26
  import { accessOf } from "../../tenant/auth.js";
27
27
  import { command } from "../../tenant/commands.js";
28
- import { loadSession, } from "../../tenant/context.js";
28
+ import { loadSession, reachesAgent, } from "../../tenant/context.js";
29
+ import { agentGrantsOf, liveEnvironment } from "../../tenant/agents.js";
29
30
  import { HttpError, fail } from "../../tenant/http.js";
30
31
  import { observeSession, readHistory } from "../../tenant/session-streams.js";
31
32
  import { putSession } from "../../tenant/sessions.js";
@@ -105,12 +106,22 @@ async function operation(caller, request, signal) {
105
106
  return a2aFail("methodNotFound", `Method ${request.method} not found`);
106
107
  }
107
108
  }
108
- /** The agent's definition, or a `404` when it is missing or the caller may not use it. */
109
+ /**
110
+ * What the card of Agent `agentId` says (the manifest version it runs), or a `404` when it is
111
+ * missing or the caller may not use it. Every caller's session runs on that Agent, with its disk
112
+ * and vault (D66, D70): an app that serves several audiences makes an Agent for each.
113
+ */
109
114
  async function definitionFor(ctx, agentId, access) {
110
- if (access?.agents !== undefined && !access.agents.has(agentId))
115
+ if (!reachesAgent(access, agentId))
111
116
  return fail(404, "Agent not found");
112
- const definition = await ctx.store.tx((t) => t.get("definitions", agentId));
113
- return definition ?? fail(404, "Agent not found");
117
+ return ctx.store.tx(async (t) => {
118
+ const agent = (await liveEnvironment(t, agentId)) ?? fail(404, "Agent not found");
119
+ const version = await t.agentManifest(agent.manifestName, agent.manifestVersion);
120
+ return {
121
+ manifest: { id: agentId, ...(version?.body.description === undefined ? {} : { description: version.body.description }) },
122
+ version: `${agent.manifestName}@${agent.manifestVersion}`,
123
+ };
124
+ });
114
125
  }
115
126
  const taskNotFound = (taskId) => a2aFail("taskNotFound", "Task not found", { taskId });
116
127
  /** The caller's session for a context, or undefined when it does not exist yet. */
@@ -166,9 +177,9 @@ async function openContext(caller, sessionId) {
166
177
  return existing;
167
178
  return putSession(caller.ctx, sessionId, {
168
179
  requestId: randomUUID(),
169
- agentId: caller.agentId,
180
+ agent: caller.agentId,
170
181
  ownerUserId: caller.access.owner,
171
- }, caller.access);
182
+ }, caller.access, agentGrantsOf(caller.scope) === undefined ? {} : { agentGrants: agentGrantsOf(caller.scope) });
172
183
  }
173
184
  async function sendMessage(caller, params, signal) {
174
185
  const send = parseSendParams(params);
@@ -36,7 +36,7 @@ import { fail, HttpError } from "../../tenant/http.js";
36
36
  import { observeSession, readHistory, StreamClosed, streamHolderOf, } from "../../tenant/session-streams.js";
37
37
  import { putSession, sessionView } from "../../tenant/sessions.js";
38
38
  import { mayUseAgent } from "../../tenant/auth.js";
39
- import { environmentGrantsOf } from "../../tenant/environments.js";
39
+ import { agentGrantsOf } from "../../tenant/agents.js";
40
40
  import { hostTuning } from "../../tuning.js";
41
41
  const TERMINAL = new Set([
42
42
  "turn.completed",
@@ -111,10 +111,7 @@ function sessionOptions(input, scope) {
111
111
  ?.nylorun?.session;
112
112
  if (raw === undefined)
113
113
  return {};
114
- const parsed = PutSessionRequestSchema.pick({
115
- info: true,
116
- environment: true,
117
- })
114
+ const parsed = PutSessionRequestSchema.pick({ info: true })
118
115
  .strict()
119
116
  .safeParse(raw);
120
117
  if (!parsed.success)
@@ -282,12 +279,12 @@ trace) {
282
279
  const id = sessionIdFor(caller.subject, agentId, input.threadId);
283
280
  await putSession(ctx, id, {
284
281
  requestId: randomUUID(),
285
- agentId,
282
+ agent: agentId,
286
283
  ownerUserId: caller.subject,
287
284
  ...sessionOptions(input, scope),
288
285
  }, caller.access, {
289
286
  createOnly: true,
290
- ...(environmentGrantsOf(scope) === undefined ? {} : { environmentGrants: environmentGrantsOf(scope) }),
287
+ ...(agentGrantsOf(scope) === undefined ? {} : { agentGrants: agentGrantsOf(scope) }),
291
288
  });
292
289
  const translator = new RunTranslator(input.threadId, input.runId);
293
290
  let cursor;