poe-code 11.0.32 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/auth.js +10 -44
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/doctor.js +4 -4
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/program.js +0 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +126 -135
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/dist/sdk/auth-check.d.ts +7 -0
- package/dist/sdk/auth-check.js +22 -0
- package/dist/sdk/auth-check.js.map +1 -0
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-6EXLQKE5.js → chunk-73RTIWRH.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-YE6I5W6O.js → chunk-HD7TQKZ7.js} +4 -2
- package/packages/safejs/dist/chunks/{chunk-YE6I5W6O.js.map → chunk-HD7TQKZ7.js.map} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/globals/object-array.js +7 -1
- /package/packages/safejs/dist/chunks/{chunk-6EXLQKE5.js.map → chunk-73RTIWRH.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -87349,86 +87349,6 @@ var init_gaslight = __esm({
|
|
|
87349
87349
|
}
|
|
87350
87350
|
});
|
|
87351
87351
|
|
|
87352
|
-
// src/sdk/credentials.ts
|
|
87353
|
-
async function getPoeApiKey() {
|
|
87354
|
-
const envKey = Object.hasOwn(process.env, "POE_API_KEY") ? process.env.POE_API_KEY : void 0;
|
|
87355
|
-
if (typeof envKey === "string" && envKey.trim().length > 0) {
|
|
87356
|
-
return envKey.trim();
|
|
87357
|
-
}
|
|
87358
|
-
const { store } = createSecretStore({
|
|
87359
|
-
backendEnvVar: "POE_AUTH_BACKEND",
|
|
87360
|
-
fileStore: {
|
|
87361
|
-
salt: "poe-code:encrypted-file-auth-store:v1",
|
|
87362
|
-
defaultDirectory: ".poe-code",
|
|
87363
|
-
defaultFileName: "credentials.enc"
|
|
87364
|
-
}
|
|
87365
|
-
});
|
|
87366
|
-
const storedKey = await store.get();
|
|
87367
|
-
if (typeof storedKey === "string" && storedKey.trim().length > 0) {
|
|
87368
|
-
return storedKey.trim();
|
|
87369
|
-
}
|
|
87370
|
-
throw new AuthenticationError("No API key found. Set POE_API_KEY or run 'poe-code login'.");
|
|
87371
|
-
}
|
|
87372
|
-
async function getPoeAuthIdentity(options = {}) {
|
|
87373
|
-
const apiKey = options.apiKey ?? await getPoeApiKey();
|
|
87374
|
-
return fetchPoeAuthIdentity({
|
|
87375
|
-
apiKey,
|
|
87376
|
-
baseUrl: options.baseUrl ?? resolvePoeApiBaseUrl(options.variables),
|
|
87377
|
-
httpClient: options.httpClient
|
|
87378
|
-
});
|
|
87379
|
-
}
|
|
87380
|
-
async function fetchPoeAuthIdentity(options) {
|
|
87381
|
-
const httpClient = options.httpClient ?? createDefaultHttpClient();
|
|
87382
|
-
const response = await httpClient(`${trimTrailingSlashes(options.baseUrl ?? resolvePoeApiBaseUrl())}/whoami`, {
|
|
87383
|
-
method: "POST",
|
|
87384
|
-
headers: {
|
|
87385
|
-
Authorization: `Bearer ${options.apiKey}`
|
|
87386
|
-
}
|
|
87387
|
-
});
|
|
87388
|
-
if (!response.ok) {
|
|
87389
|
-
throw new ApiError(`Failed to fetch identity (HTTP ${response.status})`, {
|
|
87390
|
-
httpStatus: response.status,
|
|
87391
|
-
endpoint: "/v1/whoami"
|
|
87392
|
-
});
|
|
87393
|
-
}
|
|
87394
|
-
return parsePoeAuthIdentity(await response.json());
|
|
87395
|
-
}
|
|
87396
|
-
function parsePoeAuthIdentity(value) {
|
|
87397
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
87398
|
-
throw new ApiError("Malformed identity response from Poe API.", {
|
|
87399
|
-
endpoint: "/v1/whoami"
|
|
87400
|
-
});
|
|
87401
|
-
}
|
|
87402
|
-
const identity = value;
|
|
87403
|
-
if (typeof identity.user_id !== "number" || !Number.isFinite(identity.user_id) || typeof identity.handle !== "string" || identity.handle.trim().length === 0 || typeof identity.name !== "string" || identity.name.trim().length === 0 || typeof identity.profile_picture !== "string") {
|
|
87404
|
-
throw new ApiError("Malformed identity response from Poe API.", {
|
|
87405
|
-
endpoint: "/v1/whoami"
|
|
87406
|
-
});
|
|
87407
|
-
}
|
|
87408
|
-
return value;
|
|
87409
|
-
}
|
|
87410
|
-
function createDefaultHttpClient() {
|
|
87411
|
-
return async (url, init) => {
|
|
87412
|
-
const response = await globalThis.fetch(url, init);
|
|
87413
|
-
return {
|
|
87414
|
-
ok: response.ok,
|
|
87415
|
-
status: response.status,
|
|
87416
|
-
json: () => response.json()
|
|
87417
|
-
};
|
|
87418
|
-
};
|
|
87419
|
-
}
|
|
87420
|
-
function trimTrailingSlashes(value) {
|
|
87421
|
-
return value.replace(/\/+$/, "");
|
|
87422
|
-
}
|
|
87423
|
-
var init_credentials = __esm({
|
|
87424
|
-
"src/sdk/credentials.ts"() {
|
|
87425
|
-
"use strict";
|
|
87426
|
-
init_src17();
|
|
87427
|
-
init_errors();
|
|
87428
|
-
init_environment2();
|
|
87429
|
-
}
|
|
87430
|
-
});
|
|
87431
|
-
|
|
87432
87352
|
// packages/github-workflows/src/frontmatter.ts
|
|
87433
87353
|
var init_frontmatter4 = __esm({
|
|
87434
87354
|
"packages/github-workflows/src/frontmatter.ts"() {
|
|
@@ -104750,6 +104670,34 @@ var init_logout = __esm({
|
|
|
104750
104670
|
}
|
|
104751
104671
|
});
|
|
104752
104672
|
|
|
104673
|
+
// src/sdk/auth-check.ts
|
|
104674
|
+
async function checkPoeAuth(options) {
|
|
104675
|
+
const response = await options.httpClient(createCurrentBalanceUrl2(options.baseUrl), {
|
|
104676
|
+
method: "GET",
|
|
104677
|
+
headers: {
|
|
104678
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
104679
|
+
}
|
|
104680
|
+
});
|
|
104681
|
+
if (!response.ok) {
|
|
104682
|
+
throw new ApiError(`Failed to check authentication (HTTP ${response.status})`, {
|
|
104683
|
+
httpStatus: response.status,
|
|
104684
|
+
endpoint: "/usage/current_balance"
|
|
104685
|
+
});
|
|
104686
|
+
}
|
|
104687
|
+
}
|
|
104688
|
+
function createCurrentBalanceUrl2(baseUrl) {
|
|
104689
|
+
const url = new URL(baseUrl);
|
|
104690
|
+
const path191 = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
|
|
104691
|
+
url.pathname = `${path191}/usage/current_balance`;
|
|
104692
|
+
return url.toString();
|
|
104693
|
+
}
|
|
104694
|
+
var init_auth_check = __esm({
|
|
104695
|
+
"src/sdk/auth-check.ts"() {
|
|
104696
|
+
"use strict";
|
|
104697
|
+
init_errors();
|
|
104698
|
+
}
|
|
104699
|
+
});
|
|
104700
|
+
|
|
104753
104701
|
// src/cli/commands/json-output.ts
|
|
104754
104702
|
function writeJson(value) {
|
|
104755
104703
|
process.stdout.write(`${JSON.stringify(value)}
|
|
@@ -104779,8 +104727,6 @@ function registerAuthCommand(program, container) {
|
|
|
104779
104727
|
auth.command("api_key", { hidden: true }).option("--reveal", "Print the full API key to stdout (for use in command substitution).").action(async (options) => {
|
|
104780
104728
|
await executeApiKey(program, container, options);
|
|
104781
104729
|
});
|
|
104782
|
-
registerWhoamiCommand(auth, program, container);
|
|
104783
|
-
registerWhoamiCommand(program, program, container);
|
|
104784
104730
|
auth.command("login").description("Store a Poe API key for reuse across commands.").option("--api-key <key>", apiKeyFlagDescription("POE_API_KEY")).action(async (options) => {
|
|
104785
104731
|
await executeLogin(program, container, options);
|
|
104786
104732
|
});
|
|
@@ -104790,11 +104736,6 @@ function registerAuthCommand(program, container) {
|
|
|
104790
104736
|
await executeLogout(program, container);
|
|
104791
104737
|
});
|
|
104792
104738
|
}
|
|
104793
|
-
function registerWhoamiCommand(parent, program, container) {
|
|
104794
|
-
parent.command("whoami").description("Print Poe account identity as JSON (uses POE_API_KEY if set).").option("--json", "Accepted for consistency with other commands; whoami always prints JSON.").action(async () => {
|
|
104795
|
-
await executeWhoami(program, container);
|
|
104796
|
-
});
|
|
104797
|
-
}
|
|
104798
104739
|
async function executeStatus(program, container, options = {}) {
|
|
104799
104740
|
const flags = resolveCommandFlags(program);
|
|
104800
104741
|
if (options.json === true) {
|
|
@@ -104811,24 +104752,23 @@ async function executeStatus(program, container, options = {}) {
|
|
|
104811
104752
|
return;
|
|
104812
104753
|
}
|
|
104813
104754
|
if (flags.dryRun) {
|
|
104814
|
-
resources.logger.dryRun("Dry run: would
|
|
104755
|
+
resources.logger.dryRun("Dry run: would check authentication with the Poe API.");
|
|
104815
104756
|
resources.context.finalize();
|
|
104816
104757
|
return;
|
|
104817
104758
|
}
|
|
104818
104759
|
const s = spinner();
|
|
104819
104760
|
s.start("Checking authentication...");
|
|
104820
|
-
let identity;
|
|
104821
104761
|
try {
|
|
104822
|
-
|
|
104762
|
+
await checkPoeAuth({
|
|
104823
104763
|
apiKey,
|
|
104824
|
-
baseUrl: container.env.
|
|
104764
|
+
baseUrl: container.env.poeBaseUrl,
|
|
104825
104765
|
httpClient: container.httpClient
|
|
104826
104766
|
});
|
|
104827
104767
|
} catch (error3) {
|
|
104828
104768
|
s.stop("Authentication failed");
|
|
104829
104769
|
throw error3;
|
|
104830
104770
|
}
|
|
104831
|
-
s.stop(
|
|
104771
|
+
s.stop("Logged in");
|
|
104832
104772
|
resources.context.finalize();
|
|
104833
104773
|
} catch (error3) {
|
|
104834
104774
|
if (error3 instanceof Error) {
|
|
@@ -104849,14 +104789,12 @@ async function writeStatusJson(container, flags) {
|
|
|
104849
104789
|
writeJson({ loggedIn: true, dryRun: true });
|
|
104850
104790
|
return;
|
|
104851
104791
|
}
|
|
104852
|
-
|
|
104853
|
-
|
|
104854
|
-
|
|
104855
|
-
|
|
104856
|
-
baseUrl: container.env.poeApiBaseUrl,
|
|
104857
|
-
httpClient: container.httpClient
|
|
104858
|
-
})
|
|
104792
|
+
await checkPoeAuth({
|
|
104793
|
+
apiKey,
|
|
104794
|
+
baseUrl: container.env.poeBaseUrl,
|
|
104795
|
+
httpClient: container.httpClient
|
|
104859
104796
|
});
|
|
104797
|
+
writeJson({ loggedIn: true });
|
|
104860
104798
|
}
|
|
104861
104799
|
async function executeApiKey(program, container, options) {
|
|
104862
104800
|
const flags = resolveCommandFlags(program);
|
|
@@ -104879,7 +104817,9 @@ async function executeApiKey(program, container, options) {
|
|
|
104879
104817
|
}
|
|
104880
104818
|
process.stdout.write(`${maskApiKey(apiKey)}
|
|
104881
104819
|
`);
|
|
104882
|
-
resources.logger.warn(
|
|
104820
|
+
resources.logger.warn(
|
|
104821
|
+
"Masked to the last 4 characters. Re-run with --reveal to print the full secret."
|
|
104822
|
+
);
|
|
104883
104823
|
resources.context.finalize();
|
|
104884
104824
|
}
|
|
104885
104825
|
function maskApiKey(apiKey) {
|
|
@@ -104893,27 +104833,6 @@ async function resolveAuthCredential(container, options = {}) {
|
|
|
104893
104833
|
}
|
|
104894
104834
|
return container.readApiKey(options);
|
|
104895
104835
|
}
|
|
104896
|
-
async function executeWhoami(program, container) {
|
|
104897
|
-
const flags = resolveCommandFlags(program);
|
|
104898
|
-
const apiKey = await resolveAuthCredential(container, { readOnly: flags.dryRun });
|
|
104899
|
-
if (!apiKey) {
|
|
104900
|
-
process.exitCode = 1;
|
|
104901
|
-
return;
|
|
104902
|
-
}
|
|
104903
|
-
if (flags.dryRun) {
|
|
104904
|
-
const resources = createExecutionResources(container, flags, "auth:whoami");
|
|
104905
|
-
resources.logger.dryRun("Dry run: would fetch identity from Poe API.");
|
|
104906
|
-
resources.context.finalize();
|
|
104907
|
-
return;
|
|
104908
|
-
}
|
|
104909
|
-
writeJson(
|
|
104910
|
-
await fetchPoeAuthIdentity({
|
|
104911
|
-
apiKey,
|
|
104912
|
-
baseUrl: container.env.poeApiBaseUrl,
|
|
104913
|
-
httpClient: container.httpClient
|
|
104914
|
-
})
|
|
104915
|
-
);
|
|
104916
|
-
}
|
|
104917
104836
|
var init_auth = __esm({
|
|
104918
104837
|
"src/cli/commands/auth.ts"() {
|
|
104919
104838
|
"use strict";
|
|
@@ -104921,7 +104840,7 @@ var init_auth = __esm({
|
|
|
104921
104840
|
init_shared();
|
|
104922
104841
|
init_login();
|
|
104923
104842
|
init_logout();
|
|
104924
|
-
|
|
104843
|
+
init_auth_check();
|
|
104925
104844
|
init_json_output();
|
|
104926
104845
|
}
|
|
104927
104846
|
});
|
|
@@ -142993,7 +142912,9 @@ function createObjectArrayGlobals(options) {
|
|
|
142993
142912
|
}),
|
|
142994
142913
|
String: createSandboxClosure({
|
|
142995
142914
|
sandbox: true,
|
|
142996
|
-
call: ([value]) => options.budget.allocateString(
|
|
142915
|
+
call: ([value]) => options.budget.allocateString(
|
|
142916
|
+
typeof value === "object" && value !== null && sandboxErrorTypes.has(value) && !Object.hasOwn(value, "toString") ? Error.prototype.toString.call(value) : String(value)
|
|
142917
|
+
),
|
|
142997
142918
|
name: "String",
|
|
142998
142919
|
properties: {
|
|
142999
142920
|
raw: createSandboxClosure({
|
|
@@ -143205,6 +143126,7 @@ function getTemplateRawParts(template2) {
|
|
|
143205
143126
|
var init_object_array = __esm({
|
|
143206
143127
|
"packages/safejs/src/interp/globals/object-array.ts"() {
|
|
143207
143128
|
"use strict";
|
|
143129
|
+
init_shape();
|
|
143208
143130
|
init_iteration();
|
|
143209
143131
|
init_values();
|
|
143210
143132
|
}
|
|
@@ -154024,12 +153946,12 @@ async function checkAuth2(container, credential) {
|
|
|
154024
153946
|
return { name: "auth", ok: false, detail: 'Not logged in. Run "poe-code login".' };
|
|
154025
153947
|
}
|
|
154026
153948
|
try {
|
|
154027
|
-
|
|
153949
|
+
await checkPoeAuth({
|
|
154028
153950
|
apiKey: credential,
|
|
154029
|
-
baseUrl: container.env.
|
|
153951
|
+
baseUrl: container.env.poeBaseUrl,
|
|
154030
153952
|
httpClient: container.httpClient
|
|
154031
153953
|
});
|
|
154032
|
-
return { name: "auth", ok: true, detail:
|
|
153954
|
+
return { name: "auth", ok: true, detail: "Logged in" };
|
|
154033
153955
|
} catch (error3) {
|
|
154034
153956
|
return {
|
|
154035
153957
|
name: "auth",
|
|
@@ -154098,11 +154020,7 @@ async function checkRuntimes(services, resources) {
|
|
|
154098
154020
|
if (!binaryName) {
|
|
154099
154021
|
continue;
|
|
154100
154022
|
}
|
|
154101
|
-
const check = createBinaryExistsCheck(
|
|
154102
|
-
binaryName,
|
|
154103
|
-
`${service}-binary`,
|
|
154104
|
-
`${binaryName} on PATH`
|
|
154105
|
-
);
|
|
154023
|
+
const check = createBinaryExistsCheck(binaryName, `${service}-binary`, `${binaryName} on PATH`);
|
|
154106
154024
|
try {
|
|
154107
154025
|
await check.run({
|
|
154108
154026
|
isDryRun: false,
|
|
@@ -154137,7 +154055,7 @@ var init_doctor = __esm({
|
|
|
154137
154055
|
init_src8();
|
|
154138
154056
|
init_shared();
|
|
154139
154057
|
init_config5();
|
|
154140
|
-
|
|
154058
|
+
init_auth_check();
|
|
154141
154059
|
init_command_checks();
|
|
154142
154060
|
}
|
|
154143
154061
|
});
|
|
@@ -155836,7 +155754,7 @@ var init_package2 = __esm({
|
|
|
155836
155754
|
"package.json"() {
|
|
155837
155755
|
package_default2 = {
|
|
155838
155756
|
name: "poe-code",
|
|
155839
|
-
version: "
|
|
155757
|
+
version: "12.0.1",
|
|
155840
155758
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
155841
155759
|
license: "MIT",
|
|
155842
155760
|
type: "module",
|
|
@@ -156993,7 +156911,6 @@ var init_program = __esm({
|
|
|
156993
156911
|
"ralph",
|
|
156994
156912
|
"usage",
|
|
156995
156913
|
"dashboard",
|
|
156996
|
-
"whoami",
|
|
156997
156914
|
"version",
|
|
156998
156915
|
"help"
|
|
156999
156916
|
];
|
|
@@ -157360,7 +157277,81 @@ async function installSkill2(agentId, source, options = {}) {
|
|
|
157360
157277
|
|
|
157361
157278
|
// src/index.ts
|
|
157362
157279
|
init_gaslight();
|
|
157363
|
-
|
|
157280
|
+
|
|
157281
|
+
// src/sdk/credentials.ts
|
|
157282
|
+
init_src17();
|
|
157283
|
+
init_errors();
|
|
157284
|
+
init_environment2();
|
|
157285
|
+
async function getPoeApiKey() {
|
|
157286
|
+
const envKey = Object.hasOwn(process.env, "POE_API_KEY") ? process.env.POE_API_KEY : void 0;
|
|
157287
|
+
if (typeof envKey === "string" && envKey.trim().length > 0) {
|
|
157288
|
+
return envKey.trim();
|
|
157289
|
+
}
|
|
157290
|
+
const { store } = createSecretStore({
|
|
157291
|
+
backendEnvVar: "POE_AUTH_BACKEND",
|
|
157292
|
+
fileStore: {
|
|
157293
|
+
salt: "poe-code:encrypted-file-auth-store:v1",
|
|
157294
|
+
defaultDirectory: ".poe-code",
|
|
157295
|
+
defaultFileName: "credentials.enc"
|
|
157296
|
+
}
|
|
157297
|
+
});
|
|
157298
|
+
const storedKey = await store.get();
|
|
157299
|
+
if (typeof storedKey === "string" && storedKey.trim().length > 0) {
|
|
157300
|
+
return storedKey.trim();
|
|
157301
|
+
}
|
|
157302
|
+
throw new AuthenticationError("No API key found. Set POE_API_KEY or run 'poe-code login'.");
|
|
157303
|
+
}
|
|
157304
|
+
async function getPoeAuthIdentity(options = {}) {
|
|
157305
|
+
const apiKey = options.apiKey ?? await getPoeApiKey();
|
|
157306
|
+
return fetchPoeAuthIdentity({
|
|
157307
|
+
apiKey,
|
|
157308
|
+
baseUrl: options.baseUrl ?? resolvePoeApiBaseUrl(options.variables),
|
|
157309
|
+
httpClient: options.httpClient
|
|
157310
|
+
});
|
|
157311
|
+
}
|
|
157312
|
+
async function fetchPoeAuthIdentity(options) {
|
|
157313
|
+
const httpClient = options.httpClient ?? createDefaultHttpClient();
|
|
157314
|
+
const response = await httpClient(`${trimTrailingSlashes(options.baseUrl ?? resolvePoeApiBaseUrl())}/whoami`, {
|
|
157315
|
+
method: "POST",
|
|
157316
|
+
headers: {
|
|
157317
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
157318
|
+
}
|
|
157319
|
+
});
|
|
157320
|
+
if (!response.ok) {
|
|
157321
|
+
throw new ApiError(`Failed to fetch identity (HTTP ${response.status})`, {
|
|
157322
|
+
httpStatus: response.status,
|
|
157323
|
+
endpoint: "/v1/whoami"
|
|
157324
|
+
});
|
|
157325
|
+
}
|
|
157326
|
+
return parsePoeAuthIdentity(await response.json());
|
|
157327
|
+
}
|
|
157328
|
+
function parsePoeAuthIdentity(value) {
|
|
157329
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
157330
|
+
throw new ApiError("Malformed identity response from Poe API.", {
|
|
157331
|
+
endpoint: "/v1/whoami"
|
|
157332
|
+
});
|
|
157333
|
+
}
|
|
157334
|
+
const identity = value;
|
|
157335
|
+
if (typeof identity.user_id !== "number" || !Number.isFinite(identity.user_id) || typeof identity.handle !== "string" || identity.handle.trim().length === 0 || typeof identity.name !== "string" || identity.name.trim().length === 0 || typeof identity.profile_picture !== "string") {
|
|
157336
|
+
throw new ApiError("Malformed identity response from Poe API.", {
|
|
157337
|
+
endpoint: "/v1/whoami"
|
|
157338
|
+
});
|
|
157339
|
+
}
|
|
157340
|
+
return value;
|
|
157341
|
+
}
|
|
157342
|
+
function createDefaultHttpClient() {
|
|
157343
|
+
return async (url, init) => {
|
|
157344
|
+
const response = await globalThis.fetch(url, init);
|
|
157345
|
+
return {
|
|
157346
|
+
ok: response.ok,
|
|
157347
|
+
status: response.status,
|
|
157348
|
+
json: () => response.json()
|
|
157349
|
+
};
|
|
157350
|
+
};
|
|
157351
|
+
}
|
|
157352
|
+
function trimTrailingSlashes(value) {
|
|
157353
|
+
return value.replace(/\/+$/, "");
|
|
157354
|
+
}
|
|
157364
157355
|
|
|
157365
157356
|
// src/agent.ts
|
|
157366
157357
|
init_src20();
|