poe-code 3.0.39 → 3.0.41
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/dist/cli/commands/generate.js +1 -40
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/models.js +17 -11
- package/dist/cli/commands/models.js.map +1 -1
- package/dist/cli/commands/test.js +49 -40
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/usage.js +25 -7
- package/dist/cli/commands/usage.js.map +1 -1
- package/dist/cli/prompts.js +1 -1
- package/dist/cli/prompts.js.map +1 -1
- package/dist/index.js +165 -106
- package/dist/index.js.map +3 -3
- package/dist/utils/command-checks.js +19 -3
- package/dist/utils/command-checks.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15090,7 +15090,7 @@ function createPromptLibrary() {
|
|
|
15090
15090
|
return {
|
|
15091
15091
|
loginApiKey: () => describe3({
|
|
15092
15092
|
name: "apiKey",
|
|
15093
|
-
message: "Enter your Poe API key
|
|
15093
|
+
message: "Enter your Poe API key - get one at https://poe.com/api/keys",
|
|
15094
15094
|
type: "password"
|
|
15095
15095
|
}),
|
|
15096
15096
|
model: ({ label, defaultValue, choices }) => {
|
|
@@ -15721,6 +15721,61 @@ async function password2(opts) {
|
|
|
15721
15721
|
function spinner2() {
|
|
15722
15722
|
return clack.spinner();
|
|
15723
15723
|
}
|
|
15724
|
+
function formatElapsed(ms) {
|
|
15725
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
15726
|
+
if (totalSeconds < 60) {
|
|
15727
|
+
return `${totalSeconds}s`;
|
|
15728
|
+
}
|
|
15729
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
15730
|
+
const seconds = totalSeconds % 60;
|
|
15731
|
+
return `${minutes}m ${seconds}s`;
|
|
15732
|
+
}
|
|
15733
|
+
async function withSpinner(options) {
|
|
15734
|
+
const { message, fn, stopMessage, subtext } = options;
|
|
15735
|
+
const noSpinner = process.env.POE_NO_SPINNER === "1";
|
|
15736
|
+
const isTTY = process.stdout.isTTY;
|
|
15737
|
+
if (noSpinner || !isTTY) {
|
|
15738
|
+
const result = await fn();
|
|
15739
|
+
const msg = stopMessage ? stopMessage(result) : void 0;
|
|
15740
|
+
if (msg) {
|
|
15741
|
+
process.stdout.write(`\x1B[32m\u25C6\x1B[0m ${msg}
|
|
15742
|
+
`);
|
|
15743
|
+
}
|
|
15744
|
+
const sub = subtext ? subtext(result) : void 0;
|
|
15745
|
+
if (sub) {
|
|
15746
|
+
for (const line of sub.split("\n")) {
|
|
15747
|
+
process.stdout.write(`\x1B[90m\u2502\x1B[0m ${line}
|
|
15748
|
+
`);
|
|
15749
|
+
}
|
|
15750
|
+
}
|
|
15751
|
+
return result;
|
|
15752
|
+
}
|
|
15753
|
+
const s = spinner2();
|
|
15754
|
+
const start = Date.now();
|
|
15755
|
+
s.start(message);
|
|
15756
|
+
const timer = setInterval(() => {
|
|
15757
|
+
s.message(`${message} [${formatElapsed(Date.now() - start)}]`);
|
|
15758
|
+
}, 1e3);
|
|
15759
|
+
try {
|
|
15760
|
+
const result = await fn();
|
|
15761
|
+
clearInterval(timer);
|
|
15762
|
+
const elapsed = formatElapsed(Date.now() - start);
|
|
15763
|
+
const msg = stopMessage ? stopMessage(result) : void 0;
|
|
15764
|
+
s.stop(msg ? `${msg} [${elapsed}]` : `Done [${elapsed}]`);
|
|
15765
|
+
const sub = subtext ? subtext(result) : void 0;
|
|
15766
|
+
if (sub) {
|
|
15767
|
+
for (const line of sub.split("\n")) {
|
|
15768
|
+
process.stdout.write(`\x1B[90m\u2502\x1B[0m ${line}
|
|
15769
|
+
`);
|
|
15770
|
+
}
|
|
15771
|
+
}
|
|
15772
|
+
return result;
|
|
15773
|
+
} catch (error2) {
|
|
15774
|
+
clearInterval(timer);
|
|
15775
|
+
s.stop("", 1);
|
|
15776
|
+
throw error2;
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15724
15779
|
|
|
15725
15780
|
// packages/design-system/src/static/spinner.ts
|
|
15726
15781
|
import chalk8 from "chalk";
|
|
@@ -17021,7 +17076,22 @@ function stdoutMatchesExpected(stdout, expected) {
|
|
|
17021
17076
|
if (trimmed === expected) {
|
|
17022
17077
|
return true;
|
|
17023
17078
|
}
|
|
17024
|
-
|
|
17079
|
+
const lines = stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
17080
|
+
if (lines.some((line) => line === expected)) {
|
|
17081
|
+
return true;
|
|
17082
|
+
}
|
|
17083
|
+
for (const line of lines) {
|
|
17084
|
+
if (line[0] !== "{") continue;
|
|
17085
|
+
try {
|
|
17086
|
+
const parsed = JSON.parse(line);
|
|
17087
|
+
if (parsed.type === "result" && parsed.result === expected) {
|
|
17088
|
+
return true;
|
|
17089
|
+
}
|
|
17090
|
+
} catch {
|
|
17091
|
+
continue;
|
|
17092
|
+
}
|
|
17093
|
+
}
|
|
17094
|
+
return false;
|
|
17025
17095
|
}
|
|
17026
17096
|
function createSpawnHealthCheck(agentId, options) {
|
|
17027
17097
|
const prompt = `Output exactly: ${options.expectedOutput}`;
|
|
@@ -19214,31 +19284,35 @@ async function executeTest(program, container, service, options = {}) {
|
|
|
19214
19284
|
}
|
|
19215
19285
|
const expectedOutput = "STDIN_OK";
|
|
19216
19286
|
const prompt = `Output exactly: ${expectedOutput}`;
|
|
19217
|
-
const result = await (
|
|
19218
|
-
|
|
19219
|
-
|
|
19220
|
-
|
|
19221
|
-
|
|
19222
|
-
|
|
19223
|
-
model: options.model
|
|
19224
|
-
});
|
|
19225
|
-
}
|
|
19226
|
-
return container.registry.invoke(
|
|
19227
|
-
canonicalService,
|
|
19228
|
-
"spawn",
|
|
19229
|
-
async (entry) => {
|
|
19230
|
-
if (!entry.spawn) {
|
|
19231
|
-
throw new Error(`Agent "${canonicalService}" does not support spawn.`);
|
|
19232
|
-
}
|
|
19233
|
-
const output = await entry.spawn(providerContext, {
|
|
19287
|
+
const result = await withSpinner({
|
|
19288
|
+
message: `Testing ${adapter.label} via stdin...`,
|
|
19289
|
+
fn: async () => {
|
|
19290
|
+
const spawnConfig = getSpawnConfig(canonicalService);
|
|
19291
|
+
if (spawnConfig) {
|
|
19292
|
+
return spawn2(canonicalService, {
|
|
19234
19293
|
prompt,
|
|
19235
19294
|
useStdin: true,
|
|
19236
19295
|
model: options.model
|
|
19237
19296
|
});
|
|
19238
|
-
return output;
|
|
19239
19297
|
}
|
|
19240
|
-
|
|
19241
|
-
|
|
19298
|
+
return container.registry.invoke(
|
|
19299
|
+
canonicalService,
|
|
19300
|
+
"spawn",
|
|
19301
|
+
async (entry) => {
|
|
19302
|
+
if (!entry.spawn) {
|
|
19303
|
+
throw new Error(`Agent "${canonicalService}" does not support spawn.`);
|
|
19304
|
+
}
|
|
19305
|
+
const output = await entry.spawn(providerContext, {
|
|
19306
|
+
prompt,
|
|
19307
|
+
useStdin: true,
|
|
19308
|
+
model: options.model
|
|
19309
|
+
});
|
|
19310
|
+
return output;
|
|
19311
|
+
}
|
|
19312
|
+
);
|
|
19313
|
+
},
|
|
19314
|
+
stopMessage: () => `${adapter.label} stdin test`
|
|
19315
|
+
});
|
|
19242
19316
|
if (!result) {
|
|
19243
19317
|
throw new Error(
|
|
19244
19318
|
`Stdin spawn test for ${adapter.label} did not return command output.`
|
|
@@ -19261,26 +19335,30 @@ async function executeTest(program, container, service, options = {}) {
|
|
|
19261
19335
|
);
|
|
19262
19336
|
}
|
|
19263
19337
|
} else {
|
|
19264
|
-
await
|
|
19265
|
-
|
|
19266
|
-
|
|
19267
|
-
|
|
19268
|
-
|
|
19269
|
-
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19273
|
-
|
|
19274
|
-
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19278
|
-
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
|
|
19338
|
+
await withSpinner({
|
|
19339
|
+
message: `Testing ${adapter.label}...`,
|
|
19340
|
+
fn: () => container.registry.invoke(canonicalService, "test", async (entry) => {
|
|
19341
|
+
if (!entry.test) {
|
|
19342
|
+
throw new Error(`Agent "${canonicalService}" does not support test.`);
|
|
19343
|
+
}
|
|
19344
|
+
const activeContext = isolatedDetails ? {
|
|
19345
|
+
...providerContext,
|
|
19346
|
+
runCheck: async (check2) => {
|
|
19347
|
+
await check2.run({
|
|
19348
|
+
isDryRun: providerContext.logger.context.dryRun,
|
|
19349
|
+
runCommand: (command, args) => resources.context.runCommand("poe-code", [
|
|
19350
|
+
"wrap",
|
|
19351
|
+
canonicalService,
|
|
19352
|
+
"--",
|
|
19353
|
+
...args
|
|
19354
|
+
]),
|
|
19355
|
+
logDryRun: (message) => providerContext.logger.dryRun(message)
|
|
19356
|
+
});
|
|
19357
|
+
}
|
|
19358
|
+
} : providerContext;
|
|
19359
|
+
await entry.test(activeContext);
|
|
19360
|
+
}),
|
|
19361
|
+
stopMessage: () => `${adapter.label} health check`
|
|
19284
19362
|
});
|
|
19285
19363
|
}
|
|
19286
19364
|
const dryMessage = canonicalService === "claude-code" ? `${adapter.label} test (dry run)` : `Dry run: would test ${adapter.label}.`;
|
|
@@ -19683,47 +19761,6 @@ function collectParam(value, previous) {
|
|
|
19683
19761
|
list.push(value);
|
|
19684
19762
|
return list;
|
|
19685
19763
|
}
|
|
19686
|
-
async function withSpinner(options) {
|
|
19687
|
-
const { message, fn, stopMessage, subtext } = options;
|
|
19688
|
-
const noSpinner = process.env.POE_NO_SPINNER === "1";
|
|
19689
|
-
const isTTY = process.stdout.isTTY;
|
|
19690
|
-
if (noSpinner || !isTTY) {
|
|
19691
|
-
const result = await fn();
|
|
19692
|
-
const msg = stopMessage ? stopMessage(result) : void 0;
|
|
19693
|
-
if (msg) {
|
|
19694
|
-
process.stdout.write(`\x1B[32m\u25C6\x1B[0m ${msg}
|
|
19695
|
-
`);
|
|
19696
|
-
}
|
|
19697
|
-
const sub = subtext ? subtext(result) : void 0;
|
|
19698
|
-
if (sub) {
|
|
19699
|
-
const lines = sub.split("\n");
|
|
19700
|
-
for (const line of lines) {
|
|
19701
|
-
process.stdout.write(`\x1B[90m\u2502\x1B[0m ${line}
|
|
19702
|
-
`);
|
|
19703
|
-
}
|
|
19704
|
-
}
|
|
19705
|
-
return result;
|
|
19706
|
-
}
|
|
19707
|
-
const s = spinner2();
|
|
19708
|
-
s.start(message);
|
|
19709
|
-
try {
|
|
19710
|
-
const result = await fn();
|
|
19711
|
-
const msg = stopMessage ? stopMessage(result) : void 0;
|
|
19712
|
-
s.stop(msg);
|
|
19713
|
-
const sub = subtext ? subtext(result) : void 0;
|
|
19714
|
-
if (sub) {
|
|
19715
|
-
const lines = sub.split("\n");
|
|
19716
|
-
for (const line of lines) {
|
|
19717
|
-
process.stdout.write(`\x1B[90m\u2502\x1B[0m ${line}
|
|
19718
|
-
`);
|
|
19719
|
-
}
|
|
19720
|
-
}
|
|
19721
|
-
return result;
|
|
19722
|
-
} catch (error2) {
|
|
19723
|
-
s.stop("", 1);
|
|
19724
|
-
throw error2;
|
|
19725
|
-
}
|
|
19726
|
-
}
|
|
19727
19764
|
async function resolveClient(container) {
|
|
19728
19765
|
try {
|
|
19729
19766
|
return getGlobalClient();
|
|
@@ -36026,14 +36063,18 @@ function registerUsageCommand(program, container) {
|
|
|
36026
36063
|
const tzAbbr = Intl.DateTimeFormat("en-US", { timeZoneName: "short" }).formatToParts(/* @__PURE__ */ new Date()).find((p) => p.type === "timeZoneName")?.value ?? "local";
|
|
36027
36064
|
const dateTitle = `Date [${tzAbbr}]`;
|
|
36028
36065
|
const dateWidth = Math.max(16, dateTitle.length);
|
|
36029
|
-
const costTitle = "Cost
|
|
36030
|
-
const costWidth =
|
|
36031
|
-
const
|
|
36032
|
-
const
|
|
36066
|
+
const costTitle = "Cost";
|
|
36067
|
+
const costWidth = 24;
|
|
36068
|
+
const tokenWidth = 10;
|
|
36069
|
+
const tableChrome = 22;
|
|
36070
|
+
const modelMaxWidth = Math.max(20, widths.maxLine - dateWidth - costWidth - tokenWidth * 3 - tableChrome);
|
|
36033
36071
|
const tableColumns = [
|
|
36034
36072
|
{ name: "Date", title: dateTitle, alignment: "left", maxLen: dateWidth },
|
|
36035
36073
|
{ name: "Model", title: "Model", alignment: "left", maxLen: modelMaxWidth },
|
|
36036
|
-
{ name: "Cost", title: costTitle, alignment: "right", maxLen: costWidth }
|
|
36074
|
+
{ name: "Cost", title: costTitle, alignment: "right", maxLen: costWidth },
|
|
36075
|
+
{ name: "Input", title: "Input tkn", alignment: "right", maxLen: tokenWidth },
|
|
36076
|
+
{ name: "Output", title: "Output tkn", alignment: "right", maxLen: tokenWidth },
|
|
36077
|
+
{ name: "Cached", title: "Cached tkn", alignment: "right", maxLen: tokenWidth }
|
|
36037
36078
|
];
|
|
36038
36079
|
const formatEntry = (entry) => {
|
|
36039
36080
|
const date4 = new Date(entry.creation_time / 1e3);
|
|
@@ -36044,10 +36085,22 @@ function registerUsageCommand(program, container) {
|
|
|
36044
36085
|
const minutes = String(date4.getMinutes()).padStart(2, "0");
|
|
36045
36086
|
const formatted = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
36046
36087
|
const modelName = entry.bot_name.length > modelMaxWidth ? entry.bot_name.slice(0, modelMaxWidth - 1) + "\u2026" : entry.bot_name;
|
|
36088
|
+
const costText = `$${entry.cost_usd} (${entry.cost_points} points)`;
|
|
36089
|
+
const bd = entry.cost_breakdown_in_points;
|
|
36090
|
+
const parseTokens = (s) => {
|
|
36091
|
+
if (!s) return "-";
|
|
36092
|
+
const start = s.indexOf("(");
|
|
36093
|
+
const end = s.indexOf(" tokens");
|
|
36094
|
+
if (start === -1 || end === -1) return "-";
|
|
36095
|
+
return s.slice(start + 1, end);
|
|
36096
|
+
};
|
|
36047
36097
|
return {
|
|
36048
36098
|
Date: theme.muted(formatted),
|
|
36049
36099
|
Model: theme.accent(modelName),
|
|
36050
|
-
Cost: entry.cost_points < 0 ? theme.error(
|
|
36100
|
+
Cost: entry.cost_points < 0 ? theme.error(costText) : theme.success(costText),
|
|
36101
|
+
Input: theme.muted(parseTokens(bd?.Input)),
|
|
36102
|
+
Output: theme.muted(parseTokens(bd?.Output)),
|
|
36103
|
+
Cached: theme.muted(parseTokens(bd?.Cached))
|
|
36051
36104
|
};
|
|
36052
36105
|
};
|
|
36053
36106
|
let totalFetched = 0;
|
|
@@ -36179,23 +36232,29 @@ function registerModelsCommand(program, container) {
|
|
|
36179
36232
|
if (apiKey) {
|
|
36180
36233
|
headers.Authorization = `Bearer ${apiKey}`;
|
|
36181
36234
|
}
|
|
36182
|
-
const
|
|
36183
|
-
|
|
36184
|
-
{
|
|
36185
|
-
|
|
36186
|
-
|
|
36187
|
-
|
|
36188
|
-
|
|
36189
|
-
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
{
|
|
36193
|
-
|
|
36194
|
-
|
|
36235
|
+
const result = await withSpinner({
|
|
36236
|
+
message: "Fetching models...",
|
|
36237
|
+
fn: async () => {
|
|
36238
|
+
const response = await container.httpClient(
|
|
36239
|
+
`${container.env.poeBaseUrl}/v1/models`,
|
|
36240
|
+
{
|
|
36241
|
+
method: "GET",
|
|
36242
|
+
headers
|
|
36243
|
+
}
|
|
36244
|
+
);
|
|
36245
|
+
if (!response.ok) {
|
|
36246
|
+
throw new ApiError(
|
|
36247
|
+
`Failed to fetch models (HTTP ${response.status})`,
|
|
36248
|
+
{
|
|
36249
|
+
httpStatus: response.status,
|
|
36250
|
+
endpoint: "/v1/models"
|
|
36251
|
+
}
|
|
36252
|
+
);
|
|
36195
36253
|
}
|
|
36196
|
-
|
|
36197
|
-
|
|
36198
|
-
|
|
36254
|
+
return await response.json();
|
|
36255
|
+
},
|
|
36256
|
+
stopMessage: (r) => `${r.data.length} models`
|
|
36257
|
+
});
|
|
36199
36258
|
const allModels = result.data;
|
|
36200
36259
|
if (allModels.length === 0) {
|
|
36201
36260
|
resources.logger.info("No models found.");
|
|
@@ -36308,7 +36367,7 @@ function registerModelsCommand(program, container) {
|
|
|
36308
36367
|
// package.json
|
|
36309
36368
|
var package_default = {
|
|
36310
36369
|
name: "poe-code",
|
|
36311
|
-
version: "3.0.
|
|
36370
|
+
version: "3.0.41",
|
|
36312
36371
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
36313
36372
|
type: "module",
|
|
36314
36373
|
workspaces: [
|