@cognipeer/agent-sdk 0.2.2 → 0.2.3
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/index.cjs +423 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -4
- package/dist/index.d.ts +56 -4
- package/dist/index.mjs +423 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -2
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,18 @@ interface BaseChatMessage {
|
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}
|
|
27
27
|
interface BaseChatModel {
|
|
28
|
-
invoke(messages: BaseChatMessage[]
|
|
28
|
+
invoke(messages: BaseChatMessage[], options?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
cancellationToken?: {
|
|
31
|
+
isCancellationRequested: boolean;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<BaseChatMessage>;
|
|
34
|
+
stream?(messages: BaseChatMessage[], options?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
cancellationToken?: {
|
|
37
|
+
isCancellationRequested: boolean;
|
|
38
|
+
};
|
|
39
|
+
}): AsyncIterable<BaseChatMessage | BaseChatMessagePart | string>;
|
|
29
40
|
bindTools?(tools: any[]): BaseChatModel;
|
|
30
41
|
modelName?: string;
|
|
31
42
|
[key: string]: any;
|
|
@@ -185,6 +196,8 @@ type SmartAgentOptions = {
|
|
|
185
196
|
maxTokens: number;
|
|
186
197
|
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
187
198
|
summaryPromptMaxTokens?: number;
|
|
199
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
200
|
+
promptTemplate?: string;
|
|
188
201
|
};
|
|
189
202
|
systemPrompt?: string;
|
|
190
203
|
useTodoList?: boolean;
|
|
@@ -478,6 +491,23 @@ type MetadataEvent = {
|
|
|
478
491
|
limits?: SmartAgentLimits;
|
|
479
492
|
[key: string]: any;
|
|
480
493
|
};
|
|
494
|
+
type ProgressEvent = {
|
|
495
|
+
type: "progress";
|
|
496
|
+
stage?: string;
|
|
497
|
+
message?: string;
|
|
498
|
+
percent?: number;
|
|
499
|
+
detail?: any;
|
|
500
|
+
};
|
|
501
|
+
type StreamEvent = {
|
|
502
|
+
type: "stream";
|
|
503
|
+
text: string;
|
|
504
|
+
isFinal?: boolean;
|
|
505
|
+
};
|
|
506
|
+
type CancelledEvent = {
|
|
507
|
+
type: "cancelled";
|
|
508
|
+
stage?: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
};
|
|
481
511
|
type HandoffEvent = {
|
|
482
512
|
type: "handoff";
|
|
483
513
|
from?: string;
|
|
@@ -528,9 +558,31 @@ type GuardrailEvent = {
|
|
|
528
558
|
reason?: string;
|
|
529
559
|
details?: Record<string, any>;
|
|
530
560
|
};
|
|
531
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
561
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
562
|
+
type CancellationTokenLike = {
|
|
563
|
+
readonly isCancellationRequested: boolean;
|
|
564
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
565
|
+
dispose(): void;
|
|
566
|
+
} | void;
|
|
567
|
+
};
|
|
568
|
+
type ProgressUpdate = {
|
|
569
|
+
stage?: string;
|
|
570
|
+
message?: string;
|
|
571
|
+
percent?: number;
|
|
572
|
+
detail?: any;
|
|
573
|
+
};
|
|
574
|
+
type StreamChunk = {
|
|
575
|
+
text: string;
|
|
576
|
+
isFinal?: boolean;
|
|
577
|
+
};
|
|
532
578
|
type InvokeConfig = RunnableConfig & {
|
|
533
579
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
580
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
581
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
582
|
+
stream?: boolean;
|
|
583
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
584
|
+
timeoutMs?: number;
|
|
585
|
+
limits?: Partial<AgentLimits>;
|
|
534
586
|
onStateChange?: (state: SmartState) => boolean;
|
|
535
587
|
checkpointReason?: string;
|
|
536
588
|
};
|
|
@@ -724,13 +776,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
724
776
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
725
777
|
}, "strip", z.ZodTypeAny, {
|
|
726
778
|
allow: boolean;
|
|
727
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
728
779
|
reason?: string | undefined;
|
|
780
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
729
781
|
details?: Record<string, any> | undefined;
|
|
730
782
|
}, {
|
|
731
783
|
allow: boolean;
|
|
732
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
733
784
|
reason?: string | undefined;
|
|
785
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
734
786
|
details?: Record<string, any> | undefined;
|
|
735
787
|
}>;
|
|
736
788
|
type AgentRuleOptions = {
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,18 @@ interface BaseChatMessage {
|
|
|
25
25
|
[key: string]: any;
|
|
26
26
|
}
|
|
27
27
|
interface BaseChatModel {
|
|
28
|
-
invoke(messages: BaseChatMessage[]
|
|
28
|
+
invoke(messages: BaseChatMessage[], options?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
cancellationToken?: {
|
|
31
|
+
isCancellationRequested: boolean;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<BaseChatMessage>;
|
|
34
|
+
stream?(messages: BaseChatMessage[], options?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
cancellationToken?: {
|
|
37
|
+
isCancellationRequested: boolean;
|
|
38
|
+
};
|
|
39
|
+
}): AsyncIterable<BaseChatMessage | BaseChatMessagePart | string>;
|
|
29
40
|
bindTools?(tools: any[]): BaseChatModel;
|
|
30
41
|
modelName?: string;
|
|
31
42
|
[key: string]: any;
|
|
@@ -185,6 +196,8 @@ type SmartAgentOptions = {
|
|
|
185
196
|
maxTokens: number;
|
|
186
197
|
/** Max tokens to include in the summarization prompt itself (to avoid sending huge context to summarizer). Default: 8000 */
|
|
187
198
|
summaryPromptMaxTokens?: number;
|
|
199
|
+
/** Optional prompt template. Use {{conversation}} and {{previousSummary}} placeholders. */
|
|
200
|
+
promptTemplate?: string;
|
|
188
201
|
};
|
|
189
202
|
systemPrompt?: string;
|
|
190
203
|
useTodoList?: boolean;
|
|
@@ -478,6 +491,23 @@ type MetadataEvent = {
|
|
|
478
491
|
limits?: SmartAgentLimits;
|
|
479
492
|
[key: string]: any;
|
|
480
493
|
};
|
|
494
|
+
type ProgressEvent = {
|
|
495
|
+
type: "progress";
|
|
496
|
+
stage?: string;
|
|
497
|
+
message?: string;
|
|
498
|
+
percent?: number;
|
|
499
|
+
detail?: any;
|
|
500
|
+
};
|
|
501
|
+
type StreamEvent = {
|
|
502
|
+
type: "stream";
|
|
503
|
+
text: string;
|
|
504
|
+
isFinal?: boolean;
|
|
505
|
+
};
|
|
506
|
+
type CancelledEvent = {
|
|
507
|
+
type: "cancelled";
|
|
508
|
+
stage?: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
};
|
|
481
511
|
type HandoffEvent = {
|
|
482
512
|
type: "handoff";
|
|
483
513
|
from?: string;
|
|
@@ -528,9 +558,31 @@ type GuardrailEvent = {
|
|
|
528
558
|
reason?: string;
|
|
529
559
|
details?: Record<string, any>;
|
|
530
560
|
};
|
|
531
|
-
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent;
|
|
561
|
+
type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
|
|
562
|
+
type CancellationTokenLike = {
|
|
563
|
+
readonly isCancellationRequested: boolean;
|
|
564
|
+
onCancellationRequested?: (listener: () => void) => {
|
|
565
|
+
dispose(): void;
|
|
566
|
+
} | void;
|
|
567
|
+
};
|
|
568
|
+
type ProgressUpdate = {
|
|
569
|
+
stage?: string;
|
|
570
|
+
message?: string;
|
|
571
|
+
percent?: number;
|
|
572
|
+
detail?: any;
|
|
573
|
+
};
|
|
574
|
+
type StreamChunk = {
|
|
575
|
+
text: string;
|
|
576
|
+
isFinal?: boolean;
|
|
577
|
+
};
|
|
532
578
|
type InvokeConfig = RunnableConfig & {
|
|
533
579
|
onEvent?: (event: SmartAgentEvent) => void;
|
|
580
|
+
onProgress?: (progress: ProgressUpdate) => void;
|
|
581
|
+
onStream?: (chunk: StreamChunk) => void;
|
|
582
|
+
stream?: boolean;
|
|
583
|
+
cancellationToken?: CancellationTokenLike | AbortSignal;
|
|
584
|
+
timeoutMs?: number;
|
|
585
|
+
limits?: Partial<AgentLimits>;
|
|
534
586
|
onStateChange?: (state: SmartState) => boolean;
|
|
535
587
|
checkpointReason?: string;
|
|
536
588
|
};
|
|
@@ -724,13 +776,13 @@ declare const guardianSchema: z.ZodObject<{
|
|
|
724
776
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
725
777
|
}, "strip", z.ZodTypeAny, {
|
|
726
778
|
allow: boolean;
|
|
727
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
728
779
|
reason?: string | undefined;
|
|
780
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
729
781
|
details?: Record<string, any> | undefined;
|
|
730
782
|
}, {
|
|
731
783
|
allow: boolean;
|
|
732
|
-
disposition?: "block" | "warn" | "allow" | undefined;
|
|
733
784
|
reason?: string | undefined;
|
|
785
|
+
disposition?: "block" | "warn" | "allow" | undefined;
|
|
734
786
|
details?: Record<string, any> | undefined;
|
|
735
787
|
}>;
|
|
736
788
|
type AgentRuleOptions = {
|