poe-code 3.0.22 → 3.0.24
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/models.d.ts +3 -0
- package/dist/cli/commands/models.js +183 -0
- package/dist/cli/commands/models.js.map +1 -0
- package/dist/cli/commands/spawn.js +16 -8
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/logger.js +17 -1
- package/dist/cli/logger.js.map +1 -1
- package/dist/cli/program.js +2 -0
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +341 -22
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15375,12 +15375,30 @@ var symbols = {
|
|
|
15375
15375
|
// packages/design-system/src/components/logger.ts
|
|
15376
15376
|
import { log } from "@clack/prompts";
|
|
15377
15377
|
import chalk6 from "chalk";
|
|
15378
|
+
|
|
15379
|
+
// packages/design-system/src/internal/output-format.ts
|
|
15380
|
+
var VALID_FORMATS = /* @__PURE__ */ new Set(["terminal", "markdown", "json"]);
|
|
15381
|
+
var cached;
|
|
15382
|
+
function resolveOutputFormat(env = process.env) {
|
|
15383
|
+
if (cached) {
|
|
15384
|
+
return cached;
|
|
15385
|
+
}
|
|
15386
|
+
const raw = env.OUTPUT_FORMAT?.toLowerCase();
|
|
15387
|
+
cached = VALID_FORMATS.has(raw) ? raw : "terminal";
|
|
15388
|
+
return cached;
|
|
15389
|
+
}
|
|
15390
|
+
|
|
15391
|
+
// packages/design-system/src/components/logger.ts
|
|
15378
15392
|
function createLogger(emitter) {
|
|
15379
15393
|
const emit = (level, message) => {
|
|
15380
15394
|
if (emitter) {
|
|
15381
15395
|
emitter(message);
|
|
15382
15396
|
return;
|
|
15383
15397
|
}
|
|
15398
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15399
|
+
process.stdout.write(message + "\n");
|
|
15400
|
+
return;
|
|
15401
|
+
}
|
|
15384
15402
|
if (level === "success") {
|
|
15385
15403
|
log.message(message, { symbol: symbols.success });
|
|
15386
15404
|
return;
|
|
@@ -15457,7 +15475,10 @@ function formatCommandNotFoundPanel(input) {
|
|
|
15457
15475
|
|
|
15458
15476
|
// packages/design-system/src/components/table.ts
|
|
15459
15477
|
import { Table } from "console-table-printer";
|
|
15460
|
-
function
|
|
15478
|
+
function stripAnsi2(value) {
|
|
15479
|
+
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
15480
|
+
}
|
|
15481
|
+
function renderTableTerminal(options) {
|
|
15461
15482
|
const { theme, columns, rows } = options;
|
|
15462
15483
|
const table = new Table({
|
|
15463
15484
|
style: {
|
|
@@ -15499,6 +15520,37 @@ function renderTable(options) {
|
|
|
15499
15520
|
}
|
|
15500
15521
|
return table.render();
|
|
15501
15522
|
}
|
|
15523
|
+
function renderTableMarkdown(options) {
|
|
15524
|
+
const { columns, rows } = options;
|
|
15525
|
+
const header = `| ${columns.map((c) => c.title).join(" | ")} |`;
|
|
15526
|
+
const separator = `| ${columns.map((c) => c.alignment === "right" ? "---:" : ":---").join(" | ")} |`;
|
|
15527
|
+
const dataRows = rows.map(
|
|
15528
|
+
(row) => `| ${columns.map((c) => stripAnsi2(row[c.name] ?? "").replace(/\|/g, "\\|")).join(" | ")} |`
|
|
15529
|
+
);
|
|
15530
|
+
return [header, separator, ...dataRows].join("\n");
|
|
15531
|
+
}
|
|
15532
|
+
function renderTableJson(options) {
|
|
15533
|
+
const { columns, rows } = options;
|
|
15534
|
+
const cleaned = rows.map((row) => {
|
|
15535
|
+
const obj = {};
|
|
15536
|
+
for (const col of columns) {
|
|
15537
|
+
obj[col.name] = stripAnsi2(row[col.name] ?? "");
|
|
15538
|
+
}
|
|
15539
|
+
return obj;
|
|
15540
|
+
});
|
|
15541
|
+
return JSON.stringify(cleaned, null, 2);
|
|
15542
|
+
}
|
|
15543
|
+
function renderTable(options) {
|
|
15544
|
+
const format = resolveOutputFormat();
|
|
15545
|
+
switch (format) {
|
|
15546
|
+
case "markdown":
|
|
15547
|
+
return renderTableMarkdown(options);
|
|
15548
|
+
case "json":
|
|
15549
|
+
return renderTableJson(options);
|
|
15550
|
+
default:
|
|
15551
|
+
return renderTableTerminal(options);
|
|
15552
|
+
}
|
|
15553
|
+
}
|
|
15502
15554
|
|
|
15503
15555
|
// packages/design-system/src/acp/index.ts
|
|
15504
15556
|
var acp_exports = {};
|
|
@@ -15549,7 +15601,7 @@ function renderReasoning(text4) {
|
|
|
15549
15601
|
writeLine(chalk7.dim(` \u2713 ${truncate(text4, 80)}`));
|
|
15550
15602
|
}
|
|
15551
15603
|
function renderUsage(tokens) {
|
|
15552
|
-
const
|
|
15604
|
+
const cached3 = typeof tokens.cached === "number" && tokens.cached > 0 ? ` (${tokens.cached} cached)` : "";
|
|
15553
15605
|
let cost = "";
|
|
15554
15606
|
if (typeof tokens.costUsd === "number") {
|
|
15555
15607
|
const formatted = new Intl.NumberFormat("en-US", {
|
|
@@ -15562,7 +15614,7 @@ function renderUsage(tokens) {
|
|
|
15562
15614
|
}
|
|
15563
15615
|
writeLine(
|
|
15564
15616
|
chalk7.green(
|
|
15565
|
-
`\u2713 tokens: ${tokens.input} in${
|
|
15617
|
+
`\u2713 tokens: ${tokens.input} in${cached3} \u2192 ${tokens.output} out${cost}`
|
|
15566
15618
|
)
|
|
15567
15619
|
);
|
|
15568
15620
|
}
|
|
@@ -15573,16 +15625,45 @@ function renderError(message) {
|
|
|
15573
15625
|
// packages/design-system/src/prompts/index.ts
|
|
15574
15626
|
import * as clack from "@clack/prompts";
|
|
15575
15627
|
import { isCancel, cancel, log as log2 } from "@clack/prompts";
|
|
15628
|
+
function stripAnsi3(value) {
|
|
15629
|
+
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
15630
|
+
}
|
|
15576
15631
|
function intro2(title) {
|
|
15632
|
+
const format = resolveOutputFormat();
|
|
15633
|
+
if (format === "markdown") {
|
|
15634
|
+
process.stdout.write(`# ${stripAnsi3(title)}
|
|
15635
|
+
|
|
15636
|
+
`);
|
|
15637
|
+
return;
|
|
15638
|
+
}
|
|
15639
|
+
if (format === "json") {
|
|
15640
|
+
return;
|
|
15641
|
+
}
|
|
15577
15642
|
clack.intro(text.intro(title));
|
|
15578
15643
|
}
|
|
15579
15644
|
function introPlain(title) {
|
|
15645
|
+
const format = resolveOutputFormat();
|
|
15646
|
+
if (format === "markdown") {
|
|
15647
|
+
process.stdout.write(`# ${stripAnsi3(title)}
|
|
15648
|
+
|
|
15649
|
+
`);
|
|
15650
|
+
return;
|
|
15651
|
+
}
|
|
15652
|
+
if (format === "json") {
|
|
15653
|
+
return;
|
|
15654
|
+
}
|
|
15580
15655
|
clack.intro(title);
|
|
15581
15656
|
}
|
|
15582
15657
|
function outro2(message) {
|
|
15658
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15659
|
+
return;
|
|
15660
|
+
}
|
|
15583
15661
|
clack.outro(message);
|
|
15584
15662
|
}
|
|
15585
15663
|
function note2(message, title) {
|
|
15664
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15665
|
+
return;
|
|
15666
|
+
}
|
|
15586
15667
|
clack.note(message, title);
|
|
15587
15668
|
}
|
|
15588
15669
|
async function select2(opts) {
|
|
@@ -15637,6 +15718,10 @@ function createLoggerFactory(emitter, theme) {
|
|
|
15637
15718
|
emitter(message);
|
|
15638
15719
|
return;
|
|
15639
15720
|
}
|
|
15721
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15722
|
+
process.stdout.write(message + "\n");
|
|
15723
|
+
return;
|
|
15724
|
+
}
|
|
15640
15725
|
if (level === "success") {
|
|
15641
15726
|
log2.message(message, { symbol: successSymbol });
|
|
15642
15727
|
return;
|
|
@@ -15675,6 +15760,11 @@ function createLoggerFactory(emitter, theme) {
|
|
|
15675
15760
|
emitter(`${label}: ${value}`);
|
|
15676
15761
|
return;
|
|
15677
15762
|
}
|
|
15763
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15764
|
+
process.stdout.write(`${label}: ${value}
|
|
15765
|
+
`);
|
|
15766
|
+
return;
|
|
15767
|
+
}
|
|
15678
15768
|
const symbol2 = theme?.errorSymbol ?? chalk10.red("\u25A0");
|
|
15679
15769
|
log2.message(`${label}
|
|
15680
15770
|
${value}`, { symbol: symbol2 });
|
|
@@ -15720,6 +15810,10 @@ function createLoggerFactory(emitter, theme) {
|
|
|
15720
15810
|
emitter(formatMessage(message));
|
|
15721
15811
|
return;
|
|
15722
15812
|
}
|
|
15813
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15814
|
+
process.stdout.write(formatMessage(message) + "\n");
|
|
15815
|
+
return;
|
|
15816
|
+
}
|
|
15723
15817
|
log2.message(formatMessage(message), { symbol: chalk10.gray("\u2502") });
|
|
15724
15818
|
},
|
|
15725
15819
|
intro(title) {
|
|
@@ -15738,6 +15832,11 @@ function createLoggerFactory(emitter, theme) {
|
|
|
15738
15832
|
emitter(`${label}: ${value}`);
|
|
15739
15833
|
return;
|
|
15740
15834
|
}
|
|
15835
|
+
if (resolveOutputFormat() !== "terminal") {
|
|
15836
|
+
process.stdout.write(`${label}: ${value}
|
|
15837
|
+
`);
|
|
15838
|
+
return;
|
|
15839
|
+
}
|
|
15741
15840
|
const symbol2 = theme?.resolvedSymbol ?? chalk10.magenta("\u25C7");
|
|
15742
15841
|
log2.message(`${label}
|
|
15743
15842
|
${value}`, { symbol: symbol2 });
|
|
@@ -15996,7 +16095,8 @@ var claudeCodeSpawnConfig = {
|
|
|
15996
16095
|
stdinMode: {
|
|
15997
16096
|
omitPrompt: true,
|
|
15998
16097
|
extraArgs: ["--input-format", "text"]
|
|
15999
|
-
}
|
|
16098
|
+
},
|
|
16099
|
+
resumeCommand: (threadId) => ["--resume", threadId]
|
|
16000
16100
|
};
|
|
16001
16101
|
|
|
16002
16102
|
// packages/agent-spawn/src/configs/codex.ts
|
|
@@ -16011,7 +16111,8 @@ var codexSpawnConfig = {
|
|
|
16011
16111
|
stdinMode: {
|
|
16012
16112
|
omitPrompt: true,
|
|
16013
16113
|
extraArgs: ["-"]
|
|
16014
|
-
}
|
|
16114
|
+
},
|
|
16115
|
+
resumeCommand: (threadId, cwd) => ["resume", "-C", cwd, threadId]
|
|
16015
16116
|
};
|
|
16016
16117
|
|
|
16017
16118
|
// packages/agent-spawn/src/configs/opencode.ts
|
|
@@ -16024,7 +16125,8 @@ var openCodeSpawnConfig = {
|
|
|
16024
16125
|
adapter: "opencode",
|
|
16025
16126
|
promptFlag: "run",
|
|
16026
16127
|
modelFlag: "--model",
|
|
16027
|
-
defaultArgs: ["--format", "json"]
|
|
16128
|
+
defaultArgs: ["--format", "json"],
|
|
16129
|
+
resumeCommand: (threadId, cwd) => [cwd, "--session", threadId]
|
|
16028
16130
|
};
|
|
16029
16131
|
|
|
16030
16132
|
// packages/agent-spawn/src/configs/kimi.ts
|
|
@@ -16040,7 +16142,8 @@ var kimiSpawnConfig = {
|
|
|
16040
16142
|
stdinMode: {
|
|
16041
16143
|
omitPrompt: true,
|
|
16042
16144
|
extraArgs: ["--input-format", "stream-json"]
|
|
16043
|
-
}
|
|
16145
|
+
},
|
|
16146
|
+
resumeCommand: (threadId, cwd) => ["--session", threadId, "--work-dir", cwd]
|
|
16044
16147
|
};
|
|
16045
16148
|
|
|
16046
16149
|
// packages/agent-spawn/src/configs/index.ts
|
|
@@ -16244,6 +16347,29 @@ var TOOL_KIND_MAP = {
|
|
|
16244
16347
|
Grep: "search",
|
|
16245
16348
|
Task: "think"
|
|
16246
16349
|
};
|
|
16350
|
+
var TITLE_KEYS = {
|
|
16351
|
+
Bash: ["command"],
|
|
16352
|
+
Read: ["file_path"],
|
|
16353
|
+
Write: ["file_path"],
|
|
16354
|
+
Edit: ["file_path"],
|
|
16355
|
+
NotebookEdit: ["notebook_path"],
|
|
16356
|
+
Glob: ["pattern"],
|
|
16357
|
+
Grep: ["pattern"],
|
|
16358
|
+
Task: ["description", "prompt"]
|
|
16359
|
+
};
|
|
16360
|
+
function extractTitle(name, input) {
|
|
16361
|
+
const keys = TITLE_KEYS[name];
|
|
16362
|
+
if (keys && input && typeof input === "object") {
|
|
16363
|
+
const obj = input;
|
|
16364
|
+
for (const key of keys) {
|
|
16365
|
+
const value = obj[key];
|
|
16366
|
+
if (typeof value === "string" && value.length > 0) {
|
|
16367
|
+
return truncate2(value, 80);
|
|
16368
|
+
}
|
|
16369
|
+
}
|
|
16370
|
+
}
|
|
16371
|
+
return name;
|
|
16372
|
+
}
|
|
16247
16373
|
async function* adaptClaude(lines) {
|
|
16248
16374
|
const toolKindsById = /* @__PURE__ */ new Map();
|
|
16249
16375
|
let emittedSessionStart = false;
|
|
@@ -16306,7 +16432,7 @@ async function* adaptClaude(lines) {
|
|
|
16306
16432
|
event: "tool_start",
|
|
16307
16433
|
id: item.id,
|
|
16308
16434
|
kind,
|
|
16309
|
-
title: item.name,
|
|
16435
|
+
title: extractTitle(item.name, item.input),
|
|
16310
16436
|
input: item.input
|
|
16311
16437
|
};
|
|
16312
16438
|
}
|
|
@@ -18421,14 +18547,20 @@ function registerSpawnCommand(program, container, options = {}) {
|
|
|
18421
18547
|
}
|
|
18422
18548
|
}
|
|
18423
18549
|
if (final.threadId) {
|
|
18424
|
-
const
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
const
|
|
18429
|
-
|
|
18430
|
-
|
|
18550
|
+
const spawnConfig = getSpawnConfig(canonicalService);
|
|
18551
|
+
if (spawnConfig?.kind === "cli" && spawnConfig.resumeCommand) {
|
|
18552
|
+
const resolvedId = resolveAgentId(canonicalService) ?? canonicalService;
|
|
18553
|
+
const agentDefinition = allAgents.find((agent) => agent.id === resolvedId);
|
|
18554
|
+
const binaryName = agentDefinition?.binaryName;
|
|
18555
|
+
if (binaryName) {
|
|
18556
|
+
const resumeCwd = path8.resolve(spawnOptions.cwd ?? process.cwd());
|
|
18557
|
+
const args = spawnConfig.resumeCommand(final.threadId, resumeCwd);
|
|
18558
|
+
const agentCommand = [binaryName, ...args.map(shlexQuote)].join(" ");
|
|
18559
|
+
const needsCdPrefix = !args.includes(resumeCwd);
|
|
18560
|
+
const resumeCommand = needsCdPrefix ? `cd ${shlexQuote(resumeCwd)} && ${agentCommand}` : agentCommand;
|
|
18561
|
+
resources.logger.info(text.muted(`
|
|
18431
18562
|
Resume: ${resumeCommand}`));
|
|
18563
|
+
}
|
|
18432
18564
|
}
|
|
18433
18565
|
}
|
|
18434
18566
|
} finally {
|
|
@@ -24151,7 +24283,7 @@ __export(util_exports, {
|
|
|
24151
24283
|
assignProp: () => assignProp,
|
|
24152
24284
|
base64ToUint8Array: () => base64ToUint8Array,
|
|
24153
24285
|
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
24154
|
-
cached: () =>
|
|
24286
|
+
cached: () => cached2,
|
|
24155
24287
|
captureStackTrace: () => captureStackTrace,
|
|
24156
24288
|
cleanEnum: () => cleanEnum,
|
|
24157
24289
|
cleanRegex: () => cleanRegex,
|
|
@@ -24227,7 +24359,7 @@ function jsonStringifyReplacer(_, value) {
|
|
|
24227
24359
|
return value.toString();
|
|
24228
24360
|
return value;
|
|
24229
24361
|
}
|
|
24230
|
-
function
|
|
24362
|
+
function cached2(getter) {
|
|
24231
24363
|
const set2 = false;
|
|
24232
24364
|
return {
|
|
24233
24365
|
get value() {
|
|
@@ -24343,7 +24475,7 @@ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace :
|
|
|
24343
24475
|
function isObject(data) {
|
|
24344
24476
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
24345
24477
|
}
|
|
24346
|
-
var allowsEval =
|
|
24478
|
+
var allowsEval = cached2(() => {
|
|
24347
24479
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
24348
24480
|
return false;
|
|
24349
24481
|
}
|
|
@@ -26430,7 +26562,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
26430
26562
|
}
|
|
26431
26563
|
});
|
|
26432
26564
|
}
|
|
26433
|
-
const _normalized =
|
|
26565
|
+
const _normalized = cached2(() => normalizeDef(def));
|
|
26434
26566
|
defineLazy(inst._zod, "propValues", () => {
|
|
26435
26567
|
const shape = def.shape;
|
|
26436
26568
|
const propValues = {};
|
|
@@ -26481,7 +26613,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
26481
26613
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
26482
26614
|
$ZodObject.init(inst, def);
|
|
26483
26615
|
const superParse = inst._zod.parse;
|
|
26484
|
-
const _normalized =
|
|
26616
|
+
const _normalized = cached2(() => normalizeDef(def));
|
|
26485
26617
|
const generateFastpass = (shape) => {
|
|
26486
26618
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
26487
26619
|
const normalized = _normalized.value;
|
|
@@ -26717,7 +26849,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
26717
26849
|
}
|
|
26718
26850
|
return propValues;
|
|
26719
26851
|
});
|
|
26720
|
-
const disc =
|
|
26852
|
+
const disc = cached2(() => {
|
|
26721
26853
|
const opts = def.options;
|
|
26722
26854
|
const map2 = /* @__PURE__ */ new Map();
|
|
26723
26855
|
for (const o of opts) {
|
|
@@ -35681,6 +35813,192 @@ function registerUsageCommand(program, container) {
|
|
|
35681
35813
|
});
|
|
35682
35814
|
}
|
|
35683
35815
|
|
|
35816
|
+
// src/cli/commands/models.ts
|
|
35817
|
+
init_shared();
|
|
35818
|
+
init_credentials();
|
|
35819
|
+
function formatTokenCount(tokens) {
|
|
35820
|
+
if (tokens >= 1048576) {
|
|
35821
|
+
const value = tokens / 1048576;
|
|
35822
|
+
return `${Number.isInteger(value) ? value : value.toFixed(1)}M`;
|
|
35823
|
+
}
|
|
35824
|
+
if (tokens >= 1024) {
|
|
35825
|
+
const value = tokens / 1024;
|
|
35826
|
+
return `${Number.isInteger(value) ? value : value.toFixed(1)}K`;
|
|
35827
|
+
}
|
|
35828
|
+
return String(tokens);
|
|
35829
|
+
}
|
|
35830
|
+
function formatPrice(perToken) {
|
|
35831
|
+
const perMTok = Math.round(perToken * 1e6 * 100) / 100;
|
|
35832
|
+
return `$${perMTok.toFixed(2)}`;
|
|
35833
|
+
}
|
|
35834
|
+
function formatOptionalPrice(value) {
|
|
35835
|
+
return value != null ? formatPrice(value) : "-";
|
|
35836
|
+
}
|
|
35837
|
+
function formatDate(ms) {
|
|
35838
|
+
const date4 = new Date(ms);
|
|
35839
|
+
const year = date4.getUTCFullYear();
|
|
35840
|
+
const month = String(date4.getUTCMonth() + 1).padStart(2, "0");
|
|
35841
|
+
const day = String(date4.getUTCDate()).padStart(2, "0");
|
|
35842
|
+
return `${year}-${month}-${day}`;
|
|
35843
|
+
}
|
|
35844
|
+
function hasFeature(model, feature) {
|
|
35845
|
+
if (feature === "reasoning") return model.reasoning != null;
|
|
35846
|
+
return (model.supported_features ?? []).includes(feature);
|
|
35847
|
+
}
|
|
35848
|
+
function registerModelsCommand(program, container) {
|
|
35849
|
+
program.command("models").description("List available Poe API models.").option("--provider <name>", "Filter by provider name").option("--model <name>", "Filter by model id").option("--feature <name>", "Filter by feature (tools, web_search, reasoning)").option("--input <modalities>", "Filter by input modalities (e.g. text,image)").option("--output <modalities>", "Filter by output modalities (e.g. text)").option("--view <name>", "Table view: capabilities or pricing", "capabilities").action(async function() {
|
|
35850
|
+
const flags = resolveCommandFlags(program);
|
|
35851
|
+
const resources = createExecutionResources(
|
|
35852
|
+
container,
|
|
35853
|
+
flags,
|
|
35854
|
+
"models"
|
|
35855
|
+
);
|
|
35856
|
+
const commandOptions = this.opts();
|
|
35857
|
+
resources.logger.intro("models");
|
|
35858
|
+
try {
|
|
35859
|
+
const apiKey = await loadCredentials({
|
|
35860
|
+
fs: container.fs,
|
|
35861
|
+
filePath: container.env.credentialsPath
|
|
35862
|
+
});
|
|
35863
|
+
if (!apiKey) {
|
|
35864
|
+
throw new AuthenticationError(
|
|
35865
|
+
"Poe API key not found. Run 'poe-code login' first."
|
|
35866
|
+
);
|
|
35867
|
+
}
|
|
35868
|
+
if (flags.dryRun) {
|
|
35869
|
+
resources.logger.dryRun(
|
|
35870
|
+
"Dry run: would fetch models from Poe API."
|
|
35871
|
+
);
|
|
35872
|
+
return;
|
|
35873
|
+
}
|
|
35874
|
+
const response = await container.httpClient(
|
|
35875
|
+
`${container.env.poeBaseUrl}/v1/models`,
|
|
35876
|
+
{
|
|
35877
|
+
method: "GET",
|
|
35878
|
+
headers: {
|
|
35879
|
+
Authorization: `Bearer ${apiKey}`
|
|
35880
|
+
}
|
|
35881
|
+
}
|
|
35882
|
+
);
|
|
35883
|
+
if (!response.ok) {
|
|
35884
|
+
throw new ApiError(
|
|
35885
|
+
`Failed to fetch models (HTTP ${response.status})`,
|
|
35886
|
+
{
|
|
35887
|
+
httpStatus: response.status,
|
|
35888
|
+
endpoint: "/v1/models"
|
|
35889
|
+
}
|
|
35890
|
+
);
|
|
35891
|
+
}
|
|
35892
|
+
const result = await response.json();
|
|
35893
|
+
const allModels = result.data;
|
|
35894
|
+
if (allModels.length === 0) {
|
|
35895
|
+
resources.logger.info("No models found.");
|
|
35896
|
+
return;
|
|
35897
|
+
}
|
|
35898
|
+
let filtered = allModels;
|
|
35899
|
+
if (commandOptions.provider) {
|
|
35900
|
+
const term = commandOptions.provider.toLowerCase();
|
|
35901
|
+
filtered = filtered.filter(
|
|
35902
|
+
(m) => m.owned_by.toLowerCase().includes(term)
|
|
35903
|
+
);
|
|
35904
|
+
}
|
|
35905
|
+
if (commandOptions.model) {
|
|
35906
|
+
const term = commandOptions.model.toLowerCase();
|
|
35907
|
+
filtered = filtered.filter(
|
|
35908
|
+
(m) => m.id.toLowerCase().includes(term)
|
|
35909
|
+
);
|
|
35910
|
+
}
|
|
35911
|
+
if (commandOptions.feature) {
|
|
35912
|
+
const feature = commandOptions.feature.toLowerCase();
|
|
35913
|
+
filtered = filtered.filter((m) => hasFeature(m, feature));
|
|
35914
|
+
}
|
|
35915
|
+
if (commandOptions.input) {
|
|
35916
|
+
const required2 = commandOptions.input.toLowerCase().split(",");
|
|
35917
|
+
filtered = filtered.filter((m) => {
|
|
35918
|
+
const modalities = m.architecture?.input_modalities ?? [];
|
|
35919
|
+
return required2.every((r) => modalities.includes(r));
|
|
35920
|
+
});
|
|
35921
|
+
}
|
|
35922
|
+
if (commandOptions.output) {
|
|
35923
|
+
const required2 = commandOptions.output.toLowerCase().split(",");
|
|
35924
|
+
filtered = filtered.filter((m) => {
|
|
35925
|
+
const modalities = m.architecture?.output_modalities ?? [];
|
|
35926
|
+
return required2.every((r) => modalities.includes(r));
|
|
35927
|
+
});
|
|
35928
|
+
}
|
|
35929
|
+
if (filtered.length === 0) {
|
|
35930
|
+
resources.logger.info("No models match the given filters.");
|
|
35931
|
+
return;
|
|
35932
|
+
}
|
|
35933
|
+
filtered.sort((a, b) => b.created - a.created);
|
|
35934
|
+
const theme = getTheme();
|
|
35935
|
+
let columns;
|
|
35936
|
+
let rows;
|
|
35937
|
+
if (commandOptions.view === "pricing") {
|
|
35938
|
+
columns = [
|
|
35939
|
+
{ name: "Model", title: "Model", alignment: "left", maxLen: 35 },
|
|
35940
|
+
{ name: "Context", title: "Context", alignment: "right", maxLen: 9 },
|
|
35941
|
+
{ name: "Input", title: "Input $/MTok", alignment: "right", maxLen: 12 },
|
|
35942
|
+
{ name: "Output", title: "Output $/MTok", alignment: "right", maxLen: 13 },
|
|
35943
|
+
{ name: "CacheRead", title: "Cache Read", alignment: "right", maxLen: 10 },
|
|
35944
|
+
{ name: "CacheWrite", title: "Cache Write", alignment: "right", maxLen: 11 },
|
|
35945
|
+
{ name: "Request", title: "Request", alignment: "right", maxLen: 9 }
|
|
35946
|
+
];
|
|
35947
|
+
rows = filtered.map((model) => {
|
|
35948
|
+
const pricing = model.pricing;
|
|
35949
|
+
return {
|
|
35950
|
+
Model: theme.accent(`${model.owned_by.toLowerCase()}/${model.id}`),
|
|
35951
|
+
Context: model.context_window?.context_length != null ? formatTokenCount(model.context_window.context_length) : "-",
|
|
35952
|
+
Input: formatOptionalPrice(pricing?.prompt ?? null),
|
|
35953
|
+
Output: formatOptionalPrice(pricing?.completion ?? null),
|
|
35954
|
+
CacheRead: formatOptionalPrice(pricing?.input_cache_read ?? null),
|
|
35955
|
+
CacheWrite: formatOptionalPrice(pricing?.input_cache_write ?? null),
|
|
35956
|
+
Request: formatOptionalPrice(pricing?.request ?? null)
|
|
35957
|
+
};
|
|
35958
|
+
});
|
|
35959
|
+
} else {
|
|
35960
|
+
const allFeatures = Array.from(
|
|
35961
|
+
new Set(filtered.flatMap((m) => m.supported_features ?? []))
|
|
35962
|
+
).sort();
|
|
35963
|
+
columns = [
|
|
35964
|
+
{ name: "Model", title: "Model", alignment: "left", maxLen: 35 },
|
|
35965
|
+
{ name: "Date", title: "Date Added", alignment: "left", maxLen: 12 },
|
|
35966
|
+
{ name: "Modality", title: "Modality", alignment: "left", maxLen: 18 },
|
|
35967
|
+
{ name: "Context", title: "Context", alignment: "right", maxLen: 9 },
|
|
35968
|
+
{ name: "Reasoning", title: "Reasoning", alignment: "left", maxLen: 9 },
|
|
35969
|
+
...allFeatures.map((feature) => ({
|
|
35970
|
+
name: feature,
|
|
35971
|
+
title: feature,
|
|
35972
|
+
alignment: "left",
|
|
35973
|
+
maxLen: Math.max(feature.length, 3)
|
|
35974
|
+
}))
|
|
35975
|
+
];
|
|
35976
|
+
rows = filtered.map((model) => {
|
|
35977
|
+
const row = {
|
|
35978
|
+
Model: theme.accent(`${model.owned_by.toLowerCase()}/${model.id}`),
|
|
35979
|
+
Date: theme.muted(formatDate(model.created)),
|
|
35980
|
+
Modality: model.architecture ? `${model.architecture.input_modalities.join(",")}->${model.architecture.output_modalities.join(",")}` : "-",
|
|
35981
|
+
Context: model.context_window?.context_length != null ? formatTokenCount(model.context_window.context_length) : "-",
|
|
35982
|
+
Reasoning: model.reasoning ? theme.success("\u2713") : ""
|
|
35983
|
+
};
|
|
35984
|
+
for (const feature of allFeatures) {
|
|
35985
|
+
row[feature] = (model.supported_features ?? []).includes(feature) ? theme.success("\u2713") : "";
|
|
35986
|
+
}
|
|
35987
|
+
return row;
|
|
35988
|
+
});
|
|
35989
|
+
}
|
|
35990
|
+
resources.logger.info(renderTable({ theme, columns, rows }));
|
|
35991
|
+
} catch (error2) {
|
|
35992
|
+
if (error2 instanceof Error) {
|
|
35993
|
+
resources.logger.logException(error2, "models", {
|
|
35994
|
+
operation: "fetch-models"
|
|
35995
|
+
});
|
|
35996
|
+
}
|
|
35997
|
+
throw error2;
|
|
35998
|
+
}
|
|
35999
|
+
});
|
|
36000
|
+
}
|
|
36001
|
+
|
|
35684
36002
|
// package.json
|
|
35685
36003
|
var package_default = {
|
|
35686
36004
|
name: "poe-code",
|
|
@@ -35693,7 +36011,7 @@ var package_default = {
|
|
|
35693
36011
|
scripts: {
|
|
35694
36012
|
build: "turbo run build && tsc -p tsconfig.build.json && node scripts/generate-bin-wrappers.mjs && node scripts/bundle.mjs",
|
|
35695
36013
|
"build:deps": "node scripts/list-workspace-deps.mjs",
|
|
35696
|
-
predev: "turbo run build --
|
|
36014
|
+
predev: "turbo run build --output-logs=none --log-prefix=none --verbosity=0 > /dev/null 2>&1",
|
|
35697
36015
|
dev: "tsx src/index.ts",
|
|
35698
36016
|
start: "node dist/bin.cjs",
|
|
35699
36017
|
"dev:bundle": "npm run build && node dist/bin.cjs",
|
|
@@ -36002,6 +36320,7 @@ function bootstrapProgram(container) {
|
|
|
36002
36320
|
registerSkillCommand(program, container);
|
|
36003
36321
|
registerRalphCommand(program, container);
|
|
36004
36322
|
registerUsageCommand(program, container);
|
|
36323
|
+
registerModelsCommand(program, container);
|
|
36005
36324
|
program.action(function() {
|
|
36006
36325
|
const args = this.args;
|
|
36007
36326
|
if (args.length > 0) {
|