@agentick/core 0.0.1
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/LICENSE +21 -0
- package/README.md +875 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/.tsbuildinfo.build +1 -0
- package/dist/agent.d.ts +32 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +26 -0
- package/dist/agent.js.map +1 -0
- package/dist/agentick-instance.d.ts +285 -0
- package/dist/agentick-instance.d.ts.map +1 -0
- package/dist/agentick-instance.js +700 -0
- package/dist/agentick-instance.js.map +1 -0
- package/dist/aidk-instance.d.ts +294 -0
- package/dist/aidk-instance.d.ts.map +1 -0
- package/dist/aidk-instance.js +340 -0
- package/dist/aidk-instance.js.map +1 -0
- package/dist/app/session-store.d.ts +57 -0
- package/dist/app/session-store.d.ts.map +1 -0
- package/dist/app/session-store.js +87 -0
- package/dist/app/session-store.js.map +1 -0
- package/dist/app/session.d.ts +209 -0
- package/dist/app/session.d.ts.map +1 -0
- package/dist/app/session.js +2131 -0
- package/dist/app/session.js.map +1 -0
- package/dist/app/sqlite-session-store.d.ts +60 -0
- package/dist/app/sqlite-session-store.d.ts.map +1 -0
- package/dist/app/sqlite-session-store.js +234 -0
- package/dist/app/sqlite-session-store.js.map +1 -0
- package/dist/app/types.d.ts +1461 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/app/types.js +14 -0
- package/dist/app/types.js.map +1 -0
- package/dist/app.d.ts +79 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +83 -0
- package/dist/app.js.map +1 -0
- package/dist/channels/adapters/index.d.ts +2 -0
- package/dist/channels/adapters/index.d.ts.map +1 -0
- package/dist/channels/adapters/index.js +2 -0
- package/dist/channels/adapters/index.js.map +1 -0
- package/dist/channels/adapters/redis.d.ts +77 -0
- package/dist/channels/adapters/redis.d.ts.map +1 -0
- package/dist/channels/adapters/redis.js +259 -0
- package/dist/channels/adapters/redis.js.map +1 -0
- package/dist/channels/index.d.ts +38 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +38 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/service.d.ts +684 -0
- package/dist/channels/service.d.ts.map +1 -0
- package/dist/channels/service.js +870 -0
- package/dist/channels/service.js.map +1 -0
- package/dist/channels/transports/index.d.ts +4 -0
- package/dist/channels/transports/index.d.ts.map +1 -0
- package/dist/channels/transports/index.js +4 -0
- package/dist/channels/transports/index.js.map +1 -0
- package/dist/channels/transports/socketio.d.ts +98 -0
- package/dist/channels/transports/socketio.d.ts.map +1 -0
- package/dist/channels/transports/socketio.js +246 -0
- package/dist/channels/transports/socketio.js.map +1 -0
- package/dist/channels/transports/streamable-http.d.ts +107 -0
- package/dist/channels/transports/streamable-http.d.ts.map +1 -0
- package/dist/channels/transports/streamable-http.js +353 -0
- package/dist/channels/transports/streamable-http.js.map +1 -0
- package/dist/channels/transports/websocket.d.ts +117 -0
- package/dist/channels/transports/websocket.d.ts.map +1 -0
- package/dist/channels/transports/websocket.js +416 -0
- package/dist/channels/transports/websocket.js.map +1 -0
- package/dist/com/index.d.ts +29 -0
- package/dist/com/index.d.ts.map +1 -0
- package/dist/com/index.js +29 -0
- package/dist/com/index.js.map +1 -0
- package/dist/com/object-model.d.ts +634 -0
- package/dist/com/object-model.d.ts.map +1 -0
- package/dist/com/object-model.js +963 -0
- package/dist/com/object-model.js.map +1 -0
- package/dist/com/types.d.ts +192 -0
- package/dist/com/types.d.ts.map +1 -0
- package/dist/com/types.js +1 -0
- package/dist/com/types.js.map +1 -0
- package/dist/compiler/collector.d.ts +16 -0
- package/dist/compiler/collector.d.ts.map +1 -0
- package/dist/compiler/collector.js +388 -0
- package/dist/compiler/collector.js.map +1 -0
- package/dist/compiler/content-block-registry.d.ts +11 -0
- package/dist/compiler/content-block-registry.d.ts.map +1 -0
- package/dist/compiler/content-block-registry.js +312 -0
- package/dist/compiler/content-block-registry.js.map +1 -0
- package/dist/compiler/extractors.d.ts +68 -0
- package/dist/compiler/extractors.d.ts.map +1 -0
- package/dist/compiler/extractors.js +547 -0
- package/dist/compiler/extractors.js.map +1 -0
- package/dist/compiler/fiber-compiler.d.ts +203 -0
- package/dist/compiler/fiber-compiler.d.ts.map +1 -0
- package/dist/compiler/fiber-compiler.js +498 -0
- package/dist/compiler/fiber-compiler.js.map +1 -0
- package/dist/compiler/fiber.d.ts +61 -0
- package/dist/compiler/fiber.d.ts.map +1 -0
- package/dist/compiler/fiber.js +244 -0
- package/dist/compiler/fiber.js.map +1 -0
- package/dist/compiler/index.d.ts +18 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +38 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/scheduler.d.ts +95 -0
- package/dist/compiler/scheduler.d.ts.map +1 -0
- package/dist/compiler/scheduler.js +138 -0
- package/dist/compiler/scheduler.js.map +1 -0
- package/dist/compiler/structure-renderer.d.ts +42 -0
- package/dist/compiler/structure-renderer.d.ts.map +1 -0
- package/dist/compiler/structure-renderer.js +189 -0
- package/dist/compiler/structure-renderer.js.map +1 -0
- package/dist/compiler/types.d.ts +96 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/compiler/types.js +19 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/component/component-hooks.d.ts +68 -0
- package/dist/component/component-hooks.d.ts.map +1 -0
- package/dist/component/component-hooks.js +112 -0
- package/dist/component/component-hooks.js.map +1 -0
- package/dist/component/component.d.ts +314 -0
- package/dist/component/component.d.ts.map +1 -0
- package/dist/component/component.js +64 -0
- package/dist/component/component.js.map +1 -0
- package/dist/component/index.d.ts +47 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +47 -0
- package/dist/component/index.js.map +1 -0
- package/dist/component/tentickle-component.d.ts +185 -0
- package/dist/component/tentickle-component.d.ts.map +1 -0
- package/dist/component/tentickle-component.js +182 -0
- package/dist/component/tentickle-component.js.map +1 -0
- package/dist/content/index.d.ts +12 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +17 -0
- package/dist/content/index.js.map +1 -0
- package/dist/context/index.d.ts +51 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +69 -0
- package/dist/context/index.js.map +1 -0
- package/dist/core/channel-helpers.d.ts +31 -0
- package/dist/core/channel-helpers.d.ts.map +1 -0
- package/dist/core/channel-helpers.js +62 -0
- package/dist/core/channel-helpers.js.map +1 -0
- package/dist/core/channel.d.ts +164 -0
- package/dist/core/channel.d.ts.map +1 -0
- package/dist/core/channel.js +199 -0
- package/dist/core/channel.js.map +1 -0
- package/dist/core/context.d.ts +412 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +290 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/event-buffer.d.ts +212 -0
- package/dist/core/event-buffer.d.ts.map +1 -0
- package/dist/core/event-buffer.js +346 -0
- package/dist/core/event-buffer.js.map +1 -0
- package/dist/core/execution-helpers.d.ts +179 -0
- package/dist/core/execution-helpers.d.ts.map +1 -0
- package/dist/core/execution-helpers.js +212 -0
- package/dist/core/execution-helpers.js.map +1 -0
- package/dist/core/execution-tracker.d.ts +53 -0
- package/dist/core/execution-tracker.d.ts.map +1 -0
- package/dist/core/execution-tracker.js +309 -0
- package/dist/core/execution-tracker.js.map +1 -0
- package/dist/core/index.d.ts +58 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +58 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +341 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +346 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/metrics-helpers.d.ts +40 -0
- package/dist/core/metrics-helpers.d.ts.map +1 -0
- package/dist/core/metrics-helpers.js +72 -0
- package/dist/core/metrics-helpers.js.map +1 -0
- package/dist/core/otel-provider.d.ts +54 -0
- package/dist/core/otel-provider.d.ts.map +1 -0
- package/dist/core/otel-provider.js +107 -0
- package/dist/core/otel-provider.js.map +1 -0
- package/dist/core/procedure-graph.d.ts +136 -0
- package/dist/core/procedure-graph.d.ts.map +1 -0
- package/dist/core/procedure-graph.js +272 -0
- package/dist/core/procedure-graph.js.map +1 -0
- package/dist/core/procedure.d.ts +755 -0
- package/dist/core/procedure.d.ts.map +1 -0
- package/dist/core/procedure.js +899 -0
- package/dist/core/procedure.js.map +1 -0
- package/dist/core/stream.d.ts +106 -0
- package/dist/core/stream.d.ts.map +1 -0
- package/dist/core/stream.js +186 -0
- package/dist/core/stream.js.map +1 -0
- package/dist/core/telemetry.d.ts +182 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +124 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/engine/client-tool-coordinator.d.ts +50 -0
- package/dist/engine/client-tool-coordinator.d.ts.map +1 -0
- package/dist/engine/client-tool-coordinator.js +121 -0
- package/dist/engine/client-tool-coordinator.js.map +1 -0
- package/dist/engine/engine-events.d.ts +117 -0
- package/dist/engine/engine-events.d.ts.map +1 -0
- package/dist/engine/engine-events.js +178 -0
- package/dist/engine/engine-events.js.map +1 -0
- package/dist/engine/engine-response.d.ts +48 -0
- package/dist/engine/engine-response.d.ts.map +1 -0
- package/dist/engine/engine-response.js +2 -0
- package/dist/engine/engine-response.js.map +1 -0
- package/dist/engine/execution-graph.d.ts +104 -0
- package/dist/engine/execution-graph.d.ts.map +1 -0
- package/dist/engine/execution-graph.js +257 -0
- package/dist/engine/execution-graph.js.map +1 -0
- package/dist/engine/execution-handle.d.ts +212 -0
- package/dist/engine/execution-handle.d.ts.map +1 -0
- package/dist/engine/execution-handle.js +602 -0
- package/dist/engine/execution-handle.js.map +1 -0
- package/dist/engine/execution-types.d.ts +248 -0
- package/dist/engine/execution-types.d.ts.map +1 -0
- package/dist/engine/execution-types.js +23 -0
- package/dist/engine/execution-types.js.map +1 -0
- package/dist/engine/index.d.ts +21 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +23 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/tool-confirmation-coordinator.d.ts +74 -0
- package/dist/engine/tool-confirmation-coordinator.d.ts.map +1 -0
- package/dist/engine/tool-confirmation-coordinator.js +137 -0
- package/dist/engine/tool-confirmation-coordinator.js.map +1 -0
- package/dist/engine/tool-executor.d.ts +127 -0
- package/dist/engine/tool-executor.d.ts.map +1 -0
- package/dist/engine/tool-executor.js +363 -0
- package/dist/engine/tool-executor.js.map +1 -0
- package/dist/hibernation/index.d.ts +126 -0
- package/dist/hibernation/index.d.ts.map +1 -0
- package/dist/hibernation/index.js +127 -0
- package/dist/hibernation/index.js.map +1 -0
- package/dist/hooks/base-hook-registry.d.ts +41 -0
- package/dist/hooks/base-hook-registry.d.ts.map +1 -0
- package/dist/hooks/base-hook-registry.js +76 -0
- package/dist/hooks/base-hook-registry.js.map +1 -0
- package/dist/hooks/com-state.d.ts +40 -0
- package/dist/hooks/com-state.d.ts.map +1 -0
- package/dist/hooks/com-state.js +90 -0
- package/dist/hooks/com-state.js.map +1 -0
- package/dist/hooks/context-info.d.ts +139 -0
- package/dist/hooks/context-info.d.ts.map +1 -0
- package/dist/hooks/context-info.js +115 -0
- package/dist/hooks/context-info.js.map +1 -0
- package/dist/hooks/context-internal.d.ts +21 -0
- package/dist/hooks/context-internal.d.ts.map +1 -0
- package/dist/hooks/context-internal.js +20 -0
- package/dist/hooks/context-internal.js.map +1 -0
- package/dist/hooks/context.d.ts +64 -0
- package/dist/hooks/context.d.ts.map +1 -0
- package/dist/hooks/context.js +83 -0
- package/dist/hooks/context.js.map +1 -0
- package/dist/hooks/data.d.ts +33 -0
- package/dist/hooks/data.d.ts.map +1 -0
- package/dist/hooks/data.js +84 -0
- package/dist/hooks/data.js.map +1 -0
- package/dist/hooks/formatter-context.d.ts +34 -0
- package/dist/hooks/formatter-context.d.ts.map +1 -0
- package/dist/hooks/formatter-context.js +34 -0
- package/dist/hooks/formatter-context.js.map +1 -0
- package/dist/hooks/hook-registry.d.ts +45 -0
- package/dist/hooks/hook-registry.d.ts.map +1 -0
- package/dist/hooks/hook-registry.js +109 -0
- package/dist/hooks/hook-registry.js.map +1 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +47 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/knob.d.ts +87 -0
- package/dist/hooks/knob.d.ts.map +1 -0
- package/dist/hooks/knob.js +129 -0
- package/dist/hooks/knob.js.map +1 -0
- package/dist/hooks/knobs-component.d.ts +70 -0
- package/dist/hooks/knobs-component.d.ts.map +1 -0
- package/dist/hooks/knobs-component.js +300 -0
- package/dist/hooks/knobs-component.js.map +1 -0
- package/dist/hooks/lifecycle.d.ts +158 -0
- package/dist/hooks/lifecycle.d.ts.map +1 -0
- package/dist/hooks/lifecycle.js +217 -0
- package/dist/hooks/lifecycle.js.map +1 -0
- package/dist/hooks/message-context.d.ts +101 -0
- package/dist/hooks/message-context.d.ts.map +1 -0
- package/dist/hooks/message-context.js +145 -0
- package/dist/hooks/message-context.js.map +1 -0
- package/dist/hooks/policy-context.d.ts.map +1 -0
- package/dist/hooks/runtime-context.d.ts +122 -0
- package/dist/hooks/runtime-context.d.ts.map +1 -0
- package/dist/hooks/runtime-context.js +149 -0
- package/dist/hooks/runtime-context.js.map +1 -0
- package/dist/hooks/signal.d.ts +267 -0
- package/dist/hooks/signal.d.ts.map +1 -0
- package/dist/hooks/signal.js +825 -0
- package/dist/hooks/signal.js.map +1 -0
- package/dist/hooks/types.d.ts +179 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +5 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx/components/agent.d.ts +64 -0
- package/dist/jsx/components/agent.d.ts.map +1 -0
- package/dist/jsx/components/agent.js +80 -0
- package/dist/jsx/components/agent.js.map +1 -0
- package/dist/jsx/components/complete.d.ts +65 -0
- package/dist/jsx/components/complete.d.ts.map +1 -0
- package/dist/jsx/components/complete.js +64 -0
- package/dist/jsx/components/complete.js.map +1 -0
- package/dist/jsx/components/content.d.ts +98 -0
- package/dist/jsx/components/content.d.ts.map +1 -0
- package/dist/jsx/components/content.js +51 -0
- package/dist/jsx/components/content.js.map +1 -0
- package/dist/jsx/components/harness.d.ts +118 -0
- package/dist/jsx/components/harness.d.ts.map +1 -0
- package/dist/jsx/components/harness.js +117 -0
- package/dist/jsx/components/harness.js.map +1 -0
- package/dist/jsx/components/index.d.ts +11 -0
- package/dist/jsx/components/index.d.ts.map +1 -0
- package/dist/jsx/components/index.js +11 -0
- package/dist/jsx/components/index.js.map +1 -0
- package/dist/jsx/components/markdown.d.ts +31 -0
- package/dist/jsx/components/markdown.d.ts.map +1 -0
- package/dist/jsx/components/markdown.js +17 -0
- package/dist/jsx/components/markdown.js.map +1 -0
- package/dist/jsx/components/messages.d.ts +283 -0
- package/dist/jsx/components/messages.d.ts.map +1 -0
- package/dist/jsx/components/messages.js +257 -0
- package/dist/jsx/components/messages.js.map +1 -0
- package/dist/jsx/components/model.d.ts +94 -0
- package/dist/jsx/components/model.d.ts.map +1 -0
- package/dist/jsx/components/model.js +96 -0
- package/dist/jsx/components/model.js.map +1 -0
- package/dist/jsx/components/primitives.d.ts +117 -0
- package/dist/jsx/components/primitives.d.ts.map +1 -0
- package/dist/jsx/components/primitives.js +83 -0
- package/dist/jsx/components/primitives.js.map +1 -0
- package/dist/jsx/components/renderer.d.ts +24 -0
- package/dist/jsx/components/renderer.d.ts.map +1 -0
- package/dist/jsx/components/renderer.js +11 -0
- package/dist/jsx/components/renderer.js.map +1 -0
- package/dist/jsx/components/semantic.d.ts +155 -0
- package/dist/jsx/components/semantic.d.ts.map +1 -0
- package/dist/jsx/components/semantic.js +39 -0
- package/dist/jsx/components/semantic.js.map +1 -0
- package/dist/jsx/components/timeline.d.ts +157 -0
- package/dist/jsx/components/timeline.d.ts.map +1 -0
- package/dist/jsx/components/timeline.js +357 -0
- package/dist/jsx/components/timeline.js.map +1 -0
- package/dist/jsx/components/token-budget.d.ts +70 -0
- package/dist/jsx/components/token-budget.d.ts.map +1 -0
- package/dist/jsx/components/token-budget.js +135 -0
- package/dist/jsx/components/token-budget.js.map +1 -0
- package/dist/jsx/components/xml.d.ts +27 -0
- package/dist/jsx/components/xml.d.ts.map +1 -0
- package/dist/jsx/components/xml.js +17 -0
- package/dist/jsx/components/xml.js.map +1 -0
- package/dist/jsx/index.d.ts +58 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +59 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +370 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.js +79 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/jsx-types.d.ts +23 -0
- package/dist/jsx/jsx-types.d.ts.map +1 -0
- package/dist/jsx/jsx-types.js +1 -0
- package/dist/jsx/jsx-types.js.map +1 -0
- package/dist/mcp/client.d.ts +46 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +138 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/component.d.ts +95 -0
- package/dist/mcp/component.d.ts.map +1 -0
- package/dist/mcp/component.js +185 -0
- package/dist/mcp/component.js.map +1 -0
- package/dist/mcp/create-mcp-tool.d.ts +191 -0
- package/dist/mcp/create-mcp-tool.d.ts.map +1 -0
- package/dist/mcp/create-mcp-tool.js +228 -0
- package/dist/mcp/create-mcp-tool.js.map +1 -0
- package/dist/mcp/index.d.ts +49 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +48 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/service.d.ts +39 -0
- package/dist/mcp/service.d.ts.map +1 -0
- package/dist/mcp/service.js +77 -0
- package/dist/mcp/service.js.map +1 -0
- package/dist/mcp/tool.d.ts +55 -0
- package/dist/mcp/tool.d.ts.map +1 -0
- package/dist/mcp/tool.js +119 -0
- package/dist/mcp/tool.js.map +1 -0
- package/dist/mcp/types.d.ts +72 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +6 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/middleware/defaults.d.ts +9 -0
- package/dist/middleware/defaults.d.ts.map +1 -0
- package/dist/middleware/defaults.js +47 -0
- package/dist/middleware/defaults.js.map +1 -0
- package/dist/model/adapter-helpers.d.ts +161 -0
- package/dist/model/adapter-helpers.d.ts.map +1 -0
- package/dist/model/adapter-helpers.js +351 -0
- package/dist/model/adapter-helpers.js.map +1 -0
- package/dist/model/adapter.d.ts +399 -0
- package/dist/model/adapter.d.ts.map +1 -0
- package/dist/model/adapter.js +497 -0
- package/dist/model/adapter.js.map +1 -0
- package/dist/model/index.d.ts +54 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +55 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/model-hooks.d.ts +45 -0
- package/dist/model/model-hooks.d.ts.map +1 -0
- package/dist/model/model-hooks.js +24 -0
- package/dist/model/model-hooks.js.map +1 -0
- package/dist/model/model.d.ts +302 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +20 -0
- package/dist/model/model.js.map +1 -0
- package/dist/model/simple-adapter.d.ts +176 -0
- package/dist/model/simple-adapter.d.ts.map +1 -0
- package/dist/model/simple-adapter.js +264 -0
- package/dist/model/simple-adapter.js.map +1 -0
- package/dist/model/stream-accumulator.d.ts +284 -0
- package/dist/model/stream-accumulator.d.ts.map +1 -0
- package/dist/model/stream-accumulator.js +532 -0
- package/dist/model/stream-accumulator.js.map +1 -0
- package/dist/model/utils/index.d.ts +2 -0
- package/dist/model/utils/index.d.ts.map +1 -0
- package/dist/model/utils/index.js +2 -0
- package/dist/model/utils/index.js.map +1 -0
- package/dist/model/utils/language-model.d.ts +26 -0
- package/dist/model/utils/language-model.d.ts.map +1 -0
- package/dist/model/utils/language-model.js +706 -0
- package/dist/model/utils/language-model.js.map +1 -0
- package/dist/procedure/index.d.ts +20 -0
- package/dist/procedure/index.d.ts.map +1 -0
- package/dist/procedure/index.js +19 -0
- package/dist/procedure/index.js.map +1 -0
- package/dist/reconciler/devtools-bridge.d.ts +40 -0
- package/dist/reconciler/devtools-bridge.d.ts.map +1 -0
- package/dist/reconciler/devtools-bridge.js +79 -0
- package/dist/reconciler/devtools-bridge.js.map +1 -0
- package/dist/reconciler/host-config.d.ts +39 -0
- package/dist/reconciler/host-config.d.ts.map +1 -0
- package/dist/reconciler/host-config.js +195 -0
- package/dist/reconciler/host-config.js.map +1 -0
- package/dist/reconciler/index.d.ts +7 -0
- package/dist/reconciler/index.d.ts.map +1 -0
- package/dist/reconciler/index.js +7 -0
- package/dist/reconciler/index.js.map +1 -0
- package/dist/reconciler/reconciler.d.ts +47 -0
- package/dist/reconciler/reconciler.d.ts.map +1 -0
- package/dist/reconciler/reconciler.js +89 -0
- package/dist/reconciler/reconciler.js.map +1 -0
- package/dist/reconciler/types.d.ts +86 -0
- package/dist/reconciler/types.d.ts.map +1 -0
- package/dist/reconciler/types.js +37 -0
- package/dist/reconciler/types.js.map +1 -0
- package/dist/renderers/base.d.ts +98 -0
- package/dist/renderers/base.d.ts.map +1 -0
- package/dist/renderers/base.js +82 -0
- package/dist/renderers/base.js.map +1 -0
- package/dist/renderers/index.d.ts +31 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/index.js +31 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/markdown.d.ts +48 -0
- package/dist/renderers/markdown.d.ts.map +1 -0
- package/dist/renderers/markdown.js +432 -0
- package/dist/renderers/markdown.js.map +1 -0
- package/dist/renderers/types.d.ts +7 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/renderers/types.js +7 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/renderers/xml.d.ts +49 -0
- package/dist/renderers/xml.d.ts.map +1 -0
- package/dist/renderers/xml.js +444 -0
- package/dist/renderers/xml.js.map +1 -0
- package/dist/state/boundary.d.ts +347 -0
- package/dist/state/boundary.d.ts.map +1 -0
- package/dist/state/boundary.js +341 -0
- package/dist/state/boundary.js.map +1 -0
- package/dist/state/context.d.ts +138 -0
- package/dist/state/context.d.ts.map +1 -0
- package/dist/state/context.js +139 -0
- package/dist/state/context.js.map +1 -0
- package/dist/state/hooks.d.ts +798 -0
- package/dist/state/hooks.d.ts.map +1 -0
- package/dist/state/hooks.js +1437 -0
- package/dist/state/hooks.js.map +1 -0
- package/dist/state/index.d.ts +72 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +73 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/signal.d.ts +223 -0
- package/dist/state/signal.d.ts.map +1 -0
- package/dist/state/signal.js +699 -0
- package/dist/state/signal.js.map +1 -0
- package/dist/state/use-state.d.ts +210 -0
- package/dist/state/use-state.d.ts.map +1 -0
- package/dist/state/use-state.js +327 -0
- package/dist/state/use-state.js.map +1 -0
- package/dist/tentickle-instance.d.ts +285 -0
- package/dist/tentickle-instance.d.ts.map +1 -0
- package/dist/tentickle-instance.js +700 -0
- package/dist/tentickle-instance.js.map +1 -0
- package/dist/testing/act.d.ts +59 -0
- package/dist/testing/act.d.ts.map +1 -0
- package/dist/testing/act.js +92 -0
- package/dist/testing/act.js.map +1 -0
- package/dist/testing/async-helpers.d.ts +99 -0
- package/dist/testing/async-helpers.d.ts.map +1 -0
- package/dist/testing/async-helpers.js +193 -0
- package/dist/testing/async-helpers.js.map +1 -0
- package/dist/testing/compile-agent.d.ts +101 -0
- package/dist/testing/compile-agent.d.ts.map +1 -0
- package/dist/testing/compile-agent.js +136 -0
- package/dist/testing/compile-agent.js.map +1 -0
- package/dist/testing/index.d.ts +57 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +59 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-app.d.ts +163 -0
- package/dist/testing/mock-app.d.ts.map +1 -0
- package/dist/testing/mock-app.js +393 -0
- package/dist/testing/mock-app.js.map +1 -0
- package/dist/testing/mocks.d.ts +142 -0
- package/dist/testing/mocks.d.ts.map +1 -0
- package/dist/testing/mocks.js +191 -0
- package/dist/testing/mocks.js.map +1 -0
- package/dist/testing/render-agent.d.ts +146 -0
- package/dist/testing/render-agent.d.ts.map +1 -0
- package/dist/testing/render-agent.js +200 -0
- package/dist/testing/render-agent.js.map +1 -0
- package/dist/testing/test-adapter.d.ts +157 -0
- package/dist/testing/test-adapter.d.ts.map +1 -0
- package/dist/testing/test-adapter.js +297 -0
- package/dist/testing/test-adapter.js.map +1 -0
- package/dist/testing/test-model.d.ts +132 -0
- package/dist/testing/test-model.d.ts.map +1 -0
- package/dist/testing/test-model.js +260 -0
- package/dist/testing/test-model.js.map +1 -0
- package/dist/tool/index.d.ts +61 -0
- package/dist/tool/index.d.ts.map +1 -0
- package/dist/tool/index.js +63 -0
- package/dist/tool/index.js.map +1 -0
- package/dist/tool/tool-hooks.d.ts +45 -0
- package/dist/tool/tool-hooks.d.ts.map +1 -0
- package/dist/tool/tool-hooks.js +35 -0
- package/dist/tool/tool-hooks.js.map +1 -0
- package/dist/tool/tool.d.ts +403 -0
- package/dist/tool/tool.d.ts.map +1 -0
- package/dist/tool/tool.js +176 -0
- package/dist/tool/tool.js.map +1 -0
- package/dist/types.d.ts +442 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +97 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/abort-utils.d.ts +5 -0
- package/dist/utils/abort-utils.d.ts.map +1 -0
- package/dist/utils/abort-utils.js +50 -0
- package/dist/utils/abort-utils.js.map +1 -0
- package/dist/utils/classify-error.d.ts +19 -0
- package/dist/utils/classify-error.d.ts.map +1 -0
- package/dist/utils/classify-error.js +77 -0
- package/dist/utils/classify-error.js.map +1 -0
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/normalization.d.ts +6 -0
- package/dist/utils/normalization.d.ts.map +1 -0
- package/dist/utils/normalization.js +103 -0
- package/dist/utils/normalization.js.map +1 -0
- package/dist/utils/registry.d.ts +15 -0
- package/dist/utils/registry.d.ts.map +1 -0
- package/dist/utils/registry.js +28 -0
- package/dist/utils/registry.js.map +1 -0
- package/dist/utils/schema.d.ts +7 -0
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +13 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/token-estimate.d.ts +87 -0
- package/dist/utils/token-estimate.d.ts.map +1 -0
- package/dist/utils/token-estimate.js +199 -0
- package/dist/utils/token-estimate.js.map +1 -0
- package/dist/v2/reconciler/host-config.d.ts +31 -0
- package/dist/v2/reconciler/host-config.d.ts.map +1 -0
- package/dist/v2/reconciler/host-config.js +197 -0
- package/dist/v2/reconciler/host-config.js.map +1 -0
- package/dist/v2/reconciler/index.d.ts +7 -0
- package/dist/v2/reconciler/index.d.ts.map +1 -0
- package/dist/v2/reconciler/index.js +7 -0
- package/dist/v2/reconciler/index.js.map +1 -0
- package/dist/v2/reconciler/reconciler.d.ts +39 -0
- package/dist/v2/reconciler/reconciler.d.ts.map +1 -0
- package/dist/v2/reconciler/reconciler.js +54 -0
- package/dist/v2/reconciler/reconciler.js.map +1 -0
- package/dist/v2/reconciler/types.d.ts +64 -0
- package/dist/v2/reconciler/types.d.ts.map +1 -0
- package/dist/v2/reconciler/types.js +20 -0
- package/dist/v2/reconciler/types.js.map +1 -0
- package/dist/v2/renderers/index.d.ts +7 -0
- package/dist/v2/renderers/index.d.ts.map +1 -0
- package/dist/v2/renderers/index.js +7 -0
- package/dist/v2/renderers/index.js.map +1 -0
- package/dist/v2/renderers/markdown.d.ts +16 -0
- package/dist/v2/renderers/markdown.d.ts.map +1 -0
- package/dist/v2/renderers/markdown.js +65 -0
- package/dist/v2/renderers/markdown.js.map +1 -0
- package/dist/v2/renderers/types.d.ts +26 -0
- package/dist/v2/renderers/types.d.ts.map +1 -0
- package/dist/v2/renderers/types.js +6 -0
- package/dist/v2/renderers/types.js.map +1 -0
- package/dist/v2/renderers/xml.d.ts +17 -0
- package/dist/v2/renderers/xml.d.ts.map +1 -0
- package/dist/v2/renderers/xml.js +73 -0
- package/dist/v2/renderers/xml.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2 Hooks Implementation
|
|
3
|
+
*
|
|
4
|
+
* React-inspired hooks for function components in the tick-based agent model.
|
|
5
|
+
* Key difference from React: async-first, effects can be async.
|
|
6
|
+
*
|
|
7
|
+
* Rules of Hooks:
|
|
8
|
+
* 1. Only call hooks at the top level of a function component
|
|
9
|
+
* 2. Only call hooks from function components or custom hooks
|
|
10
|
+
* 3. Call hooks in the same order every render
|
|
11
|
+
*/
|
|
12
|
+
import type { FiberNode, RenderContext, StateHookResult, ReducerHookResult, RefObject, AsyncResult, EffectCallback } from "../compiler/types";
|
|
13
|
+
import { type Signal, type ComputedSignal, type ReadonlySignal } from "./signal";
|
|
14
|
+
import type { COM } from "../com/object-model";
|
|
15
|
+
import type { COMTimelineEntry } from "../com/types";
|
|
16
|
+
import type { TickState } from "../component/component";
|
|
17
|
+
import type { CompiledStructure } from "../compiler/types";
|
|
18
|
+
import type { ExecutionMessage } from "../engine/execution-types";
|
|
19
|
+
/**
|
|
20
|
+
* Get current render context. Throws if called outside render.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCurrentContext(): RenderContext;
|
|
23
|
+
/**
|
|
24
|
+
* Set render context (called by compiler).
|
|
25
|
+
*/
|
|
26
|
+
export declare function setRenderContext(ctx: RenderContext | null): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get current fiber (for advanced use).
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCurrentFiber(): FiberNode | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get the COM (Context Object Model) for the current render.
|
|
33
|
+
*
|
|
34
|
+
* Use this instead of receiving COM as a component parameter.
|
|
35
|
+
* This makes components have standard React-like signatures: `(props) => JSX.Element`
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Before (legacy pattern with magic args):
|
|
40
|
+
* const MyComponent = (props, com, state) => { ... };
|
|
41
|
+
*
|
|
42
|
+
* // After (recommended hook pattern):
|
|
43
|
+
* const MyComponent = (props) => {
|
|
44
|
+
* const com = useCom();
|
|
45
|
+
* const state = useTickState();
|
|
46
|
+
* // ...
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useCom(): COM;
|
|
51
|
+
/**
|
|
52
|
+
* Get the TickState for the current render.
|
|
53
|
+
*
|
|
54
|
+
* TickState contains:
|
|
55
|
+
* - `tick`: Current tick number (1-indexed)
|
|
56
|
+
* - `previous`: COMInput from previous tick (conversation history)
|
|
57
|
+
* - `current`: COMOutput from current tick (model response)
|
|
58
|
+
* - `stop(reason)`: Function to stop execution
|
|
59
|
+
* - `queuedMessages`: Messages received during execution
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* const MyComponent = (props) => {
|
|
64
|
+
* const state = useTickState();
|
|
65
|
+
* console.log(`Tick ${state.tick}`);
|
|
66
|
+
* // Access previous conversation via state.previous?.timeline
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function useTickState(): TickState;
|
|
71
|
+
/**
|
|
72
|
+
* useState - Local component state.
|
|
73
|
+
*
|
|
74
|
+
* State persists across renders via fiber storage.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // Old (deprecated):
|
|
79
|
+
* const [count, setCount] = useState(0);
|
|
80
|
+
*
|
|
81
|
+
* // New (recommended):
|
|
82
|
+
* const count = useSignal(0);
|
|
83
|
+
* count.set(10) or count.update(n => n + 1)
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function useState<S>(initialState: S | (() => S)): StateHookResult<S>;
|
|
87
|
+
/**
|
|
88
|
+
* useReducer - State with reducer pattern.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialArg: S, init?: (arg: S) => S): ReducerHookResult<S, A>;
|
|
91
|
+
/**
|
|
92
|
+
* useSignal - Signal-based state in function components.
|
|
93
|
+
*
|
|
94
|
+
* Provides full signal API (not just [value, setter]).
|
|
95
|
+
* Automatically triggers recompiles when the signal is updated (like useState).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* function Counter() {
|
|
100
|
+
* const count = useSignal(0);
|
|
101
|
+
* return <Text>Count: {count()}</Text>;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function useSignal<T>(initialValue: T): Signal<T>;
|
|
106
|
+
/**
|
|
107
|
+
* useComState - COM-bound shared state.
|
|
108
|
+
*
|
|
109
|
+
* Returns a signal bound to COM state. State is shared across all components
|
|
110
|
+
* and persisted. Changes automatically trigger recompilation.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* function Timeline() {
|
|
115
|
+
* const messages = useComState('timeline', []);
|
|
116
|
+
* return <Timeline>{messages().map(...)}</Timeline>;
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function useComState<T>(key: string, initialValue: T): Signal<T>;
|
|
121
|
+
/**
|
|
122
|
+
* useWatch - Read-only COM state observation.
|
|
123
|
+
* Returns a ReadonlySignal for reactive access to the watched state.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* function StatusDisplay() {
|
|
128
|
+
* const status = useWatch('agentStatus', 'idle');
|
|
129
|
+
* return <Text>Status: {status()}</Text>;
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function useWatch<T>(key: string, defaultValue?: T): ReadonlySignal<T | undefined>;
|
|
134
|
+
/**
|
|
135
|
+
* useInput - Reactive prop access with default value.
|
|
136
|
+
*/
|
|
137
|
+
export declare function useInput<T>(propKey: string, defaultValue?: T): T | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* useEffect - Side effect after commit.
|
|
140
|
+
*
|
|
141
|
+
* Unlike React, callback CAN be async.
|
|
142
|
+
* Signals/computed values in deps array are automatically unwrapped.
|
|
143
|
+
*
|
|
144
|
+
* During hydration:
|
|
145
|
+
* - Mount effects (deps = []) are skipped (state is restored, not fresh)
|
|
146
|
+
* - Effects with deps still run (deps might have changed since snapshot)
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* function Logger() {
|
|
151
|
+
* const message = useComState('message', '');
|
|
152
|
+
*
|
|
153
|
+
* useEffect(async () => {
|
|
154
|
+
* await logToServer(message()); // Read signal value
|
|
155
|
+
* return () => console.log('cleanup');
|
|
156
|
+
* }, [message]); // Signal auto-tracked by value
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function useEffect(create: EffectCallback, deps?: unknown[]): void;
|
|
161
|
+
/**
|
|
162
|
+
* useInit - Component initialization that runs once on mount.
|
|
163
|
+
* Can be async and should be awaited if it returns a Promise.
|
|
164
|
+
* Runs DURING render, blocking until complete.
|
|
165
|
+
*
|
|
166
|
+
* Use for: loading initial data, setting up state before first render
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* function MyComponent() {
|
|
171
|
+
* const data = useComState('data', []);
|
|
172
|
+
*
|
|
173
|
+
* await useInit(async (com, state) => {
|
|
174
|
+
* const initialData = await loadData();
|
|
175
|
+
* data.set(initialData);
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* return <Section>{data().map(...)}</Section>;
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function useInit(callback: (com: COM, state: TickState) => void | Promise<void>): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* useOnMount - Run once when component mounts as a side effect.
|
|
185
|
+
* Runs AFTER render (as an effect), does not block rendering.
|
|
186
|
+
* Use for non-critical side effects like logging, analytics.
|
|
187
|
+
*
|
|
188
|
+
* For blocking initialization, use `useInit` instead.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```tsx
|
|
192
|
+
* function MyComponent() {
|
|
193
|
+
* useOnMount((com) => {
|
|
194
|
+
* log.info('Component mounted');
|
|
195
|
+
* });
|
|
196
|
+
* return <Text>Hello</Text>;
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare function useOnMount(callback: (com: COM) => void | Promise<void>): void;
|
|
201
|
+
/**
|
|
202
|
+
* useOnUnmount - Run once when component unmounts.
|
|
203
|
+
*/
|
|
204
|
+
export declare function useOnUnmount(callback: (com: COM) => void | Promise<void>): void;
|
|
205
|
+
/**
|
|
206
|
+
* useTickStart - Run at start of each tick, before render.
|
|
207
|
+
*
|
|
208
|
+
* @deprecated Use `useOnTickStart` instead for consistent naming convention.
|
|
209
|
+
*/
|
|
210
|
+
export declare function useTickStart(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
211
|
+
/**
|
|
212
|
+
* useTickEnd - Run at end of each tick, after model execution.
|
|
213
|
+
*
|
|
214
|
+
* @deprecated Use `useOnTickEnd` instead for consistent naming convention.
|
|
215
|
+
*/
|
|
216
|
+
export declare function useTickEnd(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
217
|
+
/**
|
|
218
|
+
* useAfterCompile - Run after compile, can request recompile.
|
|
219
|
+
*
|
|
220
|
+
* @deprecated Use `useOnAfterCompile` instead for consistent naming convention.
|
|
221
|
+
*/
|
|
222
|
+
export declare function useAfterCompile(callback: (com: COM, compiled: CompiledStructure, state: TickState) => void): void;
|
|
223
|
+
/**
|
|
224
|
+
* useOnMessage - Handle execution messages.
|
|
225
|
+
*
|
|
226
|
+
* Called immediately when messages are sent to the running execution via:
|
|
227
|
+
* - RuntimeSession.sendMessage() - Direct programmatic injection
|
|
228
|
+
* - ExecutionHandle.send() - Via handle reference
|
|
229
|
+
* - Channel events with type='message' - From client
|
|
230
|
+
*
|
|
231
|
+
* Messages are processed immediately when they arrive, not at tick boundaries.
|
|
232
|
+
* Use com.abort() to interrupt execution if needed, or update state for the next tick.
|
|
233
|
+
* Messages are also available in TickState.queuedMessages during render.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```tsx
|
|
237
|
+
* function InteractiveAgent() {
|
|
238
|
+
* const feedback = useComState('userFeedback', []);
|
|
239
|
+
*
|
|
240
|
+
* useOnMessage((com, message, state) => {
|
|
241
|
+
* if (message.type === 'stop') {
|
|
242
|
+
* com.abort('User requested stop');
|
|
243
|
+
* } else if (message.type === 'feedback') {
|
|
244
|
+
* feedback.update(f => [...f, message.content]);
|
|
245
|
+
* }
|
|
246
|
+
* });
|
|
247
|
+
*
|
|
248
|
+
* return <Section>{feedback().map(f => <Paragraph>{f}</Paragraph>)}</Section>;
|
|
249
|
+
* }
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export declare function useOnMessage(callback: (com: COM, message: ExecutionMessage, state: TickState) => void | Promise<void>): void;
|
|
253
|
+
/**
|
|
254
|
+
* useOnTickStart - Run at start of each tick, before render.
|
|
255
|
+
*
|
|
256
|
+
* This is the canonical hook for tick-start lifecycle.
|
|
257
|
+
* Alias: useTickStart (deprecated, prefer useOnTickStart)
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* function MyAgent() {
|
|
262
|
+
* useOnTickStart((com, state) => {
|
|
263
|
+
* console.log(`Starting tick ${state.tick}`);
|
|
264
|
+
* });
|
|
265
|
+
* return <System>You are helpful.</System>;
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
export declare function useOnTickStart(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
270
|
+
/**
|
|
271
|
+
* useOnAfterRender - Run after render/reconciliation, before compile.
|
|
272
|
+
*
|
|
273
|
+
* Use this to inspect or modify state after all components have rendered
|
|
274
|
+
* but before the context is compiled and sent to the model.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* function MyAgent() {
|
|
279
|
+
* useOnAfterRender((com, state) => {
|
|
280
|
+
* console.log('Components rendered, about to compile');
|
|
281
|
+
* });
|
|
282
|
+
* return <System>You are helpful.</System>;
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export declare function useOnAfterRender(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
287
|
+
/**
|
|
288
|
+
* useOnAfterCompile - Run after compile, before model call.
|
|
289
|
+
*
|
|
290
|
+
* Use this to transform the compiled structure before it's sent to the model.
|
|
291
|
+
* Can request recompile if needed.
|
|
292
|
+
*
|
|
293
|
+
* This is the canonical hook for after-compile lifecycle.
|
|
294
|
+
* Alias: useAfterCompile (deprecated, prefer useOnAfterCompile)
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```tsx
|
|
298
|
+
* function MyAgent() {
|
|
299
|
+
* useOnAfterCompile((com, compiled, state) => {
|
|
300
|
+
* // Inspect or modify compiled structure
|
|
301
|
+
* if (compiled.tokenCount > 10000) {
|
|
302
|
+
* // Request summarization
|
|
303
|
+
* }
|
|
304
|
+
* });
|
|
305
|
+
* return <System>You are helpful.</System>;
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export declare function useOnAfterCompile(callback: (com: COM, compiled: CompiledStructure, state: TickState) => void): void;
|
|
310
|
+
/**
|
|
311
|
+
* useOnTickEnd - Run at end of each tick, after model execution.
|
|
312
|
+
*
|
|
313
|
+
* Use this to process model response, decide on continuation, or clean up.
|
|
314
|
+
*
|
|
315
|
+
* This is the canonical hook for tick-end lifecycle.
|
|
316
|
+
* Alias: useTickEnd (deprecated, prefer useOnTickEnd)
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```tsx
|
|
320
|
+
* function MyAgent() {
|
|
321
|
+
* useOnTickEnd((com, state) => {
|
|
322
|
+
* console.log(`Tick ${state.tick} complete`);
|
|
323
|
+
* if (state.response?.stopReason === 'stop') {
|
|
324
|
+
* com.complete();
|
|
325
|
+
* }
|
|
326
|
+
* });
|
|
327
|
+
* return <System>You are helpful.</System>;
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
export declare function useOnTickEnd(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
332
|
+
/**
|
|
333
|
+
* useOnComplete - Run when session completes (all ticks done).
|
|
334
|
+
*
|
|
335
|
+
* This hook runs once when the session finishes execution, whether through:
|
|
336
|
+
* - Natural completion (shouldContinue returns false)
|
|
337
|
+
* - Explicit com.complete() call
|
|
338
|
+
* - Error or abort
|
|
339
|
+
*
|
|
340
|
+
* Use this for cleanup, final logging, or teardown logic.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```tsx
|
|
344
|
+
* function MyAgent() {
|
|
345
|
+
* useOnComplete((com, state) => {
|
|
346
|
+
* console.log(`Session complete after ${state.tick} ticks`);
|
|
347
|
+
* // Cleanup resources
|
|
348
|
+
* });
|
|
349
|
+
* return <System>You are helpful.</System>;
|
|
350
|
+
* }
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
export declare function useOnComplete(callback: (com: COM, state: TickState) => void | Promise<void>): void;
|
|
354
|
+
/**
|
|
355
|
+
* useAsync - Async data fetching.
|
|
356
|
+
*
|
|
357
|
+
* Unlike React (which needs Suspense), we just track loading state.
|
|
358
|
+
* The tick can wait for async work to complete.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```tsx
|
|
362
|
+
* function UserProfile({ userId }) {
|
|
363
|
+
* const { data: user, loading, error } = useAsync(
|
|
364
|
+
* () => fetchUser(userId),
|
|
365
|
+
* [userId]
|
|
366
|
+
* );
|
|
367
|
+
*
|
|
368
|
+
* if (loading) return null;
|
|
369
|
+
* if (error) return <Text>Error: {error.message}</Text>;
|
|
370
|
+
*
|
|
371
|
+
* return <Text>User: {user.name}</Text>;
|
|
372
|
+
* }
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
export declare function useAsync<T>(asyncFn: () => Promise<T>, deps: unknown[]): AsyncResult<T>;
|
|
376
|
+
/**
|
|
377
|
+
* useMemo - Memoize expensive computation.
|
|
378
|
+
*/
|
|
379
|
+
export declare function useMemo<T>(factory: () => T, deps: unknown[]): T;
|
|
380
|
+
/**
|
|
381
|
+
* useComputed - Create a reactive computed signal that persists across renders.
|
|
382
|
+
*
|
|
383
|
+
* Unlike useMemo which returns a plain value, useComputed returns a ComputedSignal
|
|
384
|
+
* that automatically tracks dependencies and updates when they change.
|
|
385
|
+
* The computed signal is disposed and recreated only when deps change.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const timeline = useComState('timeline', []);
|
|
390
|
+
* const recentMessages = useComputed(() => timeline().slice(-10), []);
|
|
391
|
+
*
|
|
392
|
+
* // Read the computed value
|
|
393
|
+
* const messages = recentMessages(); // or recentMessages.value
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
export declare function useComputed<T>(computation: () => T, deps?: unknown[]): ComputedSignal<T>;
|
|
397
|
+
/**
|
|
398
|
+
* useCallback - Memoize callback function.
|
|
399
|
+
*/
|
|
400
|
+
export declare function useCallback<T extends (...args: unknown[]) => unknown>(callback: T, deps: unknown[]): T;
|
|
401
|
+
/**
|
|
402
|
+
* useRef - Mutable ref that persists across renders.
|
|
403
|
+
*/
|
|
404
|
+
export declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
405
|
+
/**
|
|
406
|
+
* useCOMRef - Get component ref from COM.
|
|
407
|
+
*/
|
|
408
|
+
export declare function useCOMRef<T>(refName: string): T | undefined;
|
|
409
|
+
/**
|
|
410
|
+
* usePrevious - Track previous value.
|
|
411
|
+
*/
|
|
412
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
413
|
+
/**
|
|
414
|
+
* useToggle - Boolean toggle state.
|
|
415
|
+
*/
|
|
416
|
+
export declare function useToggle(initial?: boolean): [boolean, () => void];
|
|
417
|
+
/**
|
|
418
|
+
* useCounter - Numeric counter.
|
|
419
|
+
*/
|
|
420
|
+
export declare function useCounter(initial?: number): {
|
|
421
|
+
count: number;
|
|
422
|
+
increment: () => void;
|
|
423
|
+
decrement: () => void;
|
|
424
|
+
set: (n: number) => void;
|
|
425
|
+
reset: () => void;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* useAbortSignal - Get abort signal for current execution.
|
|
429
|
+
*/
|
|
430
|
+
export declare function useAbortSignal(): AbortSignal | undefined;
|
|
431
|
+
/**
|
|
432
|
+
* useDebugValue - Display value in devtools (no-op in production).
|
|
433
|
+
*/
|
|
434
|
+
export declare function useDebugValue<T>(value: T, formatter?: (value: T) => unknown): void;
|
|
435
|
+
/**
|
|
436
|
+
* Result of useTick() hook.
|
|
437
|
+
*/
|
|
438
|
+
export interface UseTickResult {
|
|
439
|
+
/** Request a tick to be scheduled */
|
|
440
|
+
requestTick(): void;
|
|
441
|
+
/** Cancel a pending tick request */
|
|
442
|
+
cancelTick(): void;
|
|
443
|
+
/** Current tick status: 'idle' | 'running' | 'pending' */
|
|
444
|
+
tickStatus: "idle" | "running" | "pending";
|
|
445
|
+
/** Total number of ticks executed */
|
|
446
|
+
tickCount: number;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* useTick - Control tick execution from within a component.
|
|
450
|
+
*
|
|
451
|
+
* This hook provides components with the ability to:
|
|
452
|
+
* - Request a new tick (e.g., when enough messages have accumulated)
|
|
453
|
+
* - Cancel a pending tick request
|
|
454
|
+
* - Check the current tick status
|
|
455
|
+
* - Get the total tick count
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```tsx
|
|
459
|
+
* function BatchProcessor() {
|
|
460
|
+
* const { requestTick, tickStatus, tickCount } = useTick();
|
|
461
|
+
* const queue = useComState('queue', []);
|
|
462
|
+
*
|
|
463
|
+
* useEffect(() => {
|
|
464
|
+
* // Request tick when queue has 10 items and we're idle
|
|
465
|
+
* if (queue().length >= 10 && tickStatus === 'idle') {
|
|
466
|
+
* requestTick();
|
|
467
|
+
* }
|
|
468
|
+
* }, [queue().length, tickStatus]);
|
|
469
|
+
*
|
|
470
|
+
* return <Section>Tick {tickCount}: {queue().length} items</Section>;
|
|
471
|
+
* }
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
export declare function useTick(): UseTickResult;
|
|
475
|
+
import type { Channel, ChannelEvent } from "../core/channel";
|
|
476
|
+
/**
|
|
477
|
+
* Result of useChannel() hook.
|
|
478
|
+
* Provides access to a named channel for pub/sub communication.
|
|
479
|
+
*/
|
|
480
|
+
export interface UseChannelResult {
|
|
481
|
+
/**
|
|
482
|
+
* The underlying Channel instance.
|
|
483
|
+
* May be undefined if channels are not configured.
|
|
484
|
+
*/
|
|
485
|
+
channel: Channel | undefined;
|
|
486
|
+
/**
|
|
487
|
+
* Subscribe to channel events.
|
|
488
|
+
* Returns an unsubscribe function.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```tsx
|
|
492
|
+
* const { subscribe } = useChannel('updates');
|
|
493
|
+
* useEffect(() => subscribe(handleEvent), []);
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
subscribe: (handler: (event: ChannelEvent) => void) => () => void;
|
|
497
|
+
/**
|
|
498
|
+
* Publish an event to the channel.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```tsx
|
|
502
|
+
* const { publish } = useChannel('events');
|
|
503
|
+
* publish({ type: 'status', payload: { ready: true } });
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
publish: (event: Omit<ChannelEvent, "channel">) => void;
|
|
507
|
+
/**
|
|
508
|
+
* Wait for a response to a specific request.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```tsx
|
|
512
|
+
* const { waitForResponse, publish } = useChannel('confirmations');
|
|
513
|
+
* publish({ type: 'request', id: 'confirm-1', payload: { action: 'delete' } });
|
|
514
|
+
* const response = await waitForResponse('confirm-1', 30000);
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
waitForResponse: (requestId: string, timeoutMs?: number) => Promise<ChannelEvent>;
|
|
518
|
+
/**
|
|
519
|
+
* Whether the channel is available.
|
|
520
|
+
* False if channel service is not configured.
|
|
521
|
+
*/
|
|
522
|
+
available: boolean;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* useChannel - Access a named channel for pub/sub communication.
|
|
526
|
+
*
|
|
527
|
+
* Channels enable real-time bidirectional communication between components
|
|
528
|
+
* and external code (UI, other services, etc.).
|
|
529
|
+
*
|
|
530
|
+
* Use cases:
|
|
531
|
+
* - User input during model execution (e.g., stop button, feedback)
|
|
532
|
+
* - Progress updates to UI
|
|
533
|
+
* - Tool confirmation dialogs
|
|
534
|
+
* - Live data streaming to/from external systems
|
|
535
|
+
*
|
|
536
|
+
* @param name - Channel name (e.g., 'progress', 'user-input', 'tool:confirm')
|
|
537
|
+
* @returns Channel access object with subscribe, publish, and waitForResponse
|
|
538
|
+
*
|
|
539
|
+
* @example Basic subscription
|
|
540
|
+
* ```tsx
|
|
541
|
+
* function ProgressDisplay() {
|
|
542
|
+
* const [progress, setProgress] = useState(0);
|
|
543
|
+
* const { subscribe, available } = useChannel('progress');
|
|
544
|
+
*
|
|
545
|
+
* useEffect(() => {
|
|
546
|
+
* if (!available) return;
|
|
547
|
+
* return subscribe((event) => {
|
|
548
|
+
* if (event.type === 'update') {
|
|
549
|
+
* setProgress(event.payload.percent);
|
|
550
|
+
* }
|
|
551
|
+
* });
|
|
552
|
+
* }, [available]);
|
|
553
|
+
*
|
|
554
|
+
* return <Section>Progress: {progress}%</Section>;
|
|
555
|
+
* }
|
|
556
|
+
* ```
|
|
557
|
+
*
|
|
558
|
+
* @example Request/Response pattern
|
|
559
|
+
* ```tsx
|
|
560
|
+
* function ConfirmationHandler() {
|
|
561
|
+
* const { publish, waitForResponse, available } = useChannel('confirmations');
|
|
562
|
+
*
|
|
563
|
+
* const confirmAction = async (action: string) => {
|
|
564
|
+
* if (!available) throw new Error('Channels not available');
|
|
565
|
+
*
|
|
566
|
+
* const requestId = crypto.randomUUID();
|
|
567
|
+
* publish({ type: 'request', id: requestId, payload: { action } });
|
|
568
|
+
* const response = await waitForResponse(requestId, 30000);
|
|
569
|
+
* return response.payload.confirmed;
|
|
570
|
+
* };
|
|
571
|
+
*
|
|
572
|
+
* // ...
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* @example Publishing events
|
|
577
|
+
* ```tsx
|
|
578
|
+
* function StatusReporter() {
|
|
579
|
+
* const { publish } = useChannel('status');
|
|
580
|
+
*
|
|
581
|
+
* useTickEnd(() => {
|
|
582
|
+
* publish({ type: 'tick-complete', payload: { timestamp: Date.now() } });
|
|
583
|
+
* });
|
|
584
|
+
*
|
|
585
|
+
* return null;
|
|
586
|
+
* }
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
export declare function useChannel(name: string): UseChannelResult;
|
|
590
|
+
/**
|
|
591
|
+
* useChannelSubscription - Subscribe to channel events with automatic cleanup.
|
|
592
|
+
*
|
|
593
|
+
* This is a convenience hook that combines useChannel with useEffect for
|
|
594
|
+
* the common pattern of subscribing to a channel and cleaning up on unmount.
|
|
595
|
+
*
|
|
596
|
+
* @param name - Channel name
|
|
597
|
+
* @param handler - Event handler function
|
|
598
|
+
* @param deps - Dependencies array (handler is only updated when deps change)
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```tsx
|
|
602
|
+
* function NotificationListener() {
|
|
603
|
+
* const [notifications, setNotifications] = useState<string[]>([]);
|
|
604
|
+
*
|
|
605
|
+
* useChannelSubscription('notifications', (event) => {
|
|
606
|
+
* if (event.type === 'new') {
|
|
607
|
+
* setNotifications(n => [...n, event.payload.message]);
|
|
608
|
+
* }
|
|
609
|
+
* }, []);
|
|
610
|
+
*
|
|
611
|
+
* return <Section>{notifications.map(n => <Text>{n}</Text>)}</Section>;
|
|
612
|
+
* }
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
export declare function useChannelSubscription(name: string, handler: (event: ChannelEvent) => void, deps?: unknown[]): void;
|
|
616
|
+
/**
|
|
617
|
+
* Options for filtering and limiting conversation history.
|
|
618
|
+
*/
|
|
619
|
+
export interface ConversationHistoryOptions {
|
|
620
|
+
/**
|
|
621
|
+
* Filter function to include/exclude entries.
|
|
622
|
+
* @example Filter out system messages: (e) => e.message?.role !== 'system'
|
|
623
|
+
*/
|
|
624
|
+
filter?: (entry: COMTimelineEntry) => boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Maximum number of entries to return (from the end).
|
|
627
|
+
* @example Last 10 messages: { limit: 10 }
|
|
628
|
+
*/
|
|
629
|
+
limit?: number;
|
|
630
|
+
/**
|
|
631
|
+
* Include only entries from specific roles.
|
|
632
|
+
* @example Only user/assistant: { roles: ['user', 'assistant'] }
|
|
633
|
+
*/
|
|
634
|
+
roles?: Array<"user" | "assistant" | "tool" | "system">;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Get the full conversation history across all ticks.
|
|
638
|
+
*
|
|
639
|
+
* Combines `state.previous.timeline` (history) with `state.current.timeline`
|
|
640
|
+
* (current tick) into a single array.
|
|
641
|
+
*
|
|
642
|
+
* This is a utility hook that extracts data from TickState - it doesn't use the
|
|
643
|
+
* fiber system and can be called anywhere you have access to TickState.
|
|
644
|
+
*
|
|
645
|
+
* @param state - The TickState from component context
|
|
646
|
+
* @param options - Optional filtering and limiting
|
|
647
|
+
* @returns Array of timeline entries
|
|
648
|
+
*
|
|
649
|
+
* @example Basic usage
|
|
650
|
+
* ```tsx
|
|
651
|
+
* const ChatAgent = ({ message }: Props) => {
|
|
652
|
+
* const history = useConversationHistory();
|
|
653
|
+
*
|
|
654
|
+
* return (
|
|
655
|
+
* <>
|
|
656
|
+
* <Model model={claude} />
|
|
657
|
+
* <System>You are helpful.</System>
|
|
658
|
+
* {history.map((entry, i) => (
|
|
659
|
+
* <Message key={i} {...entry.message} />
|
|
660
|
+
* ))}
|
|
661
|
+
* <User>{message}</User>
|
|
662
|
+
* </>
|
|
663
|
+
* );
|
|
664
|
+
* };
|
|
665
|
+
* ```
|
|
666
|
+
*
|
|
667
|
+
* @example With options
|
|
668
|
+
* ```tsx
|
|
669
|
+
* const history = useConversationHistory({
|
|
670
|
+
* roles: ['user', 'assistant'], // Exclude tool messages
|
|
671
|
+
* limit: 10, // Last 10 messages
|
|
672
|
+
* });
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
675
|
+
export declare function useConversationHistory(options?: ConversationHistoryOptions): COMTimelineEntry[];
|
|
676
|
+
/**
|
|
677
|
+
* Get just the messages from conversation history (convenience wrapper).
|
|
678
|
+
*
|
|
679
|
+
* @param options - Optional filtering and limiting
|
|
680
|
+
* @returns Array of messages (excluding entries without messages)
|
|
681
|
+
*/
|
|
682
|
+
export declare function useMessages(options?: ConversationHistoryOptions): Array<COMTimelineEntry["message"]>;
|
|
683
|
+
/**
|
|
684
|
+
* Get message count from conversation history.
|
|
685
|
+
*
|
|
686
|
+
* @returns Number of messages in history
|
|
687
|
+
*/
|
|
688
|
+
export declare function useMessageCount(): number;
|
|
689
|
+
/**
|
|
690
|
+
* Get messages queued for the next tick.
|
|
691
|
+
*
|
|
692
|
+
* Messages can be queued via:
|
|
693
|
+
* - `session.queue.exec(msg)` - Queue a message for later processing
|
|
694
|
+
* - `session.interrupt(msg)` - Interrupt and queue a message
|
|
695
|
+
* - `RuntimeSession.sendMessage(msg)` - Direct programmatic injection
|
|
696
|
+
*
|
|
697
|
+
* Queued messages are available during render and can be used to show
|
|
698
|
+
* pending messages in the UI or to process them in the current tick.
|
|
699
|
+
*
|
|
700
|
+
* @returns Array of queued execution messages
|
|
701
|
+
*
|
|
702
|
+
* @example Show pending messages
|
|
703
|
+
* ```tsx
|
|
704
|
+
* const ChatWithPending = () => {
|
|
705
|
+
* const history = useConversationHistory();
|
|
706
|
+
* const pending = useQueuedMessages();
|
|
707
|
+
*
|
|
708
|
+
* return (
|
|
709
|
+
* <>
|
|
710
|
+
* {history.map((entry, i) => (
|
|
711
|
+
* <Message key={i} {...entry.message} />
|
|
712
|
+
* ))}
|
|
713
|
+
* {pending.length > 0 && (
|
|
714
|
+
* <System>Processing {pending.length} pending message(s)...</System>
|
|
715
|
+
* )}
|
|
716
|
+
* </>
|
|
717
|
+
* );
|
|
718
|
+
* };
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* @example Process pending messages
|
|
722
|
+
* ```tsx
|
|
723
|
+
* const Agent = () => {
|
|
724
|
+
* const pending = useQueuedMessages();
|
|
725
|
+
*
|
|
726
|
+
* // Access the first pending message if any
|
|
727
|
+
* const firstPending = pending[0];
|
|
728
|
+
* if (firstPending?.type === 'interrupt') {
|
|
729
|
+
* return <System>Handling interrupt: {firstPending.content}</System>;
|
|
730
|
+
* }
|
|
731
|
+
*
|
|
732
|
+
* return <AssistantMessage />;
|
|
733
|
+
* };
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
736
|
+
export declare function useQueuedMessages(): ExecutionMessage[];
|
|
737
|
+
/**
|
|
738
|
+
* Inject historical timeline entries into the conversation.
|
|
739
|
+
*
|
|
740
|
+
* Use this to load an existing conversation when the component mounts.
|
|
741
|
+
* The entries are injected once (on first render) and then available via
|
|
742
|
+
* `useConversationHistory()` and `<Timeline />`.
|
|
743
|
+
*
|
|
744
|
+
* This hook only injects on the first render. On subsequent renders (tick 2+),
|
|
745
|
+
* the timeline naturally includes all entries via `TickState.previous.timeline`.
|
|
746
|
+
*
|
|
747
|
+
* @param entries - Timeline entries to inject, or a function that returns them
|
|
748
|
+
* @param deps - Dependency array (like useEffect). If omitted, injects once on mount.
|
|
749
|
+
*
|
|
750
|
+
* @example Basic usage with static entries
|
|
751
|
+
* ```tsx
|
|
752
|
+
* const ChatAgent = ({ conversationHistory }: Props) => {
|
|
753
|
+
* useInjectHistory(conversationHistory);
|
|
754
|
+
* return <Timeline />;
|
|
755
|
+
* };
|
|
756
|
+
* ```
|
|
757
|
+
*
|
|
758
|
+
* @example Async loading in useInit
|
|
759
|
+
* ```tsx
|
|
760
|
+
* const ChatAgent = ({ conversationId }: Props) => {
|
|
761
|
+
* const [loaded, setLoaded] = useState(false);
|
|
762
|
+
*
|
|
763
|
+
* await useInit(async () => {
|
|
764
|
+
* const conversation = await loadConversation(conversationId);
|
|
765
|
+
* injectHistory(conversation.entries); // Use standalone function
|
|
766
|
+
* setLoaded(true);
|
|
767
|
+
* });
|
|
768
|
+
*
|
|
769
|
+
* if (!loaded) return null;
|
|
770
|
+
* return <Timeline />;
|
|
771
|
+
* };
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
export declare function useInjectHistory(entries: COMTimelineEntry[] | (() => COMTimelineEntry[]), deps?: unknown[]): void;
|
|
775
|
+
/**
|
|
776
|
+
* Standalone function to inject history (for use in useInit or async contexts).
|
|
777
|
+
*
|
|
778
|
+
* Unlike the hook, this can be called anywhere you have access to COM.
|
|
779
|
+
*
|
|
780
|
+
* @param com - The COM instance
|
|
781
|
+
* @param entries - Timeline entries to inject
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```tsx
|
|
785
|
+
* const ChatAgent = ({ conversationId }: Props) => {
|
|
786
|
+
* const com = useCom();
|
|
787
|
+
*
|
|
788
|
+
* await useInit(async () => {
|
|
789
|
+
* const conversation = await loadConversation(conversationId);
|
|
790
|
+
* injectHistory(com, conversation.entries);
|
|
791
|
+
* });
|
|
792
|
+
*
|
|
793
|
+
* return <Timeline />;
|
|
794
|
+
* };
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
export declare function injectHistory(com: COM, entries: COMTimelineEntry[]): void;
|
|
798
|
+
//# sourceMappingURL=hooks.d.ts.map
|