@ekairos/thread 1.22.16-beta.feature-core-thread-registry-sync.0 → 1.22.18-beta.feature-core-thread-registry-sync.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.
@@ -2,28 +2,36 @@ export type Transition<From extends string, To extends string> = {
2
2
  from: From;
3
3
  to: To;
4
4
  };
5
- export declare const THREAD_STATUSES: readonly ["open", "streaming", "closed", "failed"];
5
+ export declare const THREAD_STATUSES: readonly ["idle", "streaming"];
6
6
  export type ThreadThreadStatus = (typeof THREAD_STATUSES)[number];
7
- export declare const THREAD_CONTEXT_STATUSES: readonly ["open", "streaming", "closed"];
7
+ export declare const THREAD_CONTEXT_STATUSES: readonly ["open", "closed"];
8
8
  export type ThreadContextStatus = (typeof THREAD_CONTEXT_STATUSES)[number];
9
9
  export declare const THREAD_EXECUTION_STATUSES: readonly ["executing", "completed", "failed"];
10
10
  export type ThreadExecutionStatus = (typeof THREAD_EXECUTION_STATUSES)[number];
11
11
  export declare const THREAD_STEP_STATUSES: readonly ["running", "completed", "failed"];
12
12
  export type ThreadStepStatus = (typeof THREAD_STEP_STATUSES)[number];
13
+ export declare const THREAD_STEP_KINDS: readonly ["message", "action_execute", "action_result"];
14
+ export type ThreadStepKind = (typeof THREAD_STEP_KINDS)[number];
13
15
  export declare const THREAD_ITEM_STATUSES: readonly ["stored", "pending", "completed"];
14
16
  export type ThreadItemStatus = (typeof THREAD_ITEM_STATUSES)[number];
15
- export declare const THREAD_ITEM_TYPES: readonly ["input_text", "output_text", "ekairos:system"];
17
+ export declare const THREAD_ITEM_TYPES: readonly ["input", "output"];
16
18
  export type ThreadItemType = (typeof THREAD_ITEM_TYPES)[number];
17
19
  export declare const THREAD_CHANNELS: readonly ["web", "whatsapp", "email"];
18
20
  export type ThreadChannel = (typeof THREAD_CHANNELS)[number];
19
21
  export declare const THREAD_TRACE_EVENT_KINDS: readonly ["workflow.run", "workflow.step", "thread.run", "thread.context", "thread.execution", "thread.item", "thread.review", "thread.step", "thread.part", "thread.llm"];
20
22
  export type ThreadTraceEventKind = (typeof THREAD_TRACE_EVENT_KINDS)[number];
21
- export declare const THREAD_STREAM_CHUNK_TYPES: readonly ["data-context-id", "data-context-substate", "data-thread-ping", "tool-output-available", "tool-output-error", "finish"];
23
+ export declare const THREAD_STREAM_LIFECYCLE_CHUNK_TYPES: readonly ["chunk.start", "chunk.start_step", "chunk.finish_step", "chunk.finish"];
24
+ export declare const THREAD_STREAM_TEXT_CHUNK_TYPES: readonly ["chunk.text_start", "chunk.text_delta", "chunk.text_end"];
25
+ export declare const THREAD_STREAM_REASONING_CHUNK_TYPES: readonly ["chunk.reasoning_start", "chunk.reasoning_delta", "chunk.reasoning_end"];
26
+ export declare const THREAD_STREAM_ACTION_CHUNK_TYPES: readonly ["chunk.action_input_start", "chunk.action_input_delta", "chunk.action_input_available", "chunk.action_output_available", "chunk.action_output_error"];
27
+ export declare const THREAD_STREAM_SOURCE_CHUNK_TYPES: readonly ["chunk.source_url", "chunk.source_document", "chunk.file"];
28
+ export declare const THREAD_STREAM_METADATA_CHUNK_TYPES: readonly ["chunk.message_metadata", "chunk.response_metadata"];
29
+ export declare const THREAD_STREAM_ERROR_CHUNK_TYPES: readonly ["chunk.error", "chunk.unknown"];
30
+ export declare const THREAD_STREAM_CHUNK_TYPES: readonly ["chunk.start", "chunk.start_step", "chunk.finish_step", "chunk.finish", "chunk.text_start", "chunk.text_delta", "chunk.text_end", "chunk.reasoning_start", "chunk.reasoning_delta", "chunk.reasoning_end", "chunk.action_input_start", "chunk.action_input_delta", "chunk.action_input_available", "chunk.action_output_available", "chunk.action_output_error", "chunk.source_url", "chunk.source_document", "chunk.file", "chunk.message_metadata", "chunk.response_metadata", "chunk.error", "chunk.unknown"];
22
31
  export type ThreadStreamChunkType = (typeof THREAD_STREAM_CHUNK_TYPES)[number];
