@simulacra-ai/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/README.md +232 -0
- package/dist/checkpoints/default-summarization-strategy.d.ts +13 -0
- package/dist/checkpoints/default-summarization-strategy.d.ts.map +1 -0
- package/dist/checkpoints/default-summarization-strategy.js +63 -0
- package/dist/checkpoints/default-summarization-strategy.js.map +1 -0
- package/dist/checkpoints/index.d.ts +3 -0
- package/dist/checkpoints/index.d.ts.map +1 -0
- package/dist/checkpoints/index.js +3 -0
- package/dist/checkpoints/index.js.map +1 -0
- package/dist/checkpoints/types.d.ts +32 -0
- package/dist/checkpoints/types.d.ts.map +1 -0
- package/dist/checkpoints/types.js +2 -0
- package/dist/checkpoints/types.js.map +1 -0
- package/dist/context-transformers/checkpoint-context-transformer.d.ts +13 -0
- package/dist/context-transformers/checkpoint-context-transformer.d.ts.map +1 -0
- package/dist/context-transformers/checkpoint-context-transformer.js +32 -0
- package/dist/context-transformers/checkpoint-context-transformer.js.map +1 -0
- package/dist/context-transformers/composite-context-transformer.d.ts +31 -0
- package/dist/context-transformers/composite-context-transformer.d.ts.map +1 -0
- package/dist/context-transformers/composite-context-transformer.js +41 -0
- package/dist/context-transformers/composite-context-transformer.js.map +1 -0
- package/dist/context-transformers/index.d.ts +6 -0
- package/dist/context-transformers/index.d.ts.map +1 -0
- package/dist/context-transformers/index.js +6 -0
- package/dist/context-transformers/index.js.map +1 -0
- package/dist/context-transformers/noop-context-transformer.d.ts +24 -0
- package/dist/context-transformers/noop-context-transformer.d.ts.map +1 -0
- package/dist/context-transformers/noop-context-transformer.js +26 -0
- package/dist/context-transformers/noop-context-transformer.js.map +1 -0
- package/dist/context-transformers/tool-context-transformer.d.ts +26 -0
- package/dist/context-transformers/tool-context-transformer.d.ts.map +1 -0
- package/dist/context-transformers/tool-context-transformer.js +52 -0
- package/dist/context-transformers/tool-context-transformer.js.map +1 -0
- package/dist/context-transformers/types.d.ts +65 -0
- package/dist/context-transformers/types.d.ts.map +1 -0
- package/dist/context-transformers/types.js +2 -0
- package/dist/context-transformers/types.js.map +1 -0
- package/dist/conversations/conversation.d.ts +146 -0
- package/dist/conversations/conversation.d.ts.map +1 -0
- package/dist/conversations/conversation.js +642 -0
- package/dist/conversations/conversation.js.map +1 -0
- package/dist/conversations/index.d.ts +5 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +5 -0
- package/dist/conversations/index.js.map +1 -0
- package/dist/conversations/stream-listener.d.ts +37 -0
- package/dist/conversations/stream-listener.d.ts.map +1 -0
- package/dist/conversations/stream-listener.js +68 -0
- package/dist/conversations/stream-listener.js.map +1 -0
- package/dist/conversations/token-tracker.d.ts +59 -0
- package/dist/conversations/token-tracker.d.ts.map +1 -0
- package/dist/conversations/token-tracker.js +98 -0
- package/dist/conversations/token-tracker.js.map +1 -0
- package/dist/conversations/types.d.ts +346 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/conversations/types.js +2 -0
- package/dist/conversations/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/policies/composite-policy.d.ts +29 -0
- package/dist/policies/composite-policy.d.ts.map +1 -0
- package/dist/policies/composite-policy.js +77 -0
- package/dist/policies/composite-policy.js.map +1 -0
- package/dist/policies/default-policy.d.ts +7 -0
- package/dist/policies/default-policy.d.ts.map +1 -0
- package/dist/policies/default-policy.js +14 -0
- package/dist/policies/default-policy.js.map +1 -0
- package/dist/policies/index.d.ts +8 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +8 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/noop-policy.d.ts +21 -0
- package/dist/policies/noop-policy.d.ts.map +1 -0
- package/dist/policies/noop-policy.js +36 -0
- package/dist/policies/noop-policy.js.map +1 -0
- package/dist/policies/rate-limit-policy.d.ts +44 -0
- package/dist/policies/rate-limit-policy.d.ts.map +1 -0
- package/dist/policies/rate-limit-policy.js +98 -0
- package/dist/policies/rate-limit-policy.js.map +1 -0
- package/dist/policies/retry-policy.d.ts +42 -0
- package/dist/policies/retry-policy.d.ts.map +1 -0
- package/dist/policies/retry-policy.js +114 -0
- package/dist/policies/retry-policy.js.map +1 -0
- package/dist/policies/token-limit-policy.d.ts +76 -0
- package/dist/policies/token-limit-policy.d.ts.map +1 -0
- package/dist/policies/token-limit-policy.js +134 -0
- package/dist/policies/token-limit-policy.js.map +1 -0
- package/dist/policies/types.d.ts +49 -0
- package/dist/policies/types.d.ts.map +1 -0
- package/dist/policies/types.js +9 -0
- package/dist/policies/types.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/types.d.ts +180 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/utils/async.d.ts +125 -0
- package/dist/utils/async.d.ts.map +1 -0
- package/dist/utils/async.js +217 -0
- package/dist/utils/async.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/object.d.ts +80 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +189 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils/types.d.ts +17 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/workflows/index.d.ts +4 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +4 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types.d.ts +70 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +2 -0
- package/dist/workflows/types.js.map +1 -0
- package/dist/workflows/workflow-manager.d.ts +74 -0
- package/dist/workflows/workflow-manager.d.ts.map +1 -0
- package/dist/workflows/workflow-manager.js +165 -0
- package/dist/workflows/workflow-manager.js.map +1 -0
- package/dist/workflows/workflow.d.ts +116 -0
- package/dist/workflows/workflow.d.ts.map +1 -0
- package/dist/workflows/workflow.js +351 -0
- package/dist/workflows/workflow.js.map +1 -0
- package/package.json +20 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context transformer that removes unreferenced tool invocations from message history.
|
|
3
|
+
*
|
|
4
|
+
* Filters out tool content blocks that don't have a corresponding tool_result,
|
|
5
|
+
* reducing context size when tools were invoked but their results are no longer
|
|
6
|
+
* relevant to the conversation.
|
|
7
|
+
*/
|
|
8
|
+
export class ToolContextTransformer {
|
|
9
|
+
/**
|
|
10
|
+
* Transforms prompt messages by removing unreferenced tool invocations.
|
|
11
|
+
*
|
|
12
|
+
* @param messages - The messages to transform.
|
|
13
|
+
* @returns A promise that resolves to the transformed messages.
|
|
14
|
+
*/
|
|
15
|
+
transform_prompt(messages) {
|
|
16
|
+
const tool_ids = [];
|
|
17
|
+
const message_context = [];
|
|
18
|
+
for (const message of messages.toReversed()) {
|
|
19
|
+
tool_ids.push(...message.content.filter((c) => c.type === "tool_result").map((c) => c.tool_request_id));
|
|
20
|
+
const cleaned_message = {
|
|
21
|
+
...message,
|
|
22
|
+
content: message.content.filter((c) => c.type !== "tool" || tool_ids.includes(c.tool_request_id)),
|
|
23
|
+
};
|
|
24
|
+
if (cleaned_message.content.length) {
|
|
25
|
+
message_context.unshift(cleaned_message);
|
|
26
|
+
}
|
|
27
|
+
else if (message.role === "assistant") {
|
|
28
|
+
message_context.unshift({
|
|
29
|
+
...message,
|
|
30
|
+
content: [{ type: "text", text: "" }],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (message.role === "user") {
|
|
34
|
+
message_context.unshift({
|
|
35
|
+
...message,
|
|
36
|
+
content: [{ type: "text", text: "" }],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Promise.resolve(message_context);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the completion message unchanged.
|
|
44
|
+
*
|
|
45
|
+
* @param message - The assistant message to pass through.
|
|
46
|
+
* @returns A promise that resolves to the same message.
|
|
47
|
+
*/
|
|
48
|
+
transform_completion(message) {
|
|
49
|
+
return Promise.resolve(message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=tool-context-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context-transformer.js","sourceRoot":"","sources":["../../src/context-transformers/tool-context-transformer.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IACjC;;;;;OAKG;IACH,gBAAgB,CAAC,QAAmB;QAClC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,eAAe,GAAc,EAAE,CAAC;QAEtC,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CACX,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CACzF,CAAC;YACF,MAAM,eAAe,GAAG;gBACtB,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CACjE;aACF,CAAC;YACF,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnC,eAAe,CAAC,OAAO,CAAC,eAA0B,CAAC,CAAC;YACtD,CAAC;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxC,eAAe,CAAC,OAAO,CAAC;oBACtB,GAAG,OAAO;oBACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;iBAC3B,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACnC,eAAe,CAAC,OAAO,CAAC;oBACtB,GAAG,OAAO;oBACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;iBAC3B,CAAC,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,OAAyB;QAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AssistantMessage, Message } from "../conversations/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The active checkpoint state for a conversation.
|
|
4
|
+
*/
|
|
5
|
+
export interface CheckpointState {
|
|
6
|
+
/** The ID of the last message included in the checkpoint. */
|
|
7
|
+
message_id: string;
|
|
8
|
+
/** The condensed summary produced by the checkpoint model call. */
|
|
9
|
+
summary: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Additional context passed to transformers alongside messages.
|
|
13
|
+
*/
|
|
14
|
+
export interface TransformContext {
|
|
15
|
+
/** The active checkpoint, if any. */
|
|
16
|
+
checkpoint?: CheckpointState;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface for transforming conversation context before and after model requests.
|
|
20
|
+
*
|
|
21
|
+
* Context transformers can modify messages before they are sent to the model
|
|
22
|
+
* and transform assistant responses before they are added to conversation history.
|
|
23
|
+
*/
|
|
24
|
+
export interface ContextTransformer {
|
|
25
|
+
/**
|
|
26
|
+
* Transforms the prompt messages before sending to the model.
|
|
27
|
+
*
|
|
28
|
+
* @param messages - The messages to transform.
|
|
29
|
+
* @param context - Additional context such as checkpoint state.
|
|
30
|
+
* @returns A promise that resolves to the transformed messages.
|
|
31
|
+
*/
|
|
32
|
+
transform_prompt(messages: Message[], context?: TransformContext): Promise<Message[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Transforms the assistant's completion message before adding to history.
|
|
35
|
+
*
|
|
36
|
+
* @param message - The assistant message to transform.
|
|
37
|
+
* @returns A promise that resolves to the transformed message.
|
|
38
|
+
*/
|
|
39
|
+
transform_completion(message: AssistantMessage): Promise<AssistantMessage>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Interface for provider-level context transformers.
|
|
43
|
+
*
|
|
44
|
+
* Provider transformers normalize provider-specific quirks at the wire level.
|
|
45
|
+
* They run before conversation-level transformers and do not receive
|
|
46
|
+
* conversation context (checkpoints, etc.). Both methods are optional —
|
|
47
|
+
* most provider transformers only need one direction.
|
|
48
|
+
*/
|
|
49
|
+
export interface ProviderContextTransformer {
|
|
50
|
+
/**
|
|
51
|
+
* Transforms prompt messages before sending to the model.
|
|
52
|
+
*
|
|
53
|
+
* @param messages - The messages to transform.
|
|
54
|
+
* @returns A promise that resolves to the transformed messages.
|
|
55
|
+
*/
|
|
56
|
+
transform_prompt?(messages: Message[]): Promise<Message[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Transforms the assistant's completion message before adding to history.
|
|
59
|
+
*
|
|
60
|
+
* @param message - The assistant message to transform.
|
|
61
|
+
* @returns A promise that resolves to the transformed message.
|
|
62
|
+
*/
|
|
63
|
+
transform_completion?(message: AssistantMessage): Promise<AssistantMessage>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context-transformers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEtF;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC5E;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,gBAAgB,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/context-transformers/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { CheckpointState, ContextTransformer } from "../context-transformers/types.ts";
|
|
2
|
+
import type { CheckpointConfig, SummarizationStrategy } from "../checkpoints/types.ts";
|
|
3
|
+
import type { ToolClass } from "../tools/types.ts";
|
|
4
|
+
import type { Policy } from "../policies/types.ts";
|
|
5
|
+
import { ConversationEvents, ConversationState, Message, ModelProvider, PromptRequestData, UserContent } from "./types.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Manages a conversation with a language model.
|
|
8
|
+
*
|
|
9
|
+
* The Conversation class handles message exchange, tool execution coordination,
|
|
10
|
+
* event emission, and state management for interactions with language models.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Conversation {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new conversation instance.
|
|
16
|
+
*
|
|
17
|
+
* @param provider - The model provider for executing requests.
|
|
18
|
+
* @param policy - The policy for controlling request execution (default: retry + rate limiting).
|
|
19
|
+
* @param context_transformer - Transformer for modifying messages before sending (default: noop).
|
|
20
|
+
* @param summarization_strategy - Strategy for generating checkpoint summaries (default: DefaultSummarizationStrategy).
|
|
21
|
+
*/
|
|
22
|
+
constructor(provider: ModelProvider, policy?: Policy, context_transformer?: ContextTransformer, summarization_strategy?: SummarizationStrategy);
|
|
23
|
+
/**
|
|
24
|
+
* The unique identifier for this conversation.
|
|
25
|
+
*/
|
|
26
|
+
get id(): string;
|
|
27
|
+
set id(value: string);
|
|
28
|
+
/**
|
|
29
|
+
* The current state of the conversation.
|
|
30
|
+
*/
|
|
31
|
+
get state(): ConversationState;
|
|
32
|
+
/**
|
|
33
|
+
* The system prompt for this conversation.
|
|
34
|
+
*/
|
|
35
|
+
get system(): string | undefined;
|
|
36
|
+
set system(value: string | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* The collection of tools available to the model in this conversation.
|
|
39
|
+
*/
|
|
40
|
+
get toolkit(): Readonly<ToolClass[]>;
|
|
41
|
+
set toolkit(value: ToolClass[]);
|
|
42
|
+
/**
|
|
43
|
+
* The conversation message history.
|
|
44
|
+
*/
|
|
45
|
+
get messages(): Readonly<Readonly<Message>[]>;
|
|
46
|
+
/**
|
|
47
|
+
* The most recent checkpoint state, if any.
|
|
48
|
+
*/
|
|
49
|
+
get checkpoint_state(): Readonly<CheckpointState> | undefined;
|
|
50
|
+
set checkpoint_state(value: CheckpointState | undefined);
|
|
51
|
+
/**
|
|
52
|
+
* Whether this conversation is a checkpoint session.
|
|
53
|
+
*/
|
|
54
|
+
get is_checkpoint(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Disposes the conversation and releases all resources.
|
|
57
|
+
*
|
|
58
|
+
* This method is called automatically when using the `using` keyword.
|
|
59
|
+
* Emits a dispose event and transitions to the disposed state.
|
|
60
|
+
*/
|
|
61
|
+
[Symbol.dispose](): void;
|
|
62
|
+
/**
|
|
63
|
+
* Sends a text prompt to the model.
|
|
64
|
+
*
|
|
65
|
+
* @param prompt - The text prompt to send.
|
|
66
|
+
* @returns A promise that resolves with the request data, or undefined if cancelled.
|
|
67
|
+
*/
|
|
68
|
+
prompt(prompt: string): Promise<PromptRequestData | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Sends a message with custom content to the model.
|
|
71
|
+
*
|
|
72
|
+
* @param contents - The content blocks to include in the message.
|
|
73
|
+
* @returns A promise that resolves with the request data, or undefined if cancelled.
|
|
74
|
+
*/
|
|
75
|
+
send_message(contents: UserContent[]): Promise<PromptRequestData | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* Registers a one-time event listener.
|
|
78
|
+
*
|
|
79
|
+
* @template E - The event name type.
|
|
80
|
+
* @param event_name - The name of the event to listen for.
|
|
81
|
+
* @param listener - The callback function to invoke when the event occurs.
|
|
82
|
+
*/
|
|
83
|
+
once<E extends keyof ConversationEvents>(event_name: E, listener: E extends keyof ConversationEvents ? (...arg: ConversationEvents[E]) => void : never): void;
|
|
84
|
+
/**
|
|
85
|
+
* Registers a persistent event listener.
|
|
86
|
+
*
|
|
87
|
+
* @template E - The event name type.
|
|
88
|
+
* @param event_name - The name of the event to listen for.
|
|
89
|
+
* @param listener - The callback function to invoke when the event occurs.
|
|
90
|
+
*/
|
|
91
|
+
on<E extends keyof ConversationEvents>(event_name: E, listener: E extends keyof ConversationEvents ? (...arg: ConversationEvents[E]) => void : never): void;
|
|
92
|
+
/**
|
|
93
|
+
* Removes an event listener.
|
|
94
|
+
*
|
|
95
|
+
* @template E - The event name type.
|
|
96
|
+
* @param event_name - The name of the event.
|
|
97
|
+
* @param listener - The callback function to remove.
|
|
98
|
+
*/
|
|
99
|
+
off<E extends keyof ConversationEvents>(event_name: E, listener: E extends keyof ConversationEvents ? (...arg: ConversationEvents[E]) => void : never): void;
|
|
100
|
+
/**
|
|
101
|
+
* Cancels an in-progress model response.
|
|
102
|
+
*
|
|
103
|
+
* Transitions the conversation to the "stopping" state, which triggers
|
|
104
|
+
* cancellation of the underlying request.
|
|
105
|
+
*/
|
|
106
|
+
cancel_response(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Clears all messages from the conversation history.
|
|
109
|
+
*
|
|
110
|
+
* Can only be called when the conversation is idle.
|
|
111
|
+
*/
|
|
112
|
+
clear(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Loads messages into the conversation history.
|
|
115
|
+
*
|
|
116
|
+
* @param messages - The messages to load.
|
|
117
|
+
*/
|
|
118
|
+
load(messages: Message[]): void;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a child conversation that inherits configuration from this conversation.
|
|
121
|
+
*
|
|
122
|
+
* Child events are propagated to the parent as "child_event" events.
|
|
123
|
+
*
|
|
124
|
+
* @param fork_session - Whether to copy the current message history to the child.
|
|
125
|
+
* @param id - Optional custom ID for the child conversation.
|
|
126
|
+
* @param system_prompt - Optional system prompt override for the child.
|
|
127
|
+
* @param is_checkpoint - Whether this child is a checkpoint summarization session.
|
|
128
|
+
* @returns The newly created child conversation.
|
|
129
|
+
*/
|
|
130
|
+
spawn_child(fork_session?: boolean, id?: string, system_prompt?: string, is_checkpoint?: boolean): Conversation;
|
|
131
|
+
/**
|
|
132
|
+
* Creates a checkpoint summarizing the conversation so far.
|
|
133
|
+
*
|
|
134
|
+
* Spawns an ephemeral child conversation, sends the checkpoint prompt,
|
|
135
|
+
* and stores the resulting summary as the new checkpoint state.
|
|
136
|
+
*
|
|
137
|
+
* Requires a CheckpointContextTransformer (or composite that includes one)
|
|
138
|
+
* in the context transformer pipeline for the checkpoint state to take effect
|
|
139
|
+
* on subsequent prompts.
|
|
140
|
+
*
|
|
141
|
+
* @param config - Optional checkpoint configuration.
|
|
142
|
+
* @returns The new checkpoint state.
|
|
143
|
+
*/
|
|
144
|
+
checkpoint(config?: CheckpointConfig): Promise<CheckpointState>;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation.ts"],"names":[],"mappings":"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"}
|