@clinebot/shared 0.0.11 → 0.0.13

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @clinebot/shared
1
+ # [experimental] @clinebot/shared
2
2
 
3
3
  Package-level docs are centralized:
4
4
 
@@ -0,0 +1,143 @@
1
+ export type ConnectWhatsAppOptions = {
2
+ userName: string;
3
+ phoneNumberId?: string;
4
+ accessToken?: string;
5
+ appSecret?: string;
6
+ verifyToken?: string;
7
+ apiVersion?: string;
8
+ cwd: string;
9
+ model?: string;
10
+ provider?: string;
11
+ apiKey?: string;
12
+ systemPrompt?: string;
13
+ mode: "act" | "plan";
14
+ interactive: boolean;
15
+ maxIterations?: number;
16
+ enableTools: boolean;
17
+ rpcAddress: string;
18
+ hookCommand?: string;
19
+ port: number;
20
+ host: string;
21
+ baseUrl: string;
22
+ };
23
+ export type WhatsAppConnectorState = {
24
+ instanceKey: string;
25
+ userName: string;
26
+ phoneNumberId?: string;
27
+ pid: number;
28
+ rpcAddress: string;
29
+ port: number;
30
+ baseUrl: string;
31
+ startedAt: string;
32
+ };
33
+ export type ConnectTelegramOptions = {
34
+ botToken: string;
35
+ botUsername: string;
36
+ cwd: string;
37
+ model?: string;
38
+ provider?: string;
39
+ apiKey?: string;
40
+ systemPrompt?: string;
41
+ mode: "act" | "plan";
42
+ interactive: boolean;
43
+ maxIterations?: number;
44
+ enableTools: boolean;
45
+ rpcAddress: string;
46
+ hookCommand?: string;
47
+ };
48
+ export type TelegramConnectorState = {
49
+ botUsername: string;
50
+ pid: number;
51
+ rpcAddress: string;
52
+ startedAt: string;
53
+ };
54
+ export type ConnectSlackOptions = {
55
+ userName: string;
56
+ botToken?: string;
57
+ signingSecret?: string;
58
+ clientId?: string;
59
+ clientSecret?: string;
60
+ encryptionKey?: string;
61
+ installationKeyPrefix?: string;
62
+ cwd: string;
63
+ model?: string;
64
+ provider?: string;
65
+ apiKey?: string;
66
+ systemPrompt?: string;
67
+ mode: "act" | "plan";
68
+ interactive: boolean;
69
+ maxIterations?: number;
70
+ enableTools: boolean;
71
+ rpcAddress: string;
72
+ hookCommand?: string;
73
+ port: number;
74
+ host: string;
75
+ baseUrl: string;
76
+ };
77
+ export type SlackConnectorState = {
78
+ userName: string;
79
+ pid: number;
80
+ rpcAddress: string;
81
+ port: number;
82
+ baseUrl: string;
83
+ startedAt: string;
84
+ };
85
+ export type ConnectGoogleChatOptions = {
86
+ userName: string;
87
+ cwd: string;
88
+ model?: string;
89
+ provider?: string;
90
+ apiKey?: string;
91
+ systemPrompt?: string;
92
+ mode: "act" | "plan";
93
+ interactive: boolean;
94
+ maxIterations?: number;
95
+ enableTools: boolean;
96
+ rpcAddress: string;
97
+ hookCommand?: string;
98
+ port: number;
99
+ host: string;
100
+ baseUrl: string;
101
+ pubsubTopic?: string;
102
+ impersonateUser?: string;
103
+ useApplicationDefaultCredentials: boolean;
104
+ credentialsJson?: string;
105
+ };
106
+ export type GoogleChatConnectorState = {
107
+ userName: string;
108
+ pid: number;
109
+ rpcAddress: string;
110
+ port: number;
111
+ baseUrl: string;
112
+ startedAt: string;
113
+ };
114
+ export type ConnectLinearOptions = {
115
+ userName: string;
116
+ apiKey?: string;
117
+ clientId?: string;
118
+ clientSecret?: string;
119
+ accessToken?: string;
120
+ webhookSecret: string;
121
+ cwd: string;
122
+ model?: string;
123
+ provider?: string;
124
+ apiProviderKey?: string;
125
+ systemPrompt?: string;
126
+ mode: "act" | "plan";
127
+ interactive: boolean;
128
+ maxIterations?: number;
129
+ enableTools: boolean;
130
+ rpcAddress: string;
131
+ hookCommand?: string;
132
+ port: number;
133
+ host: string;
134
+ baseUrl: string;
135
+ };
136
+ export type LinearConnectorState = {
137
+ userName: string;
138
+ pid: number;
139
+ rpcAddress: string;
140
+ port: number;
141
+ baseUrl: string;
142
+ startedAt: string;
143
+ };
package/dist/db/index.js CHANGED
@@ -1,92 +1,80 @@
1
- var E=Object.defineProperty;var F=(S)=>S;function G(S,g){this[S]=F.bind(null,g)}var Z=(S,g)=>{for(var z in g)E(S,z,{get:g[z],enumerable:!0,configurable:!0,set:G.bind(g,z)})};import{mkdirSync as J}from"node:fs";import{createRequire as K}from"node:module";import{dirname as L}from"node:path";function Q(){return new Date().toISOString()}function T(S){return S?1:0}function U(S){return typeof S==="string"?S:""}function V(S){if(typeof S!=="string")return;let g=S.trim();return g.length>0?g:void 0}function W(S){return S===1||S===!0}function X(S){J(L(S),{recursive:!0});let g=K(import.meta.url);if(typeof globalThis.Bun<"u"){let{Database:j}=g("bun:sqlite"),x=new j(S,{create:!0});return{prepare:(I)=>{let w=x.query(I);return{run:(...O)=>w.run(...O),get:(...O)=>w.get(...O),all:(...O)=>w.all(...O)}},exec:(I)=>x.exec(I)}}try{let j=["node",":sqlite"].join(""),{DatabaseSync:x}=g(j),I=new x(S);return{prepare:(w)=>{let O=I.prepare(w);return{run:(...A)=>O.run(...A),get:(...A)=>O.get(...A)??null,all:(...A)=>O.all(...A)}},exec:(w)=>I.exec(w)}}catch{}let B=["better","-sqlite3"].join("");return new(g(B))(S)}function Y(S,g={}){if(S.exec("PRAGMA journal_mode = WAL;"),S.exec("PRAGMA busy_timeout = 5000;"),S.exec(`
2
- CREATE TABLE IF NOT EXISTS sessions (
3
- session_id TEXT PRIMARY KEY,
4
- source TEXT NOT NULL,
5
- pid INTEGER NOT NULL,
6
- started_at TEXT NOT NULL,
7
- ended_at TEXT,
8
- exit_code INTEGER,
9
- status TEXT NOT NULL,
10
- status_lock INTEGER NOT NULL DEFAULT 0,
11
- interactive INTEGER NOT NULL,
12
- provider TEXT NOT NULL,
13
- model TEXT NOT NULL,
14
- cwd TEXT NOT NULL,
15
- workspace_root TEXT NOT NULL,
16
- team_name TEXT,
17
- enable_tools INTEGER NOT NULL,
18
- enable_spawn INTEGER NOT NULL,
19
- enable_teams INTEGER NOT NULL,
20
- parent_session_id TEXT,
21
- parent_agent_id TEXT,
22
- agent_id TEXT,
23
- conversation_id TEXT,
24
- is_subagent INTEGER NOT NULL DEFAULT 0,
25
- prompt TEXT,
26
- metadata_json TEXT,
27
- transcript_path TEXT NOT NULL,
28
- hook_path TEXT NOT NULL,
29
- messages_path TEXT,
30
- updated_at TEXT NOT NULL
31
- );
32
- `),S.exec(`
33
- CREATE TABLE IF NOT EXISTS subagent_spawn_queue (
34
- id INTEGER PRIMARY KEY AUTOINCREMENT,
35
- root_session_id TEXT NOT NULL,
36
- parent_agent_id TEXT NOT NULL,
37
- task TEXT,
38
- system_prompt TEXT,
39
- created_at TEXT NOT NULL,
40
- consumed_at TEXT
41
- );
42
- `),S.exec(`
43
- CREATE TABLE IF NOT EXISTS schedules (
44
- schedule_id TEXT PRIMARY KEY,
45
- name TEXT NOT NULL,
46
- cron_pattern TEXT NOT NULL,
47
- prompt TEXT NOT NULL,
48
- provider TEXT NOT NULL,
49
- model TEXT NOT NULL,
50
- mode TEXT NOT NULL DEFAULT 'act',
51
- workspace_root TEXT,
52
- cwd TEXT,
53
- system_prompt TEXT,
54
- max_iterations INTEGER,
55
- timeout_seconds INTEGER,
56
- max_parallel INTEGER NOT NULL DEFAULT 1,
57
- enabled INTEGER NOT NULL DEFAULT 1,
58
- created_at TEXT NOT NULL,
59
- updated_at TEXT NOT NULL,
60
- last_run_at TEXT,
61
- next_run_at TEXT,
62
- claim_token TEXT,
63
- claim_started_at TEXT,
64
- claim_until_at TEXT,
65
- created_by TEXT,
66
- tags TEXT,
67
- metadata_json TEXT
68
- );
69
- `),S.exec(`
70
- CREATE TABLE IF NOT EXISTS schedule_executions (
71
- execution_id TEXT PRIMARY KEY,
72
- schedule_id TEXT NOT NULL,
73
- session_id TEXT,
74
- triggered_at TEXT NOT NULL,
75
- started_at TEXT,
76
- ended_at TEXT,
77
- status TEXT NOT NULL,
78
- exit_code INTEGER,
79
- error_message TEXT,
80
- iterations INTEGER,
81
- tokens_used INTEGER,
82
- cost_usd REAL,
83
- FOREIGN KEY (schedule_id) REFERENCES schedules(schedule_id) ON DELETE CASCADE,
84
- FOREIGN KEY (session_id) REFERENCES sessions(session_id) ON DELETE SET NULL
85
- );
86
- `),S.exec(`
87
- CREATE INDEX IF NOT EXISTS idx_schedule_executions_schedule
88
- ON schedule_executions(schedule_id, triggered_at DESC);
89
- `),S.exec(`
90
- CREATE INDEX IF NOT EXISTS idx_schedules_next_run
91
- ON schedules(enabled, next_run_at);
92
- `),!g.includeLegacyMigrations)return;let z=S.prepare("PRAGMA table_info(sessions);").all(),B=(x)=>z.some((I)=>I.name===x);if(!B("workspace_root"))S.exec("ALTER TABLE sessions ADD COLUMN workspace_root TEXT;"),S.exec("UPDATE sessions SET workspace_root = cwd WHERE workspace_root IS NULL OR workspace_root = '';");if(!B("parent_session_id"))S.exec("ALTER TABLE sessions ADD COLUMN parent_session_id TEXT;");if(!B("parent_agent_id"))S.exec("ALTER TABLE sessions ADD COLUMN parent_agent_id TEXT;");if(!B("agent_id"))S.exec("ALTER TABLE sessions ADD COLUMN agent_id TEXT;");if(!B("conversation_id"))S.exec("ALTER TABLE sessions ADD COLUMN conversation_id TEXT;");if(!B("is_subagent"))S.exec("ALTER TABLE sessions ADD COLUMN is_subagent INTEGER NOT NULL DEFAULT 0;");if(!B("messages_path"))S.exec("ALTER TABLE sessions ADD COLUMN messages_path TEXT;");if(!B("metadata_json"))S.exec("ALTER TABLE sessions ADD COLUMN metadata_json TEXT;");let D=S.prepare("PRAGMA table_info(schedules);").all(),j=(x)=>D.some((I)=>I.name===x);if(!j("claim_token"))S.exec("ALTER TABLE schedules ADD COLUMN claim_token TEXT;");if(!j("claim_started_at"))S.exec("ALTER TABLE schedules ADD COLUMN claim_started_at TEXT;");if(!j("claim_until_at"))S.exec("ALTER TABLE schedules ADD COLUMN claim_until_at TEXT;")}export{T as toBoolInt,Q as nowIso,X as loadSqliteDb,Y as ensureSessionSchema,U as asString,V as asOptionalString,W as asBool};
1
+ var J=Object.defineProperty;var K=(S)=>S;function Q(S,x){this[S]=K.bind(null,x)}var M=(S,x)=>{for(var B in x)J(S,B,{get:x[B],enumerable:!0,configurable:!0,set:Q.bind(x,B)})};import{mkdirSync as U}from"node:fs";import{createRequire as V}from"node:module";import{dirname as W}from"node:path";function X(){return new Date().toISOString()}function Z(S){return S?1:0}function $(S){return typeof S==="string"?S:""}function k(S){if(typeof S!=="string")return;let x=S.trim();return x.length>0?x:void 0}function y(S){return S===1||S===!0}function F(S){return{prepare:(x)=>S.query(x),exec:(x)=>S.exec(x)}}function H(S){return{prepare:(x)=>{let B=S.prepare(x);return{run:(...O)=>B.run(...O),get:(...O)=>B.get(...O)??null,all:(...O)=>B.all(...O)}},exec:(x)=>S.exec(x)}}function L(S){U(W(S),{recursive:!0});let x=V(import.meta.url);if(typeof globalThis.Bun<"u"){let{Database:O}=x("bun:sqlite");return F(new O(S,{create:!0}))}try{let O=process.emitWarning;process.emitWarning=(z,...I)=>{if((typeof z==="string"?z:z?.message??"").includes("SQLite"))return;return O.call(process,z,...I)};let{DatabaseSync:j}=x(["node",":sqlite"].join(""));return process.emitWarning=O,H(new j(S))}catch{}return new(x(["better","-sqlite3"].join("")))(S)}var Y=[`CREATE TABLE IF NOT EXISTS sessions (
2
+ session_id TEXT PRIMARY KEY,
3
+ source TEXT NOT NULL,
4
+ pid INTEGER NOT NULL,
5
+ started_at TEXT NOT NULL,
6
+ ended_at TEXT,
7
+ exit_code INTEGER,
8
+ status TEXT NOT NULL,
9
+ status_lock INTEGER NOT NULL DEFAULT 0,
10
+ interactive INTEGER NOT NULL,
11
+ provider TEXT NOT NULL,
12
+ model TEXT NOT NULL,
13
+ cwd TEXT NOT NULL,
14
+ workspace_root TEXT NOT NULL,
15
+ team_name TEXT,
16
+ enable_tools INTEGER NOT NULL,
17
+ enable_spawn INTEGER NOT NULL,
18
+ enable_teams INTEGER NOT NULL,
19
+ parent_session_id TEXT,
20
+ parent_agent_id TEXT,
21
+ agent_id TEXT,
22
+ conversation_id TEXT,
23
+ is_subagent INTEGER NOT NULL DEFAULT 0,
24
+ prompt TEXT,
25
+ metadata_json TEXT,
26
+ transcript_path TEXT NOT NULL,
27
+ hook_path TEXT NOT NULL,
28
+ messages_path TEXT,
29
+ updated_at TEXT NOT NULL
30
+ );`,`CREATE TABLE IF NOT EXISTS subagent_spawn_queue (
31
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
32
+ root_session_id TEXT NOT NULL,
33
+ parent_agent_id TEXT NOT NULL,
34
+ task TEXT,
35
+ system_prompt TEXT,
36
+ created_at TEXT NOT NULL,
37
+ consumed_at TEXT
38
+ );`,`CREATE TABLE IF NOT EXISTS schedules (
39
+ schedule_id TEXT PRIMARY KEY,
40
+ name TEXT NOT NULL,
41
+ cron_pattern TEXT NOT NULL,
42
+ prompt TEXT NOT NULL,
43
+ provider TEXT NOT NULL,
44
+ model TEXT NOT NULL,
45
+ mode TEXT NOT NULL DEFAULT 'act',
46
+ workspace_root TEXT,
47
+ cwd TEXT,
48
+ system_prompt TEXT,
49
+ max_iterations INTEGER,
50
+ timeout_seconds INTEGER,
51
+ max_parallel INTEGER NOT NULL DEFAULT 1,
52
+ enabled INTEGER NOT NULL DEFAULT 1,
53
+ created_at TEXT NOT NULL,
54
+ updated_at TEXT NOT NULL,
55
+ last_run_at TEXT,
56
+ next_run_at TEXT,
57
+ claim_token TEXT,
58
+ claim_started_at TEXT,
59
+ claim_until_at TEXT,
60
+ created_by TEXT,
61
+ tags TEXT,
62
+ metadata_json TEXT
63
+ );`,`CREATE TABLE IF NOT EXISTS schedule_executions (
64
+ execution_id TEXT PRIMARY KEY,
65
+ schedule_id TEXT NOT NULL,
66
+ session_id TEXT,
67
+ triggered_at TEXT NOT NULL,
68
+ started_at TEXT,
69
+ ended_at TEXT,
70
+ status TEXT NOT NULL,
71
+ exit_code INTEGER,
72
+ error_message TEXT,
73
+ iterations INTEGER,
74
+ tokens_used INTEGER,
75
+ cost_usd REAL,
76
+ FOREIGN KEY (schedule_id) REFERENCES schedules(schedule_id) ON DELETE CASCADE,
77
+ FOREIGN KEY (session_id) REFERENCES sessions(session_id) ON DELETE SET NULL
78
+ );`,`CREATE INDEX IF NOT EXISTS idx_schedule_executions_schedule
79
+ ON schedule_executions(schedule_id, triggered_at DESC);`,`CREATE INDEX IF NOT EXISTS idx_schedules_next_run
80
+ ON schedules(enabled, next_run_at);`],D=[{table:"sessions",column:"workspace_root",sql:"ALTER TABLE sessions ADD COLUMN workspace_root TEXT;"},{table:"sessions",column:"parent_session_id",sql:"ALTER TABLE sessions ADD COLUMN parent_session_id TEXT;"},{table:"sessions",column:"parent_agent_id",sql:"ALTER TABLE sessions ADD COLUMN parent_agent_id TEXT;"},{table:"sessions",column:"agent_id",sql:"ALTER TABLE sessions ADD COLUMN agent_id TEXT;"},{table:"sessions",column:"conversation_id",sql:"ALTER TABLE sessions ADD COLUMN conversation_id TEXT;"},{table:"sessions",column:"is_subagent",sql:"ALTER TABLE sessions ADD COLUMN is_subagent INTEGER NOT NULL DEFAULT 0;"},{table:"sessions",column:"messages_path",sql:"ALTER TABLE sessions ADD COLUMN messages_path TEXT;"},{table:"sessions",column:"metadata_json",sql:"ALTER TABLE sessions ADD COLUMN metadata_json TEXT;"},{table:"schedules",column:"claim_token",sql:"ALTER TABLE schedules ADD COLUMN claim_token TEXT;"},{table:"schedules",column:"claim_started_at",sql:"ALTER TABLE schedules ADD COLUMN claim_started_at TEXT;"},{table:"schedules",column:"claim_until_at",sql:"ALTER TABLE schedules ADD COLUMN claim_until_at TEXT;"}];function G(S,x){return new Set(S.prepare(`PRAGMA table_info(${x});`).all().map((B)=>B.name))}function R(S,x={}){S.exec("PRAGMA journal_mode = WAL;"),S.exec("PRAGMA busy_timeout = 5000;");for(let j of Y)S.exec(j);if(!x.includeLegacyMigrations)return;let B=new Map,O=(j)=>{let z=B.get(j);if(!z)z=G(S,j),B.set(j,z);return z};for(let j of D)if(!O(j.table).has(j.column)){if(S.exec(j.sql),j.column==="workspace_root")S.exec("UPDATE sessions SET workspace_root = cwd WHERE workspace_root IS NULL OR workspace_root = '';")}}export{Z as toBoolInt,X as nowIso,L as loadSqliteDb,R as ensureSessionSchema,$ as asString,k as asOptionalString,y as asBool};
@@ -1,5 +1,6 @@
1
1
  export type { OAuthProviderId } from "./auth/constants";
