@assistant-ui/core 0.2.8 → 0.2.9

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.
@@ -22,6 +22,8 @@ import { AssistantDataUI, makeAssistantDataUI } from "./model-context/makeAssist
22
22
  import { useAssistantInstructions } from "./model-context/useAssistantInstructions.js";
23
23
  import { useAssistantContext } from "./model-context/useAssistantContext.js";
24
24
  import { useInlineRender } from "./model-context/useInlineRender.js";
25
+ import { defineToolkit } from "./model-context/define-toolkit.js";
26
+ import { hitl } from "./model-context/hitl.js";
25
27
  import { AssistantInteractableProps, useAssistantInteractable } from "./model-context/useAssistantInteractable.js";
26
28
  import { useInteractableState } from "./model-context/useInteractableState.js";
27
29
  import { ToolArgsStatus, useToolArgsStatus } from "./model-context/useToolArgsStatus.js";
@@ -95,4 +97,4 @@ import { useEditComposerCancel } from "./primitive-hooks/useEditComposerCancel.j
95
97
  import { useEditComposerSend } from "./primitive-hooks/useEditComposerSend.js";
96
98
  import { useMessageError } from "./primitive-hooks/useMessageError.js";
97
99
  import { LocalRuntimeOptions, splitLocalRuntimeOptions, useLocalRuntime } from "./runtimes/useLocalRuntime.js";
