glove-foundry 0.6.1 → 0.8.0

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveResolvable
3
- } from "./chunk-K2EU63MB.js";
3
+ } from "./chunk-CYOIHSUX.js";
4
4
 
5
5
  // src/guidance.ts
6
6
  import { createHash } from "node:crypto";
@@ -179,6 +179,9 @@ function assertSnapshot(value) {
179
179
  return structuredClone(snapshot);
180
180
  }
181
181
  function environmentSnapshotOwner(scope, context) {
182
+ if (scope === "workspace") {
183
+ return { scope, definitionId: "", agentId: "", conversationId: "", workspaceId: context.workspaceId };
184
+ }
182
185
  return {
183
186
  scope,
184
187
  definitionId: context.definitionId,
@@ -331,6 +334,32 @@ function programmaticToolFunction(selection, options) {
331
334
  }
332
335
  };
333
336
  }
337
+ function codeName(name) {
338
+ const safe = name.replace(/[^A-Za-z0-9_]/g, "_");
339
+ return /^[A-Za-z_]/.test(safe) ? safe : `_${safe}`;
340
+ }
341
+ function replApps(apps, tools) {
342
+ const byName = new Map(tools.map((tool) => [tool.name, tool]));
343
+ return Object.freeze(apps.map((app) => Object.freeze({
344
+ id: app.id,
345
+ description: app.description,
346
+ ...app.accountId ? { accountId: app.accountId } : {},
347
+ tools: Object.freeze(app.tools.flatMap(({ name, readOnly }) => {
348
+ const tool = byName.get(name);
349
+ if (!tool) return [];
350
+ return [Object.freeze({
351
+ tool,
352
+ name: codeName(name),
353
+ server: codeName(app.id),
354
+ serverDescription: app.description,
355
+ ...readOnly !== void 0 ? { readOnly } : {}
356
+ })];
357
+ }))
358
+ })));
359
+ }
360
+ function needsApproval(tool) {
361
+ return typeof tool.requiresPermission === "function" || Boolean(tool.requiresPermission);
362
+ }
334
363
  async function registerProgrammaticTools(options) {
335
364
  const config = options.repl.programmaticTools;
336
365
  if (!config) return 0;
@@ -343,6 +372,7 @@ async function registerProgrammaticTools(options) {
343
372
  assembly: options.context,
344
373
  glove: options.glove,
345
374
  tools,
375
+ apps: replApps(options.apps, tools),
346
376
  ...options.workingEnvironment ? { workingEnvironment: options.workingEnvironment } : {},
347
377
  ...options.vfs ? { vfs: options.vfs } : {}
348
378
  }));
@@ -365,6 +395,10 @@ async function registerProgrammaticTools(options) {
365
395
  options.repl.session.registerFns(functions);
366
396
  break;
367
397
  }
398
+ if (config.keepDirect === false) {
399
+ const codeOnly = selected.map((selection) => isProgrammaticSelection(selection) ? selection.tool : selection).filter((tool) => !needsApproval(tool)).map((tool) => tool.name);
400
+ if (codeOnly.length > 0) options.glove.replaceTools(codeOnly, []);
401
+ }
368
402
  return functions.length;
369
403
  }
370
404
  function persistenceContext(context) {
@@ -456,6 +490,7 @@ async function mountFoundryWorkbench(options) {
456
490
  repl,
457
491
  glove: options.glove,
458
492
  context: options.context,
493
+ apps: options.apps?.() ?? [],
459
494
  ...environment ? { workingEnvironment: environment, vfs: environment.fs } : {}
460
495
  });
461
496
  switch (repl.language) {
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FoundryRuntime,
4
4
  FoundryServer,
5
5
  writeGeneratedTypes
6
- } from "./chunk-X6EWEWWM.js";
6
+ } from "./chunk-DTFCEX67.js";
7
7
  import {
8
8
  DEFAULT_FOUNDRY_CONFIG
9
9
  } from "./chunk-ZFNMFE3T.js";
