glove-foundry 0.5.2 → 0.6.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.
- package/README.md +77 -0
- package/dist/chunk-B36BGF5R.js +530 -0
- package/dist/{chunk-PVOKR4CN.js → chunk-K2EU63MB.js} +5 -0
- package/dist/{chunk-6Q2LGPSC.js → chunk-OBTOFA7W.js} +15 -1
- package/dist/{chunk-NHV64WNO.js → chunk-RSU7NEDK.js} +9 -3
- package/dist/{chunk-MABLKZVO.js → chunk-TFGETZYH.js} +188 -10
- package/dist/{chunk-D2AHSYOB.js → chunk-X6EWEWWM.js} +875 -53
- package/dist/cli.js +4 -3
- package/dist/client-DWPYe_Nc.d.ts +888 -0
- package/dist/client.d.ts +2 -1
- package/dist/{client-CLTds1uV.d.ts → definition-A8o11aez.d.ts} +193 -822
- package/dist/execution-agent.js +5 -4
- package/dist/execution-daemon.js +37 -2
- package/dist/execution-loader.js +5 -4
- package/dist/index.d.ts +8 -3
- package/dist/index.js +29 -4
- package/dist/voice.d.ts +168 -0
- package/dist/voice.js +348 -0
- package/docs/building-with-foundry.md +28 -19
- package/docs/durable-execution.md +56 -0
- package/package.json +17 -10
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { aO as FoundryAgentDefinition, s as AccountId, j as AccountReference, t as AccountNotFound, cy as TransmissionId, ct as RunId, u as AccountSessionUnavailable, J as AgentId, cq as RouteId, cp as Route, cr as RouteNotFound, cv as TopologyConflict, Y as BindingId, l as AgentBinding, Z as BindingNotFound, al as EventReference, aj as EventId, ak as EventNotFound, cs as RunGrant, c2 as GrantResolutionError, i as AnyFoundryTransmission, a as FoundryDataAdapter, be as FoundryInstanceProvisioner, aY as FoundryCapabilityRegistry, bx as FoundryNativeRegistry, C as Conversation, bE as FoundryRequest, a2 as CreateAgentInstanceOptions, b as AgentInstance, a3 as CreateConversationOptions, h as AgentPlaybook, P as PlaybookSubscription, c as FoundryActivationRecord, ac as DefinePlaybookSubscriptionOptions, V as ApplicationConnectionState, cC as UpdateAgentInstanceOptions, cD as UpdateConversationOptions, W as WorkspaceEntry, S as SharedInboxItem, g as FoundryTask, E as EnvironmentValue, bt as FoundryMessageInput, bH as FoundryResult, aW as FoundryCapabilityManifest, bv as FoundryNativeManifest, L as AgentInstallation, b4 as FoundryDelegationStatus, b2 as FoundryDelegation, bI as FoundryRouteMap, v as AccountSummary, T as AnyFoundryAgent } from './definition-A8o11aez.js';
|
|
2
|
+
import { Context, Effect, Layer, Schema } from 'effect';
|
|
3
|
+
import * as effect_Brand from 'effect/Brand';
|
|
4
|
+
import { StoreAdapter, Displaymanager, DisplayManagerAdapter, Slot, Message, TokenConsumptionCounter } from 'glove-core';
|
|
5
|
+
import { FoundryStationDaemonAdapter } from './station.js';
|
|
6
|
+
import { FoundryConfig } from './config.js';
|
|
7
|
+
|
|
8
|
+
interface DiscoveredAgent {
|
|
9
|
+
route: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
relativePath: string;
|
|
12
|
+
definition: FoundryAgentDefinition;
|
|
13
|
+
executionName: string;
|
|
14
|
+
}
|
|
15
|
+
interface FoundryManifestAgent {
|
|
16
|
+
id: string;
|
|
17
|
+
description: string;
|
|
18
|
+
mode: "agent";
|
|
19
|
+
file: string;
|
|
20
|
+
tags: readonly string[];
|
|
21
|
+
invocationContract: "foundry/request-v1";
|
|
22
|
+
resultContract: "foundry/result-v1";
|
|
23
|
+
assembly: "foundry" | "custom";
|
|
24
|
+
handler: "glove" | "custom";
|
|
25
|
+
layers: readonly string[];
|
|
26
|
+
subscribers: readonly string[];
|
|
27
|
+
tools: readonly string[];
|
|
28
|
+
hooks: readonly string[];
|
|
29
|
+
skills: readonly string[];
|
|
30
|
+
subagents: readonly string[];
|
|
31
|
+
memory: readonly string[];
|
|
32
|
+
inboxLoader: boolean;
|
|
33
|
+
calls: readonly string[];
|
|
34
|
+
schedules: readonly string[];
|
|
35
|
+
playbooks: readonly string[];
|
|
36
|
+
mesh: boolean;
|
|
37
|
+
workingEnvironment: boolean;
|
|
38
|
+
repl: "javascript" | "python" | "lisp" | "dynamic" | null;
|
|
39
|
+
lazy: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
interface FoundryManifest {
|
|
42
|
+
version: 1;
|
|
43
|
+
generatedAt: string;
|
|
44
|
+
agents: FoundryManifestAgent[];
|
|
45
|
+
}
|
|
46
|
+
declare function routeFromAgentFile(agentsDir: string, filePath: string): string | null;
|
|
47
|
+
declare function findAgentFiles(agentsDir: string): Promise<string[]>;
|
|
48
|
+
declare function discoverAgents(options: {
|
|
49
|
+
agentsDir: string;
|
|
50
|
+
strictFileRoutes?: boolean;
|
|
51
|
+
cacheBust?: boolean;
|
|
52
|
+
}): Promise<DiscoveredAgent[]>;
|
|
53
|
+
declare function createManifest(agents: readonly DiscoveredAgent[]): FoundryManifest;
|
|
54
|
+
|
|
55
|
+
interface AccountFilter {
|
|
56
|
+
readonly transmissionId?: TransmissionId;
|
|
57
|
+
}
|
|
58
|
+
declare const AccountDirectory_base: Context.TagClass<AccountDirectory, "@glove-foundry/AccountDirectory", {
|
|
59
|
+
readonly get: (id: AccountId) => Effect.Effect<AccountReference, AccountNotFound>;
|
|
60
|
+
readonly list: (filter?: AccountFilter) => Effect.Effect<ReadonlyArray<AccountReference>>;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Read-only account metadata supplied by the application. Deliberately no
|
|
64
|
+
* create, authorize, refresh, revoke, token, or credential methods exist.
|
|
65
|
+
*/
|
|
66
|
+
declare class AccountDirectory extends AccountDirectory_base {
|
|
67
|
+
}
|
|
68
|
+
interface RouteFilter {
|
|
69
|
+
readonly transmissionId?: TransmissionId;
|
|
70
|
+
readonly accountId?: AccountId;
|
|
71
|
+
readonly direction?: Route["direction"];
|
|
72
|
+
readonly enabled?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface BindingFilter {
|
|
75
|
+
readonly agentId?: AgentId;
|
|
76
|
+
readonly transmissionId?: TransmissionId;
|
|
77
|
+
readonly accountId?: AccountId;
|
|
78
|
+
readonly routeId?: RouteId;
|
|
79
|
+
readonly enabled?: boolean;
|
|
80
|
+
}
|
|
81
|
+
declare const TopologyStore_base: Context.TagClass<TopologyStore, "@glove-foundry/TopologyStore", {
|
|
82
|
+
readonly getRoute: (id: RouteId) => Effect.Effect<Route, RouteNotFound>;
|
|
83
|
+
readonly listRoutes: (filter?: RouteFilter) => Effect.Effect<ReadonlyArray<Route>>;
|
|
84
|
+
readonly putRoute: (route: Route) => Effect.Effect<Route, TopologyConflict>;
|
|
85
|
+
readonly removeRoute: (id: RouteId) => Effect.Effect<void, RouteNotFound>;
|
|
86
|
+
readonly getBinding: (id: BindingId) => Effect.Effect<AgentBinding, BindingNotFound>;
|
|
87
|
+
readonly listBindings: (filter?: BindingFilter) => Effect.Effect<ReadonlyArray<AgentBinding>>;
|
|
88
|
+
readonly putBinding: (binding: AgentBinding) => Effect.Effect<AgentBinding, TopologyConflict>;
|
|
89
|
+
readonly removeBinding: (id: BindingId) => Effect.Effect<void, BindingNotFound>;
|
|
90
|
+
}>;
|
|
91
|
+
/** Durable desired topology. It stores opaque account ids, never credentials. */
|
|
92
|
+
declare class TopologyStore extends TopologyStore_base {
|
|
93
|
+
}
|
|
94
|
+
declare const EventStore_base: Context.TagClass<EventStore, "@glove-foundry/EventStore", {
|
|
95
|
+
readonly put: (reference: EventReference, payload: unknown) => Effect.Effect<void>;
|
|
96
|
+
readonly getReference: (id: EventId) => Effect.Effect<EventReference, EventNotFound>;
|
|
97
|
+
readonly getPayload: (id: EventId) => Effect.Effect<unknown, EventNotFound>;
|
|
98
|
+
}>;
|
|
99
|
+
declare class EventStore extends EventStore_base {
|
|
100
|
+
}
|
|
101
|
+
interface AccountSessionRequest {
|
|
102
|
+
readonly account: AccountReference;
|
|
103
|
+
readonly operation: string;
|
|
104
|
+
readonly runId?: RunId;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A user-owned adapter that produces an operation-scoped Effect Layer. Its
|
|
108
|
+
* implementation owns credential lookup, refresh, SDK construction, and
|
|
109
|
+
* cleanup. Foundry only provides the resulting service to the operation.
|
|
110
|
+
*/
|
|
111
|
+
interface AccountSessionAdapter<TSession> {
|
|
112
|
+
readonly layer: (request: AccountSessionRequest) => Layer.Layer<TSession, AccountSessionUnavailable>;
|
|
113
|
+
}
|
|
114
|
+
declare function memoryAccountDirectory(accounts: ReadonlyArray<AccountReference>): Layer.Layer<AccountDirectory>;
|
|
115
|
+
declare const memoryTopologyStore: Layer.Layer<TopologyStore>;
|
|
116
|
+
declare const memoryEventStore: Layer.Layer<EventStore>;
|
|
117
|
+
|
|
118
|
+
interface ResolveGrantRequest {
|
|
119
|
+
readonly runId: RunId;
|
|
120
|
+
readonly agentId: AgentId;
|
|
121
|
+
/** The inbound route that caused the run, when one exists. */
|
|
122
|
+
readonly originRouteId?: RouteId;
|
|
123
|
+
}
|
|
124
|
+
declare const GrantResolver_base: Context.TagClass<GrantResolver, "@glove-foundry/GrantResolver", {
|
|
125
|
+
readonly resolve: (request: ResolveGrantRequest) => Effect.Effect<RunGrant, GrantResolutionError>;
|
|
126
|
+
}>;
|
|
127
|
+
declare class GrantResolver extends GrantResolver_base {
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolve desired bindings into immutable authority for exactly one run.
|
|
131
|
+
* Agents consume the resulting grant; they never query the topology directly.
|
|
132
|
+
*/
|
|
133
|
+
declare const grantResolverLive: Layer.Layer<GrantResolver, never, TopologyStore>;
|
|
134
|
+
|
|
135
|
+
declare const FoundryManifestCapability: Schema.Struct<{
|
|
136
|
+
id: typeof Schema.String;
|
|
137
|
+
description: typeof Schema.String;
|
|
138
|
+
account: Schema.Literal<["none", "optional", "required"]>;
|
|
139
|
+
effect: Schema.Literal<["read", "write"]>;
|
|
140
|
+
}>;
|
|
141
|
+
declare const FoundryManifestTransmission: Schema.Struct<{
|
|
142
|
+
id: typeof Schema.String;
|
|
143
|
+
name: typeof Schema.String;
|
|
144
|
+
description: typeof Schema.String;
|
|
145
|
+
shape: Schema.Literal<["capability-only", "inbound-only", "outbound-only", "bidirectional"]>;
|
|
146
|
+
account: Schema.optional<Schema.Struct<{
|
|
147
|
+
required: typeof Schema.Boolean;
|
|
148
|
+
metadataSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
149
|
+
}>>;
|
|
150
|
+
capabilities: Schema.Array$<Schema.Struct<{
|
|
151
|
+
id: typeof Schema.String;
|
|
152
|
+
description: typeof Schema.String;
|
|
153
|
+
account: Schema.Literal<["none", "optional", "required"]>;
|
|
154
|
+
effect: Schema.Literal<["read", "write"]>;
|
|
155
|
+
}>>;
|
|
156
|
+
inbound: Schema.optional<Schema.Struct<{
|
|
157
|
+
configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
158
|
+
eventSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
159
|
+
}>>;
|
|
160
|
+
outbound: Schema.optional<Schema.Struct<{
|
|
161
|
+
configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
162
|
+
inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
163
|
+
outputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
164
|
+
}>>;
|
|
165
|
+
}>;
|
|
166
|
+
declare const FoundryApplicationManifest: Schema.Struct<{
|
|
167
|
+
schemaVersion: Schema.Literal<[2]>;
|
|
168
|
+
generatedAt: typeof Schema.String;
|
|
169
|
+
transmissions: Schema.Array$<Schema.Struct<{
|
|
170
|
+
id: typeof Schema.String;
|
|
171
|
+
name: typeof Schema.String;
|
|
172
|
+
description: typeof Schema.String;
|
|
173
|
+
shape: Schema.Literal<["capability-only", "inbound-only", "outbound-only", "bidirectional"]>;
|
|
174
|
+
account: Schema.optional<Schema.Struct<{
|
|
175
|
+
required: typeof Schema.Boolean;
|
|
176
|
+
metadataSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
177
|
+
}>>;
|
|
178
|
+
capabilities: Schema.Array$<Schema.Struct<{
|
|
179
|
+
id: typeof Schema.String;
|
|
180
|
+
description: typeof Schema.String;
|
|
181
|
+
account: Schema.Literal<["none", "optional", "required"]>;
|
|
182
|
+
effect: Schema.Literal<["read", "write"]>;
|
|
183
|
+
}>>;
|
|
184
|
+
inbound: Schema.optional<Schema.Struct<{
|
|
185
|
+
configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
186
|
+
eventSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
187
|
+
}>>;
|
|
188
|
+
outbound: Schema.optional<Schema.Struct<{
|
|
189
|
+
configSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
190
|
+
inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
191
|
+
outputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
192
|
+
}>>;
|
|
193
|
+
}>>;
|
|
194
|
+
}>;
|
|
195
|
+
type FoundryApplicationManifest = typeof FoundryApplicationManifest.Type;
|
|
196
|
+
declare const ManifestCompilationError_base: Schema.TaggedErrorClass<ManifestCompilationError, "ManifestCompilationError", {
|
|
197
|
+
readonly _tag: Schema.tag<"ManifestCompilationError">;
|
|
198
|
+
} & {
|
|
199
|
+
message: typeof Schema.String;
|
|
200
|
+
}>;
|
|
201
|
+
declare class ManifestCompilationError extends ManifestCompilationError_base {
|
|
202
|
+
}
|
|
203
|
+
/** Compile code definitions into a value-only, credential-free manifest. */
|
|
204
|
+
declare function compileApplicationManifest(transmissions: ReadonlyArray<AnyFoundryTransmission>): Effect.Effect<FoundryApplicationManifest, ManifestCompilationError>;
|
|
205
|
+
|
|
206
|
+
type FoundryEventCategory = "agent" | "run" | "model" | "tool" | "extension" | "application" | "inbox" | "memory" | "mcp" | "activation" | "system" | "log";
|
|
207
|
+
interface FoundryEvent {
|
|
208
|
+
readonly id: string;
|
|
209
|
+
readonly sequence: number;
|
|
210
|
+
readonly timestamp: string;
|
|
211
|
+
readonly type: string;
|
|
212
|
+
readonly category: FoundryEventCategory;
|
|
213
|
+
readonly agent?: string;
|
|
214
|
+
readonly runId?: string;
|
|
215
|
+
readonly data: unknown;
|
|
216
|
+
}
|
|
217
|
+
interface EventFilter {
|
|
218
|
+
readonly after?: number;
|
|
219
|
+
readonly agent?: string;
|
|
220
|
+
readonly runId?: string;
|
|
221
|
+
readonly category?: FoundryEventCategory;
|
|
222
|
+
readonly limit?: number;
|
|
223
|
+
}
|
|
224
|
+
interface FoundryObservabilityAdapter {
|
|
225
|
+
append(event: Omit<FoundryEvent, "id" | "sequence" | "timestamp"> & {
|
|
226
|
+
timestamp?: string;
|
|
227
|
+
}): FoundryEvent;
|
|
228
|
+
list(filter?: EventFilter): FoundryEvent[];
|
|
229
|
+
subscribe(listener: (event: FoundryEvent) => void): () => void;
|
|
230
|
+
clear?(): void | Promise<void>;
|
|
231
|
+
}
|
|
232
|
+
declare class MemoryObservabilityAdapter implements FoundryObservabilityAdapter {
|
|
233
|
+
private readonly maxEvents;
|
|
234
|
+
private readonly events;
|
|
235
|
+
private readonly listeners;
|
|
236
|
+
private sequence;
|
|
237
|
+
constructor(options?: {
|
|
238
|
+
maxEvents?: number;
|
|
239
|
+
});
|
|
240
|
+
append(input: Omit<FoundryEvent, "id" | "sequence" | "timestamp"> & {
|
|
241
|
+
timestamp?: string;
|
|
242
|
+
}): FoundryEvent;
|
|
243
|
+
list(filter?: EventFilter): FoundryEvent[];
|
|
244
|
+
subscribe(listener: (event: FoundryEvent) => void): () => void;
|
|
245
|
+
clear(): void;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare const FOUNDRY_APPLICATION_BRAND: unique symbol;
|
|
249
|
+
/**
|
|
250
|
+
* Secret-bearing HTTP request data passed only to the consumer-owned
|
|
251
|
+
* authorization adapter. Foundry does not persist or observe this value.
|
|
252
|
+
*/
|
|
253
|
+
interface FoundryRequestAuthorizationInput {
|
|
254
|
+
readonly method: string;
|
|
255
|
+
readonly path: string;
|
|
256
|
+
readonly query: string;
|
|
257
|
+
readonly authorization?: string;
|
|
258
|
+
readonly cookie?: string;
|
|
259
|
+
readonly remoteAddress?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Gate the Foundry HTTP surface without making credential acquisition or
|
|
263
|
+
* refresh a framework concern. The adapter may validate a basic/bearer
|
|
264
|
+
* credential, a session cookie, or an identity asserted by a trusted proxy.
|
|
265
|
+
*/
|
|
266
|
+
interface FoundryRequestAuthorizationAdapter<TError = never> {
|
|
267
|
+
readonly identifier: string;
|
|
268
|
+
/** Value for WWW-Authenticate when access is denied. */
|
|
269
|
+
readonly challenge?: string;
|
|
270
|
+
readonly authorize: (input: FoundryRequestAuthorizationInput) => Effect.Effect<boolean, TError, never>;
|
|
271
|
+
}
|
|
272
|
+
/** Process infrastructure only; agent files own runtime capabilities. */
|
|
273
|
+
interface FoundryApplicationOptions {
|
|
274
|
+
readonly name: string;
|
|
275
|
+
/** Optional configuration of the managed daemon; loaded from the application file in its process. */
|
|
276
|
+
readonly daemon?: FoundryStationDaemonAdapter;
|
|
277
|
+
readonly accounts?: ReadonlyArray<AccountReference>;
|
|
278
|
+
readonly routes?: ReadonlyArray<Route>;
|
|
279
|
+
readonly bindings?: ReadonlyArray<AgentBinding>;
|
|
280
|
+
readonly data?: FoundryDataAdapter;
|
|
281
|
+
readonly conversationStore?: (scope: {
|
|
282
|
+
readonly definitionId: string;
|
|
283
|
+
readonly agentId: string;
|
|
284
|
+
readonly conversationId: string;
|
|
285
|
+
readonly workspaceId: string;
|
|
286
|
+
}) => Promise<StoreAdapter> | StoreAdapter;
|
|
287
|
+
/**
|
|
288
|
+
* User-owned HTTP authorization boundary. Required for non-loopback binds;
|
|
289
|
+
* credential values never enter Foundry data, manifests, or observability.
|
|
290
|
+
*/
|
|
291
|
+
readonly requestAuthorization?: FoundryRequestAuthorizationAdapter<unknown>;
|
|
292
|
+
/** User-owned strategy for subscriptions using `provisioning.mode = "custom"`. */
|
|
293
|
+
readonly provisioner?: FoundryInstanceProvisioner;
|
|
294
|
+
readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
|
|
295
|
+
}
|
|
296
|
+
type FoundryApplication = Readonly<FoundryApplicationOptions> & {
|
|
297
|
+
readonly [FOUNDRY_APPLICATION_BRAND]: true;
|
|
298
|
+
};
|
|
299
|
+
declare function isFoundryApplication(value: unknown): value is FoundryApplication;
|
|
300
|
+
/** Define infrastructure. Agent composition is deliberately absent here. */
|
|
301
|
+
declare function defineApplication(options: FoundryApplicationOptions): FoundryApplication;
|
|
302
|
+
declare const EMPTY_FOUNDRY_APPLICATION: FoundryApplication;
|
|
303
|
+
|
|
304
|
+
interface DiscoveredCapability {
|
|
305
|
+
readonly kind: "tool" | "application" | "mcp" | "memory";
|
|
306
|
+
readonly id: string;
|
|
307
|
+
readonly filePath: string;
|
|
308
|
+
readonly relativePath: string;
|
|
309
|
+
}
|
|
310
|
+
interface DiscoveredFoundryRegistry {
|
|
311
|
+
readonly capabilities: FoundryCapabilityRegistry;
|
|
312
|
+
readonly native: FoundryNativeRegistry;
|
|
313
|
+
readonly files: ReadonlyArray<DiscoveredCapability>;
|
|
314
|
+
readonly nativeFiles: ReadonlyArray<{
|
|
315
|
+
readonly kind: "layer" | "subscriber";
|
|
316
|
+
readonly id: string;
|
|
317
|
+
readonly filePath: string;
|
|
318
|
+
readonly relativePath: string;
|
|
319
|
+
}>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
declare const FOUNDRY_APPROVAL_DIRECTORY_ENV = "GLOVE_FOUNDRY_APPROVAL_DIRECTORY";
|
|
323
|
+
type FoundryApprovalDecision = "approve" | "deny";
|
|
324
|
+
type FoundryApprovalStatus = "pending" | "approved" | "denied" | "expired" | "cancelled";
|
|
325
|
+
interface FoundryApproval {
|
|
326
|
+
readonly id: string;
|
|
327
|
+
readonly runId: string;
|
|
328
|
+
readonly definitionId: string;
|
|
329
|
+
readonly agentId: string;
|
|
330
|
+
readonly conversationId: string;
|
|
331
|
+
readonly workspaceId: string;
|
|
332
|
+
readonly toolName: string;
|
|
333
|
+
readonly toolInput: unknown;
|
|
334
|
+
readonly status: FoundryApprovalStatus;
|
|
335
|
+
readonly requestedAt: string;
|
|
336
|
+
readonly expiresAt: string;
|
|
337
|
+
readonly resolvedAt?: string;
|
|
338
|
+
}
|
|
339
|
+
declare function createFoundryApproval(directory: string, input: {
|
|
340
|
+
readonly runId: string;
|
|
341
|
+
readonly definitionId: string;
|
|
342
|
+
readonly agentId: string;
|
|
343
|
+
readonly conversationId: string;
|
|
344
|
+
readonly workspaceId: string;
|
|
345
|
+
readonly toolName: string;
|
|
346
|
+
readonly toolInput: unknown;
|
|
347
|
+
readonly timeoutMs?: number;
|
|
348
|
+
}): Promise<FoundryApproval>;
|
|
349
|
+
declare function listFoundryApprovals(directory: string, filter?: {
|
|
350
|
+
readonly runId?: string;
|
|
351
|
+
readonly status?: FoundryApprovalStatus;
|
|
352
|
+
}): Promise<ReadonlyArray<FoundryApproval>>;
|
|
353
|
+
declare function resolveFoundryApproval(directory: string, id: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
|
|
354
|
+
declare class FoundryApprovalDisplayManager extends Displaymanager implements DisplayManagerAdapter {
|
|
355
|
+
private readonly context;
|
|
356
|
+
constructor(context: {
|
|
357
|
+
readonly directory?: string;
|
|
358
|
+
readonly runId: string;
|
|
359
|
+
readonly definitionId: string;
|
|
360
|
+
readonly agentId: string;
|
|
361
|
+
readonly conversationId: string;
|
|
362
|
+
readonly workspaceId: string;
|
|
363
|
+
readonly signal: AbortSignal;
|
|
364
|
+
readonly emit: (event: {
|
|
365
|
+
readonly type: string;
|
|
366
|
+
readonly data?: unknown;
|
|
367
|
+
}) => void;
|
|
368
|
+
});
|
|
369
|
+
pushAndWait<I, O>(slot: Omit<Slot<I>, "id">): Promise<O>;
|
|
370
|
+
}
|
|
371
|
+
/** Add fail-closed per-input permissions to a custom store that omitted them. */
|
|
372
|
+
declare function withFoundryPermissions(store: StoreAdapter): StoreAdapter;
|
|
373
|
+
|
|
374
|
+
interface FoundryRun<TOutput = unknown> {
|
|
375
|
+
readonly id: string;
|
|
376
|
+
readonly agent: string;
|
|
377
|
+
readonly kind: "trigger" | "recurring";
|
|
378
|
+
readonly status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
379
|
+
readonly input: unknown;
|
|
380
|
+
readonly output?: TOutput;
|
|
381
|
+
readonly agentId?: string;
|
|
382
|
+
readonly conversationId?: string;
|
|
383
|
+
readonly workspaceId?: string;
|
|
384
|
+
readonly error?: string;
|
|
385
|
+
readonly attempts: number;
|
|
386
|
+
readonly maxAttempts: number;
|
|
387
|
+
readonly timeoutMs: number;
|
|
388
|
+
readonly createdAt: string;
|
|
389
|
+
readonly startedAt?: string;
|
|
390
|
+
readonly completedAt?: string;
|
|
391
|
+
}
|
|
392
|
+
interface FoundrySteerResult<TOutput = unknown> {
|
|
393
|
+
/** The run whose direction was changed. */
|
|
394
|
+
readonly fromRunId: string;
|
|
395
|
+
/** True when an active source run accepted cooperative cancellation. */
|
|
396
|
+
readonly interrupted: boolean;
|
|
397
|
+
/** The replacement run in the same instance and conversation. */
|
|
398
|
+
readonly run: FoundryRun<TOutput>;
|
|
399
|
+
}
|
|
400
|
+
/** Exact native Glove history and counters for one persisted conversation. */
|
|
401
|
+
interface FoundryConversationTranscript {
|
|
402
|
+
readonly conversation: Conversation;
|
|
403
|
+
readonly messages: ReadonlyArray<Message>;
|
|
404
|
+
readonly turnCount: number;
|
|
405
|
+
readonly tokenCount: number;
|
|
406
|
+
readonly tokenConsumption?: TokenConsumptionCounter;
|
|
407
|
+
readonly page: {
|
|
408
|
+
readonly offset: number;
|
|
409
|
+
readonly limit: number;
|
|
410
|
+
readonly total: number;
|
|
411
|
+
readonly hasEarlier: boolean;
|
|
412
|
+
readonly hasLater: boolean;
|
|
413
|
+
};
|
|
414
|
+
/** False means the definition did not configure a durable conversation store. */
|
|
415
|
+
readonly persisted: boolean;
|
|
416
|
+
}
|
|
417
|
+
declare const FoundryRuntimeError_base: Schema.TaggedErrorClass<FoundryRuntimeError, "FoundryRuntimeError", {
|
|
418
|
+
readonly _tag: Schema.tag<"FoundryRuntimeError">;
|
|
419
|
+
} & {
|
|
420
|
+
operation: typeof Schema.String;
|
|
421
|
+
message: typeof Schema.String;
|
|
422
|
+
}>;
|
|
423
|
+
declare class FoundryRuntimeError extends FoundryRuntimeError_base {
|
|
424
|
+
}
|
|
425
|
+
interface FoundryRuntimeOptions {
|
|
426
|
+
readonly rootDir: string;
|
|
427
|
+
readonly agents: DiscoveredAgent[];
|
|
428
|
+
readonly application?: FoundryApplication;
|
|
429
|
+
readonly applicationFilePath?: string;
|
|
430
|
+
readonly registry?: DiscoveredFoundryRegistry;
|
|
431
|
+
readonly config?: FoundryConfig;
|
|
432
|
+
readonly observability?: FoundryObservabilityAdapter;
|
|
433
|
+
}
|
|
434
|
+
declare class FoundryRuntime {
|
|
435
|
+
readonly rootDir: string;
|
|
436
|
+
readonly agents: readonly DiscoveredAgent[];
|
|
437
|
+
readonly application: FoundryApplication;
|
|
438
|
+
readonly applicationFilePath?: string;
|
|
439
|
+
readonly registry: DiscoveredFoundryRegistry;
|
|
440
|
+
readonly manifest: FoundryManifest;
|
|
441
|
+
readonly applicationManifest: FoundryApplicationManifest;
|
|
442
|
+
readonly observability: FoundryObservabilityAdapter;
|
|
443
|
+
readonly data: FoundryDataAdapter;
|
|
444
|
+
private readonly byRoute;
|
|
445
|
+
private readonly routeBySignalName;
|
|
446
|
+
private readonly transmissionById;
|
|
447
|
+
/** Stable topology view used by synchronous playbook validation. */
|
|
448
|
+
private readonly topologyRoutes;
|
|
449
|
+
private readonly compositionByDefinition;
|
|
450
|
+
private readonly connectionSupervisor;
|
|
451
|
+
private readonly execution;
|
|
452
|
+
private readonly observer;
|
|
453
|
+
private readonly signalRunner;
|
|
454
|
+
private readonly scheduleAdapter;
|
|
455
|
+
private readonly services;
|
|
456
|
+
private readonly runnerLoops;
|
|
457
|
+
private readonly materializedActivations;
|
|
458
|
+
private readonly activationTransitions;
|
|
459
|
+
private readonly activationDispatches;
|
|
460
|
+
private readonly activationTimers;
|
|
461
|
+
/** Whether each run's child process still holds its conversation, from FOUNDRY_RUN_PROCESS_EVENT. */
|
|
462
|
+
private readonly runProcesses;
|
|
463
|
+
private readonly approvalDirectory;
|
|
464
|
+
private readonly coreCommandDirectory;
|
|
465
|
+
private readonly mailboxDirectory;
|
|
466
|
+
/** The run listening for deliveries on each conversation. */
|
|
467
|
+
private readonly conversationListeners;
|
|
468
|
+
/** Runs holding each conversation, from enqueue or acquire until release. */
|
|
469
|
+
private readonly conversationRuns;
|
|
470
|
+
private readonly runConversations;
|
|
471
|
+
/** Deliveries waiting for their conversation to be free. */
|
|
472
|
+
private readonly heldDeliveries;
|
|
473
|
+
private readonly conversationQueues;
|
|
474
|
+
/** Runs cancelled by steering: a replacement follows, so their delegation stays open. */
|
|
475
|
+
private readonly steeredRuns;
|
|
476
|
+
/** One run at a time per conversation; the next starts once the one ahead has let go. */
|
|
477
|
+
private readonly gate;
|
|
478
|
+
/** Pending inbound records each run is handling, so they are cleared when it settles. */
|
|
479
|
+
private readonly pendingInboundByRun;
|
|
480
|
+
/** Recently settled runs, for a record assigned to a run that already finished. */
|
|
481
|
+
private readonly settledRuns;
|
|
482
|
+
private started;
|
|
483
|
+
private stopping;
|
|
484
|
+
private disposed;
|
|
485
|
+
constructor(options: FoundryRuntimeOptions);
|
|
486
|
+
static discover(options: {
|
|
487
|
+
rootDir: string;
|
|
488
|
+
agentsDir: string;
|
|
489
|
+
application?: FoundryApplication;
|
|
490
|
+
applicationFilePath?: string;
|
|
491
|
+
config?: FoundryConfig;
|
|
492
|
+
observability?: FoundryObservabilityAdapter;
|
|
493
|
+
}): Promise<FoundryRuntime>;
|
|
494
|
+
startEffect(): Effect.Effect<void, FoundryRuntimeError>;
|
|
495
|
+
start(): Promise<void>;
|
|
496
|
+
stopEffect(): Effect.Effect<void, FoundryRuntimeError>;
|
|
497
|
+
stop(): Promise<void>;
|
|
498
|
+
requestEffect(route: string, request: FoundryRequest, options?: {
|
|
499
|
+
readonly front?: boolean;
|
|
500
|
+
}): Effect.Effect<FoundryRun, FoundryRuntimeError>;
|
|
501
|
+
request(route: string, request: FoundryRequest): Promise<FoundryRun>;
|
|
502
|
+
createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
|
|
503
|
+
createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
|
|
504
|
+
listAgentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
|
|
505
|
+
setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
|
|
506
|
+
listPlaybookSubscriptions(workspaceId?: string): Promise<ReadonlyArray<PlaybookSubscription>>;
|
|
507
|
+
/** List persisted future activations created by schedules or sleeping runs. */
|
|
508
|
+
listActivations(workspaceId?: string): Promise<ReadonlyArray<FoundryActivationRecord>>;
|
|
509
|
+
putPlaybookSubscription(input: DefinePlaybookSubscriptionOptions | PlaybookSubscription): Promise<PlaybookSubscription>;
|
|
510
|
+
deletePlaybookSubscription(id: string): Promise<boolean>;
|
|
511
|
+
listApplicationConnections(): ReadonlyArray<ApplicationConnectionState>;
|
|
512
|
+
reconnectApplicationConnection(id: string): Promise<void>;
|
|
513
|
+
/** Atomically replace the persisted, frontend-editable instance configuration. */
|
|
514
|
+
configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
|
|
515
|
+
listConversations(agentId: string): Promise<ReadonlyArray<Conversation>>;
|
|
516
|
+
updateConversation(agentId: string, conversationId: string, options: UpdateConversationOptions): Promise<Conversation>;
|
|
517
|
+
/**
|
|
518
|
+
* Read the same StoreAdapter the child agent process uses. Foundry never
|
|
519
|
+
* reconstructs chat history from runs or observability events: adapters stay
|
|
520
|
+
* the single source of truth for durable conversations.
|
|
521
|
+
*/
|
|
522
|
+
conversationTranscript(agentId: string, conversationId: string, options?: {
|
|
523
|
+
readonly offset?: number;
|
|
524
|
+
readonly limit?: number;
|
|
525
|
+
}): Promise<FoundryConversationTranscript>;
|
|
526
|
+
listWorkspaceEntries(workspaceId: string): Promise<ReadonlyArray<WorkspaceEntry>>;
|
|
527
|
+
putWorkspaceEntry(workspaceId: string, key: string, value: unknown): Promise<WorkspaceEntry>;
|
|
528
|
+
listSharedInbox(workspaceId: string): Promise<ReadonlyArray<SharedInboxItem>>;
|
|
529
|
+
postSharedInbox(input: Omit<SharedInboxItem, "id" | "createdAt" | "updatedAt">): Promise<SharedInboxItem>;
|
|
530
|
+
updateSharedInbox(workspaceId: string, itemId: string, status: SharedInboxItem["status"]): Promise<SharedInboxItem>;
|
|
531
|
+
listTasks(workspaceId: string): Promise<ReadonlyArray<FoundryTask>>;
|
|
532
|
+
createTask(input: Omit<FoundryTask, "id" | "createdAt" | "updatedAt">): Promise<FoundryTask>;
|
|
533
|
+
updateTask(workspaceId: string, taskId: string, status: FoundryTask["status"]): Promise<FoundryTask>;
|
|
534
|
+
listDataEnvironment(scope: {
|
|
535
|
+
readonly workspaceId: string;
|
|
536
|
+
readonly agentId?: string;
|
|
537
|
+
readonly conversationId?: string;
|
|
538
|
+
}): Promise<ReadonlyArray<EnvironmentValue>>;
|
|
539
|
+
send(agentId: string, conversationId: string, message: FoundryMessageInput, options?: {
|
|
540
|
+
readonly payload?: unknown;
|
|
541
|
+
readonly context?: Readonly<Record<string, unknown>>;
|
|
542
|
+
}): Promise<FoundryRun<FoundryResult>>;
|
|
543
|
+
getRun<TOutput = unknown>(runId: string): Promise<FoundryRun<TOutput> | null>;
|
|
544
|
+
listRuns(route?: string): Promise<FoundryRun[]>;
|
|
545
|
+
waitForRun<TOutput = unknown>(runId: string, options?: {
|
|
546
|
+
pollMs?: number;
|
|
547
|
+
timeoutMs?: number;
|
|
548
|
+
}): Promise<FoundryRun<TOutput> | null>;
|
|
549
|
+
cancel(runId: string): Promise<boolean>;
|
|
550
|
+
private trackRunProcess;
|
|
551
|
+
/**
|
|
552
|
+
* Wait until a cancelled run's process has let go of its conversation. A run
|
|
553
|
+
* that never started has no process. A process that dies before it reports
|
|
554
|
+
* (SIGTERM during startup, or Station's SIGKILL five seconds after the
|
|
555
|
+
* cancel) cannot report, so the wait is bounded by that kill.
|
|
556
|
+
*/
|
|
557
|
+
private waitForRunProcessRelease;
|
|
558
|
+
/**
|
|
559
|
+
* Change course at a run boundary.
|
|
560
|
+
*
|
|
561
|
+
* Foundry does not inject text into an arbitrary in-flight tool. If the
|
|
562
|
+
* source is active, steering cooperatively cancels it first, waits for that
|
|
563
|
+
* terminal boundary, then starts a replacement turn in the same durable
|
|
564
|
+
* conversation with explicit lineage in the request context.
|
|
565
|
+
*/
|
|
566
|
+
steer(runId: string, message: FoundryMessageInput): Promise<FoundrySteerResult<FoundryResult>>;
|
|
567
|
+
listApprovals(filter?: {
|
|
568
|
+
readonly runId?: string;
|
|
569
|
+
readonly status?: FoundryApprovalStatus;
|
|
570
|
+
}): Promise<ReadonlyArray<FoundryApproval>>;
|
|
571
|
+
resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
|
|
572
|
+
capabilityManifest(definitionId: string): FoundryCapabilityManifest;
|
|
573
|
+
nativeManifest(definitionId: string): FoundryNativeManifest;
|
|
574
|
+
listInstallations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
|
|
575
|
+
installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
576
|
+
uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
577
|
+
listAccounts(): Promise<{
|
|
578
|
+
id: string & effect_Brand.Brand<"FoundryAccountId">;
|
|
579
|
+
transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
|
|
580
|
+
externalAccountId: string;
|
|
581
|
+
label?: string | undefined;
|
|
582
|
+
metadata: {
|
|
583
|
+
readonly [x: string]: unknown;
|
|
584
|
+
};
|
|
585
|
+
}[]>;
|
|
586
|
+
listRoutes(): Promise<readonly ({
|
|
587
|
+
readonly id: string & effect_Brand.Brand<"FoundryRouteId">;
|
|
588
|
+
readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
|
|
589
|
+
readonly direction: "inbound";
|
|
590
|
+
readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
|
|
591
|
+
readonly visibility: "private" | "workspace";
|
|
592
|
+
readonly enabled: boolean;
|
|
593
|
+
readonly config: {
|
|
594
|
+
readonly [x: string]: unknown;
|
|
595
|
+
};
|
|
596
|
+
} | {
|
|
597
|
+
readonly id: string & effect_Brand.Brand<"FoundryRouteId">;
|
|
598
|
+
readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
|
|
599
|
+
readonly direction: "outbound";
|
|
600
|
+
readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
|
|
601
|
+
readonly visibility: "private" | "workspace";
|
|
602
|
+
readonly enabled: boolean;
|
|
603
|
+
readonly config: {
|
|
604
|
+
readonly [x: string]: unknown;
|
|
605
|
+
};
|
|
606
|
+
})[]>;
|
|
607
|
+
putRoute(route: Route): Promise<Route>;
|
|
608
|
+
removeRoute(id: RouteId): Promise<void>;
|
|
609
|
+
listBindings(): Promise<readonly {
|
|
610
|
+
readonly id: string & effect_Brand.Brand<"FoundryBindingId">;
|
|
611
|
+
readonly transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
|
|
612
|
+
readonly accountId?: (string & effect_Brand.Brand<"FoundryAccountId">) | undefined;
|
|
613
|
+
readonly enabled: boolean;
|
|
614
|
+
readonly routeId?: (string & effect_Brand.Brand<"FoundryRouteId">) | undefined;
|
|
615
|
+
readonly agentId: string & effect_Brand.Brand<"FoundryAgentId">;
|
|
616
|
+
readonly capabilities: readonly (string & effect_Brand.Brand<"FoundryCapabilityId">)[];
|
|
617
|
+
readonly reply?: {
|
|
618
|
+
readonly mode: "none";
|
|
619
|
+
} | {
|
|
620
|
+
readonly mode: "origin";
|
|
621
|
+
} | {
|
|
622
|
+
readonly mode: "route";
|
|
623
|
+
readonly routeId: string & effect_Brand.Brand<"FoundryRouteId">;
|
|
624
|
+
} | undefined;
|
|
625
|
+
}[]>;
|
|
626
|
+
putBinding(binding: AgentBinding): Promise<AgentBinding>;
|
|
627
|
+
removeBinding(id: BindingId): Promise<void>;
|
|
628
|
+
resolveGrant(request: ResolveGrantRequest): Promise<RunGrant>;
|
|
629
|
+
putEvent(reference: EventReference, payload: unknown): Promise<void>;
|
|
630
|
+
dispatchInbound(input: {
|
|
631
|
+
readonly routeId: string;
|
|
632
|
+
readonly eventId: string;
|
|
633
|
+
readonly threadKey: string;
|
|
634
|
+
readonly conversationKey?: string;
|
|
635
|
+
readonly conversationScope?: "route" | "agent";
|
|
636
|
+
readonly raw: unknown;
|
|
637
|
+
}): Promise<ReadonlyArray<FoundryRun>>;
|
|
638
|
+
dispatchOutbound(input: {
|
|
639
|
+
readonly routeId: string;
|
|
640
|
+
readonly agentId: string;
|
|
641
|
+
readonly runId: string;
|
|
642
|
+
readonly payload: unknown;
|
|
643
|
+
readonly commandId?: string;
|
|
644
|
+
readonly applicationId?: string;
|
|
645
|
+
readonly transmissionId?: string;
|
|
646
|
+
readonly signal?: AbortSignal;
|
|
647
|
+
}): Promise<unknown>;
|
|
648
|
+
health(): Promise<Record<string, unknown>>;
|
|
649
|
+
private runsFromIds;
|
|
650
|
+
private waitForInboundDelivery;
|
|
651
|
+
private validatePlaybookSubscription;
|
|
652
|
+
private playbookMatches;
|
|
653
|
+
private resolveSubscriptionTarget;
|
|
654
|
+
private attachSubscriptionPlaybook;
|
|
655
|
+
private reconcileApplicationConnections;
|
|
656
|
+
private assertRegisteredInstallation;
|
|
657
|
+
private validatePlaybooks;
|
|
658
|
+
private validateRoute;
|
|
659
|
+
private validateBinding;
|
|
660
|
+
private seedTopology;
|
|
661
|
+
private runInBackground;
|
|
662
|
+
private settleRunnerLoops;
|
|
663
|
+
/** Every delegation, newest first, optionally narrowed to one delegating conversation. */
|
|
664
|
+
listDelegations(filter?: {
|
|
665
|
+
readonly agentId?: string;
|
|
666
|
+
readonly conversationId?: string;
|
|
667
|
+
readonly status?: FoundryDelegationStatus;
|
|
668
|
+
}): Promise<ReadonlyArray<FoundryDelegation>>;
|
|
669
|
+
private openDelegationsFrom;
|
|
670
|
+
/** Run work for one conversation after the work already queued for it. */
|
|
671
|
+
private inConversation;
|
|
672
|
+
private occupyConversation;
|
|
673
|
+
private trackConversationRun;
|
|
674
|
+
private releaseConversationRun;
|
|
675
|
+
private trackConversationListener;
|
|
676
|
+
/** Take back deliveries a listener did not read, to deliver as a run. */
|
|
677
|
+
private reclaimMailbox;
|
|
678
|
+
private deliveryTargetFor;
|
|
679
|
+
private holdDeliveries;
|
|
680
|
+
private deliver;
|
|
681
|
+
/** Start one run with everything held for a conversation, once nothing else holds it. */
|
|
682
|
+
private flushHeldDeliveries;
|
|
683
|
+
/** Clear the bookkeeping that lets a restart hand these deliveries over again. */
|
|
684
|
+
private markHandedOver;
|
|
685
|
+
/** Record which run is handling a pending inbound event (none while it waits). */
|
|
686
|
+
private assignPendingInbound;
|
|
687
|
+
/** The run settled: the inbound events it was handling are done with. */
|
|
688
|
+
private finishPendingInbound;
|
|
689
|
+
/**
|
|
690
|
+
* Hand an inbound event to one agent's conversation. A free conversation
|
|
691
|
+
* starts a run for it. A busy one gets it as a delivery: it joins the
|
|
692
|
+
* running turn at its next tool step, or waits and starts the
|
|
693
|
+
* conversation's next run with anything else that arrived meanwhile.
|
|
694
|
+
* Returns the run handling it now, when there is one.
|
|
695
|
+
*/
|
|
696
|
+
private admitInbound;
|
|
697
|
+
/** After a restart, deliver the inbound events no run had finished with. */
|
|
698
|
+
private redeliverInbound;
|
|
699
|
+
/** After a restart, hand over whatever was waiting when the runtime stopped. */
|
|
700
|
+
private redeliverDelegations;
|
|
701
|
+
private reportDeliveryFailure;
|
|
702
|
+
private loadDelegation;
|
|
703
|
+
private updateDelegation;
|
|
704
|
+
private delegatorTarget;
|
|
705
|
+
private executeDelegationCommand;
|
|
706
|
+
private startDelegation;
|
|
707
|
+
/** Report a worker's finished run back to whoever delegated to it. */
|
|
708
|
+
private handleRunSettled;
|
|
709
|
+
private enqueueCoreRequest;
|
|
710
|
+
/**
|
|
711
|
+
* Create the run for a request through its conversation's gate: it starts
|
|
712
|
+
* at once when the conversation is free and waits parked, holding no
|
|
713
|
+
* concurrency slot, behind the run that holds it otherwise. A parked run
|
|
714
|
+
* starts from an envelope built when its turn comes, not when it was asked
|
|
715
|
+
* for, so it sees the conversation as the runs ahead of it left it.
|
|
716
|
+
*/
|
|
717
|
+
private admitRun;
|
|
718
|
+
private withActivationTransition;
|
|
719
|
+
private executeCoreCommand;
|
|
720
|
+
private executeCoreCommandUnlocked;
|
|
721
|
+
private syncAgentPlaybooks;
|
|
722
|
+
private assertActivationOwnership;
|
|
723
|
+
private backendScheduleId;
|
|
724
|
+
private disarmActivation;
|
|
725
|
+
private syncDefinitionSchedules;
|
|
726
|
+
private updateScheduledActivation;
|
|
727
|
+
private pauseScheduledActivation;
|
|
728
|
+
private resumeScheduledActivation;
|
|
729
|
+
private cancelScheduledActivation;
|
|
730
|
+
private reconstructActivations;
|
|
731
|
+
private materializeActivation;
|
|
732
|
+
private armOneShotActivation;
|
|
733
|
+
private deliverOutbound;
|
|
734
|
+
private executionEnvelope;
|
|
735
|
+
private toFoundryRun;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
interface FoundryClientOptions {
|
|
739
|
+
baseUrl?: string;
|
|
740
|
+
fetch?: typeof globalThis.fetch;
|
|
741
|
+
/** Resolve secret-bearing request headers outside Foundry data and state. */
|
|
742
|
+
authorization?: FoundryClientAuthorizationAdapter;
|
|
743
|
+
}
|
|
744
|
+
interface FoundryClientAuthorizationAdapter {
|
|
745
|
+
readonly identifier: string;
|
|
746
|
+
readonly headers: (request: {
|
|
747
|
+
readonly url: string;
|
|
748
|
+
readonly method: string;
|
|
749
|
+
}) => HeadersInit | Promise<HeadersInit>;
|
|
750
|
+
}
|
|
751
|
+
interface WaitOptions {
|
|
752
|
+
pollMs?: number;
|
|
753
|
+
timeoutMs?: number;
|
|
754
|
+
signal?: AbortSignal;
|
|
755
|
+
}
|
|
756
|
+
interface FoundrySteerHandleResult<TOutput = unknown> {
|
|
757
|
+
readonly fromRunId: string;
|
|
758
|
+
readonly interrupted: boolean;
|
|
759
|
+
readonly run: FoundryRunHandle<TOutput>;
|
|
760
|
+
}
|
|
761
|
+
interface FoundryHealth {
|
|
762
|
+
readonly ok: boolean;
|
|
763
|
+
readonly execution: boolean;
|
|
764
|
+
readonly environment: boolean;
|
|
765
|
+
readonly activations: boolean;
|
|
766
|
+
readonly agents: number;
|
|
767
|
+
readonly capabilities: number;
|
|
768
|
+
readonly surfaces: number;
|
|
769
|
+
}
|
|
770
|
+
declare class FoundryRunHandle<TOutput> {
|
|
771
|
+
readonly id: string;
|
|
772
|
+
readonly initial: FoundryRun<TOutput>;
|
|
773
|
+
private readonly client;
|
|
774
|
+
constructor(id: string, initial: FoundryRun<TOutput>, client: FoundryClient<FoundryRouteMap>);
|
|
775
|
+
get(): Promise<FoundryRun<TOutput>>;
|
|
776
|
+
cancel(): Promise<boolean>;
|
|
777
|
+
steer(message: FoundryMessageInput): Promise<FoundrySteerHandleResult<TOutput>>;
|
|
778
|
+
events(): Promise<FoundryEvent[]>;
|
|
779
|
+
wait(options?: WaitOptions): Promise<FoundryRun<TOutput>>;
|
|
780
|
+
}
|
|
781
|
+
declare class FoundryClient<TRoutes extends FoundryRouteMap> {
|
|
782
|
+
private readonly baseUrl;
|
|
783
|
+
private readonly fetcher;
|
|
784
|
+
constructor(options?: FoundryClientOptions);
|
|
785
|
+
/** Resolves with `ok: false` when a subsystem is down (the server answers 503). */
|
|
786
|
+
health(): Promise<FoundryHealth>;
|
|
787
|
+
agent<TRoute extends Extract<keyof TRoutes, string>>(route: TRoute): {
|
|
788
|
+
create(options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
|
|
789
|
+
request(request: FoundryRequest): Promise<FoundryRunHandle<FoundryResult>>;
|
|
790
|
+
};
|
|
791
|
+
createAgent(definitionId: string, options?: CreateAgentInstanceOptions): Promise<AgentInstance>;
|
|
792
|
+
agentInstances(definitionId?: string): Promise<ReadonlyArray<AgentInstance>>;
|
|
793
|
+
configureAgent(agentId: string, options: UpdateAgentInstanceOptions): Promise<AgentInstance>;
|
|
794
|
+
setAgentPlaybooks(agentId: string, playbooks: ReadonlyArray<AgentPlaybook>): Promise<AgentInstance>;
|
|
795
|
+
createConversation(agentId: string, options?: CreateConversationOptions): Promise<Conversation>;
|
|
796
|
+
conversations(agentId: string): Promise<ReadonlyArray<Conversation>>;
|
|
797
|
+
updateConversation(agentId: string, conversationId: string, options: UpdateConversationOptions): Promise<Conversation>;
|
|
798
|
+
conversationTranscript(agentId: string, conversationId: string, options?: {
|
|
799
|
+
readonly offset?: number;
|
|
800
|
+
readonly limit?: number;
|
|
801
|
+
}): Promise<FoundryConversationTranscript>;
|
|
802
|
+
workspaceEntries(workspaceId: string): Promise<ReadonlyArray<WorkspaceEntry>>;
|
|
803
|
+
putWorkspaceEntry(workspaceId: string, key: string, value: unknown): Promise<WorkspaceEntry>;
|
|
804
|
+
sharedInbox(workspaceId: string): Promise<ReadonlyArray<SharedInboxItem>>;
|
|
805
|
+
postSharedInbox(workspaceId: string, input: {
|
|
806
|
+
readonly topic: string;
|
|
807
|
+
readonly payload?: unknown;
|
|
808
|
+
readonly agentId?: string;
|
|
809
|
+
readonly conversationId?: string;
|
|
810
|
+
}): Promise<SharedInboxItem>;
|
|
811
|
+
updateSharedInbox(workspaceId: string, itemId: string, status: SharedInboxItem["status"]): Promise<SharedInboxItem>;
|
|
812
|
+
tasks(workspaceId: string): Promise<ReadonlyArray<FoundryTask>>;
|
|
813
|
+
createTask(workspaceId: string, input: {
|
|
814
|
+
readonly title: string;
|
|
815
|
+
readonly detail?: string;
|
|
816
|
+
readonly agentId?: string;
|
|
817
|
+
readonly conversationId?: string;
|
|
818
|
+
}): Promise<FoundryTask>;
|
|
819
|
+
updateTask(workspaceId: string, taskId: string, status: FoundryTask["status"]): Promise<FoundryTask>;
|
|
820
|
+
dataEnvironment(workspaceId: string, scope?: {
|
|
821
|
+
readonly agentId?: string;
|
|
822
|
+
readonly conversationId?: string;
|
|
823
|
+
}): Promise<ReadonlyArray<EnvironmentValue>>;
|
|
824
|
+
dispatchInbound(input: {
|
|
825
|
+
readonly routeId: string;
|
|
826
|
+
readonly eventId: string;
|
|
827
|
+
readonly threadKey: string;
|
|
828
|
+
readonly conversationKey?: string;
|
|
829
|
+
readonly conversationScope?: "route" | "agent";
|
|
830
|
+
readonly raw: unknown;
|
|
831
|
+
}): Promise<ReadonlyArray<FoundryRun>>;
|
|
832
|
+
playbookSubscriptions(workspaceId?: string): Promise<ReadonlyArray<PlaybookSubscription>>;
|
|
833
|
+
activations(workspaceId?: string): Promise<ReadonlyArray<FoundryActivationRecord>>;
|
|
834
|
+
putPlaybookSubscription(subscription: PlaybookSubscription): Promise<PlaybookSubscription>;
|
|
835
|
+
deletePlaybookSubscription(id: string): Promise<boolean>;
|
|
836
|
+
applicationConnections(): Promise<ReadonlyArray<ApplicationConnectionState>>;
|
|
837
|
+
reconnectApplicationConnection(id: string): Promise<void>;
|
|
838
|
+
dispatchOutbound(input: {
|
|
839
|
+
readonly routeId: string;
|
|
840
|
+
readonly agentId: string;
|
|
841
|
+
readonly runId: string;
|
|
842
|
+
readonly payload: unknown;
|
|
843
|
+
}): Promise<unknown>;
|
|
844
|
+
send(agentId: string, conversationId: string, message: FoundryMessageInput, options?: {
|
|
845
|
+
readonly payload?: unknown;
|
|
846
|
+
readonly context?: Readonly<Record<string, unknown>>;
|
|
847
|
+
}): Promise<FoundryRunHandle<FoundryResult>>;
|
|
848
|
+
getRun<TOutput = unknown>(runId: string): Promise<FoundryRun<TOutput>>;
|
|
849
|
+
runs<TOutput = unknown>(route?: string): Promise<ReadonlyArray<FoundryRun<TOutput>>>;
|
|
850
|
+
cancelRun(runId: string): Promise<boolean>;
|
|
851
|
+
steerRun<TOutput = FoundryResult>(runId: string, message: FoundryMessageInput): Promise<FoundrySteerResult<TOutput>>;
|
|
852
|
+
getEvents(filter?: {
|
|
853
|
+
runId?: string;
|
|
854
|
+
agent?: string;
|
|
855
|
+
after?: number;
|
|
856
|
+
category?: FoundryEvent["category"];
|
|
857
|
+
}): Promise<FoundryEvent[]>;
|
|
858
|
+
approvals(filter?: {
|
|
859
|
+
readonly runId?: string;
|
|
860
|
+
readonly status?: FoundryApprovalStatus;
|
|
861
|
+
}): Promise<ReadonlyArray<FoundryApproval>>;
|
|
862
|
+
resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
|
|
863
|
+
manifest(): Promise<{
|
|
864
|
+
agents: FoundryManifest;
|
|
865
|
+
application: FoundryApplicationManifest;
|
|
866
|
+
definitions: Readonly<Record<string, {
|
|
867
|
+
capabilities: FoundryCapabilityManifest;
|
|
868
|
+
surfaces: FoundryNativeManifest;
|
|
869
|
+
}>>;
|
|
870
|
+
}>;
|
|
871
|
+
capabilities(definitionId: string): Promise<FoundryCapabilityManifest>;
|
|
872
|
+
surfaces(definitionId: string): Promise<FoundryNativeManifest>;
|
|
873
|
+
installations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
|
|
874
|
+
install(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
875
|
+
uninstall(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
|
|
876
|
+
accounts(): Promise<ReadonlyArray<AccountSummary>>;
|
|
877
|
+
routes(): Promise<ReadonlyArray<Route>>;
|
|
878
|
+
putRoute(route: Route): Promise<Route>;
|
|
879
|
+
removeRoute(id: string): Promise<void>;
|
|
880
|
+
bindings(): Promise<ReadonlyArray<AgentBinding>>;
|
|
881
|
+
putBinding(binding: AgentBinding): Promise<AgentBinding>;
|
|
882
|
+
removeBinding(id: string): Promise<void>;
|
|
883
|
+
resolveGrant(request: ResolveGrantRequest): Promise<RunGrant>;
|
|
884
|
+
private asUntyped;
|
|
885
|
+
}
|
|
886
|
+
declare function createFoundryClient<TRoutes extends FoundryRouteMap = Record<string, AnyFoundryAgent>>(options?: FoundryClientOptions): FoundryClient<TRoutes>;
|
|
887
|
+
|
|
888
|
+
export { grantResolverLive as $, AccountDirectory as A, type BindingFilter as B, type FoundryRequestAuthorizationAdapter as C, type DiscoveredAgent as D, EMPTY_FOUNDRY_APPLICATION as E, FoundryRuntime as F, type FoundryRequestAuthorizationInput as G, type FoundryRun as H, FoundryRunHandle as I, FoundryRuntimeError as J, type FoundryRuntimeOptions as K, type FoundrySteerHandleResult as L, type FoundrySteerResult as M, GrantResolver as N, ManifestCompilationError as O, MemoryObservabilityAdapter as P, type RouteFilter as Q, type ResolveGrantRequest as R, compileApplicationManifest as S, TopologyStore as T, createFoundryApproval as U, createFoundryClient as V, type WaitOptions as W, createManifest as X, defineApplication as Y, discoverAgents as Z, findAgentFiles as _, type FoundryManifest as a, isFoundryApplication as a0, listFoundryApprovals as a1, memoryAccountDirectory as a2, memoryEventStore as a3, memoryTopologyStore as a4, resolveFoundryApproval as a5, routeFromAgentFile as a6, withFoundryPermissions as a7, type AccountFilter as b, type AccountSessionAdapter as c, type AccountSessionRequest as d, type EventFilter as e, EventStore as f, FOUNDRY_APPLICATION_BRAND as g, FOUNDRY_APPROVAL_DIRECTORY_ENV as h, type FoundryApplication as i, FoundryApplicationManifest as j, type FoundryApplicationOptions as k, type FoundryApproval as l, type FoundryApprovalDecision as m, FoundryApprovalDisplayManager as n, type FoundryApprovalStatus as o, FoundryClient as p, type FoundryClientAuthorizationAdapter as q, type FoundryClientOptions as r, type FoundryConversationTranscript as s, type FoundryEvent as t, type FoundryEventCategory as u, type FoundryHealth as v, type FoundryManifestAgent as w, FoundryManifestCapability as x, FoundryManifestTransmission as y, type FoundryObservabilityAdapter as z };
|