98
- export { type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantInteractableProps, AssistantProviderBase, type AssistantProviderBaseProps, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AsyncStorageLike, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, type DataRenderersClientSchema, type DataRenderersMethods, type DataRenderersState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, type FileMessagePartComponent, type FileMessagePartProps, type GenerativeUIComponentRegistry, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GroupByContext, type ImageMessagePartComponent, type ImageMessagePartProps, type InteractableDefinition, type InteractablePersistedState, type InteractablePersistenceAdapter, type InteractablePersistenceStatus, type InteractableRegistration, type InteractableStateSchema, Interactables, type InteractablesClientSchema, type InteractablesMethods, type InteractablesState, type LocalRuntimeOptions, type McpAppResourceOutput, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, type PartState, QueueItemByIndexProvider, type QueueItemByIndexProviderProps, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, type RuntimeAdapters, type SourceMessagePartComponent, type SourceMessagePartProps, SuggestionByIndexProvider, type SuggestionByIndexProviderProps, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, type TitleGenerationAdapter, type ToolArgsStatus, type ToolCallMessagePartComponent, type ToolCallMessagePartProps, type ToolDefinition, type Toolkit, type ToolkitDeclaration, type ToolkitDeclarationDefinition, Tools, type ToolsClientSchema, type ToolsMethods, type ToolsState, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type UseActionBarCopyOptions, type UseComposerIfProps, type UseSuggestionTriggerOptions, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, getMessageQuote, getRenderComponent, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
100
+ export { type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantInteractableProps, AssistantProviderBase, type AssistantProviderBaseProps, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AsyncStorageLike, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, type DataRenderersClientSchema, type DataRenderersMethods, type DataRenderersState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, type FileMessagePartComponent, type FileMessagePartProps, type GenerativeUIComponentRegistry, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GroupByContext, type ImageMessagePartComponent, type ImageMessagePartProps, type InteractableDefinition, type InteractablePersistedState, type InteractablePersistenceAdapter, type InteractablePersistenceStatus, type InteractableRegistration, type InteractableStateSchema, Interactables, type InteractablesClientSchema, type InteractablesMethods, type InteractablesState, type LocalRuntimeOptions, type McpAppResourceOutput, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, type PartState, QueueItemByIndexProvider, type QueueItemByIndexProviderProps, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, type RuntimeAdapters, type SourceMessagePartComponent, type SourceMessagePartProps, SuggestionByIndexProvider, type SuggestionByIndexProviderProps, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, type TitleGenerationAdapter, type ToolArgsStatus, type ToolCallMessagePartComponent, type ToolCallMessagePartProps, type ToolDefinition, type Toolkit, type ToolkitDeclaration, type ToolkitDeclarationDefinition, Tools, type ToolsClientSchema, type ToolsMethods, type ToolsState, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type UseActionBarCopyOptions, type UseComposerIfProps, type UseSuggestionTriggerOptions, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, defineToolkit, getMessageQuote, getRenderComponent, groupPartByType, hitl, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
@@ -12,6 +12,8 @@ import { makeAssistantDataUI } from "./model-context/makeAssistantDataUI.js";
12
12
  import { useAssistantInstructions } from "./model-context/useAssistantInstructions.js";
13
13
  import { useAssistantContext } from "./model-context/useAssistantContext.js";
14
14
  import { useInlineRender } from "./model-context/useInlineRender.js";
15
+ import { defineToolkit } from "./model-context/define-toolkit.js";
16
+ import { hitl } from "./model-context/hitl.js";
15
17
  import { useAssistantInteractable } from "./model-context/useAssistantInteractable.js";
16
18
  import { useInteractableState } from "./model-context/useInteractableState.js";
17
19
  import { useToolArgsStatus } from "./model-context/useToolArgsStatus.js";
@@ -86,4 +88,4 @@ import { useEditComposerCancel } from "./primitive-hooks/useEditComposerCancel.j
86
88
  import { useEditComposerSend } from "./primitive-hooks/useEditComposerSend.js";
87
89
  import { useMessageError } from "./primitive-hooks/useMessageError.js";
88
90
  import { splitLocalRuntimeOptions, useLocalRuntime } from "./runtimes/useLocalRuntime.js";
89
- export { AssistantProviderBase, AssistantRuntimeProvider, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, QueueItemByIndexProvider, ReadonlyThreadProvider, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, SuggestionByIndexProvider, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, Tools, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, getMessageQuote, getRenderComponent, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
91
+ export { AssistantProviderBase, AssistantRuntimeProvider, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, QueueItemByIndexProvider, ReadonlyThreadProvider, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, SuggestionByIndexProvider, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, Tools, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, defineToolkit, getMessageQuote, getRenderComponent, groupPartByType, hitl, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
@@ -0,0 +1,20 @@
1
+ import { Toolkit, ToolkitDeclaration } from "./toolbox.js";
2
+
3
+ //#region src/react/model-context/define-toolkit.d.ts
4
+ /**
5
+ * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
6
+ * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
7
+ * and types the result as the canonical {@link Toolkit}.
8
+ *
9
+ * It has **no runtime implementation**. A `"use generative"` compiler (e.g.
10
+ * `@assistant-ui/next` or `@assistant-ui/vite`) strips the `defineToolkit(...)`
11
+ * wrapper (and its import) per build, so a correctly compiled
12
+ * `export default defineToolkit({...})` never calls this. If it *does* run, the
13
+ * module was not compiled by a use-generative loader — e.g. `defineToolkit` used
14
+ * outside a `"use generative"` file — which would ship a backend `execute` to the
15
+ * client. So it throws instead of silently leaking.
16
+ */
17
+ declare function defineToolkit(_declaration: ToolkitDeclaration): Toolkit;
18
+ //#endregion
19
+ export { defineToolkit };
20
+ //# sourceMappingURL=define-toolkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-toolkit.d.ts","names":[],"sources":["../../../src/react/model-context/define-toolkit.ts"],"mappings":";;;;;AAeA;;;;;;;;AAAwE;;;iBAAxD,aAAA,CAAc,YAAA,EAAc,kBAAA,GAAqB,OAAO"}
@@ -0,0 +1,21 @@
1
+ //#region src/react/model-context/define-toolkit.ts
2
+ /**
3
+ * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
4
+ * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
5
+ * and types the result as the canonical {@link Toolkit}.
6
+ *
7
+ * It has **no runtime implementation**. A `"use generative"` compiler (e.g.
8
+ * `@assistant-ui/next` or `@assistant-ui/vite`) strips the `defineToolkit(...)`
9
+ * wrapper (and its import) per build, so a correctly compiled
10
+ * `export default defineToolkit({...})` never calls this. If it *does* run, the
11
+ * module was not compiled by a use-generative loader — e.g. `defineToolkit` used
12
+ * outside a `"use generative"` file — which would ship a backend `execute` to the
13
+ * client. So it throws instead of silently leaking.
14
+ */
15
+ function defineToolkit(_declaration) {
16
+ throw new Error("[assistant-ui] defineToolkit() has no runtime implementation — it is stripped at build time by the use-generative compiler. Reaching it means this module was not compiled (e.g. defineToolkit used outside a \"use generative\" file). Add the directive, or do not use defineToolkit here.");
17
+ }
18
+ //#endregion
19
+ export { defineToolkit };
20
+
21
+ //# sourceMappingURL=define-toolkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-toolkit.js","names":[],"sources":["../../../src/react/model-context/define-toolkit.ts"],"sourcesContent":["import type { Toolkit, ToolkitDeclaration } from \"./toolbox\";\n\n/**\n * Authoring helper for a `\"use generative\"` toolkit. Accepts the permissive\n * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)\n * and types the result as the canonical {@link Toolkit}.\n *\n * It has **no runtime implementation**. A `\"use generative\"` compiler (e.g.\n * `@assistant-ui/next` or `@assistant-ui/vite`) strips the `defineToolkit(...)`\n * wrapper (and its import) per build, so a correctly compiled\n * `export default defineToolkit({...})` never calls this. If it *does* run, the\n * module was not compiled by a use-generative loader — e.g. `defineToolkit` used\n * outside a `\"use generative\"` file — which would ship a backend `execute` to the\n * client. So it throws instead of silently leaking.\n */\nexport function defineToolkit(_declaration: ToolkitDeclaration): Toolkit {\n throw new Error(\n \"[assistant-ui] defineToolkit() has no runtime implementation — it is \" +\n \"stripped at build time by the use-generative compiler. Reaching it means \" +\n 'this module was not compiled (e.g. defineToolkit used outside a \"use ' +\n 'generative\" file). Add the directive, or do not use defineToolkit here.',\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,cAAc,cAA2C;CACvE,MAAM,IAAI,MACR,8RAIF;AACF"}
@@ -0,0 +1,19 @@
1
+ //#region src/react/model-context/hitl.d.ts
2
+ /**
3
+ * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
4
+ * supplies the result instead of code. Use it as the tool's `execute`:
5
+ *
6
+ * ```tsx
7
+ * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }
8
+ * ```
9
+ *
10
+ * Like {@link defineToolkit}, it has **no runtime implementation**: a
11
+ * `"use generative"` compiler (e.g. `@assistant-ui/next` or `@assistant-ui/vite`)
12
+ * detects `execute: hitl()`, drops it, and stamps the tool `type: "human"`.
13
+ * Reaching it at runtime means the module wasn't compiled (used outside a
14
+ * `"use generative"` file), so it throws.
15
+ */
16
+ declare function hitl(): never;
17
+ //#endregion
18
+ export { hitl };
19
+ //# sourceMappingURL=hitl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl.d.ts","names":[],"sources":["../../../src/react/model-context/hitl.ts"],"mappings":";;AAcA;;;;AAAoB;;;;;;;;;iBAAJ,IAAA"}
@@ -0,0 +1,22 @@
1
+ //#region src/react/model-context/hitl.ts
2
+ /**
3
+ * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
4
+ * supplies the result instead of code. Use it as the tool's `execute`:
5
+ *
6
+ * ```tsx
7
+ * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }
8
+ * ```
9
+ *
10
+ * Like {@link defineToolkit}, it has **no runtime implementation**: a
11
+ * `"use generative"` compiler (e.g. `@assistant-ui/next` or `@assistant-ui/vite`)
12
+ * detects `execute: hitl()`, drops it, and stamps the tool `type: "human"`.
13
+ * Reaching it at runtime means the module wasn't compiled (used outside a
14
+ * `"use generative"` file), so it throws.
15
+ */
16
+ function hitl() {
17
+ throw new Error("[assistant-ui] hitl() has no runtime implementation — it marks a human-in-the-loop tool and is stripped at build time by the use-generative compiler. Reaching it means this module was not compiled (e.g. hitl() used outside a \"use generative\" file).");
18
+ }
19
+ //#endregion
20
+ export { hitl };
21
+
22
+ //# sourceMappingURL=hitl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl.js","names":[],"sources":["../../../src/react/model-context/hitl.ts"],"sourcesContent":["/**\n * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)\n * supplies the result instead of code. Use it as the tool's `execute`:\n *\n * ```tsx\n * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }\n * ```\n *\n * Like {@link defineToolkit}, it has **no runtime implementation**: a\n * `\"use generative\"` compiler (e.g. `@assistant-ui/next` or `@assistant-ui/vite`)\n * detects `execute: hitl()`, drops it, and stamps the tool `type: \"human\"`.\n * Reaching it at runtime means the module wasn't compiled (used outside a\n * `\"use generative\"` file), so it throws.\n */\nexport function hitl(): never {\n throw new Error(\n \"[assistant-ui] hitl() has no runtime implementation — it marks a \" +\n \"human-in-the-loop tool and is stripped at build time by the \" +\n \"use-generative compiler. Reaching it means this module was not compiled \" +\n '(e.g. hitl() used outside a \"use generative\" file).',\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,OAAc;CAC5B,MAAM,IAAI,MACR,4PAIF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/core",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Framework-agnostic core runtime for assistant-ui",
5
5
  "keywords": [
6
6
  "assistant",
@@ -59,7 +59,7 @@
59
59
  ],
60
60
  "sideEffects": false,
61
61
  "dependencies": {
62
- "assistant-stream": "^0.3.18",
62
+ "assistant-stream": "^0.3.19",
63
63
  "nanoid": "^5.1.11"
64
64
  },
65
65
  "peerDependencies": {
@@ -38,6 +38,8 @@ export {
38
38
  type ToolkitDeclaration,
39
39
  type ToolkitDeclarationDefinition,
40
40
  } from "./model-context/toolbox";
41
+ export { defineToolkit } from "./model-context/define-toolkit";
42
+ export { hitl } from "./model-context/hitl";
41
43
  export {
42
44
  useAssistantInteractable,
43
45
  type AssistantInteractableProps,
@@ -0,0 +1,13 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { defineToolkit } from "./define-toolkit";
3
+ import { hitl } from "./hitl";
4
+
5
+ describe("use-generative markers", () => {
6
+ it("defineToolkit throws at runtime — it must be stripped by the compiler, never called", () => {
7
+ expect(() => defineToolkit({})).toThrow(/no runtime implementation/);
8
+ });
9
+
10
+ it("hitl throws at runtime — it must be stripped by the compiler, never called", () => {
11
+ expect(() => hitl()).toThrow(/no runtime implementation/);
12
+ });
13
+ });
@@ -0,0 +1,23 @@
1
+ import type { Toolkit, ToolkitDeclaration } from "./toolbox";
2
+
3
+ /**
4
+ * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
5
+ * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
6
+ * and types the result as the canonical {@link Toolkit}.
7
+ *
8
+ * It has **no runtime implementation**. A `"use generative"` compiler (e.g.
9
+ * `@assistant-ui/next` or `@assistant-ui/vite`) strips the `defineToolkit(...)`
10
+ * wrapper (and its import) per build, so a correctly compiled
11
+ * `export default defineToolkit({...})` never calls this. If it *does* run, the
12
+ * module was not compiled by a use-generative loader — e.g. `defineToolkit` used
13
+ * outside a `"use generative"` file — which would ship a backend `execute` to the
14
+ * client. So it throws instead of silently leaking.
15
+ */
16
+ export function defineToolkit(_declaration: ToolkitDeclaration): Toolkit {
17
+ throw new Error(
18
+ "[assistant-ui] defineToolkit() has no runtime implementation — it is " +
19
+ "stripped at build time by the use-generative compiler. Reaching it means " +
20
+ 'this module was not compiled (e.g. defineToolkit used outside a "use ' +
21
+ 'generative" file). Add the directive, or do not use defineToolkit here.',
22
+ );
23
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
3
+ * supplies the result instead of code. Use it as the tool's `execute`:
4
+ *
5
+ * ```tsx
6
+ * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }
7
+ * ```
8
+ *
9
+ * Like {@link defineToolkit}, it has **no runtime implementation**: a
10
+ * `"use generative"` compiler (e.g. `@assistant-ui/next` or `@assistant-ui/vite`)
11
+ * detects `execute: hitl()`, drops it, and stamps the tool `type: "human"`.
12
+ * Reaching it at runtime means the module wasn't compiled (used outside a
13
+ * `"use generative"` file), so it throws.
14
+ */
15
+ export function hitl(): never {
16
+ throw new Error(
17
+ "[assistant-ui] hitl() has no runtime implementation — it marks a " +
18
+ "human-in-the-loop tool and is stripped at build time by the " +
19
+ "use-generative compiler. Reaching it means this module was not compiled " +
20
+ '(e.g. hitl() used outside a "use generative" file).',
21
+ );
22
+ }