akanjs 3.0.0-beta.0 → 3.0.0-beta.2
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/dictionary/agent.dictionary.ts +8 -0
- package/dictionary/agentTurn.dictionary.ts +6 -2
- package/dictionary/base.dictionary.ts +1 -0
- package/fetch/agentTurn.ts +1 -1
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/package.json +1 -1
- package/service/predefinedAdaptor/anthropicLlm.ts +382 -0
- package/service/predefinedAdaptor/deepseekLlm.ts +21 -211
- package/service/predefinedAdaptor/index.ts +3 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +25 -1
- package/service/predefinedAdaptor/openaiDialect.ts +246 -0
- package/service/predefinedAdaptor/openaiLlm.ts +91 -0
- package/signal/agentTurnStream.ts +5 -2
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +9 -9
- package/types/fetch/agentTurn.d.ts +3 -3
- package/types/service/agent.service.d.ts +1 -1
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +112 -0
- package/types/service/predefinedAdaptor/deepseekLlm.d.ts +10 -67
- package/types/service/predefinedAdaptor/index.d.ts +3 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +25 -1
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +96 -0
- package/types/service/predefinedAdaptor/openaiLlm.d.ts +24 -0
- package/types/signal/agent.signal.d.ts +1 -1
- package/types/signal/agentTurn.d.ts +1 -1
- package/types/signal/agentTurnStream.d.ts +1 -1
- package/types/ui/Agent/Attach.d.ts +4 -1
- package/types/ui/Agent/Composer.d.ts +3 -1
- package/types/ui/Agent/useChatAttachments.d.ts +1 -0
- package/types/vendor/use-agentic/types.d.ts +7 -1
- package/ui/Agent/Attach.tsx +13 -1
- package/ui/Agent/Chat.tsx +1 -0
- package/ui/Agent/Composer.tsx +11 -2
- package/ui/Agent/useChatAttachments.ts +6 -0
- package/vendor/use-agentic/AgentSession.ts +12 -2
- package/vendor/use-agentic/WIRE.md +6 -1
- package/vendor/use-agentic/httpRunner.ts +1 -1
- package/vendor/use-agentic/types.ts +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string], "ping" | "pingBody" | "pingParam" | "pingQuery" | "wsPing" | "pubsubPing", "serverUnreachable" | "serverUnavailable" | "gatewayTimeout" | "unexpectedResponse", "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
1
|
+
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string], "ping" | "pingBody" | "pingParam" | "pingQuery" | "wsPing" | "pubsubPing", "serverUnreachable" | "serverUnavailable" | "gatewayTimeout" | "unexpectedResponse", "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view">;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AgentEndpoint, AgentTurn, BaseEndpoint } from "akanjs/signal";
|
|
2
2
|
export declare const dictionary: {
|
|
3
|
-
base: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
3
|
+
base: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view">, "base.error.gatewayTimeout" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.unexpectedResponse">;
|
|
4
4
|
agentTurn: import("./locale.d.ts").DictModule<import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc`, never>;
|
|
5
|
-
agent: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, "agent.error.llmUnavailable" | "agent.error.deepseekRequestFailed">;
|
|
5
|
+
agent: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, "agent.error.llmUnavailable" | "agent.error.deepseekRequestFailed" | "agent.error.openaiRequestFailed" | "agent.error.anthropicRequestFailed">;
|
|
6
6
|
};
|
|
7
|
-
export declare const Err: import("./trans.d.ts").ErrConstructor<"base.error.gatewayTimeout" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.unexpectedResponse" | "agent.error.llmUnavailable" | "agent.error.deepseekRequestFailed">, translate: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja", key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
8
|
-
info: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
9
|
-
success: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
10
|
-
error: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
11
|
-
warning: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
12
|
-
loading: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
13
|
-
}, getDictionary: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja") => object, getAllDictionary: () => import("./trans.d.ts").RootDictionary, __Dict_Key__: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "
|
|
7
|
+
export declare const Err: import("./trans.d.ts").ErrConstructor<"base.error.gatewayTimeout" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.unexpectedResponse" | "agent.error.llmUnavailable" | "agent.error.deepseekRequestFailed" | "agent.error.openaiRequestFailed" | "agent.error.anthropicRequestFailed">, translate: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja", key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, data?: import("./trans.d.ts").TranslationData) => string, msg: {
|
|
8
|
+
info: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
9
|
+
success: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
10
|
+
error: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
11
|
+
warning: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
12
|
+
loading: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
13
|
+
}, getDictionary: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja") => object, getAllDictionary: () => import("./trans.d.ts").RootDictionary, __Dict_Key__: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "remove" | "save" | "refresh" | "password" | "skip" | "stop" | "send" | "ok" | "agent" | "success" | "somethingWrong" | "connecting" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "cancel" | "unauthorized" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "approve" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createModel" | "createSuccess" | "updateModel" | "removeModel" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new" | "edit" | "view"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, __Error_Key__: "base.error.gatewayTimeout" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.unexpectedResponse" | "agent.error.llmUnavailable" | "agent.error.deepseekRequestFailed" | "agent.error.openaiRequestFailed" | "agent.error.anthropicRequestFailed";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Any } from "akanjs/base";
|
|
2
|
-
declare const AgentStop_base: import("akanjs/base").EnumInstance<"agentStop", "end" | "toolUse">;
|
|
2
|
+
declare const AgentStop_base: import("akanjs/base").EnumInstance<"agentStop", "length" | "end" | "toolUse">;
|
|
3
3
|
export declare class AgentStop extends AgentStop_base {
|
|
4
4
|
}
|
|
5
5
|
declare const AgentTurn_base: import("akanjs/constant").ConstantCls<import("akanjs/constant").ExtractFieldInfoObject<{
|
|
@@ -466,10 +466,10 @@ export declare class AgentTurn extends AgentTurn_base {
|
|
|
466
466
|
export declare const agentTurnConstant: import("akanjs/constant").ScalarConstantModel<"agentTurn", AgentTurn, import("akanjs/constant").DefaultOf<AgentTurn>, {
|
|
467
467
|
text: string;
|
|
468
468
|
toolCalls: unknown[];
|
|
469
|
-
stop: NonNullable<"end" | "toolUse">;
|
|
469
|
+
stop: NonNullable<"length" | "end" | "toolUse">;
|
|
470
470
|
} & {}, {
|
|
471
471
|
text: string;
|
|
472
472
|
toolCalls: unknown[];
|
|
473
|
-
stop: "end" | "toolUse";
|
|
473
|
+
stop: "length" | "end" | "toolUse";
|
|
474
474
|
} & {}>;
|
|
475
475
|
export {};
|
|
@@ -6,7 +6,7 @@ export declare class AgentService extends AgentService_base {
|
|
|
6
6
|
runTurn(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<{
|
|
7
7
|
text: string;
|
|
8
8
|
toolCalls: import("./predefinedAdaptor.d.ts").AgentWireToolCall[];
|
|
9
|
-
stop: "end" | "toolUse";
|
|
9
|
+
stop: "length" | "end" | "toolUse";
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
|
12
12
|
* The framework's half of the system prompt, ahead of whatever the app said so the app's text stays the more
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { AgentWireAttachment, AgentWireMessage, LlmAccepts, LlmAdaptor, LlmOption, LlmTurnAnswer, LlmTurnRequest } from "./llm.adaptor";
|
|
2
|
+
type AnthropicSource = {
|
|
3
|
+
type: "base64";
|
|
4
|
+
media_type: string;
|
|
5
|
+
data: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "url";
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
type AnthropicBlock = {
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "image";
|
|
15
|
+
source: AnthropicSource;
|
|
16
|
+
} | {
|
|
17
|
+
type: "document";
|
|
18
|
+
source: AnthropicSource;
|
|
19
|
+
} | {
|
|
20
|
+
type: "tool_use";
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
input: Record<string, unknown>;
|
|
24
|
+
} | {
|
|
25
|
+
type: "tool_result";
|
|
26
|
+
tool_use_id: string;
|
|
27
|
+
content: string;
|
|
28
|
+
};
|
|
29
|
+
interface AnthropicMessage {
|
|
30
|
+
role: "user" | "assistant";
|
|
31
|
+
content: AnthropicBlock[];
|
|
32
|
+
}
|
|
33
|
+
interface AnthropicAnswer {
|
|
34
|
+
content?: {
|
|
35
|
+
type?: string;
|
|
36
|
+
text?: string;
|
|
37
|
+
id?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
input?: Record<string, unknown>;
|
|
40
|
+
}[];
|
|
41
|
+
stop_reason?: string;
|
|
42
|
+
}
|
|
43
|
+
declare const AnthropicLlm_base: import("..").AdaptorCls<{}, {
|
|
44
|
+
llmOption: import("..").InjectInfo<"use", LlmOption, never, never>;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Anthropic's Messages API — the one provider akanjs ships that reads a picture and a PDF.
|
|
48
|
+
*
|
|
49
|
+
* It is not the chat-completions dialect wearing a different host: the system prompt is a top-level field rather
|
|
50
|
+
* than a message, tool calls and their results are content blocks rather than a parallel `tool_calls` array, the
|
|
51
|
+
* results ride in a *user* turn, roles must alternate, and `max_tokens` is required. So it is its own file rather
|
|
52
|
+
* than a branch in `OpenaiDialect`, and nothing is shared between them but the wire they both map from.
|
|
53
|
+
*
|
|
54
|
+
* `model` is required and has no default, for the reason `OpenaiLlm` gives.
|
|
55
|
+
*/
|
|
56
|
+
export declare class AnthropicLlm extends AnthropicLlm_base implements LlmAdaptor {
|
|
57
|
+
#private;
|
|
58
|
+
/** Pinned rather than read from a header the API might move: a revision change is a mapping change, not config. */
|
|
59
|
+
static readonly version = "2023-06-01";
|
|
60
|
+
/**
|
|
61
|
+
* The API refuses a request that names no ceiling, so one is always sent. An agent turn's answer is a sentence
|
|
62
|
+
* and a few tool calls, so this is slack rather than a budget — except on a model that reasons before it
|
|
63
|
+
* writes, which can spend the whole of it thinking and return nothing with a length stop. That reads as the
|
|
64
|
+
* model refusing, so it is `option.setLlm({ maxTokens })` and not a constant.
|
|
65
|
+
*/
|
|
66
|
+
static readonly defaultMaxTokens = 8192;
|
|
67
|
+
/** What the API's blocks carry. A model of the family that reads neither takes the `accepts` override. */
|
|
68
|
+
get accepts(): LlmAccepts;
|
|
69
|
+
chat(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<LlmTurnAnswer | null>;
|
|
70
|
+
static refusal(response: Response): Promise<Error>;
|
|
71
|
+
/** The API answers a refusal as `{ error: { type, message } }`, and the sentence is the half worth printing. */
|
|
72
|
+
static reasonOf(response: Response): Promise<string>;
|
|
73
|
+
static requestBody(model: string, request: LlmTurnRequest, { accepts, stream, maxTokens }?: {
|
|
74
|
+
accepts?: LlmAccepts;
|
|
75
|
+
stream?: boolean;
|
|
76
|
+
maxTokens?: number;
|
|
77
|
+
}): {
|
|
78
|
+
tools?: {
|
|
79
|
+
input_schema: Record<string, unknown>;
|
|
80
|
+
description?: string | undefined;
|
|
81
|
+
name: string;
|
|
82
|
+
}[] | undefined;
|
|
83
|
+
system: string;
|
|
84
|
+
messages: AnthropicMessage[];
|
|
85
|
+
stream?: boolean | undefined;
|
|
86
|
+
model: string;
|
|
87
|
+
max_tokens: number;
|
|
88
|
+
};
|
|
89
|
+
/** Context rides below the instructions framed as data — screen state must never read as directives. */
|
|
90
|
+
static systemPrompt({ instructions, context }: LlmTurnRequest): string;
|
|
91
|
+
/**
|
|
92
|
+
* The API takes strictly alternating turns, so two wire messages that map to one role are merged rather than
|
|
93
|
+
* sent as two — which is not an edge case here: a turn's tool results and the next thing the user says are both
|
|
94
|
+
* user turns, and so is the tool-result turn that follows a batch of calls.
|
|
95
|
+
*/
|
|
96
|
+
static providerMessages(messages: AgentWireMessage[], accepts?: LlmAccepts): AnthropicMessage[];
|
|
97
|
+
static providerMessage(message: AgentWireMessage, accepts?: LlmAccepts): AnthropicMessage;
|
|
98
|
+
static userContent(message: AgentWireMessage, accepts?: LlmAccepts): AnthropicBlock[];
|
|
99
|
+
static sourceOf(attachment: AgentWireAttachment): AnthropicSource | null;
|
|
100
|
+
static turnAnswer(answer: AnthropicAnswer): LlmTurnAnswer;
|
|
101
|
+
/** The ceiling wins over the calls that did arrive — see `OpenaiDialect.stopOf` for why. */
|
|
102
|
+
static stopOf(reason: string | null | undefined, calls: number): LlmTurnAnswer["stop"];
|
|
103
|
+
/**
|
|
104
|
+
* The API streams named SSE events rather than one chunk shape. A tool call opens as `content_block_start`
|
|
105
|
+
* carrying its id and name and then arrives as `input_json_delta` fragments of a JSON string, so it is assembled
|
|
106
|
+
* by block index and parsed once at the end; only assistant text is worth reporting as it arrives.
|
|
107
|
+
*/
|
|
108
|
+
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
109
|
+
/** A tool called with no arguments streams no fragment at all, so an empty string is an empty object. */
|
|
110
|
+
static parsedArgs(raw: string): Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
@@ -1,76 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface DeepseekToolCall {
|
|
3
|
-
id?: string;
|
|
4
|
-
function?: {
|
|
5
|
-
name?: string;
|
|
6
|
-
arguments?: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
interface DeepseekAnswer {
|
|
10
|
-
choices?: {
|
|
11
|
-
message?: {
|
|
12
|
-
content?: string | null;
|
|
13
|
-
tool_calls?: DeepseekToolCall[];
|
|
14
|
-
};
|
|
15
|
-
finish_reason?: string;
|
|
16
|
-
}[];
|
|
17
|
-
}
|
|
18
|
-
interface DeepseekMessage {
|
|
19
|
-
role: "system" | "user" | "assistant" | "tool";
|
|
20
|
-
content: string;
|
|
21
|
-
tool_calls?: {
|
|
22
|
-
id: string;
|
|
23
|
-
type: "function";
|
|
24
|
-
function: {
|
|
25
|
-
name: string;
|
|
26
|
-
arguments: string;
|
|
27
|
-
};
|
|
28
|
-
}[];
|
|
29
|
-
tool_call_id?: string;
|
|
30
|
-
}
|
|
1
|
+
import type { LlmAdaptor, LlmOption, LlmTurnAnswer, LlmTurnRequest } from "./llm.adaptor";
|
|
31
2
|
declare const DeepseekLlm_base: import("..").AdaptorCls<{}, {
|
|
32
3
|
llmOption: import("..").InjectInfo<"use", LlmOption, never, never>;
|
|
33
4
|
}>;
|
|
5
|
+
/**
|
|
6
|
+
* The framework's default provider, and the one an app gets without choosing.
|
|
7
|
+
*
|
|
8
|
+
* `accepts` is left undeclared, so by the time an attachment reaches the dialect `AgentService.readable` has
|
|
9
|
+
* reduced it to its text and turned everything else into a note. That is deliberate rather than pending: DeepSeek's
|
|
10
|
+
* chat API is text, and an adaptor that claimed otherwise would hand it bytes it answers about having never seen.
|
|
11
|
+
* An app that wants vision swaps the role — `option.applyAdaptor(LlmAdaptorRole, OpenaiLlm)` or `AnthropicLlm`.
|
|
12
|
+
*/
|
|
34
13
|
export declare class DeepseekLlm extends DeepseekLlm_base implements LlmAdaptor {
|
|
35
14
|
#private;
|
|
36
15
|
chat(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<LlmTurnAnswer | null>;
|
|
37
|
-
/**
|
|
38
|
-
* The dialect answers a refusal as `{ error: { message } }`, and that sentence is the useful half — a request
|
|
39
|
-
* past the context window says exactly which limit it passed. Carried on the `Err` so the chat can print it.
|
|
40
|
-
*/
|
|
16
|
+
/** Carried on the `Err` so the chat prints the provider's own sentence rather than a status number. */
|
|
41
17
|
static refusal(response: Response): Promise<Error>;
|
|
42
|
-
static reasonOf(response: Response): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* The dialect streams `data: {chunk}` SSE lines ending with `data: [DONE]`. Tool calls arrive fragmented — the
|
|
45
|
-
* first fragment of an index carries id/name, later ones append to the arguments string — so they are assembled
|
|
46
|
-
* by index and parsed once at the end; only assistant text is worth reporting as it arrives.
|
|
47
|
-
*/
|
|
48
|
-
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
49
|
-
/** DeepSeek speaks the OpenAI chat-completions dialect, so the wire→provider mapping lives here in one place. */
|
|
50
|
-
static requestBody(model: string, request: LlmTurnRequest, stream?: boolean): {
|
|
51
|
-
tools?: {
|
|
52
|
-
type: "function";
|
|
53
|
-
function: {
|
|
54
|
-
parameters: Record<string, unknown>;
|
|
55
|
-
description?: string | undefined;
|
|
56
|
-
name: string;
|
|
57
|
-
};
|
|
58
|
-
}[] | undefined;
|
|
59
|
-
messages: DeepseekMessage[];
|
|
60
|
-
stream?: boolean | undefined;
|
|
61
|
-
model: string;
|
|
62
|
-
};
|
|
63
|
-
/** Context rides below the instructions framed as data — screen state must never read as directives. */
|
|
64
|
-
static systemPrompt({ instructions, context }: LlmTurnRequest): string;
|
|
65
|
-
static providerMessages(message: AgentWireMessage): DeepseekMessage[];
|
|
66
|
-
/**
|
|
67
|
-
* `accepts` is left undeclared, so by the time an attachment reaches here `AgentService.readable` has reduced it
|
|
68
|
-
* to its text and turned everything else into a note. Each block is labelled because a model handed two
|
|
69
|
-
* unlabelled documents can no longer cite either one.
|
|
70
|
-
*/
|
|
71
|
-
static userContent(message: AgentWireMessage): string;
|
|
72
|
-
static turnAnswer(answer: DeepseekAnswer): LlmTurnAnswer;
|
|
73
|
-
/** The provider sends arguments as a JSON string; an unparsable one becomes an empty call rather than a crash. */
|
|
74
|
-
static parsedArgs(raw: string | undefined): Record<string, unknown>;
|
|
75
18
|
}
|
|
76
19
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./anthropicLlm.d.ts";
|
|
1
2
|
export * from "./cache.adaptor";
|
|
2
3
|
export * from "./compress.adaptor";
|
|
3
4
|
export * from "./database.adaptor";
|
|
@@ -5,6 +6,8 @@ export * from "./deepseekLlm.d.ts";
|
|
|
5
6
|
export * from "./insightQuery.d.ts";
|
|
6
7
|
export * from "./llm.adaptor";
|
|
7
8
|
export * from "./logging.adaptor";
|
|
9
|
+
export * from "./openaiDialect.d.ts";
|
|
10
|
+
export * from "./openaiLlm.d.ts";
|
|
8
11
|
export * from "./queue.adaptor";
|
|
9
12
|
export * from "./role.adaptor";
|
|
10
13
|
export * from "./schedule.adaptor";
|
|
@@ -61,7 +61,13 @@ export interface LlmTurnRequest {
|
|
|
61
61
|
export interface LlmTurnAnswer {
|
|
62
62
|
text?: string;
|
|
63
63
|
toolCalls?: AgentWireToolCall[];
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Why the turn ended. `"length"` is the provider's ceiling — `finish_reason: "length"`, `stop_reason:
|
|
66
|
+
* "max_tokens"` — and it is distinguished from `"end"` because the two are indistinguishable downstream
|
|
67
|
+
* otherwise: a truncated answer reads as a complete one, and a turn cut off mid tool call carries no complete
|
|
68
|
+
* call at all, so it would end the loop looking exactly like a model that chose to stop.
|
|
69
|
+
*/
|
|
70
|
+
stop: "end" | "toolUse" | "length";
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* The provider seam for one stateless agent turn: the whole transcript in, one assistant answer out. The server
|
|
@@ -104,4 +110,22 @@ export interface LlmOption {
|
|
|
104
110
|
apiKey?: string;
|
|
105
111
|
model?: string;
|
|
106
112
|
host?: string;
|
|
113
|
+
/**
|
|
114
|
+
* What the *configured* model reads beyond text, overriding what the adaptor claims for its provider. It rides
|
|
115
|
+
* beside `model` because that is what capability belongs to: an adaptor answers for an API, and one API serves
|
|
116
|
+
* models that differ. Declared here rather than as a table the framework keeps, because a table is a claim about
|
|
117
|
+
* models that ship after it and goes quietly wrong — and getting this wrong is the worst failure available, a
|
|
118
|
+
* provider handed bytes it cannot decode either refusing the turn or accepting it having seen nothing.
|
|
119
|
+
*/
|
|
120
|
+
accepts?: LlmAccepts;
|
|
121
|
+
/**
|
|
122
|
+
* The answer ceiling, for an API that requires one. A fixed default is a hazard on a model that thinks before
|
|
123
|
+
* it writes: the budget goes on reasoning and the turn comes back empty with a length stop, which reads as the
|
|
124
|
+
* model refusing rather than as a number being too small.
|
|
125
|
+
*
|
|
126
|
+
* Sampling knobs are deliberately absent from this option. They are the one place a per-model difference is a
|
|
127
|
+
* hard failure rather than a nuance — `temperature` is a 400 on some models rather than an ignored field — so
|
|
128
|
+
* the role carries nothing it would have to guess the legality of per model.
|
|
129
|
+
*/
|
|
130
|
+
maxTokens?: number;
|
|
107
131
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { AgentWireMessage, LlmAccepts, LlmTurnAnswer, LlmTurnRequest } from "./llm.adaptor";
|
|
2
|
+
export interface OpenaiToolCall {
|
|
3
|
+
id?: string;
|
|
4
|
+
function?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
arguments?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface OpenaiAnswer {
|
|
10
|
+
choices?: {
|
|
11
|
+
message?: {
|
|
12
|
+
content?: string | null;
|
|
13
|
+
tool_calls?: OpenaiToolCall[];
|
|
14
|
+
};
|
|
15
|
+
finish_reason?: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
type OpenaiContentPart = {
|
|
19
|
+
type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "image_url";
|
|
23
|
+
image_url: {
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export interface OpenaiMessage {
|
|
28
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
29
|
+
content: string | OpenaiContentPart[];
|
|
30
|
+
tool_calls?: {
|
|
31
|
+
id: string;
|
|
32
|
+
type: "function";
|
|
33
|
+
function: {
|
|
34
|
+
name: string;
|
|
35
|
+
arguments: string;
|
|
36
|
+
};
|
|
37
|
+
}[];
|
|
38
|
+
tool_call_id?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The OpenAI chat-completions wire format, which several providers speak — OpenAI's own endpoint, DeepSeek, and
|
|
42
|
+
* every gateway that copied it. It lives apart from any one of them because a protocol fix belongs in one place:
|
|
43
|
+
* the SSE tool-call assembly below is the subtle part, and two copies of it drift silently.
|
|
44
|
+
*
|
|
45
|
+
* `accepts` decides the shape of a user turn, and nothing else here reads it. A provider that takes no image gets
|
|
46
|
+
* one string, exactly as before, because `AgentService.readable` has already reduced every attachment it cannot
|
|
47
|
+
* read to a note in the text.
|
|
48
|
+
*/
|
|
49
|
+
export declare class OpenaiDialect {
|
|
50
|
+
static requestBody(model: string, request: LlmTurnRequest, { accepts, stream }?: {
|
|
51
|
+
accepts?: LlmAccepts;
|
|
52
|
+
stream?: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
tools?: {
|
|
55
|
+
type: "function";
|
|
56
|
+
function: {
|
|
57
|
+
parameters: Record<string, unknown>;
|
|
58
|
+
description?: string | undefined;
|
|
59
|
+
name: string;
|
|
60
|
+
};
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
messages: OpenaiMessage[];
|
|
63
|
+
stream?: boolean | undefined;
|
|
64
|
+
model: string;
|
|
65
|
+
};
|
|
66
|
+
/** Context rides below the instructions framed as data — screen state must never read as directives. */
|
|
67
|
+
static systemPrompt({ instructions, context }: LlmTurnRequest): string;
|
|
68
|
+
static providerMessages(message: AgentWireMessage, accepts?: LlmAccepts): OpenaiMessage[];
|
|
69
|
+
/**
|
|
70
|
+
* Text attachments are labelled into the message, because a model handed two unlabelled documents can no longer
|
|
71
|
+
* cite either one. Images become their own parts only when the provider said it reads them; the dialect carries
|
|
72
|
+
* one as a `data:` URL, which is the same encoding whether the bytes were inlined or already addressable, so
|
|
73
|
+
* both carriers take one branch.
|
|
74
|
+
*/
|
|
75
|
+
static userContent(message: AgentWireMessage, accepts?: LlmAccepts): string | OpenaiContentPart[];
|
|
76
|
+
/**
|
|
77
|
+
* The dialect streams `data: {chunk}` SSE lines ending with `data: [DONE]`. Tool calls arrive fragmented — the
|
|
78
|
+
* first fragment of an index carries id/name, later ones append to the arguments string — so they are assembled
|
|
79
|
+
* by index and parsed once at the end; only assistant text is worth reporting as it arrives.
|
|
80
|
+
*/
|
|
81
|
+
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
82
|
+
/**
|
|
83
|
+
* The ceiling wins over the calls that did arrive. A turn the provider cut short is one whose last call may be
|
|
84
|
+
* missing, so running the batch it did finish is acting on half an intention.
|
|
85
|
+
*/
|
|
86
|
+
static stopOf(finish: string | null | undefined, calls: number): LlmTurnAnswer["stop"];
|
|
87
|
+
static turnAnswer(answer: OpenaiAnswer): LlmTurnAnswer;
|
|
88
|
+
/** The provider sends arguments as a JSON string; an unparsable one becomes an empty call rather than a crash. */
|
|
89
|
+
static parsedArgs(raw: string | undefined): Record<string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* The dialect answers a refusal as `{ error: { message } }`, and that sentence is the useful half — a request
|
|
92
|
+
* past the context window says exactly which limit it passed.
|
|
93
|
+
*/
|
|
94
|
+
static reasonOf(response: Response): Promise<string>;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LlmAccepts, LlmAdaptor, LlmOption, LlmTurnAnswer, LlmTurnRequest } from "./llm.adaptor";
|
|
2
|
+
declare const OpenaiLlm_base: import("..").AdaptorCls<{}, {
|
|
3
|
+
llmOption: import("..").InjectInfo<"use", LlmOption, never, never>;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* OpenAI's chat-completions endpoint, and every gateway that serves the same dialect — `host` is what points it
|
|
7
|
+
* at one. It is `DeepseekLlm`'s sibling rather than its replacement: same wire, and the difference that earns a
|
|
8
|
+
* second class is that this one declares `accepts`, so an attached image reaches the model as an image part
|
|
9
|
+
* instead of a note saying it could not be read.
|
|
10
|
+
*
|
|
11
|
+
* `model` is required and has no default. A default would be a model name that ages out of the provider's
|
|
12
|
+
* catalogue into a 404 at the first turn, and — worse here than for a text-only adaptor — it would decide the
|
|
13
|
+
* vision claim below on the app's behalf. Name the model in `option.setLlm({ model })`, and name
|
|
14
|
+
* `accepts: { image: false }` beside it when that model is one of the provider's text-only ones.
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpenaiLlm extends OpenaiLlm_base implements LlmAdaptor {
|
|
17
|
+
#private;
|
|
18
|
+
/** The endpoint takes image parts, so that is the provider's answer; a model that does not takes the override. */
|
|
19
|
+
get accepts(): LlmAccepts;
|
|
20
|
+
chat(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<LlmTurnAnswer | null>;
|
|
21
|
+
/** Carried on the `Err` so the chat prints the provider's own sentence rather than a status number. */
|
|
22
|
+
static refusal(response: Response): Promise<Error>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -12,7 +12,7 @@ declare const AgentEndpoint_base: import("./endpoint.d.ts").EndpointCls<import("
|
|
|
12
12
|
}, ["messages", "tools", "context", "instructions"], [arg: unknown[], arg: unknown[], arg: unknown[], arg?: string | null | undefined], [arg: Bun.BunRequest<string>], [arg: unknown[], arg: unknown[], arg: unknown[], arg: string | undefined], typeof AgentTurn, AgentTurn, Promise<AgentTurn | {
|
|
13
13
|
text: string;
|
|
14
14
|
toolCalls: import("akanjs/service").AgentWireToolCall[];
|
|
15
|
-
stop: "end" | "toolUse";
|
|
15
|
+
stop: "length" | "end" | "toolUse";
|
|
16
16
|
}>, false>;
|
|
17
17
|
}>;
|
|
18
18
|
export declare class AgentEndpoint extends AgentEndpoint_base {
|
|
@@ -2,7 +2,7 @@ export { AgentStop, AgentTurn, agentTurnConstant } from "akanjs/fetch";
|
|
|
2
2
|
declare const AgentTurnDocument_base: import("akanjs/document").DatabaseCls<{
|
|
3
3
|
text: string;
|
|
4
4
|
toolCalls: unknown[];
|
|
5
|
-
stop: NonNullable<"end" | "toolUse">;
|
|
5
|
+
stop: NonNullable<"length" | "end" | "toolUse">;
|
|
6
6
|
} & {}>;
|
|
7
7
|
export declare class AgentTurnDocument extends AgentTurnDocument_base {
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import type { AgentWireToolCall } from "akanjs/service";
|
|
|
2
2
|
interface StreamedTurn {
|
|
3
3
|
text?: string;
|
|
4
4
|
toolCalls?: AgentWireToolCall[];
|
|
5
|
-
stop?: "end" | "toolUse";
|
|
5
|
+
stop?: "end" | "toolUse" | "length";
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* The streaming half of the agent turn wire (use-agentic WIRE.md): the same endpoint answers `text/event-stream`
|
|
@@ -11,6 +11,9 @@ interface ChipsProps {
|
|
|
11
11
|
/** Omitted for a sent message: what is already on the wire cannot be taken back. */
|
|
12
12
|
onRemove?: (index: number) => void;
|
|
13
13
|
removeLabel?: string;
|
|
14
|
+
/** Files still being read, standing beside the ones that are staged so the panel is never blank mid-drop. */
|
|
15
|
+
pending?: number;
|
|
16
|
+
pendingLabel?: string;
|
|
14
17
|
}
|
|
15
|
-
export declare const Chips: ({ className, attachments, onRemove, removeLabel }: ChipsProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const Chips: ({ className, attachments, onRemove, removeLabel, pending, pendingLabel }: ChipsProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
export {};
|