@deepagents/context 6.1.0 → 7.0.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.
Files changed (79) hide show
  1. package/README.md +29 -3
  2. package/dist/browser.js +9 -2
  3. package/dist/browser.js.map +2 -2
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1411 -514
  7. package/dist/index.js.map +4 -4
  8. package/dist/lib/agent.d.ts +78 -37
  9. package/dist/lib/agent.d.ts.map +1 -1
  10. package/dist/lib/chat.d.ts +17 -18
  11. package/dist/lib/chat.d.ts.map +1 -1
  12. package/dist/lib/engine.d.ts.map +1 -1
  13. package/dist/lib/fragments/plan-shared.d.ts +46 -0
  14. package/dist/lib/fragments/plan-shared.d.ts.map +1 -0
  15. package/dist/lib/fragments/plan.d.ts.map +1 -1
  16. package/dist/lib/fragments/socratic-inquiry.d.ts +4 -0
  17. package/dist/lib/fragments/socratic-inquiry.d.ts.map +1 -0
  18. package/dist/lib/fragments/socratic-plan.d.ts +13 -0
  19. package/dist/lib/fragments/socratic-plan.d.ts.map +1 -0
  20. package/dist/lib/fragments/socratic.d.ts +2 -5
  21. package/dist/lib/fragments/socratic.d.ts.map +1 -1
  22. package/dist/lib/sandbox/agent-os-sandbox.d.ts +1 -1
  23. package/dist/lib/sandbox/agent-os-sandbox.d.ts.map +1 -1
  24. package/dist/lib/sandbox/apple-container-sandbox.d.ts +3 -3
  25. package/dist/lib/sandbox/apple-container-sandbox.d.ts.map +1 -1
  26. package/dist/lib/sandbox/bash-tool.d.ts +1 -1
  27. package/dist/lib/sandbox/bash-tool.d.ts.map +1 -1
  28. package/dist/lib/sandbox/cli-process.d.ts +6 -0
  29. package/dist/lib/sandbox/cli-process.d.ts.map +1 -1
  30. package/dist/lib/sandbox/container-engine.d.ts +1 -0
  31. package/dist/lib/sandbox/container-engine.d.ts.map +1 -1
  32. package/dist/lib/sandbox/container-sandbox.d.ts +1 -0
  33. package/dist/lib/sandbox/container-sandbox.d.ts.map +1 -1
  34. package/dist/lib/sandbox/daytona-sandbox.d.ts.map +1 -1
  35. package/dist/lib/sandbox/docker-sandbox.d.ts +10 -3
  36. package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
  37. package/dist/lib/sandbox/index.d.ts +1 -0
  38. package/dist/lib/sandbox/index.d.ts.map +1 -1
  39. package/dist/lib/sandbox/microsandbox-sandbox.d.ts +13 -17
  40. package/dist/lib/sandbox/microsandbox-sandbox.d.ts.map +1 -1
  41. package/dist/lib/sandbox/read-file-tool/binary.d.ts +13 -0
  42. package/dist/lib/sandbox/read-file-tool/binary.d.ts.map +1 -0
  43. package/dist/lib/sandbox/read-file-tool/format.d.ts +17 -0
  44. package/dist/lib/sandbox/read-file-tool/format.d.ts.map +1 -0
  45. package/dist/lib/sandbox/read-file-tool/image.d.ts +4 -0
  46. package/dist/lib/sandbox/read-file-tool/image.d.ts.map +1 -0
  47. package/dist/lib/sandbox/read-file-tool/index.d.ts +6 -0
  48. package/dist/lib/sandbox/read-file-tool/index.d.ts.map +1 -0
  49. package/dist/lib/sandbox/read-file-tool/ooxml.d.ts +4 -0
  50. package/dist/lib/sandbox/read-file-tool/ooxml.d.ts.map +1 -0
  51. package/dist/lib/sandbox/read-file-tool/pdf.d.ts +4 -0
  52. package/dist/lib/sandbox/read-file-tool/pdf.d.ts.map +1 -0
  53. package/dist/lib/sandbox/read-file-tool/text.d.ts +10 -0
  54. package/dist/lib/sandbox/read-file-tool/text.d.ts.map +1 -0
  55. package/dist/lib/sandbox/read-file.d.ts +8 -0
  56. package/dist/lib/sandbox/read-file.d.ts.map +1 -0
  57. package/dist/lib/sandbox/shell-quote.d.ts +1 -1
  58. package/dist/lib/sandbox/strace/index.d.ts +3 -3
  59. package/dist/lib/sandbox/strace/index.d.ts.map +1 -1
  60. package/dist/lib/sandbox/strace/index.js +2 -2
  61. package/dist/lib/sandbox/strace/index.js.map +2 -2
  62. package/dist/lib/sandbox/types.d.ts +24 -5
  63. package/dist/lib/sandbox/types.d.ts.map +1 -1
  64. package/dist/lib/sandbox/virtual-sandbox.d.ts.map +1 -1
  65. package/dist/lib/stream-buffer.d.ts +1 -1
  66. package/dist/lib/stream-buffer.d.ts.map +1 -1
  67. package/dist/lib/telemetry/console-telemetry.d.ts +0 -1
  68. package/dist/lib/telemetry/console-telemetry.d.ts.map +1 -1
  69. package/dist/lib/telemetry/file/file-telemetry.d.ts +5 -3
  70. package/dist/lib/telemetry/file/file-telemetry.d.ts.map +1 -1
  71. package/dist/lib/telemetry/file/index.js +16 -11
  72. package/dist/lib/telemetry/file/index.js.map +2 -2
  73. package/dist/lib/telemetry/index.js +3 -4
  74. package/dist/lib/telemetry/index.js.map +2 -2
  75. package/dist/lib/telemetry/safe-serialize.d.ts +2 -2
  76. package/dist/lib/telemetry/safe-serialize.d.ts.map +1 -1
  77. package/dist/lib/tracing/index.js +4 -4
  78. package/dist/lib/tracing/index.js.map +2 -2
  79. package/package.json +9 -8
