poe-code 3.0.71-beta.1 → 3.0.71
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 +1 -1
- package/dist/cli/commands/configure.js +2 -2
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/commands/ensure-isolated-config.js +1 -1
- package/dist/cli/commands/ensure-isolated-config.js.map +1 -1
- package/dist/cli/commands/generate.js +2 -5
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/login.d.ts +0 -1
- package/dist/cli/commands/login.js +36 -57
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/logout.d.ts +0 -1
- package/dist/cli/commands/logout.js +29 -32
- package/dist/cli/commands/logout.js.map +1 -1
- package/dist/cli/commands/mcp.js +12 -4
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/models.js +5 -1
- package/dist/cli/commands/models.js.map +1 -1
- package/dist/cli/commands/research.js +2 -2
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/spawn.js +2 -2
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/commands/test.js +1 -1
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/unconfigure.js +2 -2
- package/dist/cli/commands/unconfigure.js.map +1 -1
- package/dist/cli/commands/wrap.js +0 -1
- package/dist/cli/commands/wrap.js.map +1 -1
- package/dist/cli/constants.d.ts +3 -3
- package/dist/cli/constants.js +2 -0
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/container.d.ts +0 -2
- package/dist/cli/container.js +11 -29
- package/dist/cli/container.js.map +1 -1
- package/dist/cli/environment.d.ts +2 -2
- package/dist/cli/environment.js +4 -4
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/isolated-env-runner.d.ts +0 -1
- package/dist/cli/isolated-env-runner.js +2 -2
- package/dist/cli/isolated-env-runner.js.map +1 -1
- package/dist/cli/isolated-env.d.ts +2 -2
- package/dist/cli/isolated-env.js +17 -15
- package/dist/cli/isolated-env.js.map +1 -1
- package/dist/cli/poe-code-command-runner.js +2 -2
- package/dist/cli/poe-code-command-runner.js.map +1 -1
- package/dist/cli/program.js +6 -13
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +612 -1187
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +2 -1
- package/dist/providers/claude-code.js.map +2 -2
- package/dist/providers/codex.js +3 -1
- package/dist/providers/codex.js.map +2 -2
- package/dist/providers/kimi.js +2 -1
- package/dist/providers/kimi.js.map +2 -2
- package/dist/providers/opencode.js +3 -1
- package/dist/providers/opencode.js.map +2 -2
- package/dist/sdk/container.js +11 -27
- package/dist/sdk/container.js.map +1 -1
- package/dist/sdk/credentials.d.ts +1 -1
- package/dist/sdk/credentials.js +19 -6
- package/dist/sdk/credentials.js.map +1 -1
- package/dist/services/client-instance.d.ts +3 -1
- package/dist/services/client-instance.js +11 -1
- package/dist/services/client-instance.js.map +1 -1
- package/dist/services/credentials.d.ts +24 -0
- package/dist/services/{config.js → credentials.js} +21 -34
- package/dist/services/credentials.js.map +1 -0
- package/dist/services/model-strategy.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cli/commands/auth.d.ts +0 -3
- package/dist/cli/commands/auth.js +0 -102
- package/dist/cli/commands/auth.js.map +0 -1
- package/dist/services/config.d.ts +0 -24
- package/dist/services/config.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -31,469 +31,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
mod
|
|
32
32
|
));
|
|
33
33
|
|
|
34
|
-
// packages/auth/src/encrypted-file-auth-store.ts
|
|
35
|
-
import { createCipheriv, createDecipheriv, randomBytes, scrypt } from "node:crypto";
|
|
36
|
-
import { promises as fs } from "node:fs";
|
|
37
|
-
import { homedir, hostname, userInfo } from "node:os";
|
|
38
|
-
import path from "node:path";
|
|
39
|
-
function defaultMachineIdentity() {
|
|
40
|
-
return {
|
|
41
|
-
hostname: hostname(),
|
|
42
|
-
username: userInfo().username
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async function deriveEncryptionKey(getMachineIdentity) {
|
|
46
|
-
const machineIdentity = await getMachineIdentity();
|
|
47
|
-
const secret = `${machineIdentity.hostname}:${machineIdentity.username}`;
|
|
48
|
-
return await new Promise((resolve, reject) => {
|
|
49
|
-
scrypt(secret, ENCRYPTION_SALT, ENCRYPTION_KEY_BYTES, (error2, derivedKey) => {
|
|
50
|
-
if (error2) {
|
|
51
|
-
reject(error2);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
resolve(Buffer.from(derivedKey));
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function parseEncryptedDocument(raw) {
|
|
59
|
-
try {
|
|
60
|
-
const parsed = JSON.parse(raw);
|
|
61
|
-
if (!isRecord(parsed)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
if (parsed.version !== ENCRYPTION_VERSION) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
if (typeof parsed.iv !== "string" || typeof parsed.authTag !== "string" || typeof parsed.ciphertext !== "string") {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
version: parsed.version,
|
|
72
|
-
iv: parsed.iv,
|
|
73
|
-
authTag: parsed.authTag,
|
|
74
|
-
ciphertext: parsed.ciphertext
|
|
75
|
-
};
|
|
76
|
-
} catch {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function isRecord(value) {
|
|
81
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
82
|
-
}
|
|
83
|
-
function isNotFoundError(error2) {
|
|
84
|
-
return Boolean(
|
|
85
|
-
error2 && typeof error2 === "object" && "code" in error2 && error2.code === "ENOENT"
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
var ENCRYPTION_ALGORITHM, ENCRYPTION_VERSION, ENCRYPTION_KEY_BYTES, ENCRYPTION_IV_BYTES, ENCRYPTION_AUTH_TAG_BYTES, ENCRYPTION_SALT, ENCRYPTION_FILE_MODE, EncryptedFileAuthStore;
|
|
89
|
-
var init_encrypted_file_auth_store = __esm({
|
|
90
|
-
"packages/auth/src/encrypted-file-auth-store.ts"() {
|
|
91
|
-
"use strict";
|
|
92
|
-
ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
93
|
-
ENCRYPTION_VERSION = 1;
|
|
94
|
-
ENCRYPTION_KEY_BYTES = 32;
|
|
95
|
-
ENCRYPTION_IV_BYTES = 12;
|
|
96
|
-
ENCRYPTION_AUTH_TAG_BYTES = 16;
|
|
97
|
-
ENCRYPTION_SALT = "poe-code:encrypted-file-auth-store:v1";
|
|
98
|
-
ENCRYPTION_FILE_MODE = 384;
|
|
99
|
-
EncryptedFileAuthStore = class {
|
|
100
|
-
fs;
|
|
101
|
-
filePath;
|
|
102
|
-
getMachineIdentity;
|
|
103
|
-
getRandomBytes;
|
|
104
|
-
keyPromise = null;
|
|
105
|
-
constructor(input = {}) {
|
|
106
|
-
this.fs = input.fs ?? fs;
|
|
107
|
-
this.filePath = input.filePath ?? path.join(
|
|
108
|
-
(input.getHomeDirectory ?? homedir)(),
|
|
109
|
-
".poe-code",
|
|
110
|
-
"credentials.enc"
|
|
111
|
-
);
|
|
112
|
-
this.getMachineIdentity = input.getMachineIdentity ?? defaultMachineIdentity;
|
|
113
|
-
this.getRandomBytes = input.getRandomBytes ?? randomBytes;
|
|
114
|
-
}
|
|
115
|
-
async getApiKey() {
|
|
116
|
-
let rawDocument;
|
|
117
|
-
try {
|
|
118
|
-
rawDocument = await this.fs.readFile(this.filePath, "utf8");
|
|
119
|
-
} catch (error2) {
|
|
120
|
-
if (isNotFoundError(error2)) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
throw error2;
|
|
124
|
-
}
|
|
125
|
-
const document = parseEncryptedDocument(rawDocument);
|
|
126
|
-
if (!document) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
const key = await this.getEncryptionKey();
|
|
130
|
-
try {
|
|
131
|
-
const iv = Buffer.from(document.iv, "base64");
|
|
132
|
-
const authTag = Buffer.from(document.authTag, "base64");
|
|
133
|
-
const ciphertext = Buffer.from(document.ciphertext, "base64");
|
|
134
|
-
if (iv.byteLength !== ENCRYPTION_IV_BYTES || authTag.byteLength !== ENCRYPTION_AUTH_TAG_BYTES) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
const decipher = createDecipheriv(ENCRYPTION_ALGORITHM, key, iv);
|
|
138
|
-
decipher.setAuthTag(authTag);
|
|
139
|
-
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
140
|
-
return plaintext.toString("utf8");
|
|
141
|
-
} catch {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async setApiKey(apiKey) {
|
|
146
|
-
const key = await this.getEncryptionKey();
|
|
147
|
-
const iv = this.getRandomBytes(ENCRYPTION_IV_BYTES);
|
|
148
|
-
const cipher = createCipheriv(ENCRYPTION_ALGORITHM, key, iv);
|
|
149
|
-
const ciphertext = Buffer.concat([
|
|
150
|
-
cipher.update(apiKey, "utf8"),
|
|
151
|
-
cipher.final()
|
|
152
|
-
]);
|
|
153
|
-
const authTag = cipher.getAuthTag();
|
|
154
|
-
const document = {
|
|
155
|
-
version: ENCRYPTION_VERSION,
|
|
156
|
-
iv: iv.toString("base64"),
|
|
157
|
-
authTag: authTag.toString("base64"),
|
|
158
|
-
ciphertext: ciphertext.toString("base64")
|
|
159
|
-
};
|
|
160
|
-
await this.fs.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
161
|
-
await this.fs.writeFile(this.filePath, JSON.stringify(document), {
|
|
162
|
-
encoding: "utf8"
|
|
163
|
-
});
|
|
164
|
-
await this.fs.chmod(this.filePath, ENCRYPTION_FILE_MODE);
|
|
165
|
-
}
|
|
166
|
-
async deleteApiKey() {
|
|
167
|
-
try {
|
|
168
|
-
await this.fs.unlink(this.filePath);
|
|
169
|
-
} catch (error2) {
|
|
170
|
-
if (!isNotFoundError(error2)) {
|
|
171
|
-
throw error2;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
getEncryptionKey() {
|
|
176
|
-
if (!this.keyPromise) {
|
|
177
|
-
this.keyPromise = deriveEncryptionKey(this.getMachineIdentity);
|
|
178
|
-
}
|
|
179
|
-
return this.keyPromise;
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// packages/auth/src/keychain-auth-store.ts
|
|
186
|
-
import { spawn } from "node:child_process";
|
|
187
|
-
function runSecurityCommand(command, args) {
|
|
188
|
-
return new Promise((resolve) => {
|
|
189
|
-
const child = spawn(command, args, {
|
|
190
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
191
|
-
});
|
|
192
|
-
let stdout = "";
|
|
193
|
-
let stderr = "";
|
|
194
|
-
child.stdout?.setEncoding("utf8");
|
|
195
|
-
child.stdout?.on("data", (chunk) => {
|
|
196
|
-
stdout += chunk.toString();
|
|
197
|
-
});
|
|
198
|
-
child.stderr?.setEncoding("utf8");
|
|
199
|
-
child.stderr?.on("data", (chunk) => {
|
|
200
|
-
stderr += chunk.toString();
|
|
201
|
-
});
|
|
202
|
-
child.on("error", (error2) => {
|
|
203
|
-
const message = error2 instanceof Error ? error2.message : String(error2 ?? "Unknown error");
|
|
204
|
-
resolve({
|
|
205
|
-
stdout,
|
|
206
|
-
stderr: stderr ? `${stderr}${message}` : message,
|
|
207
|
-
exitCode: 127
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
child.on("close", (code) => {
|
|
211
|
-
resolve({
|
|
212
|
-
stdout,
|
|
213
|
-
stderr,
|
|
214
|
-
exitCode: code ?? 0
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
function stripTrailingLineBreak(value) {
|
|
220
|
-
if (value.endsWith("\r\n")) {
|
|
221
|
-
return value.slice(0, -2);
|
|
222
|
-
}
|
|
223
|
-
if (value.endsWith("\n") || value.endsWith("\r")) {
|
|
224
|
-
return value.slice(0, -1);
|
|
225
|
-
}
|
|
226
|
-
return value;
|
|
227
|
-
}
|
|
228
|
-
function isKeychainEntryNotFound(result) {
|
|
229
|
-
if (result.exitCode === KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE) {
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
const output = `${result.stderr}
|
|
233
|
-
${result.stdout}`.toLowerCase();
|
|
234
|
-
return output.includes("could not be found") || output.includes("item not found") || output.includes("errsecitemnotfound");
|
|
235
|
-
}
|
|
236
|
-
function createSecurityCliFailure(operation, result) {
|
|
237
|
-
const details = result.stderr.trim() || result.stdout.trim();
|
|
238
|
-
if (details) {
|
|
239
|
-
return new Error(
|
|
240
|
-
`Failed to ${operation}: security exited with code ${result.exitCode}: ${details}`
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
return new Error(`Failed to ${operation}: security exited with code ${result.exitCode}`);
|
|
244
|
-
}
|
|
245
|
-
var SECURITY_CLI, KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT, KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE, KeychainAuthStore;
|
|
246
|
-
var init_keychain_auth_store = __esm({
|
|
247
|
-
"packages/auth/src/keychain-auth-store.ts"() {
|
|
248
|
-
"use strict";
|
|
249
|
-
SECURITY_CLI = "security";
|
|
250
|
-
KEYCHAIN_SERVICE = "poe-code";
|
|
251
|
-
KEYCHAIN_ACCOUNT = "api-key";
|
|
252
|
-
KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE = 44;
|
|
253
|
-
KeychainAuthStore = class {
|
|
254
|
-
runCommand;
|
|
255
|
-
service;
|
|
256
|
-
account;
|
|
257
|
-
constructor(input = {}) {
|
|
258
|
-
this.runCommand = input.runCommand ?? runSecurityCommand;
|
|
259
|
-
this.service = input.service ?? KEYCHAIN_SERVICE;
|
|
260
|
-
this.account = input.account ?? KEYCHAIN_ACCOUNT;
|
|
261
|
-
}
|
|
262
|
-
async getApiKey() {
|
|
263
|
-
const result = await this.executeSecurityCommand(
|
|
264
|
-
["find-generic-password", "-s", this.service, "-a", this.account, "-w"],
|
|
265
|
-
"read API key from macOS Keychain"
|
|
266
|
-
);
|
|
267
|
-
if (result.exitCode === 0) {
|
|
268
|
-
return stripTrailingLineBreak(result.stdout);
|
|
269
|
-
}
|
|
270
|
-
if (isKeychainEntryNotFound(result)) {
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
throw createSecurityCliFailure("read API key from macOS Keychain", result);
|
|
274
|
-
}
|
|
275
|
-
async setApiKey(apiKey) {
|
|
276
|
-
const result = await this.executeSecurityCommand(
|
|
277
|
-
[
|
|
278
|
-
"add-generic-password",
|
|
279
|
-
"-s",
|
|
280
|
-
this.service,
|
|
281
|
-
"-a",
|
|
282
|
-
this.account,
|
|
283
|
-
"-w",
|
|
284
|
-
apiKey,
|
|
285
|
-
"-U"
|
|
286
|
-
],
|
|
287
|
-
"store API key in macOS Keychain"
|
|
288
|
-
);
|
|
289
|
-
if (result.exitCode !== 0) {
|
|
290
|
-
throw createSecurityCliFailure("store API key in macOS Keychain", result);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
async deleteApiKey() {
|
|
294
|
-
const result = await this.executeSecurityCommand(
|
|
295
|
-
["delete-generic-password", "-s", this.service, "-a", this.account],
|
|
296
|
-
"delete API key from macOS Keychain"
|
|
297
|
-
);
|
|
298
|
-
if (result.exitCode === 0 || isKeychainEntryNotFound(result)) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
throw createSecurityCliFailure("delete API key from macOS Keychain", result);
|
|
302
|
-
}
|
|
303
|
-
async executeSecurityCommand(args, operation) {
|
|
304
|
-
try {
|
|
305
|
-
return await this.runCommand(SECURITY_CLI, args);
|
|
306
|
-
} catch (error2) {
|
|
307
|
-
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
308
|
-
throw new Error(`Failed to ${operation}: ${message}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// packages/auth/src/create-auth-store.ts
|
|
316
|
-
import { promises as nodeFs } from "node:fs";
|
|
317
|
-
import { homedir as homedir2 } from "node:os";
|
|
318
|
-
import path2 from "node:path";
|
|
319
|
-
function createAuthStore(input = {}) {
|
|
320
|
-
const backend = resolveBackend(input);
|
|
321
|
-
const platform = input.platform ?? process.platform;
|
|
322
|
-
if (backend === "keychain" && platform !== MACOS_PLATFORM) {
|
|
323
|
-
throw new Error(
|
|
324
|
-
`POE_AUTH_BACKEND=keychain is only supported on macOS. Current platform: ${platform}`
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
const store = authStoreFactories[backend](input);
|
|
328
|
-
return {
|
|
329
|
-
backend,
|
|
330
|
-
store: enableLegacyCredentialsMigration(store, input)
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
function resolveBackend(input) {
|
|
334
|
-
const configuredBackend = input.backend ?? input.env?.[AUTH_BACKEND_ENV_VAR] ?? process.env[AUTH_BACKEND_ENV_VAR];
|
|
335
|
-
if (configuredBackend === "keychain") {
|
|
336
|
-
return "keychain";
|
|
337
|
-
}
|
|
338
|
-
return "file";
|
|
339
|
-
}
|
|
340
|
-
function enableLegacyCredentialsMigration(store, input) {
|
|
341
|
-
const migrationContext = createLegacyMigrationContext(input);
|
|
342
|
-
const readApiKeyFromStore = store.getApiKey.bind(store);
|
|
343
|
-
let hasCheckedLegacyCredentials = false;
|
|
344
|
-
let legacyMigrationPromise = null;
|
|
345
|
-
store.getApiKey = async () => {
|
|
346
|
-
const storedApiKey = await readApiKeyFromStore();
|
|
347
|
-
if (isNonEmptyString(storedApiKey)) {
|
|
348
|
-
return storedApiKey;
|
|
349
|
-
}
|
|
350
|
-
if (hasCheckedLegacyCredentials) {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
if (!legacyMigrationPromise) {
|
|
354
|
-
legacyMigrationPromise = migrateLegacyApiKey(store, migrationContext).finally(() => {
|
|
355
|
-
hasCheckedLegacyCredentials = true;
|
|
356
|
-
legacyMigrationPromise = null;
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return legacyMigrationPromise;
|
|
360
|
-
};
|
|
361
|
-
return store;
|
|
362
|
-
}
|
|
363
|
-
async function migrateLegacyApiKey(store, migrationContext) {
|
|
364
|
-
const legacyCredentials = await loadLegacyCredentials(
|
|
365
|
-
migrationContext.fs,
|
|
366
|
-
migrationContext.filePath
|
|
367
|
-
);
|
|
368
|
-
if (!legacyCredentials || !isNonEmptyString(legacyCredentials.apiKey)) {
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
const plaintextApiKey = legacyCredentials.apiKey;
|
|
372
|
-
try {
|
|
373
|
-
await store.setApiKey(plaintextApiKey);
|
|
374
|
-
delete legacyCredentials.apiKey;
|
|
375
|
-
await saveLegacyCredentials(
|
|
376
|
-
migrationContext.fs,
|
|
377
|
-
migrationContext.filePath,
|
|
378
|
-
legacyCredentials
|
|
379
|
-
);
|
|
380
|
-
} catch (error2) {
|
|
381
|
-
migrationContext.logWarning(
|
|
382
|
-
`Failed to migrate plaintext API key from ${migrationContext.filePath}.`,
|
|
383
|
-
error2
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
return plaintextApiKey;
|
|
387
|
-
}
|
|
388
|
-
function createLegacyMigrationContext(input) {
|
|
389
|
-
const legacyCredentialsInput = input.legacyCredentials;
|
|
390
|
-
const getHomeDirectory = legacyCredentialsInput?.getHomeDirectory ?? homedir2;
|
|
391
|
-
return {
|
|
392
|
-
fs: legacyCredentialsInput?.fs ?? input.fileStore?.fs ?? nodeFs,
|
|
393
|
-
filePath: legacyCredentialsInput?.filePath ?? path2.join(
|
|
394
|
-
getHomeDirectory(),
|
|
395
|
-
LEGACY_CREDENTIALS_RELATIVE_PATH
|
|
396
|
-
),
|
|
397
|
-
logWarning: legacyCredentialsInput?.logWarning ?? defaultMigrationWarning
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
async function loadLegacyCredentials(fs3, filePath) {
|
|
401
|
-
let raw;
|
|
402
|
-
try {
|
|
403
|
-
raw = await fs3.readFile(filePath, "utf8");
|
|
404
|
-
} catch (error2) {
|
|
405
|
-
if (isNotFoundError2(error2)) {
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
return null;
|
|
409
|
-
}
|
|
410
|
-
try {
|
|
411
|
-
const parsed = JSON.parse(raw);
|
|
412
|
-
if (!isRecord2(parsed)) {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
return parsed;
|
|
416
|
-
} catch {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
async function saveLegacyCredentials(fs3, filePath, document) {
|
|
421
|
-
await fs3.mkdir(path2.dirname(filePath), { recursive: true });
|
|
422
|
-
await fs3.writeFile(filePath, `${JSON.stringify(document, null, 2)}
|
|
423
|
-
`, {
|
|
424
|
-
encoding: "utf8"
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
function defaultMigrationWarning(message, error2) {
|
|
428
|
-
const details = toErrorDetails(error2);
|
|
429
|
-
if (details.length > 0) {
|
|
430
|
-
console.warn(`${message} ${details}`);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
console.warn(message);
|
|
434
|
-
}
|
|
435
|
-
function toErrorDetails(error2) {
|
|
436
|
-
if (error2 instanceof Error) {
|
|
437
|
-
return error2.message;
|
|
438
|
-
}
|
|
439
|
-
return typeof error2 === "string" ? error2 : "";
|
|
440
|
-
}
|
|
441
|
-
function isNonEmptyString(value) {
|
|
442
|
-
return typeof value === "string" && value.length > 0;
|
|
443
|
-
}
|
|
444
|
-
function isRecord2(value) {
|
|
445
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
446
|
-
}
|
|
447
|
-
function isNotFoundError2(error2) {
|
|
448
|
-
return Boolean(
|
|
449
|
-
error2 && typeof error2 === "object" && "code" in error2 && error2.code === "ENOENT"
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
var AUTH_BACKEND_ENV_VAR, MACOS_PLATFORM, LEGACY_CREDENTIALS_RELATIVE_PATH, authStoreFactories;
|
|
453
|
-
var init_create_auth_store = __esm({
|
|
454
|
-
"packages/auth/src/create-auth-store.ts"() {
|
|
455
|
-
"use strict";
|
|
456
|
-
init_encrypted_file_auth_store();
|
|
457
|
-
init_keychain_auth_store();
|
|
458
|
-
AUTH_BACKEND_ENV_VAR = "POE_AUTH_BACKEND";
|
|
459
|
-
MACOS_PLATFORM = "darwin";
|
|
460
|
-
LEGACY_CREDENTIALS_RELATIVE_PATH = ".poe-code/credentials.json";
|
|
461
|
-
authStoreFactories = {
|
|
462
|
-
file: (input) => new EncryptedFileAuthStore(input.fileStore),
|
|
463
|
-
keychain: (input) => new KeychainAuthStore(input.keychainStore)
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
// packages/auth/src/index.ts
|
|
469
|
-
var init_src = __esm({
|
|
470
|
-
"packages/auth/src/index.ts"() {
|
|
471
|
-
"use strict";
|
|
472
|
-
init_create_auth_store();
|
|
473
|
-
init_encrypted_file_auth_store();
|
|
474
|
-
init_keychain_auth_store();
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
|
|
478
34
|
// src/sdk/credentials.ts
|
|
35
|
+
import * as fs from "node:fs/promises";
|
|
36
|
+
import * as os from "node:os";
|
|
37
|
+
import * as path from "node:path";
|
|
479
38
|
async function getPoeApiKey() {
|
|
480
39
|
const envKey = process.env.POE_API_KEY;
|
|
481
40
|
if (typeof envKey === "string" && envKey.trim().length > 0) {
|
|
482
41
|
return envKey.trim();
|
|
483
42
|
}
|
|
484
|
-
const
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
43
|
+
const homeDir = os.homedir();
|
|
44
|
+
const credentialsPath = path.join(homeDir, CREDENTIALS_RELATIVE_PATH);
|
|
45
|
+
try {
|
|
46
|
+
const content = await fs.readFile(credentialsPath, "utf8");
|
|
47
|
+
const parsed = JSON.parse(content);
|
|
48
|
+
if (typeof parsed === "object" && parsed !== null && typeof parsed.apiKey === "string" && parsed.apiKey.length > 0) {
|
|
49
|
+
return parsed.apiKey;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
488
52
|
}
|
|
489
53
|
throw new Error(
|
|
490
54
|
"No API key found. Set POE_API_KEY or run 'poe-code login'."
|
|
491
55
|
);
|
|
492
56
|
}
|
|
57
|
+
var CREDENTIALS_RELATIVE_PATH;
|
|
493
58
|
var init_credentials = __esm({
|
|
494
59
|
"src/sdk/credentials.ts"() {
|
|
495
60
|
"use strict";
|
|
496
|
-
|
|
61
|
+
CREDENTIALS_RELATIVE_PATH = ".poe-code/credentials.json";
|
|
497
62
|
}
|
|
498
63
|
});
|
|
499
64
|
|
|
@@ -818,16 +383,16 @@ function getConfigFormat(pathOrFormat) {
|
|
|
818
383
|
}
|
|
819
384
|
return formatRegistry[formatName];
|
|
820
385
|
}
|
|
821
|
-
function detectFormat(
|
|
822
|
-
const ext = getExtension(
|
|
386
|
+
function detectFormat(path20) {
|
|
387
|
+
const ext = getExtension(path20);
|
|
823
388
|
return extensionMap[ext];
|
|
824
389
|
}
|
|
825
|
-
function getExtension(
|
|
826
|
-
const lastDot =
|
|
390
|
+
function getExtension(path20) {
|
|
391
|
+
const lastDot = path20.lastIndexOf(".");
|
|
827
392
|
if (lastDot === -1) {
|
|
828
393
|
return "";
|
|
829
394
|
}
|
|
830
|
-
return
|
|
395
|
+
return path20.slice(lastDot).toLowerCase();
|
|
831
396
|
}
|
|
832
397
|
var formatRegistry, extensionMap;
|
|
833
398
|
var init_formats = __esm({
|
|
@@ -849,7 +414,7 @@ var init_formats = __esm({
|
|
|
849
414
|
});
|
|
850
415
|
|
|
851
416
|
// packages/config-mutations/src/execution/path-utils.ts
|
|
852
|
-
import
|
|
417
|
+
import path2 from "node:path";
|
|
853
418
|
function expandHome(targetPath, homeDir) {
|
|
854
419
|
if (!targetPath?.startsWith("~")) {
|
|
855
420
|
return targetPath;
|
|
@@ -866,7 +431,7 @@ function expandHome(targetPath, homeDir) {
|
|
|
866
431
|
remainder = remainder.slice(1);
|
|
867
432
|
}
|
|
868
433
|
}
|
|
869
|
-
return remainder.length === 0 ? homeDir :
|
|
434
|
+
return remainder.length === 0 ? homeDir : path2.join(homeDir, remainder);
|
|
870
435
|
}
|
|
871
436
|
function validateHomePath(targetPath) {
|
|
872
437
|
if (typeof targetPath !== "string" || targetPath.length === 0) {
|
|
@@ -884,12 +449,12 @@ function resolvePath(rawPath, homeDir, pathMapper) {
|
|
|
884
449
|
if (!pathMapper) {
|
|
885
450
|
return expanded;
|
|
886
451
|
}
|
|
887
|
-
const rawDirectory =
|
|
452
|
+
const rawDirectory = path2.dirname(expanded);
|
|
888
453
|
const mappedDirectory = pathMapper.mapTargetDirectory({
|
|
889
454
|
targetDirectory: rawDirectory
|
|
890
455
|
});
|
|
891
|
-
const filename =
|
|
892
|
-
return filename.length === 0 ? mappedDirectory :
|
|
456
|
+
const filename = path2.basename(expanded);
|
|
457
|
+
return filename.length === 0 ? mappedDirectory : path2.join(mappedDirectory, filename);
|
|
893
458
|
}
|
|
894
459
|
var init_path_utils = __esm({
|
|
895
460
|
"packages/config-mutations/src/execution/path-utils.ts"() {
|
|
@@ -1550,7 +1115,7 @@ var init_types = __esm({
|
|
|
1550
1115
|
});
|
|
1551
1116
|
|
|
1552
1117
|
// packages/config-mutations/src/index.ts
|
|
1553
|
-
var
|
|
1118
|
+
var init_src = __esm({
|
|
1554
1119
|
"packages/config-mutations/src/index.ts"() {
|
|
1555
1120
|
"use strict";
|
|
1556
1121
|
init_config_mutation();
|
|
@@ -1570,38 +1135,38 @@ import { createTwoFilesPatch } from "diff";
|
|
|
1570
1135
|
import chalk from "chalk";
|
|
1571
1136
|
function createDryRunFileSystem(base, recorder) {
|
|
1572
1137
|
const proxy = {
|
|
1573
|
-
async readFile(
|
|
1138
|
+
async readFile(path20, encoding) {
|
|
1574
1139
|
if (encoding) {
|
|
1575
|
-
return base.readFile(
|
|
1140
|
+
return base.readFile(path20, encoding);
|
|
1576
1141
|
}
|
|
1577
|
-
return base.readFile(
|
|
1142
|
+
return base.readFile(path20);
|
|
1578
1143
|
},
|
|
1579
|
-
async writeFile(
|
|
1580
|
-
const previousContent = await tryReadText(base,
|
|
1144
|
+
async writeFile(path20, data, options) {
|
|
1145
|
+
const previousContent = await tryReadText(base, path20);
|
|
1581
1146
|
const nextContent = formatData(data, options?.encoding);
|
|
1582
1147
|
recorder.record({
|
|
1583
1148
|
type: "writeFile",
|
|
1584
|
-
path:
|
|
1149
|
+
path: path20,
|
|
1585
1150
|
nextContent,
|
|
1586
1151
|
previousContent
|
|
1587
1152
|
});
|
|
1588
1153
|
},
|
|
1589
|
-
async mkdir(
|
|
1590
|
-
recorder.record({ type: "mkdir", path:
|
|
1154
|
+
async mkdir(path20, options) {
|
|
1155
|
+
recorder.record({ type: "mkdir", path: path20, options });
|
|
1591
1156
|
},
|
|
1592
|
-
async stat(
|
|
1593
|
-
return base.stat(
|
|
1157
|
+
async stat(path20) {
|
|
1158
|
+
return base.stat(path20);
|
|
1594
1159
|
},
|
|
1595
|
-
async unlink(
|
|
1596
|
-
recorder.record({ type: "unlink", path:
|
|
1160
|
+
async unlink(path20) {
|
|
1161
|
+
recorder.record({ type: "unlink", path: path20 });
|
|
1597
1162
|
},
|
|
1598
|
-
async readdir(
|
|
1599
|
-
return base.readdir(
|
|
1163
|
+
async readdir(path20) {
|
|
1164
|
+
return base.readdir(path20);
|
|
1600
1165
|
}
|
|
1601
1166
|
};
|
|
1602
1167
|
if (typeof base.rm === "function") {
|
|
1603
|
-
proxy.rm = async (
|
|
1604
|
-
recorder.record({ type: "rm", path:
|
|
1168
|
+
proxy.rm = async (path20, options) => {
|
|
1169
|
+
recorder.record({ type: "rm", path: path20, options });
|
|
1605
1170
|
};
|
|
1606
1171
|
}
|
|
1607
1172
|
if (typeof base.copyFile === "function") {
|
|
@@ -1691,8 +1256,8 @@ function describeWriteChange(previous, next) {
|
|
|
1691
1256
|
}
|
|
1692
1257
|
return "update";
|
|
1693
1258
|
}
|
|
1694
|
-
function renderWriteCommand(
|
|
1695
|
-
const command = `cat > ${
|
|
1259
|
+
function renderWriteCommand(path20, change) {
|
|
1260
|
+
const command = `cat > ${path20}`;
|
|
1696
1261
|
if (change === "create") {
|
|
1697
1262
|
return renderOperationCommand(command, chalk.green, "# create");
|
|
1698
1263
|
}
|
|
@@ -1854,9 +1419,9 @@ function redactTomlLine(line) {
|
|
|
1854
1419
|
}
|
|
1855
1420
|
return line;
|
|
1856
1421
|
}
|
|
1857
|
-
async function tryReadText(base,
|
|
1422
|
+
async function tryReadText(base, path20) {
|
|
1858
1423
|
try {
|
|
1859
|
-
return await base.readFile(
|
|
1424
|
+
return await base.readFile(path20, "utf8");
|
|
1860
1425
|
} catch (error2) {
|
|
1861
1426
|
if (isNotFound(error2)) {
|
|
1862
1427
|
return null;
|
|
@@ -1882,7 +1447,7 @@ var REDACTED_PLACEHOLDER, JSON_SENSITIVE_KEYS, AUTH_SENSITIVE_KEYS, TOML_SENSITI
|
|
|
1882
1447
|
var init_dry_run = __esm({
|
|
1883
1448
|
"src/utils/dry-run.ts"() {
|
|
1884
1449
|
"use strict";
|
|
1885
|
-
|
|
1450
|
+
init_src();
|
|
1886
1451
|
REDACTED_PLACEHOLDER = "<redacted>";
|
|
1887
1452
|
JSON_SENSITIVE_KEYS = ["apiKey", "api_key", "apiKeyHelper"];
|
|
1888
1453
|
AUTH_SENSITIVE_KEYS = ["key"];
|
|
@@ -1917,6 +1482,7 @@ var init_constants = __esm({
|
|
|
1917
1482
|
};
|
|
1918
1483
|
DEFAULT_CLAUDE_CODE_MODEL = CLAUDE_CODE_VARIANTS.sonnet;
|
|
1919
1484
|
CODEX_MODELS = [
|
|
1485
|
+
"openai/gpt-5.3-codex",
|
|
1920
1486
|
"openai/gpt-5.2-codex",
|
|
1921
1487
|
"openai/gpt-5.2",
|
|
1922
1488
|
"openai/gpt-5.2-chat",
|
|
@@ -2032,9 +1598,170 @@ var init_context = __esm({
|
|
|
2032
1598
|
}
|
|
2033
1599
|
});
|
|
2034
1600
|
|
|
1601
|
+
// src/services/credentials.ts
|
|
1602
|
+
import path3 from "node:path";
|
|
1603
|
+
async function saveCredentials(options) {
|
|
1604
|
+
const { fs: fs3, filePath, apiKey } = options;
|
|
1605
|
+
const document = await readCredentialsDocument(fs3, filePath);
|
|
1606
|
+
document.apiKey = apiKey;
|
|
1607
|
+
await writeCredentialsDocument(fs3, filePath, document);
|
|
1608
|
+
}
|
|
1609
|
+
async function loadCredentials(options) {
|
|
1610
|
+
const { fs: fs3, filePath } = options;
|
|
1611
|
+
const document = await readCredentialsDocument(fs3, filePath);
|
|
1612
|
+
return typeof document.apiKey === "string" && document.apiKey.length > 0 ? document.apiKey : null;
|
|
1613
|
+
}
|
|
1614
|
+
async function deleteCredentials(options) {
|
|
1615
|
+
const { fs: fs3, filePath } = options;
|
|
1616
|
+
try {
|
|
1617
|
+
await fs3.unlink(filePath);
|
|
1618
|
+
return true;
|
|
1619
|
+
} catch (error2) {
|
|
1620
|
+
if (isNotFound(error2)) {
|
|
1621
|
+
return false;
|
|
1622
|
+
}
|
|
1623
|
+
throw error2;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
async function loadConfiguredServices(options) {
|
|
1627
|
+
const { fs: fs3, filePath } = options;
|
|
1628
|
+
const document = await readCredentialsDocument(fs3, filePath);
|
|
1629
|
+
return { ...document.configured_services ?? {} };
|
|
1630
|
+
}
|
|
1631
|
+
async function saveConfiguredService(options) {
|
|
1632
|
+
const { fs: fs3, filePath, service, metadata } = options;
|
|
1633
|
+
const document = await readCredentialsDocument(fs3, filePath);
|
|
1634
|
+
const normalized = normalizeConfiguredServiceMetadata(metadata);
|
|
1635
|
+
document.configured_services = {
|
|
1636
|
+
...document.configured_services ?? {},
|
|
1637
|
+
[service]: normalized
|
|
1638
|
+
};
|
|
1639
|
+
await writeCredentialsDocument(fs3, filePath, document);
|
|
1640
|
+
}
|
|
1641
|
+
async function unconfigureService(options) {
|
|
1642
|
+
const { fs: fs3, filePath, service } = options;
|
|
1643
|
+
const document = await readCredentialsDocument(fs3, filePath);
|
|
1644
|
+
const services = document.configured_services;
|
|
1645
|
+
if (!services || !(service in services)) {
|
|
1646
|
+
return false;
|
|
1647
|
+
}
|
|
1648
|
+
delete services[service];
|
|
1649
|
+
if (Object.keys(services).length === 0) {
|
|
1650
|
+
delete document.configured_services;
|
|
1651
|
+
}
|
|
1652
|
+
await writeCredentialsDocument(fs3, filePath, document);
|
|
1653
|
+
return true;
|
|
1654
|
+
}
|
|
1655
|
+
function normalizeConfiguredServiceMetadata(metadata) {
|
|
1656
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1657
|
+
const files = [];
|
|
1658
|
+
for (const entry of metadata.files ?? []) {
|
|
1659
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
1660
|
+
continue;
|
|
1661
|
+
}
|
|
1662
|
+
if (!seen.has(entry)) {
|
|
1663
|
+
files.push(entry);
|
|
1664
|
+
seen.add(entry);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
return {
|
|
1668
|
+
files
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
async function readCredentialsDocument(fs3, filePath) {
|
|
1672
|
+
try {
|
|
1673
|
+
const raw = await fs3.readFile(filePath, "utf8");
|
|
1674
|
+
return await parseCredentialsDocument(fs3, filePath, raw);
|
|
1675
|
+
} catch (error2) {
|
|
1676
|
+
if (isNotFound(error2)) {
|
|
1677
|
+
return {};
|
|
1678
|
+
}
|
|
1679
|
+
throw error2;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
async function parseCredentialsDocument(fs3, filePath, raw) {
|
|
1683
|
+
try {
|
|
1684
|
+
const parsed = JSON.parse(raw);
|
|
1685
|
+
return normalizeCredentialsDocument(parsed);
|
|
1686
|
+
} catch (error2) {
|
|
1687
|
+
if (error2 instanceof SyntaxError) {
|
|
1688
|
+
await recoverInvalidCredentials(fs3, filePath, raw);
|
|
1689
|
+
return {};
|
|
1690
|
+
}
|
|
1691
|
+
throw error2;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
function normalizeCredentialsDocument(value) {
|
|
1695
|
+
if (!isRecord(value)) {
|
|
1696
|
+
return {};
|
|
1697
|
+
}
|
|
1698
|
+
const document = {};
|
|
1699
|
+
if (typeof value.apiKey === "string" && value.apiKey.length > 0) {
|
|
1700
|
+
document.apiKey = value.apiKey;
|
|
1701
|
+
}
|
|
1702
|
+
const services = normalizeConfiguredServices(value.configured_services);
|
|
1703
|
+
if (Object.keys(services).length > 0) {
|
|
1704
|
+
document.configured_services = services;
|
|
1705
|
+
}
|
|
1706
|
+
return document;
|
|
1707
|
+
}
|
|
1708
|
+
function normalizeConfiguredServices(value) {
|
|
1709
|
+
if (!isRecord(value)) {
|
|
1710
|
+
return {};
|
|
1711
|
+
}
|
|
1712
|
+
const entries = {};
|
|
1713
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1714
|
+
if (!isRecord(entry)) {
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
const normalized = normalizeConfiguredServiceMetadata({
|
|
1718
|
+
files: Array.isArray(entry.files) ? entry.files : []
|
|
1719
|
+
});
|
|
1720
|
+
entries[key] = normalized;
|
|
1721
|
+
}
|
|
1722
|
+
return entries;
|
|
1723
|
+
}
|
|
1724
|
+
async function writeCredentialsDocument(fs3, filePath, document) {
|
|
1725
|
+
await fs3.mkdir(path3.dirname(filePath), { recursive: true });
|
|
1726
|
+
const payload = {};
|
|
1727
|
+
if (document.apiKey) {
|
|
1728
|
+
payload.apiKey = document.apiKey;
|
|
1729
|
+
}
|
|
1730
|
+
if (document.configured_services) {
|
|
1731
|
+
payload.configured_services = document.configured_services;
|
|
1732
|
+
}
|
|
1733
|
+
await fs3.writeFile(filePath, `${JSON.stringify(payload, null, 2)}
|
|
1734
|
+
`, {
|
|
1735
|
+
encoding: "utf8"
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
async function recoverInvalidCredentials(fs3, filePath, content) {
|
|
1739
|
+
const backupPath = createInvalidBackupPath(filePath);
|
|
1740
|
+
await fs3.writeFile(backupPath, content, { encoding: "utf8" });
|
|
1741
|
+
await fs3.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
|
|
1742
|
+
}
|
|
1743
|
+
function createInvalidBackupPath(filePath) {
|
|
1744
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
1745
|
+
const dir = path3.dirname(filePath);
|
|
1746
|
+
const base = path3.basename(filePath);
|
|
1747
|
+
return path3.join(dir, `${base}.invalid-${timestamp}.json`);
|
|
1748
|
+
}
|
|
1749
|
+
function isRecord(value) {
|
|
1750
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1751
|
+
}
|
|
1752
|
+
var EMPTY_DOCUMENT;
|
|
1753
|
+
var init_credentials2 = __esm({
|
|
1754
|
+
"src/services/credentials.ts"() {
|
|
1755
|
+
"use strict";
|
|
1756
|
+
init_src();
|
|
1757
|
+
EMPTY_DOCUMENT = `${JSON.stringify({}, null, 2)}
|
|
1758
|
+
`;
|
|
1759
|
+
}
|
|
1760
|
+
});
|
|
1761
|
+
|
|
2035
1762
|
// src/cli/isolated-env.ts
|
|
2036
1763
|
import path4 from "node:path";
|
|
2037
|
-
async function resolveIsolatedEnvDetails(env, isolated, providerName,
|
|
1764
|
+
async function resolveIsolatedEnvDetails(env, isolated, providerName, fs3) {
|
|
2038
1765
|
if (!providerName) {
|
|
2039
1766
|
throw new Error("resolveIsolatedEnvDetails requires providerName.");
|
|
2040
1767
|
}
|
|
@@ -2047,7 +1774,7 @@ async function resolveIsolatedEnvDetails(env, isolated, providerName, readApiKey
|
|
|
2047
1774
|
}
|
|
2048
1775
|
return {
|
|
2049
1776
|
agentBinary: isolated.agentBinary,
|
|
2050
|
-
env: await resolveIsolatedEnvVars(env, baseDir, isolated.env,
|
|
1777
|
+
env: await resolveIsolatedEnvVars(env, baseDir, isolated.env, fs3),
|
|
2051
1778
|
configProbePath: isolated.configProbe ? resolveIsolatedEnvPath(env, baseDir, isolated.configProbe) : void 0
|
|
2052
1779
|
};
|
|
2053
1780
|
}
|
|
@@ -2076,14 +1803,14 @@ function resolveIsolatedTargetDirectory(input) {
|
|
|
2076
1803
|
function resolveIsolatedBaseDir(env, providerName) {
|
|
2077
1804
|
return env.resolveHomePath(".poe-code", providerName);
|
|
2078
1805
|
}
|
|
2079
|
-
async function resolveIsolatedEnvVars(env, baseDir, vars,
|
|
1806
|
+
async function resolveIsolatedEnvVars(env, baseDir, vars, fs3) {
|
|
2080
1807
|
const out = {};
|
|
2081
1808
|
for (const [key, value] of Object.entries(vars)) {
|
|
2082
|
-
out[key] = await resolveIsolatedEnvValue(env, baseDir, value,
|
|
1809
|
+
out[key] = await resolveIsolatedEnvValue(env, baseDir, value, fs3);
|
|
2083
1810
|
}
|
|
2084
1811
|
return out;
|
|
2085
1812
|
}
|
|
2086
|
-
async function resolveIsolatedEnvValue(env, baseDir, value,
|
|
1813
|
+
async function resolveIsolatedEnvValue(env, baseDir, value, fs3) {
|
|
2087
1814
|
if (typeof value === "string") {
|
|
2088
1815
|
return expandHomeShortcut(env, value);
|
|
2089
1816
|
}
|
|
@@ -2101,12 +1828,12 @@ async function resolveIsolatedEnvValue(env, baseDir, value, readApiKey) {
|
|
|
2101
1828
|
if (typeof resolved === "string" && resolved.trim().length > 0) {
|
|
2102
1829
|
return resolved;
|
|
2103
1830
|
}
|
|
2104
|
-
if (!
|
|
1831
|
+
if (!fs3) {
|
|
2105
1832
|
throw new Error(
|
|
2106
1833
|
'Missing Poe API key for isolated wrapper. Set "POE_API_KEY" or run "poe-code login".'
|
|
2107
1834
|
);
|
|
2108
1835
|
}
|
|
2109
|
-
return await
|
|
1836
|
+
return await resolvePoeApiKeyFromCredentials({ fs: fs3, env });
|
|
2110
1837
|
}
|
|
2111
1838
|
if (isPoeBaseUrlReference(value)) {
|
|
2112
1839
|
return env.poeBaseUrl;
|
|
@@ -2133,8 +1860,8 @@ function isPoeApiKeyReference(value) {
|
|
|
2133
1860
|
function isPoeBaseUrlReference(value) {
|
|
2134
1861
|
return typeof value === "object" && value.kind === "poeBaseUrl";
|
|
2135
1862
|
}
|
|
2136
|
-
async function
|
|
2137
|
-
const stored = await
|
|
1863
|
+
async function resolvePoeApiKeyFromCredentials(input) {
|
|
1864
|
+
const stored = await loadCredentials({ fs: input.fs, filePath: input.env.credentialsPath }) ?? void 0;
|
|
2138
1865
|
if (typeof stored !== "string" || stored.trim().length === 0) {
|
|
2139
1866
|
throw new Error(
|
|
2140
1867
|
'Missing Poe API key for isolated wrapper. Set "POE_API_KEY" or run "poe-code login".'
|
|
@@ -2177,11 +1904,11 @@ async function applyIsolatedEnvRepairs(input) {
|
|
|
2177
1904
|
}
|
|
2178
1905
|
}
|
|
2179
1906
|
}
|
|
2180
|
-
async function resolveCliSettings(cliSettings, env,
|
|
1907
|
+
async function resolveCliSettings(cliSettings, env, fs3) {
|
|
2181
1908
|
const result = { ...cliSettings.values };
|
|
2182
1909
|
if (cliSettings.resolved) {
|
|
2183
1910
|
for (const [key, value] of Object.entries(cliSettings.resolved)) {
|
|
2184
|
-
result[key] = await resolveCliSettingValue(value, env,
|
|
1911
|
+
result[key] = await resolveCliSettingValue(value, env, fs3);
|
|
2185
1912
|
}
|
|
2186
1913
|
}
|
|
2187
1914
|
if (cliSettings.env) {
|
|
@@ -2190,21 +1917,21 @@ async function resolveCliSettings(cliSettings, env, readApiKey) {
|
|
|
2190
1917
|
if (typeof value === "string") {
|
|
2191
1918
|
resolvedEnv[key] = value;
|
|
2192
1919
|
} else {
|
|
2193
|
-
resolvedEnv[key] = await resolveCliSettingValue(value, env,
|
|
1920
|
+
resolvedEnv[key] = await resolveCliSettingValue(value, env, fs3);
|
|
2194
1921
|
}
|
|
2195
1922
|
}
|
|
2196
1923
|
result.env = resolvedEnv;
|
|
2197
1924
|
}
|
|
2198
1925
|
return result;
|
|
2199
1926
|
}
|
|
2200
|
-
async function resolveCliSettingValue(value, env,
|
|
1927
|
+
async function resolveCliSettingValue(value, env, fs3) {
|
|
2201
1928
|
if (isPoeApiKeyReference(value)) {
|
|
2202
1929
|
const resolved = env.getVariable("POE_API_KEY");
|
|
2203
1930
|
if (typeof resolved === "string" && resolved.trim().length > 0) {
|
|
2204
1931
|
return resolved;
|
|
2205
1932
|
}
|
|
2206
|
-
if (
|
|
2207
|
-
return await
|
|
1933
|
+
if (fs3) {
|
|
1934
|
+
return await resolvePoeApiKeyFromCredentials({ fs: fs3, env });
|
|
2208
1935
|
}
|
|
2209
1936
|
throw new Error(
|
|
2210
1937
|
'Missing Poe API key for CLI settings. Set "POE_API_KEY" or run "poe-code login".'
|
|
@@ -2245,16 +1972,17 @@ function expandHomeShortcut(env, input) {
|
|
|
2245
1972
|
var init_isolated_env = __esm({
|
|
2246
1973
|
"src/cli/isolated-env.ts"() {
|
|
2247
1974
|
"use strict";
|
|
2248
|
-
|
|
1975
|
+
init_src();
|
|
1976
|
+
init_credentials2();
|
|
2249
1977
|
}
|
|
2250
1978
|
});
|
|
2251
1979
|
|
|
2252
1980
|
// packages/agent-spawn/src/run-command.ts
|
|
2253
|
-
import { spawn
|
|
1981
|
+
import { spawn } from "node:child_process";
|
|
2254
1982
|
function runCommand(command, args, options) {
|
|
2255
1983
|
return new Promise((resolve) => {
|
|
2256
1984
|
const hasStdin = options?.stdin != null;
|
|
2257
|
-
const child =
|
|
1985
|
+
const child = spawn(command, args, {
|
|
2258
1986
|
stdio: [hasStdin ? "pipe" : "ignore", "pipe", "pipe"],
|
|
2259
1987
|
cwd: options?.cwd,
|
|
2260
1988
|
env: options?.env ? {
|
|
@@ -2457,7 +2185,7 @@ var init_registry = __esm({
|
|
|
2457
2185
|
});
|
|
2458
2186
|
|
|
2459
2187
|
// packages/agent-defs/src/index.ts
|
|
2460
|
-
var
|
|
2188
|
+
var init_src2 = __esm({
|
|
2461
2189
|
"packages/agent-defs/src/index.ts"() {
|
|
2462
2190
|
"use strict";
|
|
2463
2191
|
init_agents();
|
|
@@ -2682,7 +2410,7 @@ var allSpawnConfigs, lookup2;
|
|
|
2682
2410
|
var init_configs = __esm({
|
|
2683
2411
|
"packages/agent-spawn/src/configs/index.ts"() {
|
|
2684
2412
|
"use strict";
|
|
2685
|
-
|
|
2413
|
+
init_src2();
|
|
2686
2414
|
init_claude_code2();
|
|
2687
2415
|
init_codex2();
|
|
2688
2416
|
init_opencode2();
|
|
@@ -2717,7 +2445,7 @@ function resolveConfig(agentId) {
|
|
|
2717
2445
|
var init_resolve_config = __esm({
|
|
2718
2446
|
"packages/agent-spawn/src/configs/resolve-config.ts"() {
|
|
2719
2447
|
"use strict";
|
|
2720
|
-
|
|
2448
|
+
init_src2();
|
|
2721
2449
|
init_configs();
|
|
2722
2450
|
}
|
|
2723
2451
|
});
|
|
@@ -2800,7 +2528,7 @@ function buildCliArgs(config2, options, stdinMode) {
|
|
|
2800
2528
|
}
|
|
2801
2529
|
return args;
|
|
2802
2530
|
}
|
|
2803
|
-
async function
|
|
2531
|
+
async function spawn2(agentId, options, context) {
|
|
2804
2532
|
const { agentId: resolvedId, binaryName, spawnConfig } = resolveCliConfig(agentId);
|
|
2805
2533
|
const stdinMode = options.useStdin && spawnConfig.stdinMode ? spawnConfig.stdinMode : void 0;
|
|
2806
2534
|
const spawnArgs = buildCliArgs(spawnConfig, options, stdinMode);
|
|
@@ -3613,7 +3341,7 @@ var init_static = __esm({
|
|
|
3613
3341
|
});
|
|
3614
3342
|
|
|
3615
3343
|
// packages/design-system/src/index.ts
|
|
3616
|
-
var
|
|
3344
|
+
var init_src3 = __esm({
|
|
3617
3345
|
"packages/design-system/src/index.ts"() {
|
|
3618
3346
|
"use strict";
|
|
3619
3347
|
init_tokens();
|
|
@@ -3706,7 +3434,7 @@ async function renderAcpStream(events) {
|
|
|
3706
3434
|
var init_renderer = __esm({
|
|
3707
3435
|
"packages/agent-spawn/src/acp/renderer.ts"() {
|
|
3708
3436
|
"use strict";
|
|
3709
|
-
|
|
3437
|
+
init_src3();
|
|
3710
3438
|
}
|
|
3711
3439
|
});
|
|
3712
3440
|
|
|
@@ -3716,13 +3444,13 @@ function truncate2(text4, maxLength) {
|
|
|
3716
3444
|
if (maxLength <= 3) return text4.slice(0, maxLength);
|
|
3717
3445
|
return `${text4.slice(0, maxLength - 3)}...`;
|
|
3718
3446
|
}
|
|
3719
|
-
function
|
|
3447
|
+
function isNonEmptyString(value) {
|
|
3720
3448
|
return typeof value === "string" && value.length > 0;
|
|
3721
3449
|
}
|
|
3722
3450
|
function extractThreadId(value) {
|
|
3723
3451
|
if (!value || typeof value !== "object") return;
|
|
3724
3452
|
const obj = value;
|
|
3725
|
-
const maybeThreadId =
|
|
3453
|
+
const maybeThreadId = isNonEmptyString(obj.thread_id) && obj.thread_id || isNonEmptyString(obj.threadId) && obj.threadId || isNonEmptyString(obj.threadID) && obj.threadID || isNonEmptyString(obj.session_id) && obj.session_id || isNonEmptyString(obj.sessionId) && obj.sessionId || isNonEmptyString(obj.sessionID) && obj.sessionID;
|
|
3726
3454
|
return maybeThreadId || void 0;
|
|
3727
3455
|
}
|
|
3728
3456
|
var init_utils = __esm({
|
|
@@ -3768,7 +3496,7 @@ async function* adaptClaude(lines) {
|
|
|
3768
3496
|
continue;
|
|
3769
3497
|
}
|
|
3770
3498
|
const eventType = event.type;
|
|
3771
|
-
if (!
|
|
3499
|
+
if (!isNonEmptyString(eventType)) continue;
|
|
3772
3500
|
if (!emittedSessionStart) {
|
|
3773
3501
|
const threadId = extractThreadId(event);
|
|
3774
3502
|
emittedSessionStart = true;
|
|
@@ -3791,16 +3519,16 @@ async function* adaptClaude(lines) {
|
|
|
3791
3519
|
const item = block;
|
|
3792
3520
|
if (!item || typeof item !== "object") continue;
|
|
3793
3521
|
const blockType = item.type;
|
|
3794
|
-
if (!
|
|
3522
|
+
if (!isNonEmptyString(blockType)) continue;
|
|
3795
3523
|
if (eventType === "assistant") {
|
|
3796
|
-
if (blockType === "text" &&
|
|
3524
|
+
if (blockType === "text" && isNonEmptyString(item.text)) {
|
|
3797
3525
|
yield {
|
|
3798
3526
|
event: "agent_message",
|
|
3799
3527
|
text: item.text
|
|
3800
3528
|
};
|
|
3801
3529
|
continue;
|
|
3802
3530
|
}
|
|
3803
|
-
if (blockType === "tool_use" &&
|
|
3531
|
+
if (blockType === "tool_use" && isNonEmptyString(item.id) && isNonEmptyString(item.name)) {
|
|
3804
3532
|
const kind = TOOL_KIND_MAP[item.name] ?? "other";
|
|
3805
3533
|
toolKindsById.set(item.id, kind);
|
|
3806
3534
|
yield {
|
|
@@ -3814,25 +3542,25 @@ async function* adaptClaude(lines) {
|
|
|
3814
3542
|
continue;
|
|
3815
3543
|
}
|
|
3816
3544
|
if (eventType === "user") {
|
|
3817
|
-
if (!
|
|
3545
|
+
if (!isNonEmptyString(item.tool_use_id)) continue;
|
|
3818
3546
|
if (blockType !== "tool_result") continue;
|
|
3819
3547
|
const kind = toolKindsById.get(item.tool_use_id);
|
|
3820
3548
|
toolKindsById.delete(item.tool_use_id);
|
|
3821
|
-
let
|
|
3549
|
+
let path20;
|
|
3822
3550
|
if (typeof item.content === "string") {
|
|
3823
|
-
|
|
3551
|
+
path20 = item.content;
|
|
3824
3552
|
} else {
|
|
3825
3553
|
try {
|
|
3826
|
-
|
|
3554
|
+
path20 = JSON.stringify(item.content);
|
|
3827
3555
|
} catch {
|
|
3828
|
-
|
|
3556
|
+
path20 = String(item.content);
|
|
3829
3557
|
}
|
|
3830
3558
|
}
|
|
3831
3559
|
yield {
|
|
3832
3560
|
event: "tool_complete",
|
|
3833
3561
|
id: item.tool_use_id,
|
|
3834
3562
|
kind,
|
|
3835
|
-
path:
|
|
3563
|
+
path: path20
|
|
3836
3564
|
};
|
|
3837
3565
|
}
|
|
3838
3566
|
}
|
|
@@ -3886,7 +3614,7 @@ async function* adaptCodex(lines) {
|
|
|
3886
3614
|
continue;
|
|
3887
3615
|
}
|
|
3888
3616
|
const eventType = event.type;
|
|
3889
|
-
if (!
|
|
3617
|
+
if (!isNonEmptyString(eventType)) continue;
|
|
3890
3618
|
if (eventType === "thread.started") {
|
|
3891
3619
|
const maybeThreadId = extractThreadId(event);
|
|
3892
3620
|
yield { event: "session_start", threadId: maybeThreadId };
|
|
@@ -3910,23 +3638,23 @@ async function* adaptCodex(lines) {
|
|
|
3910
3638
|
const item = event.item ?? null;
|
|
3911
3639
|
if (!item || typeof item !== "object") continue;
|
|
3912
3640
|
const itemType = item.type;
|
|
3913
|
-
if (!
|
|
3641
|
+
if (!isNonEmptyString(itemType)) continue;
|
|
3914
3642
|
if (eventType === "item.started") {
|
|
3915
|
-
if (!
|
|
3643
|
+
if (!isNonEmptyString(item.id)) continue;
|
|
3916
3644
|
let kind;
|
|
3917
3645
|
let title;
|
|
3918
3646
|
if (itemType === "command_execution") {
|
|
3919
3647
|
kind = "exec";
|
|
3920
|
-
title = truncate2(
|
|
3648
|
+
title = truncate2(isNonEmptyString(item.command) ? item.command : "", 80);
|
|
3921
3649
|
} else if (itemType === "file_edit") {
|
|
3922
3650
|
kind = "edit";
|
|
3923
|
-
title =
|
|
3651
|
+
title = isNonEmptyString(item.path) ? item.path : "";
|
|
3924
3652
|
} else if (itemType === "thinking") {
|
|
3925
3653
|
kind = "think";
|
|
3926
3654
|
title = "thinking...";
|
|
3927
3655
|
} else if (itemType === "mcp_tool_call") {
|
|
3928
|
-
const server =
|
|
3929
|
-
const tool =
|
|
3656
|
+
const server = isNonEmptyString(item.server) ? item.server : "unknown";
|
|
3657
|
+
const tool = isNonEmptyString(item.tool) ? item.tool : "unknown";
|
|
3930
3658
|
kind = "other";
|
|
3931
3659
|
title = `${server}.${tool}`;
|
|
3932
3660
|
}
|
|
@@ -3939,25 +3667,25 @@ async function* adaptCodex(lines) {
|
|
|
3939
3667
|
}
|
|
3940
3668
|
if (eventType === "item.completed") {
|
|
3941
3669
|
if (itemType === "agent_message") {
|
|
3942
|
-
if (!
|
|
3670
|
+
if (!isNonEmptyString(item.text)) continue;
|
|
3943
3671
|
yield { event: "agent_message", text: item.text };
|
|
3944
3672
|
continue;
|
|
3945
3673
|
}
|
|
3946
3674
|
if (itemType === "reasoning") {
|
|
3947
|
-
const text4 =
|
|
3675
|
+
const text4 = isNonEmptyString(item.text) ? item.text : isNonEmptyString(item.content) ? item.content : isNonEmptyString(item.summary) ? item.summary : void 0;
|
|
3948
3676
|
if (!text4) continue;
|
|
3949
3677
|
yield { event: "reasoning", text: text4 };
|
|
3950
3678
|
continue;
|
|
3951
3679
|
}
|
|
3952
|
-
if (!
|
|
3680
|
+
if (!isNonEmptyString(item.id)) continue;
|
|
3953
3681
|
if (itemType === "command_execution" || itemType === "file_edit" || itemType === "mcp_tool_call") {
|
|
3954
3682
|
const kindFromStart = toolKindById.get(item.id);
|
|
3955
3683
|
const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
|
|
3956
|
-
const titleFromEvent =
|
|
3957
|
-
const
|
|
3684
|
+
const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
|
|
3685
|
+
const path20 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
|
|
3958
3686
|
toolTitleById.delete(item.id);
|
|
3959
3687
|
toolKindById.delete(item.id);
|
|
3960
|
-
yield { event: "tool_complete", id: item.id, kind, path:
|
|
3688
|
+
yield { event: "tool_complete", id: item.id, kind, path: path20 };
|
|
3961
3689
|
}
|
|
3962
3690
|
}
|
|
3963
3691
|
}
|
|
@@ -3996,9 +3724,9 @@ async function* adaptKimi(lines) {
|
|
|
3996
3724
|
}
|
|
3997
3725
|
}
|
|
3998
3726
|
const role = event.role;
|
|
3999
|
-
if (!
|
|
3727
|
+
if (!isNonEmptyString(role) || role !== "assistant") continue;
|
|
4000
3728
|
const content = event.content;
|
|
4001
|
-
if (!
|
|
3729
|
+
if (!isNonEmptyString(content)) continue;
|
|
4002
3730
|
yield { event: "agent_message", text: content };
|
|
4003
3731
|
}
|
|
4004
3732
|
}
|
|
@@ -4027,7 +3755,7 @@ async function* adaptNative(lines) {
|
|
|
4027
3755
|
continue;
|
|
4028
3756
|
}
|
|
4029
3757
|
const maybeEventType = event?.event;
|
|
4030
|
-
if (!
|
|
3758
|
+
if (!isNonEmptyString(maybeEventType)) {
|
|
4031
3759
|
yield {
|
|
4032
3760
|
event: "error",
|
|
4033
3761
|
message: `[adaptNative] Line missing string "event" field: ${truncate2(line, 200)}`
|
|
@@ -4086,23 +3814,23 @@ async function* adaptOpenCode(lines) {
|
|
|
4086
3814
|
}
|
|
4087
3815
|
if (!event || typeof event !== "object") continue;
|
|
4088
3816
|
const sessionID = extractThreadId(event);
|
|
4089
|
-
if (!emittedSessionStart &&
|
|
3817
|
+
if (!emittedSessionStart && isNonEmptyString(sessionID)) {
|
|
4090
3818
|
emittedSessionStart = true;
|
|
4091
3819
|
yield { event: "session_start", threadId: sessionID };
|
|
4092
3820
|
}
|
|
4093
3821
|
const eventType = event.type;
|
|
4094
|
-
if (!
|
|
3822
|
+
if (!isNonEmptyString(eventType)) continue;
|
|
4095
3823
|
if (eventType === "text") {
|
|
4096
3824
|
const part = event.part ?? null;
|
|
4097
3825
|
if (!part || typeof part !== "object") continue;
|
|
4098
|
-
if (!
|
|
3826
|
+
if (!isNonEmptyString(part.text)) continue;
|
|
4099
3827
|
yield { event: "agent_message", text: part.text };
|
|
4100
3828
|
continue;
|
|
4101
3829
|
}
|
|
4102
3830
|
if (eventType === "tool_use") {
|
|
4103
3831
|
const part = event.part ?? null;
|
|
4104
3832
|
if (!part || typeof part !== "object") continue;
|
|
4105
|
-
if (!
|
|
3833
|
+
if (!isNonEmptyString(part.callID) || !isNonEmptyString(part.tool)) continue;
|
|
4106
3834
|
const state = part.state ?? null;
|
|
4107
3835
|
if (!state || typeof state !== "object") continue;
|
|
4108
3836
|
const kind = guessToolKind(part.tool);
|
|
@@ -4114,7 +3842,7 @@ async function* adaptOpenCode(lines) {
|
|
|
4114
3842
|
const maybeInput = state.input;
|
|
4115
3843
|
if (kind === "exec" && maybeInput && typeof maybeInput === "object") {
|
|
4116
3844
|
const command = maybeInput.command;
|
|
4117
|
-
if (
|
|
3845
|
+
if (isNonEmptyString(command)) {
|
|
4118
3846
|
title = truncate2(command, 80);
|
|
4119
3847
|
}
|
|
4120
3848
|
}
|
|
@@ -4318,7 +4046,7 @@ var init_spawn2 = __esm({
|
|
|
4318
4046
|
});
|
|
4319
4047
|
|
|
4320
4048
|
// packages/agent-spawn/src/index.ts
|
|
4321
|
-
var
|
|
4049
|
+
var init_src4 = __esm({
|
|
4322
4050
|
"packages/agent-spawn/src/index.ts"() {
|
|
4323
4051
|
"use strict";
|
|
4324
4052
|
init_run_command();
|
|
@@ -4498,8 +4226,8 @@ var init_shared = __esm({
|
|
|
4498
4226
|
"use strict";
|
|
4499
4227
|
init_context();
|
|
4500
4228
|
init_isolated_env();
|
|
4501
|
-
|
|
4502
|
-
|
|
4229
|
+
init_src4();
|
|
4230
|
+
init_src2();
|
|
4503
4231
|
}
|
|
4504
4232
|
});
|
|
4505
4233
|
|
|
@@ -4620,7 +4348,7 @@ import path7 from "node:path";
|
|
|
4620
4348
|
function createCliEnvironment(init) {
|
|
4621
4349
|
const platform = init.platform ?? process.platform;
|
|
4622
4350
|
const variables = init.variables ?? process.env;
|
|
4623
|
-
const
|
|
4351
|
+
const credentialsPath = resolveCredentialsPath(init.homeDir);
|
|
4624
4352
|
const logDir = resolveLogDir(init.homeDir);
|
|
4625
4353
|
const { poeApiBaseUrl, poeBaseUrl } = resolvePoeBaseUrls(variables);
|
|
4626
4354
|
const resolveHomePath = (...segments) => path7.join(init.homeDir, ...segments);
|
|
@@ -4629,7 +4357,7 @@ function createCliEnvironment(init) {
|
|
|
4629
4357
|
cwd: init.cwd,
|
|
4630
4358
|
homeDir: init.homeDir,
|
|
4631
4359
|
platform,
|
|
4632
|
-
|
|
4360
|
+
credentialsPath,
|
|
4633
4361
|
logDir,
|
|
4634
4362
|
poeApiBaseUrl,
|
|
4635
4363
|
poeBaseUrl,
|
|
@@ -4638,8 +4366,8 @@ function createCliEnvironment(init) {
|
|
|
4638
4366
|
getVariable
|
|
4639
4367
|
};
|
|
4640
4368
|
}
|
|
4641
|
-
function
|
|
4642
|
-
return path7.join(homeDir, ".poe-code", "
|
|
4369
|
+
function resolveCredentialsPath(homeDir) {
|
|
4370
|
+
return path7.join(homeDir, ".poe-code", "credentials.json");
|
|
4643
4371
|
}
|
|
4644
4372
|
function resolveLogDir(homeDir) {
|
|
4645
4373
|
return path7.join(homeDir, ".poe-code", "logs");
|
|
@@ -4810,7 +4538,7 @@ function createServiceRegistry() {
|
|
|
4810
4538
|
var init_service_registry = __esm({
|
|
4811
4539
|
"src/cli/service-registry.ts"() {
|
|
4812
4540
|
"use strict";
|
|
4813
|
-
|
|
4541
|
+
init_src2();
|
|
4814
4542
|
}
|
|
4815
4543
|
});
|
|
4816
4544
|
|
|
@@ -5078,7 +4806,7 @@ function isSilentError(error2) {
|
|
|
5078
4806
|
}
|
|
5079
4807
|
return error2.name === "SilentError" || error2.name === "OperationCancelledError";
|
|
5080
4808
|
}
|
|
5081
|
-
var CliError, SilentError, ApiError, ValidationError, OperationCancelledError;
|
|
4809
|
+
var CliError, SilentError, ApiError, ValidationError, AuthenticationError, OperationCancelledError;
|
|
5082
4810
|
var init_errors = __esm({
|
|
5083
4811
|
"src/cli/errors.ts"() {
|
|
5084
4812
|
"use strict";
|
|
@@ -5118,6 +4846,11 @@ var init_errors = __esm({
|
|
|
5118
4846
|
super(message, context, { isUserError: true });
|
|
5119
4847
|
}
|
|
5120
4848
|
};
|
|
4849
|
+
AuthenticationError = class extends CliError {
|
|
4850
|
+
constructor(message, context) {
|
|
4851
|
+
super(message, context, { isUserError: true });
|
|
4852
|
+
}
|
|
4853
|
+
};
|
|
5121
4854
|
OperationCancelledError = class extends SilentError {
|
|
5122
4855
|
constructor(message = "Operation cancelled.") {
|
|
5123
4856
|
super(message, { isUserError: true });
|
|
@@ -5326,7 +5059,7 @@ function createLoggerFactory(emitter, theme) {
|
|
|
5326
5059
|
var init_logger2 = __esm({
|
|
5327
5060
|
"src/cli/logger.ts"() {
|
|
5328
5061
|
"use strict";
|
|
5329
|
-
|
|
5062
|
+
init_src3();
|
|
5330
5063
|
init_errors();
|
|
5331
5064
|
}
|
|
5332
5065
|
});
|
|
@@ -5714,7 +5447,7 @@ async function ensureIsolatedConfigForService(input) {
|
|
|
5714
5447
|
container.env,
|
|
5715
5448
|
isolated,
|
|
5716
5449
|
adapter.name,
|
|
5717
|
-
container.
|
|
5450
|
+
container.fs
|
|
5718
5451
|
);
|
|
5719
5452
|
const hasConfig = await isolatedConfigExists(
|
|
5720
5453
|
container.fs,
|
|
@@ -5789,7 +5522,7 @@ function createPoeCodeCommandRunner(input) {
|
|
|
5789
5522
|
container.env,
|
|
5790
5523
|
adapter.isolatedEnv,
|
|
5791
5524
|
adapter.name,
|
|
5792
|
-
container.
|
|
5525
|
+
container.fs
|
|
5793
5526
|
);
|
|
5794
5527
|
if (adapter.isolatedEnv.requiresConfig !== false) {
|
|
5795
5528
|
const hasConfig = await isolatedConfigExists(
|
|
@@ -5820,7 +5553,7 @@ function createPoeCodeCommandRunner(input) {
|
|
|
5820
5553
|
const resolvedSettings = await resolveCliSettings(
|
|
5821
5554
|
adapter.isolatedEnv.cliSettings,
|
|
5822
5555
|
container.env,
|
|
5823
|
-
container.
|
|
5556
|
+
container.fs
|
|
5824
5557
|
);
|
|
5825
5558
|
forwarded = buildArgsWithMergedSettings(forwarded, resolvedSettings);
|
|
5826
5559
|
}
|
|
@@ -5849,11 +5582,11 @@ var init_poe_code_command_runner = __esm({
|
|
|
5849
5582
|
|
|
5850
5583
|
// src/sdk/container.ts
|
|
5851
5584
|
import * as fs2 from "node:fs/promises";
|
|
5852
|
-
import * as
|
|
5585
|
+
import * as os2 from "node:os";
|
|
5853
5586
|
import * as nodeFsSync from "node:fs";
|
|
5854
5587
|
function createSdkContainer(options) {
|
|
5855
5588
|
const cwd = options?.cwd ?? process.cwd();
|
|
5856
|
-
const homeDir = options?.homeDir ??
|
|
5589
|
+
const homeDir = options?.homeDir ?? os2.homedir();
|
|
5857
5590
|
const variables = options?.variables ?? process.env;
|
|
5858
5591
|
const verbose = options?.verbose ?? false;
|
|
5859
5592
|
const environment = createCliEnvironment({
|
|
@@ -5872,44 +5605,23 @@ function createSdkContainer(options) {
|
|
|
5872
5605
|
});
|
|
5873
5606
|
loggerFactory.setErrorLogger(errorLogger);
|
|
5874
5607
|
const asyncFs = {
|
|
5875
|
-
readFile: ((
|
|
5608
|
+
readFile: ((path20, encoding) => {
|
|
5876
5609
|
if (encoding) {
|
|
5877
|
-
return fs2.readFile(
|
|
5610
|
+
return fs2.readFile(path20, encoding);
|
|
5878
5611
|
}
|
|
5879
|
-
return fs2.readFile(
|
|
5612
|
+
return fs2.readFile(path20);
|
|
5880
5613
|
}),
|
|
5881
|
-
writeFile: (
|
|
5882
|
-
mkdir: (
|
|
5614
|
+
writeFile: (path20, data, opts) => fs2.writeFile(path20, data, opts),
|
|
5615
|
+
mkdir: (path20, opts) => fs2.mkdir(path20, opts).then(() => {
|
|
5883
5616
|
}),
|
|
5884
|
-
stat: (
|
|
5885
|
-
rm: (
|
|
5886
|
-
unlink: (
|
|
5887
|
-
readdir: (
|
|
5617
|
+
stat: (path20) => fs2.stat(path20),
|
|
5618
|
+
rm: (path20, opts) => fs2.rm(path20, opts),
|
|
5619
|
+
unlink: (path20) => fs2.unlink(path20),
|
|
5620
|
+
readdir: (path20) => fs2.readdir(path20),
|
|
5888
5621
|
copyFile: (src, dest) => fs2.copyFile(src, dest),
|
|
5889
|
-
chmod: (
|
|
5622
|
+
chmod: (path20, mode) => fs2.chmod(path20, mode)
|
|
5890
5623
|
};
|
|
5891
5624
|
const contextFactory = createCommandContextFactory({ fs: asyncFs });
|
|
5892
|
-
const authFs = {
|
|
5893
|
-
readFile: (filePath, encoding) => fs2.readFile(filePath, encoding),
|
|
5894
|
-
writeFile: (filePath, data, options2) => fs2.writeFile(filePath, data, options2),
|
|
5895
|
-
mkdir: (directoryPath, options2) => fs2.mkdir(directoryPath, options2).then(() => void 0),
|
|
5896
|
-
unlink: (filePath) => fs2.unlink(filePath),
|
|
5897
|
-
chmod: (filePath, mode) => fs2.chmod(filePath, mode)
|
|
5898
|
-
};
|
|
5899
|
-
const { store: authStore } = createAuthStore({
|
|
5900
|
-
env: variables,
|
|
5901
|
-
platform: process.platform,
|
|
5902
|
-
fileStore: {
|
|
5903
|
-
fs: authFs,
|
|
5904
|
-
getHomeDirectory: () => homeDir
|
|
5905
|
-
},
|
|
5906
|
-
legacyCredentials: {
|
|
5907
|
-
fs: authFs,
|
|
5908
|
-
getHomeDirectory: () => homeDir
|
|
5909
|
-
}
|
|
5910
|
-
});
|
|
5911
|
-
const readApiKey = authStore.getApiKey.bind(authStore);
|
|
5912
|
-
const writeApiKey = authStore.setApiKey.bind(authStore);
|
|
5913
5625
|
const noopPrompts = async () => {
|
|
5914
5626
|
throw new Error("SDK does not support interactive prompts");
|
|
5915
5627
|
};
|
|
@@ -5918,8 +5630,15 @@ function createSdkContainer(options) {
|
|
|
5918
5630
|
prompts: noopPrompts,
|
|
5919
5631
|
promptLibrary,
|
|
5920
5632
|
apiKeyStore: {
|
|
5921
|
-
read:
|
|
5922
|
-
|
|
5633
|
+
read: () => loadCredentials({
|
|
5634
|
+
fs: asyncFs,
|
|
5635
|
+
filePath: environment.credentialsPath
|
|
5636
|
+
}),
|
|
5637
|
+
write: (value) => saveCredentials({
|
|
5638
|
+
fs: asyncFs,
|
|
5639
|
+
filePath: environment.credentialsPath,
|
|
5640
|
+
apiKey: value
|
|
5641
|
+
})
|
|
5923
5642
|
},
|
|
5924
5643
|
confirm: async () => true
|
|
5925
5644
|
});
|
|
@@ -5966,9 +5685,7 @@ function createSdkContainer(options) {
|
|
|
5966
5685
|
platform: process.platform,
|
|
5967
5686
|
variables
|
|
5968
5687
|
}
|
|
5969
|
-
}
|
|
5970
|
-
readApiKey,
|
|
5971
|
-
writeApiKey
|
|
5688
|
+
}
|
|
5972
5689
|
};
|
|
5973
5690
|
return container;
|
|
5974
5691
|
}
|
|
@@ -5982,15 +5699,15 @@ var init_container = __esm({
|
|
|
5982
5699
|
init_options();
|
|
5983
5700
|
init_logger2();
|
|
5984
5701
|
init_error_logger();
|
|
5985
|
-
|
|
5702
|
+
init_src4();
|
|
5986
5703
|
await init_providers();
|
|
5987
5704
|
init_poe_code_command_runner();
|
|
5988
|
-
|
|
5705
|
+
init_credentials2();
|
|
5989
5706
|
}
|
|
5990
5707
|
});
|
|
5991
5708
|
|
|
5992
5709
|
// src/sdk/spawn.ts
|
|
5993
|
-
function
|
|
5710
|
+
function spawn3(service, promptOrOptions, maybeOptions) {
|
|
5994
5711
|
const options = typeof promptOrOptions === "string" ? { ...maybeOptions, prompt: promptOrOptions } : promptOrOptions;
|
|
5995
5712
|
const emptyEvents = (async function* () {
|
|
5996
5713
|
})();
|
|
@@ -6053,7 +5770,7 @@ function spawn4(service, promptOrOptions, maybeOptions) {
|
|
|
6053
5770
|
}
|
|
6054
5771
|
if (spawnConfig && spawnConfig.kind === "cli") {
|
|
6055
5772
|
resolveEventsOnce(emptyEvents);
|
|
6056
|
-
return
|
|
5773
|
+
return spawn2(service, {
|
|
6057
5774
|
prompt: options.prompt,
|
|
6058
5775
|
cwd: options.cwd,
|
|
6059
5776
|
model: options.model,
|
|
@@ -6087,9 +5804,9 @@ var init_spawn3 = __esm({
|
|
|
6087
5804
|
init_credentials();
|
|
6088
5805
|
init_spawn_core();
|
|
6089
5806
|
await init_container();
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
const { events, result } =
|
|
5807
|
+
init_src4();
|
|
5808
|
+
spawn3.pretty = async function pretty(service, promptOrOptions, maybeOptions) {
|
|
5809
|
+
const { events, result } = spawn3(service, promptOrOptions, maybeOptions);
|
|
6093
5810
|
await renderAcpStream(events);
|
|
6094
5811
|
return result;
|
|
6095
5812
|
};
|
|
@@ -6160,13 +5877,13 @@ async function readErrorBody(response) {
|
|
|
6160
5877
|
}
|
|
6161
5878
|
}
|
|
6162
5879
|
function extractTextContent(data) {
|
|
6163
|
-
if (!
|
|
5880
|
+
if (!isRecord2(data)) return void 0;
|
|
6164
5881
|
const choices = data.choices;
|
|
6165
5882
|
if (!Array.isArray(choices) || choices.length === 0) return void 0;
|
|
6166
5883
|
const first = choices[0];
|
|
6167
|
-
if (!
|
|
5884
|
+
if (!isRecord2(first)) return void 0;
|
|
6168
5885
|
const message = first.message;
|
|
6169
|
-
if (!
|
|
5886
|
+
if (!isRecord2(message)) return void 0;
|
|
6170
5887
|
return typeof message.content === "string" ? message.content : void 0;
|
|
6171
5888
|
}
|
|
6172
5889
|
function extractMediaFromCompletion(data) {
|
|
@@ -6174,14 +5891,14 @@ function extractMediaFromCompletion(data) {
|
|
|
6174
5891
|
if (!content) return {};
|
|
6175
5892
|
try {
|
|
6176
5893
|
const parsed = JSON.parse(content);
|
|
6177
|
-
if (
|
|
5894
|
+
if (isRecord2(parsed) && typeof parsed.url === "string") {
|
|
6178
5895
|
return {
|
|
6179
5896
|
url: parsed.url,
|
|
6180
5897
|
mimeType: typeof parsed.mimeType === "string" ? parsed.mimeType : void 0,
|
|
6181
5898
|
data: typeof parsed.data === "string" ? parsed.data : void 0
|
|
6182
5899
|
};
|
|
6183
5900
|
}
|
|
6184
|
-
if (
|
|
5901
|
+
if (isRecord2(parsed) && typeof parsed.data === "string") {
|
|
6185
5902
|
return {
|
|
6186
5903
|
data: parsed.data,
|
|
6187
5904
|
mimeType: typeof parsed.mimeType === "string" ? parsed.mimeType : void 0
|
|
@@ -6215,7 +5932,7 @@ function isValidUrl(value) {
|
|
|
6215
5932
|
return false;
|
|
6216
5933
|
}
|
|
6217
5934
|
}
|
|
6218
|
-
function
|
|
5935
|
+
function isRecord2(value) {
|
|
6219
5936
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
6220
5937
|
}
|
|
6221
5938
|
var init_llm_client = __esm({
|
|
@@ -6239,8 +5956,17 @@ async function initializeClient(options) {
|
|
|
6239
5956
|
if (globalClient !== null) {
|
|
6240
5957
|
return;
|
|
6241
5958
|
}
|
|
5959
|
+
const apiKey = await loadCredentials({
|
|
5960
|
+
fs: options.fs,
|
|
5961
|
+
filePath: options.credentialsPath
|
|
5962
|
+
});
|
|
5963
|
+
if (!apiKey) {
|
|
5964
|
+
throw new AuthenticationError(
|
|
5965
|
+
"Poe API key not found. Run 'poe-code login' first."
|
|
5966
|
+
);
|
|
5967
|
+
}
|
|
6242
5968
|
const client = createPoeClient({
|
|
6243
|
-
apiKey
|
|
5969
|
+
apiKey,
|
|
6244
5970
|
baseUrl: options.baseUrl,
|
|
6245
5971
|
httpClient: options.httpClient
|
|
6246
5972
|
});
|
|
@@ -6250,6 +5976,8 @@ var globalClient;
|
|
|
6250
5976
|
var init_client_instance = __esm({
|
|
6251
5977
|
"src/services/client-instance.ts"() {
|
|
6252
5978
|
"use strict";
|
|
5979
|
+
init_errors();
|
|
5980
|
+
init_credentials2();
|
|
6253
5981
|
init_llm_client();
|
|
6254
5982
|
globalClient = null;
|
|
6255
5983
|
}
|
|
@@ -6290,33 +6018,19 @@ function createCliContainer(dependencies) {
|
|
|
6290
6018
|
});
|
|
6291
6019
|
const commandRunner = dependencies.commandRunner ?? runCommand;
|
|
6292
6020
|
const promptLibrary = createPromptLibrary();
|
|
6293
|
-
const authFs = {
|
|
6294
|
-
readFile: (filePath, encoding) => dependencies.fs.readFile(filePath, encoding),
|
|
6295
|
-
writeFile: (filePath, data, opts) => dependencies.fs.writeFile(filePath, data, opts),
|
|
6296
|
-
mkdir: (directoryPath, opts) => dependencies.fs.mkdir(directoryPath, opts).then(() => void 0),
|
|
6297
|
-
unlink: (filePath) => dependencies.fs.unlink(filePath),
|
|
6298
|
-
chmod: (filePath, mode) => dependencies.fs.chmod ? dependencies.fs.chmod(filePath, mode) : Promise.resolve()
|
|
6299
|
-
};
|
|
6300
|
-
const { store: authStore } = createAuthStore({
|
|
6301
|
-
env: dependencies.env.variables,
|
|
6302
|
-
platform: dependencies.env.platform,
|
|
6303
|
-
fileStore: {
|
|
6304
|
-
fs: authFs,
|
|
6305
|
-
getHomeDirectory: () => dependencies.env.homeDir
|
|
6306
|
-
},
|
|
6307
|
-
legacyCredentials: {
|
|
6308
|
-
fs: authFs,
|
|
6309
|
-
getHomeDirectory: () => dependencies.env.homeDir
|
|
6310
|
-
}
|
|
6311
|
-
});
|
|
6312
|
-
const readApiKey = authStore.getApiKey.bind(authStore);
|
|
6313
|
-
const writeApiKey = authStore.setApiKey.bind(authStore);
|
|
6314
6021
|
const options = createOptionResolvers({
|
|
6315
6022
|
prompts: dependencies.prompts,
|
|
6316
6023
|
promptLibrary,
|
|
6317
6024
|
apiKeyStore: {
|
|
6318
|
-
read:
|
|
6319
|
-
|
|
6025
|
+
read: () => loadCredentials({
|
|
6026
|
+
fs: dependencies.fs,
|
|
6027
|
+
filePath: environment.credentialsPath
|
|
6028
|
+
}),
|
|
6029
|
+
write: (value) => saveCredentials({
|
|
6030
|
+
fs: dependencies.fs,
|
|
6031
|
+
filePath: environment.credentialsPath,
|
|
6032
|
+
apiKey: value
|
|
6033
|
+
})
|
|
6320
6034
|
},
|
|
6321
6035
|
confirm: async (message) => {
|
|
6322
6036
|
const result = await confirm2({ message });
|
|
@@ -6352,16 +6066,14 @@ function createCliContainer(dependencies) {
|
|
|
6352
6066
|
httpClient,
|
|
6353
6067
|
commandRunner: wrappedRunner,
|
|
6354
6068
|
providers,
|
|
6355
|
-
dependencies
|
|
6356
|
-
readApiKey,
|
|
6357
|
-
writeApiKey
|
|
6069
|
+
dependencies
|
|
6358
6070
|
};
|
|
6359
6071
|
return container;
|
|
6360
6072
|
}
|
|
6361
6073
|
var init_container2 = __esm({
|
|
6362
6074
|
async "src/cli/container.ts"() {
|
|
6363
6075
|
"use strict";
|
|
6364
|
-
|
|
6076
|
+
init_credentials2();
|
|
6365
6077
|
init_environment();
|
|
6366
6078
|
init_service_registry();
|
|
6367
6079
|
init_context();
|
|
@@ -6369,176 +6081,14 @@ var init_container2 = __esm({
|
|
|
6369
6081
|
init_options();
|
|
6370
6082
|
init_logger2();
|
|
6371
6083
|
init_error_logger();
|
|
6372
|
-
init_src5();
|
|
6373
6084
|
init_src4();
|
|
6085
|
+
init_src3();
|
|
6374
6086
|
await init_providers();
|
|
6375
6087
|
init_poe_code_command_runner();
|
|
6376
6088
|
init_errors();
|
|
6377
6089
|
}
|
|
6378
6090
|
});
|
|
6379
6091
|
|
|
6380
|
-
// src/services/config.ts
|
|
6381
|
-
import path10 from "node:path";
|
|
6382
|
-
async function deleteConfig(options) {
|
|
6383
|
-
const { fs: fs3, filePath } = options;
|
|
6384
|
-
try {
|
|
6385
|
-
await fs3.unlink(filePath);
|
|
6386
|
-
return true;
|
|
6387
|
-
} catch (error2) {
|
|
6388
|
-
if (isNotFound(error2)) {
|
|
6389
|
-
return false;
|
|
6390
|
-
}
|
|
6391
|
-
throw error2;
|
|
6392
|
-
}
|
|
6393
|
-
}
|
|
6394
|
-
async function loadConfiguredServices(options) {
|
|
6395
|
-
const { fs: fs3, filePath } = options;
|
|
6396
|
-
const document = await readConfigDocument(fs3, filePath);
|
|
6397
|
-
return { ...document.configured_services ?? {} };
|
|
6398
|
-
}
|
|
6399
|
-
async function saveConfiguredService(options) {
|
|
6400
|
-
const { fs: fs3, filePath, service, metadata } = options;
|
|
6401
|
-
const document = await readConfigDocument(fs3, filePath);
|
|
6402
|
-
const normalized = normalizeConfiguredServiceMetadata(metadata);
|
|
6403
|
-
document.configured_services = {
|
|
6404
|
-
...document.configured_services ?? {},
|
|
6405
|
-
[service]: normalized
|
|
6406
|
-
};
|
|
6407
|
-
await writeConfigDocument(fs3, filePath, document);
|
|
6408
|
-
}
|
|
6409
|
-
async function unconfigureService(options) {
|
|
6410
|
-
const { fs: fs3, filePath, service } = options;
|
|
6411
|
-
const document = await readConfigDocument(fs3, filePath);
|
|
6412
|
-
const services = document.configured_services;
|
|
6413
|
-
if (!services || !(service in services)) {
|
|
6414
|
-
return false;
|
|
6415
|
-
}
|
|
6416
|
-
delete services[service];
|
|
6417
|
-
if (Object.keys(services).length === 0) {
|
|
6418
|
-
delete document.configured_services;
|
|
6419
|
-
}
|
|
6420
|
-
await writeConfigDocument(fs3, filePath, document);
|
|
6421
|
-
return true;
|
|
6422
|
-
}
|
|
6423
|
-
function normalizeConfiguredServiceMetadata(metadata) {
|
|
6424
|
-
const seen = /* @__PURE__ */ new Set();
|
|
6425
|
-
const files = [];
|
|
6426
|
-
for (const entry of metadata.files ?? []) {
|
|
6427
|
-
if (typeof entry !== "string" || entry.length === 0) {
|
|
6428
|
-
continue;
|
|
6429
|
-
}
|
|
6430
|
-
if (!seen.has(entry)) {
|
|
6431
|
-
files.push(entry);
|
|
6432
|
-
seen.add(entry);
|
|
6433
|
-
}
|
|
6434
|
-
}
|
|
6435
|
-
return {
|
|
6436
|
-
files
|
|
6437
|
-
};
|
|
6438
|
-
}
|
|
6439
|
-
async function readConfigDocument(fs3, filePath) {
|
|
6440
|
-
try {
|
|
6441
|
-
const raw = await fs3.readFile(filePath, "utf8");
|
|
6442
|
-
return await parseConfigDocument(fs3, filePath, raw);
|
|
6443
|
-
} catch (error2) {
|
|
6444
|
-
if (isNotFound(error2)) {
|
|
6445
|
-
return migrateLegacyCredentialsFile(fs3, filePath);
|
|
6446
|
-
}
|
|
6447
|
-
throw error2;
|
|
6448
|
-
}
|
|
6449
|
-
}
|
|
6450
|
-
async function migrateLegacyCredentialsFile(fs3, configPath) {
|
|
6451
|
-
const legacyPath = path10.join(path10.dirname(configPath), "credentials.json");
|
|
6452
|
-
try {
|
|
6453
|
-
const raw = await fs3.readFile(legacyPath, "utf8");
|
|
6454
|
-
const document = await parseConfigDocument(fs3, legacyPath, raw);
|
|
6455
|
-
await writeConfigDocument(fs3, configPath, document);
|
|
6456
|
-
await fs3.unlink(legacyPath);
|
|
6457
|
-
return document;
|
|
6458
|
-
} catch {
|
|
6459
|
-
return {};
|
|
6460
|
-
}
|
|
6461
|
-
}
|
|
6462
|
-
async function parseConfigDocument(fs3, filePath, raw) {
|
|
6463
|
-
try {
|
|
6464
|
-
const parsed = JSON.parse(raw);
|
|
6465
|
-
return normalizeConfigDocument(parsed);
|
|
6466
|
-
} catch (error2) {
|
|
6467
|
-
if (error2 instanceof SyntaxError) {
|
|
6468
|
-
await recoverInvalidConfig(fs3, filePath, raw);
|
|
6469
|
-
return {};
|
|
6470
|
-
}
|
|
6471
|
-
throw error2;
|
|
6472
|
-
}
|
|
6473
|
-
}
|
|
6474
|
-
function normalizeConfigDocument(value) {
|
|
6475
|
-
if (!isRecord4(value)) {
|
|
6476
|
-
return {};
|
|
6477
|
-
}
|
|
6478
|
-
const document = {};
|
|
6479
|
-
if (typeof value.apiKey === "string" && value.apiKey.length > 0) {
|
|
6480
|
-
document.apiKey = value.apiKey;
|
|
6481
|
-
}
|
|
6482
|
-
const services = normalizeConfiguredServices(value.configured_services);
|
|
6483
|
-
if (Object.keys(services).length > 0) {
|
|
6484
|
-
document.configured_services = services;
|
|
6485
|
-
}
|
|
6486
|
-
return document;
|
|
6487
|
-
}
|
|
6488
|
-
function normalizeConfiguredServices(value) {
|
|
6489
|
-
if (!isRecord4(value)) {
|
|
6490
|
-
return {};
|
|
6491
|
-
}
|
|
6492
|
-
const entries = {};
|
|
6493
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
6494
|
-
if (!isRecord4(entry)) {
|
|
6495
|
-
continue;
|
|
6496
|
-
}
|
|
6497
|
-
const normalized = normalizeConfiguredServiceMetadata({
|
|
6498
|
-
files: Array.isArray(entry.files) ? entry.files : []
|
|
6499
|
-
});
|
|
6500
|
-
entries[key] = normalized;
|
|
6501
|
-
}
|
|
6502
|
-
return entries;
|
|
6503
|
-
}
|
|
6504
|
-
async function writeConfigDocument(fs3, filePath, document) {
|
|
6505
|
-
await fs3.mkdir(path10.dirname(filePath), { recursive: true });
|
|
6506
|
-
const payload = {};
|
|
6507
|
-
if (document.apiKey) {
|
|
6508
|
-
payload.apiKey = document.apiKey;
|
|
6509
|
-
}
|
|
6510
|
-
if (document.configured_services) {
|
|
6511
|
-
payload.configured_services = document.configured_services;
|
|
6512
|
-
}
|
|
6513
|
-
await fs3.writeFile(filePath, `${JSON.stringify(payload, null, 2)}
|
|
6514
|
-
`, {
|
|
6515
|
-
encoding: "utf8"
|
|
6516
|
-
});
|
|
6517
|
-
}
|
|
6518
|
-
async function recoverInvalidConfig(fs3, filePath, content) {
|
|
6519
|
-
const backupPath = createInvalidBackupPath(filePath);
|
|
6520
|
-
await fs3.writeFile(backupPath, content, { encoding: "utf8" });
|
|
6521
|
-
await fs3.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
|
|
6522
|
-
}
|
|
6523
|
-
function createInvalidBackupPath(filePath) {
|
|
6524
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
6525
|
-
const dir = path10.dirname(filePath);
|
|
6526
|
-
const base = path10.basename(filePath);
|
|
6527
|
-
return path10.join(dir, `${base}.invalid-${timestamp}.json`);
|
|
6528
|
-
}
|
|
6529
|
-
function isRecord4(value) {
|
|
6530
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
6531
|
-
}
|
|
6532
|
-
var EMPTY_DOCUMENT;
|
|
6533
|
-
var init_config = __esm({
|
|
6534
|
-
"src/services/config.ts"() {
|
|
6535
|
-
"use strict";
|
|
6536
|
-
init_src2();
|
|
6537
|
-
EMPTY_DOCUMENT = `${JSON.stringify({}, null, 2)}
|
|
6538
|
-
`;
|
|
6539
|
-
}
|
|
6540
|
-
});
|
|
6541
|
-
|
|
6542
6092
|
// src/cli/commands/configure.ts
|
|
6543
6093
|
function registerConfigureCommand(program, container) {
|
|
6544
6094
|
const serviceNames = container.registry.list().map((service) => service.name);
|
|
@@ -6603,7 +6153,7 @@ async function executeConfigure(program, container, service, options) {
|
|
|
6603
6153
|
if (!flags.dryRun) {
|
|
6604
6154
|
await saveConfiguredService({
|
|
6605
6155
|
fs: container.fs,
|
|
6606
|
-
filePath: providerContext.env.
|
|
6156
|
+
filePath: providerContext.env.credentialsPath,
|
|
6607
6157
|
service: canonicalService,
|
|
6608
6158
|
metadata: {
|
|
6609
6159
|
files: tracker.files()
|
|
@@ -6703,7 +6253,7 @@ var init_configure = __esm({
|
|
|
6703
6253
|
"use strict";
|
|
6704
6254
|
init_shared();
|
|
6705
6255
|
init_errors();
|
|
6706
|
-
|
|
6256
|
+
init_credentials2();
|
|
6707
6257
|
init_mutation_events();
|
|
6708
6258
|
init_configure_payload();
|
|
6709
6259
|
serviceSelectionPrompt = (action) => `Pick an agent to ${action}:`;
|
|
@@ -6711,7 +6261,7 @@ var init_configure = __esm({
|
|
|
6711
6261
|
});
|
|
6712
6262
|
|
|
6713
6263
|
// src/cli/commands/spawn.ts
|
|
6714
|
-
import
|
|
6264
|
+
import path10 from "node:path";
|
|
6715
6265
|
function registerSpawnCommand(program, container, options = {}) {
|
|
6716
6266
|
const spawnServices = container.registry.list().filter((service) => typeof service.spawn === "function" || getSpawnConfig(service.name)).map((service) => service.name);
|
|
6717
6267
|
const extraServices = options.extraServices ?? [];
|
|
@@ -6843,7 +6393,7 @@ function registerSpawnCommand(program, container, options = {}) {
|
|
|
6843
6393
|
if (!proceed) {
|
|
6844
6394
|
return;
|
|
6845
6395
|
}
|
|
6846
|
-
const { events, result } =
|
|
6396
|
+
const { events, result } = spawn3(canonicalService, {
|
|
6847
6397
|
prompt: spawnOptions.prompt,
|
|
6848
6398
|
args: spawnOptions.args,
|
|
6849
6399
|
model: spawnOptions.model,
|
|
@@ -6890,7 +6440,7 @@ Resume: ${resumeCommand}`));
|
|
|
6890
6440
|
async function confirmUnconfiguredService(container, service, label, flags) {
|
|
6891
6441
|
const configuredServices = await loadConfiguredServices({
|
|
6892
6442
|
fs: container.fs,
|
|
6893
|
-
filePath: container.env.
|
|
6443
|
+
filePath: container.env.credentialsPath
|
|
6894
6444
|
});
|
|
6895
6445
|
if (service in configuredServices) {
|
|
6896
6446
|
return true;
|
|
@@ -6910,10 +6460,10 @@ function resolveSpawnWorkingDirectory2(baseDir, candidate) {
|
|
|
6910
6460
|
if (!candidate || candidate.trim().length === 0) {
|
|
6911
6461
|
return void 0;
|
|
6912
6462
|
}
|
|
6913
|
-
if (
|
|
6463
|
+
if (path10.isAbsolute(candidate)) {
|
|
6914
6464
|
return candidate;
|
|
6915
6465
|
}
|
|
6916
|
-
return
|
|
6466
|
+
return path10.resolve(baseDir, candidate);
|
|
6917
6467
|
}
|
|
6918
6468
|
function parseMcpSpawnConfig(input) {
|
|
6919
6469
|
if (!input) {
|
|
@@ -7006,9 +6556,9 @@ function isObjectRecord(value) {
|
|
|
7006
6556
|
var init_spawn4 = __esm({
|
|
7007
6557
|
async "src/cli/commands/spawn.ts"() {
|
|
7008
6558
|
"use strict";
|
|
7009
|
-
init_src5();
|
|
7010
6559
|
init_src4();
|
|
7011
|
-
|
|
6560
|
+
init_src3();
|
|
6561
|
+
init_credentials2();
|
|
7012
6562
|
init_shared();
|
|
7013
6563
|
init_spawn_core();
|
|
7014
6564
|
await init_spawn3();
|
|
@@ -7017,7 +6567,7 @@ var init_spawn4 = __esm({
|
|
|
7017
6567
|
});
|
|
7018
6568
|
|
|
7019
6569
|
// src/sdk/research.ts
|
|
7020
|
-
import
|
|
6570
|
+
import path11 from "node:path";
|
|
7021
6571
|
async function research(container, options) {
|
|
7022
6572
|
const logger2 = options.logger;
|
|
7023
6573
|
const source = await resolveSource({
|
|
@@ -7027,7 +6577,7 @@ async function research(container, options) {
|
|
|
7027
6577
|
});
|
|
7028
6578
|
const researchPrompt = buildResearchPrompt(options.prompt);
|
|
7029
6579
|
const mode = options.mode ?? "read";
|
|
7030
|
-
const { events, result } =
|
|
6580
|
+
const { events, result } = spawn3(options.agent, {
|
|
7031
6581
|
prompt: researchPrompt,
|
|
7032
6582
|
args: options.args ?? [],
|
|
7033
6583
|
model: options.model,
|
|
@@ -7052,7 +6602,7 @@ async function research(container, options) {
|
|
|
7052
6602
|
markdown: markdownOutput
|
|
7053
6603
|
});
|
|
7054
6604
|
outputPath = buildOutputPath(container.env.homeDir, options.prompt);
|
|
7055
|
-
await ensureDirectory2(container.fs,
|
|
6605
|
+
await ensureDirectory2(container.fs, path11.dirname(outputPath));
|
|
7056
6606
|
await container.fs.writeFile(outputPath, document, {
|
|
7057
6607
|
encoding: "utf8"
|
|
7058
6608
|
});
|
|
@@ -7127,7 +6677,7 @@ function buildResearchDocument(input) {
|
|
|
7127
6677
|
}
|
|
7128
6678
|
function buildClonePath(homeDir, github) {
|
|
7129
6679
|
const slug = extractRepoSlug(github);
|
|
7130
|
-
return
|
|
6680
|
+
return path11.join(homeDir, ".poe-code", "repos", slug);
|
|
7131
6681
|
}
|
|
7132
6682
|
function extractRepoSlug(value) {
|
|
7133
6683
|
const trimmed = value.trim();
|
|
@@ -7165,7 +6715,7 @@ function extractRepoSlug(value) {
|
|
|
7165
6715
|
function buildOutputPath(homeDir, prompt, now = /* @__PURE__ */ new Date()) {
|
|
7166
6716
|
const timestamp = formatTimestamp(now);
|
|
7167
6717
|
const slug = buildSlug(prompt);
|
|
7168
|
-
return
|
|
6718
|
+
return path11.join(
|
|
7169
6719
|
homeDir,
|
|
7170
6720
|
".poe-code",
|
|
7171
6721
|
"research",
|
|
@@ -7186,7 +6736,7 @@ async function resolveSource(input) {
|
|
|
7186
6736
|
if (options.github) {
|
|
7187
6737
|
const cloneUrl = resolveGithubCloneUrl(options.github);
|
|
7188
6738
|
const clonePath = buildClonePath(container.env.homeDir, options.github);
|
|
7189
|
-
await ensureDirectory2(container.fs,
|
|
6739
|
+
await ensureDirectory2(container.fs, path11.dirname(clonePath));
|
|
7190
6740
|
const exists = await pathExists2(container.fs, clonePath);
|
|
7191
6741
|
if (!exists) {
|
|
7192
6742
|
const cloneResult = await container.commandRunner(
|
|
@@ -7284,10 +6834,10 @@ function formatYamlString(value) {
|
|
|
7284
6834
|
return JSON.stringify(value);
|
|
7285
6835
|
}
|
|
7286
6836
|
function resolvePath2(baseDir, candidate) {
|
|
7287
|
-
if (
|
|
6837
|
+
if (path11.isAbsolute(candidate)) {
|
|
7288
6838
|
return candidate;
|
|
7289
6839
|
}
|
|
7290
|
-
return
|
|
6840
|
+
return path11.resolve(baseDir, candidate);
|
|
7291
6841
|
}
|
|
7292
6842
|
function teeAcpStream(events) {
|
|
7293
6843
|
const chunks = [];
|
|
@@ -7347,7 +6897,7 @@ async function removePathFallback(fs3, target) {
|
|
|
7347
6897
|
if (stats && typeof stats.isDirectory === "function" && stats.isDirectory()) {
|
|
7348
6898
|
const entries = await fs3.readdir(target);
|
|
7349
6899
|
for (const entry of entries) {
|
|
7350
|
-
await removePathFallback(fs3,
|
|
6900
|
+
await removePathFallback(fs3, path11.join(target, entry));
|
|
7351
6901
|
}
|
|
7352
6902
|
}
|
|
7353
6903
|
try {
|
|
@@ -7451,7 +7001,7 @@ async function resolveResearchAgent(input) {
|
|
|
7451
7001
|
if (input.flags.assumeYes) {
|
|
7452
7002
|
const configured = await loadConfiguredServices({
|
|
7453
7003
|
fs: input.container.fs,
|
|
7454
|
-
filePath: input.container.env.
|
|
7004
|
+
filePath: input.container.env.credentialsPath
|
|
7455
7005
|
});
|
|
7456
7006
|
const configuredService = spawnable.find(
|
|
7457
7007
|
(service) => service.name in configured
|
|
@@ -7513,8 +7063,8 @@ async function resolveResearchModel(input) {
|
|
|
7513
7063
|
var init_research2 = __esm({
|
|
7514
7064
|
async "src/cli/commands/research.ts"() {
|
|
7515
7065
|
"use strict";
|
|
7516
|
-
|
|
7517
|
-
|
|
7066
|
+
init_src4();
|
|
7067
|
+
init_credentials2();
|
|
7518
7068
|
await init_research();
|
|
7519
7069
|
init_errors();
|
|
7520
7070
|
init_shared();
|
|
@@ -7522,13 +7072,13 @@ var init_research2 = __esm({
|
|
|
7522
7072
|
});
|
|
7523
7073
|
|
|
7524
7074
|
// src/cli/isolated-env-runner.ts
|
|
7525
|
-
import { spawn as
|
|
7075
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
7526
7076
|
async function isolatedEnvRunner(input) {
|
|
7527
7077
|
const details = await resolveIsolatedEnvDetails(
|
|
7528
7078
|
input.env,
|
|
7529
7079
|
input.isolated,
|
|
7530
7080
|
input.providerName,
|
|
7531
|
-
input.
|
|
7081
|
+
input.fs
|
|
7532
7082
|
);
|
|
7533
7083
|
let args = input.argv.slice(2);
|
|
7534
7084
|
if (input.isolated.requiresConfig !== false) {
|
|
@@ -7543,11 +7093,11 @@ async function isolatedEnvRunner(input) {
|
|
|
7543
7093
|
const resolvedSettings = await resolveCliSettings(
|
|
7544
7094
|
input.isolated.cliSettings,
|
|
7545
7095
|
input.env,
|
|
7546
|
-
input.
|
|
7096
|
+
input.fs
|
|
7547
7097
|
);
|
|
7548
7098
|
args = buildArgsWithMergedSettings(args, resolvedSettings);
|
|
7549
7099
|
}
|
|
7550
|
-
const child =
|
|
7100
|
+
const child = spawn4(details.agentBinary, args, {
|
|
7551
7101
|
stdio: "inherit",
|
|
7552
7102
|
env: {
|
|
7553
7103
|
...process.env,
|
|
@@ -7580,7 +7130,7 @@ async function configExists(fs3, filePath) {
|
|
|
7580
7130
|
var init_isolated_env_runner = __esm({
|
|
7581
7131
|
"src/cli/isolated-env-runner.ts"() {
|
|
7582
7132
|
"use strict";
|
|
7583
|
-
|
|
7133
|
+
init_src();
|
|
7584
7134
|
init_isolated_env();
|
|
7585
7135
|
init_cli_settings_merge();
|
|
7586
7136
|
}
|
|
@@ -7630,7 +7180,6 @@ function registerWrapCommand(program, container) {
|
|
|
7630
7180
|
await isolatedEnvRunner({
|
|
7631
7181
|
env: container.env,
|
|
7632
7182
|
fs: container.fs,
|
|
7633
|
-
readApiKey: container.readApiKey,
|
|
7634
7183
|
providerName: adapter.name,
|
|
7635
7184
|
isolated,
|
|
7636
7185
|
argv: ["node", "poe-code", ...forwarded]
|
|
@@ -7650,66 +7199,46 @@ var init_wrap = __esm({
|
|
|
7650
7199
|
// src/cli/commands/login.ts
|
|
7651
7200
|
function registerLoginCommand(program, container) {
|
|
7652
7201
|
program.command("login").description("Store a Poe API key for reuse across commands.").option("--api-key <key>", "Poe API key").action(async (options) => {
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
}
|
|
7656
|
-
async function executeLogin(program, container, options) {
|
|
7657
|
-
const flags = resolveCommandFlags(program);
|
|
7658
|
-
const resources = createExecutionResources(
|
|
7659
|
-
container,
|
|
7660
|
-
flags,
|
|
7661
|
-
"login"
|
|
7662
|
-
);
|
|
7663
|
-
resources.logger.intro("login");
|
|
7664
|
-
try {
|
|
7665
|
-
const input = await resolveApiKeyInput(container, options);
|
|
7666
|
-
const normalized = container.options.normalizeApiKey(input);
|
|
7667
|
-
const configuredServices = await loadConfiguredServices({
|
|
7668
|
-
fs: container.fs,
|
|
7669
|
-
filePath: container.env.configPath
|
|
7670
|
-
});
|
|
7671
|
-
if (!flags.dryRun) {
|
|
7672
|
-
await container.writeApiKey(normalized);
|
|
7673
|
-
}
|
|
7674
|
-
await reconfigureServices({
|
|
7675
|
-
program,
|
|
7202
|
+
const flags = resolveCommandFlags(program);
|
|
7203
|
+
const resources = createExecutionResources(
|
|
7676
7204
|
container,
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
resources.
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7205
|
+
flags,
|
|
7206
|
+
"login"
|
|
7207
|
+
);
|
|
7208
|
+
resources.logger.intro("login");
|
|
7209
|
+
try {
|
|
7210
|
+
const configuredServices = await loadConfiguredServices({
|
|
7211
|
+
fs: container.fs,
|
|
7212
|
+
filePath: container.env.credentialsPath
|
|
7213
|
+
});
|
|
7214
|
+
const apiKey = await container.options.resolveApiKey({
|
|
7215
|
+
value: options.apiKey,
|
|
7216
|
+
envValue: container.env.getVariable("POE_API_KEY"),
|
|
7217
|
+
dryRun: flags.dryRun,
|
|
7218
|
+
assumeYes: flags.assumeYes,
|
|
7219
|
+
allowStored: false
|
|
7690
7220
|
});
|
|
7221
|
+
await reconfigureServices({
|
|
7222
|
+
program,
|
|
7223
|
+
container,
|
|
7224
|
+
apiKey,
|
|
7225
|
+
configuredServices
|
|
7226
|
+
});
|
|
7227
|
+
resources.context.complete({
|
|
7228
|
+
success: "Logged in.",
|
|
7229
|
+
dry: "Dry run: would save API key."
|
|
7230
|
+
});
|
|
7231
|
+
resources.context.finalize();
|
|
7232
|
+
} catch (error2) {
|
|
7233
|
+
if (error2 instanceof Error) {
|
|
7234
|
+
resources.logger.logException(error2, "login command", {
|
|
7235
|
+
operation: "login",
|
|
7236
|
+
credentialsPath: container.env.credentialsPath
|
|
7237
|
+
});
|
|
7238
|
+
}
|
|
7239
|
+
throw error2;
|
|
7691
7240
|
}
|
|
7692
|
-
|
|
7693
|
-
}
|
|
7694
|
-
}
|
|
7695
|
-
async function resolveApiKeyInput(container, options) {
|
|
7696
|
-
if (options.apiKey) {
|
|
7697
|
-
return options.apiKey;
|
|
7698
|
-
}
|
|
7699
|
-
const envKey = container.env.getVariable("POE_API_KEY");
|
|
7700
|
-
if (envKey && envKey.trim().length > 0) {
|
|
7701
|
-
return envKey;
|
|
7702
|
-
}
|
|
7703
|
-
const descriptor = container.promptLibrary.loginApiKey();
|
|
7704
|
-
const response = await container.prompts(descriptor);
|
|
7705
|
-
const value = response[descriptor.name];
|
|
7706
|
-
if (typeof value !== "string" || value.trim() === "") {
|
|
7707
|
-
throw new ValidationError("POE API key is required.", {
|
|
7708
|
-
operation: "login",
|
|
7709
|
-
field: "apiKey"
|
|
7710
|
-
});
|
|
7711
|
-
}
|
|
7712
|
-
return value;
|
|
7241
|
+
});
|
|
7713
7242
|
}
|
|
7714
7243
|
async function reconfigureServices(input) {
|
|
7715
7244
|
const { program, container, apiKey, configuredServices } = input;
|
|
@@ -7763,8 +7292,7 @@ var init_login = __esm({
|
|
|
7763
7292
|
"src/cli/commands/login.ts"() {
|
|
7764
7293
|
"use strict";
|
|
7765
7294
|
init_shared();
|
|
7766
|
-
|
|
7767
|
-
init_errors();
|
|
7295
|
+
init_credentials2();
|
|
7768
7296
|
init_mutation_events();
|
|
7769
7297
|
}
|
|
7770
7298
|
});
|
|
@@ -7844,7 +7372,7 @@ async function executeUnconfigure(program, container, service, options) {
|
|
|
7844
7372
|
if (!flags.dryRun) {
|
|
7845
7373
|
await unconfigureService({
|
|
7846
7374
|
fs: container.fs,
|
|
7847
|
-
filePath: providerContext.env.
|
|
7375
|
+
filePath: providerContext.env.credentialsPath,
|
|
7848
7376
|
service: canonicalService
|
|
7849
7377
|
});
|
|
7850
7378
|
}
|
|
@@ -7889,7 +7417,7 @@ function formatUnconfigureMessages(service, label, unconfigured, _payload) {
|
|
|
7889
7417
|
var init_unconfigure = __esm({
|
|
7890
7418
|
"src/cli/commands/unconfigure.ts"() {
|
|
7891
7419
|
"use strict";
|
|
7892
|
-
|
|
7420
|
+
init_credentials2();
|
|
7893
7421
|
init_mutation_events();
|
|
7894
7422
|
init_isolated_env();
|
|
7895
7423
|
init_shared();
|
|
@@ -7898,157 +7426,53 @@ var init_unconfigure = __esm({
|
|
|
7898
7426
|
|
|
7899
7427
|
// src/cli/commands/logout.ts
|
|
7900
7428
|
function registerLogoutCommand(program, container) {
|
|
7901
|
-
program.command("logout").description("Remove all Poe API configuration.").action(async () => {
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
if (!adapter) {
|
|
7920
|
-
continue;
|
|
7429
|
+
program.command("logout").description("Remove all Poe API configuration and stored credentials.").action(async () => {
|
|
7430
|
+
const flags = resolveCommandFlags(program);
|
|
7431
|
+
const resources = createExecutionResources(
|
|
7432
|
+
container,
|
|
7433
|
+
flags,
|
|
7434
|
+
"logout"
|
|
7435
|
+
);
|
|
7436
|
+
resources.logger.intro("logout");
|
|
7437
|
+
const configuredServices = await loadConfiguredServices({
|
|
7438
|
+
fs: container.fs,
|
|
7439
|
+
filePath: container.env.credentialsPath
|
|
7440
|
+
});
|
|
7441
|
+
for (const serviceName of Object.keys(configuredServices)) {
|
|
7442
|
+
const adapter = container.registry.get(serviceName);
|
|
7443
|
+
if (!adapter) {
|
|
7444
|
+
continue;
|
|
7445
|
+
}
|
|
7446
|
+
await executeUnconfigure(program, container, serviceName, {});
|
|
7921
7447
|
}
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7448
|
+
if (flags.dryRun) {
|
|
7449
|
+
resources.context.complete({
|
|
7450
|
+
success: "Logged out.",
|
|
7451
|
+
dry: `Dry run: would delete credentials at ${container.env.credentialsPath}.`
|
|
7452
|
+
});
|
|
7453
|
+
resources.context.finalize();
|
|
7454
|
+
return;
|
|
7455
|
+
}
|
|
7456
|
+
const deleted = await deleteCredentials({
|
|
7457
|
+
fs: container.fs,
|
|
7458
|
+
filePath: container.env.credentialsPath
|
|
7459
|
+
});
|
|
7925
7460
|
resources.context.complete({
|
|
7926
|
-
success: "Logged out.",
|
|
7927
|
-
dry: `Dry run: would delete
|
|
7461
|
+
success: deleted ? "Logged out." : "Already logged out.",
|
|
7462
|
+
dry: `Dry run: would delete credentials at ${container.env.credentialsPath}.`
|
|
7928
7463
|
});
|
|
7929
7464
|
resources.context.finalize();
|
|
7930
|
-
return;
|
|
7931
|
-
}
|
|
7932
|
-
const deleted = await deleteConfig({
|
|
7933
|
-
fs: container.fs,
|
|
7934
|
-
filePath: container.env.configPath
|
|
7935
|
-
});
|
|
7936
|
-
resources.context.complete({
|
|
7937
|
-
success: deleted ? "Logged out." : "Already logged out.",
|
|
7938
|
-
dry: `Dry run: would delete config at ${container.env.configPath}.`
|
|
7939
7465
|
});
|
|
7940
|
-
resources.context.finalize();
|
|
7941
7466
|
}
|
|
7942
7467
|
var init_logout = __esm({
|
|
7943
7468
|
"src/cli/commands/logout.ts"() {
|
|
7944
7469
|
"use strict";
|
|
7945
|
-
|
|
7470
|
+
init_credentials2();
|
|
7946
7471
|
init_shared();
|
|
7947
7472
|
init_unconfigure();
|
|
7948
7473
|
}
|
|
7949
7474
|
});
|
|
7950
7475
|
|
|
7951
|
-
// src/cli/commands/auth.ts
|
|
7952
|
-
function registerAuthCommand(program, container) {
|
|
7953
|
-
const auth = program.command("auth").description("Authentication and account commands.").action(async () => {
|
|
7954
|
-
await executeStatus(program, container);
|
|
7955
|
-
});
|
|
7956
|
-
auth.command("status").description("Show login, balance, and configuration status.").action(async () => {
|
|
7957
|
-
await executeStatus(program, container);
|
|
7958
|
-
});
|
|
7959
|
-
auth.command("api_key").description("Display stored API key.").action(async () => {
|
|
7960
|
-
await executeApiKey(program, container);
|
|
7961
|
-
});
|
|
7962
|
-
auth.command("login").description("Store a Poe API key.").option("--api-key <key>", "Poe API key").action(async (options) => {
|
|
7963
|
-
await executeLogin(program, container, options);
|
|
7964
|
-
});
|
|
7965
|
-
auth.command("logout").description("Remove all configuration and credentials.").action(async () => {
|
|
7966
|
-
await executeLogout(program, container);
|
|
7967
|
-
});
|
|
7968
|
-
}
|
|
7969
|
-
async function executeStatus(program, container) {
|
|
7970
|
-
const flags = resolveCommandFlags(program);
|
|
7971
|
-
const resources = createExecutionResources(container, flags, "auth:status");
|
|
7972
|
-
resources.logger.intro("auth status");
|
|
7973
|
-
try {
|
|
7974
|
-
const apiKey = await container.readApiKey();
|
|
7975
|
-
const loggedIn = Boolean(apiKey);
|
|
7976
|
-
resources.logger.info(loggedIn ? "Logged in" : "Not logged in");
|
|
7977
|
-
if (loggedIn) {
|
|
7978
|
-
if (flags.dryRun) {
|
|
7979
|
-
resources.logger.dryRun(
|
|
7980
|
-
"Dry run: would fetch usage balance from Poe API."
|
|
7981
|
-
);
|
|
7982
|
-
} else {
|
|
7983
|
-
const response = await container.httpClient(
|
|
7984
|
-
`${container.env.poeBaseUrl}/usage/current_balance`,
|
|
7985
|
-
{
|
|
7986
|
-
method: "GET",
|
|
7987
|
-
headers: {
|
|
7988
|
-
Authorization: `Bearer ${apiKey}`
|
|
7989
|
-
}
|
|
7990
|
-
}
|
|
7991
|
-
);
|
|
7992
|
-
if (!response.ok) {
|
|
7993
|
-
throw new ApiError(
|
|
7994
|
-
`Failed to fetch usage balance (HTTP ${response.status})`,
|
|
7995
|
-
{
|
|
7996
|
-
httpStatus: response.status,
|
|
7997
|
-
endpoint: "/usage/current_balance"
|
|
7998
|
-
}
|
|
7999
|
-
);
|
|
8000
|
-
}
|
|
8001
|
-
const data = await response.json();
|
|
8002
|
-
const formattedBalance = data.current_point_balance.toLocaleString(
|
|
8003
|
-
"en-US"
|
|
8004
|
-
);
|
|
8005
|
-
resources.logger.info(`Current balance: ${formattedBalance} points`);
|
|
8006
|
-
}
|
|
8007
|
-
}
|
|
8008
|
-
const configuredServices = await loadConfiguredServices({
|
|
8009
|
-
fs: container.fs,
|
|
8010
|
-
filePath: container.env.configPath
|
|
8011
|
-
});
|
|
8012
|
-
const configuredAgentNames = Object.keys(configuredServices).sort();
|
|
8013
|
-
if (configuredAgentNames.length === 0) {
|
|
8014
|
-
resources.logger.info("No agents configured.");
|
|
8015
|
-
} else {
|
|
8016
|
-
resources.logger.info(
|
|
8017
|
-
`Configured agents: ${configuredAgentNames.join(", ")}`
|
|
8018
|
-
);
|
|
8019
|
-
}
|
|
8020
|
-
resources.context.finalize();
|
|
8021
|
-
} catch (error2) {
|
|
8022
|
-
if (error2 instanceof Error) {
|
|
8023
|
-
resources.logger.logException(error2, "auth status", {
|
|
8024
|
-
operation: "auth-status"
|
|
8025
|
-
});
|
|
8026
|
-
}
|
|
8027
|
-
throw error2;
|
|
8028
|
-
}
|
|
8029
|
-
}
|
|
8030
|
-
async function executeApiKey(program, container) {
|
|
8031
|
-
const flags = resolveCommandFlags(program);
|
|
8032
|
-
const resources = createExecutionResources(container, flags, "auth:api_key");
|
|
8033
|
-
resources.logger.intro("auth api_key");
|
|
8034
|
-
const apiKey = await container.readApiKey();
|
|
8035
|
-
if (!apiKey) {
|
|
8036
|
-
resources.logger.info("No API key stored.");
|
|
8037
|
-
return;
|
|
8038
|
-
}
|
|
8039
|
-
resources.logger.info(`API key: ${apiKey}`);
|
|
8040
|
-
}
|
|
8041
|
-
var init_auth = __esm({
|
|
8042
|
-
"src/cli/commands/auth.ts"() {
|
|
8043
|
-
"use strict";
|
|
8044
|
-
init_errors();
|
|
8045
|
-
init_config();
|
|
8046
|
-
init_shared();
|
|
8047
|
-
init_login();
|
|
8048
|
-
init_logout();
|
|
8049
|
-
}
|
|
8050
|
-
});
|
|
8051
|
-
|
|
8052
7476
|
// src/cli/commands/install.ts
|
|
8053
7477
|
function registerInstallCommand(program, container) {
|
|
8054
7478
|
const serviceNames = container.registry.list().filter((service) => typeof service.install === "function").map((service) => service.name);
|
|
@@ -8143,7 +7567,7 @@ async function executeTest(program, container, service, options = {}) {
|
|
|
8143
7567
|
container.env,
|
|
8144
7568
|
adapter.isolatedEnv,
|
|
8145
7569
|
adapter.name,
|
|
8146
|
-
container.
|
|
7570
|
+
container.fs
|
|
8147
7571
|
) : null;
|
|
8148
7572
|
if (options.isolated && adapter.isolatedEnv) {
|
|
8149
7573
|
const { ensureIsolatedConfigForService: ensureIsolatedConfigForService2 } = await Promise.resolve().then(() => (init_ensure_isolated_config(), ensure_isolated_config_exports));
|
|
@@ -8192,7 +7616,7 @@ var init_test = __esm({
|
|
|
8192
7616
|
init_shared();
|
|
8193
7617
|
init_configure();
|
|
8194
7618
|
init_isolated_env();
|
|
8195
|
-
|
|
7619
|
+
init_src3();
|
|
8196
7620
|
}
|
|
8197
7621
|
});
|
|
8198
7622
|
|
|
@@ -8245,7 +7669,7 @@ var init_media_download = __esm({
|
|
|
8245
7669
|
});
|
|
8246
7670
|
|
|
8247
7671
|
// src/cli/commands/generate.ts
|
|
8248
|
-
import
|
|
7672
|
+
import path12 from "node:path";
|
|
8249
7673
|
function registerGenerateCommand(program, container) {
|
|
8250
7674
|
const generate2 = program.command("generate").description("Generate content via Poe API").option("--model <model>", `Model identifier (default: ${DEFAULT_TEXT_MODEL})`).option(
|
|
8251
7675
|
"--param <key=value>",
|
|
@@ -8424,13 +7848,10 @@ async function resolveClient2(container) {
|
|
|
8424
7848
|
try {
|
|
8425
7849
|
return getGlobalClient();
|
|
8426
7850
|
} catch {
|
|
8427
|
-
const apiKey = await container.readApiKey();
|
|
8428
|
-
if (!apiKey) {
|
|
8429
|
-
throw new Error("Poe API key not found. Run 'poe-code login' first.");
|
|
8430
|
-
}
|
|
8431
7851
|
const apiBaseUrl = resolveApiBaseUrl(container);
|
|
8432
7852
|
await initializeClient({
|
|
8433
|
-
|
|
7853
|
+
fs: container.fs,
|
|
7854
|
+
credentialsPath: container.env.credentialsPath,
|
|
8434
7855
|
baseUrl: apiBaseUrl,
|
|
8435
7856
|
httpClient: container.httpClient
|
|
8436
7857
|
});
|
|
@@ -8511,11 +7932,11 @@ function getDefaultMimeType(type) {
|
|
|
8511
7932
|
return defaults[type];
|
|
8512
7933
|
}
|
|
8513
7934
|
function resolveOutputPath(filename, cwd) {
|
|
8514
|
-
if (
|
|
7935
|
+
if (path12.isAbsolute(filename)) {
|
|
8515
7936
|
return { path: filename, label: filename };
|
|
8516
7937
|
}
|
|
8517
7938
|
return {
|
|
8518
|
-
path:
|
|
7939
|
+
path: path12.join(cwd, filename),
|
|
8519
7940
|
label: `./${filename}`
|
|
8520
7941
|
};
|
|
8521
7942
|
}
|
|
@@ -8523,7 +7944,7 @@ var MODEL_ENV_KEYS2, DEFAULT_MODELS2;
|
|
|
8523
7944
|
var init_generate = __esm({
|
|
8524
7945
|
"src/cli/commands/generate.ts"() {
|
|
8525
7946
|
"use strict";
|
|
8526
|
-
|
|
7947
|
+
init_src3();
|
|
8527
7948
|
init_constants();
|
|
8528
7949
|
init_shared();
|
|
8529
7950
|
init_client_instance();
|
|
@@ -9619,8 +9040,8 @@ var init_parseUtil = __esm({
|
|
|
9619
9040
|
init_errors2();
|
|
9620
9041
|
init_en();
|
|
9621
9042
|
makeIssue = (params) => {
|
|
9622
|
-
const { data, path:
|
|
9623
|
-
const fullPath = [...
|
|
9043
|
+
const { data, path: path20, errorMaps, issueData } = params;
|
|
9044
|
+
const fullPath = [...path20, ...issueData.path || []];
|
|
9624
9045
|
const fullIssue = {
|
|
9625
9046
|
...issueData,
|
|
9626
9047
|
path: fullPath
|
|
@@ -9900,11 +9321,11 @@ var init_types3 = __esm({
|
|
|
9900
9321
|
init_parseUtil();
|
|
9901
9322
|
init_util();
|
|
9902
9323
|
ParseInputLazyPath = class {
|
|
9903
|
-
constructor(parent, value,
|
|
9324
|
+
constructor(parent, value, path20, key) {
|
|
9904
9325
|
this._cachedPath = [];
|
|
9905
9326
|
this.parent = parent;
|
|
9906
9327
|
this.data = value;
|
|
9907
|
-
this._path =
|
|
9328
|
+
this._path = path20;
|
|
9908
9329
|
this._key = key;
|
|
9909
9330
|
}
|
|
9910
9331
|
get path() {
|
|
@@ -13408,10 +12829,10 @@ function mergeDefs(...defs) {
|
|
|
13408
12829
|
function cloneDef(schema) {
|
|
13409
12830
|
return mergeDefs(schema._zod.def);
|
|
13410
12831
|
}
|
|
13411
|
-
function getElementAtPath(obj,
|
|
13412
|
-
if (!
|
|
12832
|
+
function getElementAtPath(obj, path20) {
|
|
12833
|
+
if (!path20)
|
|
13413
12834
|
return obj;
|
|
13414
|
-
return
|
|
12835
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
13415
12836
|
}
|
|
13416
12837
|
function promiseAllObject(promisesObj) {
|
|
13417
12838
|
const keys = Object.keys(promisesObj);
|
|
@@ -13723,11 +13144,11 @@ function aborted(x, startIndex = 0) {
|
|
|
13723
13144
|
}
|
|
13724
13145
|
return false;
|
|
13725
13146
|
}
|
|
13726
|
-
function prefixIssues(
|
|
13147
|
+
function prefixIssues(path20, issues) {
|
|
13727
13148
|
return issues.map((iss) => {
|
|
13728
13149
|
var _a2;
|
|
13729
13150
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
13730
|
-
iss.path.unshift(
|
|
13151
|
+
iss.path.unshift(path20);
|
|
13731
13152
|
return iss;
|
|
13732
13153
|
});
|
|
13733
13154
|
}
|
|
@@ -14103,7 +13524,7 @@ __export(regexes_exports, {
|
|
|
14103
13524
|
extendedDuration: () => extendedDuration,
|
|
14104
13525
|
guid: () => guid,
|
|
14105
13526
|
hex: () => hex,
|
|
14106
|
-
hostname: () =>
|
|
13527
|
+
hostname: () => hostname,
|
|
14107
13528
|
html5Email: () => html5Email,
|
|
14108
13529
|
idnEmail: () => idnEmail,
|
|
14109
13530
|
integer: () => integer,
|
|
@@ -14170,7 +13591,7 @@ function fixedBase64(bodyLength, padding) {
|
|
|
14170
13591
|
function fixedBase64url(length) {
|
|
14171
13592
|
return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
|
|
14172
13593
|
}
|
|
14173
|
-
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, extendedDuration, guid, uuid, uuid4, uuid6, uuid7, email, html5Email, rfc5322Email, unicodeEmail, idnEmail, browserEmail, _emoji, ipv4, ipv6, mac, cidrv4, cidrv6, base64, base64url,
|
|
13594
|
+
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, extendedDuration, guid, uuid, uuid4, uuid6, uuid7, email, html5Email, rfc5322Email, unicodeEmail, idnEmail, browserEmail, _emoji, ipv4, ipv6, mac, cidrv4, cidrv6, base64, base64url, hostname, domain, e164, dateSource, date, string, bigint, integer, number, boolean, _null, _undefined, lowercase, uppercase, hex, md5_hex, md5_base64, md5_base64url, sha1_hex, sha1_base64, sha1_base64url, sha256_hex, sha256_base64, sha256_base64url, sha384_hex, sha384_base64, sha384_base64url, sha512_hex, sha512_base64, sha512_base64url;
|
|
14174
13595
|
var init_regexes = __esm({
|
|
14175
13596
|
"node_modules/zod/v4/core/regexes.js"() {
|
|
14176
13597
|
init_util2();
|
|
@@ -14208,7 +13629,7 @@ var init_regexes = __esm({
|
|
|
14208
13629
|
cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
14209
13630
|
base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
14210
13631
|
base64url = /^[A-Za-z0-9_-]*$/;
|
|
14211
|
-
|
|
13632
|
+
hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
14212
13633
|
domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
14213
13634
|
e164 = /^\+[1-9]\d{6,14}$/;
|
|
14214
13635
|
dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
@@ -19414,7 +18835,7 @@ __export(schemas_exports3, {
|
|
|
19414
18835
|
guid: () => guid2,
|
|
19415
18836
|
hash: () => hash,
|
|
19416
18837
|
hex: () => hex2,
|
|
19417
|
-
hostname: () =>
|
|
18838
|
+
hostname: () => hostname2,
|
|
19418
18839
|
httpUrl: () => httpUrl,
|
|
19419
18840
|
instanceof: () => _instanceof,
|
|
19420
18841
|
int: () => int,
|
|
@@ -19561,7 +18982,7 @@ function jwt(params) {
|
|
|
19561
18982
|
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
19562
18983
|
return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
19563
18984
|
}
|
|
19564
|
-
function
|
|
18985
|
+
function hostname2(_params) {
|
|
19565
18986
|
return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
|
|
19566
18987
|
}
|
|
19567
18988
|
function hex2(_params) {
|
|
@@ -25685,8 +25106,8 @@ var require_utils = __commonJS({
|
|
|
25685
25106
|
}
|
|
25686
25107
|
return ind;
|
|
25687
25108
|
}
|
|
25688
|
-
function removeDotSegments(
|
|
25689
|
-
let input =
|
|
25109
|
+
function removeDotSegments(path20) {
|
|
25110
|
+
let input = path20;
|
|
25690
25111
|
const output = [];
|
|
25691
25112
|
let nextSlash = -1;
|
|
25692
25113
|
let len = 0;
|
|
@@ -25885,8 +25306,8 @@ var require_schemes = __commonJS({
|
|
|
25885
25306
|
wsComponent.secure = void 0;
|
|
25886
25307
|
}
|
|
25887
25308
|
if (wsComponent.resourceName) {
|
|
25888
|
-
const [
|
|
25889
|
-
wsComponent.path =
|
|
25309
|
+
const [path20, query] = wsComponent.resourceName.split("?");
|
|
25310
|
+
wsComponent.path = path20 && path20 !== "/" ? path20 : void 0;
|
|
25890
25311
|
wsComponent.query = query;
|
|
25891
25312
|
wsComponent.resourceName = void 0;
|
|
25892
25313
|
}
|
|
@@ -35000,7 +34421,7 @@ var init_content = __esm({
|
|
|
35000
34421
|
});
|
|
35001
34422
|
|
|
35002
34423
|
// packages/tiny-stdio-mcp-server/src/index.ts
|
|
35003
|
-
var
|
|
34424
|
+
var init_src5 = __esm({
|
|
35004
34425
|
"packages/tiny-stdio-mcp-server/src/index.ts"() {
|
|
35005
34426
|
"use strict";
|
|
35006
34427
|
init_server();
|
|
@@ -35304,7 +34725,7 @@ var generateTextSchema, generateImageSchema, generateVideoSchema, generateAudioS
|
|
|
35304
34725
|
var init_mcp_server = __esm({
|
|
35305
34726
|
"src/cli/mcp-server.ts"() {
|
|
35306
34727
|
"use strict";
|
|
35307
|
-
|
|
34728
|
+
init_src5();
|
|
35308
34729
|
init_client_instance();
|
|
35309
34730
|
init_constants();
|
|
35310
34731
|
generateTextSchema = defineSchema({
|
|
@@ -35562,7 +34983,7 @@ ${panel.footer}`);
|
|
|
35562
34983
|
var init_command_not_found = __esm({
|
|
35563
34984
|
"src/cli/command-not-found.ts"() {
|
|
35564
34985
|
"use strict";
|
|
35565
|
-
|
|
34986
|
+
init_src3();
|
|
35566
34987
|
init_execution_context();
|
|
35567
34988
|
init_errors();
|
|
35568
34989
|
}
|
|
@@ -35587,7 +35008,7 @@ function getAgentConfig(agentId) {
|
|
|
35587
35008
|
const support = resolveAgentSupport(agentId);
|
|
35588
35009
|
return support.status === "supported" ? support.config : void 0;
|
|
35589
35010
|
}
|
|
35590
|
-
function
|
|
35011
|
+
function resolveConfigPath(config2, platform) {
|
|
35591
35012
|
if (typeof config2.configFile === "function") {
|
|
35592
35013
|
return config2.configFile(platform);
|
|
35593
35014
|
}
|
|
@@ -35597,7 +35018,7 @@ var agentMcpConfigs, supportedAgents;
|
|
|
35597
35018
|
var init_configs2 = __esm({
|
|
35598
35019
|
"packages/agent-mcp-config/src/configs.ts"() {
|
|
35599
35020
|
"use strict";
|
|
35600
|
-
|
|
35021
|
+
init_src2();
|
|
35601
35022
|
agentMcpConfigs = {
|
|
35602
35023
|
"claude-code": {
|
|
35603
35024
|
configFile: "~/.claude.json",
|
|
@@ -35710,9 +35131,9 @@ var init_shapes = __esm({
|
|
|
35710
35131
|
});
|
|
35711
35132
|
|
|
35712
35133
|
// packages/agent-mcp-config/src/apply.ts
|
|
35713
|
-
import
|
|
35134
|
+
import path13 from "node:path";
|
|
35714
35135
|
function getConfigDirectory(configPath) {
|
|
35715
|
-
return
|
|
35136
|
+
return path13.dirname(configPath);
|
|
35716
35137
|
}
|
|
35717
35138
|
function isConfigObject5(value) {
|
|
35718
35139
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -35729,7 +35150,7 @@ async function configure(agentId, server, options) {
|
|
|
35729
35150
|
throw new UnsupportedAgentError(agentId);
|
|
35730
35151
|
}
|
|
35731
35152
|
const config2 = getAgentConfig(agentId);
|
|
35732
|
-
const configPath =
|
|
35153
|
+
const configPath = resolveConfigPath(config2, options.platform);
|
|
35733
35154
|
const shapeTransformer = getShapeTransformer(config2.shape);
|
|
35734
35155
|
const shaped = shapeTransformer(server);
|
|
35735
35156
|
if (shaped === void 0) {
|
|
@@ -35775,7 +35196,7 @@ async function unconfigure(agentId, serverName, options) {
|
|
|
35775
35196
|
throw new UnsupportedAgentError(agentId);
|
|
35776
35197
|
}
|
|
35777
35198
|
const config2 = getAgentConfig(agentId);
|
|
35778
|
-
const configPath =
|
|
35199
|
+
const configPath = resolveConfigPath(config2, options.platform);
|
|
35779
35200
|
await runMutations(
|
|
35780
35201
|
[
|
|
35781
35202
|
configMutation.prune({
|
|
@@ -35801,7 +35222,7 @@ var UnsupportedAgentError;
|
|
|
35801
35222
|
var init_apply = __esm({
|
|
35802
35223
|
"packages/agent-mcp-config/src/apply.ts"() {
|
|
35803
35224
|
"use strict";
|
|
35804
|
-
|
|
35225
|
+
init_src();
|
|
35805
35226
|
init_configs2();
|
|
35806
35227
|
init_shapes();
|
|
35807
35228
|
UnsupportedAgentError = class extends Error {
|
|
@@ -35814,7 +35235,7 @@ var init_apply = __esm({
|
|
|
35814
35235
|
});
|
|
35815
35236
|
|
|
35816
35237
|
// packages/agent-mcp-config/src/index.ts
|
|
35817
|
-
var
|
|
35238
|
+
var init_src6 = __esm({
|
|
35818
35239
|
"packages/agent-mcp-config/src/index.ts"() {
|
|
35819
35240
|
"use strict";
|
|
35820
35241
|
init_configs2();
|
|
@@ -35872,7 +35293,10 @@ function registerMcpCommand(program, container) {
|
|
|
35872
35293
|
mcp.command("configure [agent]").description("Configure MCP client to use poe-code").option("-y, --yes", "Skip prompt, use claude-code").action(async (agentArg, options) => {
|
|
35873
35294
|
const flags = resolveCommandFlags(program);
|
|
35874
35295
|
const resources = createExecutionResources(container, flags, "mcp");
|
|
35875
|
-
const existingKey = await
|
|
35296
|
+
const existingKey = await loadCredentials({
|
|
35297
|
+
fs: container.fs,
|
|
35298
|
+
filePath: container.env.credentialsPath
|
|
35299
|
+
});
|
|
35876
35300
|
if (!existingKey) {
|
|
35877
35301
|
resources.logger.intro("login");
|
|
35878
35302
|
await container.options.resolveApiKey({ dryRun: flags.dryRun });
|
|
@@ -35972,13 +35396,17 @@ async function runMcpServer(container, options) {
|
|
|
35972
35396
|
const outputFormatPreferences = parseMcpOutputFormatPreferences(
|
|
35973
35397
|
options.outputFormat
|
|
35974
35398
|
);
|
|
35975
|
-
const apiKey = await
|
|
35399
|
+
const apiKey = await loadCredentials({
|
|
35400
|
+
fs: container.fs,
|
|
35401
|
+
filePath: container.env.credentialsPath
|
|
35402
|
+
});
|
|
35976
35403
|
if (!apiKey) {
|
|
35977
|
-
process.stderr.write("No
|
|
35404
|
+
process.stderr.write("No credentials found. Run 'poe-code login' first.\n");
|
|
35978
35405
|
process.exit(1);
|
|
35979
35406
|
}
|
|
35980
35407
|
await initializeClient({
|
|
35981
|
-
|
|
35408
|
+
fs: container.fs,
|
|
35409
|
+
credentialsPath: container.env.credentialsPath,
|
|
35982
35410
|
baseUrl: container.env.poeApiBaseUrl,
|
|
35983
35411
|
httpClient: container.httpClient
|
|
35984
35412
|
});
|
|
@@ -35988,21 +35416,22 @@ var DEFAULT_MCP_AGENT;
|
|
|
35988
35416
|
var init_mcp2 = __esm({
|
|
35989
35417
|
"src/cli/commands/mcp.ts"() {
|
|
35990
35418
|
"use strict";
|
|
35991
|
-
|
|
35419
|
+
init_src3();
|
|
35420
|
+
init_credentials2();
|
|
35992
35421
|
init_client_instance();
|
|
35993
35422
|
init_mcp_server();
|
|
35994
35423
|
init_shared();
|
|
35995
35424
|
init_mcp_output_format();
|
|
35996
35425
|
init_command_not_found();
|
|
35997
|
-
|
|
35426
|
+
init_src6();
|
|
35998
35427
|
init_execution_context();
|
|
35999
35428
|
DEFAULT_MCP_AGENT = "claude-code";
|
|
36000
35429
|
}
|
|
36001
35430
|
});
|
|
36002
35431
|
|
|
36003
35432
|
// packages/agent-skill-config/src/configs.ts
|
|
36004
|
-
import
|
|
36005
|
-
import
|
|
35433
|
+
import os3 from "node:os";
|
|
35434
|
+
import path14 from "node:path";
|
|
36006
35435
|
function resolveAgentSupport2(input, registry2 = agentSkillConfigs) {
|
|
36007
35436
|
const resolvedId = resolveAgentId(input);
|
|
36008
35437
|
if (!resolvedId) {
|
|
@@ -36018,7 +35447,7 @@ var agentSkillConfigs, supportedAgents2;
|
|
|
36018
35447
|
var init_configs3 = __esm({
|
|
36019
35448
|
"packages/agent-skill-config/src/configs.ts"() {
|
|
36020
35449
|
"use strict";
|
|
36021
|
-
|
|
35450
|
+
init_src2();
|
|
36022
35451
|
agentSkillConfigs = {
|
|
36023
35452
|
"claude-code": {
|
|
36024
35453
|
globalSkillDir: "~/.claude/skills",
|
|
@@ -36038,7 +35467,7 @@ var init_configs3 = __esm({
|
|
|
36038
35467
|
});
|
|
36039
35468
|
|
|
36040
35469
|
// packages/agent-skill-config/src/templates.ts
|
|
36041
|
-
import { readFile as
|
|
35470
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
36042
35471
|
async function getTemplates() {
|
|
36043
35472
|
if (templatesCache) {
|
|
36044
35473
|
return templatesCache;
|
|
@@ -36047,7 +35476,7 @@ async function getTemplates() {
|
|
|
36047
35476
|
"./templates/poe-generate.md",
|
|
36048
35477
|
import.meta.url
|
|
36049
35478
|
);
|
|
36050
|
-
const poeGenerateTemplate = await
|
|
35479
|
+
const poeGenerateTemplate = await readFile3(poeGenerateTemplateUrl, "utf8");
|
|
36051
35480
|
templatesCache = {
|
|
36052
35481
|
"poe-generate.md": poeGenerateTemplate
|
|
36053
35482
|
};
|
|
@@ -36179,7 +35608,7 @@ var UnsupportedAgentError2, bundledSkillTemplateIds, SKILL_TEMPLATE_ID;
|
|
|
36179
35608
|
var init_apply2 = __esm({
|
|
36180
35609
|
"packages/agent-skill-config/src/apply.ts"() {
|
|
36181
35610
|
"use strict";
|
|
36182
|
-
|
|
35611
|
+
init_src();
|
|
36183
35612
|
init_configs3();
|
|
36184
35613
|
init_templates();
|
|
36185
35614
|
UnsupportedAgentError2 = class extends Error {
|
|
@@ -36194,7 +35623,7 @@ var init_apply2 = __esm({
|
|
|
36194
35623
|
});
|
|
36195
35624
|
|
|
36196
35625
|
// packages/agent-skill-config/src/index.ts
|
|
36197
|
-
var
|
|
35626
|
+
var init_src7 = __esm({
|
|
36198
35627
|
"packages/agent-skill-config/src/index.ts"() {
|
|
36199
35628
|
"use strict";
|
|
36200
35629
|
init_configs3();
|
|
@@ -36418,8 +35847,8 @@ var DEFAULT_SKILL_AGENT;
|
|
|
36418
35847
|
var init_skill = __esm({
|
|
36419
35848
|
"src/cli/commands/skill.ts"() {
|
|
36420
35849
|
"use strict";
|
|
36421
|
-
|
|
36422
|
-
|
|
35850
|
+
init_src3();
|
|
35851
|
+
init_src7();
|
|
36423
35852
|
init_shared();
|
|
36424
35853
|
init_command_not_found();
|
|
36425
35854
|
DEFAULT_SKILL_AGENT = "claude-code";
|
|
@@ -36509,7 +35938,7 @@ async function displayVersion(container, currentVersion) {
|
|
|
36509
35938
|
var init_version2 = __esm({
|
|
36510
35939
|
"src/cli/commands/version.ts"() {
|
|
36511
35940
|
"use strict";
|
|
36512
|
-
|
|
35941
|
+
init_src3();
|
|
36513
35942
|
init_version();
|
|
36514
35943
|
init_exit_signals();
|
|
36515
35944
|
}
|
|
@@ -36634,10 +36063,10 @@ var init_registry2 = __esm({
|
|
|
36634
36063
|
});
|
|
36635
36064
|
|
|
36636
36065
|
// packages/worktree/src/create.ts
|
|
36637
|
-
import { join } from "node:path";
|
|
36066
|
+
import { join as join2 } from "node:path";
|
|
36638
36067
|
async function createWorktree(opts) {
|
|
36639
36068
|
const branch = `poe-code/${opts.name}`;
|
|
36640
|
-
const worktreePath =
|
|
36069
|
+
const worktreePath = join2(opts.worktreeDir, opts.name);
|
|
36641
36070
|
try {
|
|
36642
36071
|
await opts.deps.exec(`git worktree remove ${worktreePath} --force`, { cwd: opts.cwd });
|
|
36643
36072
|
} catch {
|
|
@@ -36712,7 +36141,7 @@ var init_list = __esm({
|
|
|
36712
36141
|
});
|
|
36713
36142
|
|
|
36714
36143
|
// packages/worktree/src/index.ts
|
|
36715
|
-
var
|
|
36144
|
+
var init_src8 = __esm({
|
|
36716
36145
|
"packages/worktree/src/index.ts"() {
|
|
36717
36146
|
"use strict";
|
|
36718
36147
|
init_create();
|
|
@@ -36801,13 +36230,13 @@ function getDirtyFiles(cwd) {
|
|
|
36801
36230
|
for (const line of lines) {
|
|
36802
36231
|
if (!line) continue;
|
|
36803
36232
|
if (line.length < 4) continue;
|
|
36804
|
-
let
|
|
36233
|
+
let path20 = line.slice(3).trim();
|
|
36805
36234
|
const renameArrow = " -> ";
|
|
36806
|
-
const arrowIndex =
|
|
36235
|
+
const arrowIndex = path20.lastIndexOf(renameArrow);
|
|
36807
36236
|
if (arrowIndex >= 0) {
|
|
36808
|
-
|
|
36237
|
+
path20 = path20.slice(arrowIndex + renameArrow.length).trim();
|
|
36809
36238
|
}
|
|
36810
|
-
if (
|
|
36239
|
+
if (path20) files.push(path20);
|
|
36811
36240
|
}
|
|
36812
36241
|
return files;
|
|
36813
36242
|
}
|
|
@@ -36819,7 +36248,7 @@ var init_utils2 = __esm({
|
|
|
36819
36248
|
|
|
36820
36249
|
// packages/ralph/src/plan/parser.ts
|
|
36821
36250
|
import { parse as parse7 } from "yaml";
|
|
36822
|
-
function
|
|
36251
|
+
function isRecord3(value) {
|
|
36823
36252
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36824
36253
|
}
|
|
36825
36254
|
function asOptionalString(value, field) {
|
|
@@ -36870,7 +36299,7 @@ function normalizeStatus(value) {
|
|
|
36870
36299
|
);
|
|
36871
36300
|
}
|
|
36872
36301
|
function parseStory(value, index) {
|
|
36873
|
-
if (!
|
|
36302
|
+
if (!isRecord3(value)) throw new Error(`Invalid stories[${index}]: expected object`);
|
|
36874
36303
|
return {
|
|
36875
36304
|
id: asRequiredString(value.id, `stories[${index}].id`),
|
|
36876
36305
|
title: asRequiredString(value.title, `stories[${index}].title`),
|
|
@@ -36894,7 +36323,7 @@ function parsePlan(yamlContent) {
|
|
|
36894
36323
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36895
36324
|
throw new Error(`Invalid plan YAML: ${message}`, { cause: error2 });
|
|
36896
36325
|
}
|
|
36897
|
-
if (!
|
|
36326
|
+
if (!isRecord3(doc)) {
|
|
36898
36327
|
throw new Error("Invalid plan YAML: expected top-level object");
|
|
36899
36328
|
}
|
|
36900
36329
|
const storiesValue = doc.stories;
|
|
@@ -36960,17 +36389,17 @@ function serializePlan(prd) {
|
|
|
36960
36389
|
return yaml.endsWith("\n") ? yaml : `${yaml}
|
|
36961
36390
|
`;
|
|
36962
36391
|
}
|
|
36963
|
-
function lockPlanFile(
|
|
36964
|
-
return lockFile(
|
|
36392
|
+
function lockPlanFile(path20) {
|
|
36393
|
+
return lockFile(path20, { retries: 20, minTimeout: 25, maxTimeout: 250 });
|
|
36965
36394
|
}
|
|
36966
|
-
async function writePlan(
|
|
36395
|
+
async function writePlan(path20, prd, options = {}) {
|
|
36967
36396
|
const fs3 = options.fs ?? fsPromises2;
|
|
36968
36397
|
const lock = options.lock ?? lockPlanFile;
|
|
36969
|
-
await fs3.mkdir(dirname3(
|
|
36970
|
-
const release = await lock(
|
|
36398
|
+
await fs3.mkdir(dirname3(path20), { recursive: true });
|
|
36399
|
+
const release = await lock(path20);
|
|
36971
36400
|
try {
|
|
36972
36401
|
const yaml = serializePlan(prd);
|
|
36973
|
-
await fs3.writeFile(
|
|
36402
|
+
await fs3.writeFile(path20, yaml, { encoding: "utf8" });
|
|
36974
36403
|
} finally {
|
|
36975
36404
|
await release();
|
|
36976
36405
|
}
|
|
@@ -36989,7 +36418,7 @@ function renderPrompt(template, variables) {
|
|
|
36989
36418
|
var init_renderer2 = __esm({
|
|
36990
36419
|
"packages/ralph/src/prompt/renderer.ts"() {
|
|
36991
36420
|
"use strict";
|
|
36992
|
-
|
|
36421
|
+
init_src();
|
|
36993
36422
|
}
|
|
36994
36423
|
});
|
|
36995
36424
|
|
|
@@ -37058,8 +36487,8 @@ var init_selector = __esm({
|
|
|
37058
36487
|
// packages/ralph/src/story/updater.ts
|
|
37059
36488
|
import { dirname as dirname4 } from "node:path";
|
|
37060
36489
|
import * as fsPromises3 from "node:fs/promises";
|
|
37061
|
-
function lockPlanFile2(
|
|
37062
|
-
return lockFile(
|
|
36490
|
+
function lockPlanFile2(path20) {
|
|
36491
|
+
return lockFile(path20, { retries: 20, minTimeout: 25, maxTimeout: 250 });
|
|
37063
36492
|
}
|
|
37064
36493
|
function assertStoryStatus(value) {
|
|
37065
36494
|
if (value === "open") return;
|
|
@@ -37140,9 +36569,9 @@ function appendSection(lines, title, items, options) {
|
|
|
37140
36569
|
}
|
|
37141
36570
|
lines.push("");
|
|
37142
36571
|
}
|
|
37143
|
-
async function writeRunMeta(
|
|
36572
|
+
async function writeRunMeta(path20, metadata, options = {}) {
|
|
37144
36573
|
const fs3 = options.fs ?? fsPromises4;
|
|
37145
|
-
await fs3.mkdir(dirname5(
|
|
36574
|
+
await fs3.mkdir(dirname5(path20), { recursive: true });
|
|
37146
36575
|
const lines = [];
|
|
37147
36576
|
lines.push("# Ralph Run Summary", "");
|
|
37148
36577
|
lines.push(`- Run ID: ${metadata.runId}`);
|
|
@@ -37171,7 +36600,7 @@ async function writeRunMeta(path21, metadata, options = {}) {
|
|
|
37171
36600
|
const git = metadata.git ?? null;
|
|
37172
36601
|
if (!git) {
|
|
37173
36602
|
lines.push("");
|
|
37174
|
-
await fs3.writeFile(
|
|
36603
|
+
await fs3.writeFile(path20, lines.join("\n"), { encoding: "utf8" });
|
|
37175
36604
|
return;
|
|
37176
36605
|
}
|
|
37177
36606
|
lines.push("", "## Git");
|
|
@@ -37186,7 +36615,7 @@ async function writeRunMeta(path21, metadata, options = {}) {
|
|
|
37186
36615
|
lines.push("");
|
|
37187
36616
|
} else {
|
|
37188
36617
|
lines.push("");
|
|
37189
|
-
await fs3.writeFile(
|
|
36618
|
+
await fs3.writeFile(path20, lines.join("\n"), { encoding: "utf8" });
|
|
37190
36619
|
return;
|
|
37191
36620
|
}
|
|
37192
36621
|
if (git.commits !== void 0 && git.commits !== null) {
|
|
@@ -37206,7 +36635,7 @@ async function writeRunMeta(path21, metadata, options = {}) {
|
|
|
37206
36635
|
appendSection(lines, "### Uncommitted Changes", git.dirtyFiles, {
|
|
37207
36636
|
emptyLabel: "(none)"
|
|
37208
36637
|
});
|
|
37209
|
-
await fs3.writeFile(
|
|
36638
|
+
await fs3.writeFile(path20, lines.join("\n"), { encoding: "utf8" });
|
|
37210
36639
|
}
|
|
37211
36640
|
var init_metadata = __esm({
|
|
37212
36641
|
"packages/ralph/src/run/metadata.ts"() {
|
|
@@ -37294,9 +36723,9 @@ async function defaultStreamingSpawn(agentId, options) {
|
|
|
37294
36723
|
exitCode: result.exitCode
|
|
37295
36724
|
};
|
|
37296
36725
|
}
|
|
37297
|
-
function absPath(cwd,
|
|
37298
|
-
if (!
|
|
37299
|
-
return
|
|
36726
|
+
function absPath(cwd, path20) {
|
|
36727
|
+
if (!path20) return resolvePath3(cwd);
|
|
36728
|
+
return path20.startsWith("/") ? path20 : resolvePath3(cwd, path20);
|
|
37300
36729
|
}
|
|
37301
36730
|
function pad2(value) {
|
|
37302
36731
|
return value < 10 ? `0${value}` : String(value);
|
|
@@ -37346,8 +36775,8 @@ async function appendToErrorsLog(fs3, errorsLogPath, message) {
|
|
|
37346
36775
|
await fs3.mkdir(dirname6(errorsLogPath), { recursive: true });
|
|
37347
36776
|
await fs3.writeFile(errorsLogPath, `${previous}${next}`, { encoding: "utf8" });
|
|
37348
36777
|
}
|
|
37349
|
-
function lockPlanFile3(
|
|
37350
|
-
return lockFile(
|
|
36778
|
+
function lockPlanFile3(path20) {
|
|
36779
|
+
return lockFile(path20, { retries: 20, minTimeout: 25, maxTimeout: 250 });
|
|
37351
36780
|
}
|
|
37352
36781
|
function getCurrentBranch(cwd) {
|
|
37353
36782
|
try {
|
|
@@ -37449,7 +36878,7 @@ async function defaultPromptOverbake(args) {
|
|
|
37449
36878
|
async function buildLoop(options) {
|
|
37450
36879
|
const fs3 = options.deps?.fs ?? fsPromises5;
|
|
37451
36880
|
const lock = options.deps?.lock ?? lockPlanFile3;
|
|
37452
|
-
const
|
|
36881
|
+
const spawn5 = options.deps?.spawn ?? defaultStreamingSpawn;
|
|
37453
36882
|
const git = options.deps?.git ?? {
|
|
37454
36883
|
getHead,
|
|
37455
36884
|
getCommitList,
|
|
@@ -37503,7 +36932,7 @@ async function buildLoop(options) {
|
|
|
37503
36932
|
});
|
|
37504
36933
|
worktreeBranch = entry.branch;
|
|
37505
36934
|
const worktreePath = entry.path;
|
|
37506
|
-
const symlinkFn = fs3.symlink ?? ((target,
|
|
36935
|
+
const symlinkFn = fs3.symlink ?? ((target, path20) => fsPromises5.symlink(target, path20));
|
|
37507
36936
|
const exec = worktreeDeps.exec;
|
|
37508
36937
|
const dirsToLink = [".poe-code-ralph", ".agents/poe-code-ralph"];
|
|
37509
36938
|
for (const dir of dirsToLink) {
|
|
@@ -37618,7 +37047,7 @@ async function buildLoop(options) {
|
|
|
37618
37047
|
let stderrForErrorsLog;
|
|
37619
37048
|
let overbakeAction = null;
|
|
37620
37049
|
try {
|
|
37621
|
-
const result = await
|
|
37050
|
+
const result = await spawn5(options.agent, {
|
|
37622
37051
|
prompt,
|
|
37623
37052
|
cwd,
|
|
37624
37053
|
model: options.model,
|
|
@@ -37791,10 +37220,10 @@ var init_loop = __esm({
|
|
|
37791
37220
|
"packages/ralph/src/build/loop.ts"() {
|
|
37792
37221
|
"use strict";
|
|
37793
37222
|
init_lock();
|
|
37794
|
-
init_src5();
|
|
37795
37223
|
init_src4();
|
|
37796
|
-
|
|
37797
|
-
|
|
37224
|
+
init_src3();
|
|
37225
|
+
init_src();
|
|
37226
|
+
init_src8();
|
|
37798
37227
|
init_detector();
|
|
37799
37228
|
init_utils2();
|
|
37800
37229
|
init_parser();
|
|
@@ -37808,18 +37237,18 @@ var init_loop = __esm({
|
|
|
37808
37237
|
});
|
|
37809
37238
|
|
|
37810
37239
|
// packages/ralph/src/plan/resolver.ts
|
|
37811
|
-
import
|
|
37240
|
+
import path15 from "node:path";
|
|
37812
37241
|
import * as fsPromises6 from "node:fs/promises";
|
|
37813
37242
|
function isPlanCandidateFile(fileName) {
|
|
37814
37243
|
const lower = fileName.toLowerCase();
|
|
37815
37244
|
if (!lower.startsWith("plan")) {
|
|
37816
37245
|
return false;
|
|
37817
37246
|
}
|
|
37818
|
-
const ext =
|
|
37247
|
+
const ext = path15.extname(lower);
|
|
37819
37248
|
return ext === ".yml" || ext === ".yaml";
|
|
37820
37249
|
}
|
|
37821
37250
|
async function listPlanCandidates(fs3, cwd) {
|
|
37822
|
-
const plansDir =
|
|
37251
|
+
const plansDir = path15.join(cwd, ".agents", "poe-code-ralph", "plans");
|
|
37823
37252
|
let entries;
|
|
37824
37253
|
try {
|
|
37825
37254
|
entries = await fs3.readdir(plansDir);
|
|
@@ -37834,12 +37263,12 @@ async function listPlanCandidates(fs3, cwd) {
|
|
|
37834
37263
|
if (!isPlanCandidateFile(entry)) {
|
|
37835
37264
|
continue;
|
|
37836
37265
|
}
|
|
37837
|
-
const absPath2 =
|
|
37266
|
+
const absPath2 = path15.join(plansDir, entry);
|
|
37838
37267
|
const stats = await fs3.stat(absPath2);
|
|
37839
37268
|
if (!stats.isFile()) {
|
|
37840
37269
|
continue;
|
|
37841
37270
|
}
|
|
37842
|
-
const relativePath =
|
|
37271
|
+
const relativePath = path15.relative(cwd, absPath2);
|
|
37843
37272
|
const content = await fs3.readFile(absPath2, "utf8");
|
|
37844
37273
|
const plan = parsePlan(content);
|
|
37845
37274
|
const done = plan.stories.filter((s) => s.status === "done").length;
|
|
@@ -37858,7 +37287,7 @@ async function resolvePlanPath(options) {
|
|
|
37858
37287
|
const cwd = options.cwd;
|
|
37859
37288
|
const provided = options.plan?.trim();
|
|
37860
37289
|
if (provided) {
|
|
37861
|
-
const absPath2 =
|
|
37290
|
+
const absPath2 = path15.isAbsolute(provided) ? provided : path15.resolve(cwd, provided);
|
|
37862
37291
|
try {
|
|
37863
37292
|
const stats = await fs3.stat(absPath2);
|
|
37864
37293
|
if (!stats.isFile()) {
|
|
@@ -37907,21 +37336,21 @@ async function resolvePlanPath(options) {
|
|
|
37907
37336
|
var init_resolver = __esm({
|
|
37908
37337
|
"packages/ralph/src/plan/resolver.ts"() {
|
|
37909
37338
|
"use strict";
|
|
37910
|
-
|
|
37911
|
-
|
|
37339
|
+
init_src3();
|
|
37340
|
+
init_src();
|
|
37912
37341
|
init_parser();
|
|
37913
37342
|
}
|
|
37914
37343
|
});
|
|
37915
37344
|
|
|
37916
37345
|
// packages/ralph/src/plan/generator.ts
|
|
37917
|
-
import
|
|
37346
|
+
import path16 from "node:path";
|
|
37918
37347
|
import * as fsPromises7 from "node:fs/promises";
|
|
37919
37348
|
var PLAN_PROMPT_TEMPLATE;
|
|
37920
37349
|
var init_generator = __esm({
|
|
37921
37350
|
"packages/ralph/src/plan/generator.ts"() {
|
|
37922
37351
|
"use strict";
|
|
37923
|
-
|
|
37924
|
-
|
|
37352
|
+
init_src4();
|
|
37353
|
+
init_src();
|
|
37925
37354
|
init_renderer2();
|
|
37926
37355
|
PLAN_PROMPT_TEMPLATE = [
|
|
37927
37356
|
"# Plan",
|
|
@@ -37983,27 +37412,27 @@ function formatTimestamp3(date4) {
|
|
|
37983
37412
|
const seconds = pad22(date4.getSeconds());
|
|
37984
37413
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
37985
37414
|
}
|
|
37986
|
-
function validateLogPath(
|
|
37987
|
-
if (typeof
|
|
37415
|
+
function validateLogPath(path20) {
|
|
37416
|
+
if (typeof path20 !== "string" || path20.trim().length === 0) {
|
|
37988
37417
|
throw new Error(
|
|
37989
|
-
`Invalid activity log path: expected a non-empty string, got ${String(
|
|
37418
|
+
`Invalid activity log path: expected a non-empty string, got ${String(path20)}`
|
|
37990
37419
|
);
|
|
37991
37420
|
}
|
|
37992
|
-
if (
|
|
37421
|
+
if (path20.includes("\0")) {
|
|
37993
37422
|
throw new Error("Invalid activity log path: contains null byte");
|
|
37994
37423
|
}
|
|
37995
37424
|
}
|
|
37996
|
-
async function logActivity(
|
|
37997
|
-
validateLogPath(
|
|
37425
|
+
async function logActivity(path20, message, options = {}) {
|
|
37426
|
+
validateLogPath(path20);
|
|
37998
37427
|
const fs3 = options.fs ?? fsPromises8;
|
|
37999
|
-
const parent = dirname7(
|
|
37428
|
+
const parent = dirname7(path20);
|
|
38000
37429
|
if (parent && parent !== ".") {
|
|
38001
37430
|
await fs3.mkdir(parent, { recursive: true });
|
|
38002
37431
|
}
|
|
38003
37432
|
const entry = `[${formatTimestamp3(/* @__PURE__ */ new Date())}] ${message}
|
|
38004
37433
|
`;
|
|
38005
37434
|
try {
|
|
38006
|
-
await fs3.appendFile(
|
|
37435
|
+
await fs3.appendFile(path20, entry, { encoding: "utf8" });
|
|
38007
37436
|
} catch (error2) {
|
|
38008
37437
|
const detail = error2 instanceof Error ? error2.message : `Unknown error: ${String(error2)}`;
|
|
38009
37438
|
throw new Error(`Failed to append activity log entry: ${detail}`, { cause: error2 });
|
|
@@ -38016,7 +37445,7 @@ var init_activity = __esm({
|
|
|
38016
37445
|
});
|
|
38017
37446
|
|
|
38018
37447
|
// packages/ralph/src/config/loader.ts
|
|
38019
|
-
import
|
|
37448
|
+
import path17 from "node:path";
|
|
38020
37449
|
import * as fsPromises9 from "node:fs/promises";
|
|
38021
37450
|
import YAML from "yaml";
|
|
38022
37451
|
function isPlainObject2(value) {
|
|
@@ -38051,8 +37480,8 @@ function pickOptionalPositiveInt(config2, key, options) {
|
|
|
38051
37480
|
return value;
|
|
38052
37481
|
}
|
|
38053
37482
|
async function loadSingleConfig(configDir, fs3) {
|
|
38054
|
-
const yamlPath =
|
|
38055
|
-
const jsonPath =
|
|
37483
|
+
const yamlPath = path17.join(configDir, "config.yaml");
|
|
37484
|
+
const jsonPath = path17.join(configDir, "config.json");
|
|
38056
37485
|
let raw = null;
|
|
38057
37486
|
let format = null;
|
|
38058
37487
|
let sourcePath = null;
|
|
@@ -38125,14 +37554,14 @@ async function loadConfig(cwd, deps) {
|
|
|
38125
37554
|
const sources = [];
|
|
38126
37555
|
let merged = {};
|
|
38127
37556
|
if (deps?.homeDir) {
|
|
38128
|
-
const globalDir =
|
|
37557
|
+
const globalDir = path17.join(deps.homeDir, ".poe-code", "ralph");
|
|
38129
37558
|
const globalResult = await loadSingleConfig(globalDir, fs3);
|
|
38130
37559
|
if (globalResult) {
|
|
38131
37560
|
merged = globalResult.config;
|
|
38132
37561
|
sources.push({ path: globalResult.sourcePath, scope: "global" });
|
|
38133
37562
|
}
|
|
38134
37563
|
}
|
|
38135
|
-
const localDir =
|
|
37564
|
+
const localDir = path17.join(cwd, ".agents", "poe-code-ralph");
|
|
38136
37565
|
const localResult = await loadSingleConfig(localDir, fs3);
|
|
38137
37566
|
if (localResult) {
|
|
38138
37567
|
merged = mergeConfigs(merged, localResult.config);
|
|
@@ -38143,7 +37572,7 @@ async function loadConfig(cwd, deps) {
|
|
|
38143
37572
|
var init_loader = __esm({
|
|
38144
37573
|
"packages/ralph/src/config/loader.ts"() {
|
|
38145
37574
|
"use strict";
|
|
38146
|
-
|
|
37575
|
+
init_src();
|
|
38147
37576
|
}
|
|
38148
37577
|
});
|
|
38149
37578
|
|
|
@@ -38154,7 +37583,7 @@ async function ralphBuild(options) {
|
|
|
38154
37583
|
cwd: options.cwd ?? process.cwd()
|
|
38155
37584
|
});
|
|
38156
37585
|
}
|
|
38157
|
-
var
|
|
37586
|
+
var init_src9 = __esm({
|
|
38158
37587
|
"packages/ralph/src/index.ts"() {
|
|
38159
37588
|
"use strict";
|
|
38160
37589
|
init_loop();
|
|
@@ -38174,12 +37603,12 @@ var require_PROMPT_worktree_merge = __commonJS({
|
|
|
38174
37603
|
});
|
|
38175
37604
|
|
|
38176
37605
|
// src/cli/commands/ralph-worktree.ts
|
|
38177
|
-
import
|
|
37606
|
+
import path18 from "node:path";
|
|
38178
37607
|
import { execSync as execSync3 } from "node:child_process";
|
|
38179
37608
|
function registerRalphWorktreeCommand(ralph, container) {
|
|
38180
37609
|
ralph.command("worktree").description("Merge a completed worktree back into the main branch.").argument("<name>", "Name of the worktree to merge").option("--agent <name>", "Agent to use for the merge").action(async function(name) {
|
|
38181
37610
|
const cwd = container.env.cwd;
|
|
38182
|
-
const registryFile =
|
|
37611
|
+
const registryFile = path18.join(cwd, ".poe-code-ralph", "worktrees.yaml");
|
|
38183
37612
|
const worktrees = await listWorktrees(cwd, registryFile, {
|
|
38184
37613
|
fs: {
|
|
38185
37614
|
readFile: (p, enc) => container.fs.readFile(p, enc),
|
|
@@ -38242,10 +37671,10 @@ function registerRalphWorktreeCommand(ralph, container) {
|
|
|
38242
37671
|
var init_ralph_worktree = __esm({
|
|
38243
37672
|
"src/cli/commands/ralph-worktree.ts"() {
|
|
38244
37673
|
"use strict";
|
|
37674
|
+
init_src3();
|
|
37675
|
+
init_src8();
|
|
38245
37676
|
init_src4();
|
|
38246
|
-
|
|
38247
|
-
init_src5();
|
|
38248
|
-
init_src2();
|
|
37677
|
+
init_src();
|
|
38249
37678
|
init_errors();
|
|
38250
37679
|
}
|
|
38251
37680
|
});
|
|
@@ -38321,7 +37750,7 @@ var require_activity = __commonJS({
|
|
|
38321
37750
|
});
|
|
38322
37751
|
|
|
38323
37752
|
// src/cli/commands/ralph.ts
|
|
38324
|
-
import
|
|
37753
|
+
import path19 from "node:path";
|
|
38325
37754
|
async function loadRalphTemplates() {
|
|
38326
37755
|
const [
|
|
38327
37756
|
promptPartialPlan,
|
|
@@ -38406,7 +37835,7 @@ async function writeFileOrSkip(args) {
|
|
|
38406
37835
|
args.logger.info(`Skip: ${args.displayPath} (already exists)`);
|
|
38407
37836
|
return "skipped";
|
|
38408
37837
|
}
|
|
38409
|
-
await args.fs.mkdir(
|
|
37838
|
+
await args.fs.mkdir(path19.dirname(args.filePath), { recursive: true });
|
|
38410
37839
|
await args.fs.writeFile(args.filePath, args.contents, { encoding: "utf8" });
|
|
38411
37840
|
args.logger.info(`${exists ? "Overwrite" : "Create"}: ${args.displayPath}`);
|
|
38412
37841
|
return "written";
|
|
@@ -38442,22 +37871,22 @@ async function installRalphTemplates(args) {
|
|
|
38442
37871
|
const promptPlanContents = templates.promptPlan.replace("{{{PROMPT_PARTIAL_PLAN}}}", templates.promptPartialPlan);
|
|
38443
37872
|
const templateWrites = [
|
|
38444
37873
|
{
|
|
38445
|
-
targetPath:
|
|
37874
|
+
targetPath: path19.join(cwd, ".agents", "poe-code-ralph", "PROMPT_plan.md"),
|
|
38446
37875
|
displayPath: ".agents/poe-code-ralph/PROMPT_plan.md",
|
|
38447
37876
|
contents: promptPlanContents
|
|
38448
37877
|
},
|
|
38449
37878
|
{
|
|
38450
|
-
targetPath:
|
|
37879
|
+
targetPath: path19.join(cwd, ".agents", "poe-code-ralph", "PROMPT_build.md"),
|
|
38451
37880
|
displayPath: ".agents/poe-code-ralph/PROMPT_build.md",
|
|
38452
37881
|
contents: templates.promptBuild
|
|
38453
37882
|
},
|
|
38454
37883
|
{
|
|
38455
|
-
targetPath:
|
|
37884
|
+
targetPath: path19.join(cwd, ".agents", "poe-code-ralph", "references", "GUARDRAILS.md"),
|
|
38456
37885
|
displayPath: ".agents/poe-code-ralph/references/GUARDRAILS.md",
|
|
38457
37886
|
contents: templates.refGuardrails
|
|
38458
37887
|
},
|
|
38459
37888
|
{
|
|
38460
|
-
targetPath:
|
|
37889
|
+
targetPath: path19.join(cwd, ".agents", "poe-code-ralph", "references", "CONTEXT_ENGINEERING.md"),
|
|
38461
37890
|
displayPath: ".agents/poe-code-ralph/references/CONTEXT_ENGINEERING.md",
|
|
38462
37891
|
contents: templates.refContextEngineering
|
|
38463
37892
|
}
|
|
@@ -38475,22 +37904,22 @@ async function installRalphTemplates(args) {
|
|
|
38475
37904
|
const stateFiles = [
|
|
38476
37905
|
{
|
|
38477
37906
|
contents: templates.stateProgress,
|
|
38478
|
-
targetPath:
|
|
37907
|
+
targetPath: path19.join(cwd, ".poe-code-ralph", "progress.md"),
|
|
38479
37908
|
displayPath: ".poe-code-ralph/progress.md"
|
|
38480
37909
|
},
|
|
38481
37910
|
{
|
|
38482
37911
|
contents: templates.stateGuardrails,
|
|
38483
|
-
targetPath:
|
|
37912
|
+
targetPath: path19.join(cwd, ".poe-code-ralph", "guardrails.md"),
|
|
38484
37913
|
displayPath: ".poe-code-ralph/guardrails.md"
|
|
38485
37914
|
},
|
|
38486
37915
|
{
|
|
38487
37916
|
contents: templates.stateErrors,
|
|
38488
|
-
targetPath:
|
|
37917
|
+
targetPath: path19.join(cwd, ".poe-code-ralph", "errors.log"),
|
|
38489
37918
|
displayPath: ".poe-code-ralph/errors.log"
|
|
38490
37919
|
},
|
|
38491
37920
|
{
|
|
38492
37921
|
contents: templates.stateActivity,
|
|
38493
|
-
targetPath:
|
|
37922
|
+
targetPath: path19.join(cwd, ".poe-code-ralph", "activity.log"),
|
|
38494
37923
|
displayPath: ".poe-code-ralph/activity.log"
|
|
38495
37924
|
}
|
|
38496
37925
|
];
|
|
@@ -38537,7 +37966,7 @@ function registerRalphCommand(program, container) {
|
|
|
38537
37966
|
throw new ValidationError(message2);
|
|
38538
37967
|
}
|
|
38539
37968
|
const rawPath = options.activityLog?.trim() || configActivityLogPath || ".poe-code-ralph/activity.log";
|
|
38540
|
-
const resolvedPath =
|
|
37969
|
+
const resolvedPath = path19.isAbsolute(rawPath) ? rawPath : path19.resolve(container.env.cwd, rawPath);
|
|
38541
37970
|
await logActivity(resolvedPath, trimmedMessage, {
|
|
38542
37971
|
fs: container.fs
|
|
38543
37972
|
});
|
|
@@ -38549,7 +37978,7 @@ function registerRalphCommand(program, container) {
|
|
|
38549
37978
|
if (!planPath) {
|
|
38550
37979
|
throw new ValidationError("--plan <path> is required.");
|
|
38551
37980
|
}
|
|
38552
|
-
const resolvedPath =
|
|
37981
|
+
const resolvedPath = path19.isAbsolute(planPath) ? planPath : path19.resolve(cwd, planPath);
|
|
38553
37982
|
let content;
|
|
38554
37983
|
try {
|
|
38555
37984
|
content = await container.fs.readFile(resolvedPath, "utf8");
|
|
@@ -38723,7 +38152,7 @@ function registerRalphCommand(program, container) {
|
|
|
38723
38152
|
} else {
|
|
38724
38153
|
try {
|
|
38725
38154
|
const planContent = await container.fs.readFile(
|
|
38726
|
-
|
|
38155
|
+
path19.resolve(cwd, planPath),
|
|
38727
38156
|
"utf8"
|
|
38728
38157
|
);
|
|
38729
38158
|
const plan = parsePlan(planContent);
|
|
@@ -38757,7 +38186,7 @@ function registerRalphCommand(program, container) {
|
|
|
38757
38186
|
} else {
|
|
38758
38187
|
try {
|
|
38759
38188
|
const planContent = await container.fs.readFile(
|
|
38760
|
-
|
|
38189
|
+
path19.resolve(cwd, planPath),
|
|
38761
38190
|
"utf8"
|
|
38762
38191
|
);
|
|
38763
38192
|
const plan = parsePlan(planContent);
|
|
@@ -38813,10 +38242,10 @@ var templateImports, DEFAULT_RALPH_AGENT;
|
|
|
38813
38242
|
var init_ralph = __esm({
|
|
38814
38243
|
"src/cli/commands/ralph.ts"() {
|
|
38815
38244
|
"use strict";
|
|
38816
|
-
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38245
|
+
init_src3();
|
|
38246
|
+
init_src9();
|
|
38247
|
+
init_src7();
|
|
38248
|
+
init_src();
|
|
38820
38249
|
init_errors();
|
|
38821
38250
|
init_shared();
|
|
38822
38251
|
init_ralph_worktree();
|
|
@@ -39037,7 +38466,7 @@ var init_usage = __esm({
|
|
|
39037
38466
|
"use strict";
|
|
39038
38467
|
init_shared();
|
|
39039
38468
|
init_errors();
|
|
39040
|
-
|
|
38469
|
+
init_src3();
|
|
39041
38470
|
}
|
|
39042
38471
|
});
|
|
39043
38472
|
|
|
@@ -39130,7 +38559,10 @@ function registerModelsCommand(program, container) {
|
|
|
39130
38559
|
const commandOptions = this.opts();
|
|
39131
38560
|
resources.logger.intro("models");
|
|
39132
38561
|
try {
|
|
39133
|
-
const apiKey = await
|
|
38562
|
+
const apiKey = await loadCredentials({
|
|
38563
|
+
fs: container.fs,
|
|
38564
|
+
filePath: container.env.credentialsPath
|
|
38565
|
+
});
|
|
39134
38566
|
if (flags.dryRun) {
|
|
39135
38567
|
resources.logger.dryRun(
|
|
39136
38568
|
"Dry run: would fetch models from Poe API."
|
|
@@ -39318,8 +38750,9 @@ var init_models = __esm({
|
|
|
39318
38750
|
"src/cli/commands/models.ts"() {
|
|
39319
38751
|
"use strict";
|
|
39320
38752
|
init_shared();
|
|
38753
|
+
init_credentials2();
|
|
39321
38754
|
init_errors();
|
|
39322
|
-
|
|
38755
|
+
init_src3();
|
|
39323
38756
|
MAX_VALUES_LENGTH = 105;
|
|
39324
38757
|
MAX_DEFAULT_LENGTH = 36;
|
|
39325
38758
|
}
|
|
@@ -39331,7 +38764,7 @@ var init_package = __esm({
|
|
|
39331
38764
|
"package.json"() {
|
|
39332
38765
|
package_default = {
|
|
39333
38766
|
name: "poe-code",
|
|
39334
|
-
version: "3.0.71
|
|
38767
|
+
version: "3.0.71",
|
|
39335
38768
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
39336
38769
|
type: "module",
|
|
39337
38770
|
main: "./dist/index.js",
|
|
@@ -39413,7 +38846,6 @@ var init_package = __esm({
|
|
|
39413
38846
|
devDependencies: {
|
|
39414
38847
|
"@eslint/js": "^9.0.0",
|
|
39415
38848
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
39416
|
-
"@poe-code/auth": "*",
|
|
39417
38849
|
"@poe-code/agent-spawn": "*",
|
|
39418
38850
|
"@poe-code/config-mutations": "*",
|
|
39419
38851
|
"@poe-code/design-system": "*",
|
|
@@ -39477,26 +38909,21 @@ function formatHelpText(input) {
|
|
|
39477
38909
|
args: "<agent>",
|
|
39478
38910
|
description: "Remove a previously applied configuration"
|
|
39479
38911
|
},
|
|
39480
|
-
{
|
|
39481
|
-
name: "login",
|
|
39482
|
-
args: "",
|
|
39483
|
-
description: "Store a Poe API key"
|
|
39484
|
-
},
|
|
39485
38912
|
{
|
|
39486
38913
|
name: "logout",
|
|
39487
38914
|
args: "",
|
|
39488
|
-
description: "Remove all configuration"
|
|
39489
|
-
},
|
|
39490
|
-
{
|
|
39491
|
-
name: "auth status",
|
|
39492
|
-
args: "",
|
|
39493
|
-
description: "Show login, balance, and configuration status"
|
|
38915
|
+
description: "Remove all configuration and stored credentials"
|
|
39494
38916
|
},
|
|
39495
38917
|
{
|
|
39496
38918
|
name: "spawn",
|
|
39497
38919
|
args: "<agent> [prompt]",
|
|
39498
38920
|
description: "Launch a coding agent"
|
|
39499
38921
|
},
|
|
38922
|
+
{
|
|
38923
|
+
name: "research",
|
|
38924
|
+
args: "<prompt>",
|
|
38925
|
+
description: "Research a codebase using a coding agent"
|
|
38926
|
+
},
|
|
39500
38927
|
{
|
|
39501
38928
|
name: "generate",
|
|
39502
38929
|
args: "[type]",
|
|
@@ -39680,7 +39107,6 @@ function bootstrapProgram(container) {
|
|
|
39680
39107
|
registerUnconfigureCommand(program, container);
|
|
39681
39108
|
registerLoginCommand(program, container);
|
|
39682
39109
|
registerLogoutCommand(program, container);
|
|
39683
|
-
registerAuthCommand(program, container);
|
|
39684
39110
|
registerMcpCommand(program, container);
|
|
39685
39111
|
registerSkillCommand(program, container);
|
|
39686
39112
|
registerRalphCommand(program, container);
|
|
@@ -39722,14 +39148,13 @@ var init_program = __esm({
|
|
|
39722
39148
|
async "src/cli/program.ts"() {
|
|
39723
39149
|
"use strict";
|
|
39724
39150
|
await init_container2();
|
|
39725
|
-
|
|
39151
|
+
init_src3();
|
|
39726
39152
|
init_configure();
|
|
39727
39153
|
await init_spawn4();
|
|
39728
39154
|
await init_research2();
|
|
39729
39155
|
init_wrap();
|
|
39730
39156
|
init_login();
|
|
39731
39157
|
init_logout();
|
|
39732
|
-
init_auth();
|
|
39733
39158
|
init_install();
|
|
39734
39159
|
init_unconfigure();
|
|
39735
39160
|
init_test();
|
|
@@ -39820,7 +39245,7 @@ function createPromptRunner(adapter = {
|
|
|
39820
39245
|
var init_prompt_runner = __esm({
|
|
39821
39246
|
"src/cli/prompt-runner.ts"() {
|
|
39822
39247
|
"use strict";
|
|
39823
|
-
|
|
39248
|
+
init_src3();
|
|
39824
39249
|
init_errors();
|
|
39825
39250
|
}
|
|
39826
39251
|
});
|
|
@@ -39831,17 +39256,17 @@ __export(bootstrap_exports, {
|
|
|
39831
39256
|
createCliMain: () => createCliMain,
|
|
39832
39257
|
isCliInvocation: () => isCliInvocation
|
|
39833
39258
|
});
|
|
39834
|
-
import * as
|
|
39259
|
+
import * as nodeFs from "node:fs/promises";
|
|
39835
39260
|
import * as nodeFsSync3 from "node:fs";
|
|
39836
39261
|
import { realpathSync } from "node:fs";
|
|
39837
|
-
import { homedir as
|
|
39262
|
+
import { homedir as homedir3 } from "node:os";
|
|
39838
39263
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
39839
|
-
import { join as
|
|
39264
|
+
import { join as join3 } from "node:path";
|
|
39840
39265
|
import chalk13 from "chalk";
|
|
39841
39266
|
function createCliMain(programFactory) {
|
|
39842
39267
|
return async function runCli() {
|
|
39843
|
-
const homeDir =
|
|
39844
|
-
const logDir =
|
|
39268
|
+
const homeDir = homedir3();
|
|
39269
|
+
const logDir = join3(homeDir, ".poe-code", "logs");
|
|
39845
39270
|
const promptRunner = createPromptRunner();
|
|
39846
39271
|
const shouldLogToStderr = process.env.POE_CODE_STDERR_LOGS === "1" || process.env.POE_CODE_STDERR_LOGS === "true";
|
|
39847
39272
|
const errorLogger = new ErrorLogger({
|
|
@@ -39876,7 +39301,7 @@ function createCliMain(programFactory) {
|
|
|
39876
39301
|
} else {
|
|
39877
39302
|
log2.error(`Error: ${error2.message}`);
|
|
39878
39303
|
log2.message(
|
|
39879
|
-
`See logs at ${
|
|
39304
|
+
`See logs at ${join3(logDir, "errors.log")} for more details.`,
|
|
39880
39305
|
{ symbol: chalk13.magenta("\u25CF") }
|
|
39881
39306
|
);
|
|
39882
39307
|
}
|
|
@@ -39902,11 +39327,11 @@ var fsAdapter;
|
|
|
39902
39327
|
var init_bootstrap = __esm({
|
|
39903
39328
|
"src/cli/bootstrap.ts"() {
|
|
39904
39329
|
"use strict";
|
|
39905
|
-
|
|
39330
|
+
init_src3();
|
|
39906
39331
|
init_error_logger();
|
|
39907
39332
|
init_errors();
|
|
39908
39333
|
init_prompt_runner();
|
|
39909
|
-
fsAdapter =
|
|
39334
|
+
fsAdapter = nodeFs;
|
|
39910
39335
|
}
|
|
39911
39336
|
});
|
|
39912
39337
|
|
|
@@ -40045,6 +39470,6 @@ export {
|
|
|
40045
39470
|
getPoeApiKey,
|
|
40046
39471
|
isCliInvocation2 as isCliInvocation,
|
|
40047
39472
|
main,
|
|
40048
|
-
|
|
39473
|
+
spawn3 as spawn
|
|
40049
39474
|
};
|
|
40050
39475
|
//# sourceMappingURL=index.js.map
|