@deepagents/experimental 7.7.1 → 7.7.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.
@@ -1 +1 @@
1
- {"version":3,"file":"agent-directory.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/agent-directory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,gEAAgE;AAChE,qBAAa,cAAc;;gBAGb,KAAK,EAAE,YAAY;IAIzB,mBAAmB,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhE,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IASpE,gBAAgB,CACpB,YAAY,EAAE,cAAc,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC;IAyBjB,gBAAgB,CACpB,YAAY,EAAE,cAAc,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;IAIjB,yBAAyB,CAC7B,YAAY,EAAE,cAAc,EAC5B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,GAAG,SAAS,GACrC,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAI7B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAoBrD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOlE,IAAI,CACR,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAO7B,WAAW,CAAC,OAAO,EAAE;QACz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EAAE;QACzB,MAAM,EAAE,WAAW,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,WAAW,CAAC;CAsIzB"}
@@ -0,0 +1,9 @@
1
+ import type { ConversationId } from '../mailbox/types.ts';
2
+ /** A conversation the caller does not own reads as absent, so its owner never leaks. */
3
+ export declare class ConversationNotFoundError extends Error {
4
+ readonly name = "ConversationNotFoundError";
5
+ readonly chatId: string;
6
+ constructor(chatId: string);
7
+ }
8
+ export declare function assertConversationOwner(conversation: ConversationId, storedUserId: string): void;
9
+ //# sourceMappingURL=conversation-not-found-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-not-found-error.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/conversation-not-found-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wFAAwF;AACxF,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,+BAA+B;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAI3B;AAED,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,cAAc,EAC5B,YAAY,EAAE,MAAM,GACnB,IAAI,CAIN"}
@@ -1,6 +1,7 @@
1
1
  export * from './agent.ts';
2
2
  export * from './control-plane/agent-path.ts';
3
3
  export * from './control-plane/agent-thread.ts';
4
+ export { ConversationNotFoundError } from './control-plane/conversation-not-found-error.ts';
4
5
  export * from './instructions.ts';
5
6
  export * from './mailbox/sqlite.store.ts';
6
7
  export * from './mailbox/store.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zukhruf/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,iDAAiD,CAAC;AACrE,cAAc,wDAAwD,CAAC;AACvE,mBAAmB,4CAA4C,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zukhruf/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,iDAAiD,CAAC;AACrE,cAAc,wDAAwD,CAAC;AACvE,mBAAmB,4CAA4C,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
@@ -182,6 +182,21 @@ var AgentThread = class _AgentThread {
182
182
  }
183
183
  };
184
184
 
185
+ // packages/experimental/src/zukhruf/control-plane/conversation-not-found-error.ts
186
+ var ConversationNotFoundError = class extends Error {
187
+ name = "ConversationNotFoundError";
188
+ chatId;
189
+ constructor(chatId) {
190
+ super(`chat "${chatId}" does not exist`);
191
+ this.chatId = chatId;
192
+ }
193
+ };
194
+ function assertConversationOwner(conversation, storedUserId) {
195
+ if (storedUserId !== conversation.userId) {
196
+ throw new ConversationNotFoundError(conversation.chatId);
197
+ }
198
+ }
199
+
185
200
  // packages/experimental/src/zukhruf/instructions.ts
