glove-foundry 0.6.0 → 0.7.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-64UBLGYM.js";
4
4
 
5
5
  // src/guidance.ts
6
6
  import { createHash } from "node:crypto";
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-2GXPSIRL.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-EJZJAVNG.js";
15
+ import "./chunk-AC6SRI5V.js";
16
+ import "./chunk-64UBLGYM.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, Displaymanager, DisplayManagerAdapter, Slot, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
+ import { t as AccountId, k as AccountReference, u as AccountNotFound, cH as TransmissionId, cz as RouteId, cy as Route, cA as RouteNotFound, cE as TopologyConflict, $ as BindingId, m as AgentBinding, a0 as BindingNotFound, K as AgentId, ar as EventReference, ap as EventId, aq as EventNotFound, cC as RunId, v as AccountSessionUnavailable, a as FoundryDataAdapter, bm as FoundryInstanceProvisioner, aU as FoundryAgentDefinition, cB as RunGrant, cb as GrantResolutionError, j as AnyFoundryTransmission, b2 as FoundryCapabilityRegistry, bG as FoundryNativeRegistry, bN as FoundryRequest, a5 as CreateAgentInstanceOptions, b as AgentInstance, bC as FoundryMessageOptions, Q as AgentMessageReceipt, bd as FoundryEventTarget, bc as FoundryEventPolicy, C as Conversation, e as FoundryEventRecord, c as FoundryActivationRecord, f as FoundryPendingInbound, h as FoundryTask, S as SharedInboxItem, a6 as CreateConversationOptions, i as AgentPlaybook, P as PlaybookSubscription, af as DefinePlaybookSubscriptionOptions, Z as ApplicationConnectionState, cL as UpdateAgentInstanceOptions, cM as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bB as FoundryMessageInput, bQ as FoundryResult, b0 as FoundryCapabilityManifest, bE as FoundryNativeManifest, M as AgentInstallation, ba as FoundryDelegationStatus, b8 as FoundryDelegation, bR as FoundryRouteMap, w as AccountSummary, V as AnyFoundryAgent } from './event-delivery-BaYe6d9w.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,114 @@ 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
+ readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
118
+ }
119
+ type FoundryApplication = Readonly<FoundryApplicationOptions> & {
120
+ readonly [FOUNDRY_APPLICATION_BRAND]: true;
121
+ };
122
+ declare function isFoundryApplication(value: unknown): value is FoundryApplication;
123
+ /** Define infrastructure. Agent composition is deliberately absent here. */
124
+ declare function defineApplication(options: FoundryApplicationOptions): FoundryApplication;
125
+ declare const EMPTY_FOUNDRY_APPLICATION: FoundryApplication;
126
+
127
+ interface DiscoveredAgent {
128
+ route: string;
129
+ filePath: string;
130
+ relativePath: string;
131
+ definition: FoundryAgentDefinition;
132
+ executionName: string;
133
+ }
134
+ interface FoundryManifestAgent {
135
+ id: string;
136
+ description: string;
137
+ mode: "agent";
138
+ file: string;
139
+ tags: readonly string[];
140
+ invocationContract: "foundry/request-v1";
141
+ resultContract: "foundry/result-v1";
142
+ assembly: "foundry" | "custom";
143
+ handler: "glove" | "custom";
144
+ layers: readonly string[];
145
+ subscribers: readonly string[];
146
+ tools: readonly string[];
147
+ hooks: readonly string[];
148
+ skills: readonly string[];
149
+ subagents: readonly string[];
150
+ durableSubagents?: ReadonlyArray<{
151
+ readonly name: string;
152
+ readonly definitionId: string;
153
+ readonly description?: string;
154
+ }>;
155
+ memory: readonly string[];
156
+ inboxLoader: boolean;
157
+ calls: readonly string[];
158
+ schedules: readonly string[];
159
+ playbooks: readonly string[];
160
+ mesh: boolean;
161
+ workingEnvironment: boolean;
162
+ repl: "javascript" | "python" | "lisp" | "dynamic" | null;
163
+ lazy: readonly string[];
164
+ }
165
+ interface FoundryManifest {
166
+ version: 1;
167
+ generatedAt: string;
168
+ agents: FoundryManifestAgent[];
169
+ }
170
+ declare function routeFromAgentFile(agentsDir: string, filePath: string): string | null;
171
+ declare function findAgentFiles(agentsDir: string): Promise<string[]>;
172
+ declare function discoverAgents(options: {
173
+ agentsDir: string;
174
+ strictFileRoutes?: boolean;
175
+ cacheBust?: boolean;
176
+ }): Promise<DiscoveredAgent[]>;
177
+ declare function createManifest(agents: readonly DiscoveredAgent[]): FoundryManifest;
178
+
118
179
  interface ResolveGrantRequest {
119
180
  readonly runId: RunId;
120
181
  readonly agentId: AgentId;
@@ -245,62 +306,6 @@ declare class MemoryObservabilityAdapter implements FoundryObservabilityAdapter
245
306
  clear(): void;
246
307
  }