@@ -11,9 +11,9 @@ import "./chunk-J7ZBJM54.js";
11
11
  import {
12
12
  EMPTY_FOUNDRY_APPLICATION,
13
13
  isFoundryApplication
14
- } from "./chunk-OBTOFA7W.js";
15
- import "./chunk-B36BGF5R.js";
16
- import "./chunk-K2EU63MB.js";
14
+ } from "./chunk-EUGKVW3J.js";
15
+ import "./chunk-J6NHL4SM.js";
16
+ import "./chunk-CYOIHSUX.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { watch } from "node:fs";
@@ -1,57 +1,10 @@
1
- import { aO as FoundryAgentDefinition, s as AccountId, j as AccountReference, t as AccountNotFound, cy as TransmissionId, ct as RunId, u as AccountSessionUnavailable, J as AgentId, cq as RouteId, cp as Route, cr as RouteNotFound, cv as TopologyConflict, Y as BindingId, l as AgentBinding, Z as BindingNotFound, al as EventReference, aj as EventId, ak as EventNotFound, cs as RunGrant, c2 as GrantResolutionError, i as AnyFoundryTransmission, a as FoundryDataAdapter, be as FoundryInstanceProvisioner, aY as FoundryCapabilityRegistry, bx as FoundryNativeRegistry, C as Conversation, bE as FoundryRequest, a2 as CreateAgentInstanceOptions, b as AgentInstance, a3 as CreateConversationOptions, h as AgentPlaybook, P as PlaybookSubscription, c as FoundryActivationRecord, ac as DefinePlaybookSubscriptionOptions, V as ApplicationConnectionState, cC as UpdateAgentInstanceOptions, cD as UpdateConversationOptions, W as WorkspaceEntry, S as SharedInboxItem, g as FoundryTask, E as EnvironmentValue, bt as FoundryMessageInput, bH as FoundryResult, aW as FoundryCapabilityManifest, bv as FoundryNativeManifest, L as AgentInstallation, b4 as FoundryDelegationStatus, b2 as FoundryDelegation, bI as FoundryRouteMap, v as AccountSummary, T as AnyFoundryAgent } from './definition-A8o11aez.js';
2
- import { Context, Effect, Layer, Schema } from 'effect';
1
+ import { StoreAdapter, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
+ import { v as AccountId, m as AccountReference, w as AccountNotFound, cZ as TransmissionId, cR as RouteId, cQ as Route, cS as RouteNotFound, cW as TopologyConflict, a1 as BindingId, o as AgentBinding, a2 as BindingNotFound, M as AgentId, av as EventReference, at as EventId, au as EventNotFound, cU as RunId, x as AccountSessionUnavailable, b as FoundryDataAdapter, bz as FoundryInstanceProvisioner, h as FoundryApproval, aZ as FoundryAgentDefinition, cT as RunGrant, ct as GrantResolutionError, l as AnyFoundryTransmission, be as FoundryCapabilityRegistry, bX as FoundryNativeRegistry, c3 as FoundryRequest, a7 as CreateAgentInstanceOptions, c as AgentInstance, bT as FoundryMessageOptions, T as AgentMessageReceipt, bp as FoundryEventTarget, bo as FoundryEventPolicy, C as Conversation, f as FoundryEventRecord, d as FoundryActivationRecord, g as FoundryPendingInbound, j as FoundryTask, S as SharedInboxItem, a8 as CreateConversationOptions, k as AgentPlaybook, P as PlaybookSubscription, aj as DefinePlaybookSubscriptionOptions, $ as ApplicationConnectionState, d1 as UpdateAgentInstanceOptions, d2 as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bS as FoundryMessageInput, c6 as FoundryResult, b7 as FoundryApprovalStatus, b4 as FoundryApprovalDecision, bc as FoundryCapabilityManifest, bV as FoundryNativeManifest, Q as AgentInstallation, bm as FoundryDelegationStatus, bk as FoundryDelegation, bR as FoundryMeshThreadStatus, bQ as FoundryMeshThread, c7 as FoundryRouteMap, y as AccountSummary, Y as AnyFoundryAgent } from './event-delivery-CNCsVqi8.js';
3
3
  import * as effect_Brand from 'effect/Brand';
4
- import { StoreAdapter, Displaymanager, DisplayManagerAdapter, Slot, Message, TokenConsumptionCounter } from 'glove-core';
4
+ import { Context, Effect, Layer, Schema } from 'effect';
5
5
  import { FoundryStationDaemonAdapter } from './station.js';
6
6
  import { FoundryConfig } from './config.js';
7
7
 
8
- interface DiscoveredAgent {
9
- route: string;
10
- filePath: string;
11
- relativePath: string;
12
- definition: FoundryAgentDefinition;
13
- executionName: string;
14
- }
15
- interface FoundryManifestAgent {
16
- id: string;
17
- description: string;
18
- mode: "agent";
19
- file: string;
20
- tags: readonly string[];
21
- invocationContract: "foundry/request-v1";
22
- resultContract: "foundry/result-v1";
23
- assembly: "foundry" | "custom";
24
- handler: "glove" | "custom";
25
- layers: readonly string[];
26
- subscribers: readonly string[];
27
- tools: readonly string[];
28
- hooks: readonly string[];
29
- skills: readonly string[];
30
- subagents: readonly string[];
31
- memory: readonly string[];
32
- inboxLoader: boolean;
33
- calls: readonly string[];
34
- schedules: readonly string[];
35
- playbooks: readonly string[];
36
- mesh: boolean;
37
- workingEnvironment: boolean;
38
- repl: "javascript" | "python" | "lisp" | "dynamic" | null;
39
- lazy: readonly string[];
40
- }
41
- interface FoundryManifest {
42
- version: 1;
43
- generatedAt: string;
44
- agents: FoundryManifestAgent[];
45
- }
46
- declare function routeFromAgentFile(agentsDir: string, filePath: string): string | null;
47
- declare function findAgentFiles(agentsDir: string): Promise<string[]>;
48
- declare function discoverAgents(options: {
49
- agentsDir: string;
50
- strictFileRoutes?: boolean;
51
- cacheBust?: boolean;
52
- }): Promise<DiscoveredAgent[]>;
53
- declare function createManifest(agents: readonly DiscoveredAgent[]): FoundryManifest;
54
-
55
8
  interface AccountFilter {
56
9
  readonly transmissionId?: TransmissionId;
57
10
  }
@@ -115,6 +68,133 @@ declare function memoryAccountDirectory(accounts: ReadonlyArray<AccountReference
115
68
  declare const memoryTopologyStore: Layer.Layer<TopologyStore>;
116
69
  declare const memoryEventStore: Layer.Layer<EventStore>;
117
70
 
71
+ declare const FOUNDRY_APPLICATION_BRAND: unique symbol;
72
+ /**
73
+ * Secret-bearing HTTP request data passed only to the consumer-owned
74
+ * authorization adapter. Foundry does not persist or observe this value.
75
+ */
76
+ interface FoundryRequestAuthorizationInput {
77
+ readonly method: string;
78
+ readonly path: string;
79
+ readonly query: string;
80
+ readonly authorization?: string;
81
+ readonly cookie?: string;
82
+ readonly remoteAddress?: string;
83
+ }
84
+ /**
85
+ * Gate the Foundry HTTP surface without making credential acquisition or
86
+ * refresh a framework concern. The adapter may validate a basic/bearer
87
+ * credential, a session cookie, or an identity asserted by a trusted proxy.
88
+ */
89
+ interface FoundryRequestAuthorizationAdapter<TError = never> {
90
+ readonly identifier: string;
91
+ /** Value for WWW-Authenticate when access is denied. */
92
+ readonly challenge?: string;
93
+ readonly authorize: (input: FoundryRequestAuthorizationInput) => Effect.Effect<boolean, TError, never>;
94
+ }
95
+ /** Process infrastructure only; agent files own runtime capabilities. */
96
+ interface FoundryApplicationOptions {
97
+ readonly name: string;
98
+ /** Optional configuration of the managed daemon; loaded from the application file in its process. */
99
+ readonly daemon?: FoundryStationDaemonAdapter;
100
+ readonly accounts?: ReadonlyArray<AccountReference>;
101
+ readonly routes?: ReadonlyArray<Route>;
102
+ readonly bindings?: ReadonlyArray<AgentBinding>;
103
+ readonly data?: FoundryDataAdapter;
104
+ readonly conversationStore?: (scope: {
105
+ readonly definitionId: string;
106
+ readonly agentId: string;
107
+ readonly conversationId: string;
108
+ readonly workspaceId: string;
109
+ }) => Promise<StoreAdapter> | StoreAdapter;
110
+ /**
111
+ * User-owned HTTP authorization boundary. Required for non-loopback binds;
112
+ * credential values never enter Foundry data, manifests, or observability.
113
+ */
114
+ readonly requestAuthorization?: FoundryRequestAuthorizationAdapter<unknown>;
115
+ /** User-owned strategy for subscriptions using `provisioning.mode = "custom"`. */
116
+ readonly provisioner?: FoundryInstanceProvisioner;
117
+ /**
118
+ * How approvals work. They are durable when the data adapter stores
119
+ * approvals and events (`FileFoundryDataAdapter` and
120
+ * `MemoryFoundryDataAdapter` do): the run that asked waits `waitMs` for a
121
+ * decision, then suspends; the approval stays open for `expiresAfterMs`;
122
+ * and a decision made later resumes the run at the tool call that asked.
123
+ */
124
+ readonly approvals?: {
125
+ /** How long a run waits for a decision before it suspends. Default 60 s (5 min when approvals are not durable). */
126
+ readonly waitMs?: number;
127
+ /** How long a durable approval stays open. Default 7 days. */
128
+ readonly expiresAfterMs?: number;
129
+ /**
130
+ * Where a person decides one approval: a page of your app. Foundry keeps
131
+ * it on the approval (`url`) so whatever tells the person, such as a
132
+ * message or an email, can link straight to it.
133
+ */
134
+ readonly url?: (approval: FoundryApproval) => string | undefined;
135
+ };
136
+ readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
137
+ }
138
+ type FoundryApplication = Readonly<FoundryApplicationOptions> & {
139
+ readonly [FOUNDRY_APPLICATION_BRAND]: true;
140
+ };
141
+ declare function isFoundryApplication(value: unknown): value is FoundryApplication;
142
+ /** Define infrastructure. Agent composition is deliberately absent here. */
143
+ declare function defineApplication(options: FoundryApplicationOptions): FoundryApplication;
144
+ declare const EMPTY_FOUNDRY_APPLICATION: FoundryApplication;
145
+
146
+ interface DiscoveredAgent {
147
+ route: string;
148
+ filePath: string;
149
+ relativePath: string;
150
+ definition: FoundryAgentDefinition;
151
+ executionName: string;
152
+ }
153
+ interface FoundryManifestAgent {
154
+ id: string;
155
+ description: string;
156
+ mode: "agent";
157
+ file: string;
158
+ tags: readonly string[];
159
+ invocationContract: "foundry/request-v1";
160
+ resultContract: "foundry/result-v1";
161
+ assembly: "foundry" | "custom";
162
+ handler: "glove" | "custom";
163
+ layers: readonly string[];
164
+ subscribers: readonly string[];
165
+ tools: readonly string[];
166
+ hooks: readonly string[];
167
+ skills: readonly string[];
168
+ subagents: readonly string[];
169
+ durableSubagents?: ReadonlyArray<{
170
+ readonly name: string;
171
+ readonly definitionId: string;
172
+ readonly description?: string;
173
+ }>;
174
+ memory: readonly string[];
175
+ inboxLoader: boolean;
176
+ calls: readonly string[];
177
+ schedules: readonly string[];
178
+ playbooks: readonly string[];
179
+ mesh: boolean;
180
+ workingEnvironment: boolean;
181
+ repl: "javascript" | "python" | "lisp" | "dynamic" | null;
182
+ lazy: readonly string[];
183
+ }
184
+ interface FoundryManifest {
185
+ version: 1;
186
+ generatedAt: string;
187
+ agents: FoundryManifestAgent[];
188
+ }
189
+ declare function routeFromAgentFile(agentsDir: string, filePath: string): string | null;
190
+ declare function findAgentFiles(agentsDir: string): Promise<string[]>;
191
+ declare function discoverAgents(options: {
192
+ agentsDir: string;
193
+ strictFileRoutes?: boolean;
194
+ cacheBust?: boolean;
195
+ }): Promise<DiscoveredAgent[]>;
196
+ declare function createManifest(agents: readonly DiscoveredAgent[]): FoundryManifest;
197
+
118
198
  interface ResolveGrantRequest {
119
199
  readonly runId: RunId;
120
200
  readonly agentId: AgentId;
@@ -245,62 +325,6 @@ declare class MemoryObservabilityAdapter implements FoundryObservabilityAdapter
245
325
  clear(): void;
246
326
  }
247
327
 
248
- declare const FOUNDRY_APPLICATION_BRAND: unique symbol;
249
- /**
250
- * Secret-bearing HTTP request data passed only to the consumer-owned
251
- * authorization adapter. Foundry does not persist or observe this value.
252
- */
253
- interface FoundryRequestAuthorizationInput {
254
- readonly method: string;
255
- readonly path: string;
256
- readonly query: string;
257
- readonly authorization?: string;
258
- readonly cookie?: string;
259
- readonly remoteAddress?: string;
260
- }
261
- /**
262
- * Gate the Foundry HTTP surface without making credential acquisition or
263
- * refresh a framework concern. The adapter may validate a basic/bearer
264
- * credential, a session cookie, or an identity asserted by a trusted proxy.
265
- */
266
- interface FoundryRequestAuthorizationAdapter<TError = never> {
267
- readonly identifier: string;
268
- /** Value for WWW-Authenticate when access is denied. */
269
- readonly challenge?: string;
270
- readonly authorize: (input: FoundryRequestAuthorizationInput) => Effect.Effect<boolean, TError, never>;
271
- }
272
- /** Process infrastructure only; agent files own runtime capabilities. */
273
- interface FoundryApplicationOptions {
274
- readonly name: string;
275
- /** Optional configuration of the managed daemon; loaded from the application file in its process. */
276
- readonly daemon?: FoundryStationDaemonAdapter;
277
- readonly accounts?: ReadonlyArray<AccountReference>;
278
- readonly routes?: ReadonlyArray<Route>;
279
- readonly bindings?: ReadonlyArray<AgentBinding>;
280
- readonly data?: FoundryDataAdapter;
281
- readonly conversationStore?: (scope: {
282
- readonly definitionId: string;
283
- readonly agentId: string;
284
- readonly conversationId: string;
285
- readonly workspaceId: string;
286
- }) => Promise<StoreAdapter> | StoreAdapter;
287
- /**
288
- * User-owned HTTP authorization boundary. Required for non-loopback binds;
289
- * credential values never enter Foundry data, manifests, or observability.
290
- */
291
- readonly requestAuthorization?: FoundryRequestAuthorizationAdapter<unknown>;
292
- /** User-owned strategy for subscriptions using `provisioning.mode = "custom"`. */
293
- readonly provisioner?: FoundryInstanceProvisioner;
294
- readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
295
- }
296
- type FoundryApplication = Readonly<FoundryApplicationOptions> & {
297
- readonly [FOUNDRY_APPLICATION_BRAND]: true;
298
- };
299
- declare function isFoundryApplication(value: unknown): value is FoundryApplication;
300
- /** Define infrastructure. Agent composition is deliberately absent here. */
301
- declare function defineApplication(options: FoundryApplicationOptions): FoundryApplication;
302
- declare const EMPTY_FOUNDRY_APPLICATION: FoundryApplication;
303
-
304
328
  interface DiscoveredCapability {
305
329
  readonly kind: "tool" | "application" | "mcp" | "memory";
306
330
  readonly id: string;
@@ -319,58 +343,6 @@ interface DiscoveredFoundryRegistry {
319
343
  }>;
320
344
  }
321
345
 
322
- declare const FOUNDRY_APPROVAL_DIRECTORY_ENV = "GLOVE_FOUNDRY_APPROVAL_DIRECTORY";
323
- type FoundryApprovalDecision = "approve" | "deny";
324
- type FoundryApprovalStatus = "pending" | "approved" | "denied" | "expired" | "cancelled";
325
- interface FoundryApproval {
326
- readonly id: string;
327
- readonly runId: string;
328
- readonly definitionId: string;
329
- readonly agentId: string;
330
- readonly conversationId: string;
331
- readonly workspaceId: string;
332
- readonly toolName: string;
333
- readonly toolInput: unknown;
334
- readonly status: FoundryApprovalStatus;
335
- readonly requestedAt: string;
336
- readonly expiresAt: string;
337
- readonly resolvedAt?: string;
338
- }
339
- declare function createFoundryApproval(directory: string, input: {
340
- readonly runId: string;
341
- readonly definitionId: string;
342
- readonly agentId: string;
343
- readonly conversationId: string;
344
- readonly workspaceId: string;
345
- readonly toolName: string;
346
- readonly toolInput: unknown;
347
- readonly timeoutMs?: number;
348
- }): Promise<FoundryApproval>;
349
- declare function listFoundryApprovals(directory: string, filter?: {
350
- readonly runId?: string;
351
- readonly status?: FoundryApprovalStatus;
352
- }): Promise<ReadonlyArray<FoundryApproval>>;
353
- declare function resolveFoundryApproval(directory: string, id: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
354
- declare class FoundryApprovalDisplayManager extends Displaymanager implements DisplayManagerAdapter {
355
- private readonly context;
356
- constructor(context: {
357
- readonly directory?: string;
358
- readonly runId: string;
359
- readonly definitionId: string;
360
- readonly agentId: string;
361
- readonly conversationId: string;
362
- readonly workspaceId: string;
363
- readonly signal: AbortSignal;
364
- readonly emit: (event: {
365
- readonly type: string;
366
- readonly data?: unknown;
367
- }) => void;
368
- });
369
- pushAndWait<I, O>(slot: Omit<Slot<I>, "id">): Promise<O>;
370
- }
371
- /** Add fail-closed per-input permissions to a custom store that omitted them. */
372
- declare function withFoundryPermissions(store: StoreAdapter): StoreAdapter;
373
-
374
346
  interface FoundryRun<TOutput = unknown> {
375
347
  readonly id: string;
376
348
  readonly agent: string;
@@ -476,9 +448,15 @@ declare class FoundryRuntime {
476
448
  /** One run at a time per conversation; the next starts once the one ahead has let go. */
477
449
  private readonly gate;
478
450
  /** Pending inbound records each run is handling, so they are cleared when it settles. */
451
+ private readonly eventTimers;
452
+ private readonly completedEventRuns;
479
453
  private readonly pendingInboundByRun;
480
454
  /** Recently settled runs, for a record assigned to a run that already finished. */
481
455
  private readonly settledRuns;
456
+ /** How runs treat approvals; durable when the data adapter can keep them. */
457
+ private readonly approvalPolicy;
458
+ /** Approval records change one at a time. */
459
+ private approvalWrites;
482
460
  private started;
483
461
  private stopping;
484
462
  private disposed;
@@ -500,6 +478,35 @@ declare class FoundryRuntime {
500
478
  }): Effect.Effect<FoundryRun, FoundryRuntimeError>;
501
479
  request(route: string, request: FoundryRequest): Promise<FoundryRun>;
502
480
  createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
481
+ /** Provision exactly one owned worker per parent instance and declared slot. */
482
+ subagent(parentAgentId: string, name: string): Promise<AgentInstance>;
483
+ private ensureSubagent;
484
+ listSubagents(parentAgentId: string): Promise<ReadonlyArray<AgentInstance>>;
485
+ private assertDurableActive;
486
+ private effectiveAgent;
487
+ private ensureAgentEventConversation;
488
+ /** A message to an owned worker, independent of any delegated task. */
489
+ messageSubagent(parentAgentId: string, name: string, message: string, options?: FoundryMessageOptions): Promise<AgentMessageReceipt>;
490
+ private postAgentMessage;
491
+ /** Persist a spontaneous event before dispatching it to one exact runtime context. */
492
+ emitEvent(target: FoundryEventTarget, event: AgentEvent, policy?: FoundryEventPolicy): Promise<AgentMessageReceipt>;
493
+ private acceptEvent;
494
+ private executeAgentMessage;
495
+ /** Inspect owned records without provisioning or requiring the declaration to still exist. */
496
+ subagentData(parentAgentId: string, name: string): Promise<{
497
+ agent: AgentInstance;
498
+ conversations: readonly Conversation[];
499
+ events: FoundryEventRecord[];
500
+ children: readonly AgentInstance[];
501
+ activations: FoundryActivationRecord[];
502
+ pendingMessages: FoundryPendingInbound[];
503
+ tasks: FoundryTask[];
504
+ inbox: SharedInboxItem[];
505
+ }>;
506
+ archiveSubagent(parentAgentId: string, name: string): Promise<AgentInstance>;
507
+ resumeSubagent(parentAgentId: string, name: string): Promise<AgentInstance>;
508
+ /** Purge requires archival and an explicit application cleanup hook. Shared data is never passed to it. */
509
+ purgeSubagent(parentAgentId: string, name: string): Promise<void>;
503
510
  createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
504
511
  listAgentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
505
512
  setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
@@ -568,17 +575,49 @@ declare class FoundryRuntime {
568
575
  readonly runId?: string;
569
576
  readonly status?: FoundryApprovalStatus;
570
577
  }): Promise<ReadonlyArray<FoundryApproval>>;
578
+ /** One approval: what a link to it opens. Null when there is no such approval. */
579
+ getApproval(approvalId: string): Promise<FoundryApproval | null>;
580
+ /**
581
+ * Decide an approval. When the run that asked is still waiting, it reads the
582
+ * decision and carries on. When it is not (it suspended, timed out, or the
583
+ * runtime restarted since), the decision goes to the conversation as a
584
+ * durable event, and the run that takes it resumes the turn at the tool
585
+ * call that asked: approved, the call runs; denied, it is refused.
586
+ */
571
587
  resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
588
+ private reportResolved;
589
+ private withApprovals;
590
+ private reportApprovalFailure;
591
+ /** Stored approvals, expired where their time ran out, plus requests not recorded yet. Call inside withApprovals. */
592
+ private currentApprovals;
593
+ private withApprovalUrl;
594
+ /** What a run reported about one of its approvals, kept in the data adapter. */
595
+ private recordApprovalEvent;
596
+ /**
597
+ * A run ended. Its approvals still open no longer have anyone waiting:
598
+ * they stay open, and a decision resumes the conversation. A decision the
599
+ * run never read (it ended first) is handed over now.
600
+ */
601
+ private settleApprovalsOf;
602
+ private cancelApprovalsOf;
603
+ /** After a restart: open approvals have no run waiting, and decided ones may still be owed. */
604
+ private reconcileApprovals;
605
+ /**
606
+ * Hand a decision to the conversation that asked, as a durable event. The
607
+ * run that takes it resumes the turn at the waiting tool call. If the
608
+ * conversation moved on, the event tells the agent what was decided.
609
+ */
610
+ private resumeApproval;
572
611
  capabilityManifest(definitionId: string): FoundryCapabilityManifest;
573
612
  nativeManifest(definitionId: string): FoundryNativeManifest;
574
613
  listInstallations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
575
614
  installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
576
615
  uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
577
616
  listAccounts(): Promise<{
617
+ label?: string | undefined;
578
618
  id: string & effect_Brand.Brand<"FoundryAccountId">;
579
619
  transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
580
620
  externalAccountId: string;
581
- label?: string | undefined;
582
621
  metadata: {
583
622
  readonly [x: string]: unknown;
584
623
  };
@@ -680,8 +719,11 @@ declare class FoundryRuntime {
680
719
  private deliver;
681
720
  /** Start one run with everything held for a conversation, once nothing else holds it. */
682
721
  private flushHeldDeliveries;
683
- /** Clear the bookkeeping that lets a restart hand these deliveries over again. */
684
722
  private markHandedOver;
723
+ private finishEvents;
724
+ private redeliverEvents;
725
+ /** Clear the bookkeeping that lets a restart hand these deliveries over again. */
726
+ private markLegacyHandedOver;
685
727
  /** Record which run is handling a pending inbound event (none while it waits). */
686
728
  private assignPendingInbound;
687
729
  /** The run settled: the inbound events it was handling are done with. */
@@ -705,6 +747,41 @@ declare class FoundryRuntime {
705
747
  private executeDelegationCommand;
706
748
  private startDelegation;
707
749
  /** Report a worker's finished run back to whoever delegated to it. */
750
+ /** Every thread, newest first, optionally narrowed to who started it or who it went to. */
751
+ listThreads(filter?: {
752
+ /** The agent that started the thread. */
753
+ readonly agentId?: string;
754
+ /** The conversation that started the thread. */
755
+ readonly conversationId?: string;
756
+ /** The agent the thread was sent to. */
757
+ readonly to?: string;
758
+ readonly status?: FoundryMeshThreadStatus;
759
+ }): Promise<ReadonlyArray<FoundryMeshThread>>;
760
+ /**
761
+ * Older thread records kept their own lists of messages not handed over yet.
762
+ * Move them to the event journal once; message ids keep a retry from
763
+ * delivering twice.
764
+ */
765
+ private redeliverThreads;
766
+ /** The open threads a conversation started, oldest first. */
767
+ private openThreadsFrom;
768
+ private loadThread;
769
+ private updateThread;
770
+ private starterTarget;
771
+ private recipientTarget;
772
+ /**
773
+ * Hand mesh messages to one side of a thread. Messages, replies and
774
+ * failures go through durable delivery. A read receipt only ever reaches a
775
+ * run that is listening, and is dropped otherwise.
776
+ */
777
+ private deliverMesh;
778
+ /** A run's mesh call: answered through its request, so the tool hears the outcome. */
779
+ private runMeshCommand;
780
+ /** The agents an agent may see and message: its workspace, narrowed by its definition's rule. */
781
+ private meshPeers;
782
+ private executeMeshCommand;
783
+ /** When the recipient's run on a thread ends, its reply (or its failure) goes back. */
784
+ private settleThread;
708
785
  private handleRunSettled;
709
786
  private enqueueCoreRequest;
710
787
  /**
@@ -789,6 +866,18 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
789
866
  request(request: FoundryRequest): Promise<FoundryRunHandle<FoundryResult>>;
790
867
  };
791
868
  createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
869
+ emitEvent(target: FoundryEventTarget, event: AgentEvent, policy?: FoundryEventPolicy): Promise<AgentMessageReceipt>;
870
+ subagents(parentAgentId: string): Promise<ReadonlyArray<AgentInstance>>;
871
+ subagent(parentAgentId: string, name: string): {
872
+ ensure: () => Promise<AgentInstance>;
873
+ send: (message: string, delivery?: FoundryMessageOptions) => Promise<AgentMessageReceipt>;
874
+ data: () => Promise<Awaited<ReturnType<FoundryRuntime["subagentData"]>>>;
875
+ archive: () => Promise<AgentInstance>;
876
+ resume: () => Promise<AgentInstance>;
877
+ purge: () => Promise<{
878
+ purged: true;
879
+ }>;
880
+ };
792
881
  agentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
793
882
  configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
794
883
  setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
@@ -859,6 +948,8 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
859
948
  readonly runId?: string;
860
949
  readonly status?: FoundryApprovalStatus;
861
950
  }): Promise<ReadonlyArray<FoundryApproval>>;
951
+ /** One approval, by id: what a link to it opens. */
952
+ approval(approvalId: string): Promise<FoundryApproval>;
862
953
  resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
863
954
  manifest(): Promise<{
864
955
  agents: FoundryManifest;
@@ -885,4 +976,4 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
885
976
  }
886
977
  declare function createFoundryClient<TRoutes extends FoundryRouteMap = Record<string, AnyFoundryAgent>>(options?: FoundryClientOptions): FoundryClient<TRoutes>;
887
978
 
888
- export { grantResolverLive as $, AccountDirectory as A, type BindingFilter as B, type FoundryRequestAuthorizationAdapter as C, type DiscoveredAgent as D, EMPTY_FOUNDRY_APPLICATION as E, FoundryRuntime as F, type FoundryRequestAuthorizationInput as G, type FoundryRun as H, FoundryRunHandle as I, FoundryRuntimeError as J, type FoundryRuntimeOptions as K, type FoundrySteerHandleResult as L, type FoundrySteerResult as M, GrantResolver as N, ManifestCompilationError as O, MemoryObservabilityAdapter as P, type RouteFilter as Q, type ResolveGrantRequest as R, compileApplicationManifest as S, TopologyStore as T, createFoundryApproval as U, createFoundryClient as V, type WaitOptions as W, createManifest as X, defineApplication as Y, discoverAgents as Z, findAgentFiles as _, type FoundryManifest as a, isFoundryApplication as a0, listFoundryApprovals as a1, memoryAccountDirectory as a2, memoryEventStore as a3, memoryTopologyStore as a4, resolveFoundryApproval as a5, routeFromAgentFile as a6, withFoundryPermissions as a7, type AccountFilter as b, type AccountSessionAdapter as c, type AccountSessionRequest as d, type EventFilter as e, EventStore as f, FOUNDRY_APPLICATION_BRAND as g, FOUNDRY_APPROVAL_DIRECTORY_ENV as h, type FoundryApplication as i, FoundryApplicationManifest as j, type FoundryApplicationOptions as k, type FoundryApproval as l, type FoundryApprovalDecision as m, FoundryApprovalDisplayManager as n, type FoundryApprovalStatus as o, FoundryClient as p, type FoundryClientAuthorizationAdapter as q, type FoundryClientOptions as r, type FoundryConversationTranscript as s, type FoundryEvent as t, type FoundryEventCategory as u, type FoundryHealth as v, type FoundryManifestAgent as w, FoundryManifestCapability as x, FoundryManifestTransmission as y, type FoundryObservabilityAdapter as z };
979
+ export { AccountDirectory as A, type BindingFilter as B, type FoundryRuntimeOptions as C, type DiscoveredAgent as D, EMPTY_FOUNDRY_APPLICATION as E, FoundryRuntime as F, type FoundrySteerHandleResult as G, type FoundrySteerResult as H, GrantResolver as I, MemoryObservabilityAdapter as J, type RouteFilter as K, compileApplicationManifest as L, ManifestCompilationError as M, createFoundryClient as N, createManifest as O, defineApplication as P, discoverAgents as Q, type ResolveGrantRequest as R, findAgentFiles as S, TopologyStore as T, grantResolverLive as U, isFoundryApplication as V, type WaitOptions as W, memoryAccountDirectory as X, memoryEventStore as Y, memoryTopologyStore as Z, routeFromAgentFile as _, type FoundryManifest as a, type AccountFilter as b, type AccountSessionAdapter as c, type AccountSessionRequest as d, type EventFilter as e, EventStore as f, FOUNDRY_APPLICATION_BRAND as g, type FoundryApplication as h, FoundryApplicationManifest as i, type FoundryApplicationOptions as j, FoundryClient as k, type FoundryClientAuthorizationAdapter as l, type FoundryClientOptions as m, type FoundryConversationTranscript as n, type FoundryEvent as o, type FoundryEventCategory as p, type FoundryHealth as q, type FoundryManifestAgent as r, FoundryManifestCapability as s, FoundryManifestTransmission as t, type FoundryObservabilityAdapter as u, type FoundryRequestAuthorizationAdapter as v, type FoundryRequestAuthorizationInput as w, type FoundryRun as x, FoundryRunHandle as y, FoundryRuntimeError as z };
package/dist/client.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import './definition-A8o11aez.js';
2
- export { p as FoundryClient, q as FoundryClientAuthorizationAdapter, r as FoundryClientOptions, v as FoundryHealth, I as FoundryRunHandle, L as FoundrySteerHandleResult, W as WaitOptions, V as createFoundryClient } from './client-DWPYe_Nc.js';
3
1
  import 'glove-core';
2
+ import './event-delivery-CNCsVqi8.js';
3
+ export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-CekanYLW.js';
4
4
  import 'effect';
5
5
  import 'zod';
6
6
  import 'glove-mesh';
7
7
  import 'glove-mcp';
8
8
  import 'glove-memory';
9
9
  import 'glove-memory/tools';
10
- import 'glove-working-environment';
11
10
  import 'glove-js';
12
11
  import 'glove-lisp';
13
12
  import 'glove-python';
13
+ import 'glove-working-environment';
14
14
  import 'glove-facts';
15
15
  import 'glove-memory/goals';
16
16
  import 'glove-memory/forms';
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  FoundryClient,
3
3
  FoundryRunHandle,
4
4
  createFoundryClient
5
- } from "./chunk-7F7QVO6I.js";
5
+ } from "./chunk-L5JQVTHD.js";
6
6
  export {
7
7
  FoundryClient,
8
8
  FoundryRunHandle,
package/dist/config.d.ts CHANGED
@@ -29,6 +29,13 @@ interface FoundryConfig {
29
29
  readonly execution?: FoundryExecutionConfig;
30
30
  readonly observability?: {
31
31
  readonly maxEvents?: number;
32
+ /**
33
+ * Record what each model request was sent: system prompt, messages,
34
+ * runtime context and tools, compactly. The inspector's Network and
35
+ * Context views read these. On by default; `false` leaves them out of
36
+ * `/api/events` for systems that must not keep prompts.
37
+ */
38
+ readonly modelRequests?: boolean;
32
39
  };
33
40
  readonly branding?: FoundryBrandingConfig;
34
41
  readonly strictFileRoutes?: boolean;