@tambo-ai/react 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-helpers/current-interactables-context-helper.d.ts +16 -2
- package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
- package/dist/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
- package/dist/context-helpers/current-interactables-context-helper.test.js +70 -0
- package/dist/context-helpers/current-interactables-context-helper.test.js.map +1 -0
- package/dist/mcp/elicitation.d.ts +3 -37
- package/dist/mcp/elicitation.d.ts.map +1 -1
- package/dist/mcp/elicitation.js +7 -24
- package/dist/mcp/elicitation.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-client.test.js +17 -17
- package/dist/mcp/mcp-client.test.js.map +1 -1
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +8 -5
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/mcp/mcp-hooks.test.js +30 -29
- package/dist/mcp/mcp-hooks.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +6 -9
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +9 -13
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.test.js +26 -25
- package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/dist/mcp/use-mcp-servers.test.js +2 -1
- package/dist/mcp/use-mcp-servers.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +7 -372
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/validate-input.test.d.ts +2 -0
- package/dist/model/validate-input.test.d.ts.map +1 -0
- package/dist/model/validate-input.test.js +38 -0
- package/dist/model/validate-input.test.js.map +1 -0
- package/dist/providers/tambo-interactable-provider.d.ts +7 -7
- package/dist/providers/tambo-registry-provider.d.ts +1 -1
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +4 -4
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/schema/index.d.ts +2 -4
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +9 -11
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/json-schema.d.ts +1 -17
- package/dist/schema/json-schema.d.ts.map +1 -1
- package/dist/schema/json-schema.js +5 -69
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/schema.test.js +24 -25
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.test.js +25 -25
- package/dist/schema/standard-schema.test.js.map +1 -1
- package/dist/schema/validate.test.js +33 -33
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/testing/tools.d.ts +4 -4
- package/dist/testing/tools.test.d.ts +2 -0
- package/dist/testing/tools.test.d.ts.map +1 -0
- package/dist/testing/tools.test.js +60 -0
- package/dist/testing/tools.test.js.map +1 -0
- package/dist/util/mcp-server-utils.d.ts +1 -1
- package/dist/util/mcp-server-utils.d.ts.map +1 -1
- package/dist/util/mcp-server-utils.js +4 -4
- package/dist/util/mcp-server-utils.js.map +1 -1
- package/dist/util/mcp-server-utils.test.js +27 -27
- package/dist/util/mcp-server-utils.test.js.map +1 -1
- package/dist/util/registry.js +1 -1
- package/dist/util/registry.js.map +1 -1
- package/dist/util/resource-content-resolver.js +5 -5
- package/dist/util/resource-content-resolver.js.map +1 -1
- package/dist/util/resource-content-resolver.test.js +6 -6
- package/dist/util/resource-content-resolver.test.js.map +1 -1
- package/dist/util/tool-caller.test.d.ts +2 -0
- package/dist/util/tool-caller.test.d.ts.map +1 -0
- package/dist/util/tool-caller.test.js +71 -0
- package/dist/util/tool-caller.test.js.map +1 -0
- package/dist/v1/__tests__/v1-interactables.test.js +1 -0
- package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.js +17 -17
- package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.d.ts +7 -6
- package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.js +2 -2
- package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.test.js +23 -23
- package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/dist/v1/index.d.ts +6 -6
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/index.js +2 -2
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts +2 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.js +2 -0
- package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.d.ts +2 -2
- package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.js +9 -9
- package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.test.js +35 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.js +2 -2
- package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/dist/v1/types/event.test.js +13 -13
- package/dist/v1/types/event.test.js.map +1 -1
- package/dist/v1/types/message.d.ts +12 -109
- package/dist/v1/types/message.d.ts.map +1 -1
- package/dist/v1/types/message.js +0 -7
- package/dist/v1/types/message.js.map +1 -1
- package/dist/v1/utils/event-accumulator.test.js +183 -184
- package/dist/v1/utils/event-accumulator.test.js.map +1 -1
- package/dist/v1/utils/json-patch.test.js +4 -4
- package/dist/v1/utils/json-patch.test.js.map +1 -1
- package/dist/v1/utils/keyed-throttle.test.js +12 -12
- package/dist/v1/utils/keyed-throttle.test.js.map +1 -1
- package/dist/v1/utils/registry-conversion.test.js +13 -13
- package/dist/v1/utils/registry-conversion.test.js.map +1 -1
- package/dist/v1/utils/stream-handler.test.js +5 -5
- package/dist/v1/utils/stream-handler.test.js.map +1 -1
- package/dist/v1/utils/tool-call-tracker.test.js +15 -9
- package/dist/v1/utils/tool-call-tracker.test.js.map +1 -1
- package/dist/v1/utils/tool-executor.test.js +25 -26
- package/dist/v1/utils/tool-executor.test.js.map +1 -1
- package/dist/v1/utils/unstrictify.test.js +16 -16
- package/dist/v1/utils/unstrictify.test.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +16 -2
- package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
- package/esm/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
- package/esm/context-helpers/current-interactables-context-helper.test.js +68 -0
- package/esm/context-helpers/current-interactables-context-helper.test.js.map +1 -0
- package/esm/mcp/elicitation.d.ts +3 -37
- package/esm/mcp/elicitation.d.ts.map +1 -1
- package/esm/mcp/elicitation.js +4 -24
- package/esm/mcp/elicitation.js.map +1 -1
- package/esm/mcp/index.d.ts +4 -4
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +1 -1
- package/esm/mcp/index.js.map +1 -1
- package/esm/mcp/mcp-client.test.js +1 -1
- package/esm/mcp/mcp-client.test.js.map +1 -1
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +4 -1
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.js +3 -2
- package/esm/mcp/mcp-hooks.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +6 -9
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +4 -8
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.test.js +3 -2
- package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/esm/mcp/use-mcp-servers.test.js +2 -1
- package/esm/mcp/use-mcp-servers.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +7 -372
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/validate-input.test.d.ts +2 -0
- package/esm/model/validate-input.test.d.ts.map +1 -0
- package/esm/model/validate-input.test.js +36 -0
- package/esm/model/validate-input.test.js.map +1 -0
- package/esm/providers/tambo-interactable-provider.d.ts +7 -7
- package/esm/providers/tambo-registry-provider.d.ts +1 -1
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +4 -4
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/schema/index.d.ts +2 -4
- package/esm/schema/index.d.ts.map +1 -1
- package/esm/schema/index.js +2 -4
- package/esm/schema/index.js.map +1 -1
- package/esm/schema/json-schema.d.ts +1 -17
- package/esm/schema/json-schema.d.ts.map +1 -1
- package/esm/schema/json-schema.js +2 -67
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/schema.test.js +1 -2
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.test.js +1 -1
- package/esm/schema/standard-schema.test.js.map +1 -1
- package/esm/schema/validate.test.js +1 -1
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/testing/tools.d.ts +4 -4
- package/esm/testing/tools.test.d.ts +2 -0
- package/esm/testing/tools.test.d.ts.map +1 -0
- package/esm/testing/tools.test.js +58 -0
- package/esm/testing/tools.test.js.map +1 -0
- package/esm/util/mcp-server-utils.d.ts +1 -1
- package/esm/util/mcp-server-utils.d.ts.map +1 -1
- package/esm/util/mcp-server-utils.js +1 -1
- package/esm/util/mcp-server-utils.js.map +1 -1
- package/esm/util/mcp-server-utils.test.js +1 -1
- package/esm/util/mcp-server-utils.test.js.map +1 -1
- package/esm/util/registry.js +1 -1
- package/esm/util/registry.js.map +1 -1
- package/esm/util/resource-content-resolver.js +1 -1
- package/esm/util/resource-content-resolver.js.map +1 -1
- package/esm/util/resource-content-resolver.test.js +2 -2
- package/esm/util/resource-content-resolver.test.js.map +1 -1
- package/esm/util/tool-caller.test.d.ts +2 -0
- package/esm/util/tool-caller.test.d.ts.map +1 -0
- package/esm/util/tool-caller.test.js +69 -0
- package/esm/util/tool-caller.test.js.map +1 -0
- package/esm/v1/__tests__/v1-interactables.test.js +1 -0
- package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.js +6 -6
- package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.d.ts +7 -6
- package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.js +1 -1
- package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.test.js +22 -22
- package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/esm/v1/index.d.ts +6 -6
- package/esm/v1/index.d.ts.map +1 -1
- package/esm/v1/index.js +1 -1
- package/esm/v1/index.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts +2 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.js +2 -0
- package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.d.ts +2 -2
- package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.test.js +35 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/esm/v1/types/event.test.js +1 -1
- package/esm/v1/types/event.test.js.map +1 -1
- package/esm/v1/types/message.d.ts +12 -109
- package/esm/v1/types/message.d.ts.map +1 -1
- package/esm/v1/types/message.js +0 -7
- package/esm/v1/types/message.js.map +1 -1
- package/esm/v1/utils/event-accumulator.test.js +2 -3
- package/esm/v1/utils/event-accumulator.test.js.map +1 -1
- package/esm/v1/utils/json-patch.test.js +1 -1
- package/esm/v1/utils/json-patch.test.js.map +1 -1
- package/esm/v1/utils/keyed-throttle.test.js +1 -1
- package/esm/v1/utils/keyed-throttle.test.js.map +1 -1
- package/esm/v1/utils/registry-conversion.test.js +1 -1
- package/esm/v1/utils/registry-conversion.test.js.map +1 -1
- package/esm/v1/utils/stream-handler.test.js +1 -1
- package/esm/v1/utils/stream-handler.test.js.map +1 -1
- package/esm/v1/utils/tool-call-tracker.test.js +9 -3
- package/esm/v1/utils/tool-call-tracker.test.js.map +1 -1
- package/esm/v1/utils/tool-executor.test.js +1 -2
- package/esm/v1/utils/tool-executor.test.js.map +1 -1
- package/esm/v1/utils/unstrictify.test.js +1 -1
- package/esm/v1/utils/unstrictify.test.js.map +1 -1
- package/package.json +10 -11
- package/dist/mcp/mcp-client.d.ts +0 -185
- package/dist/mcp/mcp-client.d.ts.map +0 -1
- package/dist/mcp/mcp-client.js +0 -219
- package/dist/mcp/mcp-client.js.map +0 -1
- package/dist/mcp/mcp-constants.d.ts +0 -19
- package/dist/mcp/mcp-constants.d.ts.map +0 -1
- package/dist/mcp/mcp-constants.js +0 -21
- package/dist/mcp/mcp-constants.js.map +0 -1
- package/dist/model/mcp-server-info.d.ts +0 -76
- package/dist/model/mcp-server-info.d.ts.map +0 -1
- package/dist/model/mcp-server-info.js +0 -29
- package/dist/model/mcp-server-info.js.map +0 -1
- package/dist/schema/schema.d.ts +0 -49
- package/dist/schema/schema.d.ts.map +0 -1
- package/dist/schema/schema.js +0 -129
- package/dist/schema/schema.js.map +0 -1
- package/dist/schema/standard-schema.d.ts +0 -22
- package/dist/schema/standard-schema.d.ts.map +0 -1
- package/dist/schema/standard-schema.js +0 -42
- package/dist/schema/standard-schema.js.map +0 -1
- package/dist/schema/validate.d.ts +0 -14
- package/dist/schema/validate.d.ts.map +0 -1
- package/dist/schema/validate.js +0 -148
- package/dist/schema/validate.js.map +0 -1
- package/dist/v1/types/auth.d.ts +0 -24
- package/dist/v1/types/auth.d.ts.map +0 -1
- package/dist/v1/types/auth.js +0 -3
- package/dist/v1/types/auth.js.map +0 -1
- package/dist/v1/types/event.d.ts +0 -89
- package/dist/v1/types/event.d.ts.map +0 -1
- package/dist/v1/types/event.js +0 -57
- package/dist/v1/types/event.js.map +0 -1
- package/dist/v1/types/thread.d.ts +0 -58
- package/dist/v1/types/thread.d.ts.map +0 -1
- package/dist/v1/types/thread.js +0 -9
- package/dist/v1/types/thread.js.map +0 -1
- package/dist/v1/types/tool-choice.d.ts +0 -8
- package/dist/v1/types/tool-choice.d.ts.map +0 -1
- package/dist/v1/types/tool-choice.js +0 -3
- package/dist/v1/types/tool-choice.js.map +0 -1
- package/dist/v1/utils/event-accumulator.d.ts +0 -165
- package/dist/v1/utils/event-accumulator.d.ts.map +0 -1
- package/dist/v1/utils/event-accumulator.js +0 -1277
- package/dist/v1/utils/event-accumulator.js.map +0 -1
- package/dist/v1/utils/json-patch.d.ts +0 -18
- package/dist/v1/utils/json-patch.d.ts.map +0 -1
- package/dist/v1/utils/json-patch.js +0 -35
- package/dist/v1/utils/json-patch.js.map +0 -1
- package/dist/v1/utils/keyed-throttle.d.ts +0 -42
- package/dist/v1/utils/keyed-throttle.d.ts.map +0 -1
- package/dist/v1/utils/keyed-throttle.js +0 -86
- package/dist/v1/utils/keyed-throttle.js.map +0 -1
- package/dist/v1/utils/registry-conversion.d.ts +0 -53
- package/dist/v1/utils/registry-conversion.d.ts.map +0 -1
- package/dist/v1/utils/registry-conversion.js +0 -115
- package/dist/v1/utils/registry-conversion.js.map +0 -1
- package/dist/v1/utils/stream-handler.d.ts +0 -45
- package/dist/v1/utils/stream-handler.d.ts.map +0 -1
- package/dist/v1/utils/stream-handler.js +0 -47
- package/dist/v1/utils/stream-handler.js.map +0 -1
- package/dist/v1/utils/thread-utils.d.ts +0 -16
- package/dist/v1/utils/thread-utils.d.ts.map +0 -1
- package/dist/v1/utils/thread-utils.js +0 -34
- package/dist/v1/utils/thread-utils.js.map +0 -1
- package/dist/v1/utils/tool-call-tracker.d.ts +0 -73
- package/dist/v1/utils/tool-call-tracker.d.ts.map +0 -1
- package/dist/v1/utils/tool-call-tracker.js +0 -180
- package/dist/v1/utils/tool-call-tracker.js.map +0 -1
- package/dist/v1/utils/tool-executor.d.ts +0 -67
- package/dist/v1/utils/tool-executor.d.ts.map +0 -1
- package/dist/v1/utils/tool-executor.js +0 -160
- package/dist/v1/utils/tool-executor.js.map +0 -1
- package/dist/v1/utils/unstrictify.d.ts +0 -32
- package/dist/v1/utils/unstrictify.d.ts.map +0 -1
- package/dist/v1/utils/unstrictify.js +0 -159
- package/dist/v1/utils/unstrictify.js.map +0 -1
- package/esm/mcp/mcp-client.d.ts +0 -185
- package/esm/mcp/mcp-client.d.ts.map +0 -1
- package/esm/mcp/mcp-client.js +0 -216
- package/esm/mcp/mcp-client.js.map +0 -1
- package/esm/mcp/mcp-constants.d.ts +0 -19
- package/esm/mcp/mcp-constants.d.ts.map +0 -1
- package/esm/mcp/mcp-constants.js +0 -18
- package/esm/mcp/mcp-constants.js.map +0 -1
- package/esm/model/mcp-server-info.d.ts +0 -76
- package/esm/model/mcp-server-info.d.ts.map +0 -1
- package/esm/model/mcp-server-info.js +0 -25
- package/esm/model/mcp-server-info.js.map +0 -1
- package/esm/schema/schema.d.ts +0 -49
- package/esm/schema/schema.d.ts.map +0 -1
- package/esm/schema/schema.js +0 -124
- package/esm/schema/schema.js.map +0 -1
- package/esm/schema/standard-schema.d.ts +0 -22
- package/esm/schema/standard-schema.d.ts.map +0 -1
- package/esm/schema/standard-schema.js +0 -39
- package/esm/schema/standard-schema.js.map +0 -1
- package/esm/schema/validate.d.ts +0 -14
- package/esm/schema/validate.d.ts.map +0 -1
- package/esm/schema/validate.js +0 -145
- package/esm/schema/validate.js.map +0 -1
- package/esm/v1/types/auth.d.ts +0 -24
- package/esm/v1/types/auth.d.ts.map +0 -1
- package/esm/v1/types/auth.js +0 -2
- package/esm/v1/types/auth.js.map +0 -1
- package/esm/v1/types/event.d.ts +0 -89
- package/esm/v1/types/event.d.ts.map +0 -1
- package/esm/v1/types/event.js +0 -53
- package/esm/v1/types/event.js.map +0 -1
- package/esm/v1/types/thread.d.ts +0 -58
- package/esm/v1/types/thread.d.ts.map +0 -1
- package/esm/v1/types/thread.js +0 -8
- package/esm/v1/types/thread.js.map +0 -1
- package/esm/v1/types/tool-choice.d.ts +0 -8
- package/esm/v1/types/tool-choice.d.ts.map +0 -1
- package/esm/v1/types/tool-choice.js +0 -2
- package/esm/v1/types/tool-choice.js.map +0 -1
- package/esm/v1/utils/event-accumulator.d.ts +0 -165
- package/esm/v1/utils/event-accumulator.d.ts.map +0 -1
- package/esm/v1/utils/event-accumulator.js +0 -1268
- package/esm/v1/utils/event-accumulator.js.map +0 -1
- package/esm/v1/utils/json-patch.d.ts +0 -18
- package/esm/v1/utils/json-patch.d.ts.map +0 -1
- package/esm/v1/utils/json-patch.js +0 -32
- package/esm/v1/utils/json-patch.js.map +0 -1
- package/esm/v1/utils/keyed-throttle.d.ts +0 -42
- package/esm/v1/utils/keyed-throttle.d.ts.map +0 -1
- package/esm/v1/utils/keyed-throttle.js +0 -83
- package/esm/v1/utils/keyed-throttle.js.map +0 -1
- package/esm/v1/utils/registry-conversion.d.ts +0 -53
- package/esm/v1/utils/registry-conversion.d.ts.map +0 -1
- package/esm/v1/utils/registry-conversion.js +0 -109
- package/esm/v1/utils/registry-conversion.js.map +0 -1
- package/esm/v1/utils/stream-handler.d.ts +0 -45
- package/esm/v1/utils/stream-handler.d.ts.map +0 -1
- package/esm/v1/utils/stream-handler.js +0 -44
- package/esm/v1/utils/stream-handler.js.map +0 -1
- package/esm/v1/utils/thread-utils.d.ts +0 -16
- package/esm/v1/utils/thread-utils.d.ts.map +0 -1
- package/esm/v1/utils/thread-utils.js +0 -31
- package/esm/v1/utils/thread-utils.js.map +0 -1
- package/esm/v1/utils/tool-call-tracker.d.ts +0 -73
- package/esm/v1/utils/tool-call-tracker.d.ts.map +0 -1
- package/esm/v1/utils/tool-call-tracker.js +0 -176
- package/esm/v1/utils/tool-call-tracker.js.map +0 -1
- package/esm/v1/utils/tool-executor.d.ts +0 -67
- package/esm/v1/utils/tool-executor.d.ts.map +0 -1
- package/esm/v1/utils/tool-executor.js +0 -154
- package/esm/v1/utils/tool-executor.js.map +0 -1
- package/esm/v1/utils/unstrictify.d.ts +0 -32
- package/esm/v1/utils/unstrictify.d.ts.map +0 -1
- package/esm/v1/utils/unstrictify.js +0 -155
- package/esm/v1/utils/unstrictify.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@ag-ui/core");
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("@tambo-ai/client");
|
|
5
5
|
/**
|
|
6
6
|
* Helper to extract a ToolUseContent from a message content array.
|
|
7
7
|
* @param content - Content array from a message
|
|
@@ -23,9 +23,9 @@ function asComponentContent(content, index) {
|
|
|
23
23
|
// Helper to create a base thread state for testing
|
|
24
24
|
function createTestThreadState(threadId) {
|
|
25
25
|
return {
|
|
26
|
-
...(0,
|
|
26
|
+
...(0, client_1.createInitialThreadState)(threadId),
|
|
27
27
|
thread: {
|
|
28
|
-
...(0,
|
|
28
|
+
...(0, client_1.createInitialThreadState)(threadId).thread,
|
|
29
29
|
// Use fixed timestamps for snapshot stability
|
|
30
30
|
createdAt: "2024-01-01T00:00:00.000Z",
|
|
31
31
|
updatedAt: "2024-01-01T00:00:00.000Z",
|
|
@@ -44,23 +44,22 @@ function createTestStreamState(threadId) {
|
|
|
44
44
|
}
|
|
45
45
|
describe("createInitialThreadState", () => {
|
|
46
46
|
it("creates thread state with correct structure", () => {
|
|
47
|
-
const state = (0,
|
|
47
|
+
const state = (0, client_1.createInitialThreadState)("thread_123");
|
|
48
48
|
expect(state.thread.id).toBe("thread_123");
|
|
49
49
|
expect(state.thread.messages).toEqual([]);
|
|
50
50
|
expect(state.thread.status).toBe("idle");
|
|
51
51
|
expect(state.streaming.status).toBe("idle");
|
|
52
|
-
expect(state.accumulatingToolArgs).
|
|
53
|
-
expect(state.accumulatingToolArgs.size).toBe(0);
|
|
52
|
+
expect(state.accumulatingToolArgs).toEqual({});
|
|
54
53
|
});
|
|
55
54
|
});
|
|
56
55
|
describe("createInitialState", () => {
|
|
57
56
|
it("creates initial state with placeholder thread", () => {
|
|
58
|
-
const state = (0,
|
|
59
|
-
expect(state.currentThreadId).toBe(
|
|
60
|
-
expect(state.threadMap[
|
|
61
|
-
expect(state.threadMap[
|
|
62
|
-
expect(state.threadMap[
|
|
63
|
-
expect(state.threadMap[
|
|
57
|
+
const state = (0, client_1.createInitialState)();
|
|
58
|
+
expect(state.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
59
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID]).toBeDefined();
|
|
60
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.id).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
61
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toEqual([]);
|
|
62
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].streaming.status).toBe("idle");
|
|
64
63
|
});
|
|
65
64
|
});
|
|
66
65
|
describe("streamReducer", () => {
|
|
@@ -74,13 +73,13 @@ describe("streamReducer", () => {
|
|
|
74
73
|
});
|
|
75
74
|
describe("unknown thread handling", () => {
|
|
76
75
|
it("auto-initializes unknown thread when receiving events", () => {
|
|
77
|
-
const state = (0,
|
|
76
|
+
const state = (0, client_1.createInitialState)();
|
|
78
77
|
const event = {
|
|
79
78
|
type: core_1.EventType.RUN_STARTED,
|
|
80
79
|
runId: "run_1",
|
|
81
80
|
threadId: "unknown_thread",
|
|
82
81
|
};
|
|
83
|
-
const result = (0,
|
|
82
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
84
83
|
type: "EVENT",
|
|
85
84
|
event,
|
|
86
85
|
threadId: "unknown_thread",
|
|
@@ -101,7 +100,7 @@ describe("streamReducer", () => {
|
|
|
101
100
|
type: core_1.EventType.STATE_SNAPSHOT,
|
|
102
101
|
snapshot: {},
|
|
103
102
|
};
|
|
104
|
-
const result = (0,
|
|
103
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
105
104
|
type: "EVENT",
|
|
106
105
|
event,
|
|
107
106
|
threadId: "thread_1",
|
|
@@ -116,7 +115,7 @@ describe("streamReducer", () => {
|
|
|
116
115
|
const event = {
|
|
117
116
|
type: "TOTALLY_UNKNOWN_EVENT_TYPE",
|
|
118
117
|
};
|
|
119
|
-
expect(() => (0,
|
|
118
|
+
expect(() => (0, client_1.streamReducer)(state, {
|
|
120
119
|
type: "EVENT",
|
|
121
120
|
event: event,
|
|
122
121
|
threadId: "thread_1",
|
|
@@ -129,7 +128,7 @@ describe("streamReducer", () => {
|
|
|
129
128
|
name: "unknown.custom.event",
|
|
130
129
|
value: {},
|
|
131
130
|
};
|
|
132
|
-
const result = (0,
|
|
131
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
133
132
|
type: "EVENT",
|
|
134
133
|
event,
|
|
135
134
|
threadId: "thread_1",
|
|
@@ -140,8 +139,8 @@ describe("streamReducer", () => {
|
|
|
140
139
|
});
|
|
141
140
|
describe("START_NEW_THREAD action", () => {
|
|
142
141
|
it("creates a new thread and sets it as current", () => {
|
|
143
|
-
const state = (0,
|
|
144
|
-
const result = (0,
|
|
142
|
+
const state = (0, client_1.createInitialState)();
|
|
143
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
145
144
|
type: "START_NEW_THREAD",
|
|
146
145
|
threadId: "new_thread",
|
|
147
146
|
});
|
|
@@ -151,7 +150,7 @@ describe("streamReducer", () => {
|
|
|
151
150
|
});
|
|
152
151
|
it("overwrites existing placeholder thread on second call", () => {
|
|
153
152
|
// First call: start a new thread on the placeholder
|
|
154
|
-
let state = (0,
|
|
153
|
+
let state = (0, client_1.createInitialState)();
|
|
155
154
|
const initialThread = {
|
|
156
155
|
messages: [
|
|
157
156
|
{
|
|
@@ -161,14 +160,14 @@ describe("streamReducer", () => {
|
|
|
161
160
|
},
|
|
162
161
|
],
|
|
163
162
|
};
|
|
164
|
-
state = (0,
|
|
163
|
+
state = (0, client_1.streamReducer)(state, {
|
|
165
164
|
type: "START_NEW_THREAD",
|
|
166
|
-
threadId:
|
|
165
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
167
166
|
initialThread,
|
|
168
167
|
});
|
|
169
|
-
expect(state.currentThreadId).toBe(
|
|
170
|
-
expect(state.threadMap[
|
|
171
|
-
expect(state.threadMap[
|
|
168
|
+
expect(state.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
169
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(1);
|
|
170
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages[0].id).toBe("seed_1");
|
|
172
171
|
// Simulate a completed conversation: add more messages to the placeholder
|
|
173
172
|
const userMsgStart = {
|
|
174
173
|
type: core_1.EventType.TEXT_MESSAGE_START,
|
|
@@ -180,48 +179,48 @@ describe("streamReducer", () => {
|
|
|
180
179
|
messageId: "extra_msg",
|
|
181
180
|
delta: "Follow-up",
|
|
182
181
|
};
|
|
183
|
-
state = (0,
|
|
182
|
+
state = (0, client_1.streamReducer)(state, {
|
|
184
183
|
type: "EVENT",
|
|
185
184
|
event: userMsgStart,
|
|
186
|
-
threadId:
|
|
185
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
187
186
|
});
|
|
188
|
-
state = (0,
|
|
187
|
+
state = (0, client_1.streamReducer)(state, {
|
|
189
188
|
type: "EVENT",
|
|
190
189
|
event: userMsgContent,
|
|
191
|
-
threadId:
|
|
190
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
192
191
|
});
|
|
193
|
-
expect(state.threadMap[
|
|
192
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(2);
|
|
194
193
|
// Second call: start a new thread again — should reset to fresh state
|
|
195
|
-
state = (0,
|
|
194
|
+
state = (0, client_1.streamReducer)(state, {
|
|
196
195
|
type: "START_NEW_THREAD",
|
|
197
|
-
threadId:
|
|
196
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
198
197
|
initialThread,
|
|
199
198
|
});
|
|
200
199
|
// Should be reset to just the initial seed message, not the old messages
|
|
201
|
-
expect(state.currentThreadId).toBe(
|
|
202
|
-
expect(state.threadMap[
|
|
203
|
-
expect(state.threadMap[
|
|
200
|
+
expect(state.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
201
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(1);
|
|
202
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages[0].id).toBe("seed_1");
|
|
204
203
|
});
|
|
205
204
|
it("overwrites existing placeholder even without initialThread", () => {
|
|
206
|
-
let state = (0,
|
|
205
|
+
let state = (0, client_1.createInitialState)();
|
|
207
206
|
// Add a message to the placeholder
|
|
208
|
-
state = (0,
|
|
207
|
+
state = (0, client_1.streamReducer)(state, {
|
|
209
208
|
type: "EVENT",
|
|
210
209
|
event: {
|
|
211
210
|
type: core_1.EventType.TEXT_MESSAGE_START,
|
|
212
211
|
messageId: "msg_1",
|
|
213
212
|
role: "user",
|
|
214
213
|
},
|
|
215
|
-
threadId:
|
|
214
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
216
215
|
});
|
|
217
|
-
expect(state.threadMap[
|
|
216
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(1);
|
|
218
217
|
// START_NEW_THREAD without initialThread should still reset
|
|
219
|
-
state = (0,
|
|
218
|
+
state = (0, client_1.streamReducer)(state, {
|
|
220
219
|
type: "START_NEW_THREAD",
|
|
221
|
-
threadId:
|
|
220
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
222
221
|
});
|
|
223
|
-
expect(state.currentThreadId).toBe(
|
|
224
|
-
expect(state.threadMap[
|
|
222
|
+
expect(state.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
223
|
+
expect(state.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(0);
|
|
225
224
|
});
|
|
226
225
|
});
|
|
227
226
|
describe("RUN_STARTED event", () => {
|
|
@@ -233,7 +232,7 @@ describe("streamReducer", () => {
|
|
|
233
232
|
threadId: "thread_1",
|
|
234
233
|
timestamp: 1704067200000,
|
|
235
234
|
};
|
|
236
|
-
const result = (0,
|
|
235
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
237
236
|
type: "EVENT",
|
|
238
237
|
event,
|
|
239
238
|
threadId: "thread_1",
|
|
@@ -252,7 +251,7 @@ describe("streamReducer", () => {
|
|
|
252
251
|
threadId: "thread_1",
|
|
253
252
|
timestamp: 1704067200000,
|
|
254
253
|
};
|
|
255
|
-
const result = (0,
|
|
254
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
256
255
|
type: "EVENT",
|
|
257
256
|
event,
|
|
258
257
|
threadId: "thread_1",
|
|
@@ -268,7 +267,7 @@ describe("streamReducer", () => {
|
|
|
268
267
|
threadId: "thread_1",
|
|
269
268
|
timestamp: 1704067200000,
|
|
270
269
|
};
|
|
271
|
-
const result = (0,
|
|
270
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
272
271
|
type: "EVENT",
|
|
273
272
|
event,
|
|
274
273
|
threadId: "thread_1",
|
|
@@ -276,7 +275,7 @@ describe("streamReducer", () => {
|
|
|
276
275
|
expect(result.threadMap.thread_1.streaming.startTime).toBe(1704067200000);
|
|
277
276
|
});
|
|
278
277
|
it("does not switch currentThreadId when placeholder has no messages", () => {
|
|
279
|
-
const state = (0,
|
|
278
|
+
const state = (0, client_1.createInitialState)();
|
|
280
279
|
const realThreadId = "thread_real_123";
|
|
281
280
|
const runStartedEvent = {
|
|
282
281
|
type: core_1.EventType.RUN_STARTED,
|
|
@@ -284,19 +283,19 @@ describe("streamReducer", () => {
|
|
|
284
283
|
threadId: realThreadId,
|
|
285
284
|
timestamp: 1704067200000,
|
|
286
285
|
};
|
|
287
|
-
const result = (0,
|
|
286
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
288
287
|
type: "EVENT",
|
|
289
288
|
event: runStartedEvent,
|
|
290
289
|
threadId: realThreadId,
|
|
291
290
|
});
|
|
292
|
-
expect(result.threadMap[
|
|
293
|
-
expect(result.currentThreadId).toBe(
|
|
291
|
+
expect(result.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(0);
|
|
292
|
+
expect(result.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
294
293
|
});
|
|
295
294
|
it("migrates messages from placeholder thread to real thread", () => {
|
|
296
295
|
// Start with initial state (which has placeholder thread)
|
|
297
|
-
const state = (0,
|
|
296
|
+
const state = (0, client_1.createInitialState)();
|
|
298
297
|
// Verify placeholder thread exists
|
|
299
|
-
expect(state.currentThreadId).toBe(
|
|
298
|
+
expect(state.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
300
299
|
// Add a user message to the placeholder thread
|
|
301
300
|
const userMsgStart = {
|
|
302
301
|
type: core_1.EventType.TEXT_MESSAGE_START,
|
|
@@ -312,25 +311,25 @@ describe("streamReducer", () => {
|
|
|
312
311
|
type: core_1.EventType.TEXT_MESSAGE_END,
|
|
313
312
|
messageId: "user_msg_1",
|
|
314
313
|
};
|
|
315
|
-
let stateWithUserMsg = (0,
|
|
314
|
+
let stateWithUserMsg = (0, client_1.streamReducer)(state, {
|
|
316
315
|
type: "EVENT",
|
|
317
316
|
event: userMsgStart,
|
|
318
|
-
threadId:
|
|
317
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
319
318
|
});
|
|
320
|
-
stateWithUserMsg = (0,
|
|
319
|
+
stateWithUserMsg = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
321
320
|
type: "EVENT",
|
|
322
321
|
event: userMsgContent,
|
|
323
|
-
threadId:
|
|
322
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
324
323
|
});
|
|
325
|
-
stateWithUserMsg = (0,
|
|
324
|
+
stateWithUserMsg = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
326
325
|
type: "EVENT",
|
|
327
326
|
event: userMsgEnd,
|
|
328
|
-
threadId:
|
|
327
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
329
328
|
});
|
|
330
329
|
// Verify placeholder thread has the message
|
|
331
|
-
expect(stateWithUserMsg.currentThreadId).toBe(
|
|
332
|
-
expect(stateWithUserMsg.threadMap[
|
|
333
|
-
expect(stateWithUserMsg.threadMap[
|
|
330
|
+
expect(stateWithUserMsg.currentThreadId).toBe(client_1.PLACEHOLDER_THREAD_ID);
|
|
331
|
+
expect(stateWithUserMsg.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(1);
|
|
332
|
+
expect(stateWithUserMsg.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages[0]
|
|
334
333
|
.content[0]).toEqual({
|
|
335
334
|
type: "text",
|
|
336
335
|
text: "Hello",
|
|
@@ -343,14 +342,14 @@ describe("streamReducer", () => {
|
|
|
343
342
|
threadId: realThreadId,
|
|
344
343
|
timestamp: 1704067200000,
|
|
345
344
|
};
|
|
346
|
-
const finalState = (0,
|
|
345
|
+
const finalState = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
347
346
|
type: "EVENT",
|
|
348
347
|
event: runStartedEvent,
|
|
349
348
|
threadId: realThreadId,
|
|
350
349
|
});
|
|
351
350
|
// Placeholder thread should be reset to empty (not removed)
|
|
352
|
-
expect(finalState.threadMap[
|
|
353
|
-
expect(finalState.threadMap[
|
|
351
|
+
expect(finalState.threadMap[client_1.PLACEHOLDER_THREAD_ID]).toBeDefined();
|
|
352
|
+
expect(finalState.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(0);
|
|
354
353
|
// Real thread should have the migrated user message
|
|
355
354
|
expect(finalState.threadMap[realThreadId]).toBeDefined();
|
|
356
355
|
expect(finalState.threadMap[realThreadId].thread.messages).toHaveLength(1);
|
|
@@ -365,12 +364,12 @@ describe("streamReducer", () => {
|
|
|
365
364
|
expect(finalState.threadMap[realThreadId].streaming.runId).toBe("run_456");
|
|
366
365
|
});
|
|
367
366
|
it("migrates messages even if currentThreadId changes away from placeholder", () => {
|
|
368
|
-
let state = (0,
|
|
369
|
-
state = (0,
|
|
367
|
+
let state = (0, client_1.createInitialState)();
|
|
368
|
+
state = (0, client_1.streamReducer)(state, {
|
|
370
369
|
type: "INIT_THREAD",
|
|
371
370
|
threadId: "thread_1",
|
|
372
371
|
});
|
|
373
|
-
state = (0,
|
|
372
|
+
state = (0, client_1.streamReducer)(state, {
|
|
374
373
|
type: "SET_CURRENT_THREAD",
|
|
375
374
|
threadId: "thread_1",
|
|
376
375
|
});
|
|
@@ -388,20 +387,20 @@ describe("streamReducer", () => {
|
|
|
388
387
|
type: core_1.EventType.TEXT_MESSAGE_END,
|
|
389
388
|
messageId: "user_msg_1",
|
|
390
389
|
};
|
|
391
|
-
state = (0,
|
|
390
|
+
state = (0, client_1.streamReducer)(state, {
|
|
392
391
|
type: "EVENT",
|
|
393
392
|
event: userMsgStart,
|
|
394
|
-
threadId:
|
|
393
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
395
394
|
});
|
|
396
|
-
state = (0,
|
|
395
|
+
state = (0, client_1.streamReducer)(state, {
|
|
397
396
|
type: "EVENT",
|
|
398
397
|
event: userMsgContent,
|
|
399
|
-
threadId:
|
|
398
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
400
399
|
});
|
|
401
|
-
state = (0,
|
|
400
|
+
state = (0, client_1.streamReducer)(state, {
|
|
402
401
|
type: "EVENT",
|
|
403
402
|
event: userMsgEnd,
|
|
404
|
-
threadId:
|
|
403
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
405
404
|
});
|
|
406
405
|
const realThreadId = "thread_real_123";
|
|
407
406
|
const runStartedEvent = {
|
|
@@ -410,18 +409,18 @@ describe("streamReducer", () => {
|
|
|
410
409
|
threadId: realThreadId,
|
|
411
410
|
timestamp: 1704067200000,
|
|
412
411
|
};
|
|
413
|
-
const result = (0,
|
|
412
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
414
413
|
type: "EVENT",
|
|
415
414
|
event: runStartedEvent,
|
|
416
415
|
threadId: realThreadId,
|
|
417
416
|
});
|
|
418
|
-
expect(result.threadMap[
|
|
417
|
+
expect(result.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(0);
|
|
419
418
|
expect(result.threadMap[realThreadId].thread.messages).toHaveLength(1);
|
|
420
419
|
expect(result.currentThreadId).toBe("thread_1");
|
|
421
420
|
});
|
|
422
421
|
it("prefers event.threadId over action threadId when RUN_STARTED is dispatched", () => {
|
|
423
422
|
// Start with initial state (which has placeholder thread)
|
|
424
|
-
const state = (0,
|
|
423
|
+
const state = (0, client_1.createInitialState)();
|
|
425
424
|
// Add a user message to the placeholder thread
|
|
426
425
|
const userMsgStart = {
|
|
427
426
|
type: core_1.EventType.TEXT_MESSAGE_START,
|
|
@@ -437,20 +436,20 @@ describe("streamReducer", () => {
|
|
|
437
436
|
type: core_1.EventType.TEXT_MESSAGE_END,
|
|
438
437
|
messageId: "user_msg_1",
|
|
439
438
|
};
|
|
440
|
-
let stateWithUserMsg = (0,
|
|
439
|
+
let stateWithUserMsg = (0, client_1.streamReducer)(state, {
|
|
441
440
|
type: "EVENT",
|
|
442
441
|
event: userMsgStart,
|
|
443
|
-
threadId:
|
|
442
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
444
443
|
});
|
|
445
|
-
stateWithUserMsg = (0,
|
|
444
|
+
stateWithUserMsg = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
446
445
|
type: "EVENT",
|
|
447
446
|
event: userMsgContent,
|
|
448
|
-
threadId:
|
|
447
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
449
448
|
});
|
|
450
|
-
stateWithUserMsg = (0,
|
|
449
|
+
stateWithUserMsg = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
451
450
|
type: "EVENT",
|
|
452
451
|
event: userMsgEnd,
|
|
453
|
-
threadId:
|
|
452
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
454
453
|
});
|
|
455
454
|
const realThreadId = "thread_real_123";
|
|
456
455
|
const runStartedEvent = {
|
|
@@ -459,12 +458,12 @@ describe("streamReducer", () => {
|
|
|
459
458
|
threadId: realThreadId,
|
|
460
459
|
timestamp: 1704067200000,
|
|
461
460
|
};
|
|
462
|
-
const result = (0,
|
|
461
|
+
const result = (0, client_1.streamReducer)(stateWithUserMsg, {
|
|
463
462
|
type: "EVENT",
|
|
464
463
|
event: runStartedEvent,
|
|
465
|
-
threadId:
|
|
464
|
+
threadId: client_1.PLACEHOLDER_THREAD_ID,
|
|
466
465
|
});
|
|
467
|
-
expect(result.threadMap[
|
|
466
|
+
expect(result.threadMap[client_1.PLACEHOLDER_THREAD_ID].thread.messages).toHaveLength(0);
|
|
468
467
|
expect(result.threadMap[realThreadId].thread.messages).toHaveLength(1);
|
|
469
468
|
expect(result.currentThreadId).toBe(realThreadId);
|
|
470
469
|
});
|
|
@@ -479,7 +478,7 @@ describe("streamReducer", () => {
|
|
|
479
478
|
runId: "run_123",
|
|
480
479
|
threadId: "thread_1",
|
|
481
480
|
};
|
|
482
|
-
const result = (0,
|
|
481
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
483
482
|
type: "EVENT",
|
|
484
483
|
event,
|
|
485
484
|
threadId: "thread_1",
|
|
@@ -498,7 +497,7 @@ describe("streamReducer", () => {
|
|
|
498
497
|
runId: "run_abc",
|
|
499
498
|
threadId: "thread_1",
|
|
500
499
|
};
|
|
501
|
-
const result = (0,
|
|
500
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
502
501
|
type: "EVENT",
|
|
503
502
|
event,
|
|
504
503
|
threadId: "thread_1",
|
|
@@ -517,7 +516,7 @@ describe("streamReducer", () => {
|
|
|
517
516
|
runId: "run_from_event",
|
|
518
517
|
threadId: "thread_1",
|
|
519
518
|
};
|
|
520
|
-
const result = (0,
|
|
519
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
521
520
|
type: "EVENT",
|
|
522
521
|
event,
|
|
523
522
|
threadId: "thread_1",
|
|
@@ -533,7 +532,7 @@ describe("streamReducer", () => {
|
|
|
533
532
|
message: "Something went wrong",
|
|
534
533
|
code: "ERR_001",
|
|
535
534
|
};
|
|
536
|
-
const result = (0,
|
|
535
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
537
536
|
type: "EVENT",
|
|
538
537
|
event,
|
|
539
538
|
threadId: "thread_1",
|
|
@@ -552,7 +551,7 @@ describe("streamReducer", () => {
|
|
|
552
551
|
message: "Run cancelled",
|
|
553
552
|
code: "CANCELLED",
|
|
554
553
|
};
|
|
555
|
-
const result = (0,
|
|
554
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
556
555
|
type: "EVENT",
|
|
557
556
|
event,
|
|
558
557
|
threadId: "thread_1",
|
|
@@ -574,7 +573,7 @@ describe("streamReducer", () => {
|
|
|
574
573
|
messageId: "msg_1",
|
|
575
574
|
role: "assistant",
|
|
576
575
|
};
|
|
577
|
-
const result = (0,
|
|
576
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
578
577
|
type: "EVENT",
|
|
579
578
|
event,
|
|
580
579
|
threadId: "thread_1",
|
|
@@ -592,7 +591,7 @@ describe("streamReducer", () => {
|
|
|
592
591
|
messageId: "msg_1",
|
|
593
592
|
role: "user",
|
|
594
593
|
};
|
|
595
|
-
const result = (0,
|
|
594
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
596
595
|
type: "EVENT",
|
|
597
596
|
event,
|
|
598
597
|
threadId: "thread_1",
|
|
@@ -619,7 +618,7 @@ describe("streamReducer", () => {
|
|
|
619
618
|
messageId: "msg_1",
|
|
620
619
|
delta: "Hello ",
|
|
621
620
|
};
|
|
622
|
-
const result = (0,
|
|
621
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
623
622
|
type: "EVENT",
|
|
624
623
|
event,
|
|
625
624
|
threadId: "thread_1",
|
|
@@ -645,7 +644,7 @@ describe("streamReducer", () => {
|
|
|
645
644
|
messageId: "msg_1",
|
|
646
645
|
delta: "After tool call",
|
|
647
646
|
};
|
|
648
|
-
const result = (0,
|
|
647
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
649
648
|
type: "EVENT",
|
|
650
649
|
event,
|
|
651
650
|
threadId: "thread_1",
|
|
@@ -675,7 +674,7 @@ describe("streamReducer", () => {
|
|
|
675
674
|
messageId: "msg_1",
|
|
676
675
|
delta: "world!",
|
|
677
676
|
};
|
|
678
|
-
const result = (0,
|
|
677
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
679
678
|
type: "EVENT",
|
|
680
679
|
event,
|
|
681
680
|
threadId: "thread_1",
|
|
@@ -700,7 +699,7 @@ describe("streamReducer", () => {
|
|
|
700
699
|
delta: "Hello",
|
|
701
700
|
};
|
|
702
701
|
expect(() => {
|
|
703
|
-
(0,
|
|
702
|
+
(0, client_1.streamReducer)(state, {
|
|
704
703
|
type: "EVENT",
|
|
705
704
|
event,
|
|
706
705
|
threadId: "thread_1",
|
|
@@ -726,7 +725,7 @@ describe("streamReducer", () => {
|
|
|
726
725
|
messageId: "wrong_msg_id",
|
|
727
726
|
};
|
|
728
727
|
expect(() => {
|
|
729
|
-
(0,
|
|
728
|
+
(0, client_1.streamReducer)(state, {
|
|
730
729
|
type: "EVENT",
|
|
731
730
|
event,
|
|
732
731
|
threadId: "thread_1",
|
|
@@ -748,7 +747,7 @@ describe("streamReducer", () => {
|
|
|
748
747
|
type: core_1.EventType.TEXT_MESSAGE_END,
|
|
749
748
|
messageId: "msg_1",
|
|
750
749
|
};
|
|
751
|
-
const result = (0,
|
|
750
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
752
751
|
type: "EVENT",
|
|
753
752
|
event,
|
|
754
753
|
threadId: "thread_1",
|
|
@@ -773,7 +772,7 @@ describe("streamReducer", () => {
|
|
|
773
772
|
toolCallName: "get_weather",
|
|
774
773
|
parentMessageId: "msg_1",
|
|
775
774
|
};
|
|
776
|
-
const result = (0,
|
|
775
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
777
776
|
type: "EVENT",
|
|
778
777
|
event,
|
|
779
778
|
threadId: "thread_1",
|
|
@@ -805,7 +804,7 @@ describe("streamReducer", () => {
|
|
|
805
804
|
toolCallName: "get_weather",
|
|
806
805
|
// No parentMessageId - should use last message
|
|
807
806
|
};
|
|
808
|
-
const result = (0,
|
|
807
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
809
808
|
type: "EVENT",
|
|
810
809
|
event,
|
|
811
810
|
threadId: "thread_1",
|
|
@@ -836,7 +835,7 @@ describe("streamReducer", () => {
|
|
|
836
835
|
parentMessageId: "unknown_msg",
|
|
837
836
|
};
|
|
838
837
|
// When parentMessageId not found, creates a synthetic message
|
|
839
|
-
const result = (0,
|
|
838
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
840
839
|
type: "EVENT",
|
|
841
840
|
event,
|
|
842
841
|
threadId: "thread_1",
|
|
@@ -863,7 +862,7 @@ describe("streamReducer", () => {
|
|
|
863
862
|
// No parentMessageId, no messages
|
|
864
863
|
};
|
|
865
864
|
// When no messages exist, creates a synthetic message
|
|
866
|
-
const result = (0,
|
|
865
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
867
866
|
type: "EVENT",
|
|
868
867
|
event,
|
|
869
868
|
threadId: "thread_1",
|
|
@@ -895,7 +894,7 @@ describe("streamReducer", () => {
|
|
|
895
894
|
toolCallName: "get_weather",
|
|
896
895
|
// No parentMessageId - last message is user, should NOT append to it
|
|
897
896
|
};
|
|
898
|
-
const result = (0,
|
|
897
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
899
898
|
type: "EVENT",
|
|
900
899
|
event,
|
|
901
900
|
threadId: "thread_1",
|
|
@@ -933,7 +932,7 @@ describe("streamReducer", () => {
|
|
|
933
932
|
type: core_1.EventType.TOOL_CALL_END,
|
|
934
933
|
toolCallId: "tool_1",
|
|
935
934
|
};
|
|
936
|
-
const result = (0,
|
|
935
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
937
936
|
type: "EVENT",
|
|
938
937
|
event: endEvent,
|
|
939
938
|
threadId: "thread_1",
|
|
@@ -959,7 +958,7 @@ describe("streamReducer", () => {
|
|
|
959
958
|
toolCallId: "tool_1",
|
|
960
959
|
delta: '{"city":',
|
|
961
960
|
};
|
|
962
|
-
let result = (0,
|
|
961
|
+
let result = (0, client_1.streamReducer)(state, {
|
|
963
962
|
type: "EVENT",
|
|
964
963
|
event: argsEvent1,
|
|
965
964
|
threadId: "thread_1",
|
|
@@ -969,7 +968,7 @@ describe("streamReducer", () => {
|
|
|
969
968
|
toolCallId: "tool_1",
|
|
970
969
|
delta: '"NYC"}',
|
|
971
970
|
};
|
|
972
|
-
result = (0,
|
|
971
|
+
result = (0, client_1.streamReducer)(result, {
|
|
973
972
|
type: "EVENT",
|
|
974
973
|
event: argsEvent2,
|
|
975
974
|
threadId: "thread_1",
|
|
@@ -979,7 +978,7 @@ describe("streamReducer", () => {
|
|
|
979
978
|
type: core_1.EventType.TOOL_CALL_END,
|
|
980
979
|
toolCallId: "tool_1",
|
|
981
980
|
};
|
|
982
|
-
result = (0,
|
|
981
|
+
result = (0, client_1.streamReducer)(result, {
|
|
983
982
|
type: "EVENT",
|
|
984
983
|
event: endEvent,
|
|
985
984
|
threadId: "thread_1",
|
|
@@ -1000,7 +999,7 @@ describe("streamReducer", () => {
|
|
|
1000
999
|
},
|
|
1001
1000
|
];
|
|
1002
1001
|
// First chunk: partial key — partial-json can parse this into { city: "" }
|
|
1003
|
-
let result = (0,
|
|
1002
|
+
let result = (0, client_1.streamReducer)(state, {
|
|
1004
1003
|
type: "EVENT",
|
|
1005
1004
|
event: {
|
|
1006
1005
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1013,7 +1012,7 @@ describe("streamReducer", () => {
|
|
|
1013
1012
|
// partial-json parses incomplete string values
|
|
1014
1013
|
expect(toolContent.input).toEqual({ city: "N" });
|
|
1015
1014
|
// Second chunk: complete city, start of units
|
|
1016
|
-
result = (0,
|
|
1015
|
+
result = (0, client_1.streamReducer)(result, {
|
|
1017
1016
|
type: "EVENT",
|
|
1018
1017
|
event: {
|
|
1019
1018
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1025,7 +1024,7 @@ describe("streamReducer", () => {
|
|
|
1025
1024
|
toolContent = asToolUseContent(result.threadMap.thread_1.thread.messages[0].content, 0);
|
|
1026
1025
|
expect(toolContent.input).toEqual({ city: "NYC", units: "fahr" });
|
|
1027
1026
|
// Final chunk + TOOL_CALL_END
|
|
1028
|
-
result = (0,
|
|
1027
|
+
result = (0, client_1.streamReducer)(result, {
|
|
1029
1028
|
type: "EVENT",
|
|
1030
1029
|
event: {
|
|
1031
1030
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1034,7 +1033,7 @@ describe("streamReducer", () => {
|
|
|
1034
1033
|
},
|
|
1035
1034
|
threadId: "thread_1",
|
|
1036
1035
|
});
|
|
1037
|
-
result = (0,
|
|
1036
|
+
result = (0, client_1.streamReducer)(result, {
|
|
1038
1037
|
type: "EVENT",
|
|
1039
1038
|
event: {
|
|
1040
1039
|
type: core_1.EventType.TOOL_CALL_END,
|
|
@@ -1066,7 +1065,7 @@ describe("streamReducer", () => {
|
|
|
1066
1065
|
toolCallId: "tool_1",
|
|
1067
1066
|
delta: "{invalid json",
|
|
1068
1067
|
};
|
|
1069
|
-
const result = (0,
|
|
1068
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1070
1069
|
type: "EVENT",
|
|
1071
1070
|
event: argsEvent,
|
|
1072
1071
|
threadId: "thread_1",
|
|
@@ -1077,7 +1076,7 @@ describe("streamReducer", () => {
|
|
|
1077
1076
|
toolCallId: "tool_1",
|
|
1078
1077
|
};
|
|
1079
1078
|
expect(() => {
|
|
1080
|
-
(0,
|
|
1079
|
+
(0, client_1.streamReducer)(result, {
|
|
1081
1080
|
type: "EVENT",
|
|
1082
1081
|
event: endEvent,
|
|
1083
1082
|
threadId: "thread_1",
|
|
@@ -1097,7 +1096,7 @@ describe("streamReducer", () => {
|
|
|
1097
1096
|
},
|
|
1098
1097
|
];
|
|
1099
1098
|
const preParsed = { city: "Seattle", units: "celsius" };
|
|
1100
|
-
const result = (0,
|
|
1099
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1101
1100
|
type: "EVENT",
|
|
1102
1101
|
event: {
|
|
1103
1102
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1144,7 +1143,7 @@ describe("streamReducer", () => {
|
|
|
1144
1143
|
const chunkSize = 3;
|
|
1145
1144
|
for (let i = 0; i < fullJson.length; i += chunkSize) {
|
|
1146
1145
|
const delta = fullJson.slice(i, i + chunkSize);
|
|
1147
|
-
state = (0,
|
|
1146
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1148
1147
|
type: "EVENT",
|
|
1149
1148
|
event: {
|
|
1150
1149
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1162,7 +1161,7 @@ describe("streamReducer", () => {
|
|
|
1162
1161
|
const finalStreaming = asToolUseContent(state.threadMap.thread_1.thread.messages[0].content, 0);
|
|
1163
1162
|
expect(finalStreaming.input).toEqual({ required_string: "required" });
|
|
1164
1163
|
// TOOL_CALL_END — final authoritative parse + unstrictify
|
|
1165
|
-
state = (0,
|
|
1164
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1166
1165
|
type: "EVENT",
|
|
1167
1166
|
event: {
|
|
1168
1167
|
type: core_1.EventType.TOOL_CALL_END,
|
|
@@ -1202,7 +1201,7 @@ describe("streamReducer", () => {
|
|
|
1202
1201
|
},
|
|
1203
1202
|
];
|
|
1204
1203
|
// Stream the strict args (optional_string sent as null by LLM)
|
|
1205
|
-
let result = (0,
|
|
1204
|
+
let result = (0, client_1.streamReducer)(state, {
|
|
1206
1205
|
type: "EVENT",
|
|
1207
1206
|
event: {
|
|
1208
1207
|
type: core_1.EventType.TOOL_CALL_ARGS,
|
|
@@ -1212,7 +1211,7 @@ describe("streamReducer", () => {
|
|
|
1212
1211
|
threadId: "thread_1",
|
|
1213
1212
|
});
|
|
1214
1213
|
// End the tool call with schemas attached
|
|
1215
|
-
result = (0,
|
|
1214
|
+
result = (0, client_1.streamReducer)(result, {
|
|
1216
1215
|
type: "EVENT",
|
|
1217
1216
|
event: {
|
|
1218
1217
|
type: core_1.EventType.TOOL_CALL_END,
|
|
@@ -1246,7 +1245,7 @@ describe("streamReducer", () => {
|
|
|
1246
1245
|
componentName: "WeatherCard",
|
|
1247
1246
|
},
|
|
1248
1247
|
};
|
|
1249
|
-
const result = (0,
|
|
1248
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1250
1249
|
type: "EVENT",
|
|
1251
1250
|
event,
|
|
1252
1251
|
threadId: "thread_1",
|
|
@@ -1287,7 +1286,7 @@ describe("streamReducer", () => {
|
|
|
1287
1286
|
operations: [{ op: "add", path: "/temperature", value: 72 }],
|
|
1288
1287
|
},
|
|
1289
1288
|
};
|
|
1290
|
-
const result = (0,
|
|
1289
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1291
1290
|
type: "EVENT",
|
|
1292
1291
|
event,
|
|
1293
1292
|
threadId: "thread_1",
|
|
@@ -1315,7 +1314,7 @@ describe("streamReducer", () => {
|
|
|
1315
1314
|
},
|
|
1316
1315
|
};
|
|
1317
1316
|
expect(() => {
|
|
1318
|
-
(0,
|
|
1317
|
+
(0, client_1.streamReducer)(state, {
|
|
1319
1318
|
type: "EVENT",
|
|
1320
1319
|
event,
|
|
1321
1320
|
threadId: "thread_1",
|
|
@@ -1335,7 +1334,7 @@ describe("streamReducer", () => {
|
|
|
1335
1334
|
],
|
|
1336
1335
|
},
|
|
1337
1336
|
};
|
|
1338
|
-
const result = (0,
|
|
1337
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1339
1338
|
type: "EVENT",
|
|
1340
1339
|
event,
|
|
1341
1340
|
threadId: "thread_1",
|
|
@@ -1369,7 +1368,7 @@ describe("streamReducer", () => {
|
|
|
1369
1368
|
operations: [{ op: "add", path: "/count", value: 42 }],
|
|
1370
1369
|
},
|
|
1371
1370
|
};
|
|
1372
|
-
const result = (0,
|
|
1371
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1373
1372
|
type: "EVENT",
|
|
1374
1373
|
event,
|
|
1375
1374
|
threadId: "thread_1",
|
|
@@ -1401,7 +1400,7 @@ describe("streamReducer", () => {
|
|
|
1401
1400
|
name: "tambo.component.end",
|
|
1402
1401
|
value: { componentId: "comp_1" },
|
|
1403
1402
|
};
|
|
1404
|
-
const result = (0,
|
|
1403
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1405
1404
|
type: "EVENT",
|
|
1406
1405
|
event,
|
|
1407
1406
|
threadId: "thread_1",
|
|
@@ -1435,7 +1434,7 @@ describe("streamReducer", () => {
|
|
|
1435
1434
|
},
|
|
1436
1435
|
};
|
|
1437
1436
|
// Should create the message on-demand instead of throwing
|
|
1438
|
-
const result = (0,
|
|
1437
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1439
1438
|
type: "EVENT",
|
|
1440
1439
|
event,
|
|
1441
1440
|
threadId: "thread_1",
|
|
@@ -1469,7 +1468,7 @@ describe("streamReducer", () => {
|
|
|
1469
1468
|
value: { componentId: "unknown_comp" },
|
|
1470
1469
|
};
|
|
1471
1470
|
expect(() => {
|
|
1472
|
-
(0,
|
|
1471
|
+
(0, client_1.streamReducer)(state, {
|
|
1473
1472
|
type: "EVENT",
|
|
1474
1473
|
event,
|
|
1475
1474
|
threadId: "thread_1",
|
|
@@ -1505,7 +1504,7 @@ describe("streamReducer", () => {
|
|
|
1505
1504
|
],
|
|
1506
1505
|
},
|
|
1507
1506
|
};
|
|
1508
|
-
const result = (0,
|
|
1507
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1509
1508
|
type: "EVENT",
|
|
1510
1509
|
event,
|
|
1511
1510
|
threadId: "thread_1",
|
|
@@ -1544,7 +1543,7 @@ describe("streamReducer", () => {
|
|
|
1544
1543
|
componentName: "Second",
|
|
1545
1544
|
},
|
|
1546
1545
|
};
|
|
1547
|
-
const result = (0,
|
|
1546
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1548
1547
|
type: "EVENT",
|
|
1549
1548
|
event,
|
|
1550
1549
|
threadId: "thread_1",
|
|
@@ -1588,7 +1587,7 @@ describe("streamReducer", () => {
|
|
|
1588
1587
|
operations: [{ op: "replace", path: "/value", value: 99 }],
|
|
1589
1588
|
},
|
|
1590
1589
|
};
|
|
1591
|
-
const result = (0,
|
|
1590
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1592
1591
|
type: "EVENT",
|
|
1593
1592
|
event,
|
|
1594
1593
|
threadId: "thread_1",
|
|
@@ -1610,7 +1609,7 @@ describe("streamReducer", () => {
|
|
|
1610
1609
|
threadId: "thread_1",
|
|
1611
1610
|
timestamp: 1704067200000,
|
|
1612
1611
|
};
|
|
1613
|
-
state = (0,
|
|
1612
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1614
1613
|
type: "EVENT",
|
|
1615
1614
|
event: runStarted,
|
|
1616
1615
|
threadId: "thread_1",
|
|
@@ -1621,7 +1620,7 @@ describe("streamReducer", () => {
|
|
|
1621
1620
|
messageId: "msg_1",
|
|
1622
1621
|
role: "assistant",
|
|
1623
1622
|
};
|
|
1624
|
-
state = (0,
|
|
1623
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1625
1624
|
type: "EVENT",
|
|
1626
1625
|
event: msgStart,
|
|
1627
1626
|
threadId: "thread_1",
|
|
@@ -1632,7 +1631,7 @@ describe("streamReducer", () => {
|
|
|
1632
1631
|
messageId: "msg_1",
|
|
1633
1632
|
delta: "Hello, how can I help?",
|
|
1634
1633
|
};
|
|
1635
|
-
state = (0,
|
|
1634
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1636
1635
|
type: "EVENT",
|
|
1637
1636
|
event: msgContent,
|
|
1638
1637
|
threadId: "thread_1",
|
|
@@ -1642,7 +1641,7 @@ describe("streamReducer", () => {
|
|
|
1642
1641
|
type: core_1.EventType.TEXT_MESSAGE_END,
|
|
1643
1642
|
messageId: "msg_1",
|
|
1644
1643
|
};
|
|
1645
|
-
state = (0,
|
|
1644
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1646
1645
|
type: "EVENT",
|
|
1647
1646
|
event: msgEnd,
|
|
1648
1647
|
threadId: "thread_1",
|
|
@@ -1653,7 +1652,7 @@ describe("streamReducer", () => {
|
|
|
1653
1652
|
runId: "run_1",
|
|
1654
1653
|
threadId: "thread_1",
|
|
1655
1654
|
};
|
|
1656
|
-
state = (0,
|
|
1655
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1657
1656
|
type: "EVENT",
|
|
1658
1657
|
event: runFinished,
|
|
1659
1658
|
threadId: "thread_1",
|
|
@@ -1699,7 +1698,7 @@ describe("streamReducer", () => {
|
|
|
1699
1698
|
componentName: "WeatherCard",
|
|
1700
1699
|
},
|
|
1701
1700
|
};
|
|
1702
|
-
state = (0,
|
|
1701
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1703
1702
|
type: "EVENT",
|
|
1704
1703
|
event: compStart,
|
|
1705
1704
|
threadId: "thread_1",
|
|
@@ -1713,7 +1712,7 @@ describe("streamReducer", () => {
|
|
|
1713
1712
|
operations: [{ op: "add", path: "/city", value: "New York" }],
|
|
1714
1713
|
},
|
|
1715
1714
|
};
|
|
1716
|
-
state = (0,
|
|
1715
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1717
1716
|
type: "EVENT",
|
|
1718
1717
|
event: propsDelta1,
|
|
1719
1718
|
threadId: "thread_1",
|
|
@@ -1727,7 +1726,7 @@ describe("streamReducer", () => {
|
|
|
1727
1726
|
operations: [{ op: "add", path: "/temperature", value: 72 }],
|
|
1728
1727
|
},
|
|
1729
1728
|
};
|
|
1730
|
-
state = (0,
|
|
1729
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1731
1730
|
type: "EVENT",
|
|
1732
1731
|
event: propsDelta2,
|
|
1733
1732
|
threadId: "thread_1",
|
|
@@ -1738,7 +1737,7 @@ describe("streamReducer", () => {
|
|
|
1738
1737
|
name: "tambo.component.end",
|
|
1739
1738
|
value: { componentId: "comp_1" },
|
|
1740
1739
|
};
|
|
1741
|
-
state = (0,
|
|
1740
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1742
1741
|
type: "EVENT",
|
|
1743
1742
|
event: compEnd,
|
|
1744
1743
|
threadId: "thread_1",
|
|
@@ -1782,7 +1781,7 @@ describe("streamReducer", () => {
|
|
|
1782
1781
|
toolCallId: "tool_1",
|
|
1783
1782
|
delta: '{"city":"San Francisco","units":"fahrenheit"}',
|
|
1784
1783
|
};
|
|
1785
|
-
state = (0,
|
|
1784
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1786
1785
|
type: "EVENT",
|
|
1787
1786
|
event: toolArgs,
|
|
1788
1787
|
threadId: "thread_1",
|
|
@@ -1792,7 +1791,7 @@ describe("streamReducer", () => {
|
|
|
1792
1791
|
type: core_1.EventType.TOOL_CALL_END,
|
|
1793
1792
|
toolCallId: "tool_1",
|
|
1794
1793
|
};
|
|
1795
|
-
state = (0,
|
|
1794
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1796
1795
|
type: "EVENT",
|
|
1797
1796
|
event: toolEnd,
|
|
1798
1797
|
threadId: "thread_1",
|
|
@@ -1805,7 +1804,7 @@ describe("streamReducer", () => {
|
|
|
1805
1804
|
content: "Temperature: 65°F, Sunny",
|
|
1806
1805
|
role: "tool",
|
|
1807
1806
|
};
|
|
1808
|
-
state = (0,
|
|
1807
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1809
1808
|
type: "EVENT",
|
|
1810
1809
|
event: toolResult,
|
|
1811
1810
|
threadId: "thread_1",
|
|
@@ -1847,7 +1846,7 @@ describe("streamReducer", () => {
|
|
|
1847
1846
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
1848
1847
|
timestamp: 1704067200000,
|
|
1849
1848
|
};
|
|
1850
|
-
const result = (0,
|
|
1849
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1851
1850
|
type: "EVENT",
|
|
1852
1851
|
event,
|
|
1853
1852
|
threadId: "thread_1",
|
|
@@ -1873,7 +1872,7 @@ describe("streamReducer", () => {
|
|
|
1873
1872
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
1874
1873
|
delta: "Let me think about this...",
|
|
1875
1874
|
};
|
|
1876
|
-
const result = (0,
|
|
1875
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1877
1876
|
type: "EVENT",
|
|
1878
1877
|
event,
|
|
1879
1878
|
threadId: "thread_1",
|
|
@@ -1897,7 +1896,7 @@ describe("streamReducer", () => {
|
|
|
1897
1896
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
1898
1897
|
delta: "second part",
|
|
1899
1898
|
};
|
|
1900
|
-
const result = (0,
|
|
1899
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1901
1900
|
type: "EVENT",
|
|
1902
1901
|
event,
|
|
1903
1902
|
threadId: "thread_1",
|
|
@@ -1924,7 +1923,7 @@ describe("streamReducer", () => {
|
|
|
1924
1923
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_END,
|
|
1925
1924
|
timestamp: endTime,
|
|
1926
1925
|
};
|
|
1927
|
-
const result = (0,
|
|
1926
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
1928
1927
|
type: "EVENT",
|
|
1929
1928
|
event,
|
|
1930
1929
|
threadId: "thread_1",
|
|
@@ -1947,7 +1946,7 @@ describe("streamReducer", () => {
|
|
|
1947
1946
|
const start1 = {
|
|
1948
1947
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
1949
1948
|
};
|
|
1950
|
-
state = (0,
|
|
1949
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1951
1950
|
type: "EVENT",
|
|
1952
1951
|
event: start1,
|
|
1953
1952
|
threadId: "thread_1",
|
|
@@ -1956,7 +1955,7 @@ describe("streamReducer", () => {
|
|
|
1956
1955
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
1957
1956
|
delta: "First thought",
|
|
1958
1957
|
};
|
|
1959
|
-
state = (0,
|
|
1958
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1960
1959
|
type: "EVENT",
|
|
1961
1960
|
event: content1,
|
|
1962
1961
|
threadId: "thread_1",
|
|
@@ -1964,7 +1963,7 @@ describe("streamReducer", () => {
|
|
|
1964
1963
|
const end1 = {
|
|
1965
1964
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_END,
|
|
1966
1965
|
};
|
|
1967
|
-
state = (0,
|
|
1966
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1968
1967
|
type: "EVENT",
|
|
1969
1968
|
event: end1,
|
|
1970
1969
|
threadId: "thread_1",
|
|
@@ -1973,7 +1972,7 @@ describe("streamReducer", () => {
|
|
|
1973
1972
|
const start2 = {
|
|
1974
1973
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
1975
1974
|
};
|
|
1976
|
-
state = (0,
|
|
1975
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1977
1976
|
type: "EVENT",
|
|
1978
1977
|
event: start2,
|
|
1979
1978
|
threadId: "thread_1",
|
|
@@ -1982,7 +1981,7 @@ describe("streamReducer", () => {
|
|
|
1982
1981
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
1983
1982
|
delta: "Second thought",
|
|
1984
1983
|
};
|
|
1985
|
-
state = (0,
|
|
1984
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1986
1985
|
type: "EVENT",
|
|
1987
1986
|
event: content2,
|
|
1988
1987
|
threadId: "thread_1",
|
|
@@ -1990,7 +1989,7 @@ describe("streamReducer", () => {
|
|
|
1990
1989
|
const end2 = {
|
|
1991
1990
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_END,
|
|
1992
1991
|
};
|
|
1993
|
-
state = (0,
|
|
1992
|
+
state = (0, client_1.streamReducer)(state, {
|
|
1994
1993
|
type: "EVENT",
|
|
1995
1994
|
event: end2,
|
|
1996
1995
|
threadId: "thread_1",
|
|
@@ -2014,7 +2013,7 @@ describe("streamReducer", () => {
|
|
|
2014
2013
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
2015
2014
|
delta: "Implicit start",
|
|
2016
2015
|
};
|
|
2017
|
-
const result = (0,
|
|
2016
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2018
2017
|
type: "EVENT",
|
|
2019
2018
|
event,
|
|
2020
2019
|
threadId: "thread_1",
|
|
@@ -2031,7 +2030,7 @@ describe("streamReducer", () => {
|
|
|
2031
2030
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
2032
2031
|
timestamp: 1704067200000,
|
|
2033
2032
|
};
|
|
2034
|
-
const result = (0,
|
|
2033
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2035
2034
|
type: "EVENT",
|
|
2036
2035
|
event,
|
|
2037
2036
|
threadId: "thread_1",
|
|
@@ -2059,7 +2058,7 @@ describe("streamReducer", () => {
|
|
|
2059
2058
|
const event = {
|
|
2060
2059
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
2061
2060
|
};
|
|
2062
|
-
const result = (0,
|
|
2061
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2063
2062
|
type: "EVENT",
|
|
2064
2063
|
event,
|
|
2065
2064
|
threadId: "thread_1",
|
|
@@ -2075,7 +2074,7 @@ describe("streamReducer", () => {
|
|
|
2075
2074
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
2076
2075
|
timestamp: 1704067200000,
|
|
2077
2076
|
};
|
|
2078
|
-
state = (0,
|
|
2077
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2079
2078
|
type: "EVENT",
|
|
2080
2079
|
event: thinkingStart,
|
|
2081
2080
|
threadId: "thread_1",
|
|
@@ -2084,7 +2083,7 @@ describe("streamReducer", () => {
|
|
|
2084
2083
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
2085
2084
|
delta: "Let me think about this...",
|
|
2086
2085
|
};
|
|
2087
|
-
state = (0,
|
|
2086
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2088
2087
|
type: "EVENT",
|
|
2089
2088
|
event: thinkingContent,
|
|
2090
2089
|
threadId: "thread_1",
|
|
@@ -2102,7 +2101,7 @@ describe("streamReducer", () => {
|
|
|
2102
2101
|
messageId: "msg_real_123",
|
|
2103
2102
|
role: "assistant",
|
|
2104
2103
|
};
|
|
2105
|
-
state = (0,
|
|
2104
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2106
2105
|
type: "EVENT",
|
|
2107
2106
|
event: textStart,
|
|
2108
2107
|
threadId: "thread_1",
|
|
@@ -2135,7 +2134,7 @@ describe("streamReducer", () => {
|
|
|
2135
2134
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_START,
|
|
2136
2135
|
timestamp: 1704067200000,
|
|
2137
2136
|
};
|
|
2138
|
-
state = (0,
|
|
2137
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2139
2138
|
type: "EVENT",
|
|
2140
2139
|
event: thinkingStart,
|
|
2141
2140
|
threadId: "thread_1",
|
|
@@ -2145,7 +2144,7 @@ describe("streamReducer", () => {
|
|
|
2145
2144
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_CONTENT,
|
|
2146
2145
|
delta: "Let me analyze this step by step...",
|
|
2147
2146
|
};
|
|
2148
|
-
state = (0,
|
|
2147
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2149
2148
|
type: "EVENT",
|
|
2150
2149
|
event: thinkingContent,
|
|
2151
2150
|
threadId: "thread_1",
|
|
@@ -2154,7 +2153,7 @@ describe("streamReducer", () => {
|
|
|
2154
2153
|
const thinkingEnd = {
|
|
2155
2154
|
type: core_1.EventType.THINKING_TEXT_MESSAGE_END,
|
|
2156
2155
|
};
|
|
2157
|
-
state = (0,
|
|
2156
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2158
2157
|
type: "EVENT",
|
|
2159
2158
|
event: thinkingEnd,
|
|
2160
2159
|
threadId: "thread_1",
|
|
@@ -2165,7 +2164,7 @@ describe("streamReducer", () => {
|
|
|
2165
2164
|
messageId: "msg_1",
|
|
2166
2165
|
delta: "Based on my analysis, here's what I think...",
|
|
2167
2166
|
};
|
|
2168
|
-
state = (0,
|
|
2167
|
+
state = (0, client_1.streamReducer)(state, {
|
|
2169
2168
|
type: "EVENT",
|
|
2170
2169
|
event: msgContent,
|
|
2171
2170
|
threadId: "thread_1",
|
|
@@ -2205,7 +2204,7 @@ describe("streamReducer", () => {
|
|
|
2205
2204
|
describe("LOAD_THREAD_MESSAGES action", () => {
|
|
2206
2205
|
it("loads messages into empty thread", () => {
|
|
2207
2206
|
const state = createTestStreamState("thread_1");
|
|
2208
|
-
const result = (0,
|
|
2207
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2209
2208
|
type: "LOAD_THREAD_MESSAGES",
|
|
2210
2209
|
threadId: "thread_1",
|
|
2211
2210
|
messages: [
|
|
@@ -2228,8 +2227,8 @@ describe("streamReducer", () => {
|
|
|
2228
2227
|
expect(result.threadMap.thread_1.thread.messages[1].id).toBe("msg_2");
|
|
2229
2228
|
});
|
|
2230
2229
|
it("creates thread if it does not exist", () => {
|
|
2231
|
-
const state = (0,
|
|
2232
|
-
const result = (0,
|
|
2230
|
+
const state = (0, client_1.createInitialState)();
|
|
2231
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2233
2232
|
type: "LOAD_THREAD_MESSAGES",
|
|
2234
2233
|
threadId: "new_thread",
|
|
2235
2234
|
messages: [
|
|
@@ -2256,7 +2255,7 @@ describe("streamReducer", () => {
|
|
|
2256
2255
|
createdAt: "2024-01-01T00:00:00.000Z",
|
|
2257
2256
|
},
|
|
2258
2257
|
];
|
|
2259
|
-
const result = (0,
|
|
2258
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2260
2259
|
type: "LOAD_THREAD_MESSAGES",
|
|
2261
2260
|
threadId: "thread_1",
|
|
2262
2261
|
messages: [
|
|
@@ -2294,7 +2293,7 @@ describe("streamReducer", () => {
|
|
|
2294
2293
|
createdAt: "2024-01-01T00:00:00.000Z",
|
|
2295
2294
|
},
|
|
2296
2295
|
];
|
|
2297
|
-
const result = (0,
|
|
2296
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2298
2297
|
type: "LOAD_THREAD_MESSAGES",
|
|
2299
2298
|
threadId: "thread_1",
|
|
2300
2299
|
messages: [
|
|
@@ -2315,7 +2314,7 @@ describe("streamReducer", () => {
|
|
|
2315
2314
|
const state = createTestStreamState("thread_1");
|
|
2316
2315
|
state.threadMap.thread_1.streaming.status = "streaming";
|
|
2317
2316
|
state.threadMap.thread_1.thread.messages = [];
|
|
2318
|
-
const result = (0,
|
|
2317
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2319
2318
|
type: "LOAD_THREAD_MESSAGES",
|
|
2320
2319
|
threadId: "thread_1",
|
|
2321
2320
|
messages: [
|
|
@@ -2340,7 +2339,7 @@ describe("streamReducer", () => {
|
|
|
2340
2339
|
createdAt: "2024-01-01T00:00:02.000Z",
|
|
2341
2340
|
},
|
|
2342
2341
|
];
|
|
2343
|
-
const result = (0,
|
|
2342
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2344
2343
|
type: "LOAD_THREAD_MESSAGES",
|
|
2345
2344
|
threadId: "thread_1",
|
|
2346
2345
|
messages: [
|
|
@@ -2367,7 +2366,7 @@ describe("streamReducer", () => {
|
|
|
2367
2366
|
it("handles messages without createdAt (places them at the end)", () => {
|
|
2368
2367
|
const state = createTestStreamState("thread_1");
|
|
2369
2368
|
state.threadMap.thread_1.thread.messages = [];
|
|
2370
|
-
const result = (0,
|
|
2369
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2371
2370
|
type: "LOAD_THREAD_MESSAGES",
|
|
2372
2371
|
threadId: "thread_1",
|
|
2373
2372
|
messages: [
|
|
@@ -2392,7 +2391,7 @@ describe("streamReducer", () => {
|
|
|
2392
2391
|
});
|
|
2393
2392
|
it("sets streamingState to 'done' on component content blocks without streamingState", () => {
|
|
2394
2393
|
const state = createTestStreamState("thread_1");
|
|
2395
|
-
const result = (0,
|
|
2394
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2396
2395
|
type: "LOAD_THREAD_MESSAGES",
|
|
2397
2396
|
threadId: "thread_1",
|
|
2398
2397
|
messages: [
|
|
@@ -2423,7 +2422,7 @@ describe("streamReducer", () => {
|
|
|
2423
2422
|
it("overwrites non-done streamingState and warns", () => {
|
|
2424
2423
|
const state = createTestStreamState("thread_1");
|
|
2425
2424
|
const warnSpy = jest.spyOn(console, "warn").mockImplementation();
|
|
2426
|
-
const result = (0,
|
|
2425
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2427
2426
|
type: "LOAD_THREAD_MESSAGES",
|
|
2428
2427
|
threadId: "thread_1",
|
|
2429
2428
|
messages: [
|
|
@@ -2453,7 +2452,7 @@ describe("streamReducer", () => {
|
|
|
2453
2452
|
it("does not modify lastCompletedRunId", () => {
|
|
2454
2453
|
const state = createTestStreamState("thread_1");
|
|
2455
2454
|
state.threadMap.thread_1.lastCompletedRunId = "run_existing";
|
|
2456
|
-
const result = (0,
|
|
2455
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2457
2456
|
type: "LOAD_THREAD_MESSAGES",
|
|
2458
2457
|
threadId: "thread_1",
|
|
2459
2458
|
messages: [],
|
|
@@ -2462,7 +2461,7 @@ describe("streamReducer", () => {
|
|
|
2462
2461
|
});
|
|
2463
2462
|
it("handles system role messages from API", () => {
|
|
2464
2463
|
const state = createTestStreamState("thread_1");
|
|
2465
|
-
const result = (0,
|
|
2464
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2466
2465
|
type: "LOAD_THREAD_MESSAGES",
|
|
2467
2466
|
threadId: "thread_1",
|
|
2468
2467
|
messages: [
|
|
@@ -2488,7 +2487,7 @@ describe("streamReducer", () => {
|
|
|
2488
2487
|
describe("SET_LAST_COMPLETED_RUN_ID action", () => {
|
|
2489
2488
|
it("stores lastCompletedRunId on an existing thread", () => {
|
|
2490
2489
|
const state = createTestStreamState("thread_1");
|
|
2491
|
-
const result = (0,
|
|
2490
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2492
2491
|
type: "SET_LAST_COMPLETED_RUN_ID",
|
|
2493
2492
|
threadId: "thread_1",
|
|
2494
2493
|
lastCompletedRunId: "run_xyz",
|
|
@@ -2498,7 +2497,7 @@ describe("streamReducer", () => {
|
|
|
2498
2497
|
it("overwrites existing lastCompletedRunId", () => {
|
|
2499
2498
|
const state = createTestStreamState("thread_1");
|
|
2500
2499
|
state.threadMap.thread_1.lastCompletedRunId = "run_old";
|
|
2501
|
-
const result = (0,
|
|
2500
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2502
2501
|
type: "SET_LAST_COMPLETED_RUN_ID",
|
|
2503
2502
|
threadId: "thread_1",
|
|
2504
2503
|
lastCompletedRunId: "run_new",
|
|
@@ -2507,7 +2506,7 @@ describe("streamReducer", () => {
|
|
|
2507
2506
|
});
|
|
2508
2507
|
it("creates thread state if thread does not exist", () => {
|
|
2509
2508
|
const state = createTestStreamState("thread_1");
|
|
2510
|
-
const result = (0,
|
|
2509
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2511
2510
|
type: "SET_LAST_COMPLETED_RUN_ID",
|
|
2512
2511
|
threadId: "thread_new",
|
|
2513
2512
|
lastCompletedRunId: "run_abc",
|
|
@@ -2519,7 +2518,7 @@ describe("streamReducer", () => {
|
|
|
2519
2518
|
describe("UPDATE_THREAD_NAME action", () => {
|
|
2520
2519
|
it("updates the name on an existing thread", () => {
|
|
2521
2520
|
const state = createTestStreamState("thread_1");
|
|
2522
|
-
const result = (0,
|
|
2521
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2523
2522
|
type: "UPDATE_THREAD_NAME",
|
|
2524
2523
|
threadId: "thread_1",
|
|
2525
2524
|
name: "My Chat Thread",
|
|
@@ -2528,7 +2527,7 @@ describe("streamReducer", () => {
|
|
|
2528
2527
|
});
|
|
2529
2528
|
it("returns unchanged state when thread does not exist", () => {
|
|
2530
2529
|
const state = createTestStreamState("thread_1");
|
|
2531
|
-
const result = (0,
|
|
2530
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2532
2531
|
type: "UPDATE_THREAD_NAME",
|
|
2533
2532
|
threadId: "nonexistent_thread",
|
|
2534
2533
|
name: "My Chat Thread",
|
|
@@ -2545,7 +2544,7 @@ describe("streamReducer", () => {
|
|
|
2545
2544
|
createdAt: "2024-01-01T00:00:00.000Z",
|
|
2546
2545
|
},
|
|
2547
2546
|
];
|
|
2548
|
-
const result = (0,
|
|
2547
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2549
2548
|
type: "UPDATE_THREAD_NAME",
|
|
2550
2549
|
threadId: "thread_1",
|
|
2551
2550
|
name: "My Chat Thread",
|
|
@@ -2566,7 +2565,7 @@ describe("streamReducer", () => {
|
|
|
2566
2565
|
parentMessageId: "msg_parent",
|
|
2567
2566
|
},
|
|
2568
2567
|
};
|
|
2569
|
-
const result = (0,
|
|
2568
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2570
2569
|
type: "EVENT",
|
|
2571
2570
|
event,
|
|
2572
2571
|
threadId: "thread_1",
|
|
@@ -2596,7 +2595,7 @@ describe("streamReducer", () => {
|
|
|
2596
2595
|
parentMessageId: "msg_parent",
|
|
2597
2596
|
},
|
|
2598
2597
|
};
|
|
2599
|
-
const result = (0,
|
|
2598
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2600
2599
|
type: "EVENT",
|
|
2601
2600
|
event,
|
|
2602
2601
|
threadId: "thread_1",
|
|
@@ -2623,7 +2622,7 @@ describe("streamReducer", () => {
|
|
|
2623
2622
|
parentMessageId: "msg_parent",
|
|
2624
2623
|
},
|
|
2625
2624
|
};
|
|
2626
|
-
const afterParent = (0,
|
|
2625
|
+
const afterParent = (0, client_1.streamReducer)(state, {
|
|
2627
2626
|
type: "EVENT",
|
|
2628
2627
|
event: parentEvent,
|
|
2629
2628
|
threadId: "thread_1",
|
|
@@ -2634,7 +2633,7 @@ describe("streamReducer", () => {
|
|
|
2634
2633
|
messageId: "msg_child",
|
|
2635
2634
|
role: "assistant",
|
|
2636
2635
|
};
|
|
2637
|
-
const result = (0,
|
|
2636
|
+
const result = (0, client_1.streamReducer)(afterParent, {
|
|
2638
2637
|
type: "EVENT",
|
|
2639
2638
|
event: textStartEvent,
|
|
2640
2639
|
threadId: "thread_1",
|
|
@@ -2648,7 +2647,7 @@ describe("streamReducer", () => {
|
|
|
2648
2647
|
});
|
|
2649
2648
|
it("preserves parentMessageId through LOAD_THREAD_MESSAGES", () => {
|
|
2650
2649
|
const state = createTestStreamState("thread_1");
|
|
2651
|
-
const result = (0,
|
|
2650
|
+
const result = (0, client_1.streamReducer)(state, {
|
|
2652
2651
|
type: "LOAD_THREAD_MESSAGES",
|
|
2653
2652
|
threadId: "thread_1",
|
|
2654
2653
|
messages: [
|