@haklex/rich-agent-core 0.0.95 → 0.0.97
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +284 -0
- package/dist/provider/create-provider.d.ts +8 -0
- package/dist/provider/create-provider.d.ts.map +1 -0
- package/dist/provider/index.d.ts +4 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/message-format.d.ts +4 -0
- package/dist/provider/message-format.d.ts.map +1 -0
- package/dist/provider/sse-claude.d.ts +3 -0
- package/dist/provider/sse-claude.d.ts.map +1 -0
- package/dist/provider/sse-openai.d.ts +3 -0
- package/dist/provider/sse-openai.d.ts.map +1 -0
- package/dist/provider/transport.d.ts +13 -0
- package/dist/provider/transport.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type { ToolCallGroupItem, ToolCallItemStatus } from './initialState';
|
|
|
7
7
|
export { createInitialAgentStoreState } from './initialState';
|
|
8
8
|
export { BaseEveryUserContentProvider, BaseFirstUserContentProvider, BaseFirstUserMessageProvider, BaseLastUserContentProvider, BaseMessageEngineProcessor, BaseSystemMessageProvider, BaseSystemRoleProvider, BaseSystemRootProvider, MessagesEngine, } from './messages-engine';
|
|
9
9
|
export type { AgentToolConfig, AgentToolResult, ChatMessage, DocumentContextOptions, LLMChunk, LLMProvider, MessageEngine, MessageEngineContext, PageContentContext, PageContentMetadata, PageSelection, PreparedMessages, ToolCall, ToolError, ToolSchema, } from './protocol';
|
|
10
|
+
export type { ProviderType, TransportAdapter } from './provider';
|
|
11
|
+
export { createDirectTransport, createProvider, createProxyTransport } from './provider';
|
|
10
12
|
export { acceptAndRebaseBatch, acceptBatch, applyOpsToSnapshot, createReviewBatch, detectConflicts, reconcileReviewBatches, rejectBatch, resolveReviewEntry, } from './review-engine';
|
|
11
13
|
export type { ReviewBatch, ReviewBatchStatus, ReviewEntry, ReviewEntryStatus, ReviewState, } from './review-types';
|
|
12
14
|
export { agentStoreSelectors } from './selectors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,E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T,YAAY,EACZ,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -684,6 +684,287 @@ function createInitialAgentStoreState() {
|
|
|
684
684
|
reviewState: null
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
|
+
async function* parseClaudeSSE(response) {
|
|
688
|
+
const reader = response.body.getReader();
|
|
689
|
+
const decoder = new TextDecoder();
|
|
690
|
+
let buffer = "";
|
|
691
|
+
let currentToolBlock = null;
|
|
692
|
+
try {
|
|
693
|
+
while (true) {
|
|
694
|
+
const { done, value } = await reader.read();
|
|
695
|
+
if (done) break;
|
|
696
|
+
buffer += decoder.decode(value, { stream: true });
|
|
697
|
+
const lines = buffer.split("\n");
|
|
698
|
+
buffer = lines.pop();
|
|
699
|
+
let currentEvent = "";
|
|
700
|
+
for (const line of lines) {
|
|
701
|
+
if (line.startsWith("event: ")) {
|
|
702
|
+
currentEvent = line.slice(7).trim();
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (!line.startsWith("data: ")) continue;
|
|
706
|
+
const data = line.slice(6).trim();
|
|
707
|
+
if (!data) continue;
|
|
708
|
+
let parsed;
|
|
709
|
+
try {
|
|
710
|
+
parsed = JSON.parse(data);
|
|
711
|
+
} catch {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const eventType = currentEvent || parsed.type;
|
|
715
|
+
if (eventType === "content_block_start") {
|
|
716
|
+
if (parsed.content_block?.type === "tool_use") {
|
|
717
|
+
currentToolBlock = {
|
|
718
|
+
id: parsed.content_block.id,
|
|
719
|
+
name: parsed.content_block.name,
|
|
720
|
+
arguments: ""
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
} else if (eventType === "content_block_delta") {
|
|
724
|
+
const delta = parsed.delta;
|
|
725
|
+
if (delta?.type === "text_delta") {
|
|
726
|
+
yield { type: "text", text: delta.text };
|
|
727
|
+
} else if (delta?.type === "thinking_delta") {
|
|
728
|
+
yield { type: "thinking", text: delta.thinking };
|
|
729
|
+
} else if (delta?.type === "input_json_delta" && currentToolBlock) {
|
|
730
|
+
currentToolBlock.arguments += delta.partial_json;
|
|
731
|
+
}
|
|
732
|
+
} else if (eventType === "content_block_stop") {
|
|
733
|
+
if (currentToolBlock) {
|
|
734
|
+
yield {
|
|
735
|
+
type: "tool_call",
|
|
736
|
+
id: currentToolBlock.id,
|
|
737
|
+
name: currentToolBlock.name,
|
|
738
|
+
arguments: currentToolBlock.arguments
|
|
739
|
+
};
|
|
740
|
+
currentToolBlock = null;
|
|
741
|
+
}
|
|
742
|
+
} else if (eventType === "message_stop") {
|
|
743
|
+
yield { type: "done" };
|
|
744
|
+
}
|
|
745
|
+
currentEvent = "";
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
} finally {
|
|
749
|
+
reader.releaseLock();
|
|
750
|
+
}
|
|
751
|
+
yield { type: "done" };
|
|
752
|
+
}
|
|
753
|
+
async function* parseOpenAISSE(response) {
|
|
754
|
+
const reader = response.body.getReader();
|
|
755
|
+
const decoder = new TextDecoder();
|
|
756
|
+
let buffer = "";
|
|
757
|
+
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
758
|
+
try {
|
|
759
|
+
while (true) {
|
|
760
|
+
const { done, value } = await reader.read();
|
|
761
|
+
if (done) break;
|
|
762
|
+
buffer += decoder.decode(value, { stream: true });
|
|
763
|
+
const lines = buffer.split("\n");
|
|
764
|
+
buffer = lines.pop();
|
|
765
|
+
for (const line of lines) {
|
|
766
|
+
if (!line.startsWith("data: ")) continue;
|
|
767
|
+
const data = line.slice(6).trim();
|
|
768
|
+
if (data === "[DONE]") {
|
|
769
|
+
for (const tc of pendingToolCalls.values()) {
|
|
770
|
+
yield { type: "tool_call", id: tc.id, name: tc.name, arguments: tc.arguments };
|
|
771
|
+
}
|
|
772
|
+
pendingToolCalls.clear();
|
|
773
|
+
yield { type: "done" };
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
let parsed;
|
|
777
|
+
try {
|
|
778
|
+
parsed = JSON.parse(data);
|
|
779
|
+
} catch {
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
const delta = parsed.choices?.[0]?.delta;
|
|
783
|
+
if (!delta) continue;
|
|
784
|
+
if (delta.content) {
|
|
785
|
+
yield { type: "text", text: delta.content };
|
|
786
|
+
}
|
|
787
|
+
if (delta.tool_calls) {
|
|
788
|
+
for (const tc of delta.tool_calls) {
|
|
789
|
+
const idx = tc.index ?? 0;
|
|
790
|
+
if (!pendingToolCalls.has(idx)) {
|
|
791
|
+
pendingToolCalls.set(idx, {
|
|
792
|
+
id: tc.id || "",
|
|
793
|
+
name: tc.function?.name || "",
|
|
794
|
+
arguments: ""
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
const pending = pendingToolCalls.get(idx);
|
|
798
|
+
if (tc.id) pending.id = tc.id;
|
|
799
|
+
if (tc.function?.name) pending.name = tc.function.name;
|
|
800
|
+
if (tc.function?.arguments) pending.arguments += tc.function.arguments;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const finishReason = parsed.choices?.[0]?.finish_reason;
|
|
804
|
+
if (finishReason === "tool_calls") {
|
|
805
|
+
for (const tc of pendingToolCalls.values()) {
|
|
806
|
+
yield { type: "tool_call", id: tc.id, name: tc.name, arguments: tc.arguments };
|
|
807
|
+
}
|
|
808
|
+
pendingToolCalls.clear();
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
} finally {
|
|
813
|
+
reader.releaseLock();
|
|
814
|
+
}
|
|
815
|
+
yield { type: "done" };
|
|
816
|
+
}
|
|
817
|
+
function createProvider(config) {
|
|
818
|
+
const { model, transport, providerType } = config;
|
|
819
|
+
const parse = providerType === "claude" ? parseClaudeSSE : parseOpenAISSE;
|
|
820
|
+
return {
|
|
821
|
+
async *chat(messages, tools) {
|
|
822
|
+
const controller = new AbortController();
|
|
823
|
+
const response = await transport(messages, tools, model, controller.signal);
|
|
824
|
+
if (!response.ok) {
|
|
825
|
+
const err = await response.text();
|
|
826
|
+
throw new Error(`LLM API error (${response.status}): ${err}`);
|
|
827
|
+
}
|
|
828
|
+
yield* parse(response);
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function buildClaudeBody(messages, tools, model) {
|
|
833
|
+
const systemMsgs = messages.filter((m) => m.role === "system");
|
|
834
|
+
const nonSystemMsgs = messages.filter((m) => m.role !== "system");
|
|
835
|
+
const claudeMessages = nonSystemMsgs.map((m) => {
|
|
836
|
+
if (m.role === "user") return { role: "user", content: m.content };
|
|
837
|
+
if (m.role === "assistant") return { role: "assistant", content: m.content };
|
|
838
|
+
if (m.role === "assistant_tool_call") {
|
|
839
|
+
return {
|
|
840
|
+
role: "assistant",
|
|
841
|
+
content: m.toolCalls.map((tc) => ({
|
|
842
|
+
type: "tool_use",
|
|
843
|
+
id: tc.id,
|
|
844
|
+
name: tc.name,
|
|
845
|
+
input: JSON.parse(tc.arguments)
|
|
846
|
+
}))
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
if (m.role === "tool_result") {
|
|
850
|
+
return {
|
|
851
|
+
role: "user",
|
|
852
|
+
content: [
|
|
853
|
+
{
|
|
854
|
+
type: "tool_result",
|
|
855
|
+
tool_use_id: m.toolCallId,
|
|
856
|
+
content: m.content,
|
|
857
|
+
is_error: m.isError
|
|
858
|
+
}
|
|
859
|
+
]
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
return { role: m.role, content: m.content };
|
|
863
|
+
});
|
|
864
|
+
const claudeTools = tools?.map((t) => ({
|
|
865
|
+
name: t.name,
|
|
866
|
+
description: t.description,
|
|
867
|
+
input_schema: t.parameters
|
|
868
|
+
}));
|
|
869
|
+
const body = {
|
|
870
|
+
model,
|
|
871
|
+
max_tokens: 4096,
|
|
872
|
+
stream: true,
|
|
873
|
+
messages: claudeMessages
|
|
874
|
+
};
|
|
875
|
+
if (systemMsgs.length > 0) {
|
|
876
|
+
body.system = systemMsgs.map((m) => ({ type: "text", text: m.content }));
|
|
877
|
+
}
|
|
878
|
+
if (claudeTools?.length) {
|
|
879
|
+
body.tools = claudeTools;
|
|
880
|
+
}
|
|
881
|
+
if (model.includes("opus") || model.includes("sonnet")) {
|
|
882
|
+
body.thinking = { type: "enabled", budget_tokens: 2048 };
|
|
883
|
+
}
|
|
884
|
+
return body;
|
|
885
|
+
}
|
|
886
|
+
function buildOpenAIBody(messages, tools, model) {
|
|
887
|
+
const openaiMessages = messages.map((m) => {
|
|
888
|
+
if (m.role === "system") return { role: "system", content: m.content };
|
|
889
|
+
if (m.role === "user") return { role: "user", content: m.content };
|
|
890
|
+
if (m.role === "assistant") return { role: "assistant", content: m.content };
|
|
891
|
+
if (m.role === "assistant_tool_call") {
|
|
892
|
+
return {
|
|
893
|
+
role: "assistant",
|
|
894
|
+
content: null,
|
|
895
|
+
tool_calls: m.toolCalls.map((tc) => ({
|
|
896
|
+
id: tc.id,
|
|
897
|
+
type: "function",
|
|
898
|
+
function: { name: tc.name, arguments: tc.arguments }
|
|
899
|
+
}))
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
if (m.role === "tool_result") {
|
|
903
|
+
return {
|
|
904
|
+
role: "tool",
|
|
905
|
+
tool_call_id: m.toolCallId,
|
|
906
|
+
content: m.content
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
return { role: m.role, content: m.content };
|
|
910
|
+
});
|
|
911
|
+
const openaiTools = tools?.map((t) => ({
|
|
912
|
+
type: "function",
|
|
913
|
+
function: { name: t.name, description: t.description, parameters: t.parameters }
|
|
914
|
+
}));
|
|
915
|
+
const body = {
|
|
916
|
+
model,
|
|
917
|
+
stream: true,
|
|
918
|
+
messages: openaiMessages
|
|
919
|
+
};
|
|
920
|
+
if (openaiTools?.length) {
|
|
921
|
+
body.tools = openaiTools;
|
|
922
|
+
}
|
|
923
|
+
return body;
|
|
924
|
+
}
|
|
925
|
+
function createDirectTransport(config) {
|
|
926
|
+
const { apiKey, baseUrl, providerType } = config;
|
|
927
|
+
return async (messages, tools, model, signal) => {
|
|
928
|
+
if (providerType === "claude") {
|
|
929
|
+
const body2 = buildClaudeBody(messages, tools, model);
|
|
930
|
+
return fetch(`${baseUrl}/messages`, {
|
|
931
|
+
method: "POST",
|
|
932
|
+
headers: {
|
|
933
|
+
"Content-Type": "application/json",
|
|
934
|
+
"x-api-key": apiKey,
|
|
935
|
+
"anthropic-version": "2023-06-01",
|
|
936
|
+
"anthropic-beta": "interleaved-thinking-2025-05-14"
|
|
937
|
+
},
|
|
938
|
+
body: JSON.stringify(body2),
|
|
939
|
+
signal
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
const body = buildOpenAIBody(messages, tools, model);
|
|
943
|
+
return fetch(`${baseUrl}/chat/completions`, {
|
|
944
|
+
method: "POST",
|
|
945
|
+
headers: {
|
|
946
|
+
"Content-Type": "application/json",
|
|
947
|
+
"Authorization": `Bearer ${apiKey}`
|
|
948
|
+
},
|
|
949
|
+
body: JSON.stringify(body),
|
|
950
|
+
signal
|
|
951
|
+
});
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function createProxyTransport(config) {
|
|
955
|
+
const { endpoint, headers: extraHeaders } = config;
|
|
956
|
+
return async (messages, tools, model, signal) => {
|
|
957
|
+
return fetch(endpoint, {
|
|
958
|
+
method: "POST",
|
|
959
|
+
headers: {
|
|
960
|
+
"Content-Type": "application/json",
|
|
961
|
+
...extraHeaders
|
|
962
|
+
},
|
|
963
|
+
body: JSON.stringify({ model, messages, tools }),
|
|
964
|
+
signal
|
|
965
|
+
});
|
|
966
|
+
};
|
|
967
|
+
}
|
|
687
968
|
function getBlockId(node) {
|
|
688
969
|
return node.$?.blockId;
|
|
689
970
|
}
|
|
@@ -1129,8 +1410,11 @@ export {
|
|
|
1129
1410
|
createAgentStore,
|
|
1130
1411
|
createAgentStoreSlice,
|
|
1131
1412
|
createDiffEngine,
|
|
1413
|
+
createDirectTransport,
|
|
1132
1414
|
createDocumentTools,
|
|
1133
1415
|
createInitialAgentStoreState,
|
|
1416
|
+
createProvider,
|
|
1417
|
+
createProxyTransport,
|
|
1134
1418
|
createReviewBatch,
|
|
1135
1419
|
createSnapshot,
|
|
1136
1420
|
detectConflicts,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LLMProvider } from '../protocol';
|
|
2
|
+
import { ProviderType, TransportAdapter } from './transport';
|
|
3
|
+
export declare function createProvider(config: {
|
|
4
|
+
model: string;
|
|
5
|
+
providerType: ProviderType;
|
|
6
|
+
transport: TransportAdapter;
|
|
7
|
+
}): LLMProvider;
|
|
8
|
+
//# sourceMappingURL=create-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src/provider/create-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;CAC7B,GAAG,WAAW,CAiBd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChatMessage, ToolSchema } from '../protocol';
|
|
2
|
+
export declare function buildClaudeBody(messages: ChatMessage[], tools: ToolSchema[] | undefined, model: string): Record<string, unknown>;
|
|
3
|
+
export declare function buildOpenAIBody(messages: ChatMessage[], tools: ToolSchema[] | undefined, model: string): Record<string, unknown>;
|
|
4
|
+
//# sourceMappingURL=message-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-format.d.ts","sourceRoot":"","sources":["../../src/provider/message-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,EAC/B,KAAK,EAAE,MAAM,2BA2Dd;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,EAC/B,KAAK,EAAE,MAAM,2BA0Cd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-claude.d.ts","sourceRoot":"","sources":["../../src/provider/sse-claude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAuB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CA0EjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-openai.d.ts","sourceRoot":"","sources":["../../src/provider/sse-openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAuB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAwEjF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChatMessage, ToolSchema } from '../protocol';
|
|
2
|
+
export type TransportAdapter = (messages: ChatMessage[], tools: ToolSchema[] | undefined, model: string, signal: AbortSignal) => Promise<Response>;
|
|
3
|
+
export type ProviderType = 'claude' | 'openai-compatible';
|
|
4
|
+
export declare function createDirectTransport(config: {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
providerType: ProviderType;
|
|
8
|
+
}): TransportAdapter;
|
|
9
|
+
export declare function createProxyTransport(config: {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}): TransportAdapter;
|
|
13
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/provider/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,EAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,mBAAmB,CAAC;AAE1D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,gBAAgB,CA8BnB;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GAAG,gBAAgB,CAcnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-agent-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.97",
|
|
4
4
|
"description": "Headless AI agent protocol, diff engine, and store for Lexical editor",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"nanoid": "^5.1.6",
|
|
24
24
|
"zustand": "^5.0.12",
|
|
25
|
-
"@haklex/rich-litexml": "0.0.
|
|
25
|
+
"@haklex/rich-litexml": "0.0.97"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"lexical": "^0.42.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"vite": "^7.3.1",
|
|
31
31
|
"vite-plugin-dts": "^4.5.4",
|
|
32
32
|
"vitest": "^4.0.18",
|
|
33
|
-
"@haklex/rich-editor": "0.0.
|
|
33
|
+
"@haklex/rich-editor": "0.0.97"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"lexical": "^0.42.0",
|
|
37
|
-
"@haklex/rich-editor": "0.0.
|
|
37
|
+
"@haklex/rich-editor": "0.0.97"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|