247
308
 
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
309
  interface DiscoveredCapability {
305
310
  readonly kind: "tool" | "application" | "mcp" | "memory";
306
311
  readonly id: string;
@@ -476,6 +481,8 @@ declare class FoundryRuntime {
476
481
  /** One run at a time per conversation; the next starts once the one ahead has let go. */
477
482
  private readonly gate;
478
483
  /** Pending inbound records each run is handling, so they are cleared when it settles. */
484
+ private readonly eventTimers;
485
+ private readonly completedEventRuns;
479
486
  private readonly pendingInboundByRun;
480
487
  /** Recently settled runs, for a record assigned to a run that already finished. */
481
488
  private readonly settledRuns;
@@ -500,6 +507,35 @@ declare class FoundryRuntime {
500
507
  }): Effect.Effect<FoundryRun, FoundryRuntimeError>;
501
508
  request(route: string, request: FoundryRequest): Promise<FoundryRun>;
502
509
  createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
510
+ /** Provision exactly one owned worker per parent instance and declared slot. */
511
+ subagent(parentAgentId: string, name: string): Promise<AgentInstance>;
512
+ private ensureSubagent;
513
+ listSubagents(parentAgentId: string): Promise<ReadonlyArray<AgentInstance>>;
514
+ private assertDurableActive;
515
+ private effectiveAgent;
516
+ private ensureAgentEventConversation;
517
+ /** A message to an owned worker, independent of any delegated task. */
518
+ messageSubagent(parentAgentId: string, name: string, message: string, options?: FoundryMessageOptions): Promise<AgentMessageReceipt>;
519
+ private postAgentMessage;
520
+ /** Persist a spontaneous event before dispatching it to one exact runtime context. */
521
+ emitEvent(target: FoundryEventTarget, event: AgentEvent, policy?: FoundryEventPolicy): Promise<AgentMessageReceipt>;
522
+ private acceptEvent;
523
+ private executeAgentMessage;
524
+ /** Inspect owned records without provisioning or requiring the declaration to still exist. */
525
+ subagentData(parentAgentId: string, name: string): Promise<{
526
+ agent: AgentInstance;
527
+ conversations: readonly Conversation[];
528
+ events: FoundryEventRecord[];
529
+ children: readonly AgentInstance[];
530
+ activations: FoundryActivationRecord[];
531
+ pendingMessages: FoundryPendingInbound[];
532
+ tasks: FoundryTask[];
533
+ inbox: SharedInboxItem[];
534
+ }>;
535
+ archiveSubagent(parentAgentId: string, name: string): Promise<AgentInstance>;
536
+ resumeSubagent(parentAgentId: string, name: string): Promise<AgentInstance>;
537
+ /** Purge requires archival and an explicit application cleanup hook. Shared data is never passed to it. */
538
+ purgeSubagent(parentAgentId: string, name: string): Promise<void>;
503
539
  createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
504
540
  listAgentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
505
541
  setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
@@ -680,8 +716,11 @@ declare class FoundryRuntime {
680
716
  private deliver;
681
717
  /** Start one run with everything held for a conversation, once nothing else holds it. */
682
718
  private flushHeldDeliveries;
683
- /** Clear the bookkeeping that lets a restart hand these deliveries over again. */
684
719
  private markHandedOver;
720
+ private finishEvents;
721
+ private redeliverEvents;
722
+ /** Clear the bookkeeping that lets a restart hand these deliveries over again. */
723
+ private markLegacyHandedOver;
685
724
  /** Record which run is handling a pending inbound event (none while it waits). */
686
725
  private assignPendingInbound;
687
726
  /** The run settled: the inbound events it was handling are done with. */
@@ -789,6 +828,18 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
789
828
  request(request: FoundryRequest): Promise<FoundryRunHandle<FoundryResult>>;
790
829
  };
791
830
  createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
831
+ emitEvent(target: FoundryEventTarget, event: AgentEvent, policy?: FoundryEventPolicy): Promise<AgentMessageReceipt>;
832
+ subagents(parentAgentId: string): Promise<ReadonlyArray<AgentInstance>>;
833
+ subagent(parentAgentId: string, name: string): {
834
+ ensure: () => Promise<AgentInstance>;
835
+ send: (message: string, delivery?: FoundryMessageOptions) => Promise<AgentMessageReceipt>;
836
+ data: () => Promise<Awaited<ReturnType<FoundryRuntime["subagentData"]>>>;
837
+ archive: () => Promise<AgentInstance>;
838
+ resume: () => Promise<AgentInstance>;
839
+ purge: () => Promise<{
840
+ purged: true;
841
+ }>;
842
+ };
792
843
  agentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
793
844
  configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
794
845
  setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
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-BaYe6d9w.js';
3
+ 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-BgpgsnoO.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-EEHGAWXM.js";
6
6
  export {
7
7
  FoundryClient,
8
8
  FoundryRunHandle,