23
- export declare const THREAD_CONTEXT_SUBSTATE_KEYS: readonly ["actions"];
24
- export type ThreadContextSubstateKey = (typeof THREAD_CONTEXT_SUBSTATE_KEYS)[number];
25
- export type ThreadTransition = Transition<"open" | "streaming" | "failed", "open" | "streaming" | "closed" | "failed">;
26
- export type ContextTransition = Transition<"open" | "streaming", "streaming" | "open" | "closed">;
32
+ export declare function isThreadStreamChunkType(value: string): value is ThreadStreamChunkType;
33
+ export type ThreadTransition = Transition<"idle" | "streaming", "idle" | "streaming">;
34
+ export type ContextTransition = Transition<"open" | "closed", "open" | "closed">;
27
35
  export type ExecutionTransition = Transition<"executing", "completed" | "failed">;
28
36
  export type StepTransition = Transition<"running", "completed" | "failed">;
29
37
  export type ItemTransition = Transition<"stored" | "pending", "pending" | "completed">;
@@ -1,9 +1,17 @@
1
- export const THREAD_STATUSES = ["open", "streaming", "closed", "failed"];
2
- export const THREAD_CONTEXT_STATUSES = ["open", "streaming", "closed"];
1
+ export const THREAD_STATUSES = ["idle", "streaming"];
2
+ export const THREAD_CONTEXT_STATUSES = ["open", "closed"];
3
3
  export const THREAD_EXECUTION_STATUSES = ["executing", "completed", "failed"];
4
4
  export const THREAD_STEP_STATUSES = ["running", "completed", "failed"];
5
+ export const THREAD_STEP_KINDS = [
6
+ "message",
7
+ "action_execute",
8
+ "action_result",
9
+ ];
5
10
  export const THREAD_ITEM_STATUSES = ["stored", "pending", "completed"];
6
- export const THREAD_ITEM_TYPES = ["input_text", "output_text", "ekairos:system"];
11
+ export const THREAD_ITEM_TYPES = [
12
+ "input",
13
+ "output",
14
+ ];
7
15
  export const THREAD_CHANNELS = ["web", "whatsapp", "email"];
8
16
  export const THREAD_TRACE_EVENT_KINDS = [
9
17
  "workflow.run",
@@ -17,27 +25,61 @@ export const THREAD_TRACE_EVENT_KINDS = [
17
25
  "thread.part",
18
26
  "thread.llm",
19
27
  ];
28
+ export const THREAD_STREAM_LIFECYCLE_CHUNK_TYPES = [
29
+ "chunk.start",
30
+ "chunk.start_step",
31
+ "chunk.finish_step",
32
+ "chunk.finish",
33
+ ];
34
+ export const THREAD_STREAM_TEXT_CHUNK_TYPES = [
35
+ "chunk.text_start",
36
+ "chunk.text_delta",
37
+ "chunk.text_end",
38
+ ];
39
+ export const THREAD_STREAM_REASONING_CHUNK_TYPES = [
40
+ "chunk.reasoning_start",
41
+ "chunk.reasoning_delta",
42
+ "chunk.reasoning_end",
43
+ ];
44
+ export const THREAD_STREAM_ACTION_CHUNK_TYPES = [
45
+ "chunk.action_input_start",
46
+ "chunk.action_input_delta",
47
+ "chunk.action_input_available",
48
+ "chunk.action_output_available",
49
+ "chunk.action_output_error",
50
+ ];
51
+ export const THREAD_STREAM_SOURCE_CHUNK_TYPES = [
52
+ "chunk.source_url",
53
+ "chunk.source_document",
54
+ "chunk.file",
55
+ ];
56
+ export const THREAD_STREAM_METADATA_CHUNK_TYPES = [
57
+ "chunk.message_metadata",
58
+ "chunk.response_metadata",
59
+ ];
60
+ export const THREAD_STREAM_ERROR_CHUNK_TYPES = [
61
+ "chunk.error",
62
+ "chunk.unknown",
63
+ ];
20
64
  export const THREAD_STREAM_CHUNK_TYPES = [
21
- "data-context-id",
22
- "data-context-substate",
23
- "data-thread-ping",
24
- "tool-output-available",
25
- "tool-output-error",
26
- "finish",
27
- ];
28
- export const THREAD_CONTEXT_SUBSTATE_KEYS = ["actions"];
65
+ ...THREAD_STREAM_LIFECYCLE_CHUNK_TYPES,
66
+ ...THREAD_STREAM_TEXT_CHUNK_TYPES,
67
+ ...THREAD_STREAM_REASONING_CHUNK_TYPES,
68
+ ...THREAD_STREAM_ACTION_CHUNK_TYPES,
69
+ ...THREAD_STREAM_SOURCE_CHUNK_TYPES,
70
+ ...THREAD_STREAM_METADATA_CHUNK_TYPES,
71
+ ...THREAD_STREAM_ERROR_CHUNK_TYPES,
72
+ ];
73
+ export function isThreadStreamChunkType(value) {
74
+ return THREAD_STREAM_CHUNK_TYPES.includes(value);
75
+ }
29
76
  export const THREAD_THREAD_TRANSITIONS = [
30
- { from: "open", to: "streaming" },
31
- { from: "streaming", to: "open" },
32
- { from: "streaming", to: "closed" },
33
- { from: "streaming", to: "failed" },
34
- { from: "failed", to: "open" },
77
+ { from: "idle", to: "streaming" },
78
+ { from: "streaming", to: "idle" },
35
79
  ];
