@useorgx/openclaw-plugin 0.2.1 → 0.3.1
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 +64 -2
- package/dashboard/dist/assets/index-BjqNjHpY.css +1 -0
- package/dashboard/dist/assets/index-DCLkU4AM.js +57 -0
- package/dashboard/dist/assets/orgx-logo-QSE5QWy4.png +0 -0
- package/dashboard/dist/brand/anthropic-mark.svg +10 -0
- package/dashboard/dist/brand/control-tower.png +0 -0
- package/dashboard/dist/brand/design-codex.png +0 -0
- package/dashboard/dist/brand/engineering-autopilot.png +0 -0
- package/dashboard/dist/brand/launch-captain.png +0 -0
- package/dashboard/dist/brand/openai-mark.svg +10 -0
- package/dashboard/dist/brand/openclaw-mark.svg +11 -0
- package/dashboard/dist/brand/orgx-logo.png +0 -0
- package/dashboard/dist/brand/pipeline-intelligence.png +0 -0
- package/dashboard/dist/brand/product-orchestrator.png +0 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/adapters/outbox.d.ts +8 -0
- package/dist/adapters/outbox.d.ts.map +1 -0
- package/dist/adapters/outbox.js +6 -0
- package/dist/adapters/outbox.js.map +1 -0
- package/dist/agent-context-store.d.ts +24 -0
- package/dist/agent-context-store.d.ts.map +1 -0
- package/dist/agent-context-store.js +110 -0
- package/dist/agent-context-store.js.map +1 -0
- package/dist/agent-run-store.d.ts +31 -0
- package/dist/agent-run-store.d.ts.map +1 -0
- package/dist/agent-run-store.js +158 -0
- package/dist/agent-run-store.js.map +1 -0
- package/dist/api.d.ts +4 -131
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -285
- package/dist/api.js.map +1 -1
- package/dist/auth-store.d.ts +20 -0
- package/dist/auth-store.d.ts.map +1 -0
- package/dist/auth-store.js +154 -0
- package/dist/auth-store.js.map +1 -0
- package/dist/byok-store.d.ts +11 -0
- package/dist/byok-store.d.ts.map +1 -0
- package/dist/byok-store.js +94 -0
- package/dist/byok-store.js.map +1 -0
- package/dist/contracts/client.d.ts +154 -0
- package/dist/contracts/client.d.ts.map +1 -0
- package/dist/contracts/client.js +422 -0
- package/dist/contracts/client.js.map +1 -0
- package/dist/contracts/types.d.ts +430 -0
- package/dist/contracts/types.d.ts.map +1 -0
- package/dist/contracts/types.js +8 -0
- package/dist/contracts/types.js.map +1 -0
- package/dist/dashboard-api.d.ts +2 -7
- package/dist/dashboard-api.d.ts.map +1 -1
- package/dist/dashboard-api.js +2 -4
- package/dist/dashboard-api.js.map +1 -1
- package/dist/http-handler.d.ts +37 -3
- package/dist/http-handler.d.ts.map +1 -1
- package/dist/http-handler.js +3880 -80
- package/dist/http-handler.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1615 -41
- package/dist/index.js.map +1 -1
- package/dist/local-openclaw.d.ts +87 -0
- package/dist/local-openclaw.d.ts.map +1 -0
- package/dist/local-openclaw.js +816 -0
- package/dist/local-openclaw.js.map +1 -0
- package/dist/openclaw.plugin.json +76 -0
- package/dist/outbox.d.ts +27 -0
- package/dist/outbox.d.ts.map +1 -0
- package/dist/outbox.js +174 -0
- package/dist/outbox.js.map +1 -0
- package/dist/snapshot-store.d.ts +10 -0
- package/dist/snapshot-store.d.ts.map +1 -0
- package/dist/snapshot-store.js +64 -0
- package/dist/snapshot-store.js.map +1 -0
- package/dist/types.d.ts +5 -320
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -4
- package/dist/types.js.map +1 -1
- package/openclaw.plugin.json +4 -3
- package/package.json +14 -2
- package/skills/orgx/SKILL.md +180 -0
- package/dashboard/dist/assets/index-C_w24A8p.css +0 -1
- package/dashboard/dist/assets/index-DfkN5JSS.js +0 -48
package/dist/api.js
CHANGED
|
@@ -1,289 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Public API client entrypoint.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Uses native fetch — no external dependencies.
|
|
4
|
+
* Kept stable because consumers import `@useorgx/openclaw-plugin/api`.
|
|
5
|
+
* The implementation lives under `src/contracts/client.ts`.
|
|
8
6
|
*/
|
|
9
|
-
|
|
10
|
-
const USER_AGENT = "OrgX-Clawdbot-Plugin/1.0";
|
|
11
|
-
export class OrgXClient {
|
|
12
|
-
apiKey;
|
|
13
|
-
baseUrl;
|
|
14
|
-
userId;
|
|
15
|
-
constructor(apiKey, baseUrl, userId) {
|
|
16
|
-
this.apiKey = apiKey;
|
|
17
|
-
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
18
|
-
this.userId = userId || "";
|
|
19
|
-
}
|
|
20
|
-
// ===========================================================================
|
|
21
|
-
// HTTP helpers
|
|
22
|
-
// ===========================================================================
|
|
23
|
-
async request(method, path, body) {
|
|
24
|
-
const url = `${this.baseUrl}${path}`;
|
|
25
|
-
const controller = new AbortController();
|
|
26
|
-
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
27
|
-
try {
|
|
28
|
-
const headers = {
|
|
29
|
-
"Content-Type": "application/json",
|
|
30
|
-
"User-Agent": USER_AGENT,
|
|
31
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
32
|
-
};
|
|
33
|
-
if (this.userId) {
|
|
34
|
-
headers["X-Orgx-User-Id"] = this.userId;
|
|
35
|
-
}
|
|
36
|
-
const response = await fetch(url, {
|
|
37
|
-
method,
|
|
38
|
-
headers,
|
|
39
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
40
|
-
signal: controller.signal,
|
|
41
|
-
});
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
const text = await response.text().catch(() => "");
|
|
44
|
-
throw new Error(`OrgX API ${method} ${path}: ${response.status} ${response.statusText}${text ? ` — ${text.slice(0, 200)}` : ""}`);
|
|
45
|
-
}
|
|
46
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
47
|
-
if (contentType.includes("application/json")) {
|
|
48
|
-
return (await response.json());
|
|
49
|
-
}
|
|
50
|
-
return (await response.text());
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
54
|
-
throw new Error(`OrgX API ${method} ${path} timed out after ${REQUEST_TIMEOUT_MS}ms`);
|
|
55
|
-
}
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
clearTimeout(timeout);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
get(path) {
|
|
63
|
-
return this.request("GET", path);
|
|
64
|
-
}
|
|
65
|
-
post(path, body) {
|
|
66
|
-
return this.request("POST", path, body);
|
|
67
|
-
}
|
|
68
|
-
patch(path, body) {
|
|
69
|
-
return this.request("PATCH", path, body);
|
|
70
|
-
}
|
|
71
|
-
buildQuery(params) {
|
|
72
|
-
const entries = Object.entries(params).filter(([, value]) => value !== undefined && value !== null);
|
|
73
|
-
if (entries.length === 0)
|
|
74
|
-
return "";
|
|
75
|
-
const search = new URLSearchParams();
|
|
76
|
-
for (const [key, value] of entries) {
|
|
77
|
-
search.set(key, String(value));
|
|
78
|
-
}
|
|
79
|
-
return `?${search.toString()}`;
|
|
80
|
-
}
|
|
81
|
-
// ===========================================================================
|
|
82
|
-
// Org Snapshot
|
|
83
|
-
// ===========================================================================
|
|
84
|
-
async getOrgSnapshot() {
|
|
85
|
-
// Use the sync endpoint with POST (empty body = pull only)
|
|
86
|
-
const resp = await this.post("/api/client/sync", {});
|
|
87
|
-
const data = resp.data;
|
|
88
|
-
// Transform SyncResponse to OrgSnapshot format
|
|
89
|
-
return {
|
|
90
|
-
initiatives: data.initiatives.map(i => ({
|
|
91
|
-
id: i.id,
|
|
92
|
-
title: i.title,
|
|
93
|
-
status: i.status,
|
|
94
|
-
})),
|
|
95
|
-
agents: [], // Not returned by sync endpoint
|
|
96
|
-
activeTasks: data.activeTasks.map(t => ({
|
|
97
|
-
id: t.id,
|
|
98
|
-
title: t.title,
|
|
99
|
-
status: t.status,
|
|
100
|
-
domain: t.domain,
|
|
101
|
-
modelTier: t.modelTier,
|
|
102
|
-
})),
|
|
103
|
-
pendingDecisions: data.pendingDecisions.map(d => ({
|
|
104
|
-
id: d.id,
|
|
105
|
-
title: d.title,
|
|
106
|
-
urgency: d.urgency,
|
|
107
|
-
})),
|
|
108
|
-
syncedAt: data.syncedAt,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
// ===========================================================================
|
|
112
|
-
// Memory Sync
|
|
113
|
-
// ===========================================================================
|
|
114
|
-
async syncMemory(payload) {
|
|
115
|
-
const response = await this.post("/api/client/sync", payload);
|
|
116
|
-
if (response &&
|
|
117
|
-
typeof response === "object" &&
|
|
118
|
-
"data" in response &&
|
|
119
|
-
response.data) {
|
|
120
|
-
return response.data;
|
|
121
|
-
}
|
|
122
|
-
return response;
|
|
123
|
-
}
|
|
124
|
-
async delegationPreflight(payload) {
|
|
125
|
-
return this.post("/api/client/delegation/preflight", payload);
|
|
126
|
-
}
|
|
127
|
-
// ===========================================================================
|
|
128
|
-
// Spawn Guard (Quality Gate + Model Routing)
|
|
129
|
-
// ===========================================================================
|
|
130
|
-
async checkSpawnGuard(domain, taskId) {
|
|
131
|
-
return this.post("/api/client/spawn", {
|
|
132
|
-
domain,
|
|
133
|
-
taskId,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// ===========================================================================
|
|
137
|
-
// Quality Scores
|
|
138
|
-
// ===========================================================================
|
|
139
|
-
async recordQuality(score) {
|
|
140
|
-
return this.post("/api/client/quality", score);
|
|
141
|
-
}
|
|
142
|
-
// ===========================================================================
|
|
143
|
-
// Entity CRUD
|
|
144
|
-
// Uses /api/entities with type in body (NOT per-type REST paths)
|
|
145
|
-
// ===========================================================================
|
|
146
|
-
/**
|
|
147
|
-
* Create an OrgX entity.
|
|
148
|
-
* POST /api/entities { type, title, summary, status, initiative_id, ... }
|
|
149
|
-
*/
|
|
150
|
-
async createEntity(type, data) {
|
|
151
|
-
const resp = await this.post("/api/entities", {
|
|
152
|
-
type,
|
|
153
|
-
...data,
|
|
154
|
-
});
|
|
155
|
-
return resp.data ?? resp;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Update an OrgX entity.
|
|
159
|
-
* PATCH /api/entities { type, id, ...updates }
|
|
160
|
-
*/
|
|
161
|
-
async updateEntity(type, id, updates) {
|
|
162
|
-
const resp = await this.patch("/api/entities", {
|
|
163
|
-
type,
|
|
164
|
-
id,
|
|
165
|
-
...updates,
|
|
166
|
-
});
|
|
167
|
-
return resp.data ?? resp;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* List OrgX entities.
|
|
171
|
-
* GET /api/entities?type={type}&status={status}&limit={n}
|
|
172
|
-
*/
|
|
173
|
-
async listEntities(type, filters) {
|
|
174
|
-
const params = new URLSearchParams({ type });
|
|
175
|
-
if (filters?.status)
|
|
176
|
-
params.set("status", filters.status);
|
|
177
|
-
if (filters?.limit)
|
|
178
|
-
params.set("limit", String(filters.limit));
|
|
179
|
-
return this.get(`/api/entities?${params.toString()}`);
|
|
180
|
-
}
|
|
181
|
-
// ===========================================================================
|
|
182
|
-
// Live Sessions + Activity + Handoffs
|
|
183
|
-
// ===========================================================================
|
|
184
|
-
async getLiveSessions(params) {
|
|
185
|
-
const query = this.buildQuery({
|
|
186
|
-
limit: params?.limit,
|
|
187
|
-
initiative: params?.initiative ?? null,
|
|
188
|
-
});
|
|
189
|
-
return this.get(`/api/client/live/sessions${query}`);
|
|
190
|
-
}
|
|
191
|
-
async getLiveActivity(params) {
|
|
192
|
-
const query = this.buildQuery({
|
|
193
|
-
limit: params?.limit,
|
|
194
|
-
run: params?.run ?? null,
|
|
195
|
-
since: params?.since ?? null,
|
|
196
|
-
});
|
|
197
|
-
return this.get(`/api/client/live/activity${query}`);
|
|
198
|
-
}
|
|
199
|
-
async getLiveAgents(params) {
|
|
200
|
-
const query = this.buildQuery({
|
|
201
|
-
initiative: params?.initiative ?? null,
|
|
202
|
-
include_idle: params?.includeIdle ?? undefined,
|
|
203
|
-
});
|
|
204
|
-
return this.get(`/api/client/live/agents${query}`);
|
|
205
|
-
}
|
|
206
|
-
async getLiveInitiatives(params) {
|
|
207
|
-
const query = this.buildQuery({
|
|
208
|
-
id: params?.id ?? null,
|
|
209
|
-
limit: params?.limit ?? null,
|
|
210
|
-
});
|
|
211
|
-
return this.get(`/api/client/live/initiatives${query}`);
|
|
212
|
-
}
|
|
213
|
-
async getHandoffs() {
|
|
214
|
-
return this.get(`/api/client/handoffs`);
|
|
215
|
-
}
|
|
216
|
-
async runAction(runId, action, payload) {
|
|
217
|
-
const encodedRunId = encodeURIComponent(runId);
|
|
218
|
-
const encodedAction = encodeURIComponent(action);
|
|
219
|
-
return this.post(`/api/client/runs/${encodedRunId}/actions/${encodedAction}`, payload ?? {});
|
|
220
|
-
}
|
|
221
|
-
async listRunCheckpoints(runId) {
|
|
222
|
-
const encodedRunId = encodeURIComponent(runId);
|
|
223
|
-
return this.get(`/api/client/runs/${encodedRunId}/checkpoints`);
|
|
224
|
-
}
|
|
225
|
-
async createRunCheckpoint(runId, payload) {
|
|
226
|
-
const encodedRunId = encodeURIComponent(runId);
|
|
227
|
-
return this.post(`/api/client/runs/${encodedRunId}/checkpoints`, payload ?? {});
|
|
228
|
-
}
|
|
229
|
-
async restoreRunCheckpoint(runId, request) {
|
|
230
|
-
const encodedRunId = encodeURIComponent(runId);
|
|
231
|
-
const encodedCheckpointId = encodeURIComponent(request.checkpointId);
|
|
232
|
-
return this.post(`/api/client/runs/${encodedRunId}/checkpoints/${encodedCheckpointId}/restore`, { reason: request.reason });
|
|
233
|
-
}
|
|
234
|
-
async getLiveDecisions(params) {
|
|
235
|
-
const response = await this.listEntities("decision", {
|
|
236
|
-
status: params?.status,
|
|
237
|
-
limit: params?.limit,
|
|
238
|
-
});
|
|
239
|
-
const decisions = Array.isArray(response.data) ? response.data : [];
|
|
240
|
-
return {
|
|
241
|
-
decisions,
|
|
242
|
-
total: response.pagination?.total ?? decisions.length,
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
async decideDecision(id, action, note) {
|
|
246
|
-
const resolvedStatus = action === "approve" ? "approved" : "rejected";
|
|
247
|
-
const resolvedAt = new Date().toISOString();
|
|
248
|
-
try {
|
|
249
|
-
return await this.updateEntity("decision", id, {
|
|
250
|
-
status: resolvedStatus,
|
|
251
|
-
resolution: resolvedStatus,
|
|
252
|
-
resolved_at: resolvedAt,
|
|
253
|
-
decided_at: resolvedAt,
|
|
254
|
-
decided_by: this.userId || undefined,
|
|
255
|
-
note: note ?? undefined,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
catch {
|
|
259
|
-
// Fallback for backends that only support generic "resolved" status.
|
|
260
|
-
return this.updateEntity("decision", id, {
|
|
261
|
-
status: "resolved",
|
|
262
|
-
decision_status: resolvedStatus,
|
|
263
|
-
resolution: resolvedStatus,
|
|
264
|
-
resolved_at: resolvedAt,
|
|
265
|
-
decided_at: resolvedAt,
|
|
266
|
-
note: note ?? undefined,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
async bulkDecideDecisions(ids, action, note) {
|
|
271
|
-
const uniqueIds = Array.from(new Set(ids.filter(Boolean)));
|
|
272
|
-
const results = [];
|
|
273
|
-
for (const id of uniqueIds) {
|
|
274
|
-
try {
|
|
275
|
-
const entity = await this.decideDecision(id, action, note);
|
|
276
|
-
results.push({ id, ok: true, entity });
|
|
277
|
-
}
|
|
278
|
-
catch (err) {
|
|
279
|
-
results.push({
|
|
280
|
-
id,
|
|
281
|
-
ok: false,
|
|
282
|
-
error: err instanceof Error ? err.message : String(err),
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return results;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
7
|
+
export * from "./contracts/client.js";
|
|
289
8
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface PersistedAuthRecord {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
source: 'manual' | 'browser_pairing';
|
|
4
|
+
installationId: string;
|
|
5
|
+
userId?: string | null;
|
|
6
|
+
workspaceName?: string | null;
|
|
7
|
+
keyPrefix?: string | null;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function getAuthFilePath(): string;
|
|
12
|
+
export declare function readPersistedAuth(): PersistedAuthRecord | null;
|
|
13
|
+
export declare function writePersistedAuth(input: Omit<PersistedAuthRecord, 'createdAt' | 'updatedAt'>): PersistedAuthRecord;
|
|
14
|
+
export declare function clearPersistedAuth(): void;
|
|
15
|
+
export declare function getOrCreateInstallationId(): string;
|
|
16
|
+
export declare function loadAuthStore(): PersistedAuthRecord | null;
|
|
17
|
+
export declare function saveAuthStore(input: Omit<PersistedAuthRecord, 'createdAt' | 'updatedAt'>): PersistedAuthRecord;
|
|
18
|
+
export declare function resolveInstallationId(): string;
|
|
19
|
+
export declare function clearPersistedApiKey(): void;
|
|
20
|
+
//# sourceMappingURL=auth-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../src/auth-store.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,QAAQ,GAAG,iBAAiB,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AA6BD,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,iBAAiB,IAAI,mBAAmB,GAAG,IAAI,CAgC9D;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,WAAW,CAAC,GAC1D,mBAAmB,CA6BrB;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAMzC;AAcD,wBAAgB,yBAAyB,IAAI,MAAM,CAwBlD;AAGD,wBAAgB,aAAa,IAAI,mBAAmB,GAAG,IAAI,CAE1D;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,WAAW,CAAC,GAC1D,mBAAmB,CAErB;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync, chmodSync, existsSync, rmSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
const AUTH_DIR = join(homedir(), '.config', 'useorgx', 'openclaw-plugin');
|
|
6
|
+
const AUTH_FILE = join(AUTH_DIR, 'auth.json');
|
|
7
|
+
const INSTALLATION_FILE = join(AUTH_DIR, 'installation.json');
|
|
8
|
+
function isUserScopedApiKey(apiKey) {
|
|
9
|
+
return apiKey.trim().toLowerCase().startsWith('oxk_');
|
|
10
|
+
}
|
|
11
|
+
function ensureAuthDir() {
|
|
12
|
+
mkdirSync(AUTH_DIR, { recursive: true, mode: 0o700 });
|
|
13
|
+
try {
|
|
14
|
+
chmodSync(AUTH_DIR, 0o700);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// best effort
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function parseJson(value) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(value);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function getAuthFilePath() {
|
|
29
|
+
return AUTH_FILE;
|
|
30
|
+
}
|
|
31
|
+
export function readPersistedAuth() {
|
|
32
|
+
try {
|
|
33
|
+
if (!existsSync(AUTH_FILE))
|
|
34
|
+
return null;
|
|
35
|
+
const parsed = parseJson(readFileSync(AUTH_FILE, 'utf8'));
|
|
36
|
+
if (!parsed || typeof parsed.apiKey !== 'string' || parsed.apiKey.trim().length === 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (isUserScopedApiKey(parsed.apiKey) &&
|
|
40
|
+
typeof parsed.userId === 'string' &&
|
|
41
|
+
parsed.userId.trim().length > 0) {
|
|
42
|
+
const sanitized = {
|
|
43
|
+
...parsed,
|
|
44
|
+
userId: null,
|
|
45
|
+
updatedAt: new Date().toISOString(),
|
|
46
|
+
};
|
|
47
|
+
writeFileSync(AUTH_FILE, JSON.stringify(sanitized, null, 2), {
|
|
48
|
+
mode: 0o600,
|
|
49
|
+
encoding: 'utf8',
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
chmodSync(AUTH_FILE, 0o600);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// best effort
|
|
56
|
+
}
|
|
57
|
+
return sanitized;
|
|
58
|
+
}
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function writePersistedAuth(input) {
|
|
66
|
+
ensureAuthDir();
|
|
67
|
+
const now = new Date().toISOString();
|
|
68
|
+
const existing = readPersistedAuth();
|
|
69
|
+
const normalizedUserId = isUserScopedApiKey(input.apiKey)
|
|
70
|
+
? null
|
|
71
|
+
: input.userId ?? null;
|
|
72
|
+
const next = {
|
|
73
|
+
apiKey: input.apiKey,
|
|
74
|
+
source: input.source,
|
|
75
|
+
installationId: input.installationId,
|
|
76
|
+
userId: normalizedUserId,
|
|
77
|
+
workspaceName: input.workspaceName ?? null,
|
|
78
|
+
keyPrefix: input.keyPrefix ?? null,
|
|
79
|
+
createdAt: existing?.createdAt ?? now,
|
|
80
|
+
updatedAt: now,
|
|
81
|
+
};
|
|
82
|
+
writeFileSync(AUTH_FILE, JSON.stringify(next, null, 2), {
|
|
83
|
+
mode: 0o600,
|
|
84
|
+
encoding: 'utf8',
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
chmodSync(AUTH_FILE, 0o600);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// best effort
|
|
91
|
+
}
|
|
92
|
+
return next;
|
|
93
|
+
}
|
|
94
|
+
export function clearPersistedAuth() {
|
|
95
|
+
try {
|
|
96
|
+
rmSync(AUTH_FILE, { force: true });
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// best effort
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function readInstallationRecord() {
|
|
103
|
+
try {
|
|
104
|
+
if (!existsSync(INSTALLATION_FILE))
|
|
105
|
+
return null;
|
|
106
|
+
const parsed = parseJson(readFileSync(INSTALLATION_FILE, 'utf8'));
|
|
107
|
+
if (!parsed || typeof parsed.installationId !== 'string')
|
|
108
|
+
return null;
|
|
109
|
+
if (parsed.installationId.trim().length < 6)
|
|
110
|
+
return null;
|
|
111
|
+
return parsed;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function getOrCreateInstallationId() {
|
|
118
|
+
const existing = readInstallationRecord();
|
|
119
|
+
if (existing?.installationId)
|
|
120
|
+
return existing.installationId;
|
|
121
|
+
ensureAuthDir();
|
|
122
|
+
const now = new Date().toISOString();
|
|
123
|
+
const installationId = `ocw_${randomUUID()}`;
|
|
124
|
+
const record = {
|
|
125
|
+
installationId,
|
|
126
|
+
createdAt: now,
|
|
127
|
+
updatedAt: now,
|
|
128
|
+
};
|
|
129
|
+
writeFileSync(INSTALLATION_FILE, JSON.stringify(record, null, 2), {
|
|
130
|
+
mode: 0o600,
|
|
131
|
+
encoding: 'utf8',
|
|
132
|
+
});
|
|
133
|
+
try {
|
|
134
|
+
chmodSync(INSTALLATION_FILE, 0o600);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// best effort
|
|
138
|
+
}
|
|
139
|
+
return installationId;
|
|
140
|
+
}
|
|
141
|
+
// Backward-compatible aliases used by the runtime.
|
|
142
|
+
export function loadAuthStore() {
|
|
143
|
+
return readPersistedAuth();
|
|
144
|
+
}
|
|
145
|
+
export function saveAuthStore(input) {
|
|
146
|
+
return writePersistedAuth(input);
|
|
147
|
+
}
|
|
148
|
+
export function resolveInstallationId() {
|
|
149
|
+
return getOrCreateInstallationId();
|
|
150
|
+
}
|
|
151
|
+
export function clearPersistedApiKey() {
|
|
152
|
+
clearPersistedAuth();
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=auth-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../src/auth-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;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E,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,cAAc,GAAG,OAAO,UAAU,EAAE,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAuB;QACjC,cAAc;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC;IAEF,aAAa,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QAChE,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IACH,IAAI,CAAC;QACH,SAAS,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,aAAa;IAC3B,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAA2D;IAE3D,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,yBAAyB,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,kBAAkB,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ByokKeysRecord {
|
|
2
|
+
openaiApiKey: string | null;
|
|
3
|
+
anthropicApiKey: string | null;
|
|
4
|
+
openrouterApiKey: string | null;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function readByokKeys(): ByokKeysRecord | null;
|
|
9
|
+
export declare function writeByokKeys(input: Partial<ByokKeysRecord>): ByokKeysRecord;
|
|
10
|
+
export declare function clearByokKeys(): void;
|
|
11
|
+
//# sourceMappingURL=byok-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byok-store.d.ts","sourceRoot":"","sources":["../src/byok-store.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0BD,wBAAgB,YAAY,IAAI,cAAc,GAAG,IAAI,CAuBpD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CA+B5E;AAED,wBAAgB,aAAa,IAAI,IAAI,CAMpC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
const CONFIG_DIR = join(homedir(), ".config", "useorgx", "openclaw-plugin");
|
|
5
|
+
const BYOK_FILE = join(CONFIG_DIR, "byok.json");
|
|
6
|
+
function ensureConfigDir() {
|
|
7
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
8
|
+
try {
|
|
9
|
+
chmodSync(CONFIG_DIR, 0o700);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// best effort
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function parseJson(value) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(value);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function normalizeKey(value) {
|
|
24
|
+
if (typeof value !== "string")
|
|
25
|
+
return null;
|
|
26
|
+
const trimmed = value.trim();
|
|
27
|
+
if (!trimmed)
|
|
28
|
+
return null;
|
|
29
|
+
return trimmed;
|
|
30
|
+
}
|
|
31
|
+
export function readByokKeys() {
|
|
32
|
+
try {
|
|
33
|
+
if (!existsSync(BYOK_FILE))
|
|
34
|
+
return null;
|
|
35
|
+
const parsed = parseJson(readFileSync(BYOK_FILE, "utf8"));
|
|
36
|
+
if (!parsed || typeof parsed !== "object")
|
|
37
|
+
return null;
|
|
38
|
+
const createdAt = typeof parsed.createdAt === "string" && parsed.createdAt.trim().length > 0
|
|
39
|
+
? parsed.createdAt
|
|
40
|
+
: new Date().toISOString();
|
|
41
|
+
const updatedAt = typeof parsed.updatedAt === "string" && parsed.updatedAt.trim().length > 0
|
|
42
|
+
? parsed.updatedAt
|
|
43
|
+
: createdAt;
|
|
44
|
+
return {
|
|
45
|
+
openaiApiKey: normalizeKey(parsed.openaiApiKey) ?? null,
|
|
46
|
+
anthropicApiKey: normalizeKey(parsed.anthropicApiKey) ?? null,
|
|
47
|
+
openrouterApiKey: normalizeKey(parsed.openrouterApiKey) ?? null,
|
|
48
|
+
createdAt,
|
|
49
|
+
updatedAt,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function writeByokKeys(input) {
|
|
57
|
+
ensureConfigDir();
|
|
58
|
+
const now = new Date().toISOString();
|
|
59
|
+
const existing = readByokKeys();
|
|
60
|
+
const has = (key) => Object.prototype.hasOwnProperty.call(input, key);
|
|
61
|
+
const next = {
|
|
62
|
+
openaiApiKey: has("openaiApiKey")
|
|
63
|
+
? normalizeKey(input.openaiApiKey)
|
|
64
|
+
: existing?.openaiApiKey ?? null,
|
|
65
|
+
anthropicApiKey: has("anthropicApiKey")
|
|
66
|
+
? normalizeKey(input.anthropicApiKey)
|
|
67
|
+
: existing?.anthropicApiKey ?? null,
|
|
68
|
+
openrouterApiKey: has("openrouterApiKey")
|
|
69
|
+
? normalizeKey(input.openrouterApiKey)
|
|
70
|
+
: existing?.openrouterApiKey ?? null,
|
|
71
|
+
createdAt: existing?.createdAt ?? now,
|
|
72
|
+
updatedAt: now,
|
|
73
|
+
};
|
|
74
|
+
writeFileSync(BYOK_FILE, JSON.stringify(next, null, 2), {
|
|
75
|
+
mode: 0o600,
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
chmodSync(BYOK_FILE, 0o600);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// best effort
|
|
83
|
+
}
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
export function clearByokKeys() {
|
|
87
|
+
try {
|
|
88
|
+
rmSync(BYOK_FILE, { force: true });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// best effort
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=byok-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byok-store.js","sourceRoot":"","sources":["../src/byok-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAUhD,SAAS,eAAe;IACtB,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACxD,IAAI,CAAC;QACH,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;AACH,CAAC;AAED,SAAS,S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