package/README.md CHANGED
@@ -177,14 +177,20 @@ parent thread.
177
177
 
178
178
  ```typescript
179
179
  import { openai } from '@ai-sdk/openai';
180
+ import { InMemoryFs } from 'just-bash';
180
181
 
181
182
  import {
182
183
  ContextEngine,
183
184
  InMemoryContextStore,
184
185
  agent,
186
+ createBashTool,
187
+ createVirtualSandbox,
185
188
  role,
186
189
  } from '@deepagents/context';
187
190
 
191
+ await using backend = await createVirtualSandbox({ fs: new InMemoryFs() });
192
+ const sandbox = await createBashTool({ sandbox: backend });
193
+
188
194
  const context = new ContextEngine({
189
195
  store: new InMemoryContextStore(),
190
196
  chatId: 'chat-001',
@@ -194,14 +200,16 @@ const context = new ContextEngine({
194
200
  const analyst = agent({
195
201
  name: 'analyst',
196
202
  context,
203
+ sandbox,
197
204
  model: openai('gpt-5.4-mini'),
198
205
  });
199
206
 
200
- const { tool: advisor } = analyst.asAdvisor({ concise: true });
207
+ const { tool: advisor } = analyst.asAdvisor();
201
208
 
202
209
  const coordinator = agent({
203
210
  name: 'coordinator',
204
211
  context,
212
+ sandbox,
205
213
  model: openai('gpt-5.4'),
206
214
  tools: {
207
215
  analyze: analyst.asTool({
@@ -317,8 +325,9 @@ points.
317
325
  For `target: 'tool-output'`, use `toolOutput(...)` or inspect
318
326
  `ctx.toolOutcome`. The outcome is available after a tool reaches
319
327
  `output-available`, `output-error`, or `output-denied`, but before the next model
320
- generation. Assistant-history predicates such as `toolCalled(...)` only
321
- describe already persisted calls.
328
+ generation. Assistant-history predicates such as `toolCalled(...)` describe
329
+ tool parts visible in the current assistant segment; use `toolOutput(...)` when
330
+ you need the raw outcome currently being evaluated.
322
331
 
323
332
  ```ts
324
333
  import {
@@ -380,6 +389,23 @@ engine.set(
380
389
  );
381
390
  ```
382
391
 
392
+ Use `socraticPlan.instructions()` when the work needs inquiry instead of a
393
+ fixed checklist. It stores evidence-backed questions and answers in the same
394
+ plan file, moves adaptively through domain, case, and bridge phases, and lets
395
+ each review choose the highest-value unanswered question.
396
+
397
+ ```ts
398
+ engine.set(
399
+ socraticPlan.instructions(),
400
+ socraticPlan.review({ when: everyNToolCalls(5) }),
401
+ );
402
+ ```
403
+
404
+ The agent answers from source and runtime evidence, and asks the user only when
405
+ the answer requires missing information or authority. The standalone
406
+ `socraticPrompting()` fragment shares the inquiry workflow but does not persist
407
+ plan state.
408
+
383
409
  - `stripTextByRanges(text, ranges)` removes offset spans from text and returns the remaining visible content.
384
410
  - `stripReminders(message)` strips inline/part reminders and model-only synthetic reminder payloads from a `UIMessage`.
385
411
  - `isSyntheticReminderMessage(message)` identifies stored model-only reminder carriers so a UI can omit them entirely.
package/dist/browser.js CHANGED
@@ -2244,6 +2244,7 @@ async function persistedWriter(options) {
2244
2244
  let seq = 0;
2245
2245
  let buffer = [];
2246
2246
  let failedByErrorChunk = false;
2247
+ let abortedByChunk = false;
2247
2248
  async function flush() {
2248
2249
  if (buffer.length === 0) return;
2249
2250
  const batch = buffer;
@@ -2269,11 +2270,14 @@ async function persistedWriter(options) {
2269
2270
  }
2270
2271
  }
2271
2272
  async function persistChunk(chunk) {
2273
+ if (chunk.data.type === "abort") {
2274
+ abortedByChunk = true;
2275
+ }
2272
2276
  if (strategy === "immediate") {
2273
2277
  await appendBatch([chunk]);
2274
2278
  } else {
2275
2279
  buffer.push(chunk);
2276
- if (buffer.length >= flushSize) {
2280
+ if (buffer.length >= flushSize || chunk.data.type.startsWith("data-")) {
2277
2281
  await flush();
2278
2282
  }
2279
2283
  }
@@ -2301,7 +2305,10 @@ async function persistedWriter(options) {
2301
2305
  async complete() {
2302
2306
  await flush();
2303
2307
  if (failedByErrorChunk) return;
2304
- await store.updateStreamStatus(streamId, "completed");
2308
+ await store.updateStreamStatus(
2309
+ streamId,
2310
+ abortedByChunk ? "cancelled" : "completed"
2311
+ );
2305
2312
  },
2306
2313
  async fail(error) {
2307
2314
  await flush();