@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
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @clinebot/core
|
|
2
|
+
|
|
3
|
+
`@clinebot/core` is the stateful orchestration layer of the Cline SDK. It
|
|
4
|
+
connects the agent runtime, provider settings, storage, default tools, and
|
|
5
|
+
session lifecycle into a host-ready runtime.
|
|
6
|
+
|
|
7
|
+
## What You Get
|
|
8
|
+
|
|
9
|
+
- session lifecycle and orchestration primitives
|
|
10
|
+
- provider settings and account services
|
|
11
|
+
- default runtime tools and MCP integration
|
|
12
|
+
- storage-backed session and team state helpers
|
|
13
|
+
- host-facing Node helpers through `@clinebot/core/server`
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @clinebot/core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Entry Points
|
|
22
|
+
|
|
23
|
+
- `@clinebot/core`: runtime-agnostic core contracts and shared utilities
|
|
24
|
+
- `@clinebot/core/server`: Node/server helpers for building hosts and runtimes
|
|
25
|
+
|
|
26
|
+
## Typical Usage
|
|
27
|
+
|
|
28
|
+
Most host apps should start with `@clinebot/core/server`.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createSessionHost } from "@clinebot/core/server";
|
|
32
|
+
|
|
33
|
+
const host = await createSessionHost({});
|
|
34
|
+
|
|
35
|
+
const result = await host.start({
|
|
36
|
+
config: {
|
|
37
|
+
providerId: "anthropic",
|
|
38
|
+
modelId: "claude-sonnet-4-6",
|
|
39
|
+
apiKey: process.env.ANTHROPIC_API_KEY ?? "",
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
enableTools: true,
|
|
42
|
+
systemPrompt: "You are a concise assistant.",
|
|
43
|
+
},
|
|
44
|
+
prompt: "Summarize this project.",
|
|
45
|
+
interactive: false,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log(result.result?.text);
|
|
49
|
+
await host.dispose();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Main APIs
|
|
53
|
+
|
|
54
|
+
### Runtime and Sessions
|
|
55
|
+
|
|
56
|
+
Use `@clinebot/core/server` for host-facing runtime assembly:
|
|
57
|
+
|
|
58
|
+
- `createSessionHost(...)`
|
|
59
|
+
- `DefaultSessionManager`
|
|
60
|
+
- `DefaultRuntimeBuilder`
|
|
61
|
+
|
|
62
|
+
### Default Tools
|
|
63
|
+
|
|
64
|
+
`@clinebot/core` owns the built-in host tools and executors:
|
|
65
|
+
|
|
66
|
+
- `createBuiltinTools(...)`
|
|
67
|
+
- `createDefaultTools(...)`
|
|
68
|
+
- `createDefaultExecutors(...)`
|
|
69
|
+
|
|
70
|
+
### Storage and Settings
|
|
71
|
+
|
|
72
|
+
The package also exports storage and settings helpers such as:
|
|
73
|
+
|
|
74
|
+
- `ProviderSettingsManager`
|
|
75
|
+
- `SqliteTeamStore`
|
|
76
|
+
- SQLite RPC session backend helpers from `@clinebot/core/server`
|
|
77
|
+
|
|
78
|
+
## Related Packages
|
|
79
|
+
|
|
80
|
+
- `@clinebot/agents`: stateless agent loop and tool primitives
|
|
81
|
+
- `@clinebot/llms`: provider/model configuration and handlers
|
|
82
|
+
- `@clinebot/rpc`: remote session and runtime transport
|
|
83
|
+
|
|
84
|
+
## More Examples
|
|
85
|
+
|
|
86
|
+
- Repo examples: [apps/examples/cline-sdk](https://github.com/cline/cline/tree/main/apps/examples/cline-sdk)
|
|
87
|
+
- Workspace overview: [README.md](https://github.com/cline/cline/blob/main/README.md)
|
|
88
|
+
- API and architecture references: [DOC.md](https://github.com/cline/cline/blob/main/DOC.md), [ARCHITECTURE.md](https://github.com/cline/cline/blob/main/ARCHITECTURE.md)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser } from "./types";
|
|
2
|
+
export interface ClineAccountServiceOptions {
|
|
3
|
+
apiBaseUrl: string;
|
|
4
|
+
getAuthToken: () => Promise<string | undefined | null>;
|
|
5
|
+
getCurrentUserId?: () => Promise<string | undefined | null> | string | undefined | null;
|
|
6
|
+
getOrganizationMemberId?: (organizationId: string) => Promise<string | undefined | null> | string | undefined | null;
|
|
7
|
+
getHeaders?: () => Promise<Record<string, string> | undefined> | Record<string, string> | undefined;
|
|
8
|
+
requestTimeoutMs?: number;
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export declare class ClineAccountService {
|
|
12
|
+
private readonly apiBaseUrl;
|
|
13
|
+
private readonly getAuthTokenFn;
|
|
14
|
+
private readonly getCurrentUserIdFn;
|
|
15
|
+
private readonly getOrganizationMemberIdFn;
|
|
16
|
+
private readonly getHeadersFn;
|
|
17
|
+
private readonly requestTimeoutMs;
|
|
18
|
+
private readonly fetchImpl;
|
|
19
|
+
constructor(options: ClineAccountServiceOptions);
|
|
20
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
21
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
22
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
23
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
24
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
25
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
26
|
+
fetchOrganizationUsageTransactions(input: {
|
|
27
|
+
organizationId: string;
|
|
28
|
+
memberId?: string;
|
|
29
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
30
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
31
|
+
private resolveUserId;
|
|
32
|
+
private resolveOrganizationMemberId;
|
|
33
|
+
private request;
|
|
34
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ClineAccountService, type ClineAccountServiceOptions, } from "./cline-account-service";
|
|
2
|
+
export { type ClineAccountOperations, executeRpcClineAccountAction, isRpcClineAccountActionRequest, RpcClineAccountService, type RpcProviderActionExecutor, } from "./rpc";
|
|
3
|
+
export type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser, } from "./types";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RpcClineAccountActionRequest, RpcProviderActionRequest } from "@clinebot/shared";
|
|
2
|
+
import type { ClineAccountBalance, ClineAccountOrganization, ClineAccountOrganizationBalance, ClineAccountOrganizationUsageTransaction, ClineAccountPaymentTransaction, ClineAccountUsageTransaction, ClineAccountUser } from "./types";
|
|
3
|
+
export interface ClineAccountOperations {
|
|
4
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
5
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
6
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
7
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
8
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
9
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
10
|
+
fetchOrganizationUsageTransactions(input: {
|
|
11
|
+
organizationId: string;
|
|
12
|
+
memberId?: string;
|
|
13
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
14
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function isRpcClineAccountActionRequest(request: RpcProviderActionRequest): request is RpcClineAccountActionRequest;
|
|
17
|
+
export declare function executeRpcClineAccountAction(request: RpcClineAccountActionRequest, service: ClineAccountOperations): Promise<unknown>;
|
|
18
|
+
export interface RpcProviderActionExecutor {
|
|
19
|
+
runProviderAction(request: RpcProviderActionRequest): Promise<{
|
|
20
|
+
result: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export declare class RpcClineAccountService implements ClineAccountOperations {
|
|
24
|
+
private readonly executor;
|
|
25
|
+
constructor(executor: RpcProviderActionExecutor);
|
|
26
|
+
fetchMe(): Promise<ClineAccountUser>;
|
|
27
|
+
fetchBalance(userId?: string): Promise<ClineAccountBalance>;
|
|
28
|
+
fetchUsageTransactions(userId?: string): Promise<ClineAccountUsageTransaction[]>;
|
|
29
|
+
fetchPaymentTransactions(userId?: string): Promise<ClineAccountPaymentTransaction[]>;
|
|
30
|
+
fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
|
|
31
|
+
fetchOrganizationBalance(organizationId: string): Promise<ClineAccountOrganizationBalance>;
|
|
32
|
+
fetchOrganizationUsageTransactions(input: {
|
|
33
|
+
organizationId: string;
|
|
34
|
+
memberId?: string;
|
|
35
|
+
}): Promise<ClineAccountOrganizationUsageTransaction[]>;
|
|
36
|
+
switchAccount(organizationId?: string | null): Promise<void>;
|
|
37
|
+
private request;
|
|
38
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface ClineAccountOrganization {
|
|
2
|
+
active: boolean;
|
|
3
|
+
memberId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
organizationId: string;
|
|
6
|
+
roles: Array<"admin" | "member" | "owner">;
|
|
7
|
+
}
|
|
8
|
+
export interface ClineAccountUser {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
photoUrl: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
organizations: ClineAccountOrganization[];
|
|
16
|
+
}
|
|
17
|
+
export interface ClineAccountBalance {
|
|
18
|
+
balance: number;
|
|
19
|
+
userId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ClineAccountUsageTransaction {
|
|
22
|
+
aiInferenceProviderName: string;
|
|
23
|
+
aiModelName: string;
|
|
24
|
+
aiModelTypeName: string;
|
|
25
|
+
completionTokens: number;
|
|
26
|
+
costUsd: number;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
creditsUsed: number;
|
|
29
|
+
generationId: string;
|
|
30
|
+
id: string;
|
|
31
|
+
metadata: {
|
|
32
|
+
additionalProp1: string;
|
|
33
|
+
additionalProp2: string;
|
|
34
|
+
additionalProp3: string;
|
|
35
|
+
};
|
|
36
|
+
operation?: string;
|
|
37
|
+
organizationId: string;
|
|
38
|
+
promptTokens: number;
|
|
39
|
+
totalTokens: number;
|
|
40
|
+
userId: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ClineAccountPaymentTransaction {
|
|
43
|
+
paidAt: string;
|
|
44
|
+
creatorId: string;
|
|
45
|
+
amountCents: number;
|
|
46
|
+
credits: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ClineAccountOrganizationBalance {
|
|
49
|
+
balance: number;
|
|
50
|
+
organizationId: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ClineAccountOrganizationUsageTransaction {
|
|
53
|
+
aiInferenceProviderName: string;
|
|
54
|
+
aiModelName: string;
|
|
55
|
+
aiModelTypeName: string;
|
|
56
|
+
completionTokens: number;
|
|
57
|
+
costUsd: number;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
creditsUsed: number;
|
|
60
|
+
generationId: string;
|
|
61
|
+
id: string;
|
|
62
|
+
memberDisplayName: string;
|
|
63
|
+
memberEmail: string;
|
|
64
|
+
metadata: {
|
|
65
|
+
additionalProp1: string;
|
|
66
|
+
additionalProp2: string;
|
|
67
|
+
additionalProp3: string;
|
|
68
|
+
};
|
|
69
|
+
operation?: string;
|
|
70
|
+
organizationId: string;
|
|
71
|
+
promptTokens: number;
|
|
72
|
+
totalTokens: number;
|
|
73
|
+
userId: string;
|
|
74
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AGENT_CONFIG_DIRECTORY_NAME, resolveDocumentsAgentConfigDirectoryPath } from "@clinebot/shared/storage";
|
|
2
|
+
import { type AgentYamlConfig } from "./agent-config-parser";
|
|
3
|
+
import { type UnifiedConfigDefinition, UnifiedConfigFileWatcher, type UnifiedConfigWatcherEvent } from "./unified-config-file-watcher";
|
|
4
|
+
export type { AgentYamlConfig, BuildAgentConfigOverridesOptions, ParseYamlFrontmatterResult, } from "./agent-config-parser";
|
|
5
|
+
export { parseAgentConfigFromYaml, parsePartialAgentConfigFromYaml, resolveAgentTools, toPartialAgentConfig, } from "./agent-config-parser";
|
|
6
|
+
export type AgentConfigWatcher = UnifiedConfigFileWatcher<"agent", AgentYamlConfig>;
|
|
7
|
+
export type AgentConfigWatcherEvent = UnifiedConfigWatcherEvent<"agent", AgentYamlConfig>;
|
|
8
|
+
export { AGENT_CONFIG_DIRECTORY_NAME, resolveDocumentsAgentConfigDirectoryPath, };
|
|
9
|
+
export declare function resolveAgentsConfigDirPath(): string;
|
|
10
|
+
export declare function resolveAgentConfigSearchPaths(): string[];
|
|
11
|
+
export interface CreateAgentConfigWatcherOptions {
|
|
12
|
+
directoryPathOrPaths?: string | ReadonlyArray<string>;
|
|
13
|
+
debounceMs?: number;
|
|
14
|
+
emitParseErrors?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function createAgentConfigDefinition(directoryPathOrPaths?: string | ReadonlyArray<string>): UnifiedConfigDefinition<"agent", AgentYamlConfig>;
|
|
17
|
+
export declare function createAgentConfigWatcher(options?: CreateAgentConfigWatcherOptions): AgentConfigWatcher;
|
|
18
|
+
export declare function readAgentConfigsFromDisk(directoryPathOrPaths?: string | ReadonlyArray<string>): Promise<Map<string, AgentYamlConfig>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentConfig, Tool } from "@clinebot/agents";
|
|
2
|
+
import { type DefaultToolName } from "../default-tools";
|
|
3
|
+
export interface AgentYamlConfig {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
modelId?: string;
|
|
7
|
+
tools: DefaultToolName[];
|
|
8
|
+
skills?: string[];
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ParseYamlFrontmatterResult {
|
|
12
|
+
data: Record<string, unknown>;
|
|
13
|
+
body: string;
|
|
14
|
+
hadFrontmatter: boolean;
|
|
15
|
+
parseError?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BuildAgentConfigOverridesOptions {
|
|
18
|
+
availableTools?: ReadonlyArray<Tool>;
|
|
19
|
+
}
|
|
20
|
+
export declare function isAgentConfigYamlFile(fileName: string): boolean;
|
|
21
|
+
export declare function normalizeAgentConfigName(name: string): string;
|
|
22
|
+
export declare function parseAgentConfigFromYaml(content: string): AgentYamlConfig;
|
|
23
|
+
export declare function resolveAgentTools(toolNames: ReadonlyArray<DefaultToolName>, availableTools: ReadonlyArray<Tool>): Tool[];
|
|
24
|
+
export declare function toPartialAgentConfig(config: AgentYamlConfig, options?: BuildAgentConfigOverridesOptions): Partial<Pick<AgentConfig, "modelId" | "systemPrompt" | "tools">>;
|
|
25
|
+
export declare function parsePartialAgentConfigFromYaml(content: string, options?: BuildAgentConfigOverridesOptions): Partial<Pick<AgentConfig, "modelId" | "systemPrompt" | "tools">>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HookEventName } from "@clinebot/agents";
|
|
2
|
+
import { HOOKS_CONFIG_DIRECTORY_NAME, resolveDocumentsHooksDirectoryPath } from "@clinebot/shared/storage";
|
|
3
|
+
export { HOOKS_CONFIG_DIRECTORY_NAME, resolveDocumentsHooksDirectoryPath };
|
|
4
|
+
export declare function resolveHooksConfigSearchPaths(workspacePath?: string): string[];
|
|
5
|
+
export declare enum HookConfigFileName {
|
|
6
|
+
TaskStart = "TaskStart",
|
|
7
|
+
TaskResume = "TaskResume",
|
|
8
|
+
TaskCancel = "TaskCancel",
|
|
9
|
+
TaskComplete = "TaskComplete",
|
|
10
|
+
PreToolUse = "PreToolUse",
|
|
11
|
+
PostToolUse = "PostToolUse",
|
|
12
|
+
UserPromptSubmit = "UserPromptSubmit",
|
|
13
|
+
PreCompact = "PreCompact",
|
|
14
|
+
SessionShutdown = "SessionShutdown"
|
|
15
|
+
}
|
|
16
|
+
export declare const HOOK_CONFIG_FILE_EVENT_MAP: Readonly<Record<HookConfigFileName, HookEventName | undefined>>;
|
|
17
|
+
export declare function toHookConfigFileName(fileName: string): HookConfigFileName | undefined;
|
|
18
|
+
export interface HookConfigFileEntry {
|
|
19
|
+
fileName: HookConfigFileName;
|
|
20
|
+
hookEventName?: HookEventName;
|
|
21
|
+
path: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function listHookConfigFiles(workspacePath?: string): HookConfigFileEntry[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { AgentConfigWatcher, AgentConfigWatcherEvent, AgentYamlConfig, BuildAgentConfigOverridesOptions, CreateAgentConfigWatcherOptions, ParseYamlFrontmatterResult, } from "./agent-config-loader";
|
|
2
|
+
export { AGENT_CONFIG_DIRECTORY_NAME, createAgentConfigDefinition, createAgentConfigWatcher, parseAgentConfigFromYaml, parsePartialAgentConfigFromYaml, readAgentConfigsFromDisk, resolveAgentConfigSearchPaths, resolveAgentsConfigDirPath, resolveAgentTools, resolveDocumentsAgentConfigDirectoryPath, toPartialAgentConfig, } from "./agent-config-loader";
|
|
3
|
+
export { HOOK_CONFIG_FILE_EVENT_MAP, HOOKS_CONFIG_DIRECTORY_NAME, type HookConfigFileEntry, HookConfigFileName, listHookConfigFiles, resolveDocumentsHooksDirectoryPath, resolveHooksConfigSearchPaths, toHookConfigFileName, } from "./hooks-config-loader";
|
|
4
|
+
export type { ResolveAgentPluginPathsOptions } from "./plugin-config-loader";
|
|
5
|
+
export { discoverPluginModulePaths, resolveAgentPluginPaths, resolveAndLoadAgentPlugins, resolvePluginConfigSearchPaths, } from "./plugin-config-loader";
|
|
6
|
+
export type { LoadAgentPluginFromPathOptions } from "./plugin-loader";
|
|
7
|
+
export { loadAgentPluginFromPath, loadAgentPluginsFromPaths, } from "./plugin-loader";
|
|
8
|
+
export type { UnifiedConfigDefinition, UnifiedConfigFileCandidate, UnifiedConfigFileContext, UnifiedConfigRecord, UnifiedConfigWatcherEvent, UnifiedConfigWatcherOptions, } from "./unified-config-file-watcher";
|
|
9
|
+
export { UnifiedConfigFileWatcher } from "./unified-config-file-watcher";
|
|
10
|
+
export type { CreateInstructionWatcherOptions, CreateRulesConfigDefinitionOptions, CreateSkillsConfigDefinitionOptions, CreateUserInstructionConfigWatcherOptions, CreateWorkflowsConfigDefinitionOptions, ParseMarkdownFrontmatterResult, RuleConfig, SkillConfig, UserInstructionConfig, UserInstructionConfigType, UserInstructionConfigWatcher, UserInstructionConfigWatcherEvent, WorkflowConfig, } from "./user-instruction-config-loader";
|
|
11
|
+
export { createRulesConfigDefinition, createSkillsConfigDefinition, createUserInstructionConfigWatcher, createWorkflowsConfigDefinition, parseRuleConfigFromMarkdown, parseSkillConfigFromMarkdown, parseWorkflowConfigFromMarkdown, RULES_CONFIG_DIRECTORY_NAME, resolveDocumentsRulesDirectoryPath, resolveDocumentsWorkflowsDirectoryPath, resolveRulesConfigSearchPaths, resolveSkillsConfigSearchPaths, resolveWorkflowsConfigSearchPaths, SKILLS_CONFIG_DIRECTORY_NAME, WORKFLOWS_CONFIG_DIRECTORY_NAME, } from "./user-instruction-config-loader";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentConfig } from "@clinebot/agents";
|
|
2
|
+
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
3
|
+
export declare function resolvePluginConfigSearchPaths(workspacePath?: string): string[];
|
|
4
|
+
export declare function discoverPluginModulePaths(directoryPath: string): string[];
|
|
5
|
+
export interface ResolveAgentPluginPathsOptions {
|
|
6
|
+
pluginPaths?: ReadonlyArray<string>;
|
|
7
|
+
workspacePath?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveAgentPluginPaths(options?: ResolveAgentPluginPathsOptions): string[];
|
|
11
|
+
export interface ResolveAndLoadAgentPluginsOptions extends ResolveAgentPluginPathsOptions {
|
|
12
|
+
mode?: "sandbox" | "in_process";
|
|
13
|
+
exportName?: string;
|
|
14
|
+
importTimeoutMs?: number;
|
|
15
|
+
hookTimeoutMs?: number;
|
|
16
|
+
contributionTimeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveAndLoadAgentPlugins(options?: ResolveAndLoadAgentPluginsOptions): Promise<{
|
|
19
|
+
extensions: AgentPlugin[];
|
|
20
|
+
shutdown?: () => Promise<void>;
|
|
21
|
+
}>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentConfig } from "@clinebot/agents";
|
|
2
|
+
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
3
|
+
export interface LoadAgentPluginFromPathOptions {
|
|
4
|
+
exportName?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function loadAgentPluginFromPath(pluginPath: string, options?: LoadAgentPluginFromPathOptions): Promise<AgentPlugin>;
|
|
8
|
+
export declare function loadAgentPluginsFromPaths(pluginPaths: string[], options?: LoadAgentPluginFromPathOptions): Promise<AgentPlugin[]>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentConfig } from "@clinebot/agents";
|
|
2
|
+
export interface PluginSandboxOptions {
|
|
3
|
+
pluginPaths: string[];
|
|
4
|
+
exportName?: string;
|
|
5
|
+
importTimeoutMs?: number;
|
|
6
|
+
hookTimeoutMs?: number;
|
|
7
|
+
contributionTimeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{
|
|
10
|
+
extensions: AgentConfig["extensions"];
|
|
11
|
+
shutdown: () => Promise<void>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface UnifiedConfigFileContext<TType extends string = string> {
|
|
2
|
+
type: TType;
|
|
3
|
+
directoryPath: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UnifiedConfigFileCandidate {
|
|
9
|
+
directoryPath: string;
|
|
10
|
+
fileName: string;
|
|
11
|
+
filePath: string;
|
|
12
|
+
}
|
|
13
|
+
export interface UnifiedConfigDefinition<TType extends string = string, TItem = unknown> {
|
|
14
|
+
type: TType;
|
|
15
|
+
directories: ReadonlyArray<string>;
|
|
16
|
+
discoverFiles?: (directoryPath: string) => Promise<ReadonlyArray<UnifiedConfigFileCandidate>>;
|
|
17
|
+
includeFile?: (fileName: string, filePath: string) => boolean;
|
|
18
|
+
parseFile: (context: UnifiedConfigFileContext<TType>) => TItem;
|
|
19
|
+
resolveId: (item: TItem, context: UnifiedConfigFileContext<TType>) => string;
|
|
20
|
+
}
|
|
21
|
+
export interface UnifiedConfigWatcherOptions {
|
|
22
|
+
debounceMs?: number;
|
|
23
|
+
emitParseErrors?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface UnifiedConfigRecord<TType extends string = string, TItem = unknown> {
|
|
26
|
+
type: TType;
|
|
27
|
+
id: string;
|
|
28
|
+
item: TItem;
|
|
29
|
+
filePath: string;
|
|
30
|
+
}
|
|
31
|
+
export type UnifiedConfigWatcherEvent<TType extends string = string, TItem = unknown> = {
|
|
32
|
+
kind: "upsert";
|
|
33
|
+
record: UnifiedConfigRecord<TType, TItem>;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "remove";
|
|
36
|
+
type: TType;
|
|
37
|
+
id: string;
|
|
38
|
+
filePath: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "error";
|
|
41
|
+
type: TType;
|
|
42
|
+
error: unknown;
|
|
43
|
+
filePath?: string;
|
|
44
|
+
};
|
|
45
|
+
export declare class UnifiedConfigFileWatcher<TType extends string = string, TItem = unknown> {
|
|
46
|
+
private readonly definitions;
|
|
47
|
+
private readonly debounceMs;
|
|
48
|
+
private readonly emitParseErrors;
|
|
49
|
+
private readonly listeners;
|
|
50
|
+
private readonly recordsByType;
|
|
51
|
+
private readonly watchersByDirectory;
|
|
52
|
+
private readonly baseTypesByDirectory;
|
|
53
|
+
private watchedTypesByDirectory;
|
|
54
|
+
private readonly discoveredDirectoriesByType;
|
|
55
|
+
private readonly definitionsByType;
|
|
56
|
+
private readonly pendingTypes;
|
|
57
|
+
private flushTimer;
|
|
58
|
+
private refreshQueue;
|
|
59
|
+
private started;
|
|
60
|
+
constructor(definitions: ReadonlyArray<UnifiedConfigDefinition<TType, TItem>>, options?: UnifiedConfigWatcherOptions);
|
|
61
|
+
subscribe(listener: (event: UnifiedConfigWatcherEvent<TType, TItem>) => void): () => void;
|
|
62
|
+
start(): Promise<void>;
|
|
63
|
+
stop(): void;
|
|
64
|
+
refreshAll(): Promise<void>;
|
|
65
|
+
refreshType(type: TType): Promise<void>;
|
|
66
|
+
getSnapshot(type: TType): Map<string, UnifiedConfigRecord<TType, TItem>>;
|
|
67
|
+
getAllSnapshots(): Map<TType, Map<string, UnifiedConfigRecord<TType, TItem>>>;
|
|
68
|
+
private emit;
|
|
69
|
+
private enqueueRefresh;
|
|
70
|
+
private startDirectoryWatchers;
|
|
71
|
+
private syncDirectoryWatchers;
|
|
72
|
+
private scheduleFlush;
|
|
73
|
+
private refreshTypeInternal;
|
|
74
|
+
private loadDefinition;
|
|
75
|
+
private buildDesiredTypesByDirectory;
|
|
76
|
+
private readDirectoryFileCandidates;
|
|
77
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { RULES_CONFIG_DIRECTORY_NAME, resolveDocumentsRulesDirectoryPath, resolveDocumentsWorkflowsDirectoryPath, SKILLS_CONFIG_DIRECTORY_NAME, WORKFLOWS_CONFIG_DIRECTORY_NAME } from "@clinebot/shared/storage";
|
|
2
|
+
import { type UnifiedConfigDefinition, UnifiedConfigFileWatcher, type UnifiedConfigWatcherEvent } from "./unified-config-file-watcher";
|
|
3
|
+
export { RULES_CONFIG_DIRECTORY_NAME, resolveDocumentsRulesDirectoryPath, resolveDocumentsWorkflowsDirectoryPath, SKILLS_CONFIG_DIRECTORY_NAME, WORKFLOWS_CONFIG_DIRECTORY_NAME, };
|
|
4
|
+
export interface ParseMarkdownFrontmatterResult {
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
body: string;
|
|
7
|
+
hadFrontmatter: boolean;
|
|
8
|
+
parseError?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SkillConfig {
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
instructions: string;
|
|
15
|
+
frontmatter: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface RuleConfig {
|
|
18
|
+
name: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
instructions: string;
|
|
21
|
+
frontmatter: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkflowConfig {
|
|
24
|
+
name: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
instructions: string;
|
|
27
|
+
frontmatter: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export type UserInstructionConfigType = "skill" | "rule" | "workflow";
|
|
30
|
+
export type UserInstructionConfig = SkillConfig | RuleConfig | WorkflowConfig;
|
|
31
|
+
export type UserInstructionConfigWatcher = UnifiedConfigFileWatcher<UserInstructionConfigType, UserInstructionConfig>;
|
|
32
|
+
export type UserInstructionConfigWatcherEvent = UnifiedConfigWatcherEvent<UserInstructionConfigType, UserInstructionConfig>;
|
|
33
|
+
export interface CreateInstructionWatcherOptions {
|
|
34
|
+
debounceMs?: number;
|
|
35
|
+
emitParseErrors?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateSkillsConfigDefinitionOptions {
|
|
38
|
+
directories?: ReadonlyArray<string>;
|
|
39
|
+
workspacePath?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface CreateRulesConfigDefinitionOptions {
|
|
42
|
+
directories?: ReadonlyArray<string>;
|
|
43
|
+
workspacePath?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CreateWorkflowsConfigDefinitionOptions {
|
|
46
|
+
directories?: ReadonlyArray<string>;
|
|
47
|
+
workspacePath?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function parseSkillConfigFromMarkdown(content: string, fallbackName: string): SkillConfig;
|
|
50
|
+
export declare function parseRuleConfigFromMarkdown(content: string, fallbackName: string): RuleConfig;
|
|
51
|
+
export declare function parseWorkflowConfigFromMarkdown(content: string, fallbackName: string): WorkflowConfig;
|
|
52
|
+
export declare function resolveSkillsConfigSearchPaths(workspacePath?: string): string[];
|
|
53
|
+
export declare function resolveRulesConfigSearchPaths(workspacePath?: string): string[];
|
|
54
|
+
export declare function resolveWorkflowsConfigSearchPaths(workspacePath?: string): string[];
|
|
55
|
+
export declare function createSkillsConfigDefinition(options?: CreateSkillsConfigDefinitionOptions): UnifiedConfigDefinition<"skill", SkillConfig>;
|
|
56
|
+
export declare function createRulesConfigDefinition(options?: CreateRulesConfigDefinitionOptions): UnifiedConfigDefinition<"rule", RuleConfig>;
|
|
57
|
+
export declare function createWorkflowsConfigDefinition(options?: CreateWorkflowsConfigDefinitionOptions): UnifiedConfigDefinition<"workflow", WorkflowConfig>;
|
|
58
|
+
export interface CreateUserInstructionConfigWatcherOptions extends CreateInstructionWatcherOptions {
|
|
59
|
+
skills?: CreateSkillsConfigDefinitionOptions;
|
|
60
|
+
rules?: CreateRulesConfigDefinitionOptions;
|
|
61
|
+
workflows?: CreateWorkflowsConfigDefinitionOptions;
|
|
62
|
+
}
|
|
63
|
+
export declare function createUserInstructionConfigWatcher(options?: CreateUserInstructionConfigWatcherOptions): UserInstructionConfigWatcher;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OAuthLoginCallbacks, OAuthPrompt } from "./types.js";
|
|
2
|
+
export interface OAuthClientCallbacksOptions {
|
|
3
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
4
|
+
onOutput?: (message: string) => void;
|
|
5
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
6
|
+
onOpenUrlError?: (context: {
|
|
7
|
+
url: string;
|
|
8
|
+
error: unknown;
|
|
9
|
+
}) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createOAuthClientCallbacks(options: OAuthClientCallbacksOptions): OAuthLoginCallbacks;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks, OAuthProviderInterface } from "./types.js";
|
|
2
|
+
export type ClineTokenResolution = {
|
|
3
|
+
forceRefresh?: boolean;
|
|
4
|
+
refreshBufferMs?: number;
|
|
5
|
+
retryableTokenGraceMs?: number;
|
|
6
|
+
};
|
|
7
|
+
interface ClineAuthApiUser {
|
|
8
|
+
subject: string | null;
|
|
9
|
+
email: string;
|
|
10
|
+
name: string;
|
|
11
|
+
clineUserId: string | null;
|
|
12
|
+
accounts: string[] | null;
|
|
13
|
+
}
|
|
14
|
+
type HeaderMap = Record<string, string>;
|
|
15
|
+
type HeaderInput = HeaderMap | (() => Promise<HeaderMap> | HeaderMap);
|
|
16
|
+
export interface ClineOAuthProviderOptions {
|
|
17
|
+
apiBaseUrl: string;
|
|
18
|
+
headers?: HeaderInput;
|
|
19
|
+
callbackPath?: string;
|
|
20
|
+
callbackPorts?: number[];
|
|
21
|
+
requestTimeoutMs?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Optional identity provider name for token exchange.
|
|
24
|
+
*/
|
|
25
|
+
provider?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ClineOAuthCredentials extends OAuthCredentials {
|
|
28
|
+
metadata?: {
|
|
29
|
+
provider?: string;
|
|
30
|
+
tokenType?: string;
|
|
31
|
+
userInfo?: ClineAuthApiUser;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function loginClineOAuth(options: ClineOAuthProviderOptions & {
|
|
36
|
+
callbacks: OAuthLoginCallbacks;
|
|
37
|
+
}): Promise<ClineOAuthCredentials>;
|
|
38
|
+
export declare function refreshClineToken(current: ClineOAuthCredentials, options: ClineOAuthProviderOptions): Promise<ClineOAuthCredentials>;
|
|
39
|
+
export declare function getValidClineCredentials(currentCredentials: ClineOAuthCredentials | null, providerOptions: ClineOAuthProviderOptions, options?: ClineTokenResolution): Promise<ClineOAuthCredentials | null>;
|
|
40
|
+
export declare function createClineOAuthProvider(options: ClineOAuthProviderOptions): OAuthProviderInterface;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex (ChatGPT OAuth) flow
|
|
3
|
+
*
|
|
4
|
+
* NOTE: This module uses Node.js crypto and http for the OAuth callback.
|
|
5
|
+
* It is only intended for CLI use, not browser environments.
|
|
6
|
+
*/
|
|
7
|
+
import type { OAuthCredentials, OAuthPrompt, OAuthProviderInterface } from "./types.js";
|
|
8
|
+
export declare const OPENAI_CODEX_OAUTH_CONFIG: {
|
|
9
|
+
readonly authorizationEndpoint: "https://auth.openai.com/oauth/authorize";
|
|
10
|
+
readonly tokenEndpoint: "https://auth.openai.com/oauth/token";
|
|
11
|
+
readonly clientId: "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
12
|
+
readonly redirectUri: "http://localhost:1455/auth/callback";
|
|
13
|
+
readonly scopes: "openid profile email offline_access";
|
|
14
|
+
readonly callbackPort: 1455;
|
|
15
|
+
readonly jwtClaimPath: "https://api.openai.com/auth";
|
|
16
|
+
readonly refreshBufferMs: number;
|
|
17
|
+
readonly retryableTokenGraceMs: number;
|
|
18
|
+
readonly httpTimeoutMs: number;
|
|
19
|
+
};
|
|
20
|
+
export type RefreshTokenResolution = {
|
|
21
|
+
forceRefresh?: boolean;
|
|
22
|
+
refreshBufferMs?: number;
|
|
23
|
+
retryableTokenGraceMs?: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function loginOpenAICodex(options: {
|
|
26
|
+
onAuth: (info: {
|
|
27
|
+
url: string;
|
|
28
|
+
instructions?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
31
|
+
onProgress?: (message: string) => void;
|
|
32
|
+
onManualCodeInput?: () => Promise<string>;
|
|
33
|
+
originator?: string;
|
|
34
|
+
}): Promise<OAuthCredentials>;
|
|
35
|
+
export declare function refreshOpenAICodexToken(refreshToken: string, fallback?: OAuthCredentials): Promise<OAuthCredentials>;
|
|
36
|
+
export declare function getValidOpenAICodexCredentials(currentCredentials: OAuthCredentials | null, options?: RefreshTokenResolution): Promise<OAuthCredentials | null>;
|
|
37
|
+
export declare function isOpenAICodexTokenExpired(credentials: OAuthCredentials, refreshBufferMs?: number): boolean;
|
|
38
|
+
export declare function normalizeOpenAICodexCredentials(credentials: OAuthCredentials): OAuthCredentials;
|
|
39
|
+
export declare const openaiCodexOAuthProvider: OAuthProviderInterface;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OAuthCredentials, OAuthLoginCallbacks, OAuthProviderInterface, OcaClientMetadata, OcaOAuthProviderOptions, OcaTokenResolution } from "./types.js";
|
|
2
|
+
export declare const DEFAULT_INTERNAL_IDCS_CLIENT_ID = "a8331954c0cf48ba99b5dd223a14c6ea";
|
|
3
|
+
export declare const DEFAULT_INTERNAL_IDCS_URL = "https://idcs-9dc693e80d9b469480d7afe00e743931.identity.oraclecloud.com";
|
|
4
|
+
export declare const DEFAULT_INTERNAL_IDCS_SCOPES = "openid offline_access";
|
|
5
|
+
export declare const DEFAULT_INTERNAL_OCA_BASE_URL = "https://code-internal.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
6
|
+
export declare const DEFAULT_EXTERNAL_IDCS_CLIENT_ID = "c1aba3deed5740659981a752714eba33";
|
|
7
|
+
export declare const DEFAULT_EXTERNAL_IDCS_URL = "https://login-ext.identity.oraclecloud.com";
|
|
8
|
+
export declare const DEFAULT_EXTERNAL_IDCS_SCOPES = "openid offline_access";
|
|
9
|
+
export declare const DEFAULT_EXTERNAL_OCA_BASE_URL = "https://code.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
10
|
+
export declare const OCI_HEADER_OPC_REQUEST_ID = "opc-request-id";
|
|
11
|
+
export declare function loginOcaOAuth(options: OcaOAuthProviderOptions & {
|
|
12
|
+
callbacks: OAuthLoginCallbacks;
|
|
13
|
+
}): Promise<OAuthCredentials>;
|
|
14
|
+
export declare function refreshOcaToken(credentials: OAuthCredentials, options?: OcaOAuthProviderOptions): Promise<OAuthCredentials>;
|
|
15
|
+
export declare function getValidOcaCredentials(currentCredentials: OAuthCredentials | null, options?: OcaTokenResolution, providerOptions?: OcaOAuthProviderOptions): Promise<OAuthCredentials | null>;
|
|
16
|
+
export declare function createOcaOAuthProvider(options?: OcaOAuthProviderOptions): OAuthProviderInterface;
|
|
17
|
+
export declare function generateOcaOpcRequestId(taskId: string, token: string): Promise<string>;
|
|
18
|
+
export declare function createOcaRequestHeaders(input: {
|
|
19
|
+
accessToken: string;
|
|
20
|
+
taskId: string;
|
|
21
|
+
metadata?: OcaClientMetadata;
|
|
22
|
+
}): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface OAuthCallbackPayload {
|
|
2
|
+
url: URL;
|
|
3
|
+
code?: string;
|
|
4
|
+
state?: string;
|
|
5
|
+
provider?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LocalOAuthServerOptions {
|
|
9
|
+
host?: string;
|
|
10
|
+
ports: number[];
|
|
11
|
+
callbackPath: string;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
expectedState?: string;
|
|
14
|
+
successHtml?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LocalOAuthServer {
|
|
17
|
+
callbackUrl: string;
|
|
18
|
+
waitForCallback: () => Promise<OAuthCallbackPayload | null>;
|
|
19
|
+
cancelWait: () => void;
|
|
20
|
+
close: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function startLocalOAuthServer(options: LocalOAuthServerOptions): Promise<LocalOAuthServer>;
|