operon-agents-core 0.1.0-alpha.35 → 0.1.0-alpha.36

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 (69) hide show
  1. package/dist/agent/compose-hooks.js +20 -5
  2. package/dist/agent/index.d.ts +1 -1
  3. package/dist/agent/run-support.d.ts +9 -0
  4. package/dist/agent/run-support.js +32 -0
  5. package/dist/agent/runner.d.ts +15 -0
  6. package/dist/agent/runner.js +7 -2
  7. package/dist/agent/session.d.ts +85 -1
  8. package/dist/agent/session.js +249 -17
  9. package/dist/agent/subagent-tools.js +56 -3
  10. package/dist/agent/subagent.d.ts +5 -0
  11. package/dist/agent/subagent.js +1 -0
  12. package/dist/agent/toolset.js +36 -2
  13. package/dist/capabilities/background/index.js +3 -0
  14. package/dist/capabilities/background/manager.d.ts +13 -0
  15. package/dist/capabilities/background/manager.js +40 -4
  16. package/dist/capabilities/background/monitor-tool.js +1 -0
  17. package/dist/capabilities/capability.d.ts +4 -0
  18. package/dist/capabilities/user-hooks/engine.js +7 -4
  19. package/dist/capabilities/user-hooks/index.js +15 -1
  20. package/dist/capabilities/user-hooks/types.d.ts +9 -0
  21. package/dist/config/schema.d.ts +2 -0
  22. package/dist/config/schema.js +2 -0
  23. package/dist/config/session-config.d.ts +1 -0
  24. package/dist/events/events.d.ts +2 -0
  25. package/dist/events/projection.d.ts +2 -0
  26. package/dist/events/projection.js +1 -0
  27. package/dist/loop/run-turn.d.ts +3 -0
  28. package/dist/loop/run-turn.js +2 -1
  29. package/dist/loop/tool-call.d.ts +6 -0
  30. package/dist/loop/tool-call.js +93 -8
  31. package/dist/loop/turn-step.d.ts +3 -0
  32. package/dist/loop/turn-step.js +1 -1
  33. package/dist/loop/types.d.ts +20 -0
  34. package/dist/permission/auto-approver/decision-auto-approver.js +9 -1
  35. package/dist/permission/auto-approver/llm-auto-approver.js +6 -3
  36. package/dist/permission/auto-approver/transcript.d.ts +7 -1
  37. package/dist/permission/auto-approver/transcript.js +21 -1
  38. package/dist/permission/environment-scope.d.ts +26 -0
  39. package/dist/permission/environment-scope.js +35 -0
  40. package/dist/permission/index.d.ts +1 -1
  41. package/dist/permission/manager.d.ts +20 -2
  42. package/dist/permission/manager.js +24 -3
  43. package/dist/permission/policies.d.ts +2 -0
  44. package/dist/permission/policies.js +51 -23
  45. package/dist/permission/types.d.ts +22 -0
  46. package/dist/plugins/hooks.d.ts +1 -0
  47. package/dist/plugins/hooks.js +1 -0
  48. package/dist/store/index.d.ts +1 -1
  49. package/dist/store/index.js +1 -1
  50. package/dist/store/store.d.ts +2 -0
  51. package/dist/store/store.js +2 -0
  52. package/dist/tool/access.d.ts +8 -0
  53. package/dist/tool/access.js +3 -0
  54. package/dist/tool/builtin/bash.js +1 -0
  55. package/dist/tool/builtin/edit.js +1 -0
  56. package/dist/tool/builtin/glob.js +1 -0
  57. package/dist/tool/builtin/grep.js +1 -0
  58. package/dist/tool/builtin/read.js +1 -0
  59. package/dist/tool/builtin/write.js +1 -0
  60. package/dist/tool/define.d.ts +2 -0
  61. package/dist/tool/define.js +1 -0
  62. package/dist/tool/environment-table.d.ts +160 -0
  63. package/dist/tool/environment-table.js +239 -0
  64. package/dist/tool/environment-target.d.ts +28 -0
  65. package/dist/tool/environment-target.js +59 -0
  66. package/dist/tool/index.d.ts +2 -0
  67. package/dist/tool/index.js +1 -0
  68. package/dist/tool/types.d.ts +14 -0
  69. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { toolInputGuardrailHook, toolOutputGuardrailHook } from "./guardrail.js";
