glove-foundry 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -4
- package/dist/{chunk-64UBLGYM.js → chunk-CYOIHSUX.js} +131 -7
- package/dist/{chunk-2GXPSIRL.js → chunk-DTFCEX67.js} +1384 -104
- package/dist/{chunk-EJZJAVNG.js → chunk-EUGKVW3J.js} +335 -7
- package/dist/{chunk-AC6SRI5V.js → chunk-J6NHL4SM.js} +357 -56
- package/dist/{chunk-EEHGAWXM.js → chunk-L5JQVTHD.js} +4 -0
- package/dist/{chunk-IPASF7PK.js → chunk-X3HZYVZS.js} +36 -1
- package/dist/cli.js +4 -4
- package/dist/{client-BgpgsnoO.d.ts → client-CekanYLW.d.ts} +96 -56
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/{event-delivery-BaYe6d9w.d.ts → event-delivery-CNCsVqi8.d.ts} +379 -11
- package/dist/execution-agent.js +1 -1
- package/dist/execution-daemon.js +10 -5
- package/dist/execution-loader.js +174 -17
- package/dist/index.d.ts +17 -6
- package/dist/index.js +114 -15
- package/dist/voice.d.ts +11 -7
- package/dist/voice.js +51 -10
- package/docs/README.md +1 -1
- package/docs/building-with-foundry.md +128 -4
- package/docs/durable-subagents.md +101 -23
- package/docs/execution.md +4 -0
- package/docs/inspector.md +137 -29
- package/package.json +12 -11
- package/templates/travel-concierge/README.md +1 -1
package/dist/execution-daemon.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
FOUNDRY_APPLICATION_ENV,
|
|
6
6
|
internalAgentName
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CYOIHSUX.js";
|
|
8
8
|
|
|
9
9
|
// src/execution-daemon.ts
|
|
10
10
|
import { randomBytes } from "node:crypto";
|
|
@@ -26,8 +26,12 @@ var schedules = new ScheduleMemoryAdapter();
|
|
|
26
26
|
var definitions = /* @__PURE__ */ new Map();
|
|
27
27
|
var stopping;
|
|
28
28
|
var resources;
|
|
29
|
-
function send(message) {
|
|
30
|
-
if (process.connected
|
|
29
|
+
function send(message, then) {
|
|
30
|
+
if (!process.connected || !process.send) {
|
|
31
|
+
then?.();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
process.send(message, void 0, {}, () => then?.());
|
|
31
35
|
}
|
|
32
36
|
async function stop() {
|
|
33
37
|
return stopping ??= (async () => {
|
|
@@ -178,8 +182,9 @@ export default await loadExecutionAgent(${JSON.stringify(agent.route)}, ${JSON.s
|
|
|
178
182
|
value = null;
|
|
179
183
|
break;
|
|
180
184
|
}
|
|
181
|
-
send({ id: message.id, value })
|
|
182
|
-
|
|
185
|
+
send({ id: message.id, value }, command.method === "stop" ? () => {
|
|
186
|
+
if (process.connected) process.disconnect?.();
|
|
187
|
+
} : void 0);
|
|
183
188
|
})().catch(() => {
|
|
184
189
|
send({ id: message.id, error: `Execution daemon ${message.command.method} failed. Inspect daemon health before repeating mutations.` });
|
|
185
190
|
});
|
package/dist/execution-loader.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountFoundryGuidance,
|
|
3
3
|
mountFoundryWorkbench
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-X3HZYVZS.js";
|
|
5
5
|
import {
|
|
6
6
|
EMPTY_FOUNDRY_APPLICATION,
|
|
7
7
|
FOUNDRY_APPROVAL_DIRECTORY_ENV,
|
|
8
|
+
FOUNDRY_APPROVAL_POLICY_ENV,
|
|
8
9
|
FOUNDRY_COMPOSED_PLAYBOOK_BRAND,
|
|
9
10
|
FOUNDRY_CORE_COMMAND_EVENT,
|
|
11
|
+
FOUNDRY_MODEL_REQUESTS_ENV,
|
|
10
12
|
FoundryApprovalDisplayManager,
|
|
11
13
|
MemoryFoundryDataAdapter,
|
|
12
14
|
agentPlaybookId,
|
|
@@ -22,45 +24,57 @@ import {
|
|
|
22
24
|
isFoundrySchedule,
|
|
23
25
|
materializeComposedPlaybook,
|
|
24
26
|
normalizeScheduleTiming,
|
|
27
|
+
readApprovalPolicy,
|
|
28
|
+
requestTracer,
|
|
25
29
|
routeFromAgentFile,
|
|
26
30
|
toGloveMessage,
|
|
27
31
|
toGloveRequestInput,
|
|
28
32
|
withFoundryPermissions
|
|
29
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-EUGKVW3J.js";
|
|
30
34
|
import {
|
|
31
35
|
FOUNDRY_CONVERSATION_LEASE_EVENT,
|
|
32
36
|
FOUNDRY_CONVERSATION_LISTEN_EVENT,
|
|
33
37
|
FOUNDRY_MAILBOX_DIRECTORY_ENV,
|
|
34
38
|
RunEventQueue,
|
|
35
39
|
createDelegatorTools,
|
|
40
|
+
createMeshTools,
|
|
36
41
|
createWorkerTools,
|
|
37
42
|
delegationFromContext,
|
|
38
43
|
deliveryEvent,
|
|
39
44
|
formatRunEvents,
|
|
40
45
|
isDelegationUpdate,
|
|
41
46
|
isOpenDelegation,
|
|
47
|
+
isOpenThread,
|
|
42
48
|
normalizeDelegates,
|
|
43
49
|
openRunMailbox,
|
|
44
50
|
renderDeliveries,
|
|
45
51
|
renderOpenDelegations,
|
|
52
|
+
renderOpenThreads,
|
|
53
|
+
renderOwnThread,
|
|
54
|
+
threadFromContext,
|
|
46
55
|
waitForConversationLease
|
|
47
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-J6NHL4SM.js";
|
|
48
57
|
import {
|
|
49
58
|
EMPTY_CAPABILITY_REGISTRY,
|
|
50
59
|
FOUNDRY_APPLICATION_ENV,
|
|
60
|
+
FOUNDRY_CORE_COMMAND_DIRECTORY_ENV,
|
|
51
61
|
FOUNDRY_EVENT_PREFIX,
|
|
52
62
|
FOUNDRY_EXECUTION_MARKER,
|
|
53
63
|
FOUNDRY_RUN_PROCESS_EVENT,
|
|
54
64
|
createAgentMessagingTool,
|
|
65
|
+
createFoundryCoreCommandRequest,
|
|
55
66
|
defineAgentFromModule,
|
|
67
|
+
hostedMeshOptions,
|
|
56
68
|
installRegistry,
|
|
57
69
|
internalAgentName,
|
|
58
70
|
isInboxCapableStore,
|
|
71
|
+
isMeshTransport,
|
|
59
72
|
mountAgentDefinitionMemory,
|
|
60
73
|
mountFoundrySurfaces,
|
|
61
74
|
refreshDurableAuthority,
|
|
62
|
-
resolveResolvable
|
|
63
|
-
|
|
75
|
+
resolveResolvable,
|
|
76
|
+
waitForFoundryCoreCommandResult
|
|
77
|
+
} from "./chunk-CYOIHSUX.js";
|
|
64
78
|
|
|
65
79
|
// src/execution-loader.ts
|
|
66
80
|
import { dirname } from "node:path";
|
|
@@ -68,7 +82,7 @@ import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
|
68
82
|
|
|
69
83
|
// src/agent-runtime.ts
|
|
70
84
|
import { pathToFileURL } from "node:url";
|
|
71
|
-
import { Glove } from "glove-core";
|
|
85
|
+
import { Glove, isTurnSuspended } from "glove-core";
|
|
72
86
|
import { mountMesh } from "glove-mesh";
|
|
73
87
|
import { Effect } from "effect";
|
|
74
88
|
import { signal } from "station-signal";
|
|
@@ -113,6 +127,20 @@ async function hydrateInbox(store, items, emit) {
|
|
|
113
127
|
data: { count: loaded.length, added, updated }
|
|
114
128
|
});
|
|
115
129
|
}
|
|
130
|
+
function approvalDecisionOf(delivery) {
|
|
131
|
+
const event = delivery.durable?.event;
|
|
132
|
+
if (event?.source !== "foundry:approval" || event.kind !== "approval.decided") return void 0;
|
|
133
|
+
const approval = event.metadata?.approval;
|
|
134
|
+
if (typeof approval?.id !== "string" || typeof approval.toolName !== "string") return void 0;
|
|
135
|
+
if (approval.status !== "approved" && approval.status !== "denied") return void 0;
|
|
136
|
+
return {
|
|
137
|
+
id: approval.id,
|
|
138
|
+
toolName: approval.toolName,
|
|
139
|
+
toolInput: approval.toolInput,
|
|
140
|
+
status: approval.status,
|
|
141
|
+
...typeof approval.toolCallId === "string" ? { toolCallId: approval.toolCallId } : {}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
116
144
|
function extractOutput(result) {
|
|
117
145
|
if (result == null || typeof result !== "object") return result;
|
|
118
146
|
const object = result;
|
|
@@ -144,9 +172,24 @@ function writeAgentEvent(type, data) {
|
|
|
144
172
|
});
|
|
145
173
|
}
|
|
146
174
|
function executionSubscriber() {
|
|
175
|
+
const trace = requestTracer();
|
|
147
176
|
return {
|
|
177
|
+
modelRequests: process.env[FOUNDRY_MODEL_REQUESTS_ENV] !== "off",
|
|
148
178
|
async record(eventType, data) {
|
|
149
|
-
|
|
179
|
+
if (eventType === "model_request" || eventType === "model_request_end") {
|
|
180
|
+
let recorded;
|
|
181
|
+
try {
|
|
182
|
+
recorded = eventType === "model_request" ? trace.request(data) : trace.end(data);
|
|
183
|
+
} catch (cause) {
|
|
184
|
+
recorded = {
|
|
185
|
+
request_id: data.request_id,
|
|
186
|
+
unrecorded: cause instanceof Error ? cause.message : String(cause)
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
await writeAgentEvent(eventType, recorded);
|
|
190
|
+
} else {
|
|
191
|
+
await writeAgentEvent(eventType, data);
|
|
192
|
+
}
|
|
150
193
|
}
|
|
151
194
|
};
|
|
152
195
|
}
|
|
@@ -291,6 +334,8 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
291
334
|
activations: Object.freeze([...envelope.activations ?? []]),
|
|
292
335
|
delegations: Object.freeze([...envelope.delegations ?? []]),
|
|
293
336
|
...delegationFromContext(envelope.conversation.context) ? { delegation: delegationFromContext(envelope.conversation.context) } : {},
|
|
337
|
+
threads: Object.freeze([...envelope.threads ?? []]),
|
|
338
|
+
...threadFromContext(envelope.conversation.context)?.to.agentId === envelope.agent.id ? { thread: threadFromContext(envelope.conversation.context) } : {},
|
|
294
339
|
data,
|
|
295
340
|
input,
|
|
296
341
|
message,
|
|
@@ -325,7 +370,8 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
325
370
|
conversationId: request.conversationId,
|
|
326
371
|
workspaceId: request.workspaceId,
|
|
327
372
|
signal: abortController.signal,
|
|
328
|
-
emit: controls.emit
|
|
373
|
+
emit: controls.emit,
|
|
374
|
+
policy: readApprovalPolicy(process.env[FOUNDRY_APPROVAL_POLICY_ENV])
|
|
329
375
|
})
|
|
330
376
|
),
|
|
331
377
|
resolveOptional("compactionLimit", definition.compactionLimit, void 0),
|
|
@@ -368,7 +414,8 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
368
414
|
resolveOptional("calls", definition.calls, []),
|
|
369
415
|
resolveOptional("playbooks", definition.playbooks, []),
|
|
370
416
|
resolveOptional("schedules", definition.schedules, []),
|
|
371
|
-
|
|
417
|
+
// Your own mesh transport; the mesh Foundry hosts is mounted below.
|
|
418
|
+
resolveOptional("mesh", isMeshTransport(definition.mesh) ? definition.mesh : void 0, void 0),
|
|
372
419
|
resolveOptional("workingEnvironment", definition.workingEnvironment, void 0),
|
|
373
420
|
resolveOptional("repl", definition.repl, void 0)
|
|
374
421
|
]);
|
|
@@ -440,7 +487,10 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
440
487
|
data: { count: desiredSchedules.length, names: desiredSchedules.map((item) => item.name) }
|
|
441
488
|
});
|
|
442
489
|
const effectiveInstallations = [...installations];
|
|
443
|
-
for (const tool of createFoundryCoreTools(assemblyContext, desiredSchedules
|
|
490
|
+
for (const tool of createFoundryCoreTools(assemblyContext, desiredSchedules, {
|
|
491
|
+
playbooks: desiredPlaybooks,
|
|
492
|
+
applications: registry.capabilities.applications
|
|
493
|
+
})) base.fold(tool);
|
|
444
494
|
const applicationTransmissionTools = createInstalledApplicationTransmissionTools(
|
|
445
495
|
assemblyContext,
|
|
446
496
|
registry.capabilities.applications,
|
|
@@ -479,6 +529,8 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
479
529
|
return;
|
|
480
530
|
}
|
|
481
531
|
for (const delivery of deliveries) {
|
|
532
|
+
const decision = approvalDecisionOf(delivery);
|
|
533
|
+
if (decision) await runtimeStore?.setPermission?.(decision.toolName, decision.status === "approved" ? "granted" : "denied", decision.toolInput);
|
|
482
534
|
const event = { ...deliveryEvent(delivery), whenIdle: "defer" };
|
|
483
535
|
forwarded.set(event.id, delivery);
|
|
484
536
|
await eventRecipient.emitEvent(event);
|
|
@@ -598,13 +650,63 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
598
650
|
waitForReply
|
|
599
651
|
})) base.fold(tool);
|
|
600
652
|
}
|
|
653
|
+
const coreCommandDirectory = process.env[FOUNDRY_CORE_COMMAND_DIRECTORY_ENV];
|
|
654
|
+
const emitMeshCommand = (command) => {
|
|
655
|
+
controls.commands.push(command);
|
|
656
|
+
controls.emit({ type: FOUNDRY_CORE_COMMAND_EVENT, data: command });
|
|
657
|
+
};
|
|
658
|
+
const callMesh = async (command) => {
|
|
659
|
+
if (!coreCommandDirectory) throw new Error("Foundry cannot answer mesh calls without its parent runtime.");
|
|
660
|
+
const pending = await createFoundryCoreCommandRequest(coreCommandDirectory, {
|
|
661
|
+
id: command.id,
|
|
662
|
+
runId,
|
|
663
|
+
type: "mesh",
|
|
664
|
+
timeoutMs: 6e4
|
|
665
|
+
});
|
|
666
|
+
emitMeshCommand(command);
|
|
667
|
+
return waitForFoundryCoreCommandResult(coreCommandDirectory, pending, abortController.signal, { cleanup: true });
|
|
668
|
+
};
|
|
669
|
+
const waitFrom = (agentId, timeoutMs) => {
|
|
670
|
+
const stop = new AbortController();
|
|
671
|
+
const onAbort = () => stop.abort();
|
|
672
|
+
abortController.signal.addEventListener("abort", onAbort, { once: true });
|
|
673
|
+
const message2 = (mailboxDirectory ? mailbox().waitForMesh(agentId, timeoutMs, stop.signal) : Promise.resolve(null)).finally(() => abortController.signal.removeEventListener("abort", onAbort));
|
|
674
|
+
return { message: message2, cancel: () => stop.abort() };
|
|
675
|
+
};
|
|
676
|
+
const pendingReply = {};
|
|
677
|
+
const ownThread = assemblyContext.thread;
|
|
678
|
+
const hostedMesh = hostedMeshOptions(definition.mesh);
|
|
679
|
+
if (hostedMesh && (hostedMesh.mount?.(assemblyContext) ?? true)) {
|
|
680
|
+
for (const tool of createMeshTools({
|
|
681
|
+
definitionId: id,
|
|
682
|
+
agentId: request.agentId,
|
|
683
|
+
conversationId: request.conversationId,
|
|
684
|
+
workspaceId: request.workspaceId,
|
|
685
|
+
options: hostedMesh,
|
|
686
|
+
call: callMesh,
|
|
687
|
+
waitFrom,
|
|
688
|
+
pending: pendingReply
|
|
689
|
+
})) base.fold(tool);
|
|
690
|
+
controls.emit({
|
|
691
|
+
type: "foundry.mesh.mounted",
|
|
692
|
+
data: { open: assemblyContext.threads.length, thread: ownThread?.id ?? null }
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
if (hostedMesh || assemblyContext.threads.length > 0 || ownThread) {
|
|
696
|
+
base.addContextProvider(() => [
|
|
697
|
+
ownThread ? renderOwnThread(ownThread) : null,
|
|
698
|
+
renderOpenThreads(assemblyContext.threads.filter(isOpenThread))
|
|
699
|
+
].filter(Boolean).join("\n\n") || null);
|
|
700
|
+
}
|
|
601
701
|
if (mailboxDirectory) mailbox();
|
|
702
|
+
const installedApps = [];
|
|
602
703
|
const workbench = await mountFoundryWorkbench({
|
|
603
704
|
glove: base,
|
|
604
705
|
context: assemblyContext,
|
|
605
706
|
...workingEnvironment ? { workingEnvironment } : {},
|
|
606
707
|
...repl ? { repl } : {},
|
|
607
|
-
deferRepl: Boolean(repl?.programmaticTools)
|
|
708
|
+
deferRepl: Boolean(repl?.programmaticTools),
|
|
709
|
+
apps: () => installedApps
|
|
608
710
|
});
|
|
609
711
|
cleanups.push(workbench.dispose);
|
|
610
712
|
const callByName = /* @__PURE__ */ new Map();
|
|
@@ -652,6 +754,9 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
652
754
|
...guidance.handles,
|
|
653
755
|
events: assemblyContext.events,
|
|
654
756
|
delegations: assemblyContext.delegations,
|
|
757
|
+
agentInstance: assemblyContext.agentInstance,
|
|
758
|
+
conversation: assemblyContext.conversation,
|
|
759
|
+
data: assemblyContext.data,
|
|
655
760
|
installations: effectiveInstallations,
|
|
656
761
|
onCleanup: (cleanup) => {
|
|
657
762
|
cleanups.push(cleanup);
|
|
@@ -661,6 +766,11 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
661
766
|
const stop = mailbox().onUpdates(handler);
|
|
662
767
|
cleanups.push(stop);
|
|
663
768
|
return stop;
|
|
769
|
+
},
|
|
770
|
+
onMeshMessage: (handler) => {
|
|
771
|
+
const stop = mailbox().onMesh(handler);
|
|
772
|
+
cleanups.push(stop);
|
|
773
|
+
return stop;
|
|
664
774
|
}
|
|
665
775
|
};
|
|
666
776
|
for (const call of calls) {
|
|
@@ -723,7 +833,13 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
723
833
|
emit: controls.emit
|
|
724
834
|
},
|
|
725
835
|
...definition.mcpAdapter ? { mcpAdapter: definition.mcpAdapter } : {},
|
|
726
|
-
...definition.accountSessions ? { accountSessions: definition.accountSessions } : {}
|
|
836
|
+
...definition.accountSessions ? { accountSessions: definition.accountSessions } : {},
|
|
837
|
+
onApp: (app) => {
|
|
838
|
+
installedApps.push(app);
|
|
839
|
+
},
|
|
840
|
+
onCleanup: (cleanup) => {
|
|
841
|
+
cleanups.push(cleanup);
|
|
842
|
+
}
|
|
727
843
|
})
|
|
728
844
|
);
|
|
729
845
|
await Effect.runPromise(
|
|
@@ -795,6 +911,26 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
795
911
|
const defaultRun = async (messageInput = assemblyContext.messageInput) => {
|
|
796
912
|
if (initialEventsPending && messageInput === assemblyContext.messageInput) {
|
|
797
913
|
initialEventsPending = false;
|
|
914
|
+
const decisions = initialDeliveries.filter((delivery) => approvalDecisionOf(delivery));
|
|
915
|
+
if (decisions.length && glove.resumeToolCalls) {
|
|
916
|
+
for (const delivery of decisions) {
|
|
917
|
+
const decision = approvalDecisionOf(delivery);
|
|
918
|
+
await runtimeStore?.setPermission?.(decision.toolName, decision.status === "approved" ? "granted" : "denied", decision.toolInput);
|
|
919
|
+
}
|
|
920
|
+
const resumed = await glove.resumeToolCalls(abortController.signal);
|
|
921
|
+
const answered = resumed === void 0 && runtimeStore ? new Set((await runtimeStore.getMessages()).flatMap((message2) => (message2.tool_results ?? []).map((result2) => result2.call_id))) : void 0;
|
|
922
|
+
const done = decisions.filter((delivery) => {
|
|
923
|
+
const callId = approvalDecisionOf(delivery).toolCallId;
|
|
924
|
+
return resumed !== void 0 || callId !== void 0 && answered?.has(callId);
|
|
925
|
+
});
|
|
926
|
+
if (done.length) {
|
|
927
|
+
consumed(done);
|
|
928
|
+
const rest = initialDeliveries.filter((delivery) => !done.includes(delivery));
|
|
929
|
+
if (!rest.length) return resumed === void 0 ? null : extractOutput(resumed);
|
|
930
|
+
await forwardDeliveries(rest);
|
|
931
|
+
return extractOutput(await glove.processEvents(abortController.signal));
|
|
932
|
+
}
|
|
933
|
+
}
|
|
798
934
|
await forwardDeliveries(initialDeliveries);
|
|
799
935
|
return extractOutput(await glove.processEvents(abortController.signal));
|
|
800
936
|
}
|
|
@@ -811,21 +947,31 @@ async function executeDefinition(definition, id, runtimeValue) {
|
|
|
811
947
|
defaultHandler: defaultRun,
|
|
812
948
|
spawn
|
|
813
949
|
};
|
|
814
|
-
|
|
950
|
+
let awaitingApproval;
|
|
951
|
+
let result;
|
|
952
|
+
try {
|
|
953
|
+
result = definition.run ? await resolveResolvable(definition.run(glove, handlerContext)) : definition.handler ? await resolveResolvable(definition.handler(handlerContext)) : definition.spawn ? await spawn() : await defaultRun();
|
|
954
|
+
} catch (cause) {
|
|
955
|
+
const deferral = isTurnSuspended(cause) ? cause.deferral.data : void 0;
|
|
956
|
+
if (typeof deferral?.approvalId !== "string") throw cause;
|
|
957
|
+
awaitingApproval = { approvalId: deferral.approvalId, toolName: String(deferral.toolName ?? "") };
|
|
958
|
+
result = `Waiting for approval to run ${awaitingApproval.toolName || "a tool"} (${awaitingApproval.approvalId}).`;
|
|
959
|
+
}
|
|
815
960
|
if (initialEventsPending) consumed(initialDeliveries);
|
|
816
961
|
await guidance.snapshot();
|
|
817
962
|
const sleep = [...controls.commands].reverse().find(
|
|
818
963
|
(command) => command.type === "sleep"
|
|
819
964
|
);
|
|
820
965
|
const question = pendingQuestion.current;
|
|
966
|
+
const waiting = pendingReply.current;
|
|
821
967
|
return {
|
|
822
|
-
status: sleep || question ? "suspended" : "completed",
|
|
968
|
+
status: sleep || question || waiting || awaitingApproval ? "suspended" : "completed",
|
|
823
969
|
value: serializable(result),
|
|
824
970
|
...consumedEventIds.size ? { consumedEventIds: [...consumedEventIds] } : {},
|
|
825
971
|
agentId: request.agentId,
|
|
826
972
|
conversationId: request.conversationId,
|
|
827
973
|
workspaceId: request.workspaceId,
|
|
828
|
-
...question ? { suspension: { kind: "question", ...question } } : sleep && sleep.type === "sleep" ? { suspension: { commandId: sleep.id, wakeAt: sleep.wakeAt } } : {}
|
|
974
|
+
...awaitingApproval ? { suspension: { kind: "approval", ...awaitingApproval } } : question ? { suspension: { kind: "question", ...question } } : waiting ? { suspension: { kind: "mesh", ...waiting } } : sleep && sleep.type === "sleep" ? { suspension: { commandId: sleep.id, wakeAt: sleep.wakeAt } } : {}
|
|
829
975
|
};
|
|
830
976
|
} finally {
|
|
831
977
|
const failures = [];
|
|
@@ -865,7 +1011,7 @@ function compileAgentDefinition(definition, route) {
|
|
|
865
1011
|
payload: z.unknown().optional(),
|
|
866
1012
|
context: z.record(z.string(), z.unknown()).optional(),
|
|
867
1013
|
source: z.object({
|
|
868
|
-
kind: z.enum(["direct", "transmission", "activation", "spawn", "background", "delegation", "agent-message"]),
|
|
1014
|
+
kind: z.enum(["direct", "transmission", "activation", "spawn", "background", "delegation", "agent-message", "mesh"]),
|
|
869
1015
|
id: z.string().optional(),
|
|
870
1016
|
provider: z.string().optional(),
|
|
871
1017
|
eventId: z.string().optional(),
|
|
@@ -881,6 +1027,9 @@ function compileAgentDefinition(definition, route) {
|
|
|
881
1027
|
id: z.string(),
|
|
882
1028
|
definitionId: z.string(),
|
|
883
1029
|
workspaceId: z.string(),
|
|
1030
|
+
provisioningKey: z.string().optional(),
|
|
1031
|
+
name: z.string().optional(),
|
|
1032
|
+
description: z.string().optional(),
|
|
884
1033
|
durableSubagent: z.object({ parentAgentId: z.string(), name: z.string(), status: z.enum(["active", "archived", "purged"]) }).optional(),
|
|
885
1034
|
context: z.record(z.string(), z.unknown()),
|
|
886
1035
|
installations: z.array(z.object({
|
|
@@ -974,6 +1123,7 @@ function compileAgentDefinition(definition, route) {
|
|
|
974
1123
|
createdAt: z.string(),
|
|
975
1124
|
updatedAt: z.string()
|
|
976
1125
|
})).default([]),
|
|
1126
|
+
threads: z.array(z.record(z.string(), z.unknown())).default([]),
|
|
977
1127
|
conversationLease: z.literal(true).optional()
|
|
978
1128
|
});
|
|
979
1129
|
let builder = signal(internalAgentName(route)).input(executionEnvelope).output(z.object({
|
|
@@ -990,7 +1140,14 @@ function compileAgentDefinition(definition, route) {
|
|
|
990
1140
|
commandId: z.string(),
|
|
991
1141
|
delegationId: z.string(),
|
|
992
1142
|
question: z.string()
|
|
993
|
-
})
|
|
1143
|
+
}),
|
|
1144
|
+
z.object({
|
|
1145
|
+
kind: z.literal("mesh"),
|
|
1146
|
+
commandId: z.string(),
|
|
1147
|
+
threadId: z.string(),
|
|
1148
|
+
messageId: z.string()
|
|
1149
|
+
}),
|
|
1150
|
+
z.object({ kind: z.literal("approval"), approvalId: z.string(), toolName: z.string() })
|
|
994
1151
|
]).optional()
|
|
995
1152
|
}));
|
|
996
1153
|
if (definition.runTimeoutMs !== void 0) builder = builder.timeout(definition.runTimeoutMs);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { Effect } from 'effect';
|
|
1
|
+
import { b as FoundryDataAdapter, E as EnvironmentValue, c as AgentInstance, C as Conversation, P as PlaybookSubscription, d as FoundryActivationRecord, e as ProvisionAgentOptions, I as InboundDeliveryClaim, f as FoundryEventRecord, g as FoundryPendingInbound, h as FoundryApproval, W as WorkspaceEntry, i as FoundryWorkingEnvironmentSnapshotOwner, S as SharedInboxItem, j as FoundryTask, k as AgentPlaybook, l as AnyFoundryTransmission, m as AccountReference, n as InferAccountMetadata, o as AgentBinding, p as FoundryAgentApplication, q as InboundRoute, O as OutboundRoute, r as CapabilityDefinition, s as InferInboundConfig, t as InferOutboundConfig } from './event-delivery-CNCsVqi8.js';
|
|
2
|
+
export { u as AccountContract, v as AccountId, w as AccountNotFound, x as AccountSessionUnavailable, y as AccountSummary, z as AgentApplicationContribution, B as AgentApplicationInstallContext, D as AgentApplicationOptions, G as AgentAssemblyContext, H as AgentAssemblyOptions, J as AgentDefinitionId, K as AgentDefinitionSurfaceContext, L as AgentFactoryContext, A as AgentHandlerContext, M as AgentId, N as AgentInstallContext, Q as AgentInstallation, R as AgentInstallationKind, T as AgentMessageReceipt, U as AgentPlaybookInput, V as AgentProvisioningPolicy, X as AgentRuntimeControls, Y as AnyFoundryAgent, Z as AppRestrictions, _ as ApplicationConnectionContext, $ as ApplicationConnectionState, a0 as ApplicationConnectionStatus, a1 as BindingId, a2 as BindingNotFound, a3 as CapabilityId, a4 as ComposedAgentPlaybook, a5 as ComposedAgentPlaybookInput, a6 as ConnectionReceiveInput, a7 as CreateAgentInstanceOptions, a8 as CreateConversationOptions, a9 as CustomProvisionedAgent, aa as CustomProvisioningContext, ab as DEFAULT_APPROVAL_EXPIRES_AFTER_MS, ac as DEFAULT_APPROVAL_WAIT_MS, ad as DefineAgentOptions, ae as DefineConnectionOptions, af as DefineFoundryReplOptions, ag as DefineFoundryScheduleOptions, ah as DefineFoundrySubagentOptions, ai as DefineFoundryWorkingEnvironmentOptions, aj as DefinePlaybookSubscriptionOptions, ak as DefinitionConfigInput, al as DurableSubagentOptions, am as DurableSubagentOwnership, an as DurableSubagents, ao as EMPTY_AGENT_COMPOSITION, ap as EMPTY_CAPABILITY_REGISTRY, aq as EMPTY_NATIVE_REGISTRY, ar as EgressAdapter, as as EgressContext, at as EventId, au as EventNotFound, av as EventReference, aw as FOUNDRY_AGENT_APPLICATION_BRAND, ax as FOUNDRY_AGENT_BRAND, ay as FOUNDRY_AGENT_DEFINITION_BRAND, az as FOUNDRY_AGENT_FILE_ENV, aA as FOUNDRY_AGENT_ROUTE_ENV, aB as FOUNDRY_APPLICATION_ENV, aC as FOUNDRY_APPROVAL_DIRECTORY_ENV, aD as FOUNDRY_COMPOSED_PLAYBOOK_BRAND, aE as FOUNDRY_CONNECTION_BRAND, aF as FOUNDRY_CORE_COMMAND_EVENT, aG as FOUNDRY_EVENT_PREFIX, aH as FOUNDRY_EXECUTION_MARKER, aI as FOUNDRY_LAYER_BRAND, aJ as FOUNDRY_MCP_BRAND, aK as FOUNDRY_MEMORY_BRAND, aL as FOUNDRY_PLAYBOOK_ACTION_BRAND, aM as FOUNDRY_REPL_BRAND, aN as FOUNDRY_SCHEDULE_BRAND, aO as FOUNDRY_SHARED_TOOL_BRAND, aP as FOUNDRY_SUBSCRIBER_BRAND, aQ as FOUNDRY_TRANSMISSION_BRAND, aR as FOUNDRY_TRANSMISSION_EVENT_BRAND, aS as FOUNDRY_TRANSMISSION_PREDICATE_BRAND, aT as FOUNDRY_WORKING_ENVIRONMENT_BRAND, aU as FoundryAccountSessionAdapter, aV as FoundryAgent, aW as FoundryAgentComponent, aX as FoundryAgentComposition, aY as FoundryAgentConventionModule, aZ as FoundryAgentDefinition, a_ as FoundryAgentMode, a$ as FoundryApp, b0 as FoundryAppMcp, b1 as FoundryAppMcpTool, b2 as FoundryAppToolDecision, b3 as FoundryApplicationConnection, b4 as FoundryApprovalDecision, b5 as FoundryApprovalDisplayManager, b6 as FoundryApprovalPolicy, b7 as FoundryApprovalStatus, b8 as FoundryCall, b9 as FoundryCallContext, ba as FoundryCallOptions, bb as FoundryCapabilityKind, bc as FoundryCapabilityManifest, bd as FoundryCapabilityManifestEntry, be as FoundryCapabilityRegistry, bf as FoundryCompositionSource, bg as FoundryContextProvider, bh as FoundryCoreCommand, bi as FoundryDelegate, bj as FoundryDelegateOptions, bk as FoundryDelegation, bl as FoundryDelegationReply, bm as FoundryDelegationStatus, F as FoundryDelegationUpdate, bn as FoundryDomainError, bo as FoundryEventPolicy, bp as FoundryEventTarget, bq as FoundryExecutionContext, br as FoundryFactsOptions, bs as FoundryFormsOptions, bt as FoundryGoalsOptions, bu as FoundryGuidanceHandles, bv as FoundryGuidanceScope, bw as FoundryHookDefinition, bx as FoundryInstallable, by as FoundryInstalledApp, bz as FoundryInstanceProvisioner, bA as FoundryJavaScriptReplDefinition, bB as FoundryLayer, bC as FoundryLayerOptions, bD as FoundryLayerReference, bE as FoundryLayerSelection, bF as FoundryLispReplDefinition, bG as FoundryListResolver, bH as FoundryMcp, bI as FoundryMcpOptions, bJ as FoundryMemoryProfile, bK as FoundryMemoryProfileOptions, bL as FoundryMemoryReference, bM as FoundryMemorySelection, bN as FoundryMeshConfig, a as FoundryMeshMessage, bO as FoundryMeshOptions, bP as FoundryMeshParty, bQ as FoundryMeshThread, bR as FoundryMeshThreadStatus, bS as FoundryMessageInput, bT as FoundryMessageOptions, bU as FoundryMountedRepl, bV as FoundryNativeManifest, bW as FoundryNativeManifestEntry, bX as FoundryNativeRegistry, bY as FoundryPlaybookAction, bZ as FoundryProgrammaticToolContext, b_ as FoundryProgrammaticToolSelection, b$ as FoundryProgrammaticTools, c0 as FoundryPythonReplDefinition, c1 as FoundryReplApp, c2 as FoundryReplDefinition, c3 as FoundryRequest, c4 as FoundryResolvedMcp, c5 as FoundryResolver, c6 as FoundryResult, c7 as FoundryRouteMap, c8 as FoundryScheduleDefinition, c9 as FoundryScheduleTiming, ca as FoundryScheduleTimingInput, cb as FoundrySharedTool, cc as FoundrySubagentToolContext, cd as FoundrySubscriber, ce as FoundrySubscriberOptions, cf as FoundrySubscriberSelection, cg as FoundrySurfaceContext, ch as FoundrySuspension, ci as FoundryToolBody, cj as FoundryTransmission, ck as FoundryTransmissionDelivery, cl as FoundryTransmissionEvent, cm as FoundryTransmissionPredicate, cn as FoundryVfs, co as FoundryVfsHandle, cp as FoundryWorkingEnvironmentCreateContext, cq as FoundryWorkingEnvironmentDefinition, cr as FoundryWorkingEnvironmentPersistenceAdapter, cs as FoundryWorkingEnvironmentPersistenceContext, ct as GrantResolutionError, cu as InboundContract, cv as InferAgentInput, cw as InferAgentOutput, cx as InferInboundEvent, cy as InferOutboundInput, cz as InferOutboundOutput, cA as IngressAdapter, cB as IngressContext, cC as InstallationSelection, cD as McpAdapterFactory, cE as MemoryFoundryDataAdapter, cF as OutboundContract, cG as PlaybookActionOptions, cH as PlaybookDirective, cI as PlaybookDirectiveInput, cJ as PlaybookMatch, cK as PlaybookMatchInput, cL as PlaybookOutboundDirective, cM as PlaybookOutboundInput, cN as PlaybookSubscriptionTarget, cO as PlaybookSubscriptionTargetInput, cP as ReplyPolicy, cQ as Route, cR as RouteId, cS as RouteNotFound, cT as RunGrant, cU as RunId, cV as SharedToolOptions, cW as TopologyConflict, cX as TransmissionEventDirection, cY as TransmissionEventOptions, cZ as TransmissionId, c_ as TransmissionOptions, c$ as TransmissionPredicateOptions, d0 as TransmissionSerializationContext, d1 as UpdateAgentInstanceOptions, d2 as UpdateConversationOptions, d3 as composeAgent, d4 as composePlaybook, d5 as configureLayer, d6 as configureMemory, d7 as createAgentInstance, d8 as createConversation, d9 as createFoundryApproval, da as createFoundryCoreTools, db as createInstalledApplicationTransmissionTools, dc as defineAgent, dd as defineAgentApplication, de as defineAgentFromModule, df as defineAgentInstance, dg as defineApp, dh as defineCall, di as defineConnection, dj as defineFacts, dk as defineForms, dl as defineGoals, dm as defineLayer, dn as defineMcp, dp as defineMemory, dq as definePlaybookAction, dr as definePlaybookSubscription, ds as defineRepl, dt as defineRoutes, du as defineSchedule, dv as defineSharedTool, dw as defineSubagent, dx as defineSubscriber, dy as defineTransmission, dz as defineTransmissionEvent, dA as defineTransmissionPredicate, dB as defineWorkingEnvironment, dC as foundryDataEnvironmentPersistence, dD as foundryGuidanceSubject, dE as hostedMeshOptions, dF as install, dG as installRegistry, dH as installationKey, dI as installedApplicationTransmissionToolName, dJ as internalAgentName, dK as isFoundryAgent, dL as isFoundryAgentDefinition, dM as isFoundryCapability, dN as isFoundryLayer, dO as isFoundrySchedule, dP as isFoundrySubscriber, dQ as isFoundryTransmission, dR as isInboxCapableStore, dS as isMeshTransport, dT as listFoundryApprovals, dU as meshIdentity, dV as mountAgentDefinitionMemory, dW as mountFoundrySurfaces, dX as reconstructAgentInstance, dY as reconstructPlaybook, dZ as reconstructPlaybookSubscription, d_ as resolveFoundryApproval, d$ as restrictApp, e0 as routeFromInternalAgentName, e1 as toGloveMessage, e2 as toGloveRequestInput, e3 as transmissionPredicate, e4 as withFoundryPermissions } from './event-delivery-CNCsVqi8.js';
|
|
3
|
+
import { Effect, Layer } from 'effect';
|
|
4
4
|
import { EnvSnapshot } from 'glove-working-environment';
|
|
5
|
-
import { F as FoundryRuntime, D as DiscoveredAgent, a as FoundryManifest } from './client-
|
|
6
|
-
export { A as AccountDirectory, b as AccountFilter, c as AccountSessionAdapter, d as AccountSessionRequest, B as BindingFilter, E as EMPTY_FOUNDRY_APPLICATION, e as EventFilter, f as EventStore, g as FOUNDRY_APPLICATION_BRAND, h as
|
|
5
|
+
import { T as TopologyStore, F as FoundryRuntime, D as DiscoveredAgent, a as FoundryManifest } from './client-CekanYLW.js';
|
|
6
|
+
export { A as AccountDirectory, b as AccountFilter, c as AccountSessionAdapter, d as AccountSessionRequest, B as BindingFilter, E as EMPTY_FOUNDRY_APPLICATION, e as EventFilter, f as EventStore, g as FOUNDRY_APPLICATION_BRAND, h as FoundryApplication, i as FoundryApplicationManifest, j as FoundryApplicationOptions, k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, n as FoundryConversationTranscript, o as FoundryEvent, p as FoundryEventCategory, q as FoundryHealth, r as FoundryManifestAgent, s as FoundryManifestCapability, t as FoundryManifestTransmission, u as FoundryObservabilityAdapter, v as FoundryRequestAuthorizationAdapter, w as FoundryRequestAuthorizationInput, x as FoundryRun, y as FoundryRunHandle, z as FoundryRuntimeError, C as FoundryRuntimeOptions, G as FoundrySteerHandleResult, H as FoundrySteerResult, I as GrantResolver, M as ManifestCompilationError, J as MemoryObservabilityAdapter, R as ResolveGrantRequest, K as RouteFilter, W as WaitOptions, L as compileApplicationManifest, N as createFoundryClient, O as createManifest, P as defineApplication, Q as discoverAgents, S as findAgentFiles, U as grantResolverLive, V as isFoundryApplication, X as memoryAccountDirectory, Y as memoryEventStore, Z as memoryTopologyStore, _ as routeFromAgentFile } from './client-CekanYLW.js';
|
|
7
7
|
import { AddressInfo } from 'node:net';
|
|
8
8
|
import { FoundryBrandingConfig } from './config.js';
|
|
9
9
|
export { FoundryConfig, FoundryExecutionConfig, defineConfig } from './config.js';
|
|
@@ -79,6 +79,9 @@ declare class FileFoundryDataAdapter implements FoundryDataAdapter {
|
|
|
79
79
|
putPendingInbound(record: FoundryPendingInbound): Effect.Effect<void, unknown, never>;
|
|
80
80
|
deletePendingInbound(id: string): Effect.Effect<void, unknown, never>;
|
|
81
81
|
listPendingInbound(): Effect.Effect<FoundryPendingInbound[], unknown, never>;
|
|
82
|
+
putApproval(approval: FoundryApproval): Effect.Effect<void, unknown, never>;
|
|
83
|
+
getApproval(id: string): Effect.Effect<FoundryApproval | null, unknown, never>;
|
|
84
|
+
listApprovals(): Effect.Effect<FoundryApproval[], unknown, never>;
|
|
82
85
|
releaseInboundDelivery(key: string): Effect.Effect<void, unknown, never>;
|
|
83
86
|
getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, unknown, never>;
|
|
84
87
|
putActivation(activation: FoundryActivationRecord): Effect.Effect<void, unknown, never>;
|
|
@@ -102,6 +105,14 @@ declare class FileFoundryDataAdapter implements FoundryDataAdapter {
|
|
|
102
105
|
readonly conversationId?: string;
|
|
103
106
|
}): Effect.Effect<EnvironmentValue[], unknown, never>;
|
|
104
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Keep routes and bindings in one JSON file, so topology an application writes
|
|
110
|
+
* at runtime (a person connecting an app) survives a restart on a single host.
|
|
111
|
+
* Only the control process holds it; writes are serialized and committed by
|
|
112
|
+
* atomic rename. Use a database-backed TopologyStore when several hosts share
|
|
113
|
+
* one topology.
|
|
114
|
+
*/
|
|
115
|
+
declare function fileTopologyStore(file: string): Layer.Layer<TopologyStore>;
|
|
105
116
|
|
|
106
117
|
/** Deterministic default rendering for an event merged into a Glove conversation. */
|
|
107
118
|
declare function serializeInboundTransmissionXml(input: {
|
|
@@ -197,4 +208,4 @@ interface DefineBindingOptions extends Omit<AgentBinding, "id" | "agentId" | "tr
|
|
|
197
208
|
}
|
|
198
209
|
declare function defineBinding(options: DefineBindingOptions): AgentBinding;
|
|
199
210
|
|
|
200
|
-
export { AccountReference, AgentBinding, AgentInstance, AgentPlaybook, AnyFoundryTransmission, CapabilityDefinition, Conversation, type DefineAccountOptions, type DefineBindingOptions, type DefineInboundRouteOptions, type DefineOutboundRouteOptions, DiscoveredAgent, EnvironmentValue, FileFoundryDataAdapter, type FileFoundryDataAdapterOptions, FoundryActivationRecord, FoundryAgentApplication, FoundryBrandingConfig, FoundryDataAdapter, FoundryEventRecord, FoundryManifest, FoundryPendingInbound, FoundryRuntime, FoundryServer, type FoundryServerOptions, FoundryTask, FoundryWorkingEnvironmentSnapshotOwner, InboundDeliveryClaim, InboundRoute, InferAccountMetadata, InferInboundConfig, InferOutboundConfig, OutboundRoute, PlaybookSubscription, ProvisionAgentOptions, SharedInboxItem, WorkspaceEntry, defineAccount, defineBinding, defineInboundRoute, defineOutboundRoute, serializeInboundTransmissionXml, writeGeneratedTypes };
|
|
211
|
+
export { AccountReference, AgentBinding, AgentInstance, AgentPlaybook, AnyFoundryTransmission, CapabilityDefinition, Conversation, type DefineAccountOptions, type DefineBindingOptions, type DefineInboundRouteOptions, type DefineOutboundRouteOptions, DiscoveredAgent, EnvironmentValue, FileFoundryDataAdapter, type FileFoundryDataAdapterOptions, FoundryActivationRecord, FoundryAgentApplication, FoundryApproval, FoundryBrandingConfig, FoundryDataAdapter, FoundryEventRecord, FoundryManifest, FoundryPendingInbound, FoundryRuntime, FoundryServer, type FoundryServerOptions, FoundryTask, FoundryWorkingEnvironmentSnapshotOwner, InboundDeliveryClaim, InboundRoute, InferAccountMetadata, InferInboundConfig, InferOutboundConfig, OutboundRoute, PlaybookSubscription, ProvisionAgentOptions, SharedInboxItem, TopologyStore, WorkspaceEntry, defineAccount, defineBinding, defineInboundRoute, defineOutboundRoute, fileTopologyStore, serializeInboundTransmissionXml, writeGeneratedTypes };
|