@deepagents/context 2.2.0 → 2.4.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/dist/index.js CHANGED
@@ -188,18 +188,35 @@ function fragment(name, ...children) {
188
188
  data: children
189
189
  };
190
190
  }
191
+ function withoutDuplicateReasoningParts(message2) {
192
+ const seenReasoningItemIds = /* @__PURE__ */ new Set();
193
+ let dropped = false;
194
+ const parts = message2.parts.filter((part) => {
195
+ if (part.type !== "reasoning") return true;
196
+ const itemId = part.providerMetadata?.openai?.itemId;
197
+ if (typeof itemId !== "string") return true;
198
+ if (seenReasoningItemIds.has(itemId)) {
199
+ dropped = true;
200
+ return false;
201
+ }
202
+ seenReasoningItemIds.add(itemId);
203
+ return true;
204
+ });
205
+ return dropped ? { ...message2, parts } : message2;
206
+ }
191
207
  function assistant(message2) {
208
+ const normalized = withoutDuplicateReasoningParts(message2);
192
209
  return {
193
- id: message2.id,
210
+ id: normalized.id,
194
211
  name: "assistant",
195
212
  type: "message",
196
213
  persist: true,
197
214
  codec: {
198
215
  decode() {
199
- return message2;
216
+ return normalized;
200
217
  },
201
218
  encode() {
202
- return message2;
219
+ return normalized;
203
220
  }
204
221
  }
205
222
  };
@@ -1614,7 +1631,8 @@ var Agent = class _Agent {
1614
1631
  model: this.#options.model,
1615
1632
  system: systemPrompt,
1616
1633
  messages: await convertToModelMessages(messages, {
1617
- ignoreIncompleteToolCalls: true
1634
+ ignoreIncompleteToolCalls: true,
1635
+ tools: this.tools
1618
1636
  }),
1619
1637
  stopWhen: stepCountIs(200),
1620
1638
  tools: this.tools,
@@ -1688,7 +1706,8 @@ var Agent = class _Agent {
1688
1706
  model,
1689
1707
  system: systemPrompt,
1690
1708
  messages: await convertToModelMessages(messages, {
1691
- ignoreIncompleteToolCalls: true
1709
+ ignoreIncompleteToolCalls: true,
1710
+ tools: this.tools
1692
1711
  }),
1693
1712
  experimental_repairToolCall: createRepairToolCall(
1694
1713
  model,
@@ -1963,7 +1982,8 @@ function structuredOutput(options) {
1963
1982
  model: options.model,
1964
1983
  system: systemPrompt,
1965
1984
  messages: await convertToModelMessages(messages, {
1966
- ignoreIncompleteToolCalls: true
1985
+ ignoreIncompleteToolCalls: true,
1986
+ tools: options.tools
1967
1987
  }),
1968
1988
  stopWhen: stepCountIs(200),
1969
1989
  experimental_repairToolCall: createRepairToolCall(
@@ -1998,7 +2018,8 @@ function structuredOutput(options) {
1998
2018
  config?.abortSignal
1999
2019
  ),
2000
2020
  messages: await convertToModelMessages(messages, {
2001
- ignoreIncompleteToolCalls: true
2021
+ ignoreIncompleteToolCalls: true,
2022
+ tools: options.tools
2002
2023
  }),
2003
2024
  stopWhen: stepCountIs(200),
2004
2025
  experimental_transform: config?.transform ?? smoothStream(),
@@ -6109,7 +6130,7 @@ async function snapshot(execute, destination) {
6109
6130
  const probe = await execute(`[ -d ${shellQuote(destination)} ]`);
6110
6131
  if (probe.exitCode !== 0) return /* @__PURE__ */ new Map();
6111
6132
  const list = await execute(
6112
- `find ${shellQuote(destination)} -type f -print0 | while IFS= read -r -d '' p; do sha256sum "$p"; done`
6133
+ `find ${shellQuote(destination)} -type f -exec sha256sum {} +`
6113
6134
  );
6114
6135
  if (list.exitCode !== 0) {
6115
6136
  throw new SnapshotFailedError(
@@ -7327,9 +7348,10 @@ var DockerSandboxStrategy = class {
7327
7348
  resources;
7328
7349
  env;
7329
7350
  name;
7351
+ command;
7330
7352
  createdVolumes = /* @__PURE__ */ new Set();
7331
7353
  constructor(args = {}) {
7332
- const { volumes = [], resources = {}, env = {}, name } = args;
7354
+ const { volumes = [], resources = {}, env = {}, name, command } = args;
7333
7355
  for (const key of Object.keys(env)) {
7334
7356
  validateEnvKey2(key);
7335
7357
  }
@@ -7342,6 +7364,7 @@ var DockerSandboxStrategy = class {
7342
7364
  this.resources = resources;
7343
7365
  this.env = env;
7344
7366
  this.name = name;
7367
+ this.command = command;
7345
7368
  }
7346
7369
  async create() {
7347
7370
  const image = await this.getImage();
@@ -7549,7 +7572,12 @@ var DockerSandboxStrategy = class {
7549
7572
  for (const volume of this.volumes) {
7550
7573
  args.push("--mount", this.buildVolumeMountArg(volume));
7551
7574
  }
7552
- args.push(image, "tail", "-f", "/dev/null");
7575
+ args.push(image);
7576
+ if (this.command === void 0) {
7577
+ args.push("tail", "-f", "/dev/null");
7578
+ } else if (this.command !== null) {
7579
+ args.push(...this.command);
7580
+ }
7553
7581
  return args;
7554
7582
  }
7555
7583
  buildVolumeMountArg(volume) {
@@ -7796,7 +7824,8 @@ var RuntimeStrategy = class extends DockerSandboxStrategy {
7796
7824
  volumes: args.volumes,
7797
7825
  resources: args.resources,
7798
7826
  env: args.env,
7799
- name: args.name
7827
+ name: args.name,
7828
+ command: args.command
7800
7829
  });
7801
7830
  this.image = args.image ?? "alpine:latest";
7802
7831
  this.installers = args.installers ?? [];
@@ -7820,7 +7849,8 @@ var DockerfileStrategy = class extends DockerSandboxStrategy {
7820
7849
  volumes: args.volumes,
7821
7850
  resources: args.resources,
7822
7851
  env: args.env,
7823
- name: args.name
7852
+ name: args.name,
7853
+ command: args.command
7824
7854
  });
7825
7855
  this.dockerfile = args.dockerfile;
7826
7856
  this.dockerContext = args.context ?? ".";
@@ -7989,7 +8019,8 @@ async function createDockerSandbox(options = {}) {
7989
8019
  volumes: options.volumes,
7990
8020
  resources: options.resources,
7991
8021
  env: options.env,
7992
- name: options.name
8022
+ name: options.name,
8023
+ command: options.command
7993
8024
  });
7994
8025
  } else {
7995
8026
  strategy = new RuntimeStrategy({
@@ -7998,7 +8029,8 @@ async function createDockerSandbox(options = {}) {
7998
8029
  volumes: options.volumes,
7999
8030
  resources: options.resources,
8000
8031
  env: options.env,
8001
- name: options.name
8032
+ name: options.name,
8033
+ command: options.command
8002
8034
  });
8003
8035
  }
8004
8036
  return strategy.create();
@@ -8012,6 +8044,16 @@ async function useSandbox(options, fn) {
8012
8044
  }
8013
8045
  }
8014
8046
 
8047
+ // packages/context/src/lib/sandbox/gcs.ts
8048
+ function gcs(options) {
8049
+ return {
8050
+ type: "bind",
8051
+ hostPath: options.hostPath,
8052
+ containerPath: options.mountPath,
8053
+ readOnly: options.readOnly ?? false
8054
+ };
8055
+ }
8056
+
8015
8057
  // packages/context/src/lib/sandbox/installers/package-manager.ts
8016
8058
  var PackageInstaller = class extends Installer {
8017
8059
  kind;
@@ -11712,6 +11754,7 @@ export {
11712
11754
  firstN,
11713
11755
  fragment,
11714
11756
  fromFragment,
11757
+ gcs,
11715
11758
  getFragmentData,
11716
11759
  getLocaleFromMessage,
11717
11760
  getModelsRegistry,