@tanstack/ai 0.37.0 → 0.39.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 (54) hide show
  1. package/dist/esm/activities/chat/index.js +28 -0
  2. package/dist/esm/activities/chat/index.js.map +1 -1
  3. package/dist/esm/activities/chat/mcp/manager.js +10 -1
  4. package/dist/esm/activities/chat/mcp/manager.js.map +1 -1
  5. package/dist/esm/activities/chat/mcp/types.d.ts +22 -0
  6. package/dist/esm/activities/chat/messages.js.map +1 -1
  7. package/dist/esm/activities/chat/middleware/compose.d.ts +7 -1
  8. package/dist/esm/activities/chat/middleware/compose.js +27 -0
  9. package/dist/esm/activities/chat/middleware/compose.js.map +1 -1
  10. package/dist/esm/activities/chat/middleware/index.d.ts +1 -1
  11. package/dist/esm/activities/chat/middleware/sandbox-runtime.d.ts +8 -0
  12. package/dist/esm/activities/chat/middleware/sandbox-runtime.js +9 -0
  13. package/dist/esm/activities/chat/middleware/sandbox-runtime.js.map +1 -0
  14. package/dist/esm/activities/chat/middleware/types.d.ts +22 -0
  15. package/dist/esm/activities/chat/stream/processor.js +23 -0
  16. package/dist/esm/activities/chat/stream/processor.js.map +1 -1
  17. package/dist/esm/activities/chat/tools/tool-calls.d.ts +6 -1
  18. package/dist/esm/activities/chat/tools/tool-calls.js +36 -0
  19. package/dist/esm/activities/chat/tools/tool-calls.js.map +1 -1
  20. package/dist/esm/adapter-internals.d.ts +2 -0
  21. package/dist/esm/adapter-internals.js +4 -0
  22. package/dist/esm/adapter-internals.js.map +1 -1
  23. package/dist/esm/client.d.ts +1 -1
  24. package/dist/esm/client.js.map +1 -1
  25. package/dist/esm/index.d.ts +2 -2
  26. package/dist/esm/logger/internal-logger.d.ts +2 -0
  27. package/dist/esm/logger/internal-logger.js +6 -1
  28. package/dist/esm/logger/internal-logger.js.map +1 -1
  29. package/dist/esm/logger/resolve.js +6 -3
  30. package/dist/esm/logger/resolve.js.map +1 -1
  31. package/dist/esm/logger/types.d.ts +5 -0
  32. package/dist/esm/types.d.ts +52 -1
  33. package/package.json +1 -1
  34. package/skills/ai-core/adapter-configuration/SKILL.md +25 -12
  35. package/skills/ai-core/chat-experience/SKILL.md +30 -2
  36. package/skills/ai-core/media-generation/SKILL.md +13 -0
  37. package/skills/ai-core/tool-calling/SKILL.md +10 -3
  38. package/src/activities/chat/index.ts +39 -0
  39. package/src/activities/chat/mcp/manager.ts +31 -1
  40. package/src/activities/chat/mcp/types.ts +23 -0
  41. package/src/activities/chat/messages.ts +5 -0
  42. package/src/activities/chat/middleware/compose.ts +34 -0
  43. package/src/activities/chat/middleware/index.ts +2 -0
  44. package/src/activities/chat/middleware/sandbox-runtime.ts +21 -0
  45. package/src/activities/chat/middleware/types.ts +37 -0
  46. package/src/activities/chat/stream/processor.ts +42 -0
  47. package/src/activities/chat/tools/tool-calls.ts +96 -2
  48. package/src/adapter-internals.ts +6 -0
  49. package/src/client.ts +1 -0
  50. package/src/index.ts +4 -0
  51. package/src/logger/internal-logger.ts +6 -0
  52. package/src/logger/resolve.ts +3 -0
  53. package/src/logger/types.ts +5 -0
  54. package/src/types.ts +51 -0
@@ -12,6 +12,7 @@ const ALL_OFF: ResolvedCategories = {
12
12
  config: false,
13
13
  errors: false,
14
14
  request: false,
15
+ sandbox: false,
15
16
  }
16
17
 
