@_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,50 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ToolRegistryService as c } from "../../tool/tool-registry.service.js";
|
|
10
|
-
import { ExecutorService as l } from "../../tool/executor.service.js";
|
|
11
|
-
import { TraceService as u } from "../../trace/trace.service.js";
|
|
12
|
-
import { InProcessThreadExecutionCoordinator as d, THREAD_EXECUTION_COORDINATOR as f } from "../thread-execution-coordinator.js";
|
|
13
|
-
import { ConversationRetentionService as p } from "../../retention/conversation-retention.service.js";
|
|
14
|
-
import { LangChainPlannerService as m } from "../langchain/langchain-planner.service.js";
|
|
15
|
-
import { ContextCompactionService as h } from "../internal/context-compaction.service.js";
|
|
16
|
-
import { createArchiveMessageId as g } from "../../store/internal/archive-id.js";
|
|
17
|
-
import { RunEventQueue as _ } from "../internal/run-event-queue.js";
|
|
18
|
-
import { toStructuredTools as v } from "../langchain/skill-tool.adapter.js";
|
|
19
|
-
import { hasOutput as y } from "./agent.state.js";
|
|
20
|
-
import { AGENT_GRAPH_EDGES as b, AGENT_GRAPH_NODES as x, buildAgentGraph as S } from "./agent.graph.js";
|
|
21
|
-
import { Inject as C, Injectable as w, Optional as T } from "@nestjs/common";
|
|
22
|
-
import E from "@oxc-project/runtime/helpers/decorateMetadata";
|
|
23
|
-
import D from "@oxc-project/runtime/helpers/decorate";
|
|
24
|
-
import O from "@oxc-project/runtime/helpers/decorateParam";
|
|
1
|
+
import { resolveMaxIterations as e } from "../internal/load-runtime-config.js";
|
|
2
|
+
import { createArchiveMessageId as t } from "../../store/internal/archive-id.js";
|
|
3
|
+
import { agentRunContext as n } from "../internal/agent-run-context.js";
|
|
4
|
+
import { RunEventQueue as r } from "../internal/run-event-queue.js";
|
|
5
|
+
import { InProcessThreadExecutionCoordinator as i } from "../thread-execution-coordinator.js";
|
|
6
|
+
import { toStructuredTools as a } from "../langchain/skill-tool.adapter.js";
|
|
7
|
+
import { hasOutput as o } from "./agent.state.js";
|
|
8
|
+
import { AGENT_GRAPH_EDGES as s, AGENT_GRAPH_NODES as c, buildAgentGraph as l } from "./agent.graph.js";
|
|
25
9
|
//#region app/ai/runtime/langgraph/langgraph-orchestrator.service.ts
|
|
26
|
-
var
|
|
10
|
+
var u = class extends Error {
|
|
27
11
|
code = "THREAD_MIGRATION_CONFLICT";
|
|
28
12
|
retryable = !0;
|
|
29
13
|
constructor(e) {
|
|
30
14
|
super(`[ai] thread ${e} changed after migration preview; create a new preview`), this.name = "ThreadMigrationConflictError";
|
|
31
15
|
}
|
|
32
16
|
};
|
|
33
|
-
function
|
|
17
|
+
function d(e) {
|
|
34
18
|
return typeof e == "string" ? e : e == null ? "" : JSON.stringify(e);
|
|
35
19
|
}
|
|
36
|
-
var
|
|
20
|
+
var f = class {
|
|
37
21
|
threadExecutionCoordinator;
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
runtimeId = Symbol("AgentRuntime");
|
|
23
|
+
lifecycleState = "open";
|
|
24
|
+
activeOperations = 0;
|
|
25
|
+
drainResolve;
|
|
26
|
+
closePromise;
|
|
27
|
+
constructor(e, t, n, r, a, o, s, c, l, u, d, f, p, m) {
|
|
28
|
+
this.planner = e, this.executor = t, this.agentScanner = n, this.skillScanner = r, this.toolRegistry = a, this.traceService = o, this.guardrailService = s, this.threadService = c, this.checkpointService = l, this.configService = u, this.contextCompactionService = d, this.conversationRetention = p, this.closeOwnedResources = m, this.threadExecutionCoordinator = f ?? new i();
|
|
40
29
|
}
|
|
41
30
|
getGraph() {
|
|
42
31
|
return {
|
|
43
|
-
nodes: [...
|
|
44
|
-
edges:
|
|
32
|
+
nodes: [...c],
|
|
33
|
+
edges: s.map((e) => ({ ...e }))
|
|
45
34
|
};
|
|
46
35
|
}
|
|
47
36
|
async inspectThreadContext(e) {
|
|
37
|
+
return this.withOperation(() => this.inspectThreadContextInternal(e));
|
|
38
|
+
}
|
|
39
|
+
async inspectThreadContextInternal(e) {
|
|
48
40
|
let t = this.requireThreadId(e);
|
|
49
41
|
return this.threadExecutionCoordinator.runExclusive(t, async () => {
|
|
50
42
|
let { checkpoint: e, archiveRevision: n } = await this.checkpointService.loadThreadState(t);
|
|
@@ -60,67 +52,73 @@ var U = class {
|
|
|
60
52
|
});
|
|
61
53
|
}
|
|
62
54
|
async previewThreadMigration(e, t) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let a =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
return this.withOperation(() => this.previewThreadMigrationInternal(e, t));
|
|
56
|
+
}
|
|
57
|
+
async previewThreadMigrationInternal(e, n) {
|
|
58
|
+
let r = this.requireThreadId(e), i = typeof n == "string" ? n.trim() : "";
|
|
59
|
+
if (i === "") throw Error("[ai] target Agent is required for thread migration");
|
|
60
|
+
let a = this.agentScanner.get(i);
|
|
61
|
+
if (!a) throw Error(`[ai] agent 未注册:${i}`);
|
|
62
|
+
await this.conversationRetention?.assertNotExpired(r);
|
|
63
|
+
let o = await this.threadExecutionCoordinator.runExclusive(r, async () => {
|
|
64
|
+
let { checkpoint: e, archive: n, archiveRevision: i } = await this.checkpointService.loadThreadState(r), a = e ?? this.checkpointService.createInitialCheckpoint(r, "", ""), o = n.length === 0 && e?.messages?.length ? e.messages.map(() => t()) : [];
|
|
65
|
+
if (n.length === 0 && a.summarizedThroughSeq !== 0 && o.length > 0) throw Error("[ai] legacy checkpoint cursor cannot be matched to its messages");
|
|
66
|
+
let s = n.length === 0 ? (e?.messages ?? []).map((e, t) => {
|
|
67
|
+
let n = o[t];
|
|
68
|
+
if (!n) throw Error("[ai] legacy checkpoint message could not be assigned an archive id");
|
|
74
69
|
return {
|
|
75
|
-
threadId:
|
|
70
|
+
threadId: r,
|
|
76
71
|
seq: t + 1,
|
|
77
|
-
messageId:
|
|
72
|
+
messageId: n,
|
|
78
73
|
role: e.role,
|
|
79
74
|
content: e.content,
|
|
80
75
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
81
76
|
};
|
|
82
|
-
}) : [],
|
|
83
|
-
...
|
|
84
|
-
initialGoal:
|
|
85
|
-
latestUserDirection:
|
|
77
|
+
}) : [], c = {
|
|
78
|
+
...a.pinnedContext,
|
|
79
|
+
initialGoal: a.pinnedContext.initialGoal || s[0]?.content || n.find((e) => e.role === "user")?.content || "",
|
|
80
|
+
latestUserDirection: a.pinnedContext.latestUserDirection || ""
|
|
86
81
|
};
|
|
87
82
|
return {
|
|
88
83
|
checkpoint: {
|
|
89
|
-
...
|
|
90
|
-
pinnedContext:
|
|
84
|
+
...a,
|
|
85
|
+
pinnedContext: c
|
|
91
86
|
},
|
|
92
|
-
archive: [...
|
|
93
|
-
archiveRevision:
|
|
94
|
-
legacyMessageIds:
|
|
87
|
+
archive: [...n, ...s],
|
|
88
|
+
archiveRevision: i,
|
|
89
|
+
legacyMessageIds: o
|
|
95
90
|
};
|
|
96
|
-
}),
|
|
91
|
+
}), s = await this.contextCompactionService.summarizeForMigration(o.checkpoint, o.archive, a.summaryModel ?? a.model);
|
|
97
92
|
return {
|
|
98
|
-
threadId:
|
|
99
|
-
sourceAgentId:
|
|
100
|
-
targetAgentId:
|
|
101
|
-
checkpointRevision:
|
|
102
|
-
archiveRevision:
|
|
93
|
+
threadId: r,
|
|
94
|
+
sourceAgentId: o.checkpoint.agentId,
|
|
95
|
+
targetAgentId: a.name,
|
|
96
|
+
checkpointRevision: o.checkpoint.revision,
|
|
97
|
+
archiveRevision: o.archiveRevision,
|
|
103
98
|
candidatePinnedContext: {
|
|
104
|
-
...structuredClone(
|
|
105
|
-
...
|
|
99
|
+
...structuredClone(o.checkpoint.pinnedContext),
|
|
100
|
+
...s.latestUserDirection === void 0 ? {} : { latestUserDirection: s.latestUserDirection }
|
|
106
101
|
},
|
|
107
|
-
candidateSummary: structuredClone(
|
|
108
|
-
coveredThroughSeq:
|
|
109
|
-
legacyMessageIds:
|
|
102
|
+
candidateSummary: structuredClone(s.rollingSummary),
|
|
103
|
+
coveredThroughSeq: s.summarizedThroughSeq,
|
|
104
|
+
legacyMessageIds: o.legacyMessageIds
|
|
110
105
|
};
|
|
111
106
|
}
|
|
112
107
|
async confirmThreadMigration(e) {
|
|
108
|
+
return this.withOperation(() => this.confirmThreadMigrationInternal(e));
|
|
109
|
+
}
|
|
110
|
+
async confirmThreadMigrationInternal(e) {
|
|
113
111
|
let t = this.requireThreadId(e?.threadId);
|
|
114
112
|
return this.threadExecutionCoordinator.runExclusive(t, async () => {
|
|
115
113
|
let n = this.agentScanner.get(e.targetAgentId);
|
|
116
114
|
if (!n || n.name !== e.targetAgentId) throw Error(`[ai] target Agent is no longer registered: ${e.targetAgentId}`);
|
|
117
115
|
let { checkpoint: r, archive: i, archiveRevision: a } = await this.checkpointService.loadThreadState(t), o = r?.revision ?? 0;
|
|
118
|
-
if (o !== e.checkpointRevision || a !== e.archiveRevision || (r?.agentId ?? "") !== e.sourceAgentId) throw new
|
|
116
|
+
if (o !== e.checkpointRevision || a !== e.archiveRevision || (r?.agentId ?? "") !== e.sourceAgentId) throw new u(t);
|
|
119
117
|
let s = i.length === 0 ? r?.messages ?? [] : [];
|
|
120
|
-
if (e.legacyMessageIds.length !== s.length) throw new
|
|
118
|
+
if (e.legacyMessageIds.length !== s.length) throw new u(t);
|
|
121
119
|
let c = s.map((n, r) => {
|
|
122
120
|
let i = e.legacyMessageIds[r];
|
|
123
|
-
if (!i) throw new
|
|
121
|
+
if (!i) throw new u(t);
|
|
124
122
|
return {
|
|
125
123
|
threadId: t,
|
|
126
124
|
seq: e.archiveRevision + r + 1,
|
|
@@ -129,10 +127,10 @@ var U = class {
|
|
|
129
127
|
content: n.content,
|
|
130
128
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
131
129
|
};
|
|
132
|
-
}), l = e.archiveRevision + c.length,
|
|
133
|
-
if (!Number.isSafeInteger(e.coveredThroughSeq) || e.coveredThroughSeq <
|
|
134
|
-
let
|
|
135
|
-
...
|
|
130
|
+
}), l = e.archiveRevision + c.length, d = r ?? this.checkpointService.createInitialCheckpoint(t, "", "");
|
|
131
|
+
if (!Number.isSafeInteger(e.coveredThroughSeq) || e.coveredThroughSeq < d.summarizedThroughSeq || e.coveredThroughSeq > l) throw Error("[ai] migration preview contains an invalid summary cursor");
|
|
132
|
+
let f = {
|
|
133
|
+
...d,
|
|
136
134
|
agentId: n.name,
|
|
137
135
|
pinnedContext: structuredClone(e.candidatePinnedContext),
|
|
138
136
|
rollingSummary: structuredClone(e.candidateSummary),
|
|
@@ -140,10 +138,10 @@ var U = class {
|
|
|
140
138
|
revision: o,
|
|
141
139
|
updatedAt: Date.now()
|
|
142
140
|
};
|
|
143
|
-
if (delete
|
|
144
|
-
let
|
|
145
|
-
if (!
|
|
146
|
-
return
|
|
141
|
+
if (delete f.messages, !await this.checkpointService.commitMigration(f, e.archiveRevision, o, c)) throw new u(t);
|
|
142
|
+
let p = await this.checkpointService.load(t);
|
|
143
|
+
if (!p) throw Error(`[ai] migrated checkpoint could not be reloaded for ${t}`);
|
|
144
|
+
return p;
|
|
147
145
|
});
|
|
148
146
|
}
|
|
149
147
|
requireThreadId(e) {
|
|
@@ -152,168 +150,239 @@ var U = class {
|
|
|
152
150
|
return t;
|
|
153
151
|
}
|
|
154
152
|
async run(e, t, n, r, i = {}) {
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
return this.withOperation(async () => {
|
|
154
|
+
let a = this.threadService.ensureThread(n);
|
|
155
|
+
return this.threadExecutionCoordinator.runExclusive(a, () => this.runExclusive(e, t, a, r, i));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async close() {
|
|
159
|
+
if (this.activeParent()) throw Error("[ai] runtime.close() cannot be called from an active run");
|
|
160
|
+
return this.closePromise ? this.closePromise : (this.lifecycleState = "closing", this.closePromise = this.drainAndClose(), this.closePromise);
|
|
161
|
+
}
|
|
162
|
+
onModuleDestroy() {
|
|
163
|
+
return this.close();
|
|
164
|
+
}
|
|
165
|
+
async withOperation(e) {
|
|
166
|
+
let t = this.acceptOperation();
|
|
167
|
+
try {
|
|
168
|
+
return await e();
|
|
169
|
+
} finally {
|
|
170
|
+
t();
|
|
171
|
+
}
|
|
157
172
|
}
|
|
158
|
-
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
activeParent() {
|
|
174
|
+
let e = n.getStore();
|
|
175
|
+
return e?.runtimeId === this.runtimeId && e.lease?.active ? e : void 0;
|
|
176
|
+
}
|
|
177
|
+
acceptOperation() {
|
|
178
|
+
if (this.lifecycleState !== "open" && !this.activeParent()) throw Error("[ai] runtime is closing and cannot accept a new run");
|
|
179
|
+
this.activeOperations += 1;
|
|
180
|
+
let e = !1;
|
|
181
|
+
return () => {
|
|
182
|
+
e || (e = !0, --this.activeOperations, this.lifecycleState === "closing" && this.activeOperations === 0 && (this.drainResolve?.(), this.drainResolve = void 0));
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async drainAndClose() {
|
|
186
|
+
try {
|
|
187
|
+
if (this.activeOperations > 0 && await new Promise((e) => {
|
|
188
|
+
this.drainResolve = e;
|
|
189
|
+
}), this.closeOwnedResources) {
|
|
190
|
+
await this.closeOwnedResources();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
let e = (await Promise.allSettled([this.conversationRetention?.onModuleDestroy(), this.traceService.onModuleDestroy()].filter((e) => e !== void 0))).filter((e) => e.status === "rejected").map((e) => e.reason);
|
|
194
|
+
if (e.length === 1) throw e[0];
|
|
195
|
+
if (e.length > 1) throw AggregateError(e, "[ai] runtime resources failed to close");
|
|
196
|
+
} finally {
|
|
197
|
+
this.lifecycleState = "closed";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async runExclusive(t, i, s, c, u = {}) {
|
|
201
|
+
let f = this.agentScanner.get(t);
|
|
202
|
+
if (!f) throw Error(`[ai] agent 未注册:${t}`);
|
|
203
|
+
let p = d(i), m = this.guardrailService.check(p);
|
|
204
|
+
if (!m.safe) {
|
|
205
|
+
let e = `请求已被安全策略拦截:${m.reason ?? "命中安全规则"}`, t = {
|
|
164
206
|
type: "guardrail",
|
|
165
207
|
content: e,
|
|
166
208
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
167
209
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
168
|
-
...
|
|
169
|
-
},
|
|
170
|
-
return await
|
|
210
|
+
...m.reason ? { error: m.reason } : {}
|
|
211
|
+
}, n = await this.traceService.createRun(f.name, i);
|
|
212
|
+
return await u.onStart?.(n.runId), await this.traceService.addStep(n.runId, t), await this.traceService.finish(n.runId, e), c?.({
|
|
171
213
|
type: "step",
|
|
172
|
-
step:
|
|
214
|
+
step: t
|
|
173
215
|
}), {
|
|
174
|
-
runId:
|
|
216
|
+
runId: n.runId,
|
|
175
217
|
output: e,
|
|
176
|
-
steps: [
|
|
177
|
-
threadId:
|
|
218
|
+
steps: [t],
|
|
219
|
+
threadId: s
|
|
178
220
|
};
|
|
179
221
|
}
|
|
180
|
-
await this.conversationRetention?.assertNotExpired(
|
|
181
|
-
let { checkpoint:
|
|
182
|
-
if (
|
|
183
|
-
if (
|
|
184
|
-
if (!
|
|
185
|
-
if (
|
|
186
|
-
let
|
|
187
|
-
...
|
|
222
|
+
await this.conversationRetention?.assertNotExpired(s);
|
|
223
|
+
let { checkpoint: h, archive: g } = await this.checkpointService.loadThreadState(s);
|
|
224
|
+
if (h && h.agentId === "") throw Error(`[ai] thread ${s} is not bound to an Agent; explicit migration is required`);
|
|
225
|
+
if (h && h.agentId !== f.name) throw Error(`[ai] thread ${s} is bound to Agent ${h.agentId}; explicit migration is required`);
|
|
226
|
+
if (!h && g.length > 0) throw Error(`[ai] thread ${s} has unbound archive history; explicit migration is required`);
|
|
227
|
+
if (h?.messages?.length && g.length === 0) throw Error(`[ai] thread ${s} contains legacy messages; explicit migration is required`);
|
|
228
|
+
let _ = h ?? this.checkpointService.createInitialCheckpoint(s, f.name, p), v = u.hardConstraints === void 0 ? _ : {
|
|
229
|
+
..._,
|
|
188
230
|
pinnedContext: {
|
|
189
|
-
...
|
|
190
|
-
hardConstraints: [...
|
|
231
|
+
..._.pinnedContext,
|
|
232
|
+
hardConstraints: [...u.hardConstraints]
|
|
191
233
|
}
|
|
192
|
-
},
|
|
193
|
-
threadId:
|
|
194
|
-
agent:
|
|
195
|
-
checkpoint:
|
|
196
|
-
archive:
|
|
197
|
-
currentInput:
|
|
198
|
-
}),
|
|
199
|
-
await
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
} : void 0,
|
|
234
|
+
}, y = this.contextCompactionService.createSession({
|
|
235
|
+
threadId: s,
|
|
236
|
+
agent: f,
|
|
237
|
+
checkpoint: v,
|
|
238
|
+
archive: g,
|
|
239
|
+
currentInput: p
|
|
240
|
+
}), b = await this.traceService.createRun(f.name, i);
|
|
241
|
+
await u.onStart?.(b.runId);
|
|
242
|
+
let x = [], S = c ? new r() : void 0, C = !1, w = c ? (e) => {
|
|
243
|
+
C ? c(e) : S?.push(e);
|
|
244
|
+
} : void 0, T = /* @__PURE__ */ new Map(), E = Promise.resolve(), D = (e) => {
|
|
203
245
|
let t = Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
204
|
-
return t.startedAt ??= (/* @__PURE__ */ new Date()).toISOString(), t.status !== "running" && (t.endedAt ??= t.startedAt),
|
|
205
|
-
let n =
|
|
206
|
-
n ? (Object.assign(n, t), await this.traceService.updateStep(
|
|
246
|
+
return t.startedAt ??= (/* @__PURE__ */ new Date()).toISOString(), t.status !== "running" && (t.endedAt ??= t.startedAt), E = E.then(async () => {
|
|
247
|
+
let n = T.get(e), r = n ?? t;
|
|
248
|
+
n ? (Object.assign(n, t), await this.traceService.updateStep(b.runId, n)) : (T.set(e, r), x.push(r), await this.traceService.addStep(b.runId, r)), w?.({
|
|
207
249
|
type: "step",
|
|
208
250
|
step: structuredClone(r)
|
|
209
251
|
});
|
|
210
|
-
}),
|
|
211
|
-
},
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
252
|
+
}), E;
|
|
253
|
+
}, O = this.activeParent(), k = { active: !0 };
|
|
254
|
+
return n.run({
|
|
255
|
+
runtimeId: this.runtimeId,
|
|
256
|
+
lease: k,
|
|
257
|
+
runId: b.runId,
|
|
258
|
+
agent: f.name,
|
|
259
|
+
stack: [...O?.stack ?? [], f.name],
|
|
260
|
+
record: D,
|
|
261
|
+
...w ? { emit: w } : {}
|
|
218
262
|
}, async () => {
|
|
219
|
-
let e = m.initialMessages, t = s(this.configService), i = v([...a.skills ?? [], ...a.tools ?? []], {
|
|
220
|
-
skillScanner: this.skillScanner,
|
|
221
|
-
toolRegistry: this.toolRegistry
|
|
222
|
-
}), o = S({
|
|
223
|
-
planner: this.planner,
|
|
224
|
-
executor: this.executor,
|
|
225
|
-
tools: i,
|
|
226
|
-
maxIterations: t,
|
|
227
|
-
...a.model ? { model: a.model } : {},
|
|
228
|
-
prepareMessages: m.prepareMessages,
|
|
229
|
-
getObservationOptions: (e) => this.toolRegistry.get(e)?.observation ?? {},
|
|
230
|
-
...C ? { onDelta: (e) => C({
|
|
231
|
-
type: "delta",
|
|
232
|
-
content: e
|
|
233
|
-
}) } : {},
|
|
234
|
-
record: E
|
|
235
|
-
}), l = {
|
|
236
|
-
messages: e,
|
|
237
|
-
iteration: 0,
|
|
238
|
-
pendingToolCalls: [],
|
|
239
|
-
observations: [],
|
|
240
|
-
lastContent: "",
|
|
241
|
-
output: "",
|
|
242
|
-
finished: !1
|
|
243
|
-
}, u;
|
|
244
263
|
try {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
let t = y.initialMessages, n = e(this.configService), r = a([...f.skills ?? [], ...f.tools ?? []], {
|
|
265
|
+
skillScanner: this.skillScanner,
|
|
266
|
+
toolRegistry: this.toolRegistry
|
|
267
|
+
}), i = l({
|
|
268
|
+
planner: this.planner,
|
|
269
|
+
executor: this.executor,
|
|
270
|
+
tools: r,
|
|
271
|
+
maxIterations: n,
|
|
272
|
+
...f.model ? { model: f.model } : {},
|
|
273
|
+
prepareMessages: y.prepareMessages,
|
|
274
|
+
getObservationOptions: (e) => this.toolRegistry.get(e)?.observation ?? {},
|
|
275
|
+
...w ? { onDelta: (e) => w({
|
|
276
|
+
type: "delta",
|
|
277
|
+
content: e
|
|
278
|
+
}) } : {},
|
|
279
|
+
record: D
|
|
280
|
+
}), u = {
|
|
281
|
+
messages: t,
|
|
282
|
+
iteration: 0,
|
|
283
|
+
pendingToolCalls: [],
|
|
284
|
+
observations: [],
|
|
285
|
+
lastContent: "",
|
|
286
|
+
output: "",
|
|
287
|
+
finished: !1
|
|
288
|
+
}, d;
|
|
289
|
+
try {
|
|
290
|
+
if (S) {
|
|
291
|
+
let e = this.runGraphStream(i, u, n, S);
|
|
292
|
+
try {
|
|
293
|
+
for (;;) {
|
|
294
|
+
let t = await e.next();
|
|
295
|
+
if (t.done) {
|
|
296
|
+
d = t.value, C = !0;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
c?.(t.value);
|
|
300
|
+
}
|
|
301
|
+
} finally {
|
|
302
|
+
C || await e.return(void 0);
|
|
252
303
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
304
|
+
} else d = await i.invoke(u, { recursionLimit: n * 3 + 5 });
|
|
305
|
+
} catch (e) {
|
|
306
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
307
|
+
throw await E, await this.traceService.addStep(b.runId, {
|
|
308
|
+
type: "final",
|
|
309
|
+
content: "Agent run failed",
|
|
310
|
+
error: t
|
|
311
|
+
}), await this.traceService.finish(b.runId, { error: t }), e;
|
|
312
|
+
}
|
|
313
|
+
let m = d.output;
|
|
314
|
+
return o(m) || (m = o(d.lastContent) ? d.lastContent : `达到最大轮次(${n})`, await D({
|
|
259
315
|
type: "final",
|
|
260
|
-
content:
|
|
261
|
-
|
|
262
|
-
|
|
316
|
+
content: m
|
|
317
|
+
})), await this.traceService.finish(b.runId, m), await this.persistTurn(s, y.getCheckpoint(), f.name, p, m, b.runId), {
|
|
318
|
+
runId: b.runId,
|
|
319
|
+
output: m,
|
|
320
|
+
steps: x,
|
|
321
|
+
threadId: s
|
|
322
|
+
};
|
|
323
|
+
} finally {
|
|
324
|
+
k.active = !1;
|
|
263
325
|
}
|
|
264
|
-
let d = u.output;
|
|
265
|
-
return y(d) || (d = y(u.lastContent) ? u.lastContent : `达到最大轮次(${t})`, await E({
|
|
266
|
-
type: "final",
|
|
267
|
-
content: d
|
|
268
|
-
})), await this.traceService.finish(h.runId, d), await this.persistTurn(n, m.getCheckpoint(), a.name, c, d, h.runId), {
|
|
269
|
-
runId: h.runId,
|
|
270
|
-
output: d,
|
|
271
|
-
steps: g,
|
|
272
|
-
threadId: n
|
|
273
|
-
};
|
|
274
326
|
});
|
|
275
327
|
}
|
|
276
328
|
async *runGraphStream(e, t, n, r) {
|
|
277
|
-
let i = t, a,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
329
|
+
let i = t, a, s, c = !1, l, u = !1, d = () => (c = !0, s ? (l ??= s.return(), l) : Promise.resolve()), f = (async () => {
|
|
330
|
+
try {
|
|
331
|
+
let r = await e.stream(t, {
|
|
332
|
+
streamMode: "values",
|
|
333
|
+
recursionLimit: n * 3 + 5
|
|
334
|
+
});
|
|
335
|
+
if (s = r, c) {
|
|
336
|
+
await d();
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
for await (let e of r) i = {
|
|
340
|
+
...e,
|
|
341
|
+
output: o(e.output) ? e.output : i.output
|
|
342
|
+
};
|
|
343
|
+
} catch (e) {
|
|
344
|
+
a = e;
|
|
345
|
+
} finally {
|
|
346
|
+
u = !0, r.close();
|
|
347
|
+
}
|
|
348
|
+
})();
|
|
349
|
+
try {
|
|
350
|
+
for await (let e of r.events()) yield e;
|
|
351
|
+
} finally {
|
|
352
|
+
if (!u) try {
|
|
353
|
+
await d();
|
|
354
|
+
} catch (e) {
|
|
355
|
+
a ??= e;
|
|
356
|
+
}
|
|
357
|
+
await f;
|
|
358
|
+
}
|
|
359
|
+
if (a !== void 0) throw a;
|
|
291
360
|
return i;
|
|
292
361
|
}
|
|
293
|
-
async *runStream(e, t, n) {
|
|
294
|
-
let
|
|
295
|
-
let e =
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
}).then((e) => {
|
|
300
|
-
|
|
362
|
+
async *runStream(e, t, n, r = {}) {
|
|
363
|
+
let i = [], a, o = !1, s, c, l = () => {
|
|
364
|
+
let e = a;
|
|
365
|
+
a = void 0, e?.();
|
|
366
|
+
}, u = this.run(e, t, n, (e) => {
|
|
367
|
+
i.push(e), l();
|
|
368
|
+
}, r).then((e) => {
|
|
369
|
+
c = e;
|
|
301
370
|
}).catch((e) => {
|
|
302
|
-
|
|
371
|
+
s = e;
|
|
303
372
|
}).finally(() => {
|
|
304
|
-
|
|
373
|
+
o = !0, l();
|
|
305
374
|
});
|
|
306
|
-
for (; !
|
|
307
|
-
if (
|
|
308
|
-
yield
|
|
375
|
+
for (; !o || i.length > 0;) {
|
|
376
|
+
if (i.length > 0) {
|
|
377
|
+
yield i.shift();
|
|
309
378
|
continue;
|
|
310
379
|
}
|
|
311
380
|
await new Promise((e) => {
|
|
312
|
-
|
|
381
|
+
a = e, (o || i.length > 0) && l();
|
|
313
382
|
});
|
|
314
383
|
}
|
|
315
|
-
if (await
|
|
316
|
-
return
|
|
384
|
+
if (await u, s !== void 0) throw s;
|
|
385
|
+
return c;
|
|
317
386
|
}
|
|
318
387
|
async persistTurn(e, t, n, r, i, a) {
|
|
319
388
|
(await this.checkpointService.loadArchive(e, 0)).length === 0 && t?.messages && t.messages.length > 0 && await this.checkpointService.appendArchiveMessages(e, t.messages), await this.checkpointService.appendArchiveMessages(e, [{
|
|
@@ -331,26 +400,5 @@ var U = class {
|
|
|
331
400
|
}, o.updatedAt = Date.now(), await this.checkpointService.save(o);
|
|
332
401
|
}
|
|
333
402
|
};
|
|
334
|
-
U = D([
|
|
335
|
-
w(),
|
|
336
|
-
O(11, T()),
|
|
337
|
-
O(11, C(f)),
|
|
338
|
-
O(12, T()),
|
|
339
|
-
E("design:paramtypes", [
|
|
340
|
-
typeof (k = m !== void 0 && m) == "function" ? k : Object,
|
|
341
|
-
typeof (A = l !== void 0 && l) == "function" ? A : Object,
|
|
342
|
-
typeof (j = t !== void 0 && t) == "function" ? j : Object,
|
|
343
|
-
typeof (M = a !== void 0 && a) == "function" ? M : Object,
|
|
344
|
-
typeof (N = c !== void 0 && c) == "function" ? N : Object,
|
|
345
|
-
typeof (P = u !== void 0 && u) == "function" ? P : Object,
|
|
346
|
-
typeof (F = n !== void 0 && n) == "function" ? F : Object,
|
|
347
|
-
typeof (I = i !== void 0 && i) == "function" ? I : Object,
|
|
348
|
-
typeof (L = r !== void 0 && r) == "function" ? L : Object,
|
|
349
|
-
typeof (R = e !== void 0 && e) == "function" ? R : Object,
|
|
350
|
-
typeof (z = h !== void 0 && h) == "function" ? z : Object,
|
|
351
|
-
Object,
|
|
352
|
-
typeof (B = p !== void 0 && p) == "function" ? B : Object
|
|
353
|
-
])
|
|
354
|
-
], U);
|
|
355
403
|
//#endregion
|
|
356
|
-
export {
|
|
404
|
+
export { f as LangGraphOrchestratorService, u as ThreadMigrationConflictError };
|