2
- import { runCtxFor } from "./run-support.js";
2
+ import { frameEnvironmentsFor, runCtxFor } from "./run-support.js";
3
3
  import { withToolCallRecoveryContext } from "./recovery.js";
4
4
  import { permissionDenialDetails } from "../permission/denial.js";
5
5
  /**
@@ -82,7 +82,19 @@ function buildAuthorizer(state, context, tools) {
82
82
  // The `auto`-mode judge needs THIS frame's live transcript + tool registry (the authorize
83
83
  // ctx carries neither). Bind them per turn as closure state — the manager is a session
84
84
  // singleton shared by concurrent frames, so they must never be stored on it.
85
- const base = state.permission.authorizerFor({ getTranscript: () => context.messages, getTools: typeof tools === "function" ? tools : () => tools });
85
+ const base = state.permission.authorizerFor({
86
+ getTranscript: () => context.messages,
87
+ getTools: typeof tools === "function" ? tools : () => tools,
88
+ getEnvironments: () => {
89
+ const frame = frameEnvironmentsFor(state);
90
+ if (frame === undefined)
91
+ return undefined;
92
+ return {
93
+ home: frame.home,
94
+ entries: [...frame.reachable.values()].map((entry) => ({ name: entry.name, ...(entry.description !== undefined ? { description: entry.description } : {}) })),
95
+ };
96
+ },
97
+ });
86
98
  return async (ctx) => {
87
99
  // Read at call time, not captured: a nested call (`ToolRunContext.dispatch`) may add an
88
100
  // answer while the batch runs.
@@ -92,9 +104,12 @@ function buildAuthorizer(state, context, tools) {
92
104
  // flow through (the responder/resume answer is applied here).
93
105
  context.audit({ type: "permission.record_approval", toolCallId: ctx.toolCall.id, toolName: ctx.toolCall.name, decision: answer.decision, feedback: answer.feedback, approvalRule: ctx.plan.approvalRule, scope: answer.scope });
94
106
  // That record is this frame's audit trail. A session grant is the SESSION's state, so the
95
- // session persists it — what a reopen restores from — whichever frame earned it.
96
- const grants = answer.decision === "approved" && answer.scope === "session" && !state.permission.sessionGrants.includes(ctx.plan.approvalRule);
97
- const ok = state.permission.applyApproval(ctx.plan.approvalRule, answer);
107
+ // session persists it — what a reopen restores from — whichever frame earned it. It is
108
+ // scoped to the environment the call runs in: approving `make` on one machine is not
109
+ // approving it on another.
110
+ const key = state.permission.grantKey(ctx.plan.approvalRule, ctx.environment);
111
+ const grants = answer.decision === "approved" && answer.scope === "session" && !state.permission.sessionGrants.includes(key);
112
+ const ok = state.permission.applyApproval(ctx.plan.approvalRule, answer, ctx.environment);
98
113
  if (grants)
99
114
  state.session.persistPermissionState();
100
115
  if (ok)
@@ -11,7 +11,7 @@ export { composeLoopHooks } from "./compose-hooks.ts";
11
11
  * that drive `runTurn` directly resolve precedence the same way the Runner does. */
12
12
  export { resolveModelParams } from "./run-support.ts";
13
13
  export { Session, newSessionId } from "./session.ts";
