@clinebot/core 0.0.3 → 0.0.5

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.
Files changed (60) hide show
  1. package/README.md +7 -7
  2. package/dist/agents/agent-config-parser.d.ts +1 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.node.js +113 -93
  5. package/dist/runtime/session-runtime.d.ts +1 -1
  6. package/dist/session/default-session-manager.d.ts +1 -1
  7. package/dist/session/session-host.d.ts +1 -1
  8. package/dist/session/session-manager.d.ts +1 -1
  9. package/dist/session/unified-session-persistence-service.d.ts +4 -0
  10. package/dist/types/config.d.ts +1 -1
  11. package/package.json +13 -13
  12. package/src/agents/agent-config-parser.ts +1 -1
  13. package/src/index.ts +28 -19
  14. package/src/providers/local-provider-service.ts +25 -7
  15. package/src/runtime/runtime-builder.ts +2 -2
  16. package/src/runtime/runtime-parity.test.ts +1 -1
  17. package/src/runtime/session-runtime.ts +1 -1
  18. package/src/session/default-session-manager.ts +4 -5
  19. package/src/session/session-host.ts +1 -1
  20. package/src/session/session-manager.ts +1 -1
  21. package/src/session/unified-session-persistence-service.ts +213 -23
  22. package/src/types/config.ts +1 -1
  23. package/dist/index.browser.d.ts +0 -1
  24. package/dist/index.browser.js +0 -220
  25. package/dist/index.js +0 -220
  26. package/src/index.browser.ts +0 -1
  27. /package/dist/{default-tools → tools}/constants.d.ts +0 -0
  28. /package/dist/{default-tools → tools}/definitions.d.ts +0 -0
  29. /package/dist/{default-tools → tools}/executors/apply-patch-parser.d.ts +0 -0
  30. /package/dist/{default-tools → tools}/executors/apply-patch.d.ts +0 -0
  31. /package/dist/{default-tools → tools}/executors/bash.d.ts +0 -0
  32. /package/dist/{default-tools → tools}/executors/editor.d.ts +0 -0
  33. /package/dist/{default-tools → tools}/executors/file-read.d.ts +0 -0
  34. /package/dist/{default-tools → tools}/executors/index.d.ts +0 -0
  35. /package/dist/{default-tools → tools}/executors/search.d.ts +0 -0
  36. /package/dist/{default-tools → tools}/executors/web-fetch.d.ts +0 -0
  37. /package/dist/{default-tools → tools}/index.d.ts +0 -0
  38. /package/dist/{default-tools → tools}/model-tool-routing.d.ts +0 -0
  39. /package/dist/{default-tools → tools}/presets.d.ts +0 -0
  40. /package/dist/{default-tools → tools}/schemas.d.ts +0 -0
  41. /package/dist/{default-tools → tools}/types.d.ts +0 -0
  42. /package/src/{default-tools → tools}/constants.ts +0 -0
  43. /package/src/{default-tools → tools}/definitions.test.ts +0 -0
  44. /package/src/{default-tools → tools}/definitions.ts +0 -0
  45. /package/src/{default-tools → tools}/executors/apply-patch-parser.ts +0 -0
  46. /package/src/{default-tools → tools}/executors/apply-patch.ts +0 -0
  47. /package/src/{default-tools → tools}/executors/bash.ts +0 -0
  48. /package/src/{default-tools → tools}/executors/editor.ts +0 -0
  49. /package/src/{default-tools → tools}/executors/file-read.test.ts +0 -0
  50. /package/src/{default-tools → tools}/executors/file-read.ts +0 -0
  51. /package/src/{default-tools → tools}/executors/index.ts +0 -0
  52. /package/src/{default-tools → tools}/executors/search.ts +0 -0
  53. /package/src/{default-tools → tools}/executors/web-fetch.ts +0 -0
  54. /package/src/{default-tools → tools}/index.ts +0 -0
  55. /package/src/{default-tools → tools}/model-tool-routing.test.ts +0 -0
  56. /package/src/{default-tools → tools}/model-tool-routing.ts +0 -0
  57. /package/src/{default-tools → tools}/presets.test.ts +0 -0
  58. /package/src/{default-tools → tools}/presets.ts +0 -0
  59. /package/src/{default-tools → tools}/schemas.ts +0 -0
  60. /package/src/{default-tools → tools}/types.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { AgentConfig, AgentHooks, AgentResult, AgentTeamsRuntime, Tool } from "@clinebot/agents";
