@clinebot/core 0.0.27 → 0.0.29
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/README.md +7 -0
- package/dist/ClineCore.d.ts +28 -2
- package/dist/ClineCore.d.ts.map +1 -1
- package/dist/account/cline-account-service.d.ts +1 -1
- package/dist/account/cline-account-service.d.ts.map +1 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/types.d.ts +5 -0
- package/dist/account/types.d.ts.map +1 -1
- package/dist/auth/bounded-ttl-cache.d.ts +14 -0
- package/dist/auth/bounded-ttl-cache.d.ts.map +1 -0
- package/dist/auth/cline.d.ts +27 -2
- package/dist/auth/cline.d.ts.map +1 -1
- package/dist/auth/oca.d.ts.map +1 -1
- package/dist/chat/chat-schema.d.ts +8 -8
- package/dist/extensions/config/agent-config-loader.d.ts.map +1 -0
- package/dist/{agents → extensions/config}/agent-config-parser.d.ts +2 -2
- package/dist/extensions/config/agent-config-parser.d.ts.map +1 -0
- package/dist/{agents → extensions/config}/hooks-config-loader.d.ts +1 -1
- package/dist/extensions/config/hooks-config-loader.d.ts.map +1 -0
- package/dist/{agents → extensions/config}/index.d.ts +2 -4
- package/dist/extensions/config/index.d.ts.map +1 -0
- package/dist/{runtime/commands.d.ts → extensions/config/runtime-commands.d.ts} +2 -3
- package/dist/extensions/config/runtime-commands.d.ts.map +1 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts.map +1 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -0
- package/dist/extensions/context/agentic-compaction.d.ts +13 -0
- package/dist/extensions/context/agentic-compaction.d.ts.map +1 -0
- package/dist/extensions/context/basic-compaction.d.ts +9 -0
- package/dist/extensions/context/basic-compaction.d.ts.map +1 -0
- package/dist/extensions/context/compaction-shared.d.ts +60 -0
- package/dist/extensions/context/compaction-shared.d.ts.map +1 -0
- package/dist/extensions/context/compaction.d.ts +20 -0
- package/dist/extensions/context/compaction.d.ts.map +1 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/mcp/client.d.ts +3 -0
- package/dist/extensions/mcp/client.d.ts.map +1 -0
- package/dist/extensions/mcp/config-loader.d.ts.map +1 -0
- package/dist/extensions/mcp/index.d.ts +9 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/{mcp → extensions/mcp}/manager.d.ts +1 -2
- package/dist/extensions/mcp/manager.d.ts.map +1 -0
- package/dist/extensions/mcp/name-transform.d.ts +3 -0
- package/dist/extensions/mcp/name-transform.d.ts.map +1 -0
- package/dist/extensions/mcp/policies.d.ts +15 -0
- package/dist/extensions/mcp/policies.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +4 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/{mcp → extensions/mcp}/types.d.ts +29 -1
- package/dist/extensions/mcp/types.d.ts.map +1 -0
- package/dist/{agents → extensions/plugin}/plugin-config-loader.d.ts +1 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -0
- package/dist/{agents → extensions/plugin}/plugin-loader.d.ts +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +5 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -0
- package/dist/{agents → extensions/plugin}/plugin-sandbox.d.ts +1 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +485 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/persistent.d.ts +64 -0
- package/dist/hooks/persistent.d.ts.map +1 -0
- package/dist/hooks/subprocess-runner.d.ts +22 -0
- package/dist/hooks/subprocess-runner.d.ts.map +1 -0
- package/dist/hooks/subprocess.d.ts +189 -0
- package/dist/hooks/subprocess.d.ts.map +1 -0
- package/dist/index.d.ts +22 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +560 -447
- package/dist/prompt/default-system.d.ts +2 -0
- package/dist/prompt/default-system.d.ts.map +1 -0
- package/dist/providers/local-provider-service.d.ts +1 -1
- package/dist/providers/local-provider-service.d.ts.map +1 -1
- package/dist/runtime/checkpoint-hooks.d.ts +21 -0
- package/dist/runtime/checkpoint-hooks.d.ts.map +1 -0
- package/dist/runtime/hook-file-hooks.d.ts +1 -1
- package/dist/runtime/hook-file-hooks.d.ts.map +1 -1
- package/dist/runtime/rules.d.ts +1 -1
- package/dist/runtime/rules.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts +1 -1
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +25 -5
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/runtime/subprocess-sandbox.d.ts.map +1 -0
- package/dist/runtime/team-runtime-registry.d.ts +1 -1
- package/dist/runtime/team-runtime-registry.d.ts.map +1 -1
- package/dist/runtime/tool-approval.d.ts +1 -1
- package/dist/session/default-session-manager.d.ts +4 -3
- package/dist/session/default-session-manager.d.ts.map +1 -1
- package/dist/session/file-session-service.d.ts +1 -1
- package/dist/session/file-session-service.d.ts.map +1 -1
- package/dist/session/{unified-session-persistence-service.d.ts → persistence-service.d.ts} +11 -42
- package/dist/session/persistence-service.d.ts.map +1 -0
- package/dist/session/rpc-session-service.d.ts +1 -1
- package/dist/session/rpc-session-service.d.ts.map +1 -1
- package/dist/session/session-agent-events.d.ts +1 -1
- package/dist/session/session-artifacts.d.ts.map +1 -1
- package/dist/session/session-config-builder.d.ts.map +1 -1
- package/dist/session/session-graph.d.ts +1 -1
- package/dist/session/session-graph.d.ts.map +1 -1
- package/dist/session/session-host.d.ts.map +1 -1
- package/dist/session/session-manager.d.ts +6 -5
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manifest.d.ts +1 -1
- package/dist/session/session-service.d.ts +3 -2
- package/dist/session/session-service.d.ts.map +1 -1
- package/dist/session/session-team-coordination.d.ts +2 -1
- package/dist/session/session-team-coordination.d.ts.map +1 -1
- package/dist/session/utils/helpers.d.ts +51 -3
- package/dist/session/utils/helpers.d.ts.map +1 -1
- package/dist/session/utils/types.d.ts +41 -7
- package/dist/session/utils/types.d.ts.map +1 -1
- package/dist/session/workspace-manager.d.ts +1 -2
- package/dist/session/workspace-manager.d.ts.map +1 -1
- package/dist/session/workspace-manifest.d.ts +1 -22
- package/dist/session/workspace-manifest.d.ts.map +1 -1
- package/dist/storage/file-team-store.d.ts +2 -1
- package/dist/storage/file-team-store.d.ts.map +1 -1
- package/dist/storage/sqlite-team-store.d.ts +4 -1
- package/dist/storage/sqlite-team-store.d.ts.map +1 -1
- package/dist/storage/team-store.d.ts.map +1 -1
- package/dist/team/delegated-agent.d.ts +44 -0
- package/dist/team/delegated-agent.d.ts.map +1 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/index.d.ts.map +1 -1
- package/dist/team/multi-agent.d.ts +229 -0
- package/dist/team/multi-agent.d.ts.map +1 -0
- package/dist/team/projections.d.ts +2 -2
- package/dist/team/projections.d.ts.map +1 -1
- package/dist/team/runtime.d.ts +5 -0
- package/dist/team/runtime.d.ts.map +1 -0
- package/dist/team/spawn-agent-tool.d.ts +85 -0
- package/dist/team/spawn-agent-tool.d.ts.map +1 -0
- package/dist/team/subagent-prompts.d.ts +4 -0
- package/dist/team/subagent-prompts.d.ts.map +1 -0
- package/dist/team/team-tools.d.ts +35 -0
- package/dist/team/team-tools.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts +11 -1
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -1
- package/dist/telemetry/{LoggerTelemetryAdapter.d.ts → TelemetryLoggerSink.d.ts} +10 -4
- package/dist/telemetry/TelemetryLoggerSink.d.ts.map +1 -0
- package/dist/telemetry/TelemetryService.d.ts.map +1 -1
- package/dist/telemetry/index.js +15 -28
- package/dist/tools/definitions.d.ts +4 -3
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/index.d.ts +5 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/model-tool-routing.d.ts.map +1 -1
- package/dist/tools/presets.d.ts +26 -0
- package/dist/tools/presets.d.ts.map +1 -1
- package/dist/tools/schemas.d.ts +8 -0
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/types.d.ts +23 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/config.d.ts +47 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/provider-settings.d.ts +1 -1
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types/storage.d.ts +2 -1
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types.d.ts +7 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -13
- package/src/ClineCore.test.ts +150 -0
- package/src/ClineCore.ts +114 -8
- package/src/account/cline-account-service.test.ts +84 -0
- package/src/account/cline-account-service.ts +2 -2
- package/src/account/index.ts +1 -0
- package/src/account/types.ts +6 -0
- package/src/auth/bounded-ttl-cache.test.ts +38 -0
- package/src/auth/bounded-ttl-cache.ts +53 -0
- package/src/auth/cline.test.ts +173 -36
- package/src/auth/cline.ts +395 -93
- package/src/auth/oca.test.ts +125 -0
- package/src/auth/oca.ts +17 -4
- package/src/{agents → extensions/config}/agent-config-loader.test.ts +1 -1
- package/src/{agents → extensions/config}/agent-config-parser.ts +2 -2
- package/src/{agents → extensions/config}/hooks-config-loader.ts +1 -1
- package/src/{agents → extensions/config}/index.ts +7 -11
- package/src/{runtime/commands.test.ts → extensions/config/runtime-commands.test.ts} +20 -3
- package/src/{runtime/commands.ts → extensions/config/runtime-commands.ts} +1 -8
- package/src/{agents → extensions/config}/unified-config-file-watcher.ts +15 -2
- package/src/{agents → extensions/config}/user-instruction-config-loader.test.ts +90 -2
- package/src/{agents → extensions/config}/user-instruction-config-loader.ts +126 -12
- package/src/extensions/context/agentic-compaction.ts +119 -0
- package/src/extensions/context/basic-compaction.ts +275 -0
- package/src/extensions/context/compaction-shared.ts +458 -0
- package/src/extensions/context/compaction.test.ts +477 -0
- package/src/extensions/context/compaction.ts +203 -0
- package/src/extensions/index.ts +12 -0
- package/src/extensions/mcp/client.ts +420 -0
- package/src/{mcp → extensions/mcp}/index.ts +16 -0
- package/src/{mcp → extensions/mcp}/manager.test.ts +1 -2
- package/src/{mcp → extensions/mcp}/manager.ts +3 -5
- package/src/extensions/mcp/name-transform.ts +33 -0
- package/src/extensions/mcp/policies.ts +47 -0
- package/src/extensions/mcp/tools.ts +47 -0
- package/src/{mcp → extensions/mcp}/types.ts +35 -7
- package/src/{agents → extensions/plugin}/plugin-config-loader.test.ts +18 -13
- package/src/{agents → extensions/plugin}/plugin-config-loader.ts +1 -1
- package/src/{agents → extensions/plugin}/plugin-loader.test.ts +41 -4
- package/src/extensions/plugin/plugin-loader.ts +106 -0
- package/src/extensions/plugin/plugin-module-import.ts +278 -0
- package/src/{agents → extensions/plugin}/plugin-sandbox-bootstrap.ts +30 -92
- package/src/{agents → extensions/plugin}/plugin-sandbox.test.ts +60 -3
- package/src/{agents → extensions/plugin}/plugin-sandbox.ts +146 -56
- package/src/hooks/index.ts +25 -0
- package/src/hooks/persistent.ts +661 -0
- package/src/hooks/subprocess-runner.ts +196 -0
- package/src/hooks/subprocess.ts +669 -0
- package/src/index.ts +200 -118
- package/src/prompt/default-system.ts +21 -0
- package/src/providers/local-provider-registry.ts +1 -1
- package/src/providers/local-provider-service.test.ts +23 -2
- package/src/providers/local-provider-service.ts +2 -2
- package/src/runtime/checkpoint-hooks.test.ts +167 -0
- package/src/runtime/checkpoint-hooks.ts +186 -0
- package/src/runtime/hook-file-hooks.test.ts +40 -1
- package/src/runtime/hook-file-hooks.ts +35 -16
- package/src/runtime/index.ts +4 -19
- package/src/runtime/rules.ts +4 -1
- package/src/runtime/runtime-builder.team-persistence.test.ts +3 -6
- package/src/runtime/runtime-builder.test.ts +266 -160
- package/src/runtime/runtime-builder.ts +120 -47
- package/src/runtime/runtime-parity.test.ts +22 -22
- package/src/runtime/session-runtime.ts +36 -6
- package/src/runtime/{sandbox/subprocess-sandbox.ts → subprocess-sandbox.ts} +24 -3
- package/src/runtime/team-runtime-registry.ts +1 -4
- package/src/runtime/tool-approval.ts +1 -1
- package/src/session/default-session-manager.e2e.test.ts +2 -2
- package/src/session/default-session-manager.test.ts +553 -9
- package/src/session/default-session-manager.ts +140 -46
- package/src/session/file-session-service.ts +3 -3
- package/src/session/index.ts +6 -6
- package/src/session/persistence-service.test.ts +212 -0
- package/src/session/{unified-session-persistence-service.ts → persistence-service.ts} +106 -172
- package/src/session/rpc-session-service.ts +3 -3
- package/src/session/runtime-oauth-token-manager.ts +1 -1
- package/src/session/session-agent-events.ts +1 -1
- package/src/session/session-artifacts.ts +32 -4
- package/src/session/session-config-builder.ts +22 -9
- package/src/session/session-graph.ts +1 -1
- package/src/session/session-host.ts +19 -11
- package/src/session/session-manager.ts +11 -6
- package/src/session/session-service.team-persistence.test.ts +1 -1
- package/src/session/session-service.ts +6 -9
- package/src/session/session-team-coordination.ts +7 -3
- package/src/session/session-telemetry.ts +1 -1
- package/src/session/utils/helpers.test.ts +160 -0
- package/src/session/utils/helpers.ts +289 -42
- package/src/session/utils/types.ts +47 -7
- package/src/session/workspace-manager.ts +5 -3
- package/src/session/workspace-manifest.ts +3 -49
- package/src/storage/file-team-store.ts +2 -5
- package/src/storage/provider-settings-legacy-migration.ts +2 -2
- package/src/storage/provider-settings-manager.test.ts +1 -1
- package/src/storage/sqlite-team-store.ts +212 -125
- package/src/storage/team-store.ts +1 -5
- package/src/team/delegated-agent.ts +131 -0
- package/src/team/index.ts +1 -0
- package/src/team/multi-agent.lifecycle.test.ts +201 -0
- package/src/team/multi-agent.ts +1666 -0
- package/src/team/projections.ts +2 -4
- package/src/team/runtime.ts +54 -0
- package/src/team/spawn-agent-tool.test.ts +387 -0
- package/src/team/spawn-agent-tool.ts +207 -0
- package/src/team/subagent-prompts.ts +41 -0
- package/src/team/team-tools.test.ts +802 -0
- package/src/team/team-tools.ts +792 -0
- package/src/telemetry/OpenTelemetryProvider.test.ts +25 -3
- package/src/telemetry/OpenTelemetryProvider.ts +108 -18
- package/src/telemetry/TelemetryLoggerSink.test.ts +42 -0
- package/src/telemetry/{LoggerTelemetryAdapter.ts → TelemetryLoggerSink.ts} +21 -14
- package/src/telemetry/TelemetryService.test.ts +7 -7
- package/src/telemetry/TelemetryService.ts +2 -4
- package/src/tools/definitions.test.ts +76 -0
- package/src/tools/definitions.ts +41 -2
- package/src/tools/executors/apply-patch.ts +1 -1
- package/src/tools/executors/editor.ts +1 -1
- package/src/tools/executors/file-read.ts +1 -1
- package/src/tools/executors/search.ts +1 -1
- package/src/tools/executors/web-fetch.ts +1 -1
- package/src/tools/index.ts +6 -1
- package/src/tools/model-tool-routing.ts +2 -0
- package/src/tools/presets.test.ts +8 -0
- package/src/tools/presets.ts +40 -2
- package/src/tools/schemas.ts +19 -0
- package/src/tools/types.ts +31 -2
- package/src/types/config.ts +61 -7
- package/src/types/events.ts +1 -1
- package/src/types/index.ts +0 -1
- package/src/types/provider-settings.ts +1 -1
- package/src/types/storage.ts +2 -5
- package/src/types.ts +32 -44
- package/dist/agents/agent-config-loader.d.ts.map +0 -1
- package/dist/agents/agent-config-parser.d.ts.map +0 -1
- package/dist/agents/hooks-config-loader.d.ts.map +0 -1
- package/dist/agents/index.d.ts.map +0 -1
- package/dist/agents/plugin-config-loader.d.ts.map +0 -1
- package/dist/agents/plugin-loader.d.ts.map +0 -1
- package/dist/agents/plugin-sandbox-bootstrap.js +0 -446
- package/dist/agents/plugin-sandbox.d.ts.map +0 -1
- package/dist/agents/unified-config-file-watcher.d.ts.map +0 -1
- package/dist/agents/user-instruction-config-loader.d.ts.map +0 -1
- package/dist/mcp/config-loader.d.ts.map +0 -1
- package/dist/mcp/index.d.ts +0 -5
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/manager.d.ts.map +0 -1
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/runtime/commands.d.ts.map +0 -1
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +0 -1
- package/dist/runtime/skills.d.ts +0 -14
- package/dist/runtime/skills.d.ts.map +0 -1
- package/dist/runtime/workflows.d.ts +0 -14
- package/dist/runtime/workflows.d.ts.map +0 -1
- package/dist/session/unified-session-persistence-service.d.ts.map +0 -1
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +0 -1
- package/dist/types/workspace.d.ts +0 -8
- package/dist/types/workspace.d.ts.map +0 -1
- package/src/agents/plugin-loader.ts +0 -175
- package/src/runtime/skills.ts +0 -44
- package/src/runtime/workflows.test.ts +0 -119
- package/src/runtime/workflows.ts +0 -45
- package/src/session/unified-session-persistence-service.test.ts +0 -85
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
- package/src/types/workspace.ts +0 -7
- /package/dist/{agents → extensions/config}/agent-config-loader.d.ts +0 -0
- /package/dist/{agents → extensions/config}/unified-config-file-watcher.d.ts +0 -0
- /package/dist/{agents → extensions/config}/user-instruction-config-loader.d.ts +0 -0
- /package/dist/{mcp → extensions/mcp}/config-loader.d.ts +0 -0
- /package/dist/runtime/{sandbox/subprocess-sandbox.d.ts → subprocess-sandbox.d.ts} +0 -0
- /package/src/{agents → extensions/config}/agent-config-loader.ts +0 -0
- /package/src/{agents → extensions/config}/hooks-config-loader.test.ts +0 -0
- /package/src/{agents → extensions/config}/unified-config-file-watcher.test.ts +0 -0
- /package/src/{mcp → extensions/mcp}/config-loader.test.ts +0 -0
- /package/src/{mcp → extensions/mcp}/config-loader.ts +0 -0
|
@@ -4,15 +4,13 @@ import {
|
|
|
4
4
|
readFileSync,
|
|
5
5
|
writeFileSync,
|
|
6
6
|
} from "node:fs";
|
|
7
|
-
import type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
SubAgentStartContext,
|
|
11
|
-
} from "@clinebot/agents";
|
|
12
|
-
import type * as LlmsProviders from "@clinebot/llms/providers";
|
|
13
|
-
import { normalizeUserInput, resolveRootSessionId } from "@clinebot/shared";
|
|
7
|
+
import type * as LlmsProviders from "@clinebot/llms";
|
|
8
|
+
import type { AgentResult } from "@clinebot/shared";
|
|
9
|
+
import { resolveRootSessionId } from "@clinebot/shared";
|
|
14
10
|
import { nanoid } from "nanoid";
|
|
15
11
|
import { z } from "zod";
|
|
12
|
+
import type { HookEventPayload } from "../hooks";
|
|
13
|
+
import type { SubAgentEndContext, SubAgentStartContext } from "../team";
|
|
16
14
|
import { SessionSource, type SessionStatus } from "../types/common";
|
|
17
15
|
import { nowIso, SessionArtifacts, unlinkIfExists } from "./session-artifacts";
|
|
18
16
|
import {
|
|
@@ -30,9 +28,28 @@ import type {
|
|
|
30
28
|
SessionRow,
|
|
31
29
|
UpsertSubagentInput,
|
|
32
30
|
} from "./session-service";
|
|
31
|
+
import {
|
|
32
|
+
buildManifestFromRow,
|
|
33
|
+
buildMessagesFilePayload,
|
|
34
|
+
deriveTitleFromPrompt,
|
|
35
|
+
normalizeStoredMessagesForPersistence,
|
|
36
|
+
normalizeTitle,
|
|
37
|
+
resolveMessagesFileContext,
|
|
38
|
+
resolveMetadataWithTitle,
|
|
39
|
+
sanitizeMetadata,
|
|
40
|
+
withLatestAssistantTurnMetadata,
|
|
41
|
+
withOccRetry,
|
|
42
|
+
writeEmptyMessagesFile,
|
|
43
|
+
} from "./utils/helpers";
|
|
44
|
+
import type {
|
|
45
|
+
PersistedSessionUpdateInput,
|
|
46
|
+
SessionPersistenceAdapter,
|
|
47
|
+
StoredMessageWithMetadata,
|
|
48
|
+
} from "./utils/types";
|
|
49
|
+
|
|
50
|
+
export type { PersistedSessionUpdateInput, SessionPersistenceAdapter };
|
|
33
51
|
|
|
34
52
|
const SUBSESSION_SOURCE = SessionSource.SUBAGENT;
|
|
35
|
-
const MAX_TITLE_LENGTH = 120;
|
|
36
53
|
const OCC_MAX_RETRIES = 4;
|
|
37
54
|
|
|
38
55
|
const SpawnAgentInputSchema = z.looseObject({
|
|
@@ -40,104 +57,6 @@ const SpawnAgentInputSchema = z.looseObject({
|
|
|
40
57
|
systemPrompt: z.string().optional(),
|
|
41
58
|
});
|
|
42
59
|
|
|
43
|
-
// ── Metadata helpers ──────────────────────────────────────────────────
|
|
44
|
-
|
|
45
|
-
function normalizeTitle(title?: string | null): string | undefined {
|
|
46
|
-
const trimmed = title?.trim();
|
|
47
|
-
return trimmed ? trimmed.slice(0, MAX_TITLE_LENGTH) : undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function deriveTitleFromPrompt(prompt?: string | null): string | undefined {
|
|
51
|
-
const normalized = normalizeUserInput(prompt ?? "").trim();
|
|
52
|
-
if (!normalized) return undefined;
|
|
53
|
-
return normalizeTitle(normalized.split("\n")[0]?.trim());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Strip invalid title from metadata, drop empty objects. */
|
|
57
|
-
function sanitizeMetadata(
|
|
58
|
-
metadata: Record<string, unknown> | null | undefined,
|
|
59
|
-
): Record<string, unknown> | undefined {
|
|
60
|
-
if (!metadata) return undefined;
|
|
61
|
-
const next = { ...metadata };
|
|
62
|
-
const title = normalizeTitle(
|
|
63
|
-
typeof next.title === "string" ? next.title : undefined,
|
|
64
|
-
);
|
|
65
|
-
if (title) {
|
|
66
|
-
next.title = title;
|
|
67
|
-
} else {
|
|
68
|
-
delete next.title;
|
|
69
|
-
}
|
|
70
|
-
return Object.keys(next).length > 0 ? next : undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Resolve title from explicit title, prompt, or existing metadata. */
|
|
74
|
-
function resolveMetadataWithTitle(input: {
|
|
75
|
-
metadata?: Record<string, unknown> | null;
|
|
76
|
-
title?: string | null;
|
|
77
|
-
prompt?: string | null;
|
|
78
|
-
}): Record<string, unknown> | undefined {
|
|
79
|
-
const base = sanitizeMetadata(input.metadata) ?? {};
|
|
80
|
-
const title =
|
|
81
|
-
input.title !== undefined
|
|
82
|
-
? normalizeTitle(input.title)
|
|
83
|
-
: deriveTitleFromPrompt(input.prompt);
|
|
84
|
-
if (title) base.title = title;
|
|
85
|
-
return Object.keys(base).length > 0 ? base : undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ── File helpers ──────────────────────────────────────────────────────
|
|
89
|
-
|
|
90
|
-
function writeEmptyMessagesFile(path: string, startedAt: string): void {
|
|
91
|
-
writeFileSync(
|
|
92
|
-
path,
|
|
93
|
-
`${JSON.stringify({ version: 1, updated_at: startedAt, messages: [] }, null, 2)}\n`,
|
|
94
|
-
"utf8",
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// ── Interfaces ────────────────────────────────────────────────────────
|
|
99
|
-
|
|
100
|
-
export interface PersistedSessionUpdateInput {
|
|
101
|
-
sessionId: string;
|
|
102
|
-
expectedStatusLock?: number;
|
|
103
|
-
status?: SessionStatus;
|
|
104
|
-
endedAt?: string | null;
|
|
105
|
-
exitCode?: number | null;
|
|
106
|
-
prompt?: string | null;
|
|
107
|
-
metadata?: Record<string, unknown> | null;
|
|
108
|
-
title?: string | null;
|
|
109
|
-
parentSessionId?: string | null;
|
|
110
|
-
parentAgentId?: string | null;
|
|
111
|
-
agentId?: string | null;
|
|
112
|
-
conversationId?: string | null;
|
|
113
|
-
setRunning?: boolean;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface SessionPersistenceAdapter {
|
|
117
|
-
ensureSessionsDir(): string;
|
|
118
|
-
upsertSession(row: SessionRow): Promise<void>;
|
|
119
|
-
getSession(sessionId: string): Promise<SessionRow | undefined>;
|
|
120
|
-
listSessions(options: {
|
|
121
|
-
limit: number;
|
|
122
|
-
parentSessionId?: string;
|
|
123
|
-
status?: string;
|
|
124
|
-
}): Promise<SessionRow[]>;
|
|
125
|
-
updateSession(
|
|
126
|
-
input: PersistedSessionUpdateInput,
|
|
127
|
-
): Promise<{ updated: boolean; statusLock: number }>;
|
|
128
|
-
deleteSession(sessionId: string, cascade: boolean): Promise<boolean>;
|
|
129
|
-
enqueueSpawnRequest(input: {
|
|
130
|
-
rootSessionId: string;
|
|
131
|
-
parentAgentId: string;
|
|
132
|
-
task?: string;
|
|
133
|
-
systemPrompt?: string;
|
|
134
|
-
}): Promise<void>;
|
|
135
|
-
claimSpawnRequest(
|
|
136
|
-
rootSessionId: string,
|
|
137
|
-
parentAgentId: string,
|
|
138
|
-
): Promise<string | undefined>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
60
|
// ── Service ───────────────────────────────────────────────────────────
|
|
142
61
|
|
|
143
62
|
export class UnifiedSessionPersistenceService {
|
|
@@ -160,6 +79,35 @@ export class UnifiedSessionPersistenceService {
|
|
|
160
79
|
return this.adapter.ensureSessionsDir();
|
|
161
80
|
}
|
|
162
81
|
|
|
82
|
+
private initializeMessagesFile(
|
|
83
|
+
sessionId: string,
|
|
84
|
+
path: string,
|
|
85
|
+
startedAt: string,
|
|
86
|
+
): void {
|
|
87
|
+
writeEmptyMessagesFile(
|
|
88
|
+
path,
|
|
89
|
+
startedAt,
|
|
90
|
+
resolveMessagesFileContext(sessionId),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private toPersistedMessages(
|
|
95
|
+
messages: LlmsProviders.Message[] | undefined,
|
|
96
|
+
result?: AgentResult,
|
|
97
|
+
previousMessages?: LlmsProviders.Message[],
|
|
98
|
+
): StoredMessageWithMetadata[] | undefined {
|
|
99
|
+
if (!messages) return undefined;
|
|
100
|
+
return result
|
|
101
|
+
? withLatestAssistantTurnMetadata(
|
|
102
|
+
result.messages,
|
|
103
|
+
result,
|
|
104
|
+
previousMessages as LlmsProviders.MessageWithMetadata[] | undefined,
|
|
105
|
+
)
|
|
106
|
+
: normalizeStoredMessagesForPersistence(
|
|
107
|
+
messages as LlmsProviders.MessageWithMetadata[],
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
163
111
|
// ── Manifest I/O ──────────────────────────────────────────────────
|
|
164
112
|
|
|
165
113
|
private writeManifestFile(
|
|
@@ -177,6 +125,10 @@ export class UnifiedSessionPersistenceService {
|
|
|
177
125
|
this.writeManifestFile(manifestPath, manifest);
|
|
178
126
|
}
|
|
179
127
|
|
|
128
|
+
readSessionManifest(sessionId: string): SessionManifest | undefined {
|
|
129
|
+
return this.readManifestFile(sessionId).manifest;
|
|
130
|
+
}
|
|
131
|
+
|
|
180
132
|
private readManifestFile(sessionId: string): {
|
|
181
133
|
path: string;
|
|
182
134
|
manifest?: SessionManifest;
|
|
@@ -195,39 +147,6 @@ export class UnifiedSessionPersistenceService {
|
|
|
195
147
|
}
|
|
196
148
|
}
|
|
197
149
|
|
|
198
|
-
private buildManifestFromRow(
|
|
199
|
-
row: SessionRow,
|
|
200
|
-
overrides?: {
|
|
201
|
-
status?: SessionStatus;
|
|
202
|
-
endedAt?: string | null;
|
|
203
|
-
exitCode?: number | null;
|
|
204
|
-
metadata?: Record<string, unknown>;
|
|
205
|
-
},
|
|
206
|
-
): SessionManifest {
|
|
207
|
-
return SessionManifestSchema.parse({
|
|
208
|
-
version: 1,
|
|
209
|
-
session_id: row.sessionId,
|
|
210
|
-
source: row.source,
|
|
211
|
-
pid: row.pid,
|
|
212
|
-
started_at: row.startedAt,
|
|
213
|
-
ended_at: overrides?.endedAt ?? row.endedAt ?? undefined,
|
|
214
|
-
exit_code: overrides?.exitCode ?? row.exitCode ?? undefined,
|
|
215
|
-
status: overrides?.status ?? row.status,
|
|
216
|
-
interactive: row.interactive,
|
|
217
|
-
provider: row.provider,
|
|
218
|
-
model: row.model,
|
|
219
|
-
cwd: row.cwd,
|
|
220
|
-
workspace_root: row.workspaceRoot,
|
|
221
|
-
team_name: row.teamName ?? undefined,
|
|
222
|
-
enable_tools: row.enableTools,
|
|
223
|
-
enable_spawn: row.enableSpawn,
|
|
224
|
-
enable_teams: row.enableTeams,
|
|
225
|
-
prompt: row.prompt ?? undefined,
|
|
226
|
-
metadata: overrides?.metadata ?? row.metadata ?? undefined,
|
|
227
|
-
messages_path: row.messagesPath ?? undefined,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
150
|
// ── Path resolution ───────────────────────────────────────────────
|
|
232
151
|
|
|
233
152
|
private async resolveArtifactPath(
|
|
@@ -328,7 +247,7 @@ export class UnifiedSessionPersistenceService {
|
|
|
328
247
|
updatedAt: nowIso(),
|
|
329
248
|
});
|
|
330
249
|
|
|
331
|
-
|
|
250
|
+
this.initializeMessagesFile(sessionId, messagesPath, startedAt);
|
|
332
251
|
this.writeManifestFile(manifestPath, manifest);
|
|
333
252
|
return { manifestPath, transcriptPath, hookPath, messagesPath, manifest };
|
|
334
253
|
}
|
|
@@ -340,24 +259,26 @@ export class UnifiedSessionPersistenceService {
|
|
|
340
259
|
status: SessionStatus,
|
|
341
260
|
exitCode?: number | null,
|
|
342
261
|
): Promise<{ updated: boolean; endedAt?: string }> {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
262
|
+
let endedAt: string | undefined;
|
|
263
|
+
const result = await withOccRetry(
|
|
264
|
+
() => this.adapter.getSession(sessionId),
|
|
265
|
+
async (statusLock) => {
|
|
266
|
+
endedAt = nowIso();
|
|
267
|
+
return this.adapter.updateSession({
|
|
268
|
+
sessionId,
|
|
269
|
+
status,
|
|
270
|
+
endedAt,
|
|
271
|
+
exitCode: typeof exitCode === "number" ? exitCode : null,
|
|
272
|
+
expectedStatusLock: statusLock,
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
OCC_MAX_RETRIES,
|
|
276
|
+
);
|
|
277
|
+
if (result.updated) {
|
|
278
|
+
if (status === "cancelled") {
|
|
279
|
+
await this.applyStatusToRunningChildSessions(sessionId, "cancelled");
|
|
360
280
|
}
|
|
281
|
+
return { updated: true, endedAt };
|
|
361
282
|
}
|
|
362
283
|
return { updated: false };
|
|
363
284
|
}
|
|
@@ -543,7 +464,11 @@ export class UnifiedSessionPersistenceService {
|
|
|
543
464
|
...artifactPaths,
|
|
544
465
|
}),
|
|
545
466
|
);
|
|
546
|
-
|
|
467
|
+
this.initializeMessagesFile(
|
|
468
|
+
sessionId,
|
|
469
|
+
artifactPaths.messagesPath,
|
|
470
|
+
startedAt,
|
|
471
|
+
);
|
|
547
472
|
return sessionId;
|
|
548
473
|
}
|
|
549
474
|
|
|
@@ -626,13 +551,15 @@ export class UnifiedSessionPersistenceService {
|
|
|
626
551
|
"messagesPath",
|
|
627
552
|
(id) => this.artifacts.sessionMessagesPath(id),
|
|
628
553
|
);
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
554
|
+
const normalizedMessages = normalizeStoredMessagesForPersistence(
|
|
555
|
+
messages as LlmsProviders.MessageWithMetadata[],
|
|
556
|
+
);
|
|
557
|
+
const payload = buildMessagesFilePayload({
|
|
558
|
+
updatedAt: nowIso(),
|
|
559
|
+
context: resolveMessagesFileContext(sessionId),
|
|
560
|
+
messages: normalizedMessages,
|
|
561
|
+
systemPrompt,
|
|
562
|
+
});
|
|
636
563
|
writeFileSync(path, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
637
564
|
}
|
|
638
565
|
|
|
@@ -693,9 +620,8 @@ export class UnifiedSessionPersistenceService {
|
|
|
693
620
|
|
|
694
621
|
const sessionId = makeTeamTaskSubSessionId(rootSessionId, agentId);
|
|
695
622
|
const startedAt = nowIso();
|
|
696
|
-
const transcriptPath =
|
|
697
|
-
|
|
698
|
-
const messagesPath = this.artifacts.sessionMessagesPath(sessionId);
|
|
623
|
+
const { transcriptPath, hookPath, messagesPath } =
|
|
624
|
+
this.artifacts.subagentArtifactPaths(sessionId, agentId);
|
|
699
625
|
|
|
700
626
|
await this.adapter.upsertSession(
|
|
701
627
|
this.buildSubsessionRow(root, {
|
|
@@ -710,7 +636,7 @@ export class UnifiedSessionPersistenceService {
|
|
|
710
636
|
messagesPath,
|
|
711
637
|
}),
|
|
712
638
|
);
|
|
713
|
-
|
|
639
|
+
this.initializeMessagesFile(sessionId, messagesPath, startedAt);
|
|
714
640
|
await this.appendSubagentTranscriptLine(sessionId, `[start] ${message}`);
|
|
715
641
|
|
|
716
642
|
const key = this.teamTaskQueueKey(rootSessionId, agentId);
|
|
@@ -724,6 +650,7 @@ export class UnifiedSessionPersistenceService {
|
|
|
724
650
|
agentId: string,
|
|
725
651
|
status: SessionStatus,
|
|
726
652
|
summary?: string,
|
|
653
|
+
result?: AgentResult,
|
|
727
654
|
messages?: LlmsProviders.Message[],
|
|
728
655
|
): Promise<void> {
|
|
729
656
|
const key = this.teamTaskQueueKey(rootSessionId, agentId);
|
|
@@ -734,7 +661,15 @@ export class UnifiedSessionPersistenceService {
|
|
|
734
661
|
if (queue.length === 0) this.teamTaskSessionsByAgent.delete(key);
|
|
735
662
|
if (!sessionId) return;
|
|
736
663
|
|
|
737
|
-
|
|
664
|
+
const teammateMessages = result?.messages ?? messages;
|
|
665
|
+
const persistedMessages = this.toPersistedMessages(
|
|
666
|
+
teammateMessages,
|
|
667
|
+
result,
|
|
668
|
+
messages,
|
|
669
|
+
);
|
|
670
|
+
if (persistedMessages) {
|
|
671
|
+
await this.persistSessionMessages(sessionId, persistedMessages);
|
|
672
|
+
}
|
|
738
673
|
await this.appendSubagentTranscriptLine(
|
|
739
674
|
sessionId,
|
|
740
675
|
summary ?? `[done] ${status}`,
|
|
@@ -881,7 +816,7 @@ export class UnifiedSessionPersistenceService {
|
|
|
881
816
|
|
|
882
817
|
await this.applyStatusToRunningChildSessions(latest.sessionId, "failed");
|
|
883
818
|
|
|
884
|
-
const manifest =
|
|
819
|
+
const manifest = buildManifestFromRow(latest, {
|
|
885
820
|
status: "failed",
|
|
886
821
|
endedAt: detectedAt,
|
|
887
822
|
exitCode: 1,
|
|
@@ -890,7 +825,6 @@ export class UnifiedSessionPersistenceService {
|
|
|
890
825
|
const { path: manifestPath } = this.readManifestFile(latest.sessionId);
|
|
891
826
|
this.writeManifestFile(manifestPath, manifest);
|
|
892
827
|
|
|
893
|
-
// Write termination markers to hook + transcript files
|
|
894
828
|
appendFileSync(
|
|
895
829
|
latest.hookPath,
|
|
896
830
|
`${JSON.stringify({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { existsSync, mkdirSync } from "node:fs";
|
|
2
2
|
import { RpcSessionClient, type RpcSessionRow } from "@clinebot/rpc";
|
|
3
|
-
import type { SessionRow } from "./session-service";
|
|
4
3
|
import type {
|
|
5
4
|
PersistedSessionUpdateInput,
|
|
6
5
|
SessionPersistenceAdapter,
|
|
7
|
-
} from "./
|
|
8
|
-
import { UnifiedSessionPersistenceService } from "./
|
|
6
|
+
} from "./persistence-service";
|
|
7
|
+
import { UnifiedSessionPersistenceService } from "./persistence-service";
|
|
8
|
+
import type { SessionRow } from "./session-service";
|
|
9
9
|
|
|
10
10
|
// ── Adapter ──────────────────────────────────────────────────────────
|
|
11
11
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
unlinkSync,
|
|
7
7
|
} from "node:fs";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
|
+
import { parseSubSessionId, parseTeamTaskSubSessionId } from "./session-graph";
|
|
9
10
|
|
|
10
11
|
export function nowIso(): string {
|
|
11
12
|
return new Date().toISOString();
|
|
@@ -28,6 +29,32 @@ export interface SessionArtifactPaths {
|
|
|
28
29
|
messagesPath: string;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
function childArtifactFileStem(sessionId: string): {
|
|
33
|
+
rootSessionId: string;
|
|
34
|
+
fileStem: string;
|
|
35
|
+
} {
|
|
36
|
+
const teamTask = parseTeamTaskSubSessionId(sessionId);
|
|
37
|
+
if (teamTask) {
|
|
38
|
+
return {
|
|
39
|
+
rootSessionId: teamTask.rootSessionId,
|
|
40
|
+
fileStem: `${teamTask.agentId}__${teamTask.teamTaskId}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const subagent = parseSubSessionId(sessionId);
|
|
45
|
+
if (subagent) {
|
|
46
|
+
return {
|
|
47
|
+
rootSessionId: subagent.rootSessionId,
|
|
48
|
+
fileStem: subagent.agentId,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
rootSessionId: sessionId,
|
|
54
|
+
fileStem: sessionId,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
31
58
|
export class SessionArtifacts {
|
|
32
59
|
constructor(private readonly ensureSessionsDir: () => string) {}
|
|
33
60
|
|
|
@@ -96,11 +123,12 @@ export class SessionArtifacts {
|
|
|
96
123
|
): SessionArtifactPaths {
|
|
97
124
|
void subAgentId;
|
|
98
125
|
void activeTeamTaskSessionId;
|
|
99
|
-
const
|
|
126
|
+
const { rootSessionId, fileStem } = childArtifactFileStem(sessionId);
|
|
127
|
+
const dir = this.ensureSessionArtifactsDir(rootSessionId);
|
|
100
128
|
return {
|
|
101
|
-
transcriptPath: join(dir, `${
|
|
102
|
-
hookPath: join(dir, `${
|
|
103
|
-
messagesPath: join(dir, `${
|
|
129
|
+
transcriptPath: join(dir, `${fileStem}.log`),
|
|
130
|
+
hookPath: join(dir, `${fileStem}.hooks.jsonl`),
|
|
131
|
+
messagesPath: join(dir, `${fileStem}.messages.json`),
|
|
104
132
|
};
|
|
105
133
|
}
|
|
106
134
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ITelemetryService } from "@clinebot/shared";
|
|
2
|
-
import { resolveAndLoadAgentPlugins } from "../
|
|
2
|
+
import { resolveAndLoadAgentPlugins } from "../extensions/plugin/plugin-config-loader";
|
|
3
3
|
import {
|
|
4
4
|
createHookAuditHooks,
|
|
5
5
|
createHookConfigFileHooks,
|
|
@@ -51,15 +51,25 @@ export async function buildEffectiveConfig(
|
|
|
51
51
|
auditHooks,
|
|
52
52
|
]);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
let loadedPlugins:
|
|
55
|
+
| Awaited<ReturnType<typeof resolveAndLoadAgentPlugins>>
|
|
56
|
+
| undefined;
|
|
57
|
+
try {
|
|
58
|
+
loadedPlugins = await resolveAndLoadAgentPlugins({
|
|
59
|
+
pluginPaths: input.config.pluginPaths,
|
|
60
|
+
workspacePath,
|
|
61
|
+
cwd: input.config.cwd,
|
|
62
|
+
onEvent: onPluginEvent,
|
|
63
|
+
});
|
|
64
|
+
} catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
input.config.logger?.log?.(
|
|
67
|
+
`plugin loading failed; continuing without plugins (${message})`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
60
70
|
const effectiveExtensions = mergeAgentExtensions(
|
|
61
71
|
input.config.extensions,
|
|
62
|
-
loadedPlugins
|
|
72
|
+
loadedPlugins?.extensions,
|
|
63
73
|
);
|
|
64
74
|
|
|
65
75
|
return {
|
|
@@ -69,7 +79,7 @@ export async function buildEffectiveConfig(
|
|
|
69
79
|
extensions: effectiveExtensions,
|
|
70
80
|
telemetry: input.config.telemetry ?? defaultTelemetry,
|
|
71
81
|
},
|
|
72
|
-
pluginSandboxShutdown: loadedPlugins
|
|
82
|
+
pluginSandboxShutdown: loadedPlugins?.shutdown,
|
|
73
83
|
};
|
|
74
84
|
}
|
|
75
85
|
|
|
@@ -95,6 +105,9 @@ export function buildResolvedProviderConfig(
|
|
|
95
105
|
if (config.knownModels) {
|
|
96
106
|
providerConfig.knownModels = config.knownModels;
|
|
97
107
|
}
|
|
108
|
+
if (config.extensionContext) {
|
|
109
|
+
providerConfig.extensionContext = config.extensionContext;
|
|
110
|
+
}
|
|
98
111
|
return providerConfig;
|
|
99
112
|
}
|
|
100
113
|
|
|
@@ -2,6 +2,10 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { getRpcServerDefaultAddress, getRpcServerHealth } from "@clinebot/rpc";
|
|
5
|
+
import {
|
|
6
|
+
augmentNodeCommandForDebug,
|
|
7
|
+
withResolvedClineBuildEnv,
|
|
8
|
+
} from "@clinebot/shared";
|
|
5
9
|
import { resolveSessionDataDir } from "@clinebot/shared/storage";
|
|
6
10
|
import type { ClineCoreOptions } from "../ClineCore";
|
|
7
11
|
import { SqliteSessionStore } from "../storage/sqlite-session-store";
|
|
@@ -58,20 +62,24 @@ function startRpcServerInBackground(address: string): void {
|
|
|
58
62
|
const conditionsArg = process.execArgv.find((arg) =>
|
|
59
63
|
arg.startsWith("--conditions="),
|
|
60
64
|
);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const command = augmentNodeCommandForDebug(
|
|
66
|
+
[
|
|
67
|
+
launcher,
|
|
68
|
+
...(conditionsArg ? [conditionsArg] : []),
|
|
69
|
+
entry,
|
|
70
|
+
"rpc",
|
|
71
|
+
"start",
|
|
72
|
+
"--address",
|
|
73
|
+
address,
|
|
74
|
+
],
|
|
75
|
+
{ debugRole: "rpc" },
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const child = spawn(command[0] ?? launcher, command.slice(1), {
|
|
71
79
|
detached: true,
|
|
72
80
|
stdio: "ignore",
|
|
73
81
|
env: {
|
|
74
|
-
...process.env,
|
|
82
|
+
...withResolvedClineBuildEnv(process.env),
|
|
75
83
|
CLINE_NO_INTERACTIVE: "1",
|
|
76
84
|
},
|
|
77
85
|
cwd: process.cwd(),
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import type * as LlmsProviders from "@clinebot/llms";
|
|
2
|
+
import type {
|
|
3
|
+
AgentResult,
|
|
4
|
+
ToolApprovalRequest,
|
|
5
|
+
ToolApprovalResult,
|
|
6
|
+
} from "@clinebot/shared";
|
|
3
7
|
import type { SessionSource } from "../types/common";
|
|
4
8
|
import type { CoreSessionConfig } from "../types/config";
|
|
5
9
|
import type { CoreSessionEvent } from "../types/events";
|
|
@@ -14,13 +18,14 @@ export interface StartSessionInput {
|
|
|
14
18
|
initialMessages?: LlmsProviders.Message[];
|
|
15
19
|
userImages?: string[];
|
|
16
20
|
userFiles?: string[];
|
|
17
|
-
userInstructionWatcher?: import("../
|
|
21
|
+
userInstructionWatcher?: import("../extensions/config").UserInstructionConfigWatcher;
|
|
18
22
|
onTeamRestored?: () => void;
|
|
19
23
|
defaultToolExecutors?: Partial<import("../tools").ToolExecutors>;
|
|
20
|
-
toolPolicies?: import("@clinebot/
|
|
24
|
+
toolPolicies?: import("@clinebot/shared").AgentConfig["toolPolicies"];
|
|
21
25
|
requestToolApproval?: (
|
|
22
|
-
request:
|
|
23
|
-
) => Promise<
|
|
26
|
+
request: ToolApprovalRequest,
|
|
27
|
+
) => Promise<ToolApprovalResult>;
|
|
28
|
+
teamToolsFactory?: import("../runtime/session-runtime").TeamToolsFactory;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export interface StartSessionResult {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdtempSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { AgentTeamsRuntime } from "@clinebot/agents";
|
|
5
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { AgentTeamsRuntime } from "../team";
|
|
6
6
|
import { FileTeamPersistenceStore } from "./session-service";
|
|
7
7
|
|
|
8
8
|
describe("FileTeamPersistenceStore", () => {
|
|
@@ -8,21 +8,18 @@ import {
|
|
|
8
8
|
writeFileSync,
|
|
9
9
|
} from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
|
-
import type {
|
|
12
|
-
AgentTeamsRuntime,
|
|
13
|
-
TeamEvent,
|
|
14
|
-
TeamTeammateSpec,
|
|
15
|
-
} from "@clinebot/agents";
|
|
11
|
+
import type { TeamTeammateSpec } from "@clinebot/shared";
|
|
16
12
|
import { resolveTeamDataDir } from "@clinebot/shared/storage";
|
|
17
13
|
import type { SqliteSessionStore } from "../storage/sqlite-session-store";
|
|
14
|
+
import type { AgentTeamsRuntime, TeamEvent } from "../team";
|
|
18
15
|
import type { SessionSource, SessionStatus } from "../types/common";
|
|
19
|
-
import { nowIso } from "./session-artifacts";
|
|
20
|
-
import type { SessionManifest } from "./session-manifest";
|
|
21
16
|
import type {
|
|
22
17
|
PersistedSessionUpdateInput,
|
|
23
18
|
SessionPersistenceAdapter,
|
|
24
|
-
} from "./
|
|
25
|
-
import { UnifiedSessionPersistenceService } from "./
|
|
19
|
+
} from "./persistence-service";
|
|
20
|
+
import { UnifiedSessionPersistenceService } from "./persistence-service";
|
|
21
|
+
import { nowIso } from "./session-artifacts";
|
|
22
|
+
import type { SessionManifest } from "./session-manifest";
|
|
26
23
|
|
|
27
24
|
export interface SessionRow {
|
|
28
25
|
sessionId: string;
|