14
- export type { BackgroundTaskListOptions, ReadBackgroundTaskOutputDeltaOptions, ReadBackgroundTaskOutputOptions, ConversationHead, CreateGoalInput, GoalBudgetInput, GoalStatusInput, PlanModeOptions, SessionOpenOptions, SessionPort, } from "./session.ts";
14
+ export type { BackgroundTaskListOptions, ReadBackgroundTaskOutputDeltaOptions, ReadBackgroundTaskOutputOptions, ConversationHead, CreateGoalInput, GoalBudgetInput, GoalStatusInput, PlanModeOptions, SessionOpenOptions, SessionEnvironmentInput, EnvironmentChange, SessionPort, } from "./session.ts";
15
15
  export { newAgentId } from "./subagent.ts";
16
16
  export type { SubagentRecord, SubagentStatus, AgentSpawnDetails } from "./subagent.ts";
17
17
  export { RawAgentProfileSchema, resolveAgentProfiles, resolveProfileDirs, loadAgentProfiles, loadAgentProfilesFromSources, prepareSystemPromptContext, buildAgentFromProfile, profileSubagentProvider, } from "./profiles.ts";
@@ -12,6 +12,7 @@ import type { ConversationContext, HistoryChangeListener } from "../loop/context
12
12
  import type { Agent, AgentRunContext } from "./agent.ts";
13
13
  import type { DeriveOptions, RunState } from "./runner.ts";
14
14
  import type { TurnStopReason } from "../loop/types.ts";
15
+ import { type FrameEnvironments } from "../tool/environment-table.ts";
15
16
  /**
16
17
  * This frame's flat directory id — what peers address it by.
17
18
  *
@@ -60,6 +61,14 @@ export declare function runCtxFor<TContext>(state: RunState<TContext>): AgentRun
60
61
  * subagent, Agent, and Workflow tools all go through it.
61
62
  */
62
63
  export declare function deriveChild<TContext>(parent: RunState<TContext>, opts: DeriveOptions, spawner: Pick<Agent<TContext>, "model">): RunState<TContext>;
64
+ /**
65
+ * The environments `state`'s frame can address, as the tool-call layer and the prompt need
66
+ * them — `undefined` for a frame that reaches one environment (every single-environment
67
+ * session), which keeps that path exactly as it was.
68
+ */
69
+ export declare function frameEnvironmentsFor<TContext>(state: RunState<TContext>): FrameEnvironments | undefined;
70
+ /** Append the frame's environment list to its system prompt (multi-environment frames only). */
71
+ export declare function withEnvironmentSection(system: string | undefined, frame: FrameEnvironments | undefined): string | undefined;
63
72
  /** Runs the turn-boundary injectors, appending their reminders to `context`, and returns each
64
73
  * injector's token estimate so the context breakdown can break the framing out of `messages`. */
65
74
  export declare function injectAtTurnBoundary<TContext>(state: RunState<TContext>, context: ConversationContext): Map<string, number>;
@@ -3,6 +3,7 @@ import { newInterruptionId } from "../loop/interruption.js";
3
3
  import { customMessage, DEFAULT_ADDRESS } from "../store/store.js";
4
4
  import { systemReminder } from "../capabilities/injection.js";
5
5
  import { estimateTokens } from "../capabilities/compaction/tokens.js";