186
201
  function defineInstructions(...fragments) {
187
202
  return fragments;
@@ -857,14 +872,14 @@ var AgentDirectory = class _AgentDirectory {
857
872
  async assertOwnerIfExists(conversation) {
858
873
  const chat2 = await this.#store.getChat(conversation.chatId);
859
874
  if (!chat2) return;
860
- this.#assertOwner(conversation, chat2.userId);
875
+ assertConversationOwner(conversation, chat2.userId);
861
876
  const thread = this.#threadFromMetadata(conversation, chat2.metadata);
862
877
  if (thread) await this.#assertValidParent(thread);
863
878
  }
864
879
  async load(conversation) {
865
880
  const chat2 = await this.#store.getChat(conversation.chatId);
866
- if (chat2) this.#assertOwner(conversation, chat2.userId);
867
881
  if (!chat2) return void 0;
882
+ assertConversationOwner(conversation, chat2.userId);
868
883
  const thread = this.#threadFromMetadata(conversation, chat2.metadata);
869
884
  if (thread) await this.#assertValidParent(thread);
870
885
  return thread;
@@ -877,7 +892,7 @@ var AgentDirectory = class _AgentDirectory {
877
892
  let thread;
878
893
  let adopted = false;
879
894
  await this.#store.updateChat(conversation.chatId, (chat2) => {
880
- this.#assertOwner(conversation, chat2.userId);
895
+ assertConversationOwner(conversation, chat2.userId);
881
896
  const existing = this.#threadFromMetadata(conversation, chat2.metadata);
882
897
  if (existing) {
883
898
  thread = existing;
@@ -974,12 +989,6 @@ var AgentDirectory = class _AgentDirectory {
974
989
  uuidv5.URL
975
990
  );
976
991
  }
977
- #assertOwner(conversation, storedUserId) {
978
- if (storedUserId === conversation.userId) return;
979
- throw new Error(
980
- `chat "${conversation.chatId}" belongs to user "${storedUserId}", not "${conversation.userId}"`
981
- );
982
- }
983
992
  #threadFromMetadata(conversation, metadata) {
984
993
  const thread = AgentThread.fromMetadata(conversation, metadata);
985
994
  if (!thread && AgentThread.hasReservedMetadata(metadata)) {
@@ -1017,7 +1026,7 @@ var AgentDirectory = class _AgentDirectory {
1017
1026
  async #updateLatestTurn(conversation, streamId, ...expected) {
1018
1027
  let result;
1019
1028
  await this.#store.updateChat(conversation.chatId, (chat2) => {
1020
- this.#assertOwner(conversation, chat2.userId);
1029
+ assertConversationOwner(conversation, chat2.userId);
1021
1030
  const thread = this.#threadFromMetadata(conversation, chat2.metadata);
1022
1031
  if (!thread) {
1023
1032
  throw new Error(
@@ -4477,10 +4486,13 @@ var RuntimeHost = class {
4477
4486
  subscribeConversationStatus: (signal) => this.subscribeConversationStatus(signal),
4478
4487
  // Borrows the root declaration's sandbox directly: resolving the
4479
4488
  // conversation through the control plane would create its root thread.
4480
- sandbox: (conversation) => sandboxes.acquire(this.#root, {
4481
- chatId: conversation.chatId,
4482
- userId: conversation.userId
4483
- })
4489
+ sandbox: async (conversation) => {
4490
+ await this.#directory.assertOwnerIfExists(conversation);
4491
+ return sandboxes.acquire(this.#root, {
4492
+ chatId: conversation.chatId,
4493
+ userId: conversation.userId
4494
+ });
4495
+ }
4484
4496
  };
4485
4497
  resources.use(this.#workers);
4486
4498
  }
@@ -4537,21 +4549,13 @@ var RuntimeHost = class {
4537
4549
  }
4538
4550
  async #readConversationMetadata(conversation) {
4539
4551
  const chat2 = await this.#store.getChat(conversation.chatId);
4540
- if (!chat2) throw new Error(`chat "${conversation.chatId}" not found`);
4541
- if (chat2.userId !== conversation.userId) {
4542
- throw new Error(
4543
- `chat "${conversation.chatId}" belongs to user "${chat2.userId}", not "${conversation.userId}"`
4544
- );
4545
- }
4552
+ if (!chat2) throw new ConversationNotFoundError(conversation.chatId);
4553
+ assertConversationOwner(conversation, chat2.userId);
4546
4554
  return chat2.metadata;
4547
4555
  }
4548
4556
  async #updateConversationMetadata(conversation, update) {
4549
4557
  await this.#store.updateChat(conversation.chatId, (chat2) => {
4550
- if (chat2.userId !== conversation.userId) {
4551
- throw new Error(
4552
- `chat "${conversation.chatId}" belongs to user "${chat2.userId}", not "${conversation.userId}"`
4553
- );
4554
- }
4558
+ assertConversationOwner(conversation, chat2.userId);
4555
4559
  return { metadata: update(chat2.metadata) };
4556
4560
  });
4557
4561
  }
@@ -4810,6 +4814,7 @@ export {
4810
4814
  AgentPluginCapability,
4811
4815
  AgentRuntime,
4812
4816
  AgentThread,
4817
+ ConversationNotFoundError,
4813
4818
  DEFAULT_CONVERSATION_STATUS_CHANNEL,
4814
4819
  InterAgentCommunicationTypes,
4815
4820
  MailboxStore,