36
80
  export const THREAD_CONTEXT_TRANSITIONS = [
37
- { from: "open", to: "streaming" },
38
- { from: "streaming", to: "open" },
39
81
  { from: "open", to: "closed" },
40
- { from: "streaming", to: "closed" },
82
+ { from: "closed", to: "open" },
41
83
  ];
42
84
  export const THREAD_EXECUTION_TRANSITIONS = [
43
85
  { from: "executing", to: "completed" },
package/dist/thread.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Thread, type ThreadOptions, type ThreadStreamOptions, type ShouldContinue, type ThreadShouldContinueArgs, } from "./thread.engine.js";
2
2
  export { thread, createThread, type ThreadConfig, type ThreadInstance, type RegistrableThreadBuilder, } from "./thread.builder.js";
3
- export { createAiSdkReactor, createScriptedReactor, type CreateAiSdkReactorOptions, type CreateScriptedReactorOptions, type ScriptedReactorStep, type ThreadReactor, type ThreadReactorParams, type ThreadReactionResult, type ThreadReactionToolCall, type ThreadReactionLLM, } from "./thread.reactor.js";
3
+ export { createAiSdkReactor, createScriptedReactor, type CreateAiSdkReactorOptions, type CreateScriptedReactorOptions, type ScriptedReactorStep, type ThreadReactor, type ThreadReactorParams, type ThreadReactionResult, type ThreadActionRequest, type ThreadReactionLLM, } from "./thread.reactor.js";
@@ -13,12 +13,8 @@ export interface ThreadOptions<Context = any, Env extends ThreadEnvironment = Th
13
13
  context: StoredContext<Context>;
14
14
  }) => void | Promise<void>;
15
15
  onEventCreated?: (event: ThreadItem) => void | Promise<void>;
16
- onToolCallExecuted?: (executionEvent: any) => void | Promise<void>;
17
- onEnd?: (lastEvent: ThreadItem) => void | {
18
- end?: boolean;
19
- } | Promise<void | {
20
- end?: boolean;
21
- }>;
16
+ onActionExecuted?: (executionEvent: any) => void | Promise<void>;
17
+ onEnd?: (lastEvent: ThreadItem) => void | boolean | Promise<void | boolean>;
22
18
  }
23
19
  export interface ThreadStreamOptions {
24
20
  /**
@@ -134,9 +130,17 @@ export type ThreadShouldContinueArgs<Context = any, Env extends ThreadEnvironmen
134
130
  */
135
131
  reactionEvent: ThreadItem;
136
132
  assistantEvent: ThreadItem;
137
- toolCalls: any[];
138
- toolExecutionResults: Array<{
139
- tc: any;
133
+ actionRequests: Array<{
134
+ actionRef: string;
135
+ actionName: string;
136
+ input: unknown;
137
+ }>;
138
+ actionResults: Array<{
139
+ actionRequest: {
140
+ actionRef: string;
141
+ actionName: string;
142
+ input: unknown;
143
+ };
140
144
  success: boolean;
141
145
  output: any;
142
146
  errorText?: string;