2
2
  import type { BasicLogger } from "@clinebot/shared";
3
3
  import type { UserInstructionConfigWatcher } from "../agents";
4
- import type { ToolExecutors } from "../default-tools";
4
+ import type { ToolExecutors } from "../tools";
5
5
  import type { CoreSessionConfig } from "../types/config";
6
6
  export interface BuiltRuntime {
7
7
  tools: Tool[];
@@ -1,8 +1,8 @@
1
1
  import { Agent, type AgentConfig, type AgentResult, type ToolApprovalRequest, type ToolApprovalResult } from "@clinebot/agents";
2
2
  import type { providers as LlmsProviders } from "@clinebot/llms";
3
- import { type ToolExecutors } from "../default-tools";
4
3
  import type { RuntimeBuilder } from "../runtime/session-runtime";
5
4
  import { ProviderSettingsManager } from "../storage/provider-settings-manager";
5
+ import { type ToolExecutors } from "../tools";
6
6
  import type { CoreSessionEvent } from "../types/events";
7
7
  import type { SessionRecord } from "../types/sessions";
8
8
  import type { RpcCoreSessionService } from "./rpc-session-service";
@@ -1,5 +1,5 @@
1
1
  import type { AgentConfig, ToolApprovalRequest, ToolApprovalResult } from "@clinebot/agents";
2
- import type { ToolExecutors } from "../default-tools";
2
+ import type { ToolExecutors } from "../tools";
3
3
  import { RpcCoreSessionService } from "./rpc-session-service";
4
4
  import type { SessionManager } from "./session-manager";
5
5
  import { CoreSessionService } from "./session-service";
@@ -15,7 +15,7 @@ export interface StartSessionInput {
15
15
  userFiles?: string[];
16
16
  userInstructionWatcher?: import("../agents").UserInstructionConfigWatcher;
17
17
  onTeamRestored?: () => void;
18
- defaultToolExecutors?: Partial<import("../default-tools").ToolExecutors>;
18
+ defaultToolExecutors?: Partial<import("../tools").ToolExecutors>;
19
19
  toolPolicies?: import("@clinebot/agents").AgentConfig["toolPolicies"];
20
20
  requestToolApproval?: (request: import("@clinebot/agents").ToolApprovalRequest) => Promise<import("@clinebot/agents").ToolApprovalResult>;
21
21
  }
@@ -12,6 +12,7 @@ export interface PersistedSessionUpdateInput {
12
12
  exitCode?: number | null;
13
13
  prompt?: string | null;
14
14
  metadataJson?: string | null;
15
+ title?: string | null;
15
16
  parentSessionId?: string | null;
16
17
  parentAgentId?: string | null;
17
18
  agentId?: string | null;
@@ -55,6 +56,8 @@ export declare class UnifiedSessionPersistenceService {
55
56
  private activeTeamTaskSessionId;
56
57
  private subagentArtifactPaths;
57
58
  private writeSessionManifestFile;
59
+ private readSessionManifestFile;
60
+ private applyResolvedTitleToRow;
58
61
  private createRootSessionId;
59
62
  createRootSessionWithArtifacts(input: CreateRootSessionWithArtifactsInput): Promise<RootSessionArtifacts>;
60
63
  writeSessionManifest(manifestPath: string, manifest: SessionManifest): void;
@@ -66,6 +69,7 @@ export declare class UnifiedSessionPersistenceService {
66
69
  sessionId: string;
67
70
  prompt?: string | null;
68
71
  metadata?: Record<string, unknown> | null;
72
+ title?: string | null;
69
73
  }): Promise<{
70
74
  updated: boolean;
71
75
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { AgentConfig, AgentHooks, ConsecutiveMistakeLimitContext, ConsecutiveMistakeLimitDecision, HookErrorMode, TeamEvent, Tool } from "@clinebot/agents";
2
2
  import type { providers as LlmsProviders } from "@clinebot/llms";
3
3
  import type { AgentMode, BasicLogger, SessionExecutionConfig, SessionPromptConfig, SessionWorkspaceConfig } from "@clinebot/shared";
4
- import type { ToolRoutingRule } from "../default-tools/model-tool-routing.js";
4
+ import type { ToolRoutingRule } from "../tools/model-tool-routing.js";
5
5
  export type CoreAgentMode = AgentMode;
6
6
  export interface CoreModelConfig {
7
7
  providerId: string;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@clinebot/core",
3
- "version": "0.0.3",
4
- "main": "./dist/index.js",
3
+ "version": "0.0.5",
4
+ "main": "./dist/index.node.js",
5
5
  "dependencies": {
6
- "@clinebot/agents": "0.0.3",
7
- "@clinebot/llms": "0.0.3",
6
+ "@clinebot/agents": "0.0.5",
7
+ "@clinebot/llms": "0.0.5",
8
+ "better-sqlite3": "^11.10.0",
8
9
  "nanoid": "^5.1.7",
9
10
  "simple-git": "^3.32.3",
10
11
  "yaml": "^2.8.2",
@@ -12,15 +13,14 @@
12
13
  },
13
14
  "exports": {
14
15
  ".": {
15
- "browser": "./dist/index.browser.js",
16
- "development": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
18
- "import": "./dist/index.js"
16
+ "development": "./dist/index.node.js",
17
+ "types": "./dist/index.node.d.ts",
18
+ "import": "./dist/index.node.js"
19
19
  },
20
- "./browser": {
21
- "development": "./dist/index.browser.js",
22
- "types": "./dist/index.browser.d.ts",
23
- "import": "./dist/index.browser.js"
20
+ "./node": {
21
+ "development": "./src/index.node.ts",
22
+ "types": "./dist/index.node.d.ts",
23
+ "import": "./dist/index.node.js"
24
24
  }
25
25
  },
26
26
  "description": "State-aware orchestration for Cline Agent runtimes",
@@ -38,5 +38,5 @@
38
38
  "test:watch": "vitest --config vitest.config.ts"
39
39
  },
40
40
  "type": "module",
41
- "types": "./dist/index.d.ts"
41
+ "types": "./dist/index.node.d.ts"
42
42
  }
@@ -1,7 +1,7 @@
1
1
  import type { AgentConfig, Tool } from "@clinebot/agents";
2
2
  import YAML from "yaml";
3
3
  import { z } from "zod";
4
- import { ALL_DEFAULT_TOOL_NAMES, type DefaultToolName } from "../default-tools";
4
+ import { ALL_DEFAULT_TOOL_NAMES, type DefaultToolName } from "../tools";
5
5
 
6
6
  const AgentConfigFrontmatterSchema = z.object({
7
7
  name: z.string().trim().min(1),
package/src/index.ts CHANGED
@@ -4,6 +4,15 @@
4
4
  * Runtime-agnostic core contracts and shared state utilities.
5
5
  */
6
6
 
7
+ export {
8
+ type AgentConfig,
9
+ createTool,
10
+ getClineDefaultSystemPrompt,
11
+ type Tool,
12
+ type ToolApprovalRequest,
13
+ type ToolApprovalResult,
14
+ type ToolContext,
15
+ } from "@clinebot/agents";
7
16
  // Shared contracts and path helpers re-exported for app consumers.
8
17
  export type {
9
18
  AgentMode,
@@ -76,25 +85,6 @@ export {
76
85
  ChatSummarySchema,
77
86
  ChatViewStateSchema,
78
87
  } from "./chat/chat-schema";
79
- export {
80
- ALL_DEFAULT_TOOL_NAMES,
81
- type AskQuestionExecutor,
82
- type CreateBuiltinToolsOptions,
83
- type CreateDefaultToolsOptions,
84
- createBuiltinTools,
85
- createDefaultExecutors,
86
- createDefaultTools,
87
- createDefaultToolsWithPreset,
88
- createToolPoliciesWithPreset,
89
- type DefaultExecutorsOptions,
90
- type DefaultToolName,
91
- DefaultToolNames,
92
- type DefaultToolsConfig,
93
- type ToolExecutors,
94
- type ToolPolicyPresetName,
95
- type ToolPresetName,
96
- ToolPresets,
97
- } from "./default-tools";
98
88
  export {
99
89
  hasMcpSettingsFile,
100
90
  InMemoryMcpManager,
@@ -126,6 +116,25 @@ export {
126
116
  buildTeamProgressSummary,
127
117
  toTeamProgressLifecycleEvent,
128
118
  } from "./team";
119
+ export {
120
+ ALL_DEFAULT_TOOL_NAMES,
121
+ type AskQuestionExecutor,
122
+ type CreateBuiltinToolsOptions,
123
+ type CreateDefaultToolsOptions,
124
+ createBuiltinTools,
125
+ createDefaultExecutors,
126
+ createDefaultTools,
127
+ createDefaultToolsWithPreset,
128
+ createToolPoliciesWithPreset,
129
+ type DefaultExecutorsOptions,
130
+ type DefaultToolName,
131
+ DefaultToolNames,
132
+ type DefaultToolsConfig,
133
+ type ToolExecutors,
134
+ type ToolPolicyPresetName,
135
+ type ToolPresetName,
136
+ ToolPresets,
137
+ } from "./tools";
129
138
  // Compatibility barrel (legacy imports).
130
139
  export type { RuntimeEnvironment, SessionEvent, StoredMessages } from "./types";
131
140
  export type { SessionStatus } from "./types/common";
@@ -35,6 +35,7 @@ type StoredModelsFile = {
35
35
  name: string;
36
36
  supportsVision?: boolean;
37
37
  supportsAttachments?: boolean;
38
+ supportsReasoning?: boolean;
38
39
  }
39
40
  >;
40
41
  }
@@ -132,6 +133,24 @@ async function writeModelsFile(
132
133
  await writeFile(filePath, `${JSON.stringify(state, null, 2)}\n`, "utf8");
133
134
  }
134
135
 
136
+ function toRpcProviderModel(
137
+ modelId: string,
138
+ info: {
139
+ name?: string;
140
+ capabilities?: string[];
141
+ thinkingConfig?: unknown;
142
+ },
143
+ ): RpcProviderModel {
144
+ return {
145
+ id: modelId,
146
+ name: info.name ?? modelId,
147
+ supportsAttachments: info.capabilities?.includes("files"),
148
+ supportsVision: info.capabilities?.includes("images"),
149
+ supportsReasoning:
150
+ info.capabilities?.includes("reasoning") || info.thinkingConfig != null,
151
+ };
152
+ }
153
+
135
154
  function toProviderCapabilities(
136
155
  capabilities: RpcProviderCapability[] | undefined,
137
156
  ): Array<"reasoning" | "prompt-cache" | "tools"> | undefined {
@@ -352,6 +371,7 @@ export async function addLocalProvider(
352
371
  const modelsState = await readModelsFile(modelsPath);
353
372
  const supportsVision = capabilities?.includes("vision") ?? false;
354
373
  const supportsAttachments = supportsVision;
374
+ const supportsReasoning = capabilities?.includes("reasoning") ?? false;
355
375
  modelsState.providers[providerId] = {
356
376
  provider: {
357
377
  name: providerName,
@@ -368,6 +388,7 @@ export async function addLocalProvider(
368
388
  name: modelId,
369
389
  supportsVision,
370
390
  supportsAttachments,
391
+ supportsReasoning,
371
392
  },
372
393
  ]),
373
394
  ),
@@ -394,12 +415,13 @@ export async function listLocalProviders(
394
415
  const providerItems = await Promise.all(
395
416
  ids.map(async (id): Promise<RpcProviderListItem> => {
396
417
  const info = await models.getProvider(id);
418
+ const providerModels = await getLocalProviderModels(id);
397
419
  const persistedSettings = state.providers[id]?.settings;
398
420
  const providerName = info?.name ?? titleCaseFromId(id);
399
421
  return {
400
422
  id,
401
423
  name: providerName,
402
- models: null,
424
+ models: providerModels.models.length,
403
425
  color: stableColor(id),
404
426
  letter: createLetter(providerName),
405
427
  enabled: Boolean(persistedSettings),
@@ -413,6 +435,7 @@ export async function listLocalProviders(
413
435
  defaultModelId: info?.defaultModelId,
414
436
  authDescription: "This provider uses API keys for authentication.",
415
437
  baseUrlDescription: "The base endpoint to use for provider requests.",
438
+ modelList: providerModels.models,
416
439
  };
417
440
  }),
418
441
  );
@@ -430,12 +453,7 @@ export async function getLocalProviderModels(
430
453
  const modelMap = await models.getModelsForProvider(id);
431
454
  const items = Object.entries(modelMap)
432
455
  .sort(([a], [b]) => a.localeCompare(b))
433
- .map(([modelId, info]) => ({
434
- id: modelId,
435
- name: info.name ?? modelId,
436
- supportsAttachments: info.capabilities?.includes("files"),
437
- supportsVision: info.capabilities?.includes("images"),
438
- }));
456
+ .map(([modelId, info]) => toRpcProviderModel(modelId, info));
439
457
  return {
440
458
  providerId: id,
441
459
  models: items,
@@ -14,6 +14,7 @@ import {
14
14
  type SkillConfig,
15
15
  type UserInstructionConfigWatcher,
16
16
  } from "../agents";
17
+ import { SqliteTeamStore } from "../storage/sqlite-team-store";
17
18
  import {
18
19
  createBuiltinTools,
19
20
  DEFAULT_MODEL_TOOL_ROUTING_RULES,
@@ -22,8 +23,7 @@ import {
22
23
  type ToolExecutors,
23
24
  ToolPresets,
24
25
  type ToolRoutingRule,
25
- } from "../default-tools";
26
- import { SqliteTeamStore } from "../storage/sqlite-team-store";
26
+ } from "../tools";
27
27
  import type { CoreAgentMode, CoreSessionConfig } from "../types/config";
28
28
  import type {
29
29
  RuntimeBuilder,
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import type { Tool } from "@clinebot/agents";
5
5
  import { describe, expect, it } from "vitest";
6
- import { createBuiltinTools } from "../default-tools";
6
+ import { createBuiltinTools } from "../tools";
7
7
  import { DefaultRuntimeBuilder } from "./runtime-builder";
8
8
 
9
9
  type LegacyConfig = {
@@ -7,7 +7,7 @@ import type {
7
7
  } from "@clinebot/agents";
8
8
  import type { BasicLogger } from "@clinebot/shared";
9
9
  import type { UserInstructionConfigWatcher } from "../agents";
10
- import type { ToolExecutors } from "../default-tools";
10
+ import type { ToolExecutors } from "../tools";
11
11
  import type { CoreSessionConfig } from "../types/config";
12
12
 
13
13
  export interface BuiltRuntime {
@@ -18,11 +18,6 @@ import { formatUserInputBlock, normalizeUserInput } from "@clinebot/shared";
18
18
  import { setHomeDirIfUnset } from "@clinebot/shared/storage";
19
19
  import { nanoid } from "nanoid";
20
20
  import { resolveAndLoadAgentPlugins } from "../agents/plugin-config-loader";
21
- import {
22
- createBuiltinTools,
23
- type ToolExecutors,
24
- ToolPresets,
25
- } from "../default-tools";
26
21
  import { enrichPromptWithMentions } from "../input";
27
22
  import {
28
23
  createHookAuditHooks,
@@ -36,6 +31,7 @@ import {
36
31
  buildTeamProgressSummary,
37
32
  toTeamProgressLifecycleEvent,
38
33
  } from "../team";
34
+ import { createBuiltinTools, type ToolExecutors, ToolPresets } from "../tools";
39
35
  import { SessionSource, type SessionStatus } from "../types/common";
40
36
  import type { CoreSessionConfig } from "../types/config";
41
37
  import type { CoreSessionEvent } from "../types/events";
@@ -565,6 +561,9 @@ export class DefaultSessionManager implements SessionManager {
565
561
  if (!prompt) {
566
562
  throw new Error("prompt cannot be empty");
567
563
  }
564
+ if (!session.artifacts && !session.pendingPrompt) {
565
+ session.pendingPrompt = prompt;
566
+ }
568
567
  await this.ensureSessionPersisted(session);
569
568
  await this.syncOAuthCredentials(session);
570
569
 
@@ -9,8 +9,8 @@ import type {
9
9
  import { getRpcServerDefaultAddress, getRpcServerHealth } from "@clinebot/rpc";
10
10
  import { resolveSessionDataDir } from "@clinebot/shared/storage";
11
11
  import { nanoid } from "nanoid";
12
- import type { ToolExecutors } from "../default-tools";
13
12
  import { SqliteSessionStore } from "../storage/sqlite-session-store";
13
+ import type { ToolExecutors } from "../tools";
14
14
  import { DefaultSessionManager } from "./default-session-manager";
15
15
  import { RpcCoreSessionService } from "./rpc-session-service";
16
16
  import type { SessionManager } from "./session-manager";
@@ -16,7 +16,7 @@ export interface StartSessionInput {
16
16
  userFiles?: string[];
17
17
  userInstructionWatcher?: import("../agents").UserInstructionConfigWatcher;
18
18
  onTeamRestored?: () => void;
19
- defaultToolExecutors?: Partial<import("../default-tools").ToolExecutors>;
19
+ defaultToolExecutors?: Partial<import("../tools").ToolExecutors>;
20
20
  toolPolicies?: import("@clinebot/agents").AgentConfig["toolPolicies"];
21
21
  requestToolApproval?: (
22
22
  request: import("@clinebot/agents").ToolApprovalRequest,