@deepagents/experimental 7.5.0 → 7.5.2
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 +22 -6
- package/dist/index.js +38 -5
- package/dist/index.js.map +3 -3
- package/dist/zukhruf/index.js +38 -5
- package/dist/zukhruf/index.js.map +3 -3
- package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +2 -2
- package/dist/zukhruf/plugins/schedules/index.js.map +2 -2
- package/dist/zukhruf/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts +3 -0
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
- package/dist/zukhruf/runtime/conversation-sandboxes.d.ts +16 -0
- package/dist/zukhruf/runtime/conversation-sandboxes.d.ts.map +1 -0
- package/package.json +9 -9
package/dist/zukhruf/index.js
CHANGED
|
@@ -2715,6 +2715,7 @@ var AgentTurnExecutor = class {
|
|
|
2715
2715
|
#approvals;
|
|
2716
2716
|
#multiAgent;
|
|
2717
2717
|
#plugins;
|
|
2718
|
+
#sandboxes;
|
|
2718
2719
|
#publishConversationStatus;
|
|
2719
2720
|
constructor(options) {
|
|
2720
2721
|
this.#store = options.store;
|
|
@@ -2724,6 +2725,7 @@ var AgentTurnExecutor = class {
|
|
|
2724
2725
|
this.#approvals = options.approvals;
|
|
2725
2726
|
this.#multiAgent = options.multiAgent;
|
|
2726
2727
|
this.#plugins = options.plugins;
|
|
2728
|
+
this.#sandboxes = options.sandboxes;
|
|
2727
2729
|
this.#publishConversationStatus = options.publishConversationStatus;
|
|
2728
2730
|
}
|
|
2729
2731
|
async execute(turn, context) {
|
|
@@ -2773,11 +2775,10 @@ var AgentTurnExecutor = class {
|
|
|
2773
2775
|
}
|
|
2774
2776
|
await this.#controlPlane.recordLatestTurn(turn, turn.streamId);
|
|
2775
2777
|
await this.#prepareChain(turn, engine, communications);
|
|
2776
|
-
const sandbox = await
|
|
2778
|
+
const sandbox = await this.#sandboxes.acquire(declaration, {
|
|
2777
2779
|
chatId: turn.chatId,
|
|
2778
2780
|
userId: turn.userId
|
|
2779
2781
|
});
|
|
2780
|
-
await using _turnSandbox = sandbox.sandbox;
|
|
2781
2782
|
const agentSkills = await this.#skillsFor(
|
|
2782
2783
|
turn,
|
|
2783
2784
|
declaration.name,
|
|
@@ -3283,6 +3284,36 @@ var ApprovalController = class _ApprovalController {
|
|
|
3283
3284
|
}
|
|
3284
3285
|
};
|
|
3285
3286
|
|
|
3287
|
+
// packages/experimental/src/zukhruf/runtime/conversation-sandboxes.ts
|
|
3288
|
+
var ConversationSandboxes = class {
|
|
3289
|
+
// One memoized acquisition for each declaration and conversation.
|
|
3290
|
+
#held = /* @__PURE__ */ new Map();
|
|
3291
|
+
acquire(declaration, context) {
|
|
3292
|
+
const key = JSON.stringify([
|
|
3293
|
+
declaration.name,
|
|
3294
|
+
context.chatId,
|
|
3295
|
+
context.userId
|
|
3296
|
+
]);
|
|
3297
|
+
const held = this.#held.get(key);
|
|
3298
|
+
if (held !== void 0) return held();
|
|
3299
|
+
const acquiring = declaration.sandbox(context).catch((error) => {
|
|
3300
|
+
this.#held.delete(key);
|
|
3301
|
+
throw error;
|
|
3302
|
+
});
|
|
3303
|
+
this.#held.set(key, () => acquiring);
|
|
3304
|
+
return acquiring;
|
|
3305
|
+
}
|
|
3306
|
+
async [Symbol.asyncDispose]() {
|
|
3307
|
+
await using handles = new AsyncDisposableStack();
|
|
3308
|
+
const acquired = await Promise.allSettled(
|
|
3309
|
+
Array.from(this.#held.values(), (held) => held())
|
|
3310
|
+
);
|
|
3311
|
+
this.#held.clear();
|
|
3312
|
+
for (const result of acquired)
|
|
3313
|
+
if (result.status === "fulfilled") handles.use(result.value.sandbox);
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
|
|
3286
3317
|
// packages/experimental/src/zukhruf/runtime/conversation-status/projector.ts
|
|
3287
3318
|
import { Latch } from "@zukhruf/async";
|
|
3288
3319
|
import { Mutex } from "@zukhruf/mutex";
|
|
@@ -4417,6 +4448,7 @@ var RuntimeHost = class {
|
|
|
4417
4448
|
subagents: (declaration.subagents ?? []).map(({ name }) => name)
|
|
4418
4449
|
}))
|
|
4419
4450
|
};
|
|
4451
|
+
const sandboxes = resources.use(new ConversationSandboxes());
|
|
4420
4452
|
this.#executor = new AgentTurnExecutor({
|
|
4421
4453
|
store: options.store,
|
|
4422
4454
|
streams,
|
|
@@ -4425,6 +4457,7 @@ var RuntimeHost = class {
|
|
|
4425
4457
|
approvals,
|
|
4426
4458
|
multiAgent,
|
|
4427
4459
|
plugins,
|
|
4460
|
+
sandboxes,
|
|
4428
4461
|
publishConversationStatus: (conversation) => conversationStatus.publish(conversation)
|
|
4429
4462
|
});
|
|
4430
4463
|
this.#pluginHost = {
|
|
@@ -4437,9 +4470,9 @@ var RuntimeHost = class {
|
|
|
4437
4470
|
listHistory: () => this.listHistory(),
|
|
4438
4471
|
observe: (conversation) => this.observe(conversation),
|
|
4439
4472
|
subscribeConversationStatus: (signal) => this.subscribeConversationStatus(signal),
|
|
4440
|
-
//
|
|
4441
|
-
// through the control plane would create its root thread.
|
|
4442
|
-
sandbox: (conversation) => this.#root
|
|
4473
|
+
// Borrows the root declaration's sandbox directly: resolving the
|
|
4474
|
+
// conversation through the control plane would create its root thread.
|
|
4475
|
+
sandbox: (conversation) => sandboxes.acquire(this.#root, {
|
|
4443
4476
|
chatId: conversation.chatId,
|
|
4444
4477
|
userId: conversation.userId
|
|
4445
4478
|
})
|