6
+ import { frameEnvironmentsOf, renderEnvironmentSection } from "../tool/environment-table.js";
6
7
  /**
7
8
  * This frame's flat directory id — what peers address it by.
8
9
  *
@@ -123,9 +124,29 @@ export function deriveChild(parent, opts, spawner) {
123
124
  parentToolCallId: opts.parentToolCallId,
124
125
  ...(opts.signal ? { signal: opts.signal } : {}),
125
126
  ...(opts.environment ? { environment: opts.environment } : {}),
127
+ ...(opts.homeEnvironment !== undefined ? { homeEnvironment: opts.homeEnvironment } : {}),
128
+ ...(opts.reachableEnvironments !== undefined ? { reachableEnvironments: opts.reachableEnvironments } : {}),
126
129
  ...(opts.steer ? { steer: opts.steer } : {}),
127
130
  };
128
131
  }
132
+ /**
133
+ * The environments `state`'s frame can address, as the tool-call layer and the prompt need
134
+ * them — `undefined` for a frame that reaches one environment (every single-environment
135
+ * session), which keeps that path exactly as it was.
136
+ */
137
+ export function frameEnvironmentsFor(state) {
138
+ const table = state.environments;
139
+ if (table === undefined)
140
+ return undefined;
141
+ return frameEnvironmentsOf(table, state.homeEnvironment ?? table.rootName, state.environment, state.reachableEnvironments);
142
+ }
143
+ /** Append the frame's environment list to its system prompt (multi-environment frames only). */
144
+ export function withEnvironmentSection(system, frame) {
145
+ if (frame === undefined || frame.reachable.size <= 1)
146
+ return system;
147
+ const section = renderEnvironmentSection(frame);
148
+ return system === undefined || system.length === 0 ? section : `${system}\n\n${section}`;
149
+ }
129
150
  /** Runs the turn-boundary injectors, appending their reminders to `context`, and returns each
130
151
  * injector's token estimate so the context breakdown can break the framing out of `messages`. */
131
152
  export function injectAtTurnBoundary(state, context) {
@@ -149,8 +170,19 @@ export function injectAtTurnBoundary(state, context) {
149
170
  // longer, because the journal itself broadcasts (`historyChangeEmitter`).
150
171
  context.appendMessage(message, origin);
151
172
  });
173
+ // Environment status (a declared machine not connected this open, a changed working directory,
174
+ // an `updateEnvironments`): a reminder at the boundary, never a system-prompt change, so the
175
+ // cached prefix holds. Once per frame per notice.
176
+ const notice = state.session.takeEnvironmentNotice?.(state.address);
177
+ if (notice !== undefined) {
178
+ const text = systemReminder(notice);
179
+ const message = { role: "user", content: [{ type: "text", text }], timestamp: Date.now() };
180
+ injectionTokens.set(ENVIRONMENT_INJECTOR_ID, estimateTokens(text));
181
+ context.appendMessage(message, { kind: "injection", injectorId: ENVIRONMENT_INJECTOR_ID, variant: "status" });
182
+ }
152
183
  return injectionTokens;
153
184
  }
185
+ const ENVIRONMENT_INJECTOR_ID = "environments";
154
186
  // ── Pure message helpers ─────────────────────────────────────────────────────────────────
