@_tc/template-core 0.4.0 → 0.4.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/.skills/tc-component-usage-skills/reference/component-api.md +27 -0
- package/.skills/tc-generator/SKILL.md +1 -1
- package/.skills/tc-generator/reference/project-template/ssr/apps/hello/hello.entry.tsx +6 -1
- package/.skills/tc-generator/reference/runtime-extensions.md +10 -0
- package/AGENT_README.md +8 -2
- package/CHANGE.md +27 -0
- package/README.md +157 -8
- package/cjs/app/ai/agent/agent-scanner.service.js +1 -1
- package/cjs/app/ai/agent/agent.module.js +1 -1
- package/cjs/app/ai/ai-config.module.js +1 -1
- package/cjs/app/ai/ai-config.service.js +1 -1
- package/cjs/app/ai/ai.controller.js +1 -1
- package/cjs/app/ai/ai.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.service.js +1 -1
- package/cjs/app/ai/index.js +1 -0
- package/cjs/app/ai/mcp/internal/read-sse-response.js +2 -0
- package/cjs/app/ai/mcp/internal/stdio-process.js +1 -0
- package/cjs/app/ai/mcp/mcp-registry.service.js +2 -2
- package/cjs/app/ai/mcp/mcp.client.js +2 -3
- package/cjs/app/ai/mcp/mcp.loader.js +1 -1
- package/cjs/app/ai/mcp/mcp.module.js +1 -1
- package/cjs/app/ai/memory/checkpoint.service.js +1 -1
- package/cjs/app/ai/memory/memory.module.js +1 -1
- package/cjs/app/ai/memory/thread.service.js +1 -1
- package/cjs/app/ai/models/chat-sse.js +4 -0
- package/cjs/app/ai/models/chat.js +1 -0
- package/cjs/app/ai/models/http.js +1 -0
- package/cjs/app/ai/models/image.js +1 -0
- package/cjs/app/ai/models/video.js +1 -0
- package/cjs/app/ai/nest-service-provider.js +1 -0
- package/cjs/app/ai/rag/rag.module.js +1 -1
- package/cjs/app/ai/rag/retriever.service.js +1 -1
- package/cjs/app/ai/retention/conversation-retention.service.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime-startup.validator.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime.js +1 -0
- package/cjs/app/ai/runtime/internal/context-compaction.service.js +3 -3
- package/cjs/app/ai/runtime/internal/declaration-snapshot.js +1 -0
- package/cjs/app/ai/runtime/internal/owned-runtime-resources.js +1 -0
- package/cjs/app/ai/runtime/langchain/langchain-planner.service.js +1 -1
- package/cjs/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +1 -1
- package/cjs/app/ai/runtime/runtime.module.js +1 -1
- package/cjs/app/ai/skill/skill-scanner.service.js +1 -1
- package/cjs/app/ai/skill/skill.module.js +1 -1
- package/cjs/app/ai/snapshot-data.js +1 -0
- package/cjs/app/ai/store/internal/create-vector-store.js +1 -0
- package/cjs/app/ai/store/store.module.js +1 -1
- package/cjs/app/ai/tool/builtin/index.js +1 -1
- package/cjs/app/ai/tool/builtin/invoke-agent.tool.js +1 -1
- package/cjs/app/ai/tool/builtin/retrieve.tool.js +1 -1
- package/cjs/app/ai/tool/executor.service.js +1 -1
- package/cjs/app/ai/tool/tool-registry.service.js +1 -1
- package/cjs/app/ai/tool/tool.module.js +1 -1
- package/cjs/app/ai/trace/trace.service.js +1 -1
- package/cjs/app/csr/controller.js +1 -1
- package/cjs/app/csr/types.js +0 -0
- package/cjs/app/html/browser-options.js +1 -1
- package/cjs/app/html/shell.js +31 -16
- package/cjs/app/http/api-signing.js +1 -0
- package/cjs/app/http/body-parser.middleware.js +1 -1
- package/cjs/app/http/csp-nonce.js +1 -0
- package/cjs/app/http/error-response.js +1 -1
- package/cjs/app/http/exception-filter.js +1 -1
- package/cjs/app/http/request-body-parser-policy.js +1 -0
- package/cjs/app/http/security.guard.js +1 -1
- package/cjs/app/project/controller.js +1 -1
- package/cjs/app/project/service.js +1 -1
- package/cjs/app/providers/foundation.js +1 -1
- package/cjs/app/ssr/artifacts.js +1 -1
- package/cjs/app/ssr/controller.js +1 -1
- package/cjs/app/ssr/html.js +17 -17
- package/cjs/app/ssr/stream.js +1 -1
- package/cjs/app/static-assets.middleware.js +1 -1
- package/cjs/app/template-core.module.js +1 -1
- package/cjs/app/view/entry.tpl +2 -2
- package/cjs/bundler/buildSSR.js +1 -1
- package/cjs/bundler/entryCollect.js +1 -1
- package/cjs/bundler/feSharedConfig.js +1 -1
- package/cjs/bundler/utils.js +3 -3
- package/cjs/config/config.default.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/core/bootstrap.js +1 -1
- package/cjs/packages/core/startup.js +1 -1
- package/esm/app/ai/agent/agent-scanner.service.js +33 -36
- package/esm/app/ai/agent/agent.module.js +9 -7
- package/esm/app/ai/ai-config.module.js +14 -7
- package/esm/app/ai/ai-config.service.js +24 -20
- package/esm/app/ai/ai.controller.js +41 -41
- package/esm/app/ai/ai.module.js +15 -15
- package/esm/app/ai/guardrail/guardrail.module.js +11 -9
- package/esm/app/ai/guardrail/guardrail.service.js +5 -10
- package/esm/app/ai/index.js +2 -0
- package/esm/app/ai/mcp/internal/read-sse-response.js +35 -0
- package/esm/app/ai/mcp/internal/stdio-process.js +59 -0
- package/esm/app/ai/mcp/mcp-registry.service.js +10 -15
- package/esm/app/ai/mcp/mcp.client.js +77 -78
- package/esm/app/ai/mcp/mcp.loader.js +64 -42
- package/esm/app/ai/mcp/mcp.module.js +62 -22
- package/esm/app/ai/memory/checkpoint.service.js +18 -28
- package/esm/app/ai/memory/memory.module.js +15 -12
- package/esm/app/ai/memory/thread.service.js +21 -26
- package/esm/app/ai/models/chat-sse.js +44 -0
- package/esm/app/ai/models/chat.js +60 -0
- package/esm/app/ai/models/http.js +52 -0
- package/esm/app/ai/models/image.js +37 -0
- package/esm/app/ai/models/video.js +32 -0
- package/esm/app/ai/nest-service-provider.js +10 -0
- package/esm/app/ai/rag/rag.module.js +24 -15
- package/esm/app/ai/rag/retriever.service.js +37 -54
- package/esm/app/ai/retention/conversation-retention.service.js +16 -34
- package/esm/app/ai/runtime/ai-runtime-startup.validator.js +2 -19
- package/esm/app/ai/runtime/ai-runtime.js +104 -0
- package/esm/app/ai/runtime/internal/context-compaction.service.js +139 -145
- package/esm/app/ai/runtime/internal/declaration-snapshot.js +32 -0
- package/esm/app/ai/runtime/internal/owned-runtime-resources.js +21 -0
- package/esm/app/ai/runtime/langchain/langchain-planner.service.js +43 -49
- package/esm/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +273 -225
- package/esm/app/ai/runtime/runtime.module.js +56 -35
- package/esm/app/ai/skill/skill-scanner.service.js +11 -16
- package/esm/app/ai/skill/skill.module.js +11 -9
- package/esm/app/ai/snapshot-data.js +24 -0
- package/esm/app/ai/store/internal/create-vector-store.js +10 -0
- package/esm/app/ai/store/store.module.js +9 -13
- package/esm/app/ai/tool/builtin/index.js +16 -4
- package/esm/app/ai/tool/builtin/invoke-agent.tool.js +30 -34
- package/esm/app/ai/tool/builtin/retrieve.tool.js +9 -13
- package/esm/app/ai/tool/executor.service.js +22 -29
- package/esm/app/ai/tool/tool-registry.service.js +6 -16
- package/esm/app/ai/tool/tool.module.js +26 -12
- package/esm/app/ai/trace/trace.service.js +15 -28
- package/esm/app/csr/controller.js +114 -63
- package/esm/app/csr/types.js +0 -0
- package/esm/app/html/browser-options.js +2 -2
- package/esm/app/html/shell.js +173 -32
- package/esm/app/http/api-signing.js +13 -0
- package/esm/app/http/body-parser.middleware.js +47 -27
- package/esm/app/http/csp-nonce.js +13 -0
- package/esm/app/http/error-response.js +8 -5
- package/esm/app/http/exception-filter.js +4 -4
- package/esm/app/http/request-body-parser-policy.js +46 -0
- package/esm/app/http/security.guard.js +23 -21
- package/esm/app/project/controller.js +15 -15
- package/esm/app/project/service.js +3 -3
- package/esm/app/providers/foundation.js +5 -5
- package/esm/app/ssr/artifacts.js +25 -21
- package/esm/app/ssr/controller.js +148 -75
- package/esm/app/ssr/html.js +49 -44
- package/esm/app/ssr/stream.js +25 -24
- package/esm/app/static-assets.middleware.js +4 -4
- package/esm/app/template-core.module.js +57 -52
- package/esm/app/view/entry.tpl +2 -2
- package/esm/bundler/buildSSR.js +1 -1
- package/esm/bundler/entryCollect.js +9 -9
- package/esm/bundler/feSharedConfig.js +42 -42
- package/esm/bundler/utils.js +78 -90
- package/esm/config/config.default.js +4 -3
- package/esm/packages/common/index.js +6 -6
- package/esm/packages/core/bootstrap.js +5 -5
- package/esm/packages/core/startup.js +69 -46
- package/fe/frontend/src/common/request.js +5 -2
- package/fe/frontend/src/hooks/useRouterParams.d.ts +4 -2
- package/fe/packages/common/ssr/hydration.d.ts +9 -0
- package/fe/packages/react/core/Label/Label.d.ts +1 -0
- package/fe/packages/react/core/Label/Label.js +3 -1
- package/fe/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/default.js +16 -1
- package/fe/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/en-US.js +16 -1
- package/fe/packages/react/forms/DataTable/index.d.ts +2 -0
- package/fe/packages/react/forms/DataTable/index.js +43 -29
- package/fe/packages/react/forms/Form/FormItem.js +39 -12
- package/fe/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/fe/packages/react/forms/MultiSelect/MultiSelect.js +218 -0
- package/fe/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/fe/packages/react/forms/MultiSelect/index.js +2 -0
- package/fe/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/fe/packages/react/forms/Pagination/Pagination.js +13 -4
- package/fe/packages/react/forms/Select/Select.d.ts +11 -0
- package/fe/packages/react/forms/Select/Select.js +20 -7
- package/fe/packages/react/forms/index.d.ts +1 -0
- package/fe/packages/react/forms/index.js +3 -1
- package/fe/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/fe/packages/react/index.js +2 -1
- package/fe/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/fe/packages/react/overlays/Drawer/Drawer.js +16 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.js +27 -14
- package/fe/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/fe/packages/react/overlays/Modal/Modal.js +26 -2
- package/fe/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/fe/packages/react/overlays/Modal/ModalManager.js +15 -5
- package/fe/packages/react/overlays/Modal/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/fe/packages/react/overlays/Overlay/Overlay.js +31 -14
- package/fe/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/fe/packages/react/overlays/Overlay/focusTypes.js +0 -0
- package/fe/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.js +290 -0
- package/fe/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/fe/packages/react/overlays/Popup/Popup.js +28 -11
- package/fe/packages/react/ui/components/index.js +2 -1
- package/fe/packages/react/ui/index.js +2 -1
- package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.js +5 -1
- package/fe/ssr/components/StreamingRender/StreamingRender.js +1 -1
- package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.js +9 -1
- package/fe/ssr/createSSREntry.d.ts +9 -3
- package/fe/ssr/createSSREntry.js +43 -19
- package/fe/ssr/index.d.ts +4 -1
- package/fe/ssr/index.js +2 -1
- package/fe/ssr/router.d.ts +76 -0
- package/fe/ssr/router.js +349 -0
- package/fe/ssr/types.d.ts +1 -1
- package/models/packages/common/ssr/hydration.d.ts +9 -0
- package/models/packages/react/core/Label/Label.d.ts +1 -0
- package/models/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/models/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/models/packages/react/forms/DataTable/index.d.ts +2 -0
- package/models/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/models/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/models/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/models/packages/react/forms/Select/Select.d.ts +11 -0
- package/models/packages/react/forms/index.d.ts +1 -0
- package/models/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/models/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/models/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/models/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/models/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/models/packages/react/overlays/Modal/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/models/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/models/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/models/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/package.json +26 -1
- package/types/app/ai/agent/agent-scanner.service.d.ts +4 -4
- package/types/app/ai/ai-config.service.d.ts +7 -3
- package/types/app/ai/guardrail/guardrail.service.d.ts +2 -2
- package/types/app/ai/index.d.ts +9 -0
- package/types/app/ai/mcp/internal/load-mcp-config.d.ts +2 -2
- package/types/app/ai/mcp/internal/read-sse-response.d.ts +2 -0
- package/types/app/ai/mcp/internal/stdio-process.d.ts +5 -0
- package/types/app/ai/mcp/mcp-registry.service.d.ts +5 -3
- package/types/app/ai/mcp/mcp.client.d.ts +7 -4
- package/types/app/ai/mcp/mcp.loader.d.ts +11 -11
- package/types/app/ai/mcp/mcp.module.d.ts +5 -5
- package/types/app/ai/memory/thread.service.d.ts +3 -3
- package/types/app/ai/models/chat-sse.d.ts +5 -0
- package/types/app/ai/models/chat.d.ts +22 -0
- package/types/app/ai/models/http.d.ts +20 -0
- package/types/app/ai/models/image.d.ts +69 -0
- package/types/app/ai/models/video.d.ts +99 -0
- package/types/app/ai/nest-service-provider.d.ts +6 -0
- package/types/app/ai/retention/conversation-retention.service.d.ts +3 -4
- package/types/app/ai/runtime/ai-runtime-startup.validator.d.ts +2 -3
- package/types/app/ai/runtime/ai-runtime.d.ts +46 -0
- package/types/app/ai/runtime/internal/agent-run-context.d.ts +4 -0
- package/types/app/ai/runtime/internal/context-compaction.service.d.ts +2 -2
- package/types/app/ai/runtime/internal/declaration-snapshot.d.ts +8 -0
- package/types/app/ai/runtime/internal/owned-runtime-resources.d.ts +5 -0
- package/types/app/ai/runtime/langchain/langchain-planner.service.d.ts +1 -1
- package/types/app/ai/runtime/langgraph/langgraph-orchestrator.service.d.ts +33 -16
- package/types/app/ai/skill/skill-scanner.service.d.ts +3 -4
- package/types/app/ai/snapshot-data.d.ts +1 -0
- package/types/app/ai/store/internal/create-vector-store.d.ts +4 -0
- package/types/app/ai/tool/builtin/index.d.ts +1 -1
- package/types/app/ai/tool/builtin/invoke-agent.tool.d.ts +10 -3
- package/types/app/ai/tool/builtin/retrieve.tool.d.ts +4 -3
- package/types/app/ai/tool/executor.service.d.ts +3 -3
- package/types/app/ai/tool/tool-registry.service.d.ts +2 -7
- package/types/app/ai/tool/tool.interface.d.ts +1 -1
- package/types/app/ai/tool/tool.module.d.ts +8 -1
- package/types/app/ai/trace/trace.service.d.ts +4 -5
- package/types/app/csr/types.d.ts +10 -0
- package/types/app/html/browser-options.d.ts +1 -1
- package/types/app/html/shell.d.ts +37 -10
- package/types/app/http/api-signing.d.ts +16 -0
- package/types/app/http/body-parser.middleware.d.ts +6 -2
- package/types/app/http/csp-nonce.d.ts +3 -0
- package/types/app/http/error-response.d.ts +1 -0
- package/types/app/http/request-body-parser-policy.d.ts +8 -0
- package/types/app/http/security.guard.d.ts +1 -0
- package/types/app/ssr/artifacts.d.ts +6 -3
- package/types/app/ssr/html.d.ts +7 -0
- package/types/app/ssr/stream.d.ts +1 -1
- package/types/app/ssr/types.d.ts +56 -0
- package/types/bundler/buildSSR.d.ts +2 -1
- package/types/bundler/index.d.ts +1 -1
- package/types/bundler/state.d.ts +13 -0
- package/types/bundler/utils.d.ts +3 -14
- package/types/config/config.default.d.ts +9 -3
- package/types/index.d.ts +4 -1
- package/types/packages/common/ssr/hydration.d.ts +13 -0
- package/types/packages/core/index.d.ts +1 -1
- package/types/packages/core/startup.d.ts +41 -0
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import o from "@oxc-project/runtime/helpers/decorate";
|
|
7
|
-
import { randomUUID as s } from "crypto";
|
|
8
|
-
import { AIMessage as c, HumanMessage as l, SystemMessage as u, ToolMessage as d } from "@langchain/core/messages";
|
|
9
|
-
import { convertToOpenAITool as f } from "@langchain/core/utils/function_calling";
|
|
1
|
+
import { countRequestBudget as e, resolveContextCompressionThresholds as t } from "../internal/request-budget.js";
|
|
2
|
+
import { resolveLlm as n } from "../internal/load-llm-config.js";
|
|
3
|
+
import { randomUUID as r } from "crypto";
|
|
4
|
+
import { AIMessage as i, HumanMessage as a, SystemMessage as o, ToolMessage as s } from "@langchain/core/messages";
|
|
5
|
+
import { convertToOpenAITool as c } from "@langchain/core/utils/function_calling";
|
|
10
6
|
//#region app/ai/runtime/langchain/langchain-planner.service.ts
|
|
11
|
-
|
|
12
|
-
function m(e) {
|
|
7
|
+
function l(e) {
|
|
13
8
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
14
9
|
}
|
|
15
|
-
function
|
|
16
|
-
return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e :
|
|
10
|
+
function u(e) {
|
|
11
|
+
return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : l(e) && typeof e.text == "string" ? e.text : "").join("") : "";
|
|
17
12
|
}
|
|
18
|
-
function
|
|
13
|
+
function d(e) {
|
|
19
14
|
if (typeof e == "string") try {
|
|
20
15
|
return JSON.parse(e);
|
|
21
16
|
} catch {
|
|
22
17
|
return {};
|
|
23
18
|
}
|
|
24
|
-
return
|
|
19
|
+
return l(e) ? e : {};
|
|
25
20
|
}
|
|
26
|
-
function
|
|
27
|
-
return `call_${
|
|
21
|
+
function f() {
|
|
22
|
+
return `call_${r().replace(/-/g, "")}`;
|
|
28
23
|
}
|
|
29
|
-
function
|
|
24
|
+
function p(e) {
|
|
30
25
|
return e.map((e) => {
|
|
31
26
|
let t = e.schema;
|
|
32
27
|
return {
|
|
@@ -34,59 +29,59 @@ function v(e) {
|
|
|
34
29
|
function: {
|
|
35
30
|
name: e.name,
|
|
36
31
|
description: e.description,
|
|
37
|
-
parameters:
|
|
32
|
+
parameters: l(t) ? t : {}
|
|
38
33
|
}
|
|
39
34
|
};
|
|
40
35
|
});
|
|
41
36
|
}
|
|
42
|
-
function
|
|
37
|
+
function m(e) {
|
|
43
38
|
return e.map((e) => {
|
|
44
|
-
let t =
|
|
39
|
+
let t = c(e);
|
|
45
40
|
return {
|
|
46
41
|
type: t.type,
|
|
47
42
|
function: t.function
|
|
48
43
|
};
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
|
-
function
|
|
46
|
+
function h(e) {
|
|
52
47
|
let t = e.tool_calls;
|
|
53
48
|
return !t || t.length === 0 ? e : {
|
|
54
49
|
...e,
|
|
55
50
|
tool_calls: t.map((e) => ({
|
|
56
51
|
...e,
|
|
57
|
-
id: typeof e.id == "string" && e.id !== "" ? e.id :
|
|
52
|
+
id: typeof e.id == "string" && e.id !== "" ? e.id : f(),
|
|
58
53
|
type: typeof e.type == "string" && e.type !== "" ? e.type : "function"
|
|
59
54
|
}))
|
|
60
55
|
};
|
|
61
56
|
}
|
|
62
|
-
function
|
|
57
|
+
function g(e) {
|
|
63
58
|
return {
|
|
64
|
-
id: e.id ??
|
|
59
|
+
id: e.id ?? f(),
|
|
65
60
|
name: e.function.name,
|
|
66
|
-
args:
|
|
61
|
+
args: d(e.function.arguments)
|
|
67
62
|
};
|
|
68
63
|
}
|
|
69
|
-
function
|
|
70
|
-
return e.map((e) => e.role === "system" ? new
|
|
64
|
+
function _(e) {
|
|
65
|
+
return e.map((e) => e.role === "system" ? new o(e.content) : e.role === "user" ? new a(e.content) : e.role === "tool" ? new s({
|
|
71
66
|
content: e.content,
|
|
72
67
|
tool_call_id: e.tool_call_id ?? ""
|
|
73
|
-
}) : new
|
|
68
|
+
}) : new i({
|
|
74
69
|
content: e.content,
|
|
75
|
-
...e.tool_calls && e.tool_calls.length > 0 ? { tool_calls: e.tool_calls.map(
|
|
70
|
+
...e.tool_calls && e.tool_calls.length > 0 ? { tool_calls: e.tool_calls.map(g) } : {}
|
|
76
71
|
}));
|
|
77
72
|
}
|
|
78
|
-
function
|
|
73
|
+
function v(e) {
|
|
79
74
|
let t = (e.tool_calls ?? []).map((e) => ({
|
|
80
|
-
id: typeof e.id == "string" && e.id !== "" ? e.id :
|
|
75
|
+
id: typeof e.id == "string" && e.id !== "" ? e.id : f(),
|
|
81
76
|
name: e.name,
|
|
82
|
-
args:
|
|
77
|
+
args: d(e.args)
|
|
83
78
|
}));
|
|
84
79
|
return {
|
|
85
|
-
content:
|
|
80
|
+
content: u(e.content),
|
|
86
81
|
toolCalls: t
|
|
87
82
|
};
|
|
88
83
|
}
|
|
89
|
-
function
|
|
84
|
+
function y(e, t) {
|
|
90
85
|
return {
|
|
91
86
|
role: "assistant",
|
|
92
87
|
content: e,
|
|
@@ -100,7 +95,7 @@ function w(e, t) {
|
|
|
100
95
|
})) } : {}
|
|
101
96
|
};
|
|
102
97
|
}
|
|
103
|
-
var
|
|
98
|
+
var b = class {
|
|
104
99
|
constructor(e) {
|
|
105
100
|
this.configService = e;
|
|
106
101
|
}
|
|
@@ -114,7 +109,7 @@ var T = class {
|
|
|
114
109
|
async plan(e, t, n = {}) {
|
|
115
110
|
let { resolved: r, toolSchemas: i, requestBudget: a, requestCounter: o } = await this.prepareRequest(e, t, n.model, !1);
|
|
116
111
|
if (r.kind === "custom") return this.planWithProvider(r.provider, e, i, n, a, o);
|
|
117
|
-
let s = r.model, c = t.length > 0 ? s.bindTools(t) : s, l =
|
|
112
|
+
let s = r.model, c = t.length > 0 ? s.bindTools(t) : s, l = _(e), u = n.onDelta ? await this.stream(c, l, n.onDelta) : v(await c.invoke(l)), d = y(u.content, u.toolCalls);
|
|
118
113
|
return u.toolCalls.length > 0 ? {
|
|
119
114
|
kind: "tool",
|
|
120
115
|
message: d,
|
|
@@ -129,8 +124,8 @@ var T = class {
|
|
|
129
124
|
requestCounter: o
|
|
130
125
|
};
|
|
131
126
|
}
|
|
132
|
-
async prepareRequest(
|
|
133
|
-
let s =
|
|
127
|
+
async prepareRequest(r, i, a, o) {
|
|
128
|
+
let s = n(this.configService, a), c = s.kind === "custom" ? p(i) : m(i), l = s.kind === "custom" ? s.provider.countRequestTokens?.bind(s.provider) : void 0, u = s.kind === "custom" ? s.provider.estimateRequestTokens?.bind(s.provider) : void 0;
|
|
134
129
|
if (!l && !u && !s.tokenizerEncoding) throw Error(`[ai] model "${s.modelName}" needs tokenizerEncoding or a Provider token estimator`);
|
|
135
130
|
let d = {
|
|
136
131
|
model: s.modelName,
|
|
@@ -141,13 +136,13 @@ var T = class {
|
|
|
141
136
|
return {
|
|
142
137
|
resolved: s,
|
|
143
138
|
toolSchemas: c,
|
|
144
|
-
requestBudget: await
|
|
139
|
+
requestBudget: await e({
|
|
145
140
|
model: s.modelName,
|
|
146
141
|
contextWindowTokens: s.contextWindowTokens,
|
|
147
142
|
responseReserveTokens: s.responseReserveTokens,
|
|
148
|
-
messages:
|
|
143
|
+
messages: r,
|
|
149
144
|
tools: c,
|
|
150
|
-
thresholds:
|
|
145
|
+
thresholds: t(this.configService),
|
|
151
146
|
...s.tokenizerEncoding ? { tokenizerEncoding: s.tokenizerEncoding } : {},
|
|
152
147
|
...l ? { countRequestTokens: l } : {},
|
|
153
148
|
...u ? { estimateRequestTokens: u } : {}
|
|
@@ -156,15 +151,15 @@ var T = class {
|
|
|
156
151
|
};
|
|
157
152
|
}
|
|
158
153
|
async planWithProvider(e, t, n, r, i, a) {
|
|
159
|
-
let o =
|
|
154
|
+
let o = h(await e.chat(t, {
|
|
160
155
|
...r.model ? { model: r.model } : {},
|
|
161
156
|
...n.length > 0 ? { tools: n } : {}
|
|
162
157
|
}));
|
|
163
158
|
o.content !== "" && r.onDelta && r.onDelta(o.content);
|
|
164
159
|
let s = (o.tool_calls ?? []).map((e) => ({
|
|
165
|
-
id: typeof e.id == "string" && e.id !== "" ? e.id :
|
|
160
|
+
id: typeof e.id == "string" && e.id !== "" ? e.id : f(),
|
|
166
161
|
name: e.function.name,
|
|
167
|
-
args:
|
|
162
|
+
args: d(e.function.arguments)
|
|
168
163
|
}));
|
|
169
164
|
return s.length > 0 ? {
|
|
170
165
|
kind: "tool",
|
|
@@ -183,13 +178,12 @@ var T = class {
|
|
|
183
178
|
async stream(e, t, n) {
|
|
184
179
|
let r = await e.stream(t), i;
|
|
185
180
|
for await (let e of r) {
|
|
186
|
-
let t =
|
|
181
|
+
let t = u(e.content);
|
|
187
182
|
t !== "" && n(t), i = i ? i.concat(e) : e;
|
|
188
183
|
}
|
|
189
184
|
if (!i) throw Error("[ai] langchain 流式返回为空");
|
|
190
|
-
return
|
|
185
|
+
return v(i);
|
|
191
186
|
}
|
|
192
187
|
};
|
|
193
|
-
T = o([i(), a("design:paramtypes", [typeof (p = e !== void 0 && e) == "function" ? p : Object])], T);
|
|
194
188
|
//#endregion
|
|
195
|
-
export {
|
|
189
|
+
export { b as LangChainPlannerService };
|