@clinebot/core 0.0.0
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 +88 -0
- package/dist/account/cline-account-service.d.ts +34 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +38 -0
- package/dist/account/types.d.ts +74 -0
- package/dist/agents/agent-config-loader.d.ts +18 -0
- package/dist/agents/agent-config-parser.d.ts +25 -0
- package/dist/agents/hooks-config-loader.d.ts +23 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/plugin-config-loader.d.ts +22 -0
- package/dist/agents/plugin-loader.d.ts +9 -0
- package/dist/agents/plugin-sandbox.d.ts +12 -0
- package/dist/agents/unified-config-file-watcher.d.ts +77 -0
- package/dist/agents/user-instruction-config-loader.d.ts +63 -0
- package/dist/auth/client.d.ts +11 -0
- package/dist/auth/cline.d.ts +41 -0
- package/dist/auth/codex.d.ts +39 -0
- package/dist/auth/oca.d.ts +22 -0
- package/dist/auth/server.d.ts +22 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/chat/chat-schema.d.ts +145 -0
- package/dist/default-tools/constants.d.ts +23 -0
- package/dist/default-tools/definitions.d.ts +96 -0
- package/dist/default-tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/default-tools/executors/apply-patch.d.ts +26 -0
- package/dist/default-tools/executors/bash.d.ts +49 -0
- package/dist/default-tools/executors/editor.d.ts +31 -0
- package/dist/default-tools/executors/file-read.d.ts +40 -0
- package/dist/default-tools/executors/index.d.ts +44 -0
- package/dist/default-tools/executors/search.d.ts +50 -0
- package/dist/default-tools/executors/web-fetch.d.ts +58 -0
- package/dist/default-tools/index.d.ts +57 -0
- package/dist/default-tools/presets.d.ts +124 -0
- package/dist/default-tools/schemas.d.ts +121 -0
- package/dist/default-tools/types.d.ts +237 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +220 -0
- package/dist/input/file-indexer.d.ts +5 -0
- package/dist/input/index.d.ts +4 -0
- package/dist/input/mention-enricher.d.ts +12 -0
- package/dist/mcp/config-loader.d.ts +15 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/manager.d.ts +24 -0
- package/dist/mcp/types.d.ts +66 -0
- package/dist/runtime/hook-file-hooks.d.ts +18 -0
- package/dist/runtime/rules.d.ts +5 -0
- package/dist/runtime/runtime-builder.d.ts +5 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +19 -0
- package/dist/runtime/session-runtime.d.ts +36 -0
- package/dist/runtime/tool-approval.d.ts +9 -0
- package/dist/runtime/workflows.d.ts +13 -0
- package/dist/server/index.d.ts +47 -0
- package/dist/server/index.js +641 -0
- package/dist/session/default-session-manager.d.ts +77 -0
- package/dist/session/rpc-session-service.d.ts +12 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +28 -0
- package/dist/session/session-artifacts.d.ts +19 -0
- package/dist/session/session-graph.d.ts +15 -0
- package/dist/session/session-host.d.ts +21 -0
- package/dist/session/session-manager.d.ts +50 -0
- package/dist/session/session-manifest.d.ts +30 -0
- package/dist/session/session-service.d.ts +113 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +30 -0
- package/dist/session/unified-session-persistence-service.d.ts +93 -0
- package/dist/session/workspace-manager.d.ts +28 -0
- package/dist/session/workspace-manifest.d.ts +25 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +13 -0
- package/dist/storage/provider-settings-manager.d.ts +20 -0
- package/dist/storage/sqlite-session-store.d.ts +29 -0
- package/dist/storage/sqlite-team-store.d.ts +31 -0
- package/dist/storage/team-store.d.ts +2 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/projections.d.ts +8 -0
- package/dist/types/common.d.ts +10 -0
- package/dist/types/config.d.ts +37 -0
- package/dist/types/events.d.ts +54 -0
- package/dist/types/provider-settings.d.ts +20 -0
- package/dist/types/sessions.d.ts +9 -0
- package/dist/types/storage.d.ts +37 -0
- package/dist/types/workspace.d.ts +7 -0
- package/dist/types.d.ts +26 -0
- package/package.json +63 -0
- package/src/account/cline-account-service.test.ts +101 -0
- package/src/account/cline-account-service.ts +267 -0
- package/src/account/index.ts +20 -0
- package/src/account/rpc.test.ts +62 -0
- package/src/account/rpc.ts +172 -0
- package/src/account/types.ts +80 -0
- package/src/agents/agent-config-loader.test.ts +234 -0
- package/src/agents/agent-config-loader.ts +107 -0
- package/src/agents/agent-config-parser.ts +191 -0
- package/src/agents/hooks-config-loader.ts +97 -0
- package/src/agents/index.ts +84 -0
- package/src/agents/plugin-config-loader.test.ts +91 -0
- package/src/agents/plugin-config-loader.ts +160 -0
- package/src/agents/plugin-loader.test.ts +102 -0
- package/src/agents/plugin-loader.ts +105 -0
- package/src/agents/plugin-sandbox.test.ts +120 -0
- package/src/agents/plugin-sandbox.ts +471 -0
- package/src/agents/unified-config-file-watcher.test.ts +196 -0
- package/src/agents/unified-config-file-watcher.ts +483 -0
- package/src/agents/user-instruction-config-loader.test.ts +158 -0
- package/src/agents/user-instruction-config-loader.ts +438 -0
- package/src/auth/client.test.ts +40 -0
- package/src/auth/client.ts +25 -0
- package/src/auth/cline.test.ts +130 -0
- package/src/auth/cline.ts +414 -0
- package/src/auth/codex.test.ts +170 -0
- package/src/auth/codex.ts +466 -0
- package/src/auth/oca.test.ts +215 -0
- package/src/auth/oca.ts +546 -0
- package/src/auth/server.ts +216 -0
- package/src/auth/types.ts +78 -0
- package/src/auth/utils.test.ts +128 -0
- package/src/auth/utils.ts +247 -0
- package/src/chat/chat-schema.ts +82 -0
- package/src/default-tools/constants.ts +35 -0
- package/src/default-tools/definitions.test.ts +233 -0
- package/src/default-tools/definitions.ts +632 -0
- package/src/default-tools/executors/apply-patch-parser.ts +520 -0
- package/src/default-tools/executors/apply-patch.ts +359 -0
- package/src/default-tools/executors/bash.ts +205 -0
- package/src/default-tools/executors/editor.ts +231 -0
- package/src/default-tools/executors/file-read.test.ts +25 -0
- package/src/default-tools/executors/file-read.ts +94 -0
- package/src/default-tools/executors/index.ts +75 -0
- package/src/default-tools/executors/search.ts +278 -0
- package/src/default-tools/executors/web-fetch.ts +259 -0
- package/src/default-tools/index.ts +161 -0
- package/src/default-tools/presets.test.ts +63 -0
- package/src/default-tools/presets.ts +168 -0
- package/src/default-tools/schemas.ts +228 -0
- package/src/default-tools/types.ts +324 -0
- package/src/index.ts +119 -0
- package/src/input/file-indexer.d.ts +11 -0
- package/src/input/file-indexer.test.ts +87 -0
- package/src/input/file-indexer.ts +280 -0
- package/src/input/index.ts +7 -0
- package/src/input/mention-enricher.test.ts +82 -0
- package/src/input/mention-enricher.ts +119 -0
- package/src/mcp/config-loader.test.ts +238 -0
- package/src/mcp/config-loader.ts +219 -0
- package/src/mcp/index.ts +26 -0
- package/src/mcp/manager.test.ts +106 -0
- package/src/mcp/manager.ts +262 -0
- package/src/mcp/types.ts +88 -0
- package/src/runtime/hook-file-hooks.test.ts +106 -0
- package/src/runtime/hook-file-hooks.ts +736 -0
- package/src/runtime/index.ts +27 -0
- package/src/runtime/rules.ts +34 -0
- package/src/runtime/runtime-builder.team-persistence.test.ts +203 -0
- package/src/runtime/runtime-builder.test.ts +215 -0
- package/src/runtime/runtime-builder.ts +515 -0
- package/src/runtime/runtime-parity.test.ts +132 -0
- package/src/runtime/sandbox/subprocess-sandbox.ts +207 -0
- package/src/runtime/session-runtime.ts +44 -0
- package/src/runtime/tool-approval.ts +104 -0
- package/src/runtime/workflows.test.ts +119 -0
- package/src/runtime/workflows.ts +54 -0
- package/src/server/index.ts +282 -0
- package/src/session/default-session-manager.e2e.test.ts +354 -0
- package/src/session/default-session-manager.test.ts +816 -0
- package/src/session/default-session-manager.ts +1286 -0
- package/src/session/index.ts +37 -0
- package/src/session/rpc-session-service.ts +189 -0
- package/src/session/runtime-oauth-token-manager.test.ts +137 -0
- package/src/session/runtime-oauth-token-manager.ts +265 -0
- package/src/session/session-artifacts.ts +106 -0
- package/src/session/session-graph.ts +90 -0
- package/src/session/session-host.ts +190 -0
- package/src/session/session-manager.ts +56 -0
- package/src/session/session-manifest.ts +29 -0
- package/src/session/session-service.team-persistence.test.ts +48 -0
- package/src/session/session-service.ts +610 -0
- package/src/session/sqlite-rpc-session-backend.ts +303 -0
- package/src/session/unified-session-persistence-service.ts +781 -0
- package/src/session/workspace-manager.ts +98 -0
- package/src/session/workspace-manifest.ts +100 -0
- package/src/storage/artifact-store.ts +1 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/provider-settings-legacy-migration.test.ts +175 -0
- package/src/storage/provider-settings-legacy-migration.ts +637 -0
- package/src/storage/provider-settings-manager.test.ts +111 -0
- package/src/storage/provider-settings-manager.ts +129 -0
- package/src/storage/session-store.ts +1 -0
- package/src/storage/sqlite-session-store.ts +270 -0
- package/src/storage/sqlite-team-store.ts +443 -0
- package/src/storage/team-store.ts +5 -0
- package/src/team/index.ts +4 -0
- package/src/team/projections.ts +285 -0
- package/src/types/common.ts +14 -0
- package/src/types/config.ts +64 -0
- package/src/types/events.ts +46 -0
- package/src/types/index.ts +24 -0
- package/src/types/provider-settings.ts +43 -0
- package/src/types/sessions.ts +16 -0
- package/src/types/storage.ts +64 -0
- package/src/types/workspace.ts +7 -0
- package/src/types.ts +127 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TeamEvent, TeamRuntimeState } from "@clinebot/agents";
|
|
2
|
+
import type { TeamProgressLifecycleEvent, TeamProgressSummary } from "@clinebot/shared";
|
|
3
|
+
export declare function buildTeamProgressSummary(teamName: string, state: TeamRuntimeState): TeamProgressSummary;
|
|
4
|
+
export declare function toTeamProgressLifecycleEvent(input: {
|
|
5
|
+
teamName: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
event: TeamEvent;
|
|
8
|
+
}): TeamProgressLifecycleEvent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SESSION_STATUSES: readonly ["running", "completed", "failed", "cancelled"];
|
|
2
|
+
export type SessionStatus = (typeof SESSION_STATUSES)[number];
|
|
3
|
+
export declare enum SessionSource {
|
|
4
|
+
CLI = "cli",
|
|
5
|
+
CLI_SUBAGENT = "cli-subagent",
|
|
6
|
+
CORE = "core",
|
|
7
|
+
CORE_SUBAGENT = "core-subagent",
|
|
8
|
+
DESKTOP = "desktop",
|
|
9
|
+
DESKTOP_CHAT = "desktop-chat"
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AgentConfig, AgentHooks, HookErrorMode, TeamEvent, Tool } from "@clinebot/agents";
|
|
2
|
+
import type { providers as LlmsProviders } from "@clinebot/llms";
|
|
3
|
+
import type { AgentMode, BasicLogger, SessionExecutionConfig, SessionPromptConfig, SessionWorkspaceConfig } from "@clinebot/shared";
|
|
4
|
+
export type CoreAgentMode = AgentMode;
|
|
5
|
+
export interface CoreModelConfig {
|
|
6
|
+
providerId: string;
|
|
7
|
+
modelId: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
providerConfig?: LlmsProviders.ProviderConfig;
|
|
12
|
+
knownModels?: Record<string, LlmsProviders.ModelInfo>;
|
|
13
|
+
/**
|
|
14
|
+
* Request model-side thinking/reasoning when supported.
|
|
15
|
+
*/
|
|
16
|
+
thinking?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface CoreRuntimeFeatures {
|
|
19
|
+
enableTools: boolean;
|
|
20
|
+
enableSpawnAgent: boolean;
|
|
21
|
+
enableAgentTeams: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface CoreSessionConfig extends CoreModelConfig, CoreRuntimeFeatures, Omit<SessionWorkspaceConfig, "workspaceRoot">, Omit<SessionPromptConfig, "systemPrompt">, Omit<SessionExecutionConfig, "enableTools" | "teamName" | "missionLogIntervalSteps" | "missionLogIntervalMs"> {
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
workspaceRoot?: string;
|
|
26
|
+
systemPrompt: string;
|
|
27
|
+
teamName?: string;
|
|
28
|
+
missionLogIntervalSteps?: number;
|
|
29
|
+
missionLogIntervalMs?: number;
|
|
30
|
+
hooks?: AgentHooks;
|
|
31
|
+
hookErrorMode?: HookErrorMode;
|
|
32
|
+
logger?: BasicLogger;
|
|
33
|
+
extraTools?: Tool[];
|
|
34
|
+
pluginPaths?: string[];
|
|
35
|
+
extensions?: AgentConfig["extensions"];
|
|
36
|
+
onTeamEvent?: (event: TeamEvent) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface SessionChunkEvent {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
stream: "stdout" | "stderr" | "agent";
|
|
4
|
+
chunk: string;
|
|
5
|
+
ts: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SessionEndedEvent {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
ts: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionToolEvent {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
hookEventName: "tool_call" | "tool_result" | "agent_end" | "session_shutdown";
|
|
15
|
+
agentId?: string;
|
|
16
|
+
conversationId?: string;
|
|
17
|
+
parentAgentId?: string;
|
|
18
|
+
iteration?: number;
|
|
19
|
+
toolName?: string;
|
|
20
|
+
inputTokens?: number;
|
|
21
|
+
outputTokens?: number;
|
|
22
|
+
ts?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionTeamProgressEvent {
|
|
25
|
+
sessionId: string;
|
|
26
|
+
teamName: string;
|
|
27
|
+
lifecycle: import("@clinebot/shared").TeamProgressLifecycleEvent;
|
|
28
|
+
summary: import("@clinebot/shared").TeamProgressSummary;
|
|
29
|
+
}
|
|
30
|
+
export type CoreSessionEvent = {
|
|
31
|
+
type: "chunk";
|
|
32
|
+
payload: SessionChunkEvent;
|
|
33
|
+
} | {
|
|
34
|
+
type: "agent_event";
|
|
35
|
+
payload: {
|
|
36
|
+
sessionId: string;
|
|
37
|
+
event: import("@clinebot/agents").AgentEvent;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
type: "team_progress";
|
|
41
|
+
payload: SessionTeamProgressEvent;
|
|
42
|
+
} | {
|
|
43
|
+
type: "ended";
|
|
44
|
+
payload: SessionEndedEvent;
|
|
45
|
+
} | {
|
|
46
|
+
type: "hook";
|
|
47
|
+
payload: SessionToolEvent;
|
|
48
|
+
} | {
|
|
49
|
+
type: "status";
|
|
50
|
+
payload: {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
status: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { providers } from "@clinebot/llms";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export type ProviderConfig = providers.ProviderConfig;
|
|
4
|
+
export type ProviderSettings = providers.ProviderSettings;
|
|
5
|
+
export declare const ProviderSettingsSchema: z.ZodType<ProviderSettings>;
|
|
6
|
+
export declare const toProviderConfig: typeof providers.toProviderConfig;
|
|
7
|
+
export type ProviderTokenSource = "manual" | "oauth" | "migration";
|
|
8
|
+
export interface StoredProviderSettingsEntry {
|
|
9
|
+
settings: ProviderSettings;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
tokenSource: ProviderTokenSource;
|
|
12
|
+
}
|
|
13
|
+
export interface StoredProviderSettings {
|
|
14
|
+
version: 1;
|
|
15
|
+
lastUsedProvider?: string;
|
|
16
|
+
providers: Record<string, StoredProviderSettingsEntry>;
|
|
17
|
+
}
|
|
18
|
+
export declare const StoredProviderSettingsEntrySchema: z.ZodType<StoredProviderSettingsEntry>;
|
|
19
|
+
export declare const StoredProviderSettingsSchema: z.ZodType<StoredProviderSettings>;
|
|
20
|
+
export declare function emptyStoredProviderSettings(): StoredProviderSettings;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SessionLineage, SessionRuntimeRecordShape } from "@clinebot/shared";
|
|
2
|
+
import type { SessionSource, SessionStatus } from "./common";
|
|
3
|
+
export interface SessionRef extends SessionLineage {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SessionRecord extends SessionRef, Omit<SessionRuntimeRecordShape, "source" | "status"> {
|
|
7
|
+
source: SessionSource;
|
|
8
|
+
status: SessionStatus;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TeamEvent, TeamRuntimeState, TeamTeammateSpec } from "@clinebot/agents";
|
|
2
|
+
import type { SessionStatus } from "./common";
|
|
3
|
+
import type { SessionRecord } from "./sessions";
|
|
4
|
+
export interface SessionStore {
|
|
5
|
+
init(): Promise<void> | void;
|
|
6
|
+
create(record: SessionRecord): Promise<void> | void;
|
|
7
|
+
updateStatus(sessionId: string, status: SessionStatus, exitCode?: number | null): Promise<void> | void;
|
|
8
|
+
update(record: Partial<SessionRecord> & {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
}): Promise<void> | void;
|
|
11
|
+
get(sessionId: string): Promise<SessionRecord | undefined> | SessionRecord | undefined;
|
|
12
|
+
list(limit?: number): Promise<SessionRecord[]> | SessionRecord[];
|
|
13
|
+
delete(sessionId: string, cascade?: boolean): Promise<boolean> | boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TeamStore {
|
|
16
|
+
listTeamNames(): Promise<string[]> | string[];
|
|
17
|
+
readState(teamName: string): Promise<TeamRuntimeState | undefined> | TeamRuntimeState | undefined;
|
|
18
|
+
readHistory(teamName: string, limit?: number): Promise<unknown[]> | unknown[];
|
|
19
|
+
loadRuntime(teamName: string): Promise<{
|
|
20
|
+
state?: TeamRuntimeState;
|
|
21
|
+
teammates: TeamTeammateSpec[];
|
|
22
|
+
interruptedRunIds: string[];
|
|
23
|
+
}> | {
|
|
24
|
+
state?: TeamRuntimeState;
|
|
25
|
+
teammates: TeamTeammateSpec[];
|
|
26
|
+
interruptedRunIds: string[];
|
|
27
|
+
};
|
|
28
|
+
handleTeamEvent(teamName: string, event: TeamEvent): Promise<void> | void;
|
|
29
|
+
persistRuntime(teamName: string, state: TeamRuntimeState, teammates: TeamTeammateSpec[]): Promise<void> | void;
|
|
30
|
+
markInProgressRunsInterrupted(teamName: string, reason: string): Promise<string[]> | string[];
|
|
31
|
+
}
|
|
32
|
+
export interface ArtifactStore {
|
|
33
|
+
appendTranscript(sessionId: string, text: string): Promise<void> | void;
|
|
34
|
+
appendHook(sessionId: string, payload: unknown): Promise<void> | void;
|
|
35
|
+
writeMessages(sessionId: string, messages: unknown[]): Promise<void> | void;
|
|
36
|
+
readTranscript(sessionId: string, maxChars?: number): Promise<string> | string;
|
|
37
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { providers as LlmsProviders } from "@clinebot/llms";
|
|
2
|
+
import type { CoreSessionEvent } from "./types/events";
|
|
3
|
+
export type { AgentConfigWatcher, AgentConfigWatcherEvent, AgentYamlConfig, BuildAgentConfigOverridesOptions, CreateAgentConfigWatcherOptions, CreateInstructionWatcherOptions, CreateRulesConfigDefinitionOptions, CreateSkillsConfigDefinitionOptions, CreateUserInstructionConfigWatcherOptions, CreateWorkflowsConfigDefinitionOptions, LoadAgentPluginFromPathOptions, ParseMarkdownFrontmatterResult, ParseYamlFrontmatterResult, ResolveAgentPluginPathsOptions, RuleConfig, SkillConfig, UnifiedConfigDefinition, UnifiedConfigFileCandidate, UnifiedConfigFileContext, UnifiedConfigRecord, UnifiedConfigWatcherEvent, UnifiedConfigWatcherOptions, UserInstructionConfig, UserInstructionConfigType, UserInstructionConfigWatcher, UserInstructionConfigWatcherEvent, WorkflowConfig, } from "./agents";
|
|
4
|
+
export { createAgentConfigDefinition, createAgentConfigWatcher, createRulesConfigDefinition, createSkillsConfigDefinition, createUserInstructionConfigWatcher, createWorkflowsConfigDefinition, discoverPluginModulePaths, loadAgentPluginFromPath, loadAgentPluginsFromPaths, parseAgentConfigFromYaml, parsePartialAgentConfigFromYaml, parseRuleConfigFromMarkdown, parseSkillConfigFromMarkdown, parseWorkflowConfigFromMarkdown, RULES_CONFIG_DIRECTORY_NAME, resolveAgentPluginPaths, resolveAgentTools, resolveAndLoadAgentPlugins, resolveDocumentsRulesDirectoryPath, resolveDocumentsWorkflowsDirectoryPath, resolvePluginConfigSearchPaths, resolveRulesConfigSearchPaths, resolveSkillsConfigSearchPaths, resolveWorkflowsConfigSearchPaths, SKILLS_CONFIG_DIRECTORY_NAME, toPartialAgentConfig, UnifiedConfigFileWatcher, WORKFLOWS_CONFIG_DIRECTORY_NAME, } from "./agents";
|
|
5
|
+
export type { ChatMessage, ChatSessionConfig, ChatSessionStatus, ChatSummary, ChatViewState, } from "./chat/chat-schema";
|
|
6
|
+
export type { SandboxCallOptions, SubprocessSandboxOptions, } from "./runtime/sandbox/subprocess-sandbox";
|
|
7
|
+
export { SubprocessSandbox } from "./runtime/sandbox/subprocess-sandbox";
|
|
8
|
+
export type { BuiltRuntime as RuntimeEnvironment, RuntimeBuilder, RuntimeBuilderInput, SessionRuntime, } from "./runtime/session-runtime";
|
|
9
|
+
export type { CreateSessionHostOptions, SessionHost, } from "./session/session-host";
|
|
10
|
+
export type { SendSessionInput, SessionManager, StartSessionInput, StartSessionResult, } from "./session/session-manager";
|
|
11
|
+
export type { SessionManifest } from "./session/session-manifest";
|
|
12
|
+
export type { CreateRootSessionWithArtifactsInput, RootSessionArtifacts, } from "./session/session-service";
|
|
13
|
+
export type { WorkspaceManager, WorkspaceManagerEvent, } from "./session/workspace-manager";
|
|
14
|
+
export type { WorkspaceManifest } from "./session/workspace-manifest";
|
|
15
|
+
export type { SessionSource, SessionStatus } from "./types/common";
|
|
16
|
+
export type { CoreAgentMode, CoreModelConfig, CoreRuntimeFeatures, CoreSessionConfig, } from "./types/config";
|
|
17
|
+
export type { CoreSessionEvent, SessionChunkEvent, SessionEndedEvent, SessionTeamProgressEvent, SessionToolEvent, } from "./types/events";
|
|
18
|
+
export type { SessionRecord, SessionRef } from "./types/sessions";
|
|
19
|
+
export type { ArtifactStore, SessionStore, TeamStore } from "./types/storage";
|
|
20
|
+
export type { WorkspaceInfo } from "./types/workspace";
|
|
21
|
+
export interface StoredMessages {
|
|
22
|
+
version: 1;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
messages: LlmsProviders.MessageWithMetadata[];
|
|
25
|
+
}
|
|
26
|
+
export type SessionEvent = CoreSessionEvent;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clinebot/core",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@clinebot/agents": "workspace:*",
|
|
7
|
+
"@clinebot/llms": "workspace:*",
|
|
8
|
+
"@clinebot/rpc": "workspace:*",
|
|
9
|
+
"@clinebot/shared": "workspace:*",
|
|
10
|
+
"nanoid": "^5.1.6",
|
|
11
|
+
"simple-git": "^3.32.3",
|
|
12
|
+
"yaml": "^2.8.2",
|
|
13
|
+
"zod": "^4.3.6"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"development": "./src/index.ts",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./node": {
|
|
22
|
+
"development": "./src/index.ts",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./browser": {
|
|
27
|
+
"development": "./src/index.ts",
|
|
28
|
+
"types": "./dist/index.browser.d.ts",
|
|
29
|
+
"import": "./dist/index.browser.js"
|
|
30
|
+
},
|
|
31
|
+
"./server": {
|
|
32
|
+
"development": "./src/server/index.ts",
|
|
33
|
+
"types": "./dist/server/index.d.ts",
|
|
34
|
+
"import": "./dist/server/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./server/node": {
|
|
37
|
+
"development": "./src/server/index.ts",
|
|
38
|
+
"types": "./dist/server/index.d.ts",
|
|
39
|
+
"import": "./dist/server/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./server/browser": {
|
|
42
|
+
"development": "./src/server/index.ts",
|
|
43
|
+
"types": "./dist/server.browser.d.ts",
|
|
44
|
+
"import": "./dist/server.browser.js"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"description": "State-aware orchestration for Cline Agent runtimes",
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"src"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "bun run ./build.ts && bun tsc -p tsconfig.build.json",
|
|
54
|
+
"clean": "rm -rf dist node_modules",
|
|
55
|
+
"typecheck": "bun tsc -p tsconfig.dev.json --noEmit",
|
|
56
|
+
"test": "bun run test:unit && bun run test:e2e",
|
|
57
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
58
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
59
|
+
"test:watch": "vitest --config vitest.config.ts"
|
|
60
|
+
},
|
|
61
|
+
"type": "module",
|
|
62
|
+
"types": "dist/index.d.ts"
|
|
63
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ClineAccountService } from "./cline-account-service";
|
|
3
|
+
|
|
4
|
+
describe("ClineAccountService", () => {
|
|
5
|
+
it("fetches current user balance and sends auth header", async () => {
|
|
6
|
+
const fetchImpl = vi.fn(async (input: unknown, init?: RequestInit) => {
|
|
7
|
+
expect(String(input)).toBe(
|
|
8
|
+
"https://api.cline.bot/api/v1/users/user-1/balance",
|
|
9
|
+
);
|
|
10
|
+
expect(init?.headers).toMatchObject({
|
|
11
|
+
Authorization: "Bearer workos:token-123",
|
|
12
|
+
});
|
|
13
|
+
return new Response(
|
|
14
|
+
JSON.stringify({
|
|
15
|
+
success: true,
|
|
16
|
+
data: { balance: 5, userId: "user-1" },
|
|
17
|
+
}),
|
|
18
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const service = new ClineAccountService({
|
|
23
|
+
apiBaseUrl: "https://api.cline.bot",
|
|
24
|
+
getAuthToken: async () => "workos:token-123",
|
|
25
|
+
getCurrentUserId: () => "user-1",
|
|
26
|
+
fetchImpl: fetchImpl as unknown as typeof fetch,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const balance = await service.fetchBalance();
|
|
30
|
+
expect(balance).toEqual({ balance: 5, userId: "user-1" });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("resolves organization member id from /users/me when not provided", async () => {
|
|
34
|
+
const fetchImpl = vi
|
|
35
|
+
.fn()
|
|
36
|
+
.mockResolvedValueOnce(
|
|
37
|
+
new Response(
|
|
38
|
+
JSON.stringify({
|
|
39
|
+
success: true,
|
|
40
|
+
data: {
|
|
41
|
+
id: "u-1",
|
|
42
|
+
email: "u@example.com",
|
|
43
|
+
displayName: "User",
|
|
44
|
+
photoUrl: "",
|
|
45
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
46
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
47
|
+
organizations: [
|
|
48
|
+
{
|
|
49
|
+
active: true,
|
|
50
|
+
memberId: "member-9",
|
|
51
|
+
name: "Org",
|
|
52
|
+
organizationId: "org-1",
|
|
53
|
+
roles: ["member"],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
{ status: 200 },
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
.mockResolvedValueOnce(
|
|
62
|
+
new Response(
|
|
63
|
+
JSON.stringify({ success: true, data: { items: [{ id: "tx-1" }] } }),
|
|
64
|
+
{ status: 200 },
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const service = new ClineAccountService({
|
|
69
|
+
apiBaseUrl: "https://api.cline.bot",
|
|
70
|
+
getAuthToken: async () => "workos:token-123",
|
|
71
|
+
fetchImpl: fetchImpl as unknown as typeof fetch,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const transactions = await service.fetchOrganizationUsageTransactions({
|
|
75
|
+
organizationId: "org-1",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
|
79
|
+
expect(String(fetchImpl.mock.calls[1][0])).toBe(
|
|
80
|
+
"https://api.cline.bot/api/v1/organizations/org-1/members/member-9/usages",
|
|
81
|
+
);
|
|
82
|
+
expect(transactions).toEqual([{ id: "tx-1" }]);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("switchAccount sends null org id for personal account", async () => {
|
|
86
|
+
const fetchImpl = vi.fn(async (_input: unknown, init?: RequestInit) => {
|
|
87
|
+
expect(init?.method).toBe("PUT");
|
|
88
|
+
expect(init?.body).toBe(JSON.stringify({ organizationId: null }));
|
|
89
|
+
return new Response(null, { status: 204 });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const service = new ClineAccountService({
|
|
93
|
+
apiBaseUrl: "https://api.cline.bot",
|
|
94
|
+
getAuthToken: async () => "workos:token-123",
|
|
95
|
+
fetchImpl: fetchImpl as unknown as typeof fetch,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await service.switchAccount(undefined);
|
|
99
|
+
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ClineAccountBalance,
|
|
3
|
+
ClineAccountOrganization,
|
|
4
|
+
ClineAccountOrganizationBalance,
|
|
5
|
+
ClineAccountOrganizationUsageTransaction,
|
|
6
|
+
ClineAccountPaymentTransaction,
|
|
7
|
+
ClineAccountUsageTransaction,
|
|
8
|
+
ClineAccountUser,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
12
|
+
|
|
13
|
+
interface ClineApiEnvelope<T> {
|
|
14
|
+
success?: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
data?: T;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ClineAccountServiceOptions {
|
|
20
|
+
apiBaseUrl: string;
|
|
21
|
+
getAuthToken: () => Promise<string | undefined | null>;
|
|
22
|
+
getCurrentUserId?: () =>
|
|
23
|
+
| Promise<string | undefined | null>
|
|
24
|
+
| string
|
|
25
|
+
| undefined
|
|
26
|
+
| null;
|
|
27
|
+
getOrganizationMemberId?: (
|
|
28
|
+
organizationId: string,
|
|
29
|
+
) => Promise<string | undefined | null> | string | undefined | null;
|
|
30
|
+
getHeaders?: () =>
|
|
31
|
+
| Promise<Record<string, string> | undefined>
|
|
32
|
+
| Record<string, string>
|
|
33
|
+
| undefined;
|
|
34
|
+
requestTimeoutMs?: number;
|
|
35
|
+
fetchImpl?: typeof fetch;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class ClineAccountService {
|
|
39
|
+
private readonly apiBaseUrl: string;
|
|
40
|
+
private readonly getAuthTokenFn: ClineAccountServiceOptions["getAuthToken"];
|
|
41
|
+
private readonly getCurrentUserIdFn: ClineAccountServiceOptions["getCurrentUserId"];
|
|
42
|
+
private readonly getOrganizationMemberIdFn: ClineAccountServiceOptions["getOrganizationMemberId"];
|
|
43
|
+
private readonly getHeadersFn: ClineAccountServiceOptions["getHeaders"];
|
|
44
|
+
private readonly requestTimeoutMs: number;
|
|
45
|
+
private readonly fetchImpl: typeof fetch;
|
|
46
|
+
|
|
47
|
+
constructor(options: ClineAccountServiceOptions) {
|
|
48
|
+
const apiBaseUrl = options.apiBaseUrl.trim();
|
|
49
|
+
if (!apiBaseUrl) {
|
|
50
|
+
throw new Error("apiBaseUrl is required");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
54
|
+
this.getAuthTokenFn = options.getAuthToken;
|
|
55
|
+
this.getCurrentUserIdFn = options.getCurrentUserId;
|
|
56
|
+
this.getOrganizationMemberIdFn = options.getOrganizationMemberId;
|
|
57
|
+
this.getHeadersFn = options.getHeaders;
|
|
58
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
59
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public async fetchMe(): Promise<ClineAccountUser> {
|
|
63
|
+
return this.request<ClineAccountUser>("/api/v1/users/me");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public async fetchBalance(userId?: string): Promise<ClineAccountBalance> {
|
|
67
|
+
const resolvedUserId = await this.resolveUserId(userId);
|
|
68
|
+
return this.request<ClineAccountBalance>(
|
|
69
|
+
`/api/v1/users/${encodeURIComponent(resolvedUserId)}/balance`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public async fetchUsageTransactions(
|
|
74
|
+
userId?: string,
|
|
75
|
+
): Promise<ClineAccountUsageTransaction[]> {
|
|
76
|
+
const resolvedUserId = await this.resolveUserId(userId);
|
|
77
|
+
const response = await this.request<{
|
|
78
|
+
items: ClineAccountUsageTransaction[];
|
|
79
|
+
}>(`/api/v1/users/${encodeURIComponent(resolvedUserId)}/usages`);
|
|
80
|
+
return response.items ?? [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public async fetchPaymentTransactions(
|
|
84
|
+
userId?: string,
|
|
85
|
+
): Promise<ClineAccountPaymentTransaction[]> {
|
|
86
|
+
const resolvedUserId = await this.resolveUserId(userId);
|
|
87
|
+
const response = await this.request<{
|
|
88
|
+
paymentTransactions: ClineAccountPaymentTransaction[];
|
|
89
|
+
}>(`/api/v1/users/${encodeURIComponent(resolvedUserId)}/payments`);
|
|
90
|
+
return response.paymentTransactions ?? [];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public async fetchUserOrganizations(): Promise<ClineAccountOrganization[]> {
|
|
94
|
+
const me = await this.fetchMe();
|
|
95
|
+
return me.organizations ?? [];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public async fetchOrganizationBalance(
|
|
99
|
+
organizationId: string,
|
|
100
|
+
): Promise<ClineAccountOrganizationBalance> {
|
|
101
|
+
const orgId = organizationId.trim();
|
|
102
|
+
if (!orgId) {
|
|
103
|
+
throw new Error("organizationId is required");
|
|
104
|
+
}
|
|
105
|
+
return this.request<ClineAccountOrganizationBalance>(
|
|
106
|
+
`/api/v1/organizations/${encodeURIComponent(orgId)}/balance`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public async fetchOrganizationUsageTransactions(input: {
|
|
111
|
+
organizationId: string;
|
|
112
|
+
memberId?: string;
|
|
113
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]> {
|
|
114
|
+
const organizationId = input.organizationId.trim();
|
|
115
|
+
if (!organizationId) {
|
|
116
|
+
throw new Error("organizationId is required");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const memberId = await this.resolveOrganizationMemberId(
|
|
120
|
+
organizationId,
|
|
121
|
+
input.memberId,
|
|
122
|
+
);
|
|
123
|
+
const response = await this.request<{
|
|
124
|
+
items: ClineAccountOrganizationUsageTransaction[];
|
|
125
|
+
}>(
|
|
126
|
+
`/api/v1/organizations/${encodeURIComponent(organizationId)}/members/${encodeURIComponent(memberId)}/usages`,
|
|
127
|
+
);
|
|
128
|
+
return response.items ?? [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async switchAccount(organizationId?: string | null): Promise<void> {
|
|
132
|
+
await this.request<void>("/api/v1/users/active-account", {
|
|
133
|
+
method: "PUT",
|
|
134
|
+
body: {
|
|
135
|
+
organizationId: organizationId?.trim() || null,
|
|
136
|
+
},
|
|
137
|
+
expectNoContent: true,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private async resolveUserId(userId?: string): Promise<string> {
|
|
142
|
+
const explicit = userId?.trim();
|
|
143
|
+
if (explicit) {
|
|
144
|
+
return explicit;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const fromProvider = this.getCurrentUserIdFn
|
|
148
|
+
? await this.getCurrentUserIdFn()
|
|
149
|
+
: undefined;
|
|
150
|
+
const provided = fromProvider?.trim();
|
|
151
|
+
if (provided) {
|
|
152
|
+
return provided;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const me = await this.fetchMe();
|
|
156
|
+
if (!me.id?.trim()) {
|
|
157
|
+
throw new Error("Unable to resolve current user id");
|
|
158
|
+
}
|
|
159
|
+
return me.id;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private async resolveOrganizationMemberId(
|
|
163
|
+
organizationId: string,
|
|
164
|
+
memberId?: string,
|
|
165
|
+
): Promise<string> {
|
|
166
|
+
const explicit = memberId?.trim();
|
|
167
|
+
if (explicit) {
|
|
168
|
+
return explicit;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const fromProvider = this.getOrganizationMemberIdFn
|
|
172
|
+
? await this.getOrganizationMemberIdFn(organizationId)
|
|
173
|
+
: undefined;
|
|
174
|
+
const provided = fromProvider?.trim();
|
|
175
|
+
if (provided) {
|
|
176
|
+
return provided;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const organizations = await this.fetchUserOrganizations();
|
|
180
|
+
const resolved = organizations.find(
|
|
181
|
+
(org) => org.organizationId === organizationId,
|
|
182
|
+
)?.memberId;
|
|
183
|
+
if (!resolved?.trim()) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Unable to resolve memberId for organization ${organizationId}`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return resolved;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private async request<T>(
|
|
192
|
+
endpoint: string,
|
|
193
|
+
input?: {
|
|
194
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
195
|
+
body?: unknown;
|
|
196
|
+
expectNoContent?: boolean;
|
|
197
|
+
},
|
|
198
|
+
): Promise<T> {
|
|
199
|
+
const token = (await this.getAuthTokenFn())?.trim();
|
|
200
|
+
if (!token) {
|
|
201
|
+
throw new Error("No Cline account auth token found");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const extraHeaders = this.getHeadersFn ? await this.getHeadersFn() : {};
|
|
205
|
+
const controller = new AbortController();
|
|
206
|
+
const timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
const response = await this.fetchImpl(
|
|
210
|
+
new URL(endpoint, this.apiBaseUrl),
|
|
211
|
+
{
|
|
212
|
+
method: input?.method ?? "GET",
|
|
213
|
+
headers: {
|
|
214
|
+
Authorization: `Bearer ${token}`,
|
|
215
|
+
"Content-Type": "application/json",
|
|
216
|
+
...(extraHeaders ?? {}),
|
|
217
|
+
},
|
|
218
|
+
body:
|
|
219
|
+
input?.body !== undefined ? JSON.stringify(input.body) : undefined,
|
|
220
|
+
signal: controller.signal,
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if (response.status === 204 || input?.expectNoContent) {
|
|
225
|
+
if (!response.ok) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Cline account request failed with status ${response.status}`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
return undefined as T;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const text = await response.text();
|
|
234
|
+
let parsed: unknown;
|
|
235
|
+
if (text.trim()) {
|
|
236
|
+
parsed = JSON.parse(text);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
const message =
|
|
241
|
+
typeof parsed === "object" && parsed !== null && "error" in parsed
|
|
242
|
+
? String((parsed as { error: unknown }).error)
|
|
243
|
+
: `Cline account request failed with status ${response.status}`;
|
|
244
|
+
throw new Error(message);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
248
|
+
const envelope = parsed as ClineApiEnvelope<T>;
|
|
249
|
+
if (typeof envelope.success === "boolean") {
|
|
250
|
+
if (!envelope.success) {
|
|
251
|
+
throw new Error(envelope.error || "Cline account request failed");
|
|
252
|
+
}
|
|
253
|
+
if (envelope.data !== undefined) {
|
|
254
|
+
return envelope.data;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (parsed === undefined || parsed === null) {
|
|
260
|
+
throw new Error("Cline account response payload was empty");
|
|
261
|
+
}
|
|
262
|
+
return parsed as T;
|
|
263
|
+
} finally {
|
|
264
|
+
clearTimeout(timeout);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ClineAccountService,
|
|
3
|
+
type ClineAccountServiceOptions,
|
|
4
|
+
} from "./cline-account-service";
|
|
5
|
+
export {
|
|
6
|
+
type ClineAccountOperations,
|
|
7
|
+
executeRpcClineAccountAction,
|
|
8
|
+
isRpcClineAccountActionRequest,
|
|
9
|
+
RpcClineAccountService,
|
|
10
|
+
type RpcProviderActionExecutor,
|
|
11
|
+
} from "./rpc";
|
|
12
|
+
export type {
|
|
13
|
+
ClineAccountBalance,
|
|
14
|
+
ClineAccountOrganization,
|
|
15
|
+
ClineAccountOrganizationBalance,
|
|
16
|
+
ClineAccountOrganizationUsageTransaction,
|
|
17
|
+
ClineAccountPaymentTransaction,
|
|
18
|
+
ClineAccountUsageTransaction,
|
|
19
|
+
ClineAccountUser,
|
|
20
|
+
} from "./types";
|