glove-foundry 0.0.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.
@@ -0,0 +1,2186 @@
1
+ import { ContentPart, Message, IGloveRunnable, StoreAdapter, GloveFoldArgs, SubscriberAdapter, ModelAdapter, DisplayManagerAdapter, HookHandler, DefineSkillArgs, DefineSubAgentArgs, InboxItem } from 'glove-core';
2
+ import { Schema, Effect, Context, Layer } from 'effect';
3
+ import { z } from 'zod';
4
+ import { MeshAdapter, AgentIdentity } from 'glove-mesh';
5
+ import { McpCatalogueEntry, McpAdapter } from 'glove-mcp';
6
+ import { EntityMemoryAdapter, EpisodicMemoryAdapter, ResourceFsAdapter, ContextAdapter } from 'glove-memory';
7
+ import { MemoryToolOptions } from 'glove-memory/tools';
8
+ import { EnvSnapshot, EnvFsHandle, WorkingEnvironment, CreateWorkingEnvironmentOptions, MountWorkingEnvironmentConfig, Vfs } from 'glove-working-environment';
9
+ import { JsSession, MountJsConfig } from 'glove-js';
10
+ import { LispSession, MountLispConfig } from 'glove-lisp';
11
+ import { PySession, MountPyConfig } from 'glove-python';
12
+ import * as effect_Brand from 'effect/Brand';
13
+ import { FoundryConfig } from './config.js';
14
+
15
+ declare const TransmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
16
+ type TransmissionId = typeof TransmissionId.Type;
17
+ declare const AgentDefinitionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryAgentDefinitionId">;
18
+ type AgentDefinitionId = typeof AgentDefinitionId.Type;
19
+ /** Runtime instance id. It is intentionally distinct from a file-routed definition id. */
20
+ declare const AgentId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAgentId">;
21
+ type AgentId = typeof AgentId.Type;
22
+ declare const AccountId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">;
23
+ type AccountId = typeof AccountId.Type;
24
+ declare const RouteId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
25
+ type RouteId = typeof RouteId.Type;
26
+ declare const BindingId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryBindingId">;
27
+ type BindingId = typeof BindingId.Type;
28
+ declare const EventId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryEventId">;
29
+ type EventId = typeof EventId.Type;
30
+ declare const RunId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRunId">;
31
+ type RunId = typeof RunId.Type;
32
+ declare const CapabilityId: Schema.brand<Schema.filter<typeof Schema.String>, "FoundryCapabilityId">;
33
+ type CapabilityId = typeof CapabilityId.Type;
34
+ /**
35
+ * Public metadata for an external identity. `accessRef` is an opaque pointer
36
+ * owned by the application's account-session adapter. Foundry never resolves
37
+ * it into credential material itself and never serializes it into manifests.
38
+ */
39
+ declare const AccountReference: Schema.Struct<{
40
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">;
41
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
42
+ externalAccountId: typeof Schema.NonEmptyTrimmedString;
43
+ label: Schema.optional<typeof Schema.NonEmptyTrimmedString>;
44
+ accessRef: typeof Schema.NonEmptyTrimmedString;
45
+ metadata: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
46
+ }>;
47
+ type AccountReference = typeof AccountReference.Type;
48
+ /** Account metadata safe to expose over Foundry's operator API. */
49
+ declare const AccountSummary: Schema.Struct<{
50
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">;
51
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
52
+ externalAccountId: typeof Schema.NonEmptyTrimmedString;
53
+ label: Schema.optional<typeof Schema.NonEmptyTrimmedString>;
54
+ metadata: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
55
+ }>;
56
+ type AccountSummary = typeof AccountSummary.Type;
57
+ declare const InboundRoute: Schema.Struct<{
58
+ direction: Schema.Literal<["inbound"]>;
59
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
60
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
61
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
62
+ visibility: Schema.Literal<["private", "workspace"]>;
63
+ enabled: typeof Schema.Boolean;
64
+ config: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
65
+ }>;
66
+ type InboundRoute = typeof InboundRoute.Type;
67
+ declare const OutboundRoute: Schema.Struct<{
68
+ direction: Schema.Literal<["outbound"]>;
69
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
70
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
71
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
72
+ visibility: Schema.Literal<["private", "workspace"]>;
73
+ enabled: typeof Schema.Boolean;
74
+ config: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
75
+ }>;
76
+ type OutboundRoute = typeof OutboundRoute.Type;
77
+ declare const Route: Schema.Union<[Schema.Struct<{
78
+ direction: Schema.Literal<["inbound"]>;
79
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
80
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
81
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
82
+ visibility: Schema.Literal<["private", "workspace"]>;
83
+ enabled: typeof Schema.Boolean;
84
+ config: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
85
+ }>, Schema.Struct<{
86
+ direction: Schema.Literal<["outbound"]>;
87
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
88
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
89
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
90
+ visibility: Schema.Literal<["private", "workspace"]>;
91
+ enabled: typeof Schema.Boolean;
92
+ config: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
93
+ }>]>;
94
+ type Route = typeof Route.Type;
95
+ declare const ReplyPolicy: Schema.Union<[Schema.Struct<{
96
+ mode: Schema.Literal<["none"]>;
97
+ }>, Schema.Struct<{
98
+ mode: Schema.Literal<["origin"]>;
99
+ }>, Schema.Struct<{
100
+ mode: Schema.Literal<["route"]>;
101
+ routeId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
102
+ }>]>;
103
+ type ReplyPolicy = typeof ReplyPolicy.Type;
104
+ declare const AgentBinding: Schema.Struct<{
105
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryBindingId">;
106
+ agentId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAgentId">;
107
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
108
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
109
+ routeId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">>;
110
+ capabilities: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "FoundryCapabilityId">>;
111
+ reply: Schema.optional<Schema.Union<[Schema.Struct<{
112
+ mode: Schema.Literal<["none"]>;
113
+ }>, Schema.Struct<{
114
+ mode: Schema.Literal<["origin"]>;
115
+ }>, Schema.Struct<{
116
+ mode: Schema.Literal<["route"]>;
117
+ routeId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
118
+ }>]>>;
119
+ enabled: typeof Schema.Boolean;
120
+ }>;
121
+ type AgentBinding = typeof AgentBinding.Type;
122
+ /** Authority calculated for one run. Grants are data, not prompt text. */
123
+ declare const RunGrant: Schema.Struct<{
124
+ runId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRunId">;
125
+ agentId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAgentId">;
126
+ accountIds: Schema.Array$<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
127
+ outboundRouteIds: Schema.Array$<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">>;
128
+ capabilities: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "FoundryCapabilityId">>;
129
+ reply: Schema.Union<[Schema.Struct<{
130
+ mode: Schema.Literal<["none"]>;
131
+ }>, Schema.Struct<{
132
+ mode: Schema.Literal<["origin"]>;
133
+ }>, Schema.Struct<{
134
+ mode: Schema.Literal<["route"]>;
135
+ routeId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
136
+ }>]>;
137
+ }>;
138
+ type RunGrant = typeof RunGrant.Type;
139
+ /** A concise pointer to an event whose full payload can live out-of-band. */
140
+ declare const EventReference: Schema.Struct<{
141
+ id: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryEventId">;
142
+ transmissionId: Schema.brand<Schema.refine<string, typeof Schema.String>, "FoundryTransmissionId">;
143
+ routeId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
144
+ accountId: Schema.optional<Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">>;
145
+ externalEventId: typeof Schema.NonEmptyTrimmedString;
146
+ threadKey: typeof Schema.NonEmptyTrimmedString;
147
+ emittedAt: typeof Schema.NonEmptyTrimmedString;
148
+ payloadRef: typeof Schema.NonEmptyTrimmedString;
149
+ }>;
150
+ type EventReference = typeof EventReference.Type;
151
+ declare const AccountNotFound_base: Schema.TaggedErrorClass<AccountNotFound, "AccountNotFound", {
152
+ readonly _tag: Schema.tag<"AccountNotFound">;
153
+ } & {
154
+ accountId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">;
155
+ }>;
156
+ declare class AccountNotFound extends AccountNotFound_base {
157
+ get message(): string;
158
+ }
159
+ declare const RouteNotFound_base: Schema.TaggedErrorClass<RouteNotFound, "RouteNotFound", {
160
+ readonly _tag: Schema.tag<"RouteNotFound">;
161
+ } & {
162
+ routeId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRouteId">;
163
+ }>;
164
+ declare class RouteNotFound extends RouteNotFound_base {
165
+ get message(): string;
166
+ }
167
+ declare const BindingNotFound_base: Schema.TaggedErrorClass<BindingNotFound, "BindingNotFound", {
168
+ readonly _tag: Schema.tag<"BindingNotFound">;
169
+ } & {
170
+ bindingId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryBindingId">;
171
+ }>;
172
+ declare class BindingNotFound extends BindingNotFound_base {
173
+ get message(): string;
174
+ }
175
+ declare const EventNotFound_base: Schema.TaggedErrorClass<EventNotFound, "EventNotFound", {
176
+ readonly _tag: Schema.tag<"EventNotFound">;
177
+ } & {
178
+ eventId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryEventId">;
179
+ }>;
180
+ declare class EventNotFound extends EventNotFound_base {
181
+ get message(): string;
182
+ }
183
+ declare const TopologyConflict_base: Schema.TaggedErrorClass<TopologyConflict, "TopologyConflict", {
184
+ readonly _tag: Schema.tag<"TopologyConflict">;
185
+ } & {
186
+ resource: Schema.Literal<["route", "binding"]>;
187
+ id: typeof Schema.NonEmptyTrimmedString;
188
+ reason: typeof Schema.NonEmptyTrimmedString;
189
+ }>;
190
+ declare class TopologyConflict extends TopologyConflict_base {
191
+ }
192
+ declare const AccountSessionUnavailable_base: Schema.TaggedErrorClass<AccountSessionUnavailable, "AccountSessionUnavailable", {
193
+ readonly _tag: Schema.tag<"AccountSessionUnavailable">;
194
+ } & {
195
+ accountId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAccountId">;
196
+ operation: typeof Schema.NonEmptyTrimmedString;
197
+ reason: typeof Schema.NonEmptyTrimmedString;
198
+ }>;
199
+ declare class AccountSessionUnavailable extends AccountSessionUnavailable_base {
200
+ get message(): string;
201
+ }
202
+ declare const GrantResolutionError_base: Schema.TaggedErrorClass<GrantResolutionError, "GrantResolutionError", {
203
+ readonly _tag: Schema.tag<"GrantResolutionError">;
204
+ } & {
205
+ runId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryRunId">;
206
+ agentId: Schema.brand<typeof Schema.NonEmptyTrimmedString, "FoundryAgentId">;
207
+ reason: typeof Schema.NonEmptyTrimmedString;
208
+ }>;
209
+ declare class GrantResolutionError extends GrantResolutionError_base {
210
+ }
211
+ type FoundryDomainError = AccountNotFound | RouteNotFound | BindingNotFound | EventNotFound | TopologyConflict | AccountSessionUnavailable | GrantResolutionError;
212
+
213
+ /** A serializable instruction rendered into an inbound transmission turn. */
214
+ interface PlaybookDirective {
215
+ readonly action: string;
216
+ readonly instruction: string;
217
+ readonly parameters?: Readonly<Record<string, unknown>>;
218
+ }
219
+ interface PlaybookActionOptions {
220
+ /** @deprecated File-routed definitions derive identity from their filename. */
221
+ readonly id?: string;
222
+ readonly description?: string;
223
+ }
224
+ type FoundryPlaybookAction = Readonly<PlaybookActionOptions> & {
225
+ readonly id: string;
226
+ readonly [FOUNDRY_PLAYBOOK_ACTION_BRAND]: true;
227
+ };
228
+ interface PlaybookDirectiveInput extends Omit<PlaybookDirective, "action"> {
229
+ readonly action: FoundryPlaybookAction;
230
+ }
231
+ /** Declarative match policy. Executable predicates live on the transmission definition. */
232
+ interface PlaybookMatch {
233
+ readonly event?: string;
234
+ readonly routeIds?: ReadonlyArray<string>;
235
+ readonly predicate?: {
236
+ readonly name: string;
237
+ readonly parameters?: Readonly<Record<string, unknown>>;
238
+ };
239
+ }
240
+ interface PlaybookOutboundDirective {
241
+ readonly routeId: string;
242
+ readonly applicationId?: string;
243
+ readonly event?: string;
244
+ readonly accountId?: string;
245
+ readonly applicationAccountId?: string;
246
+ readonly instruction?: string;
247
+ }
248
+ /**
249
+ * Instance-owned, persistable transmission policy. Playbooks deliberately
250
+ * contain no functions; transmission definitions own all executable logic.
251
+ */
252
+ interface AgentPlaybook {
253
+ readonly id: string;
254
+ readonly transmissionId: string;
255
+ readonly enabled?: boolean;
256
+ readonly match?: PlaybookMatch;
257
+ readonly directives: ReadonlyArray<PlaybookDirective>;
258
+ readonly applications?: ReadonlyArray<string>;
259
+ readonly outbound?: ReadonlyArray<PlaybookOutboundDirective>;
260
+ readonly serialization?: Readonly<Record<string, unknown>>;
261
+ readonly origin?: "agent-definition" | "instance";
262
+ readonly playbookName?: string;
263
+ readonly definitionRevision?: string;
264
+ }
265
+ interface PlaybookMatchInput extends Omit<PlaybookMatch, "event" | "routeIds" | "predicate"> {
266
+ readonly event?: FoundryTransmissionEvent<"inbound">;
267
+ readonly routes?: ReadonlyArray<InboundRoute>;
268
+ readonly predicate?: {
269
+ readonly definition: FoundryTransmissionPredicate<any, any, any>;
270
+ readonly parameters?: Readonly<Record<string, unknown>>;
271
+ };
272
+ }
273
+ interface PlaybookOutboundInput extends Omit<PlaybookOutboundDirective, "routeId" | "applicationId" | "event" | "accountId" | "applicationAccountId"> {
274
+ readonly route: OutboundRoute;
275
+ readonly application?: FoundryAgentApplication;
276
+ readonly event?: FoundryTransmissionEvent<"outbound">;
277
+ readonly account?: AccountReference;
278
+ readonly applicationAccount?: AccountReference;
279
+ }
280
+ /** Internal authoring shape used while runtime composition is materialized. */
281
+ interface AgentPlaybookInput extends Omit<AgentPlaybook, "id" | "transmissionId" | "match" | "directives" | "applications" | "outbound"> {
282
+ readonly id?: string;
283
+ readonly transmission: AnyFoundryTransmission;
284
+ readonly match?: PlaybookMatchInput;
285
+ readonly directives: ReadonlyArray<PlaybookDirectiveInput>;
286
+ readonly applications?: ReadonlyArray<FoundryAgentApplication>;
287
+ readonly outbound?: ReadonlyArray<PlaybookOutboundInput>;
288
+ }
289
+ interface ComposedAgentPlaybookInput extends Omit<AgentPlaybookInput, "id"> {
290
+ readonly name: string;
291
+ }
292
+ type ComposedAgentPlaybook = Readonly<ComposedAgentPlaybookInput> & {
293
+ readonly [FOUNDRY_COMPOSED_PLAYBOOK_BRAND]: true;
294
+ };
295
+ /** Compose runtime policy from direct references to transmission primitives. */
296
+ declare function composePlaybook(playbook: ComposedAgentPlaybookInput): ComposedAgentPlaybook;
297
+ /** Rehydrate the JSON-safe data representation held by an instance adapter. */
298
+ declare function reconstructPlaybook(playbook: AgentPlaybook): Readonly<AgentPlaybook>;
299
+
300
+ declare const FOUNDRY_PLAYBOOK_ACTION_BRAND: unique symbol;
301
+ declare const FOUNDRY_COMPOSED_PLAYBOOK_BRAND: unique symbol;
302
+ declare function definePlaybookAction(options?: PlaybookActionOptions): FoundryPlaybookAction;
303
+
304
+ declare const FOUNDRY_TRANSMISSION_BRAND: unique symbol;
305
+ declare const FOUNDRY_TRANSMISSION_PREDICATE_BRAND: unique symbol;
306
+ declare const FOUNDRY_TRANSMISSION_EVENT_BRAND: unique symbol;
307
+ type TransmissionEventDirection = "inbound" | "outbound";
308
+ interface TransmissionEventOptions<TDirection extends TransmissionEventDirection = TransmissionEventDirection> {
309
+ /** @deprecated File-routed definitions derive identity from their filename. */
310
+ readonly id?: string;
311
+ readonly direction: TDirection;
312
+ readonly description?: string;
313
+ }
314
+ type FoundryTransmissionEvent<TDirection extends TransmissionEventDirection = TransmissionEventDirection> = Readonly<TransmissionEventOptions<TDirection>> & {
315
+ readonly id: string;
316
+ readonly [FOUNDRY_TRANSMISSION_EVENT_BRAND]: true;
317
+ };
318
+ interface TransmissionPredicateOptions<TEvent = unknown, TError = never, TRequirements = never> {
319
+ /** @deprecated File-routed definitions derive identity from their filename. */
320
+ readonly id?: string;
321
+ readonly description?: string;
322
+ readonly match: (event: TEvent, parameters: Readonly<Record<string, unknown>>, context: IngressContext) => Effect.Effect<boolean, TError, TRequirements>;
323
+ }
324
+ type FoundryTransmissionPredicate<TEvent = unknown, TError = never, TRequirements = never> = Readonly<TransmissionPredicateOptions<TEvent, TError, TRequirements>> & {
325
+ readonly id: string;
326
+ readonly [FOUNDRY_TRANSMISSION_PREDICATE_BRAND]: true;
327
+ };
328
+ interface CapabilityDefinition {
329
+ readonly id: string;
330
+ readonly description: string;
331
+ readonly account: "none" | "optional" | "required";
332
+ readonly effect: "read" | "write";
333
+ }
334
+ interface IngressContext {
335
+ readonly route: InboundRoute;
336
+ readonly account?: AccountReference;
337
+ }
338
+ interface TransmissionSerializationContext extends IngressContext {
339
+ readonly eventId: string;
340
+ readonly eventName: string;
341
+ readonly threadKey: string;
342
+ readonly playbooks: ReadonlyArray<AgentPlaybook>;
343
+ }
344
+ interface EgressContext {
345
+ readonly route: OutboundRoute;
346
+ readonly account?: AccountReference;
347
+ readonly grant: RunGrant;
348
+ }
349
+ /** Provider ingress remains adapter-owned and returns typed Effects. */
350
+ interface IngressAdapter<TEvent, TError = never, TRequirements = never> {
351
+ readonly authenticate: (raw: unknown, context: IngressContext) => Effect.Effect<boolean, TError, TRequirements>;
352
+ readonly normalize: (raw: unknown, context: IngressContext) => Effect.Effect<TEvent, TError, TRequirements>;
353
+ }
354
+ /** Provider delivery remains adapter-owned and revalidates its route per call. */
355
+ interface EgressAdapter<TInput, TOutput, TError = never, TRequirements = never> {
356
+ readonly deliver: (input: TInput, context: EgressContext) => Effect.Effect<TOutput, TError, TRequirements>;
357
+ }
358
+ interface AccountContract<TMetadata extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext> {
359
+ readonly required: boolean;
360
+ readonly metadata: TMetadata;
361
+ }
362
+ interface InboundContract<TConfig extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext, TEvent extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext, TError = never, TRequirements = never> {
363
+ readonly config: TConfig;
364
+ readonly event: TEvent;
365
+ readonly adapter?: IngressAdapter<Schema.Schema.Type<TEvent>, TError, TRequirements>;
366
+ /** Resolve a predefined event after normalization. Omit to use provider event data at runtime. */
367
+ readonly classify?: (event: Schema.Schema.Type<TEvent>, context: IngressContext) => Effect.Effect<FoundryTransmissionEvent<"inbound">, TError, TRequirements>;
368
+ /** Executable definitions referenced directly by code-authored playbooks. */
369
+ readonly predicates?: ReadonlyArray<FoundryTransmissionPredicate<Schema.Schema.Type<TEvent>, TError, TRequirements>>;
370
+ /** Transmission-owned event rendering. Omit for Foundry's deterministic XML serializer. */
371
+ readonly serialize?: (event: Schema.Schema.Type<TEvent>, context: TransmissionSerializationContext) => Effect.Effect<string, TError, TRequirements>;
372
+ }
373
+ interface OutboundContract<TConfig extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext, TInput extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext, TOutput extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext, TError = never, TRequirements = never> {
374
+ readonly config: TConfig;
375
+ readonly input: TInput;
376
+ readonly output: TOutput;
377
+ readonly adapter?: EgressAdapter<Schema.Schema.Type<TInput>, Schema.Schema.Type<TOutput>, TError, TRequirements>;
378
+ }
379
+ interface TransmissionOptions {
380
+ /** @deprecated File-routed definitions derive identity from their filename. */
381
+ readonly id?: string;
382
+ readonly name: string;
383
+ readonly description: string;
384
+ readonly account?: AccountContract;
385
+ readonly capabilities?: ReadonlyArray<CapabilityDefinition>;
386
+ /** Events this transmission can receive or deliver. */
387
+ readonly events?: ReadonlyArray<FoundryTransmissionEvent>;
388
+ readonly inbound?: InboundContract;
389
+ readonly outbound?: OutboundContract;
390
+ }
391
+ type FoundryTransmission<TOptions extends TransmissionOptions> = Readonly<TOptions> & {
392
+ readonly id: string;
393
+ readonly [FOUNDRY_TRANSMISSION_BRAND]: true;
394
+ };
395
+ type AnyFoundryTransmission = FoundryTransmission<TransmissionOptions>;
396
+ type InferAccountMetadata<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["account"] extends AccountContract<infer TSchema> ? Schema.Schema.Type<TSchema> : never : never;
397
+ type InferInboundEvent<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["inbound"] extends InboundContract<Schema.Schema.AnyNoContext, infer TEvent> ? Schema.Schema.Type<TEvent> : never : never;
398
+ type InferInboundConfig<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["inbound"] extends InboundContract<infer TConfig, Schema.Schema.AnyNoContext> ? Schema.Schema.Type<TConfig> : never : never;
399
+ type InferOutboundConfig<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["outbound"] extends OutboundContract<infer TConfig, Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext> ? Schema.Schema.Type<TConfig> : never : never;
400
+ type InferOutboundInput<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["outbound"] extends OutboundContract<Schema.Schema.AnyNoContext, infer TInput, Schema.Schema.AnyNoContext> ? Schema.Schema.Type<TInput> : never : never;
401
+ type InferOutboundOutput<TTransmission> = TTransmission extends FoundryTransmission<infer TOptions> ? TOptions["outbound"] extends OutboundContract<Schema.Schema.AnyNoContext, Schema.Schema.AnyNoContext, infer TOutput> ? Schema.Schema.Type<TOutput> : never : never;
402
+ declare function isFoundryTransmission(value: unknown): value is AnyFoundryTransmission;
403
+ declare function defineTransmissionPredicate<TEvent = unknown, TError = never, TRequirements = never>(options: TransmissionPredicateOptions<TEvent, TError, TRequirements>): FoundryTransmissionPredicate<TEvent, TError, TRequirements>;
404
+ declare function defineTransmissionEvent<const TDirection extends TransmissionEventDirection>(options: TransmissionEventOptions<TDirection>): FoundryTransmissionEvent<TDirection>;
405
+ declare function transmissionPredicate(transmission: AnyFoundryTransmission, id: string): FoundryTransmissionPredicate | undefined;
406
+ /** Define a provider-neutral transmission backed by Effect adapters. */
407
+ declare function defineTransmission<const TOptions extends TransmissionOptions>(options: TOptions): FoundryTransmission<TOptions>;
408
+
409
+ declare const FOUNDRY_CONNECTION_BRAND: unique symbol;
410
+ interface ConnectionReceiveInput {
411
+ readonly route: InboundRoute;
412
+ readonly eventId: string;
413
+ readonly threadKey: string;
414
+ readonly raw: unknown;
415
+ }
416
+ interface ApplicationConnectionContext {
417
+ readonly applicationId: string;
418
+ readonly connectionId: string;
419
+ readonly definitionId: string;
420
+ readonly workspaceId: string;
421
+ readonly account?: AccountReference;
422
+ readonly routes: ReadonlyArray<InboundRoute>;
423
+ readonly signal: AbortSignal;
424
+ readonly ready: () => Effect.Effect<void>;
425
+ readonly receive: (input: ConnectionReceiveInput) => Effect.Effect<void, unknown, never>;
426
+ readonly withAccountSession?: <A>(operation: string, use: (session: unknown) => Effect.Effect<A, unknown, never>) => Effect.Effect<A, unknown, never>;
427
+ }
428
+ interface DefineConnectionOptions<TError = never, TRequirements = never> {
429
+ /** @deprecated File-routed definitions derive identity from their filename. */
430
+ readonly id?: string;
431
+ readonly description: string;
432
+ /** Every inbound transmission this provider connection may emit. */
433
+ readonly transmissions: ReadonlyArray<AnyFoundryTransmission>;
434
+ readonly connect: (context: ApplicationConnectionContext) => Effect.Effect<void, TError, TRequirements>;
435
+ }
436
+ type FoundryApplicationConnection = Readonly<DefineConnectionOptions<any, any>> & {
437
+ readonly id: string;
438
+ readonly [FOUNDRY_CONNECTION_BRAND]: true;
439
+ };
440
+ type ApplicationConnectionStatus = "connecting" | "connected" | "reconnecting" | "disconnected" | "failed";
441
+ interface ApplicationConnectionState {
442
+ readonly id: string;
443
+ readonly applicationId: string;
444
+ readonly connectionId: string;
445
+ readonly definitionId: string;
446
+ readonly workspaceId: string;
447
+ readonly accountId?: string;
448
+ readonly routeIds: ReadonlyArray<string>;
449
+ readonly status: ApplicationConnectionStatus;
450
+ readonly attempts: number;
451
+ readonly connectedAt?: string;
452
+ readonly disconnectedAt?: string;
453
+ readonly lastEventAt?: string;
454
+ readonly error?: string;
455
+ }
456
+ declare function defineConnection<TError = never, TRequirements = never>(options: DefineConnectionOptions<TError, TRequirements>): FoundryApplicationConnection;
457
+
458
+ type AgentProvisioningPolicy = {
459
+ readonly mode: "singleton";
460
+ readonly key?: string;
461
+ } | {
462
+ readonly mode: "per-thread";
463
+ } | {
464
+ readonly mode: "per-event";
465
+ } | {
466
+ readonly mode: "existing";
467
+ readonly agentIds: ReadonlyArray<string>;
468
+ } | {
469
+ readonly mode: "custom";
470
+ readonly adapter: string;
471
+ };
472
+ interface PlaybookSubscriptionTarget {
473
+ readonly definitionId: string;
474
+ readonly provisioning: AgentProvisioningPolicy;
475
+ readonly context: Readonly<Record<string, unknown>>;
476
+ readonly installations: ReadonlyArray<AgentInstallation>;
477
+ }
478
+ interface PlaybookSubscription {
479
+ readonly id: string;
480
+ readonly workspaceId: string;
481
+ readonly enabled: boolean;
482
+ readonly playbook: AgentPlaybook;
483
+ readonly targets: ReadonlyArray<PlaybookSubscriptionTarget>;
484
+ readonly createdAt: string;
485
+ readonly updatedAt: string;
486
+ }
487
+ interface PlaybookSubscriptionTargetInput {
488
+ readonly agent: FoundryAgentDefinition;
489
+ readonly provisioning?: AgentProvisioningPolicy;
490
+ readonly context?: Readonly<Record<string, unknown>>;
491
+ readonly installations?: ReadonlyArray<AgentInstallation>;
492
+ }
493
+ interface DefinePlaybookSubscriptionOptions {
494
+ /** @deprecated File-routed subscriptions derive identity from their filename. */
495
+ readonly id?: string;
496
+ readonly workspaceId?: string;
497
+ readonly enabled?: boolean;
498
+ readonly playbook: AgentPlaybookInput | AgentPlaybook;
499
+ readonly targets: ReadonlyArray<PlaybookSubscriptionTargetInput>;
500
+ readonly createdAt?: string;
501
+ readonly updatedAt?: string;
502
+ }
503
+ interface CustomProvisioningContext {
504
+ readonly subscription: PlaybookSubscription;
505
+ readonly target: PlaybookSubscriptionTarget;
506
+ readonly route: InboundRoute;
507
+ readonly eventId: string;
508
+ readonly eventName: string;
509
+ readonly threadKey: string;
510
+ readonly event: unknown;
511
+ }
512
+ interface CustomProvisionedAgent extends CreateAgentInstanceOptions {
513
+ /** Stable uniqueness key; the data adapter enforces it atomically. */
514
+ readonly provisioningKey: string;
515
+ }
516
+ interface FoundryInstanceProvisioner {
517
+ readonly identifier: string;
518
+ provision(adapter: string, context: CustomProvisioningContext): Effect.Effect<ReadonlyArray<CustomProvisionedAgent>, unknown, never>;
519
+ }
520
+ declare function definePlaybookSubscription(options: DefinePlaybookSubscriptionOptions): PlaybookSubscription;
521
+ /** Rehydrate the value-only representation returned by a durable adapter. */
522
+ declare function reconstructPlaybookSubscription(subscription: PlaybookSubscription): PlaybookSubscription;
523
+
524
+ declare const FOUNDRY_SCHEDULE_BRAND: unique symbol;
525
+ type FoundryScheduleTimingInput = {
526
+ readonly kind: "at";
527
+ readonly at: string;
528
+ } | {
529
+ readonly kind: "after";
530
+ readonly duration: string;
531
+ } | {
532
+ readonly kind: "every";
533
+ readonly interval: string;
534
+ } | {
535
+ readonly kind: "cron";
536
+ readonly expression: string;
537
+ readonly timezone?: string;
538
+ };
539
+ type FoundryScheduleTiming = {
540
+ readonly kind: "at";
541
+ readonly at: string;
542
+ } | {
543
+ readonly kind: "every";
544
+ readonly intervalMs: number;
545
+ } | {
546
+ readonly kind: "cron";
547
+ readonly expression: string;
548
+ readonly timezone: string;
549
+ };
550
+ interface DefineFoundryScheduleOptions {
551
+ /** Stable semantic name within one agent definition. It is not a runtime id. */
552
+ readonly name: string;
553
+ readonly description?: string;
554
+ readonly message: string;
555
+ readonly payload?: unknown;
556
+ readonly timing: FoundryScheduleTimingInput;
557
+ readonly enabled?: boolean;
558
+ }
559
+ type FoundryScheduleDefinition = Readonly<DefineFoundryScheduleOptions> & {
560
+ readonly [FOUNDRY_SCHEDULE_BRAND]: true;
561
+ };
562
+ declare function defineSchedule(options: DefineFoundryScheduleOptions): FoundryScheduleDefinition;
563
+ declare function isFoundrySchedule(value: unknown): value is FoundryScheduleDefinition;
564
+
565
+ interface AgentInstance {
566
+ readonly id: string;
567
+ readonly definitionId: string;
568
+ readonly workspaceId: string;
569
+ /** Stable adapter-enforced key used by lazy subscription provisioning. */
570
+ readonly provisioningKey?: string;
571
+ readonly context: Readonly<Record<string, unknown>>;
572
+ /** Persisted desired state. Definitions only provide the capability catalogue. */
573
+ readonly installations: ReadonlyArray<AgentInstallation>;
574
+ readonly playbooks: ReadonlyArray<AgentPlaybook>;
575
+ readonly createdAt: string;
576
+ readonly updatedAt: string;
577
+ }
578
+ interface Conversation {
579
+ readonly id: string;
580
+ readonly agentId: string;
581
+ readonly workspaceId: string;
582
+ readonly title?: string;
583
+ readonly context: Readonly<Record<string, unknown>>;
584
+ readonly createdAt: string;
585
+ readonly updatedAt: string;
586
+ }
587
+ interface WorkspaceEntry {
588
+ readonly workspaceId: string;
589
+ readonly key: string;
590
+ readonly value: unknown;
591
+ readonly updatedAt: string;
592
+ }
593
+ interface SharedInboxItem {
594
+ readonly id: string;
595
+ readonly workspaceId: string;
596
+ readonly conversationId?: string;
597
+ readonly agentId?: string;
598
+ readonly topic: string;
599
+ readonly payload: unknown;
600
+ readonly status: "pending" | "resolved" | "dismissed";
601
+ readonly createdAt: string;
602
+ readonly updatedAt: string;
603
+ }
604
+ interface EnvironmentValue {
605
+ readonly key: string;
606
+ /** Secret values are deliberately never exposed through this primitive. */
607
+ readonly value: unknown;
608
+ readonly scope: "workspace" | "agent" | "conversation";
609
+ readonly workspaceId: string;
610
+ readonly agentId?: string;
611
+ readonly conversationId?: string;
612
+ }
613
+ interface FoundryTask {
614
+ readonly id: string;
615
+ readonly workspaceId: string;
616
+ readonly agentId?: string;
617
+ readonly conversationId?: string;
618
+ readonly title: string;
619
+ readonly detail?: string;
620
+ readonly status: "open" | "in-progress" | "completed" | "cancelled";
621
+ readonly createdAt: string;
622
+ readonly updatedAt: string;
623
+ }
624
+ interface InboundDeliveryClaim {
625
+ readonly key: string;
626
+ readonly status: "pending" | "completed";
627
+ readonly runIds: ReadonlyArray<string>;
628
+ readonly claimedAt: string;
629
+ readonly completedAt?: string;
630
+ }
631
+ interface FoundryWorkingEnvironmentSnapshotOwner {
632
+ readonly scope: "agent" | "conversation";
633
+ readonly definitionId: string;
634
+ readonly agentId: string;
635
+ readonly conversationId: string;
636
+ readonly workspaceId: string;
637
+ }
638
+ /**
639
+ * Adapter-backed runtime data created by Foundry's scheduling and sleep tools.
640
+ * This is reconstructed state, never a file-authored definition primitive.
641
+ */
642
+ interface FoundryActivationRecord {
643
+ readonly id: string;
644
+ readonly kind: "scheduled" | "sleep";
645
+ readonly definitionId: string;
646
+ readonly agentId: string;
647
+ readonly conversationId: string;
648
+ readonly workspaceId: string;
649
+ readonly message: string;
650
+ readonly payload?: unknown;
651
+ readonly timing: FoundryScheduleTiming;
652
+ readonly origin: "agent-definition" | "agent-tool";
653
+ readonly scheduleName?: string;
654
+ /** Hash of the last reconciled definition value; runtime edits remain overrides. */
655
+ readonly definitionRevision?: string;
656
+ readonly status: "pending" | "active" | "completed" | "cancelled";
657
+ readonly createdByRunId: string;
658
+ readonly lastRunId?: string;
659
+ readonly createdAt: string;
660
+ readonly updatedAt: string;
661
+ }
662
+ interface FoundryDataAdapter {
663
+ readonly identifier: string;
664
+ getAgent(id: string): Effect.Effect<AgentInstance | null, unknown, never>;
665
+ putAgent(agent: AgentInstance): Effect.Effect<void, unknown, never>;
666
+ listAgents(definitionId?: string): Effect.Effect<ReadonlyArray<AgentInstance>, unknown, never>;
667
+ provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, unknown, never>;
668
+ getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, unknown, never>;
669
+ putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, unknown, never>;
670
+ deletePlaybookSubscription(id: string): Effect.Effect<boolean, unknown, never>;
671
+ listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<ReadonlyArray<PlaybookSubscription>, unknown, never>;
672
+ getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, unknown, never>;
673
+ claimInboundDelivery(key: string): Effect.Effect<boolean, unknown, never>;
674
+ completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, unknown, never>;
675
+ releaseInboundDelivery(key: string): Effect.Effect<void, unknown, never>;
676
+ getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, unknown, never>;
677
+ putActivation(activation: FoundryActivationRecord): Effect.Effect<void, unknown, never>;
678
+ listActivations(workspaceId?: string): Effect.Effect<ReadonlyArray<FoundryActivationRecord>, unknown, never>;
679
+ getConversation(id: string): Effect.Effect<Conversation | null, unknown, never>;
680
+ putConversation(conversation: Conversation): Effect.Effect<void, unknown, never>;
681
+ listConversations(agentId: string): Effect.Effect<ReadonlyArray<Conversation>, unknown, never>;
682
+ getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, unknown, never>;
683
+ putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, unknown, never>;
684
+ listWorkspaceEntries(workspaceId: string): Effect.Effect<ReadonlyArray<WorkspaceEntry>, unknown, never>;
685
+ /** Private VFS persistence; snapshots are never exposed as workspace entries. */
686
+ getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, unknown, never>;
687
+ putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, unknown, never>;
688
+ putInboxItem(item: SharedInboxItem): Effect.Effect<void, unknown, never>;
689
+ listInboxItems(workspaceId: string): Effect.Effect<ReadonlyArray<SharedInboxItem>, unknown, never>;
690
+ putTask(task: FoundryTask): Effect.Effect<void, unknown, never>;
691
+ listTasks(workspaceId: string): Effect.Effect<ReadonlyArray<FoundryTask>, unknown, never>;
692
+ listEnvironment(scope: {
693
+ readonly workspaceId: string;
694
+ readonly agentId?: string;
695
+ readonly conversationId?: string;
696
+ }): Effect.Effect<ReadonlyArray<EnvironmentValue>, unknown, never>;
697
+ }
698
+ /** The exact request shape accepted by `Glove.processRequest`. */
699
+ type FoundryMessageInput = string | ReadonlyArray<ContentPart>;
700
+ interface FoundryRequest {
701
+ readonly agentId: string;
702
+ readonly conversationId: string;
703
+ readonly workspaceId: string;
704
+ readonly message: FoundryMessageInput;
705
+ readonly payload?: unknown;
706
+ readonly context?: Readonly<Record<string, unknown>>;
707
+ readonly source?: {
708
+ readonly kind: "direct" | "transmission" | "activation" | "spawn" | "background";
709
+ readonly id?: string;
710
+ readonly provider?: string;
711
+ readonly eventId?: string;
712
+ readonly threadKey?: string;
713
+ };
714
+ }
715
+ /**
716
+ * Normalize Foundry's wire input into the native user `Message` seen by the
717
+ * Glove loop. Lazy assembly happens before hooks run, so this intentionally
718
+ * represents the unmodified inbound turn.
719
+ */
720
+ declare function toGloveMessage(input: FoundryMessageInput): Message;
721
+ /** Clone readonly request parts for Glove's mutable public input signature. */
722
+ declare function toGloveRequestInput(input: FoundryMessageInput): string | ContentPart[];
723
+ interface FoundryResult {
724
+ readonly status: "completed" | "suspended";
725
+ readonly value: unknown;
726
+ readonly agentId: string;
727
+ readonly conversationId: string;
728
+ readonly workspaceId: string;
729
+ readonly suspension?: {
730
+ readonly commandId: string;
731
+ readonly wakeAt: string;
732
+ };
733
+ }
734
+ interface CreateAgentInstanceOptions {
735
+ readonly id?: string;
736
+ readonly workspaceId?: string;
737
+ readonly context?: Readonly<Record<string, unknown>>;
738
+ readonly installations?: ReadonlyArray<AgentInstallation>;
739
+ readonly playbooks?: ReadonlyArray<AgentPlaybook>;
740
+ }
741
+ interface ProvisionAgentOptions extends CreateAgentInstanceOptions {
742
+ readonly definitionId: string;
743
+ readonly provisioningKey: string;
744
+ }
745
+ interface UpdateAgentInstanceOptions {
746
+ readonly context?: Readonly<Record<string, unknown>>;
747
+ readonly installations?: ReadonlyArray<AgentInstallation>;
748
+ readonly playbooks?: ReadonlyArray<AgentPlaybook>;
749
+ }
750
+ interface CreateConversationOptions {
751
+ readonly id?: string;
752
+ readonly workspaceId?: string;
753
+ readonly title?: string;
754
+ readonly context?: Readonly<Record<string, unknown>>;
755
+ }
756
+ declare class MemoryFoundryDataAdapter implements FoundryDataAdapter {
757
+ readonly identifier: string;
758
+ private readonly agents;
759
+ private readonly agentsByProvisioningKey;
760
+ private readonly subscriptions;
761
+ private readonly inboundDeliveries;
762
+ private readonly activations;
763
+ private readonly conversations;
764
+ private readonly workspace;
765
+ private readonly workingEnvironments;
766
+ private readonly inbox;
767
+ private readonly tasks;
768
+ private readonly environment;
769
+ private pendingAgents;
770
+ private pendingSubscriptions;
771
+ constructor(options?: {
772
+ readonly identifier?: string;
773
+ readonly environment?: ReadonlyArray<EnvironmentValue>;
774
+ readonly agents?: ReadonlyArray<AgentInstance>;
775
+ readonly conversations?: ReadonlyArray<Conversation>;
776
+ readonly subscriptions?: ReadonlyArray<PlaybookSubscription>;
777
+ readonly activations?: ReadonlyArray<FoundryActivationRecord>;
778
+ });
779
+ /** Resolve file-owned identities only after Foundry discovery has bound them. */
780
+ private materializeSeeds;
781
+ getAgent(id: string): Effect.Effect<AgentInstance | null, never, never>;
782
+ putAgent(agent: AgentInstance): Effect.Effect<void, never, never>;
783
+ listAgents(definitionId?: string): Effect.Effect<AgentInstance[], never, never>;
784
+ provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, never, never>;
785
+ getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, never, never>;
786
+ putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, never, never>;
787
+ deletePlaybookSubscription(id: string): Effect.Effect<boolean, never, never>;
788
+ listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<PlaybookSubscription[], never, never>;
789
+ getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, never, never>;
790
+ claimInboundDelivery(key: string): Effect.Effect<boolean, never, never>;
791
+ completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, never, never>;
792
+ releaseInboundDelivery(key: string): Effect.Effect<void, never, never>;
793
+ getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, never, never>;
794
+ putActivation(activation: FoundryActivationRecord): Effect.Effect<void, never, never>;
795
+ listActivations(workspaceId?: string): Effect.Effect<FoundryActivationRecord[], never, never>;
796
+ getConversation(id: string): Effect.Effect<Conversation | null, never, never>;
797
+ putConversation(conversation: Conversation): Effect.Effect<void, never, never>;
798
+ listConversations(agentId: string): Effect.Effect<Conversation[], never, never>;
799
+ getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, never, never>;
800
+ putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, never, never>;
801
+ listWorkspaceEntries(workspaceId: string): Effect.Effect<WorkspaceEntry[], never, never>;
802
+ getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, never, never>;
803
+ putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, never, never>;
804
+ putInboxItem(item: SharedInboxItem): Effect.Effect<void, never, never>;
805
+ listInboxItems(workspaceId: string): Effect.Effect<SharedInboxItem[], never, never>;
806
+ putTask(task: FoundryTask): Effect.Effect<void, never, never>;
807
+ listTasks(workspaceId: string): Effect.Effect<FoundryTask[], never, never>;
808
+ listEnvironment(scope: {
809
+ readonly workspaceId: string;
810
+ readonly agentId?: string;
811
+ readonly conversationId?: string;
812
+ }): Effect.Effect<EnvironmentValue[], never, never>;
813
+ }
814
+ declare function createAgentInstance(definitionId: string, options?: CreateAgentInstanceOptions, provisioningKey?: string): AgentInstance;
815
+ /** Code-authoring helper; instance data stores the referenced definition id. */
816
+ declare function defineAgentInstance(definition: FoundryAgentDefinition, options?: CreateAgentInstanceOptions): AgentInstance;
817
+ /** Rehydrate a durable adapter record into Foundry's immutable runtime shape. */
818
+ declare function reconstructAgentInstance(agent: AgentInstance): AgentInstance;
819
+ declare function createConversation(agent: AgentInstance, options?: CreateConversationOptions): Conversation;
820
+
821
+ declare const FOUNDRY_SHARED_TOOL_BRAND: unique symbol;
822
+ declare const FOUNDRY_AGENT_APPLICATION_BRAND: unique symbol;
823
+ declare const FOUNDRY_MCP_BRAND: unique symbol;
824
+ declare const FOUNDRY_MEMORY_BRAND: unique symbol;
825
+ type AgentInstallationKind = "tool" | "application" | "mcp";
826
+ type FoundryCapabilityKind = AgentInstallationKind | "memory";
827
+ interface AgentInstallation {
828
+ readonly kind: AgentInstallationKind;
829
+ readonly id: string;
830
+ /** Durable account selection; code authoring supplies this through an AccountReference. */
831
+ readonly accountId?: string;
832
+ readonly config?: unknown;
833
+ }
834
+ type FoundryInstallable = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp;
835
+ /** Create persisted installation data from a code definition. */
836
+ type DefinitionConfigInput<TDefinition> = TDefinition extends {
837
+ readonly config?: infer TSchema;
838
+ } ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
839
+ interface InstallationSelection {
840
+ readonly account?: AccountReference;
841
+ }
842
+ declare function install<TDefinition extends FoundryInstallable>(capability: TDefinition, ...configuration: [DefinitionConfigInput<TDefinition>] extends [never] ? [config?: never, selection?: InstallationSelection] : [config: DefinitionConfigInput<TDefinition>, selection?: InstallationSelection]): AgentInstallation;
843
+ declare function installationKey(installation: AgentInstallation): string;
844
+ interface AgentMountBaseContext {
845
+ readonly definitionId: string;
846
+ readonly agentId: string;
847
+ readonly conversationId: string;
848
+ readonly workspaceId: string;
849
+ readonly runId: string;
850
+ readonly input: unknown;
851
+ readonly request: FoundryRequest;
852
+ readonly message: Message;
853
+ readonly messageInput: FoundryMessageInput;
854
+ readonly messageText: string;
855
+ readonly history: ReadonlyArray<Message>;
856
+ readonly messages: ReadonlyArray<Message>;
857
+ readonly glove: IGloveRunnable;
858
+ readonly store: StoreAdapter;
859
+ readonly emit: (event: {
860
+ type: string;
861
+ data?: unknown;
862
+ }) => void;
863
+ }
864
+ interface AgentInstallContext<TConfig = unknown> extends AgentMountBaseContext {
865
+ readonly installation: AgentInstallation;
866
+ readonly config: TConfig;
867
+ readonly accountId?: string;
868
+ readonly withAccountSession?: <A>(operation: string, use: (session: unknown) => Effect.Effect<A, unknown, never>) => Effect.Effect<A, unknown, never>;
869
+ }
870
+ interface AgentDefinitionSurfaceContext extends AgentMountBaseContext {
871
+ readonly surface: {
872
+ readonly kind: "memory";
873
+ readonly id: string;
874
+ };
875
+ readonly config: unknown;
876
+ }
877
+ /** Pure application-definition context. It deliberately exposes no Glove. */
878
+ type AgentApplicationInstallContext<TConfig = unknown> = Omit<AgentInstallContext<TConfig>, "glove" | "store">;
879
+ interface AgentApplicationContribution {
880
+ /** Tools Foundry will mount after the installer returns. */
881
+ readonly tools?: ReadonlyArray<GloveFoldArgs<any>>;
882
+ }
883
+ interface ConfiguredCapability<TConfigSchema extends z.ZodType | undefined = z.ZodType | undefined> {
884
+ /** @deprecated File-routed definitions derive identity from their filename. */
885
+ readonly id?: string;
886
+ readonly description: string;
887
+ readonly config?: TConfigSchema;
888
+ }
889
+ type SharedToolOptions<TInput = unknown, TConfigSchema extends z.ZodType | undefined = undefined> = ConfiguredCapability<TConfigSchema> & ({
890
+ readonly tool: GloveFoldArgs<TInput>;
891
+ readonly create?: never;
892
+ } | {
893
+ readonly tool?: never;
894
+ readonly create: (context: AgentInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<GloveFoldArgs<TInput>, unknown, never>;
895
+ });
896
+ type FoundrySharedTool<TInput = unknown, TConfigSchema extends z.ZodType | undefined = any> = Readonly<SharedToolOptions<TInput, TConfigSchema>> & {
897
+ readonly id: string;
898
+ readonly [FOUNDRY_SHARED_TOOL_BRAND]: true;
899
+ };
900
+ declare function defineSharedTool<TInput, const TConfigSchema extends z.ZodType | undefined = undefined>(options: SharedToolOptions<TInput, TConfigSchema>): FoundrySharedTool<TInput, TConfigSchema>;
901
+ interface AgentApplicationOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
902
+ /** Inbound transmission mechanisms owned by this application. */
903
+ readonly inbound?: ReadonlyArray<AnyFoundryTransmission>;
904
+ /** Outbound transmission mechanisms mounted as tools when installed. */
905
+ readonly outbound?: ReadonlyArray<AnyFoundryTransmission>;
906
+ /** Mixed/bidirectional definitions; prefer inbound/outbound for clarity. */
907
+ readonly transmissions?: ReadonlyArray<AnyFoundryTransmission>;
908
+ /** Purpose-built long-lived provider connections for inbound transmissions. */
909
+ readonly connections?: ReadonlyArray<FoundryApplicationConnection>;
910
+ readonly install?: (context: AgentApplicationInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<AgentApplicationContribution | void, unknown, never>;
911
+ }
912
+ type FoundryAgentApplication<TConfigSchema extends z.ZodType | undefined = any> = Readonly<AgentApplicationOptions<TConfigSchema>> & {
913
+ readonly id: string;
914
+ readonly [FOUNDRY_AGENT_APPLICATION_BRAND]: true;
915
+ };
916
+ declare function defineAgentApplication<const TConfigSchema extends z.ZodType | undefined = undefined>(options: AgentApplicationOptions<TConfigSchema>): FoundryAgentApplication<TConfigSchema>;
917
+ /** Concise authoring name for an agent-local application definition. */
918
+ declare const defineApp: typeof defineAgentApplication;
919
+ type FoundryApp = FoundryAgentApplication;
920
+ interface FoundryMcpOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
921
+ /** @deprecated File-routed definitions derive identity from their filename. */
922
+ readonly id?: string;
923
+ readonly description?: string;
924
+ readonly config?: TConfigSchema;
925
+ readonly entry: Omit<McpCatalogueEntry, "id">;
926
+ }
927
+ type FoundryMcp<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMcpOptions<TConfigSchema>> & {
928
+ readonly id: string;
929
+ readonly [FOUNDRY_MCP_BRAND]: true;
930
+ };
931
+ declare function defineMcp<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMcpOptions<TConfigSchema>): FoundryMcp<TConfigSchema>;
932
+ type MemoryAdapterFactory<A> = (context: AgentDefinitionSurfaceContext) => Effect.Effect<A, unknown, never>;
933
+ interface MemorySurfaceOptions {
934
+ readonly access?: "reader" | "curator";
935
+ readonly tools?: MemoryToolOptions["tools"];
936
+ }
937
+ interface FoundryMemoryProfileOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
938
+ readonly entity?: MemorySurfaceOptions & {
939
+ readonly adapter: MemoryAdapterFactory<EntityMemoryAdapter>;
940
+ };
941
+ readonly episodic?: MemorySurfaceOptions & {
942
+ readonly adapter: MemoryAdapterFactory<EpisodicMemoryAdapter>;
943
+ };
944
+ readonly resources?: MemorySurfaceOptions & {
945
+ readonly adapter: MemoryAdapterFactory<ResourceFsAdapter>;
946
+ };
947
+ /** Ambient context remains on the main agent, matching glove-memory. */
948
+ readonly context?: {
949
+ readonly adapter: MemoryAdapterFactory<ContextAdapter>;
950
+ readonly tools?: MemoryToolOptions["tools"];
951
+ };
952
+ /** Escape hatch for subagent-delegated or application-specific composition. */
953
+ readonly mount?: (context: AgentDefinitionSurfaceContext) => Effect.Effect<void, unknown, never>;
954
+ }
955
+ type FoundryMemoryProfile<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMemoryProfileOptions<TConfigSchema>> & {
956
+ readonly id: string;
957
+ readonly [FOUNDRY_MEMORY_BRAND]: true;
958
+ };
959
+ declare function defineMemory<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMemoryProfileOptions<TConfigSchema>): FoundryMemoryProfile<TConfigSchema>;
960
+ interface FoundryCapabilityRegistry {
961
+ readonly tools: ReadonlyArray<FoundrySharedTool<any>>;
962
+ readonly applications: ReadonlyArray<FoundryAgentApplication>;
963
+ readonly mcp: ReadonlyArray<FoundryMcp>;
964
+ readonly memory: ReadonlyArray<FoundryMemoryProfile>;
965
+ }
966
+ interface FoundryCapabilityManifestEntry {
967
+ readonly id: string;
968
+ readonly kind: FoundryCapabilityKind;
969
+ readonly description: string;
970
+ readonly ownership: "instance" | "definition";
971
+ readonly file?: string;
972
+ }
973
+ interface FoundryCapabilityManifest {
974
+ readonly tools: ReadonlyArray<FoundryCapabilityManifestEntry>;
975
+ readonly applications: ReadonlyArray<FoundryCapabilityManifestEntry>;
976
+ readonly mcp: ReadonlyArray<FoundryCapabilityManifestEntry>;
977
+ readonly memory: ReadonlyArray<FoundryCapabilityManifestEntry>;
978
+ }
979
+ declare const EMPTY_CAPABILITY_REGISTRY: FoundryCapabilityRegistry;
980
+ interface McpAdapterFactory {
981
+ (context: Omit<AgentInstallContext, "installation" | "config"> & {
982
+ readonly installed: ReadonlyArray<FoundryMcp>;
983
+ }): Effect.Effect<McpAdapter, unknown, never>;
984
+ }
985
+ declare function isInboxCapableStore(store: StoreAdapter): store is StoreAdapter & Required<Pick<StoreAdapter, "getInboxItems" | "addInboxItem" | "updateInboxItem" | "getResolvedInboxItems">>;
986
+ interface FoundryMemoryReference<TProfile extends FoundryMemoryProfile<any> = FoundryMemoryProfile<any>> {
987
+ readonly profile: TProfile;
988
+ readonly config: DefinitionConfigInput<TProfile>;
989
+ }
990
+ type FoundryMemorySelection = FoundryMemoryProfile | FoundryMemoryReference;
991
+ /** Select a configured memory profile with schema-inferred input. */
992
+ declare function configureMemory<TProfile extends FoundryMemoryProfile<any>>(profile: TProfile, config: DefinitionConfigInput<TProfile>): FoundryMemoryReference<TProfile>;
993
+ interface MountAgentDefinitionMemoryOptions {
994
+ readonly registry: FoundryCapabilityRegistry;
995
+ readonly memory: ReadonlyArray<FoundryMemorySelection>;
996
+ readonly context: Omit<AgentDefinitionSurfaceContext, "surface" | "config">;
997
+ }
998
+ /** Mount definition-owned memory surfaces for one assembled run. */
999
+ declare function mountAgentDefinitionMemory(options: MountAgentDefinitionMemoryOptions): Effect.Effect<void, unknown, never>;
1000
+ interface InstallRegistryOptions {
1001
+ readonly registry: FoundryCapabilityRegistry;
1002
+ readonly installations: ReadonlyArray<AgentInstallation>;
1003
+ readonly context: Omit<AgentInstallContext, "installation" | "config">;
1004
+ readonly mcpAdapter?: McpAdapterFactory;
1005
+ readonly accountSessions?: FoundryAccountSessionAdapter;
1006
+ }
1007
+ interface FoundryAccountSessionAdapter {
1008
+ readonly identifier: string;
1009
+ withSession<A>(request: {
1010
+ readonly accountId: string;
1011
+ readonly operation: string;
1012
+ readonly agentId: string;
1013
+ readonly conversationId: string;
1014
+ readonly workspaceId: string;
1015
+ }, use: (session: unknown) => Effect.Effect<A, unknown, never>): Effect.Effect<A, unknown, never>;
1016
+ }
1017
+ /** Install only explicitly selected capabilities onto a running Glove. */
1018
+ declare function installRegistry(options: InstallRegistryOptions): Effect.Effect<ReadonlyArray<AgentInstallation>, unknown, never>;
1019
+ declare function isFoundryCapability(value: unknown): boolean;
1020
+
1021
+ declare const FOUNDRY_WORKING_ENVIRONMENT_BRAND: unique symbol;
1022
+ declare const FOUNDRY_REPL_BRAND: unique symbol;
1023
+ type FoundryVfs = Vfs;
1024
+ type FoundryVfsHandle = EnvFsHandle;
1025
+ interface FoundryWorkingEnvironmentPersistenceContext {
1026
+ readonly definitionId: string;
1027
+ readonly agentId: string;
1028
+ readonly conversationId: string;
1029
+ readonly workspaceId: string;
1030
+ readonly runId: string;
1031
+ readonly data: FoundryDataAdapter;
1032
+ readonly signal: AbortSignal;
1033
+ }
1034
+ /**
1035
+ * Storage is deliberately adapter-owned. Foundry never chooses a database,
1036
+ * object store, locking policy, or credential lifecycle for an environment.
1037
+ */
1038
+ interface FoundryWorkingEnvironmentPersistenceAdapter {
1039
+ readonly identifier: string;
1040
+ readonly load: (context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<EnvSnapshot | null>;
1041
+ readonly save: (snapshot: EnvSnapshot, context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<void>;
1042
+ }
1043
+ interface FoundryWorkingEnvironmentCreateContext {
1044
+ readonly assembly: AgentAssemblyContext<FoundryRequest>;
1045
+ readonly snapshot: EnvSnapshot | null;
1046
+ }
1047
+ interface DefineFoundryWorkingEnvironmentOptions {
1048
+ /**
1049
+ * Build the native Glove environment. Use this when creation itself needs
1050
+ * custom logic. The loaded snapshot is provided but never applied implicitly.
1051
+ */
1052
+ readonly create?: (context: FoundryWorkingEnvironmentCreateContext) => Resolvable<WorkingEnvironment>;
1053
+ /**
1054
+ * Native environment options. When persistence returns a snapshot and no
1055
+ * filesystem is supplied, Foundry restores that snapshot automatically.
1056
+ */
1057
+ readonly options?: CreateWorkingEnvironmentOptions | ((context: FoundryWorkingEnvironmentCreateContext) => Resolvable<CreateWorkingEnvironmentOptions>);
1058
+ readonly persistence?: FoundryWorkingEnvironmentPersistenceAdapter;
1059
+ /** Native mount behavior: prompt priming and optional tool prefix. */
1060
+ readonly mount?: Omit<MountWorkingEnvironmentConfig, "env">;
1061
+ /** Close worker/adaptor resources after the run. Default true. */
1062
+ readonly close?: boolean;
1063
+ }
1064
+ type FoundryWorkingEnvironmentDefinition = Readonly<DefineFoundryWorkingEnvironmentOptions> & {
1065
+ readonly [FOUNDRY_WORKING_ENVIRONMENT_BRAND]: true;
1066
+ };
1067
+ declare function defineWorkingEnvironment(options?: DefineFoundryWorkingEnvironmentOptions): FoundryWorkingEnvironmentDefinition;
1068
+ /**
1069
+ * Convenience persistence over the configured FoundryDataAdapter's private
1070
+ * snapshot seam. VFS contents never become public workspace entries.
1071
+ */
1072
+ declare function foundryDataEnvironmentPersistence(options?: {
1073
+ readonly scope?: "agent" | "conversation";
1074
+ }): FoundryWorkingEnvironmentPersistenceAdapter;
1075
+ interface FoundryReplBase {
1076
+ readonly [FOUNDRY_REPL_BRAND]: true;
1077
+ }
1078
+ type FoundryJavaScriptReplDefinition = FoundryReplBase & Readonly<{
1079
+ readonly language: "javascript";
1080
+ readonly session: JsSession;
1081
+ readonly mount?: Omit<MountJsConfig, "session">;
1082
+ }>;
1083
+ type FoundryPythonReplDefinition = FoundryReplBase & Readonly<{
1084
+ readonly language: "python";
1085
+ readonly session: PySession;
1086
+ readonly mount?: Omit<MountPyConfig, "session">;
1087
+ }>;
1088
+ type FoundryLispReplDefinition = FoundryReplBase & Readonly<{
1089
+ readonly language: "lisp";
1090
+ readonly session: LispSession;
1091
+ readonly mount?: Omit<MountLispConfig, "session">;
1092
+ }>;
1093
+ type FoundryReplDefinition = FoundryJavaScriptReplDefinition | FoundryPythonReplDefinition | FoundryLispReplDefinition;
1094
+ type DefineFoundryReplOptions = Omit<FoundryJavaScriptReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryPythonReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryLispReplDefinition, typeof FOUNDRY_REPL_BRAND>;
1095
+ declare function defineRepl(options: DefineFoundryReplOptions): FoundryReplDefinition;
1096
+ type FoundryMountedRepl = Readonly<{
1097
+ readonly language: "javascript";
1098
+ readonly session: JsSession;
1099
+ }> | Readonly<{
1100
+ readonly language: "python";
1101
+ readonly session: PySession;
1102
+ }> | Readonly<{
1103
+ readonly language: "lisp";
1104
+ readonly session: LispSession;
1105
+ }>;
1106
+
1107
+ declare const FOUNDRY_LAYER_BRAND: unique symbol;
1108
+ declare const FOUNDRY_SUBSCRIBER_BRAND: unique symbol;
1109
+ interface FoundrySurfaceContext<TInput = unknown> {
1110
+ readonly definitionId: string;
1111
+ readonly agentId: string;
1112
+ readonly conversationId: string;
1113
+ readonly workspaceId: string;
1114
+ readonly runId: string;
1115
+ readonly input: TInput;
1116
+ readonly request: FoundryRequest;
1117
+ readonly message: Message;
1118
+ readonly messageInput: FoundryMessageInput;
1119
+ readonly messageText: string;
1120
+ readonly history: ReadonlyArray<Message>;
1121
+ readonly messages: ReadonlyArray<Message>;
1122
+ readonly glove: IGloveRunnable;
1123
+ readonly workingEnvironment?: WorkingEnvironment;
1124
+ readonly vfs?: FoundryVfsHandle;
1125
+ readonly repl?: FoundryMountedRepl;
1126
+ readonly signal: AbortSignal;
1127
+ readonly emit: (event: {
1128
+ type: string;
1129
+ data?: unknown;
1130
+ }) => void;
1131
+ }
1132
+ type FoundrySurfaceCleanup = () => void | Promise<void> | Effect.Effect<void, unknown, never>;
1133
+ interface FoundryLayerOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
1134
+ /** @deprecated File-routed definitions derive identity from their filename. */
1135
+ readonly id?: string;
1136
+ readonly description: string;
1137
+ readonly config?: TConfigSchema;
1138
+ /**
1139
+ * Mount any Glove-native package or application concern onto the compiled
1140
+ * runnable. Mesh, memory subagent composition, scratchpads, image surfaces,
1141
+ * voice bridges and future Glove packages all fit through this seam.
1142
+ */
1143
+ readonly setup: (context: FoundrySurfaceContext & {
1144
+ readonly config: TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown;
1145
+ }) => Effect.Effect<void | FoundrySurfaceCleanup, unknown, never>;
1146
+ }
1147
+ type FoundryLayer<TConfigSchema extends z.ZodType | undefined = undefined> = Readonly<FoundryLayerOptions<TConfigSchema>> & {
1148
+ readonly id: string;
1149
+ readonly [FOUNDRY_LAYER_BRAND]: true;
1150
+ };
1151
+ declare function defineLayer<TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryLayerOptions<TConfigSchema>): FoundryLayer<TConfigSchema>;
1152
+ interface FoundryLayerReference<TLayer extends FoundryLayer<any> = FoundryLayer<any>> {
1153
+ readonly layer: TLayer;
1154
+ readonly config?: TLayer extends FoundryLayer<infer TSchema> ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
1155
+ }
1156
+ type FoundryLayerSelection = FoundryLayerReference<any> | FoundryLayer<any>;
1157
+ /** Select a configured layer with schema-inferred input. */
1158
+ declare function configureLayer<TLayer extends FoundryLayer<any>>(layer: TLayer, config: FoundryLayerReference<TLayer>["config"]): FoundryLayerReference<TLayer>;
1159
+ interface FoundrySubscriberOptions {
1160
+ /** @deprecated File-routed definitions derive identity from their filename. */
1161
+ readonly id?: string;
1162
+ readonly description: string;
1163
+ readonly create: SubscriberAdapter | ((context: FoundrySurfaceContext) => SubscriberAdapter | Promise<SubscriberAdapter> | Effect.Effect<SubscriberAdapter, unknown, never>);
1164
+ }
1165
+ type FoundrySubscriber = Readonly<FoundrySubscriberOptions> & {
1166
+ readonly id: string;
1167
+ readonly [FOUNDRY_SUBSCRIBER_BRAND]: true;
1168
+ };
1169
+ declare function defineSubscriber(options: FoundrySubscriberOptions): FoundrySubscriber;
1170
+ type FoundrySubscriberSelection = FoundrySubscriber;
1171
+ interface FoundryNativeRegistry {
1172
+ readonly layers: ReadonlyArray<FoundryLayer<any>>;
1173
+ readonly subscribers: ReadonlyArray<FoundrySubscriber>;
1174
+ }
1175
+ interface FoundryNativeManifestEntry {
1176
+ readonly id: string;
1177
+ readonly kind: "layer" | "subscriber";
1178
+ readonly description: string;
1179
+ readonly file?: string;
1180
+ }
1181
+ interface FoundryNativeManifest {
1182
+ readonly layers: ReadonlyArray<FoundryNativeManifestEntry>;
1183
+ readonly subscribers: ReadonlyArray<FoundryNativeManifestEntry>;
1184
+ }
1185
+ declare const EMPTY_NATIVE_REGISTRY: FoundryNativeRegistry;
1186
+ declare function mountFoundrySurfaces(options: {
1187
+ readonly registry: FoundryNativeRegistry;
1188
+ readonly layers?: ReadonlyArray<FoundryLayerSelection>;
1189
+ readonly subscribers?: ReadonlyArray<FoundrySubscriberSelection | SubscriberAdapter>;
1190
+ readonly context: FoundrySurfaceContext;
1191
+ }): Promise<() => Promise<void>>;
1192
+ declare function isFoundryLayer(value: unknown): value is FoundryLayer;
1193
+ declare function isFoundrySubscriber(value: unknown): value is FoundrySubscriber;
1194
+
1195
+ type FoundryAgentComponent = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp | FoundryMemoryProfile | FoundryLayer<any> | FoundrySubscriber;
1196
+ interface FoundryAgentComposition {
1197
+ readonly capabilities: FoundryCapabilityRegistry;
1198
+ readonly native: FoundryNativeRegistry;
1199
+ }
1200
+ type FoundryCompositionSource = FoundryAgentComponent | FoundryAgentComposition | ReadonlyArray<FoundryCompositionSource> | (() => FoundryCompositionSource) | false | null | undefined;
1201
+ /**
1202
+ * Compose colocated, headless agent parts into one immutable catalogue.
1203
+ * Functions are factories, not runtime installers: they return definitions and
1204
+ * never receive or mutate a Glove instance.
1205
+ */
1206
+ declare function composeAgent(...sources: ReadonlyArray<FoundryCompositionSource>): FoundryAgentComposition;
1207
+ declare const EMPTY_AGENT_COMPOSITION: FoundryAgentComposition;
1208
+
1209
+ declare const FOUNDRY_CORE_COMMAND_EVENT = "foundry.core.command";
1210
+ type FoundryCoreCommand = {
1211
+ readonly id: string;
1212
+ readonly type: "spawn";
1213
+ readonly definitionId: string;
1214
+ readonly agentId?: string;
1215
+ readonly conversationId?: string;
1216
+ readonly workspaceId: string;
1217
+ readonly message: string;
1218
+ readonly payload?: unknown;
1219
+ } | {
1220
+ readonly id: string;
1221
+ readonly type: "schedule";
1222
+ readonly definitionId: string;
1223
+ readonly agentId?: string;
1224
+ readonly conversationId?: string;
1225
+ readonly workspaceId: string;
1226
+ readonly message: string;
1227
+ readonly payload?: unknown;
1228
+ readonly timing: {
1229
+ readonly kind: "at";
1230
+ readonly at: string;
1231
+ } | {
1232
+ readonly kind: "every";
1233
+ readonly intervalMs: number;
1234
+ } | {
1235
+ readonly kind: "cron";
1236
+ readonly expression: string;
1237
+ readonly timezone: string;
1238
+ };
1239
+ } | {
1240
+ readonly id: string;
1241
+ readonly type: "playbook.sync";
1242
+ readonly definitionId: string;
1243
+ readonly agentId: string;
1244
+ readonly conversationId: string;
1245
+ readonly workspaceId: string;
1246
+ readonly playbooks: ReadonlyArray<AgentPlaybook>;
1247
+ } | {
1248
+ readonly id: string;
1249
+ readonly type: "schedule.sync";
1250
+ readonly definitionId: string;
1251
+ readonly agentId: string;
1252
+ readonly conversationId: string;
1253
+ readonly workspaceId: string;
1254
+ readonly schedules: ReadonlyArray<{
1255
+ readonly id: string;
1256
+ readonly name: string;
1257
+ readonly revision: string;
1258
+ readonly message: string;
1259
+ readonly payload?: unknown;
1260
+ readonly timing: FoundryScheduleTiming;
1261
+ readonly enabled: boolean;
1262
+ }>;
1263
+ } | {
1264
+ readonly id: string;
1265
+ readonly type: "schedule.update";
1266
+ readonly definitionId: string;
1267
+ readonly agentId: string;
1268
+ readonly conversationId: string;
1269
+ readonly workspaceId: string;
1270
+ readonly activationId: string;
1271
+ readonly patch: {
1272
+ readonly message?: string;
1273
+ readonly payload?: unknown;
1274
+ readonly timing?: FoundryScheduleTiming;
1275
+ };
1276
+ } | {
1277
+ readonly id: string;
1278
+ readonly type: "schedule.cancel";
1279
+ readonly definitionId: string;
1280
+ readonly agentId: string;
1281
+ readonly conversationId: string;
1282
+ readonly workspaceId: string;
1283
+ readonly activationId: string;
1284
+ } | {
1285
+ readonly id: string;
1286
+ readonly type: "sleep";
1287
+ readonly definitionId: string;
1288
+ readonly agentId: string;
1289
+ readonly conversationId: string;
1290
+ readonly workspaceId: string;
1291
+ readonly wakeAt: string;
1292
+ readonly message: string;
1293
+ } | {
1294
+ readonly id: string;
1295
+ readonly type: "background";
1296
+ readonly definitionId: string;
1297
+ readonly agentId: string;
1298
+ readonly conversationId: string;
1299
+ readonly workspaceId: string;
1300
+ readonly message: string;
1301
+ readonly payload?: unknown;
1302
+ readonly reconvene: boolean;
1303
+ } | {
1304
+ readonly id: string;
1305
+ readonly type: "transmit";
1306
+ readonly definitionId: string;
1307
+ readonly agentId: string;
1308
+ readonly conversationId: string;
1309
+ readonly workspaceId: string;
1310
+ readonly routeId: string;
1311
+ readonly payload: unknown;
1312
+ readonly applicationId?: string;
1313
+ readonly transmissionId?: string;
1314
+ };
1315
+ /**
1316
+ * Installed apps expose one namespaced Glove tool per outbound transmission.
1317
+ * The tool only queues a parent-runtime command; grants and delivery adapters
1318
+ * remain authoritative outside the agent subprocess.
1319
+ */
1320
+ declare function createInstalledApplicationTransmissionTools(context: AgentAssemblyContext, applications: ReadonlyArray<FoundryAgentApplication>, installations: ReadonlyArray<AgentInstallation>, playbooks?: ReadonlyArray<AgentPlaybook>): ReadonlyArray<GloveFoldArgs<any>>;
1321
+ /** Framework-owned orchestration tools. They emit commands for Foundry's runtime adapters. */
1322
+ declare function createFoundryCoreTools(context: AgentAssemblyContext, desiredSchedules?: Extract<FoundryCoreCommand, {
1323
+ readonly type: "schedule.sync";
1324
+ }>["schedules"]): ReadonlyArray<GloveFoldArgs<any>>;
1325
+
1326
+ declare const FOUNDRY_AGENT_DEFINITION_BRAND: unique symbol;
1327
+ /** @deprecated Agent modules are definitions; execution contracts are internal. */
1328
+ declare const FOUNDRY_AGENT_BRAND: symbol;
1329
+ declare const FOUNDRY_EVENT_PREFIX = "__GLOVE_FOUNDRY_EVENT__";
1330
+ declare const FOUNDRY_APPLICATION_ENV = "GLOVE_FOUNDRY_APPLICATION_FILE";
1331
+ declare const FOUNDRY_AGENT_ROUTE_ENV = "GLOVE_FOUNDRY_AGENT_ROUTE";
1332
+ declare const FOUNDRY_AGENT_FILE_ENV = "GLOVE_FOUNDRY_AGENT_FILE";
1333
+ declare const FOUNDRY_EXECUTION_MARKER = "__glove_foundry_execution_v1";
1334
+ type FoundryAgentMode = "agent";
1335
+ type Resolvable<T> = T | Promise<T> | Effect.Effect<T, unknown, never>;
1336
+ interface AgentRuntimeControls {
1337
+ readonly signal: AbortSignal;
1338
+ readonly emit: (event: {
1339
+ type: string;
1340
+ data?: unknown;
1341
+ }) => void;
1342
+ /** Commands are emitted to the parent runtime and retained for result semantics. */
1343
+ readonly commands: FoundryCoreCommand[];
1344
+ }
1345
+ interface AgentAssemblyContext<TInput = unknown> {
1346
+ readonly definitionId: string;
1347
+ readonly agentId: string;
1348
+ readonly conversationId: string;
1349
+ readonly workspaceId: string;
1350
+ readonly name: string;
1351
+ readonly runId: string;
1352
+ readonly mode: "agent";
1353
+ readonly request: FoundryRequest;
1354
+ readonly agentInstance: AgentInstance;
1355
+ readonly conversation: Conversation;
1356
+ /** Parent-runtime snapshot used by agent schedule management tools. */
1357
+ readonly activations: ReadonlyArray<FoundryActivationRecord>;
1358
+ readonly data: FoundryDataAdapter;
1359
+ readonly input: TInput;
1360
+ /** Native Glove representation of the current inbound user turn. */
1361
+ readonly message: Message;
1362
+ /** Exact input that will be passed to `Glove.processRequest`. */
1363
+ readonly messageInput: FoundryMessageInput;
1364
+ /** Convenience text projection matching Glove's multimodal normalization. */
1365
+ readonly messageText: string;
1366
+ /** Persisted native Glove messages before the current inbound turn. */
1367
+ readonly history: ReadonlyArray<Message>;
1368
+ /** Prior history followed by the current inbound turn. */
1369
+ readonly messages: ReadonlyArray<Message>;
1370
+ readonly installations: ReadonlyArray<AgentInstallation>;
1371
+ readonly store: StoreAdapter | null;
1372
+ readonly subscriber: SubscriberAdapter;
1373
+ readonly controls: AgentRuntimeControls;
1374
+ }
1375
+ /** @deprecated Use AgentAssemblyContext. */
1376
+ type AgentFactoryContext<TInput = unknown> = AgentAssemblyContext<TInput>;
1377
+ interface FoundryHookDefinition {
1378
+ readonly name: string;
1379
+ readonly handler: HookHandler;
1380
+ }
1381
+ interface FoundryCallContext<TInput = unknown> extends FoundrySurfaceContext<TInput> {
1382
+ readonly installations: ReadonlyArray<AgentInstallation>;
1383
+ }
1384
+ interface FoundryCallOptions<TInputSchema extends z.ZodType, TOutputSchema extends z.ZodType> {
1385
+ readonly name: string;
1386
+ readonly description: string;
1387
+ readonly input: TInputSchema;
1388
+ readonly output: TOutputSchema;
1389
+ readonly exposeToAgent?: boolean;
1390
+ readonly handler: (input: z.output<TInputSchema>, context: FoundryCallContext) => Resolvable<z.input<TOutputSchema>>;
1391
+ }
1392
+ type FoundryCall<TInputSchema extends z.ZodType = z.ZodType, TOutputSchema extends z.ZodType = z.ZodType> = Readonly<FoundryCallOptions<TInputSchema, TOutputSchema>>;
1393
+ declare function defineCall<TInputSchema extends z.ZodType, TOutputSchema extends z.ZodType>(options: FoundryCallOptions<TInputSchema, TOutputSchema>): FoundryCall<TInputSchema, TOutputSchema>;
1394
+ interface FoundryExecutionContext<TInput = unknown> extends FoundrySurfaceContext<TInput> {
1395
+ readonly installations: ReadonlyArray<AgentInstallation>;
1396
+ /** Native persistent environment mounted for this run, when configured. */
1397
+ readonly workingEnvironment?: WorkingEnvironment;
1398
+ /** Guarded VFS handle for host-side handlers and layers. */
1399
+ readonly vfs?: FoundryVfsHandle;
1400
+ /** Native Glove REPL session mounted for this run, when configured. */
1401
+ readonly repl?: FoundryMountedRepl;
1402
+ readonly invoke: (name: string, input: unknown) => Promise<unknown>;
1403
+ }
1404
+ interface AgentHandlerContext<TInput = unknown> extends FoundryExecutionContext<TInput> {
1405
+ readonly defaultRun: () => Promise<unknown>;
1406
+ /** @deprecated Use defaultRun. */
1407
+ readonly defaultHandler: () => Promise<unknown>;
1408
+ readonly spawn: (message?: FoundryMessageInput) => Promise<unknown>;
1409
+ }
1410
+ type FoundryResolver<T, TInput> = T | ((agent: FoundryAgentDefinition, context: AgentAssemblyContext<TInput>) => Resolvable<T>);
1411
+ type FoundryListResolver<T, TInput> = FoundryResolver<ReadonlyArray<T>, TInput>;
1412
+ interface AgentAssemblyOptions<TInput = unknown> {
1413
+ readonly model?: FoundryResolver<ModelAdapter, TInput>;
1414
+ readonly systemPrompt?: FoundryResolver<string, TInput>;
1415
+ readonly displayManager?: FoundryResolver<DisplayManagerAdapter, TInput>;
1416
+ readonly serverMode?: boolean;
1417
+ readonly maxRetries?: number;
1418
+ readonly maxConsecutiveErrors?: number;
1419
+ readonly compactionLimit?: FoundryResolver<number, TInput>;
1420
+ readonly compactionInstructions?: FoundryResolver<string, TInput>;
1421
+ readonly maxTurns?: FoundryResolver<number, TInput>;
1422
+ readonly enableToolResultSummary?: boolean;
1423
+ readonly tools?: FoundryListResolver<GloveFoldArgs<any>, TInput>;
1424
+ readonly hooks?: FoundryListResolver<FoundryHookDefinition, TInput>;
1425
+ readonly skills?: FoundryListResolver<DefineSkillArgs, TInput>;
1426
+ readonly subagents?: FoundryListResolver<DefineSubAgentArgs, TInput>;
1427
+ /** Definition-owned Glove memory surfaces; may resolve lazily from run context. */
1428
+ readonly memory?: FoundryListResolver<FoundryMemorySelection, TInput>;
1429
+ /** Lazily load native Glove inbox items into this run's conversation store. */
1430
+ readonly inboxes?: (agent: FoundryAgentDefinition, context: AgentAssemblyContext<TInput>) => Resolvable<ReadonlyArray<InboxItem>>;
1431
+ readonly subscribers?: FoundryListResolver<FoundrySubscriberSelection | SubscriberAdapter, TInput>;
1432
+ readonly layers?: FoundryListResolver<FoundryLayerSelection, TInput>;
1433
+ readonly calls?: FoundryListResolver<FoundryCall<any, any>, TInput>;
1434
+ /** Agent-local desired schedules, resolved lazily for the current instance and message. */
1435
+ readonly schedules?: FoundryListResolver<FoundryScheduleDefinition, TInput>;
1436
+ /** Runtime policy composed from transmission primitives and persisted on the instance. */
1437
+ readonly playbooks?: FoundryListResolver<ComposedAgentPlaybook, TInput>;
1438
+ readonly mesh?: FoundryResolver<FoundryMeshConfig | undefined, TInput>;
1439
+ /** Sandboxed persistent files + named script execution, assembled per context. */
1440
+ readonly workingEnvironment?: FoundryResolver<FoundryWorkingEnvironmentDefinition | undefined, TInput>;
1441
+ /** One native Glove JavaScript, Python, or Lisp REPL mounted for this run. */
1442
+ readonly repl?: FoundryResolver<FoundryReplDefinition | undefined, TInput>;
1443
+ /** Mount any adapter-backed native surface after lazy assembly. */
1444
+ readonly configure?: (agent: IGloveRunnable, context: FoundryExecutionContext<TInput>) => Resolvable<void>;
1445
+ /** Final transformation of the assembled runnable. Returning undefined keeps it. */
1446
+ readonly build?: (agent: IGloveRunnable, context: AgentAssemblyContext<TInput>) => Resolvable<IGloveRunnable | undefined>;
1447
+ /** Construct a layered S2S/S2V/custom execution for one message. */
1448
+ readonly spawn?: (agent: IGloveRunnable, context: FoundryExecutionContext<TInput>, message: FoundryMessageInput) => Resolvable<unknown>;
1449
+ /** Own request execution. Omit it to use spawn, then Glove's normal loop. */
1450
+ readonly run?: (agent: IGloveRunnable, context: AgentHandlerContext<TInput>) => Resolvable<unknown>;
1451
+ /** @deprecated Use run. */
1452
+ readonly handler?: (context: AgentHandlerContext<TInput>) => Resolvable<unknown>;
1453
+ }
1454
+ interface FoundryMeshConfig {
1455
+ readonly adapter: MeshAdapter;
1456
+ readonly identity?: Omit<AgentIdentity, "id"> & {
1457
+ readonly id?: string;
1458
+ };
1459
+ }
1460
+ interface DefineAgentOptions extends AgentAssemblyOptions<FoundryRequest> {
1461
+ /** @deprecated File-routed agents derive identity from agents/<route>/agent.ts. */
1462
+ readonly id?: string;
1463
+ readonly description: string;
1464
+ readonly tags?: readonly string[];
1465
+ /** Colocated catalogue of parts this definition allows its instances to use. */
1466
+ readonly components?: FoundryAgentComposition;
1467
+ /** Agent-local MCP state/auth seam. Foundry never acquires or refreshes credentials. */
1468
+ readonly mcpAdapter?: McpAdapterFactory;
1469
+ /** Agent-local account-session seam for application contribution factories. */
1470
+ readonly accountSessions?: FoundryAccountSessionAdapter;
1471
+ readonly store?: (context: {
1472
+ readonly definitionId: string;
1473
+ readonly agentId: string;
1474
+ readonly conversationId: string;
1475
+ readonly workspaceId: string;
1476
+ }) => Promise<StoreAdapter> | StoreAdapter;
1477
+ }
1478
+ type FoundryAgentDefinition = Readonly<DefineAgentOptions> & {
1479
+ readonly id: string;
1480
+ readonly [FOUNDRY_AGENT_DEFINITION_BRAND]: true;
1481
+ };
1482
+ type FoundryAgent = FoundryAgentDefinition;
1483
+ type AnyFoundryAgent = FoundryAgentDefinition;
1484
+ interface FoundryAgentConventionModule {
1485
+ readonly default?: unknown;
1486
+ /** @deprecated Named convention modules also derive identity from their file route. */
1487
+ readonly id?: string;
1488
+ readonly description?: string;
1489
+ readonly tags?: readonly string[];
1490
+ readonly components?: FoundryAgentComposition;
1491
+ readonly mcpAdapter?: McpAdapterFactory;
1492
+ readonly accountSessions?: FoundryAccountSessionAdapter;
1493
+ readonly store?: DefineAgentOptions["store"];
1494
+ readonly model?: AgentAssemblyOptions["model"];
1495
+ readonly systemPrompt?: AgentAssemblyOptions["systemPrompt"];
1496
+ readonly displayManager?: AgentAssemblyOptions["displayManager"];
1497
+ readonly serverMode?: boolean;
1498
+ readonly maxRetries?: number;
1499
+ readonly maxConsecutiveErrors?: number;
1500
+ readonly compactionLimit?: AgentAssemblyOptions["compactionLimit"];
1501
+ readonly compactionInstructions?: AgentAssemblyOptions["compactionInstructions"];
1502
+ readonly maxTurns?: AgentAssemblyOptions["maxTurns"];
1503
+ readonly enableToolResultSummary?: boolean;
1504
+ readonly tools?: AgentAssemblyOptions["tools"];
1505
+ readonly hooks?: AgentAssemblyOptions["hooks"];
1506
+ readonly skills?: AgentAssemblyOptions["skills"];
1507
+ readonly subagents?: AgentAssemblyOptions["subagents"];
1508
+ readonly memory?: AgentAssemblyOptions["memory"];
1509
+ readonly inboxes?: AgentAssemblyOptions["inboxes"];
1510
+ readonly subscribers?: AgentAssemblyOptions["subscribers"];
1511
+ readonly layers?: AgentAssemblyOptions["layers"];
1512
+ readonly calls?: AgentAssemblyOptions["calls"];
1513
+ readonly schedules?: AgentAssemblyOptions["schedules"];
1514
+ readonly playbooks?: AgentAssemblyOptions["playbooks"];
1515
+ readonly mesh?: AgentAssemblyOptions["mesh"];
1516
+ readonly workingEnvironment?: AgentAssemblyOptions["workingEnvironment"];
1517
+ readonly repl?: AgentAssemblyOptions["repl"];
1518
+ readonly configure?: AgentAssemblyOptions["configure"];
1519
+ readonly build?: AgentAssemblyOptions["build"];
1520
+ readonly spawn?: AgentAssemblyOptions["spawn"];
1521
+ readonly run?: AgentAssemblyOptions["run"];
1522
+ readonly handler?: AgentAssemblyOptions["handler"];
1523
+ }
1524
+ /** Agent definitions do not own transport schemas. Calls can still be typed with defineCall. */
1525
+ type InferAgentInput<_TAgent> = unknown;
1526
+ type InferAgentOutput<_TAgent> = unknown;
1527
+ declare function internalAgentName(route: string): string;
1528
+ declare function routeFromInternalAgentName(name: string): string;
1529
+ declare function isFoundryAgentDefinition(value: unknown): value is FoundryAgentDefinition;
1530
+ declare const isFoundryAgent: typeof isFoundryAgentDefinition;
1531
+ /** Pure data helper. It never creates or registers an execution job. */
1532
+ declare function defineAgent(options: DefineAgentOptions): FoundryAgentDefinition;
1533
+ /** Normalize either `export default defineAgent(...)` or named convention exports. */
1534
+ declare function defineAgentFromModule(route: string, module: FoundryAgentConventionModule): FoundryAgentDefinition;
1535
+ interface DefineFoundrySubagentOptions {
1536
+ readonly name: string;
1537
+ readonly description: string;
1538
+ readonly systemPrompt: string;
1539
+ readonly model?: ModelAdapter;
1540
+ readonly durable?: boolean;
1541
+ readonly serverMode?: boolean;
1542
+ readonly maxRetries?: number;
1543
+ readonly maxConsecutiveErrors?: number;
1544
+ readonly compactionLimit?: number;
1545
+ readonly compactionInstructions?: string;
1546
+ readonly maxTurns?: number;
1547
+ readonly enableToolResultSummary?: boolean;
1548
+ readonly tools?: ReadonlyArray<GloveFoldArgs<any>>;
1549
+ readonly hooks?: ReadonlyArray<FoundryHookDefinition>;
1550
+ readonly skills?: ReadonlyArray<DefineSkillArgs>;
1551
+ readonly subagents?: ReadonlyArray<DefineSubAgentArgs>;
1552
+ readonly layers?: ReadonlyArray<FoundryLayer<any>>;
1553
+ readonly subscribers?: ReadonlyArray<FoundrySubscriber | SubscriberAdapter>;
1554
+ readonly configure?: (context: FoundrySurfaceContext<string>) => Resolvable<void>;
1555
+ }
1556
+ declare function defineSubagent(options: DefineFoundrySubagentOptions): DefineSubAgentArgs;
1557
+ type FoundryRouteMap = Record<string, object>;
1558
+ declare function defineRoutes<const TRoutes extends FoundryRouteMap>(routes: TRoutes): TRoutes;
1559
+
1560
+ interface DiscoveredAgent {
1561
+ route: string;
1562
+ filePath: string;
1563
+ relativePath: string;
1564
+ definition: FoundryAgentDefinition;
1565
+ executionName: string;
1566
+ }
1567
+ interface FoundryManifestAgent {
1568
+ id: string;
1569
+ description: string;
1570
+ mode: "agent";
1571
+ file: string;
1572
+ tags: readonly string[];
1573
+ invocationContract: "foundry/request-v1";
1574
+ resultContract: "foundry/result-v1";
1575
+ assembly: "foundry" | "custom";
1576
+ handler: "glove" | "custom";
1577
+ layers: readonly string[];
1578
+ subscribers: readonly string[];
1579
+ tools: readonly string[];
1580
+ hooks: readonly string[];
1581
+ skills: readonly string[];
1582
+ subagents: readonly string[];
1583
+ memory: readonly string[];
1584
+ inboxLoader: boolean;
1585
+ calls: readonly string[];
1586
+ schedules: readonly string[];
1587
+ playbooks: readonly string[];
1588
+ mesh: boolean;
1589
+ workingEnvironment: boolean;
1590
+ repl: "javascript" | "python" | "lisp" | "dynamic" | null;
1591
+ lazy: readonly string[];
1592
+ }
1593
+ interface FoundryManifest {
1594
+ version: 1;
1595
+ generatedAt: string;
1596
+ agents: FoundryManifestAgent[];
1597
+ }
1598
+ declare function routeFromAgentFile(agentsDir: string, filePath: string): string | null;
1599
+ declare function findAgentFiles(agentsDir: string): Promise<string[]>;
1600
+ declare function discoverAgents(options: {
1601
+ agentsDir: string;
1602
+ strictFileRoutes?: boolean;
1603
+ cacheBust?: boolean;
1604
+ }): Promise<DiscoveredAgent[]>;
1605
+ declare function createManifest(agents: readonly DiscoveredAgent[]): FoundryManifest;
1606
+
1607
+ interface AccountFilter {
1608
+ readonly transmissionId?: TransmissionId;
1609
+ }
1610
+ declare const AccountDirectory_base: Context.TagClass<AccountDirectory, "@glove-foundry/AccountDirectory", {
1611
+ readonly get: (id: AccountId) => Effect.Effect<AccountReference, AccountNotFound>;
1612
+ readonly list: (filter?: AccountFilter) => Effect.Effect<ReadonlyArray<AccountReference>>;
1613
+ }>;
1614
+ /**
1615
+ * Read-only account metadata supplied by the application. Deliberately no
1616
+ * create, authorize, refresh, revoke, token, or credential methods exist.
1617
+ */
1618
+ declare class AccountDirectory extends AccountDirectory_base {
1619
+ }
1620
+ interface RouteFilter {
1621
+ readonly transmissionId?: TransmissionId;
1622
+ readonly accountId?: AccountId;
1623
+ readonly direction?: Route["direction"];
1624
+ readonly enabled?: boolean;
1625
+ }
1626
+ interface BindingFilter {
1627
+ readonly agentId?: AgentId;
1628
+ readonly transmissionId?: TransmissionId;
1629
+ readonly accountId?: AccountId;
1630
+ readonly routeId?: RouteId;
1631
+ readonly enabled?: boolean;
1632
+ }
1633
+ declare const TopologyStore_base: Context.TagClass<TopologyStore, "@glove-foundry/TopologyStore", {
1634
+ readonly getRoute: (id: RouteId) => Effect.Effect<Route, RouteNotFound>;
1635
+ readonly listRoutes: (filter?: RouteFilter) => Effect.Effect<ReadonlyArray<Route>>;
1636
+ readonly putRoute: (route: Route) => Effect.Effect<Route, TopologyConflict>;
1637
+ readonly removeRoute: (id: RouteId) => Effect.Effect<void, RouteNotFound>;
1638
+ readonly getBinding: (id: BindingId) => Effect.Effect<AgentBinding, BindingNotFound>;
1639
+ readonly listBindings: (filter?: BindingFilter) => Effect.Effect<ReadonlyArray<AgentBinding>>;
1640
+ readonly putBinding: (binding: AgentBinding) => Effect.Effect<AgentBinding, TopologyConflict>;
1641
+ readonly removeBinding: (id: BindingId) => Effect.Effect<void, BindingNotFound>;
1642
+ }>;
1643
+ /** Durable desired topology. It stores opaque account ids, never credentials. */
1644
+ declare class TopologyStore extends TopologyStore_base {
1645
+ }
1646
+ declare const EventStore_base: Context.TagClass<EventStore, "@glove-foundry/EventStore", {
1647
+ readonly put: (reference: EventReference, payload: unknown) => Effect.Effect<void>;
1648
+ readonly getReference: (id: EventId) => Effect.Effect<EventReference, EventNotFound>;
1649
+ readonly getPayload: (id: EventId) => Effect.Effect<unknown, EventNotFound>;
1650
+ }>;
1651
+ declare class EventStore extends EventStore_base {
1652
+ }
1653
+ interface AccountSessionRequest {
1654
+ readonly account: AccountReference;
1655
+ readonly operation: string;
1656
+ readonly runId?: RunId;
1657
+ }
1658
+ /**
1659
+ * A user-owned adapter that produces an operation-scoped Effect Layer. Its
1660
+ * implementation owns credential lookup, refresh, SDK construction, and
1661
+ * cleanup. Foundry only provides the resulting service to the operation.
1662
+ */
1663
+ interface AccountSessionAdapter<TSession> {
1664
+ readonly layer: (request: AccountSessionRequest) => Layer.Layer<TSession, AccountSessionUnavailable>;
1665
+ }
1666
+ declare function memoryAccountDirectory(accounts: ReadonlyArray<AccountReference>): Layer.Layer<AccountDirectory>;
1667
+ declare const memoryTopologyStore: Layer.Layer<TopologyStore>;
1668
+ declare const memoryEventStore: Layer.Layer<EventStore>;
1669
+
1670
+ interface ResolveGrantRequest {
1671
+ readonly runId: RunId;
1672
+ readonly agentId: AgentId;
1673
+ /** The inbound route that caused the run, when one exists. */
1674
+ readonly originRouteId?: RouteId;
1675
+ }
1676
+ declare const GrantResolver_base: Context.TagClass<GrantResolver, "@glove-foundry/GrantResolver", {
1677
+ readonly resolve: (request: ResolveGrantRequest) => Effect.Effect<RunGrant, GrantResolutionError>;
1678
+ }>;
1679
+ declare class GrantResolver extends GrantResolver_base {
1680
+ }
1681
+ /**
1682
+ * Resolve desired bindings into immutable authority for exactly one run.
1683
+ * Agents consume the resulting grant; they never query the topology directly.
1684
+ */
1685
+ declare const grantResolverLive: Layer.Layer<GrantResolver, never, TopologyStore>;
1686
+
1687
+ declare const FoundryManifestCapability: Schema.Struct<{
1688
+ id: typeof Schema.String;
1689
+ description: typeof Schema.String;
1690
+ account: Schema.Literal<["none", "optional", "required"]>;
1691
+ effect: Schema.Literal<["read", "write"]>;
1692
+ }>;
1693
+ declare const FoundryManifestTransmission: Schema.Struct<{
1694
+ id: typeof Schema.String;
1695
+ name: typeof Schema.String;
1696
+ description: typeof Schema.String;
1697
+ shape: Schema.Literal<["capability-only", "inbound-only", "outbound-only", "bidirectional"]>;
1698
+ account: Schema.optional<Schema.Struct<{
1699
+ required: typeof Schema.Boolean;
1700
+ metadataSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1701
+ }>>;
1702
+ capabilities: Schema.Array$<Schema.Struct<{
1703
+ id: typeof Schema.String;
1704
+ description: typeof Schema.String;
1705
+ account: Schema.Literal<["none", "optional", "required"]>;
1706
+ effect: Schema.Literal<["read", "write"]>;
1707
+ }>>;
1708
+ inbound: Schema.optional<Schema.Struct<{
1709
+ configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1710
+ eventSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1711
+ }>>;
1712
+ outbound: Schema.optional<Schema.Struct<{
1713
+ configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1714
+ inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1715
+ outputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1716
+ }>>;
1717
+ }>;
1718
+ declare const FoundryApplicationManifest: Schema.Struct<{
1719
+ schemaVersion: Schema.Literal<[2]>;
1720
+ generatedAt: typeof Schema.String;
1721
+ transmissions: Schema.Array$<Schema.Struct<{
1722
+ id: typeof Schema.String;
1723
+ name: typeof Schema.String;
1724
+ description: typeof Schema.String;
1725
+ shape: Schema.Literal<["capability-only", "inbound-only", "outbound-only", "bidirectional"]>;
1726
+ account: Schema.optional<Schema.Struct<{
1727
+ required: typeof Schema.Boolean;
1728
+ metadataSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1729
+ }>>;
1730
+ capabilities: Schema.Array$<Schema.Struct<{
1731
+ id: typeof Schema.String;
1732
+ description: typeof Schema.String;
1733
+ account: Schema.Literal<["none", "optional", "required"]>;
1734
+ effect: Schema.Literal<["read", "write"]>;
1735
+ }>>;
1736
+ inbound: Schema.optional<Schema.Struct<{
1737
+ configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1738
+ eventSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1739
+ }>>;
1740
+ outbound: Schema.optional<Schema.Struct<{
1741
+ configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1742
+ inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1743
+ outputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
1744
+ }>>;
1745
+ }>>;
1746
+ }>;
1747
+ type FoundryApplicationManifest = typeof FoundryApplicationManifest.Type;
1748
+ declare const ManifestCompilationError_base: Schema.TaggedErrorClass<ManifestCompilationError, "ManifestCompilationError", {
1749
+ readonly _tag: Schema.tag<"ManifestCompilationError">;
1750
+ } & {
1751
+ message: typeof Schema.String;
1752
+ }>;
1753
+ declare class ManifestCompilationError extends ManifestCompilationError_base {
1754
+ }
1755
+ /** Compile code definitions into a value-only, credential-free manifest. */
1756
+ declare function compileApplicationManifest(transmissions: ReadonlyArray<AnyFoundryTransmission>): Effect.Effect<FoundryApplicationManifest, ManifestCompilationError>;
1757
+
1758
+ type FoundryEventCategory = "agent" | "run" | "model" | "tool" | "extension" | "application" | "inbox" | "memory" | "mcp" | "activation" | "system" | "log";
1759
+ interface FoundryEvent {
1760
+ readonly id: string;
1761
+ readonly sequence: number;
1762
+ readonly timestamp: string;
1763
+ readonly type: string;
1764
+ readonly category: FoundryEventCategory;
1765
+ readonly agent?: string;
1766
+ readonly runId?: string;
1767
+ readonly data: unknown;
1768
+ }
1769
+ interface EventFilter {
1770
+ readonly after?: number;
1771
+ readonly agent?: string;
1772
+ readonly runId?: string;
1773
+ readonly category?: FoundryEventCategory;
1774
+ readonly limit?: number;
1775
+ }
1776
+ interface FoundryObservabilityAdapter {
1777
+ append(event: Omit<FoundryEvent, "id" | "sequence" | "timestamp"> & {
1778
+ timestamp?: string;
1779
+ }): FoundryEvent;
1780
+ list(filter?: EventFilter): FoundryEvent[];
1781
+ subscribe(listener: (event: FoundryEvent) => void): () => void;
1782
+ clear?(): void | Promise<void>;
1783
+ }
1784
+ declare class MemoryObservabilityAdapter implements FoundryObservabilityAdapter {
1785
+ private readonly maxEvents;
1786
+ private readonly events;
1787
+ private readonly listeners;
1788
+ private sequence;
1789
+ constructor(options?: {
1790
+ maxEvents?: number;
1791
+ });
1792
+ append(input: Omit<FoundryEvent, "id" | "sequence" | "timestamp"> & {
1793
+ timestamp?: string;
1794
+ }): FoundryEvent;
1795
+ list(filter?: EventFilter): FoundryEvent[];
1796
+ subscribe(listener: (event: FoundryEvent) => void): () => void;
1797
+ clear(): void;
1798
+ }
1799
+
1800
+ declare const FOUNDRY_APPLICATION_BRAND: unique symbol;
1801
+ /** Process infrastructure only; agent files own runtime capabilities. */
1802
+ interface FoundryApplicationOptions {
1803
+ readonly name: string;
1804
+ readonly accounts?: ReadonlyArray<AccountReference>;
1805
+ readonly routes?: ReadonlyArray<Route>;
1806
+ readonly bindings?: ReadonlyArray<AgentBinding>;
1807
+ readonly data?: FoundryDataAdapter;
1808
+ readonly conversationStore?: (scope: {
1809
+ readonly definitionId: string;
1810
+ readonly agentId: string;
1811
+ readonly conversationId: string;
1812
+ readonly workspaceId: string;
1813
+ }) => Promise<StoreAdapter> | StoreAdapter;
1814
+ /** User-owned strategy for subscriptions using `provisioning.mode = "custom"`. */
1815
+ readonly provisioner?: FoundryInstanceProvisioner;
1816
+ readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
1817
+ }
1818
+ type FoundryApplication = Readonly<FoundryApplicationOptions> & {
1819
+ readonly [FOUNDRY_APPLICATION_BRAND]: true;
1820
+ };
1821
+ declare function isFoundryApplication(value: unknown): value is FoundryApplication;
1822
+ /** Define infrastructure. Agent composition is deliberately absent here. */
1823
+ declare function defineApplication(options: FoundryApplicationOptions): FoundryApplication;
1824
+ declare const EMPTY_FOUNDRY_APPLICATION: FoundryApplication;
1825
+
1826
+ interface DiscoveredCapability {
1827
+ readonly kind: "tool" | "application" | "mcp" | "memory";
1828
+ readonly id: string;
1829
+ readonly filePath: string;
1830
+ readonly relativePath: string;
1831
+ }
1832
+ interface DiscoveredFoundryRegistry {
1833
+ readonly capabilities: FoundryCapabilityRegistry;
1834
+ readonly native: FoundryNativeRegistry;
1835
+ readonly files: ReadonlyArray<DiscoveredCapability>;
1836
+ readonly nativeFiles: ReadonlyArray<{
1837
+ readonly kind: "layer" | "subscriber";
1838
+ readonly id: string;
1839
+ readonly filePath: string;
1840
+ readonly relativePath: string;
1841
+ }>;
1842
+ }
1843
+
1844
+ interface FoundryRun<TOutput = unknown> {
1845
+ readonly id: string;
1846
+ readonly agent: string;
1847
+ readonly kind: "trigger" | "recurring";
1848
+ readonly status: "pending" | "running" | "completed" | "failed" | "cancelled";
1849
+ readonly input: unknown;
1850
+ readonly output?: TOutput;
1851
+ readonly agentId?: string;
1852
+ readonly conversationId?: string;
1853
+ readonly workspaceId?: string;
1854
+ readonly error?: string;
1855
+ readonly attempts: number;
1856
+ readonly maxAttempts: number;
1857
+ readonly timeoutMs: number;
1858
+ readonly createdAt: string;
1859
+ readonly startedAt?: string;
1860
+ readonly completedAt?: string;
1861
+ }
1862
+ declare const FoundryRuntimeError_base: Schema.TaggedErrorClass<FoundryRuntimeError, "FoundryRuntimeError", {
1863
+ readonly _tag: Schema.tag<"FoundryRuntimeError">;
1864
+ } & {
1865
+ operation: typeof Schema.String;
1866
+ message: typeof Schema.String;
1867
+ }>;
1868
+ declare class FoundryRuntimeError extends FoundryRuntimeError_base {
1869
+ }
1870
+ interface FoundryRuntimeOptions {
1871
+ readonly rootDir: string;
1872
+ readonly agents: DiscoveredAgent[];
1873
+ readonly application?: FoundryApplication;
1874
+ readonly applicationFilePath?: string;
1875
+ readonly registry?: DiscoveredFoundryRegistry;
1876
+ readonly config?: FoundryConfig;
1877
+ readonly observability?: FoundryObservabilityAdapter;
1878
+ }
1879
+ declare class FoundryRuntime {
1880
+ readonly rootDir: string;
1881
+ readonly agents: readonly DiscoveredAgent[];
1882
+ readonly application: FoundryApplication;
1883
+ readonly applicationFilePath?: string;
1884
+ readonly registry: DiscoveredFoundryRegistry;
1885
+ readonly manifest: FoundryManifest;
1886
+ readonly applicationManifest: FoundryApplicationManifest;
1887
+ readonly observability: FoundryObservabilityAdapter;
1888
+ readonly data: FoundryDataAdapter;
1889
+ private readonly byRoute;
1890
+ private readonly routeBySignalName;
1891
+ private readonly transmissionById;
1892
+ /** Stable topology view used by synchronous playbook validation. */
1893
+ private readonly topologyRoutes;
1894
+ private readonly compositionByDefinition;
1895
+ private readonly connectionSupervisor;
1896
+ private readonly execution;
1897
+ private readonly observer;
1898
+ private readonly signalRunner;
1899
+ private readonly envStore;
1900
+ private readonly envProvider;
1901
+ private readonly scheduleAdapter;
1902
+ private readonly services;
1903
+ private readonly runnerLoops;
1904
+ private readonly materializedActivations;
1905
+ private started;
1906
+ private disposed;
1907
+ constructor(options: FoundryRuntimeOptions);
1908
+ static discover(options: {
1909
+ rootDir: string;
1910
+ agentsDir: string;
1911
+ application?: FoundryApplication;
1912
+ applicationFilePath?: string;
1913
+ config?: FoundryConfig;
1914
+ observability?: FoundryObservabilityAdapter;
1915
+ }): Promise<FoundryRuntime>;
1916
+ startEffect(): Effect.Effect<void, FoundryRuntimeError>;
1917
+ start(): Promise<void>;
1918
+ stopEffect(): Effect.Effect<void, FoundryRuntimeError>;
1919
+ stop(): Promise<void>;
1920
+ requestEffect(route: string, request: FoundryRequest): Effect.Effect<FoundryRun, FoundryRuntimeError>;
1921
+ request(route: string, request: FoundryRequest): Promise<FoundryRun>;
1922
+ createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
1923
+ createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
1924
+ listAgentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
1925
+ setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
1926
+ listPlaybookSubscriptions(workspaceId?: string): Promise<ReadonlyArray<PlaybookSubscription>>;
1927
+ /** List persisted future activations created by schedules or sleeping runs. */
1928
+ listActivations(workspaceId?: string): Promise<ReadonlyArray<FoundryActivationRecord>>;
1929
+ putPlaybookSubscription(input: DefinePlaybookSubscriptionOptions | PlaybookSubscription): Promise<PlaybookSubscription>;
1930
+ deletePlaybookSubscription(id: string): Promise<boolean>;
1931
+ listApplicationConnections(): ReadonlyArray<ApplicationConnectionState>;
1932
+ reconnectApplicationConnection(id: string): Promise<void>;
1933
+ /** Atomically replace the persisted, frontend-editable instance configuration. */
1934
+ configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
1935
+ listConversations(agentId: string): Promise<ReadonlyArray<Conversation>>;
1936
+ listWorkspaceEntries(workspaceId: string): Promise<ReadonlyArray<WorkspaceEntry>>;
1937
+ putWorkspaceEntry(workspaceId: string, key: string, value: unknown): Promise<WorkspaceEntry>;
1938
+ listSharedInbox(workspaceId: string): Promise<ReadonlyArray<SharedInboxItem>>;
1939
+ postSharedInbox(input: Omit<SharedInboxItem, "id" | "createdAt" | "updatedAt">): Promise<SharedInboxItem>;
1940
+ updateSharedInbox(workspaceId: string, itemId: string, status: SharedInboxItem["status"]): Promise<SharedInboxItem>;
1941
+ listTasks(workspaceId: string): Promise<ReadonlyArray<FoundryTask>>;
1942
+ createTask(input: Omit<FoundryTask, "id" | "createdAt" | "updatedAt">): Promise<FoundryTask>;
1943
+ updateTask(workspaceId: string, taskId: string, status: FoundryTask["status"]): Promise<FoundryTask>;
1944
+ listDataEnvironment(scope: {
1945
+ readonly workspaceId: string;
1946
+ readonly agentId?: string;
1947
+ readonly conversationId?: string;
1948
+ }): Promise<ReadonlyArray<EnvironmentValue>>;
1949
+ send(agentId: string, conversationId: string, message: FoundryMessageInput, options?: {
1950
+ readonly payload?: unknown;
1951
+ readonly context?: Readonly<Record<string, unknown>>;
1952
+ }): Promise<FoundryRun<FoundryResult>>;
1953
+ getRun<TOutput = unknown>(runId: string): Promise<FoundryRun<TOutput> | null>;
1954
+ listRuns(route?: string): Promise<FoundryRun[]>;
1955
+ waitForRun<TOutput = unknown>(runId: string, options?: {
1956
+ pollMs?: number;
1957
+ timeoutMs?: number;
1958
+ }): Promise<FoundryRun<TOutput> | null>;
1959
+ cancel(runId: string): Promise<boolean>;
1960
+ capabilityManifest(definitionId: string): FoundryCapabilityManifest;
1961
+ nativeManifest(definitionId: string): FoundryNativeManifest;
1962
+ listInstallations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
1963
+ installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
1964
+ uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
1965
+ listAccounts(): Promise<{
1966
+ id: string & effect_Brand.Brand<"FoundryAccountId">;
1967
+ transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
1968
+ externalAccountId: string;
1969
+ label?: string | undefined;
1970
+ metadata: {
1971
+ readonly [x: string]: unknown;
1972
+ };
1973
+ }[]>;
1974
+ listRoutes(): Promise<readonly ({
1975
+ readonly id: string & effect_Brand.Brand<"FoundryRouteId">;
1976
+ readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
1977
+ readonly direction: "inbound";
1978
+ readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
1979
+ readonly visibility: "private" | "workspace";
1980
+ readonly enabled: boolean;
1981
+ readonly config: {
1982
+ readonly [x: string]: unknown;
1983
+ };
1984
+ } | {
1985
+ readonly id: string & effect_Brand.Brand<"FoundryRouteId">;
1986
+ readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
1987
+ readonly direction: "outbound";
1988
+ readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
1989
+ readonly visibility: "private" | "workspace";
1990
+ readonly enabled: boolean;
1991
+ readonly config: {
1992
+ readonly [x: string]: unknown;
1993
+ };
1994
+ })[]>;
1995
+ putRoute(route: Route): Promise<Route>;
1996
+ removeRoute(id: RouteId): Promise<void>;
1997
+ listBindings(): Promise<readonly {
1998
+ readonly id: string & effect_Brand.Brand<"FoundryBindingId">;
1999
+ readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
2000
+ readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
2001
+ readonly enabled: boolean;
2002
+ readonly routeId?: (string & effect_Brand.Brand<"FoundryRouteId">) | undefined;
2003
+ readonly agentId: string & effect_Brand.Brand<"FoundryAgentId">;
2004
+ readonly capabilities: readonly (string & effect_Brand.Brand<"FoundryCapabilityId">)[];
2005
+ readonly reply?: {
2006
+ readonly mode: "none";
2007
+ } | {
2008
+ readonly mode: "origin";
2009
+ } | {
2010
+ readonly mode: "route";
2011
+ readonly routeId: string & effect_Brand.Brand<"FoundryRouteId">;
2012
+ } | undefined;
2013
+ }[]>;
2014
+ putBinding(binding: AgentBinding): Promise<AgentBinding>;
2015
+ removeBinding(id: BindingId): Promise<void>;
2016
+ resolveGrant(request: ResolveGrantRequest): Promise<RunGrant>;
2017
+ putEvent(reference: EventReference, payload: unknown): Promise<void>;
2018
+ dispatchInbound(input: {
2019
+ readonly routeId: string;
2020
+ readonly eventId: string;
2021
+ readonly threadKey: string;
2022
+ readonly raw: unknown;
2023
+ }): Promise<ReadonlyArray<FoundryRun>>;
2024
+ dispatchOutbound(input: {
2025
+ readonly routeId: string;
2026
+ readonly agentId: string;
2027
+ readonly runId: string;
2028
+ readonly payload: unknown;
2029
+ readonly commandId?: string;
2030
+ readonly applicationId?: string;
2031
+ readonly transmissionId?: string;
2032
+ }): Promise<unknown>;
2033
+ health(): Promise<Record<string, unknown>>;
2034
+ private runsFromIds;
2035
+ private waitForInboundDelivery;
2036
+ private validatePlaybookSubscription;
2037
+ private playbookMatches;
2038
+ private resolveSubscriptionTarget;
2039
+ private attachSubscriptionPlaybook;
2040
+ private reconcileApplicationConnections;
2041
+ private assertRegisteredInstallation;
2042
+ private validatePlaybooks;
2043
+ private validateRoute;
2044
+ private validateBinding;
2045
+ private executionSignal;
2046
+ private seedTopology;
2047
+ private runInBackground;
2048
+ private settleRunnerLoops;
2049
+ private enqueueCoreRequest;
2050
+ private executeCoreCommand;
2051
+ private syncAgentPlaybooks;
2052
+ private assertActivationOwnership;
2053
+ private backendScheduleId;
2054
+ private disarmActivation;
2055
+ private syncDefinitionSchedules;
2056
+ private updateScheduledActivation;
2057
+ private cancelScheduledActivation;
2058
+ private reconstructActivations;
2059
+ private materializeActivation;
2060
+ private deliverOutbound;
2061
+ private executionEnvelope;
2062
+ private toFoundryRun;
2063
+ }
2064
+
2065
+ interface FoundryClientOptions {
2066
+ baseUrl?: string;
2067
+ fetch?: typeof globalThis.fetch;
2068
+ }
2069
+ interface WaitOptions {
2070
+ pollMs?: number;
2071
+ timeoutMs?: number;
2072
+ signal?: AbortSignal;
2073
+ }
2074
+ interface FoundryHealth {
2075
+ readonly ok: boolean;
2076
+ readonly execution: boolean;
2077
+ readonly environment: boolean;
2078
+ readonly activations: boolean;
2079
+ readonly agents: number;
2080
+ readonly capabilities: number;
2081
+ readonly surfaces: number;
2082
+ }
2083
+ declare class FoundryRunHandle<TOutput> {
2084
+ readonly id: string;
2085
+ readonly initial: FoundryRun<TOutput>;
2086
+ private readonly client;
2087
+ constructor(id: string, initial: FoundryRun<TOutput>, client: FoundryClient<FoundryRouteMap>);
2088
+ get(): Promise<FoundryRun<TOutput>>;
2089
+ cancel(): Promise<boolean>;
2090
+ events(): Promise<FoundryEvent[]>;
2091
+ wait(options?: WaitOptions): Promise<FoundryRun<TOutput>>;
2092
+ }
2093
+ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
2094
+ private readonly baseUrl;
2095
+ private readonly fetcher;
2096
+ constructor(options?: FoundryClientOptions);
2097
+ health(): Promise<FoundryHealth>;
2098
+ agent<TRoute extends Extract<keyof TRoutes, string>>(route: TRoute): {
2099
+ create(options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
2100
+ request(request: FoundryRequest): Promise<FoundryRunHandle<FoundryResult>>;
2101
+ };
2102
+ createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
2103
+ agentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
2104
+ configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
2105
+ setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
2106
+ createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
2107
+ conversations(agentId: string): Promise<ReadonlyArray<Conversation>>;
2108
+ workspaceEntries(workspaceId: string): Promise<ReadonlyArray<WorkspaceEntry>>;
2109
+ putWorkspaceEntry(workspaceId: string, key: string, value: unknown): Promise<WorkspaceEntry>;
2110
+ sharedInbox(workspaceId: string): Promise<ReadonlyArray<SharedInboxItem>>;
2111
+ postSharedInbox(workspaceId: string, input: {
2112
+ readonly topic: string;
2113
+ readonly payload?: unknown;
2114
+ readonly agentId?: string;
2115
+ readonly conversationId?: string;
2116
+ }): Promise<SharedInboxItem>;
2117
+ updateSharedInbox(workspaceId: string, itemId: string, status: SharedInboxItem["status"]): Promise<SharedInboxItem>;
2118
+ tasks(workspaceId: string): Promise<ReadonlyArray<FoundryTask>>;
2119
+ createTask(workspaceId: string, input: {
2120
+ readonly title: string;
2121
+ readonly detail?: string;
2122
+ readonly agentId?: string;
2123
+ readonly conversationId?: string;
2124
+ }): Promise<FoundryTask>;
2125
+ updateTask(workspaceId: string, taskId: string, status: FoundryTask["status"]): Promise<FoundryTask>;
2126
+ dataEnvironment(workspaceId: string, scope?: {
2127
+ readonly agentId?: string;
2128
+ readonly conversationId?: string;
2129
+ }): Promise<ReadonlyArray<EnvironmentValue>>;
2130
+ dispatchInbound(input: {
2131
+ readonly routeId: string;
2132
+ readonly eventId: string;
2133
+ readonly threadKey: string;
2134
+ readonly raw: unknown;
2135
+ }): Promise<ReadonlyArray<FoundryRun>>;
2136
+ playbookSubscriptions(workspaceId?: string): Promise<ReadonlyArray<PlaybookSubscription>>;
2137
+ activations(workspaceId?: string): Promise<ReadonlyArray<FoundryActivationRecord>>;
2138
+ putPlaybookSubscription(subscription: PlaybookSubscription): Promise<PlaybookSubscription>;
2139
+ deletePlaybookSubscription(id: string): Promise<boolean>;
2140
+ applicationConnections(): Promise<ReadonlyArray<ApplicationConnectionState>>;
2141
+ reconnectApplicationConnection(id: string): Promise<void>;
2142
+ dispatchOutbound(input: {
2143
+ readonly routeId: string;
2144
+ readonly agentId: string;
2145
+ readonly runId: string;
2146
+ readonly payload: unknown;
2147
+ }): Promise<unknown>;
2148
+ send(agentId: string, conversationId: string, message: FoundryMessageInput, options?: {
2149
+ readonly payload?: unknown;
2150
+ readonly context?: Readonly<Record<string, unknown>>;
2151
+ }): Promise<FoundryRunHandle<FoundryResult>>;
2152
+ getRun<TOutput = unknown>(runId: string): Promise<FoundryRun<TOutput>>;
2153
+ runs<TOutput = unknown>(route?: string): Promise<ReadonlyArray<FoundryRun<TOutput>>>;
2154
+ cancelRun(runId: string): Promise<boolean>;
2155
+ getEvents(filter?: {
2156
+ runId?: string;
2157
+ agent?: string;
2158
+ after?: number;
2159
+ category?: FoundryEvent["category"];
2160
+ }): Promise<FoundryEvent[]>;
2161
+ manifest(): Promise<{
2162
+ agents: FoundryManifest;
2163
+ application: FoundryApplicationManifest;
2164
+ definitions: Readonly<Record<string, {
2165
+ capabilities: FoundryCapabilityManifest;
2166
+ surfaces: FoundryNativeManifest;
2167
+ }>>;
2168
+ }>;
2169
+ capabilities(definitionId: string): Promise<FoundryCapabilityManifest>;
2170
+ surfaces(definitionId: string): Promise<FoundryNativeManifest>;
2171
+ installations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
2172
+ install(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
2173
+ uninstall(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
2174
+ accounts(): Promise<ReadonlyArray<AccountSummary>>;
2175
+ routes(): Promise<ReadonlyArray<Route>>;
2176
+ putRoute(route: Route): Promise<Route>;
2177
+ removeRoute(id: string): Promise<void>;
2178
+ bindings(): Promise<ReadonlyArray<AgentBinding>>;
2179
+ putBinding(binding: AgentBinding): Promise<AgentBinding>;
2180
+ removeBinding(id: string): Promise<void>;
2181
+ resolveGrant(request: ResolveGrantRequest): Promise<RunGrant>;
2182
+ private asUntyped;
2183
+ }
2184
+ declare function createFoundryClient<TRoutes extends FoundryRouteMap = Record<string, AnyFoundryAgent>>(options?: FoundryClientOptions): FoundryClient<TRoutes>;
2185
+
2186
+ export { type CreateConversationOptions as $, type AgentPlaybook as A, type AgentHandlerContext as B, type CapabilityDefinition as C, type DiscoveredAgent as D, AgentId as E, FoundryRuntime as F, type AgentInstallContext as G, type AgentInstallation as H, type InferAccountMetadata as I, type AgentInstallationKind as J, type AgentPlaybookInput as K, type AgentProvisioningPolicy as L, type AgentRuntimeControls as M, type AnyFoundryAgent as N, OutboundRoute as O, type ApplicationConnectionContext as P, type ApplicationConnectionState as Q, type ApplicationConnectionStatus as R, type BindingFilter as S, BindingId as T, BindingNotFound as U, CapabilityId as V, type ComposedAgentPlaybook as W, type ComposedAgentPlaybookInput as X, type ConnectionReceiveInput as Y, type Conversation as Z, type CreateAgentInstanceOptions as _, type FoundryManifest as a, type FoundryCapabilityManifest as a$, type CustomProvisionedAgent as a0, type CustomProvisioningContext as a1, type DefineAgentOptions as a2, type DefineConnectionOptions as a3, type DefineFoundryReplOptions as a4, type DefineFoundryScheduleOptions as a5, type DefineFoundrySubagentOptions as a6, type DefineFoundryWorkingEnvironmentOptions as a7, type DefinePlaybookSubscriptionOptions as a8, type DefinitionConfigInput as a9, FOUNDRY_MEMORY_BRAND as aA, FOUNDRY_PLAYBOOK_ACTION_BRAND as aB, FOUNDRY_REPL_BRAND as aC, FOUNDRY_SCHEDULE_BRAND as aD, FOUNDRY_SHARED_TOOL_BRAND as aE, FOUNDRY_SUBSCRIBER_BRAND as aF, FOUNDRY_TRANSMISSION_BRAND as aG, FOUNDRY_TRANSMISSION_EVENT_BRAND as aH, FOUNDRY_TRANSMISSION_PREDICATE_BRAND as aI, FOUNDRY_WORKING_ENVIRONMENT_BRAND as aJ, type FoundryAccountSessionAdapter as aK, type FoundryActivationRecord as aL, type FoundryAgent as aM, type FoundryAgentComponent as aN, type FoundryAgentComposition as aO, type FoundryAgentConventionModule as aP, type FoundryAgentDefinition as aQ, type FoundryAgentMode as aR, type FoundryApp as aS, type FoundryApplication as aT, type FoundryApplicationConnection as aU, FoundryApplicationManifest as aV, type FoundryApplicationOptions as aW, type FoundryCall as aX, type FoundryCallContext as aY, type FoundryCallOptions as aZ, type FoundryCapabilityKind as a_, EMPTY_AGENT_COMPOSITION as aa, EMPTY_CAPABILITY_REGISTRY as ab, EMPTY_FOUNDRY_APPLICATION as ac, EMPTY_NATIVE_REGISTRY as ad, type EgressAdapter as ae, type EgressContext as af, type EnvironmentValue as ag, type EventFilter as ah, EventId as ai, EventNotFound as aj, EventReference as ak, EventStore as al, FOUNDRY_AGENT_APPLICATION_BRAND as am, FOUNDRY_AGENT_BRAND as an, FOUNDRY_AGENT_DEFINITION_BRAND as ao, FOUNDRY_AGENT_FILE_ENV as ap, FOUNDRY_AGENT_ROUTE_ENV as aq, FOUNDRY_APPLICATION_BRAND as ar, FOUNDRY_APPLICATION_ENV as as, FOUNDRY_COMPOSED_PLAYBOOK_BRAND as at, FOUNDRY_CONNECTION_BRAND as au, FOUNDRY_CORE_COMMAND_EVENT as av, FOUNDRY_EVENT_PREFIX as aw, FOUNDRY_EXECUTION_MARKER as ax, FOUNDRY_LAYER_BRAND as ay, FOUNDRY_MCP_BRAND as az, type AnyFoundryTransmission as b, type FoundryWorkingEnvironmentCreateContext as b$, type FoundryCapabilityManifestEntry as b0, type FoundryCapabilityRegistry as b1, FoundryClient as b2, type FoundryClientOptions as b3, type FoundryCompositionSource as b4, type FoundryCoreCommand as b5, type FoundryDataAdapter as b6, type FoundryDomainError as b7, type FoundryEvent as b8, type FoundryEventCategory as b9, type FoundryNativeRegistry as bA, type FoundryObservabilityAdapter as bB, type FoundryPlaybookAction as bC, type FoundryPythonReplDefinition as bD, type FoundryReplDefinition as bE, type FoundryRequest as bF, type FoundryResolver as bG, type FoundryResult as bH, type FoundryRouteMap as bI, type FoundryRun as bJ, FoundryRunHandle as bK, FoundryRuntimeError as bL, type FoundryRuntimeOptions as bM, type FoundryScheduleDefinition as bN, type FoundryScheduleTiming as bO, type FoundryScheduleTimingInput as bP, type FoundrySharedTool as bQ, type FoundrySubscriber as bR, type FoundrySubscriberOptions as bS, type FoundrySubscriberSelection as bT, type FoundrySurfaceContext as bU, type FoundryTask as bV, type FoundryTransmission as bW, type FoundryTransmissionEvent as bX, type FoundryTransmissionPredicate as bY, type FoundryVfs as bZ, type FoundryVfsHandle as b_, type FoundryExecutionContext as ba, type FoundryHealth as bb, type FoundryHookDefinition as bc, type FoundryInstallable as bd, type FoundryInstanceProvisioner as be, type FoundryJavaScriptReplDefinition as bf, type FoundryLayer as bg, type FoundryLayerOptions as bh, type FoundryLayerReference as bi, type FoundryLayerSelection as bj, type FoundryLispReplDefinition as bk, type FoundryListResolver as bl, type FoundryManifestAgent as bm, FoundryManifestCapability as bn, FoundryManifestTransmission as bo, type FoundryMcp as bp, type FoundryMcpOptions as bq, type FoundryMemoryProfile as br, type FoundryMemoryProfileOptions as bs, type FoundryMemoryReference as bt, type FoundryMemorySelection as bu, type FoundryMeshConfig as bv, type FoundryMessageInput as bw, type FoundryMountedRepl as bx, type FoundryNativeManifest as by, type FoundryNativeManifestEntry as bz, AccountReference as c, createManifest as c$, type FoundryWorkingEnvironmentDefinition as c0, type FoundryWorkingEnvironmentPersistenceAdapter as c1, type FoundryWorkingEnvironmentPersistenceContext as c2, type FoundryWorkingEnvironmentSnapshotOwner as c3, GrantResolutionError as c4, GrantResolver as c5, type InboundContract as c6, type InboundDeliveryClaim as c7, type InferAgentInput as c8, type InferAgentOutput as c9, RouteId as cA, RouteNotFound as cB, RunGrant as cC, RunId as cD, type SharedInboxItem as cE, type SharedToolOptions as cF, TopologyConflict as cG, TopologyStore as cH, type TransmissionEventDirection as cI, type TransmissionEventOptions as cJ, TransmissionId as cK, type TransmissionOptions as cL, type TransmissionPredicateOptions as cM, type TransmissionSerializationContext as cN, type UpdateAgentInstanceOptions as cO, type WaitOptions as cP, type WorkspaceEntry as cQ, compileApplicationManifest as cR, composeAgent as cS, composePlaybook as cT, configureLayer as cU, configureMemory as cV, createAgentInstance as cW, createConversation as cX, createFoundryClient as cY, createFoundryCoreTools as cZ, createInstalledApplicationTransmissionTools as c_, type InferInboundEvent as ca, type InferOutboundInput as cb, type InferOutboundOutput as cc, type IngressAdapter as cd, type IngressContext as ce, type InstallationSelection as cf, ManifestCompilationError as cg, type McpAdapterFactory as ch, MemoryFoundryDataAdapter as ci, MemoryObservabilityAdapter as cj, type OutboundContract as ck, type PlaybookActionOptions as cl, type PlaybookDirective as cm, type PlaybookDirectiveInput as cn, type PlaybookMatch as co, type PlaybookMatchInput as cp, type PlaybookOutboundDirective as cq, type PlaybookOutboundInput as cr, type PlaybookSubscription as cs, type PlaybookSubscriptionTarget as ct, type PlaybookSubscriptionTargetInput as cu, type ProvisionAgentOptions as cv, ReplyPolicy as cw, type ResolveGrantRequest as cx, Route as cy, type RouteFilter as cz, AgentBinding as d, defineAgent as d0, defineAgentApplication as d1, defineAgentFromModule as d2, defineAgentInstance as d3, defineApp as d4, defineApplication as d5, defineCall as d6, defineConnection as d7, defineLayer as d8, defineMcp as d9, isFoundryLayer as dA, isFoundrySchedule as dB, isFoundrySubscriber as dC, isFoundryTransmission as dD, isInboxCapableStore as dE, memoryAccountDirectory as dF, memoryEventStore as dG, memoryTopologyStore as dH, mountAgentDefinitionMemory as dI, mountFoundrySurfaces as dJ, reconstructAgentInstance as dK, reconstructPlaybook as dL, reconstructPlaybookSubscription as dM, routeFromAgentFile as dN, routeFromInternalAgentName as dO, toGloveMessage as dP, toGloveRequestInput as dQ, transmissionPredicate as dR, defineMemory as da, definePlaybookAction as db, definePlaybookSubscription as dc, defineRepl as dd, defineRoutes as de, defineSchedule as df, defineSharedTool as dg, defineSubagent as dh, defineSubscriber as di, defineTransmission as dj, defineTransmissionEvent as dk, defineTransmissionPredicate as dl, defineWorkingEnvironment as dm, discoverAgents as dn, findAgentFiles as dp, foundryDataEnvironmentPersistence as dq, grantResolverLive as dr, install as ds, installRegistry as dt, installationKey as du, internalAgentName as dv, isFoundryAgent as dw, isFoundryAgentDefinition as dx, isFoundryApplication as dy, isFoundryCapability as dz, type AgentInstance as e, type FoundryAgentApplication as f, InboundRoute as g, type InferInboundConfig as h, type InferOutboundConfig as i, type AccountContract as j, AccountDirectory as k, type AccountFilter as l, AccountId as m, AccountNotFound as n, type AccountSessionAdapter as o, type AccountSessionRequest as p, AccountSessionUnavailable as q, AccountSummary as r, type AgentApplicationContribution as s, type AgentApplicationInstallContext as t, type AgentApplicationOptions as u, type AgentAssemblyContext as v, type AgentAssemblyOptions as w, AgentDefinitionId as x, type AgentDefinitionSurfaceContext as y, type AgentFactoryContext as z };