155
187
  export function lastAssistant(messages) {
156
188
  for (let i = messages.length - 1; i >= 0; i--) {
@@ -2,6 +2,7 @@ import type { ChatModel } from "../llm/define-model.ts";
2
2
  import type { AssistantMessage, Message, Usage } from "../protocol/index.ts";
3
3
  import { ConversationContext } from "../loop/context.ts";
4
4
  import type { Environment } from "../tool/environment.ts";
5
+ import type { EnvironmentTable } from "../tool/environment-table.ts";
5
6
  import type { BackgroundSpawner } from "../tool/background.ts";
6
7
  import { PermissionManager } from "../permission/manager.ts";
7
8
  import type { ApprovalResponse, Responder } from "../permission/types.ts";
@@ -170,7 +171,14 @@ export interface RunState<TContext> {
170
171
  readonly maxTurns: number;
171
172
  address: string;
172
173
  readonly events: EventSink;
174
+ /** This frame's home environment instance: where a call without `target` runs. */
173
175
  readonly environment: Environment;
176
+ /** The session's named environments. A table of one = the single-environment session. */
177
+ readonly environments?: EnvironmentTable;
178
+ /** Name of this frame's home environment in `environments` (default: the table's root). */
179
+ readonly homeEnvironment?: string;
180
+ /** Names this frame may target (its home always included). Undefined = the whole table. */
181
+ readonly reachableEnvironments?: readonly string[];
174
182
  readonly store?: SessionStore;
175
183
  readonly responder?: Responder;
176
184
  readonly background?: BackgroundSpawner;
@@ -206,6 +214,13 @@ export interface DeriveOptions {
206
214
  readonly signal?: AbortSignal;
207
215
  /** Isolated environment (e.g. a workflow worktree); defaults to the parent's. */
208
216
  readonly environment?: Environment;
217
+ /**
218
+ * The child's home environment by name, when it is sent to another environment of the table
219
+ * (the Agent tool's `target`). Set together with `environment` (that entry's instance).
220
+ */
221
+ readonly homeEnvironment?: string;
222
+ /** Names the child may target; defaults to what the parent could reach. */
223
+ readonly reachableEnvironments?: readonly string[];
209
224
  /** Own SteerBus (parallel workflow agents can't share the parent's single-turn bus). */
210
225
  readonly steer?: SteerBus;
211
226
  /** Stable instance identity for a fresh child. Defaults to the address tail. */
@@ -19,7 +19,7 @@ import { performHandoff } from "./handoff-executor.js";
19
19
  import { pauseRun } from "./pause.js";
20
20
  import { buildRunTools } from "./toolset.js";
21
21
  import { prepareToolCatalog } from "../tool/search/catalog.js";
22
- import { emitRunEvent, finalText, historyChangeEmitter, injectAtTurnBoundary, lastAssistant, mapTerminalStatus, resolveModelParams, runCtxFor, tryParseOutput, } from "./run-support.js";
22
+ import { emitRunEvent, finalText, frameEnvironmentsFor, historyChangeEmitter, injectAtTurnBoundary, lastAssistant, mapTerminalStatus, resolveModelParams, runCtxFor, tryParseOutput, withEnvironmentSection, } from "./run-support.js";
23
23
  export class Runner {
24
24
  config;
25
25
  engine;
@@ -527,6 +527,8 @@ export class Runner {
527
527
  address: runAddress,
528
528
  events: session.events,
529
529
  environment: session.environment,
530
+ environments: session.environments,
531
+ homeEnvironment: session.environments.rootName,
530
532
  store: session.store,
531
533
  responder: session.responder,
532
534
  background: session.background,
@@ -633,7 +635,8 @@ class Engine {
633
635
  // the resumed tool result and would change the cached request prefix.
634
636
  const injectionTokens = resumingInterruptedTurn ? new Map() : injectAtTurnBoundary(state, context);
635
637
  const model = await this.resolveModelFor(current, state);
636
- const system = await current.resolveInstructions(runCtxFor(state));
638
+ const frameEnvironments = frameEnvironmentsFor(state);
639
+ const system = withEnvironmentSection(await current.resolveInstructions(runCtxFor(state)), frameEnvironments);
637
640
  // The engine's run loop rides into the toolset as a plain callback: the spawner the
638
641
  // subagent/Agent/Workflow tools share calls it to run child agents.
639
642
  const toolset = await buildRunTools(current, state, (agent, childContext, childState, childResume) => this.run(agent, childContext, childState, childResume), model);
@@ -672,6 +675,7 @@ class Engine {
672
675
  signal: state.signal,
673
676
  model,
674
677
  environment: state.environment,
678
+ ...(frameEnvironments !== undefined ? { environments: frameEnvironments } : {}),
675
679
  background: state.background,
676
680
  responder: state.responder,
677
681
  hostContext: state.context,
@@ -768,6 +772,7 @@ class Engine {
768
772
  toolName: p.toolName,
769
773
  approvalRule: p.approvalRule,
770
774
  display: p.display,
775
+ ...(p.environment !== undefined ? { environment: p.environment } : {}),
771
776
  }, { signal: state.signal });
772
777
  if (state.signal.aborted)
773
778
  return this.finish(state, "aborted", current, messages);
@@ -4,6 +4,7 @@ import type { ThinkingLevel } from "../llm/model.ts";
4
4
  import type { PermissionMode, Responder } from "../permission/types.ts";
5
5
  import { PermissionManager } from "../permission/manager.ts";
6
6
  import type { BackgroundSpawner } from "../tool/background.ts";
7
+ import { EnvironmentTable, type SubagentEnvironmentAccess } from "../tool/environment-table.ts";
7
8
  import { WorkflowManager } from "./workflow/manager.ts";
8
9
  import type { WorkflowJournal } from "./workflow/journal.ts";
9
10
  import type { ContextBreakdown } from "./context-report.ts";
@@ -84,6 +85,31 @@ export interface SessionOpenOptions {
84
85
  * outlives any one session, so closing a session must not pull it out from under the others.
85
86
  */
86
87
  readonly environment?: Environment | EnvironmentFactory;
88
+ /**
89
+ * Name of the root environment (`environment` above) in the session's environment table.
90
+ * Defaults to `"main"`. Only matters when `additionalEnvironments` is given.
91
+ */
92
+ readonly environmentName?: string;
93
+ /**
94
+ * The live instances of this session's other environments, by name. With at least one,
95
+ * environment-scoped tools take an optional `target` naming where a call runs, and the system
96
+ * prompt lists every environment.
97
+ *
98
+ * The first open that brings them DECLARES them: names, descriptions, subagent access and what
99
+ * each machine looked like (OS, shell, cwd) are kept with the session (store-backed sessions).
100
+ * Every later open hands in instances for the declared names only — the declaration does not
101
+ * change with what is handed in, so the prompt and tool schemas (the cached request prefix) stay
102
+ * the same. A declared name this open does not get, or whose factory fails, is UNAVAILABLE:
103
+ * calls to it are refused and the model is told. A name that was never declared fails the open;
104
+ * change the declaration with `Session.updateEnvironments`.
105
+ */
106
+ readonly additionalEnvironments?: readonly SessionEnvironmentInput[];
107
+ /**
108
+ * What a subagent sent to another environment (the Agent tool's `target`) may reach, unless
109
+ * that environment says otherwise. Default `inherit`. Part of the declaration: read only when
110
+ * the declaration is first made.
111
+ */
112
+ readonly subagentEnvironmentAccess?: SubagentEnvironmentAccess;
87
113
  readonly sandboxTtlMs?: number;
88
114
  readonly events?: EventSink;
89
115
  readonly steer?: SteerBus;
@@ -98,6 +124,30 @@ export interface SessionOpenOptions {
98
124
  /** Spawns background work when no background capability is open. */
99
125
  readonly spawner?: BackgroundSpawner;
100
126
  }
127
+ /** One additional environment handed to `Session.open`. */
128
+ export interface SessionEnvironmentInput {
129
+ readonly name: string;
130
+ readonly environment: Environment | EnvironmentFactory;
131
+ /** What it is for, shown to the model with its OS / shell / cwd. */
132
+ readonly description?: string;
133
+ /** Workspace identity; give two names the same one when they reach the same workspace. */
134
+ readonly identity?: string;
135
+ /** What a subagent sent here may reach (overrides `subagentEnvironmentAccess`). */
136
+ readonly subagentAccess?: SubagentEnvironmentAccess;
137
+ }
138
+ /** A change to a session's declared environments (`Session.updateEnvironments`). */
139
+ export interface EnvironmentChange {
140
+ readonly add?: readonly SessionEnvironmentInput[];
141
+ readonly remove?: readonly string[];
142
+ /** `null` clears a field. */
143
+ readonly update?: readonly {
144
+ readonly name: string;
145
+ readonly description?: string | null;
146
+ readonly subagentAccess?: SubagentEnvironmentAccess | null;
147
+ }[];
148
+ /** The session-wide default; `null` resets it to `inherit`. */
149
+ readonly subagentAccess?: SubagentEnvironmentAccess | null;
150
+ }
101
151
  /** The current owner and root conversation shard for the next user prompt. */
102
152
  export interface ConversationHead {
103
153
  readonly agentKey: string;
@@ -155,6 +205,8 @@ export interface SessionPort {
155
205
  * tool needs; the manager itself stays behind `session.workflow`. */
156
206
  newWorkflowJournal(runId: string, parentToolCallId?: string): WorkflowJournal;
157
207
  resolveSystemPromptContext(environment: Environment): Promise<SystemPromptContext>;
208
+ /** The environment status note `address` has not seen yet (multi-environment sessions). */
209
+ takeEnvironmentNotice?(address: string): string | undefined;
158
210
  recordContextBreakdown(breakdown: ContextBreakdown): void;
159
211
  flushEvents(): Promise<void>;
160
212
  setLiveContext(address: string, ctx: ConversationContext): void;
@@ -196,7 +248,12 @@ export declare class Session implements SessionPort {
196
248
  private readonly injectedSpawner;
197
249
  /** Open capabilities in registration order — closed in reverse. */
198
250
  private openedForClose;
251
+ /** The root environment — where tools run unless a call names another `target`. */
199
252
  readonly environment: Environment;
253
+ private environmentTable;
254
+ private environmentNotice;
255
+ private readonly environmentNoticeDelivered;
256
+ private readonly sandboxTtlMs;
200
257
  readonly store?: SessionStore;
201
258
  readonly events: EventSink;
202
259
  private readonly eventPublisher;
@@ -278,6 +335,33 @@ export declare class Session implements SessionPort {
278
335
  * controls), opens every capability in order, then builds the permission manager.
279
336
  */
280
337
  static open(opts?: SessionOpenOptions): Promise<Session>;
338
+ /**
339
+ * One renewer per backing sandbox of `table`: two names on one machine share it, and an
340
+ * environment that is not connected has nothing to renew. The root keeps the message it always
341
+ * had; another environment's failure names that environment.
342
+ */
343
+ private keepalivesFor;
344
+ /** Every named environment of this session, root first. A table of one in the usual case. */
345
+ get environments(): EnvironmentTable;
346
+ /** Queue a status note for every frame's next turn boundary (replaces any undelivered one). */
347
+ setEnvironmentNotice(text: string): void;
348
+ /**
349
+ * The environment status note `address` has not seen yet, marking it seen — or undefined.
350
+ * Read at each turn boundary: availability and drift reach the model this way, never by
351
+ * changing the system prompt, so the cached prefix holds.
352
+ */
353
+ takeEnvironmentNotice(address: string): string | undefined;
354
+ /**
355
+ * Change what environments this session HAS — the one deliberate way to: reopening with a
356
+ * different set of instances never changes the declaration. Call it between runs: during a
357
+ * run it is refused (a tool awaiting it would otherwise wait on its own run). The tool `target` options and the prompt's
358
+ * environment list change with it, so the next request starts a new cached prefix; every frame
359
+ * is told what changed at its next turn boundary.
360
+ *
361
+ * Refused (nothing changes) for: the root environment, an unknown name, a name already taken,
362
+ * or removing an environment a background process is still running on.
363
+ */
364
+ updateEnvironments(change: EnvironmentChange): Promise<void>;
281
365
  /**
282
366
  * Build every capability's declared services and register them.
283
367
  *
@@ -462,7 +546,7 @@ export declare class Session implements SessionPort {
462
546
  get thinkingSetting(): ThinkingLevel | undefined;
463
547
  get permissionModeSetting(): PermissionMode | undefined;
464
548
  drainDiagnostics(): CapabilityDiagnostic[];
465
- private readonly sandboxKeepalive;
549
+ private sandboxKeepalives;
466
550
  private turnActive;
467
551
  withRunLock<T>(body: () => Promise<T>): Promise<T>;
468
552
  flushEvents(): Promise<void>;