2
2
  export { AUTH_ERROR_PATTERNS, isLikelyAuthError, isOAuthProviderId, OAUTH_PROVIDER_IDS, } from "./auth/constants";
3
+ export type * from "./connectors/adapters";
3
4
  export type { ConnectorHookEvent, ConnectorHookEventName, } from "./connectors/events";
4
5
  export { ConnectorHookEventNameSchema, ConnectorHookEventSchema, } from "./connectors/events";
5
6
  export { MODELS_DEV_PROVIDER_KEY_ENTRIES, MODELS_DEV_PROVIDER_KEY_MAP, resolveProviderModelCatalogKeys, } from "./llms/model-id";
@@ -10,6 +11,7 @@ export { parseJsonStream, safeJsonStringify } from "./parse/json";
10
11
  export { formatHumanReadableDate } from "./parse/time";
11
12
  export { validateWithZod, zodToJsonSchema } from "./parse/zod";
12
13
  export { formatFileContentBlock, formatUserInputBlock, normalizeUserInput, xmlTagsRemoval, } from "./prompt/format";
14
+ export { CLINE_DEFAULT_RPC_ADDRESS, CLINE_DEFAULT_RPC_PORT } from "./rpc";
13
15
  export type { RpcAddProviderActionRequest, RpcAgentMode, RpcChatAttachmentFile, RpcChatAttachments, RpcChatMessage, RpcChatRunTurnRequest, RpcChatRuntimeConfigBase, RpcChatRuntimeLoggerConfig, RpcChatStartSessionArtifacts, RpcChatStartSessionRequest, RpcChatStartSessionResponse, RpcChatToolCallResult, RpcChatTurnResult, RpcClineAccountActionRequest, RpcClineAccountBalance, RpcClineAccountOrganization, RpcClineAccountOrganizationBalance, RpcClineAccountOrganizationUsageTransaction, RpcClineAccountPaymentTransaction, RpcClineAccountUsageTransaction, RpcClineAccountUser, RpcGetProviderModelsActionRequest, RpcListProvidersActionRequest, RpcOAuthProviderId, RpcProviderActionRequest, RpcProviderCapability, RpcProviderCatalogResponse, RpcProviderListItem, RpcProviderModel, RpcProviderModelsResponse, RpcProviderOAuthLoginResponse, RpcProviderSettingsActionRequest, RpcSaveProviderSettingsActionRequest, RpcSessionStorageOptions, } from "./rpc/runtime";
14
16
  export type { TeamProgressCounts, TeamProgressLifecycleEvent, TeamProgressMemberRole, TeamProgressMemberStatus, TeamProgressOutcomeFragmentStatus, TeamProgressOutcomeStatus, TeamProgressProjectionEvent, TeamProgressRunStatus, TeamProgressSummary, TeamProgressTaskStatus, } from "./rpc/team-progress";
15
17
  export { RPC_TEAM_LIFECYCLE_EVENT_TYPE, RPC_TEAM_PROGRESS_EVENT_TYPE, } from "./rpc/team-progress";