17
18
  const ALL_ON: ResolvedCategories = {
@@ -23,6 +24,7 @@ const ALL_ON: ResolvedCategories = {
23
24
  config: true,
24
25
  errors: true,
25
26
  request: true,
27
+ sandbox: true,
26
28
  }
27
29
 
28
30
  const errorsOnlyCategories = (): ResolvedCategories => ({
@@ -41,6 +43,7 @@ const resolveCategoriesFromPartial = (
41
43
  config: partial.config ?? true,
42
44
  errors: partial.errors ?? true,
43
45
  request: partial.request ?? true,
46
+ sandbox: partial.sandbox ?? true,
44
47
  })
45
48
 
46
49
  /**
@@ -60,6 +60,11 @@ export interface DebugCategories {
60
60
  * Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call.
61
61
  */
62
62
  request?: boolean
63
+ /**
64
+ * Sandbox internals: watcher start/stop + mechanism, file events, sandbox
65
+ * hook dispatch, ensure/bootstrap and lifecycle transitions. Chat-only.
66
+ */
67
+ sandbox?: boolean
63
68
  }
64
69
 
65
70
  /**
package/src/types.ts CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  } from '@standard-schema/spec'
5
5
  import type { InternalLogger } from './logger/internal-logger'
6
6
  import type { SystemPrompt } from './system-prompts'
7
+ import type { CapabilityContext } from './activities/chat/middleware/capabilities'
7
8
  // The canonical usage types live in the leaf `@tanstack/ai-event-client`
8
9
  // package (which `@tanstack/ai` already depends on) so there is a single source
9
10
  // of truth without a dependency cycle. They are re-exported below.
@@ -416,6 +417,23 @@ export interface StructuredOutputPart<TData = unknown> {
416
417
  errorMessage?: string
417
418
  }
418
419
 
420
+ export interface UIResourcePart {
421
+ type: 'ui-resource'
422
+ /** The ui:// resource object in MCP-native shape — fed straight to the renderer. */
423
+ resource: { uri: string; mimeType: string; text?: string; blob?: string }
424
+ /** Pool prefix / config key — routes interactive calls to the right MCP server. */
425
+ serverId?: string
426
+ /** Links the widget to the originating tool call — correlates it with the
427
+ * sibling ToolCallPart/ToolResultPart in the same message. */
428
+ toolCallId: string
429
+ /** Server-native (unprefixed) MCP tool name whose UI this resource renders.
430
+ * Required by the renderer (`@mcp-ui/client`'s `AppRenderer` `toolName` prop). */
431
+ toolName: string
432
+ /** Reserved for future passthrough of the resource/tool `_meta.ui` (e.g. frame-size hints).
433
+ * Currently always `undefined` — nothing populates this field yet. */
434
+ meta?: Record<string, unknown>
435
+ }
436
+
419
437
  export type MessagePart<TData = unknown> =
420
438
  | TextPart
421
439
  | ImagePart
@@ -426,6 +444,7 @@ export type MessagePart<TData = unknown> =
426
444
  | ToolResultPart
427
445
  | ThinkingPart
428
446
  | StructuredOutputPart<TData>
447
+ | UIResourcePart
429
448
 
430
449
  /**
431
450
  * UIMessage - Domain-specific message format optimized for building chat UIs
@@ -928,6 +947,25 @@ export interface TextOptions<
928
947
  * Surfaced for observability/middleware; not consumed by the LLM call.
929
948
  */
930
949
  parentRunId?: string
950
+
951
+ /**
952
+ * Middleware capability context for this run. The engine populates it with
953
+ * the live middleware context so harness adapters that declare
954
+ * `requires: [SomeCapability]` can read provided capabilities from inside
955
+ * `chatStream` — e.g. `getSandbox(options.capabilities)`. Capabilities are
956
+ * provisioned by middleware `setup` before the adapter runs. Undefined for
957
+ * direct adapter usage outside the chat engine.
958
+ */
959
+ capabilities?: CapabilityContext
960
+
961
+ /**
962
+ * Client approval decisions for this run, keyed by approval id. The engine
963
+ * populates this from approvals carried on the incoming messages. Harness
964
+ * adapters consult it to resolve `ask`-policy permission requests (the agent
965
+ * pauses on a risky action; the client re-runs with a decision recorded
966
+ * here). Undefined for direct adapter usage outside the chat engine.
967
+ */
968
+ approvals?: ReadonlyMap<string, boolean>
931
969
  }
932
970
 
933
971
  // ============================================================================
@@ -1308,6 +1346,19 @@ export interface ToolInputAvailableEvent extends CustomEvent {
1308
1346
  }
1309
1347
  }
1310
1348
 
1349
+ /** Emitted when an MCP tool returns a ui:// resource (MCP Apps). Reconciled into
1350
+ * a UIResourcePart on the assistant UIMessage. Never enters model input. */
1351
+ export interface UIResourceEvent extends CustomEvent {
1352
+ name: 'ui-resource'
1353
+ value: {
1354
+ resource: UIResourcePart['resource']
1355
+ serverId?: string
1356
+ toolCallId: string
1357
+ toolName: string
1358
+ meta?: Record<string, unknown>
1359
+ }
1360
+ }
1361
+
1311
1362
  /**
1312
1363
  * Public type for streams returned by `chat({ outputSchema, stream: true })`.
1313
1364
  *