poe-code 3.0.99 → 3.0.101
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/login.js +2 -4
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/container.js +9 -9
- package/dist/cli/container.js.map +1 -1
- package/dist/cli/oauth-login.js +1 -3
- package/dist/cli/oauth-login.js.map +1 -1
- package/dist/index.js +556 -653
- package/dist/index.js.map +4 -4
- package/dist/providers/poe-agent.js +94 -252
- package/dist/providers/poe-agent.js.map +4 -4
- package/dist/sdk/container.js +9 -9
- package/dist/sdk/container.js.map +1 -1
- package/dist/sdk/credentials.d.ts +1 -1
- package/dist/sdk/credentials.js +11 -4
- package/dist/sdk/credentials.js.map +1 -1
- package/package.json +3 -2
|
@@ -630,8 +630,8 @@ function resourceNotFound(resource) {
|
|
|
630
630
|
`Resource not found: ${resource}`
|
|
631
631
|
);
|
|
632
632
|
}
|
|
633
|
-
function assertAbsolutePath(
|
|
634
|
-
if (!isAbsolute(
|
|
633
|
+
function assertAbsolutePath(path6) {
|
|
634
|
+
if (!isAbsolute(path6)) {
|
|
635
635
|
throw invalidParams('"path" must be an absolute path');
|
|
636
636
|
}
|
|
637
637
|
}
|
|
@@ -1406,7 +1406,7 @@ var require_config_toml = __commonJS({
|
|
|
1406
1406
|
}
|
|
1407
1407
|
});
|
|
1408
1408
|
|
|
1409
|
-
// packages/
|
|
1409
|
+
// packages/auth-store/src/encrypted-file-store.ts
|
|
1410
1410
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt } from "node:crypto";
|
|
1411
1411
|
import { promises as fs } from "node:fs";
|
|
1412
1412
|
import { homedir as homedir2, hostname, userInfo } from "node:os";
|
|
@@ -1417,11 +1417,11 @@ function defaultMachineIdentity() {
|
|
|
1417
1417
|
username: userInfo().username
|
|
1418
1418
|
};
|
|
1419
1419
|
}
|
|
1420
|
-
async function deriveEncryptionKey(getMachineIdentity) {
|
|
1420
|
+
async function deriveEncryptionKey(getMachineIdentity, salt) {
|
|
1421
1421
|
const machineIdentity = await getMachineIdentity();
|
|
1422
1422
|
const secret = `${machineIdentity.hostname}:${machineIdentity.username}`;
|
|
1423
1423
|
return await new Promise((resolve, reject) => {
|
|
1424
|
-
scrypt(secret,
|
|
1424
|
+
scrypt(secret, salt, ENCRYPTION_KEY_BYTES, (error, derivedKey) => {
|
|
1425
1425
|
if (error) {
|
|
1426
1426
|
reject(error);
|
|
1427
1427
|
return;
|
|
@@ -1460,34 +1460,35 @@ function isNotFoundError(error) {
|
|
|
1460
1460
|
error && typeof error === "object" && "code" in error && error.code === "ENOENT"
|
|
1461
1461
|
);
|
|
1462
1462
|
}
|
|
1463
|
-
var ENCRYPTION_ALGORITHM, ENCRYPTION_VERSION, ENCRYPTION_KEY_BYTES, ENCRYPTION_IV_BYTES, ENCRYPTION_AUTH_TAG_BYTES,
|
|
1464
|
-
var
|
|
1465
|
-
"packages/
|
|
1463
|
+
var ENCRYPTION_ALGORITHM, ENCRYPTION_VERSION, ENCRYPTION_KEY_BYTES, ENCRYPTION_IV_BYTES, ENCRYPTION_AUTH_TAG_BYTES, ENCRYPTION_FILE_MODE, EncryptedFileStore;
|
|
1464
|
+
var init_encrypted_file_store = __esm({
|
|
1465
|
+
"packages/auth-store/src/encrypted-file-store.ts"() {
|
|
1466
1466
|
"use strict";
|
|
1467
1467
|
ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
1468
1468
|
ENCRYPTION_VERSION = 1;
|
|
1469
1469
|
ENCRYPTION_KEY_BYTES = 32;
|
|
1470
1470
|
ENCRYPTION_IV_BYTES = 12;
|
|
1471
1471
|
ENCRYPTION_AUTH_TAG_BYTES = 16;
|
|
1472
|
-
ENCRYPTION_SALT = "poe-code:encrypted-file-auth-store:v1";
|
|
1473
1472
|
ENCRYPTION_FILE_MODE = 384;
|
|
1474
|
-
|
|
1473
|
+
EncryptedFileStore = class {
|
|
1475
1474
|
fs;
|
|
1476
1475
|
filePath;
|
|
1476
|
+
salt;
|
|
1477
1477
|
getMachineIdentity;
|
|
1478
1478
|
getRandomBytes;
|
|
1479
1479
|
keyPromise = null;
|
|
1480
|
-
constructor(input
|
|
1480
|
+
constructor(input) {
|
|
1481
1481
|
this.fs = input.fs ?? fs;
|
|
1482
|
+
this.salt = input.salt;
|
|
1482
1483
|
this.filePath = input.filePath ?? path2.join(
|
|
1483
1484
|
(input.getHomeDirectory ?? homedir2)(),
|
|
1484
|
-
".
|
|
1485
|
-
"credentials.enc"
|
|
1485
|
+
input.defaultDirectory ?? ".auth-store",
|
|
1486
|
+
input.defaultFileName ?? "credentials.enc"
|
|
1486
1487
|
);
|
|
1487
1488
|
this.getMachineIdentity = input.getMachineIdentity ?? defaultMachineIdentity;
|
|
1488
1489
|
this.getRandomBytes = input.getRandomBytes ?? randomBytes;
|
|
1489
1490
|
}
|
|
1490
|
-
async
|
|
1491
|
+
async get() {
|
|
1491
1492
|
let rawDocument;
|
|
1492
1493
|
try {
|
|
1493
1494
|
rawDocument = await this.fs.readFile(this.filePath, "utf8");
|
|
@@ -1517,12 +1518,12 @@ var init_encrypted_file_auth_store = __esm({
|
|
|
1517
1518
|
return null;
|
|
1518
1519
|
}
|
|
1519
1520
|
}
|
|
1520
|
-
async
|
|
1521
|
+
async set(value) {
|
|
1521
1522
|
const key = await this.getEncryptionKey();
|
|
1522
1523
|
const iv = this.getRandomBytes(ENCRYPTION_IV_BYTES);
|
|
1523
1524
|
const cipher = createCipheriv(ENCRYPTION_ALGORITHM, key, iv);
|
|
1524
1525
|
const ciphertext = Buffer.concat([
|
|
1525
|
-
cipher.update(
|
|
1526
|
+
cipher.update(value, "utf8"),
|
|
1526
1527
|
cipher.final()
|
|
1527
1528
|
]);
|
|
1528
1529
|
const authTag = cipher.getAuthTag();
|
|
@@ -1538,7 +1539,7 @@ var init_encrypted_file_auth_store = __esm({
|
|
|
1538
1539
|
});
|
|
1539
1540
|
await this.fs.chmod(this.filePath, ENCRYPTION_FILE_MODE);
|
|
1540
1541
|
}
|
|
1541
|
-
async
|
|
1542
|
+
async delete() {
|
|
1542
1543
|
try {
|
|
1543
1544
|
await this.fs.unlink(this.filePath);
|
|
1544
1545
|
} catch (error) {
|
|
@@ -1549,7 +1550,7 @@ var init_encrypted_file_auth_store = __esm({
|
|
|
1549
1550
|
}
|
|
1550
1551
|
getEncryptionKey() {
|
|
1551
1552
|
if (!this.keyPromise) {
|
|
1552
|
-
this.keyPromise = deriveEncryptionKey(this.getMachineIdentity);
|
|
1553
|
+
this.keyPromise = deriveEncryptionKey(this.getMachineIdentity, this.salt);
|
|
1553
1554
|
}
|
|
1554
1555
|
return this.keyPromise;
|
|
1555
1556
|
}
|
|
@@ -1557,7 +1558,7 @@ var init_encrypted_file_auth_store = __esm({
|
|
|
1557
1558
|
}
|
|
1558
1559
|
});
|
|
1559
1560
|
|
|
1560
|
-
// packages/
|
|
1561
|
+
// packages/auth-store/src/keychain-store.ts
|
|
1561
1562
|
import { spawn } from "node:child_process";
|
|
1562
1563
|
function runSecurityCommand(command, args) {
|
|
1563
1564
|
return new Promise((resolve) => {
|
|
@@ -1617,27 +1618,25 @@ function createSecurityCliFailure(operation, result) {
|
|
|
1617
1618
|
}
|
|
1618
1619
|
return new Error(`Failed to ${operation}: security exited with code ${result.exitCode}`);
|
|
1619
1620
|
}
|
|
1620
|
-
var SECURITY_CLI,
|
|
1621
|
-
var
|
|
1622
|
-
"packages/
|
|
1621
|
+
var SECURITY_CLI, KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE, KeychainStore;
|
|
1622
|
+
var init_keychain_store = __esm({
|
|
1623
|
+
"packages/auth-store/src/keychain-store.ts"() {
|
|
1623
1624
|
"use strict";
|
|
1624
1625
|
SECURITY_CLI = "security";
|
|
1625
|
-
KEYCHAIN_SERVICE = "poe-code";
|
|
1626
|
-
KEYCHAIN_ACCOUNT = "api-key";
|
|
1627
1626
|
KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE = 44;
|
|
1628
|
-
|
|
1627
|
+
KeychainStore = class {
|
|
1629
1628
|
runCommand;
|
|
1630
1629
|
service;
|
|
1631
1630
|
account;
|
|
1632
|
-
constructor(input
|
|
1631
|
+
constructor(input) {
|
|
1633
1632
|
this.runCommand = input.runCommand ?? runSecurityCommand;
|
|
1634
|
-
this.service = input.service
|
|
1635
|
-
this.account = input.account
|
|
1633
|
+
this.service = input.service;
|
|
1634
|
+
this.account = input.account;
|
|
1636
1635
|
}
|
|
1637
|
-
async
|
|
1636
|
+
async get() {
|
|
1638
1637
|
const result = await this.executeSecurityCommand(
|
|
1639
1638
|
["find-generic-password", "-s", this.service, "-a", this.account, "-w"],
|
|
1640
|
-
"read
|
|
1639
|
+
"read secret from macOS Keychain"
|
|
1641
1640
|
);
|
|
1642
1641
|
if (result.exitCode === 0) {
|
|
1643
1642
|
return stripTrailingLineBreak(result.stdout);
|
|
@@ -1645,9 +1644,9 @@ var init_keychain_auth_store = __esm({
|
|
|
1645
1644
|
if (isKeychainEntryNotFound(result)) {
|
|
1646
1645
|
return null;
|
|
1647
1646
|
}
|
|
1648
|
-
throw createSecurityCliFailure("read
|
|
1647
|
+
throw createSecurityCliFailure("read secret from macOS Keychain", result);
|
|
1649
1648
|
}
|
|
1650
|
-
async
|
|
1649
|
+
async set(value) {
|
|
1651
1650
|
const result = await this.executeSecurityCommand(
|
|
1652
1651
|
[
|
|
1653
1652
|
"add-generic-password",
|
|
@@ -1656,24 +1655,24 @@ var init_keychain_auth_store = __esm({
|
|
|
1656
1655
|
"-a",
|
|
1657
1656
|
this.account,
|
|
1658
1657
|
"-w",
|
|
1659
|
-
|
|
1658
|
+
value,
|
|
1660
1659
|
"-U"
|
|
1661
1660
|
],
|
|
1662
|
-
"store
|
|
1661
|
+
"store secret in macOS Keychain"
|
|
1663
1662
|
);
|
|
1664
1663
|
if (result.exitCode !== 0) {
|
|
1665
|
-
throw createSecurityCliFailure("store
|
|
1664
|
+
throw createSecurityCliFailure("store secret in macOS Keychain", result);
|
|
1666
1665
|
}
|
|
1667
1666
|
}
|
|
1668
|
-
async
|
|
1667
|
+
async delete() {
|
|
1669
1668
|
const result = await this.executeSecurityCommand(
|
|
1670
1669
|
["delete-generic-password", "-s", this.service, "-a", this.account],
|
|
1671
|
-
"delete
|
|
1670
|
+
"delete secret from macOS Keychain"
|
|
1672
1671
|
);
|
|
1673
1672
|
if (result.exitCode === 0 || isKeychainEntryNotFound(result)) {
|
|
1674
1673
|
return;
|
|
1675
1674
|
}
|
|
1676
|
-
throw createSecurityCliFailure("delete
|
|
1675
|
+
throw createSecurityCliFailure("delete secret from macOS Keychain", result);
|
|
1677
1676
|
}
|
|
1678
1677
|
async executeSecurityCommand(args, operation) {
|
|
1679
1678
|
try {
|
|
@@ -1687,222 +1686,58 @@ var init_keychain_auth_store = __esm({
|
|
|
1687
1686
|
}
|
|
1688
1687
|
});
|
|
1689
1688
|
|
|
1690
|
-
// packages/
|
|
1691
|
-
|
|
1692
|
-
import { homedir as homedir3 } from "node:os";
|
|
1693
|
-
import path3 from "node:path";
|
|
1694
|
-
function createAuthStore(input = {}) {
|
|
1689
|
+
// packages/auth-store/src/create-secret-store.ts
|
|
1690
|
+
function createSecretStore(input) {
|
|
1695
1691
|
const backend = resolveBackend(input);
|
|
1696
1692
|
const platform = input.platform ?? process.platform;
|
|
1697
1693
|
if (backend === "keychain" && platform !== MACOS_PLATFORM) {
|
|
1698
1694
|
throw new Error(
|
|
1699
|
-
`
|
|
1695
|
+
`Keychain backend is only supported on macOS. Current platform: ${platform}`
|
|
1700
1696
|
);
|
|
1701
1697
|
}
|
|
1702
|
-
const store =
|
|
1703
|
-
return {
|
|
1704
|
-
backend,
|
|
1705
|
-
store: enableLegacyCredentialsMigration(store, input)
|
|
1706
|
-
};
|
|
1698
|
+
const store = storeFactories[backend](input);
|
|
1699
|
+
return { backend, store };
|
|
1707
1700
|
}
|
|
1708
1701
|
function resolveBackend(input) {
|
|
1709
|
-
const
|
|
1702
|
+
const envVar = input.backendEnvVar ?? DEFAULT_BACKEND_ENV_VAR;
|
|
1703
|
+
const configuredBackend = input.backend ?? input.env?.[envVar] ?? process.env[envVar];
|
|
1710
1704
|
if (configuredBackend === "keychain") {
|
|
1711
1705
|
return "keychain";
|
|
1712
1706
|
}
|
|
1713
1707
|
return "file";
|
|
1714
1708
|
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
let hasCheckedLegacyCredentials = false;
|
|
1719
|
-
let legacyMigrationPromise = null;
|
|
1720
|
-
store.getApiKey = async () => {
|
|
1721
|
-
const storedApiKey = await readApiKeyFromStore();
|
|
1722
|
-
if (isNonEmptyString(storedApiKey)) {
|
|
1723
|
-
return storedApiKey;
|
|
1724
|
-
}
|
|
1725
|
-
if (hasCheckedLegacyCredentials) {
|
|
1726
|
-
return null;
|
|
1727
|
-
}
|
|
1728
|
-
if (!legacyMigrationPromise) {
|
|
1729
|
-
legacyMigrationPromise = migrateLegacyApiKey(store, migrationContext).finally(() => {
|
|
1730
|
-
hasCheckedLegacyCredentials = true;
|
|
1731
|
-
legacyMigrationPromise = null;
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
return legacyMigrationPromise;
|
|
1735
|
-
};
|
|
1736
|
-
return store;
|
|
1737
|
-
}
|
|
1738
|
-
async function migrateLegacyApiKey(store, migrationContext) {
|
|
1739
|
-
const legacyCredentials = await loadLegacyCredentials(
|
|
1740
|
-
migrationContext.fs,
|
|
1741
|
-
migrationContext.filePath
|
|
1742
|
-
);
|
|
1743
|
-
if (!legacyCredentials || !isNonEmptyString(legacyCredentials.apiKey)) {
|
|
1744
|
-
return null;
|
|
1745
|
-
}
|
|
1746
|
-
const plaintextApiKey = legacyCredentials.apiKey;
|
|
1747
|
-
try {
|
|
1748
|
-
await store.setApiKey(plaintextApiKey);
|
|
1749
|
-
delete legacyCredentials.apiKey;
|
|
1750
|
-
await saveLegacyCredentials(
|
|
1751
|
-
migrationContext.fs,
|
|
1752
|
-
migrationContext.filePath,
|
|
1753
|
-
legacyCredentials
|
|
1754
|
-
);
|
|
1755
|
-
} catch (error) {
|
|
1756
|
-
migrationContext.logWarning(
|
|
1757
|
-
`Failed to migrate plaintext API key from ${migrationContext.filePath}.`,
|
|
1758
|
-
error
|
|
1759
|
-
);
|
|
1760
|
-
}
|
|
1761
|
-
return plaintextApiKey;
|
|
1762
|
-
}
|
|
1763
|
-
function createLegacyMigrationContext(input) {
|
|
1764
|
-
const legacyCredentialsInput = input.legacyCredentials;
|
|
1765
|
-
const getHomeDirectory = legacyCredentialsInput?.getHomeDirectory ?? homedir3;
|
|
1766
|
-
return {
|
|
1767
|
-
fs: legacyCredentialsInput?.fs ?? input.fileStore?.fs ?? nodeFs,
|
|
1768
|
-
filePath: legacyCredentialsInput?.filePath ?? path3.join(
|
|
1769
|
-
getHomeDirectory(),
|
|
1770
|
-
LEGACY_CREDENTIALS_RELATIVE_PATH
|
|
1771
|
-
),
|
|
1772
|
-
logWarning: legacyCredentialsInput?.logWarning ?? defaultMigrationWarning
|
|
1773
|
-
};
|
|
1774
|
-
}
|
|
1775
|
-
async function loadLegacyCredentials(fs2, filePath) {
|
|
1776
|
-
let raw;
|
|
1777
|
-
try {
|
|
1778
|
-
raw = await fs2.readFile(filePath, "utf8");
|
|
1779
|
-
} catch (error) {
|
|
1780
|
-
if (isNotFoundError2(error)) {
|
|
1781
|
-
return null;
|
|
1782
|
-
}
|
|
1783
|
-
return null;
|
|
1784
|
-
}
|
|
1785
|
-
try {
|
|
1786
|
-
const parsed = JSON.parse(raw);
|
|
1787
|
-
if (!isRecord2(parsed)) {
|
|
1788
|
-
return null;
|
|
1789
|
-
}
|
|
1790
|
-
return parsed;
|
|
1791
|
-
} catch {
|
|
1792
|
-
return null;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
async function saveLegacyCredentials(fs2, filePath, document) {
|
|
1796
|
-
await fs2.mkdir(path3.dirname(filePath), { recursive: true });
|
|
1797
|
-
await fs2.writeFile(filePath, `${JSON.stringify(document, null, 2)}
|
|
1798
|
-
`, {
|
|
1799
|
-
encoding: "utf8"
|
|
1800
|
-
});
|
|
1801
|
-
}
|
|
1802
|
-
function defaultMigrationWarning(message, error) {
|
|
1803
|
-
const details = toErrorDetails(error);
|
|
1804
|
-
if (details.length > 0) {
|
|
1805
|
-
console.warn(`${message} ${details}`);
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
console.warn(message);
|
|
1809
|
-
}
|
|
1810
|
-
function toErrorDetails(error) {
|
|
1811
|
-
if (error instanceof Error) {
|
|
1812
|
-
return error.message;
|
|
1813
|
-
}
|
|
1814
|
-
return typeof error === "string" ? error : "";
|
|
1815
|
-
}
|
|
1816
|
-
function isNonEmptyString(value) {
|
|
1817
|
-
return typeof value === "string" && value.length > 0;
|
|
1818
|
-
}
|
|
1819
|
-
function isRecord2(value) {
|
|
1820
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1821
|
-
}
|
|
1822
|
-
function isNotFoundError2(error) {
|
|
1823
|
-
return Boolean(
|
|
1824
|
-
error && typeof error === "object" && "code" in error && error.code === "ENOENT"
|
|
1825
|
-
);
|
|
1826
|
-
}
|
|
1827
|
-
var AUTH_BACKEND_ENV_VAR, MACOS_PLATFORM, LEGACY_CREDENTIALS_RELATIVE_PATH, authStoreFactories;
|
|
1828
|
-
var init_create_auth_store = __esm({
|
|
1829
|
-
"packages/poe-auth/src/create-auth-store.ts"() {
|
|
1709
|
+
var DEFAULT_BACKEND_ENV_VAR, MACOS_PLATFORM, storeFactories;
|
|
1710
|
+
var init_create_secret_store = __esm({
|
|
1711
|
+
"packages/auth-store/src/create-secret-store.ts"() {
|
|
1830
1712
|
"use strict";
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1713
|
+
init_encrypted_file_store();
|
|
1714
|
+
init_keychain_store();
|
|
1715
|
+
DEFAULT_BACKEND_ENV_VAR = "AUTH_BACKEND";
|
|
1834
1716
|
MACOS_PLATFORM = "darwin";
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1717
|
+
storeFactories = {
|
|
1718
|
+
file: (input) => {
|
|
1719
|
+
if (!input.fileStore) {
|
|
1720
|
+
throw new Error("fileStore configuration is required for file backend");
|
|
1721
|
+
}
|
|
1722
|
+
return new EncryptedFileStore(input.fileStore);
|
|
1723
|
+
},
|
|
1724
|
+
keychain: (input) => {
|
|
1725
|
+
if (!input.keychainStore) {
|
|
1726
|
+
throw new Error("keychainStore configuration is required for keychain backend");
|
|
1727
|
+
}
|
|
1728
|
+
return new KeychainStore(input.keychainStore);
|
|
1729
|
+
}
|
|
1839
1730
|
};
|
|
1840
1731
|
}
|
|
1841
1732
|
});
|
|
1842
1733
|
|
|
1843
|
-
// packages/
|
|
1844
|
-
var init_check_auth = __esm({
|
|
1845
|
-
"packages/poe-auth/src/check-auth.ts"() {
|
|
1846
|
-
"use strict";
|
|
1847
|
-
init_create_auth_store();
|
|
1848
|
-
}
|
|
1849
|
-
});
|
|
1850
|
-
|
|
1851
|
-
// packages/poe-auth/src/get-token.ts
|
|
1852
|
-
var init_get_token = __esm({
|
|
1853
|
-
"packages/poe-auth/src/get-token.ts"() {
|
|
1854
|
-
"use strict";
|
|
1855
|
-
init_create_auth_store();
|
|
1856
|
-
}
|
|
1857
|
-
});
|
|
1858
|
-
|
|
1859
|
-
// packages/poe-auth/src/api-key-validation.ts
|
|
1860
|
-
var init_api_key_validation = __esm({
|
|
1861
|
-
"packages/poe-auth/src/api-key-validation.ts"() {
|
|
1862
|
-
"use strict";
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
|
|
1866
|
-
// packages/poe-auth/src/oauth-client.ts
|
|
1867
|
-
import http from "node:http";
|
|
1868
|
-
import crypto from "node:crypto";
|
|
1869
|
-
var init_oauth_client = __esm({
|
|
1870
|
-
"packages/poe-auth/src/oauth-client.ts"() {
|
|
1871
|
-
"use strict";
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
|
|
1875
|
-
// packages/poe-auth/src/login.ts
|
|
1876
|
-
var init_login = __esm({
|
|
1877
|
-
"packages/poe-auth/src/login.ts"() {
|
|
1878
|
-
"use strict";
|
|
1879
|
-
init_api_key_validation();
|
|
1880
|
-
init_create_auth_store();
|
|
1881
|
-
init_oauth_client();
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
|
|
1885
|
-
// packages/poe-auth/src/logout.ts
|
|
1886
|
-
var init_logout = __esm({
|
|
1887
|
-
"packages/poe-auth/src/logout.ts"() {
|
|
1888
|
-
"use strict";
|
|
1889
|
-
init_create_auth_store();
|
|
1890
|
-
}
|
|
1891
|
-
});
|
|
1892
|
-
|
|
1893
|
-
// packages/poe-auth/src/index.ts
|
|
1734
|
+
// packages/auth-store/src/index.ts
|
|
1894
1735
|
var init_src2 = __esm({
|
|
1895
|
-
"packages/
|
|
1736
|
+
"packages/auth-store/src/index.ts"() {
|
|
1896
1737
|
"use strict";
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
init_api_key_validation();
|
|
1901
|
-
init_login();
|
|
1902
|
-
init_logout();
|
|
1903
|
-
init_oauth_client();
|
|
1904
|
-
init_encrypted_file_auth_store();
|
|
1905
|
-
init_keychain_auth_store();
|
|
1738
|
+
init_create_secret_store();
|
|
1739
|
+
init_encrypted_file_store();
|
|
1740
|
+
init_keychain_store();
|
|
1906
1741
|
}
|
|
1907
1742
|
});
|
|
1908
1743
|
|
|
@@ -2727,7 +2562,7 @@ var init_acp_core = __esm({
|
|
|
2727
2562
|
});
|
|
2728
2563
|
|
|
2729
2564
|
// packages/poe-agent/src/plugins/plugin-args.ts
|
|
2730
|
-
import
|
|
2565
|
+
import path3 from "node:path";
|
|
2731
2566
|
function isObjectRecord3(value) {
|
|
2732
2567
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2733
2568
|
}
|
|
@@ -2758,13 +2593,13 @@ function getOptionalString(args, key) {
|
|
|
2758
2593
|
return value;
|
|
2759
2594
|
}
|
|
2760
2595
|
function resolveAllowedPath(cwd, allowedPaths, inputPath) {
|
|
2761
|
-
const resolvedPath =
|
|
2596
|
+
const resolvedPath = path3.resolve(cwd, inputPath);
|
|
2762
2597
|
const isAllowed = allowedPaths.some((allowedPath) => {
|
|
2763
2598
|
if (allowedPath === resolvedPath) {
|
|
2764
2599
|
return true;
|
|
2765
2600
|
}
|
|
2766
|
-
const rel =
|
|
2767
|
-
return rel.length > 0 && !rel.startsWith("..") && !
|
|
2601
|
+
const rel = path3.relative(allowedPath, resolvedPath);
|
|
2602
|
+
return rel.length > 0 && !rel.startsWith("..") && !path3.isAbsolute(rel);
|
|
2768
2603
|
});
|
|
2769
2604
|
if (!isAllowed) {
|
|
2770
2605
|
throw new Error(`Path is outside allowed paths: ${inputPath}`);
|
|
@@ -2779,7 +2614,7 @@ var init_plugin_args = __esm({
|
|
|
2779
2614
|
|
|
2780
2615
|
// packages/poe-agent/src/plugins/poe-agent-plugin-files.ts
|
|
2781
2616
|
import fsPromises2 from "node:fs/promises";
|
|
2782
|
-
import
|
|
2617
|
+
import path4 from "node:path";
|
|
2783
2618
|
async function fileExists(fs2, filePath) {
|
|
2784
2619
|
try {
|
|
2785
2620
|
await fs2.readFile(filePath, "utf8");
|
|
@@ -2803,9 +2638,9 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
2803
2638
|
"use strict";
|
|
2804
2639
|
init_plugin_args();
|
|
2805
2640
|
filesPlugin = (options = {}) => {
|
|
2806
|
-
const cwd =
|
|
2641
|
+
const cwd = path4.resolve(options.cwd ?? process.cwd());
|
|
2807
2642
|
const allowedPaths = (options.allowedPaths ?? [cwd]).map(
|
|
2808
|
-
(allowedPath) =>
|
|
2643
|
+
(allowedPath) => path4.resolve(cwd, allowedPath)
|
|
2809
2644
|
);
|
|
2810
2645
|
const fs2 = options.fs ?? fsPromises2;
|
|
2811
2646
|
const readFileTool = {
|
|
@@ -2859,7 +2694,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
2859
2694
|
async call(args) {
|
|
2860
2695
|
const command = getRequiredString(args, "command");
|
|
2861
2696
|
const filePath = resolveAllowedPath(cwd, allowedPaths, getRequiredString(args, "path"));
|
|
2862
|
-
const displayedPath =
|
|
2697
|
+
const displayedPath = path4.relative(cwd, filePath) || path4.basename(filePath);
|
|
2863
2698
|
if (command === "str_replace") {
|
|
2864
2699
|
const oldStr = getRequiredString(args, "old_str", true);
|
|
2865
2700
|
const newStr = getRequiredString(args, "new_str", true);
|
|
@@ -2879,7 +2714,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
2879
2714
|
if (await fileExists(fs2, filePath)) {
|
|
2880
2715
|
throw new Error("File already exists \u2014 use str_replace to edit");
|
|
2881
2716
|
}
|
|
2882
|
-
await fs2.mkdir(
|
|
2717
|
+
await fs2.mkdir(path4.dirname(filePath), { recursive: true });
|
|
2883
2718
|
await fs2.writeFile(filePath, fileText, "utf8");
|
|
2884
2719
|
return `Created file: ${displayedPath}`;
|
|
2885
2720
|
}
|
|
@@ -2920,7 +2755,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
2920
2755
|
|
|
2921
2756
|
// packages/poe-agent/src/plugins/poe-agent-plugin-shell.ts
|
|
2922
2757
|
import { exec as execCallback } from "node:child_process";
|
|
2923
|
-
import
|
|
2758
|
+
import path5 from "node:path";
|
|
2924
2759
|
import { promisify } from "node:util";
|
|
2925
2760
|
async function defaultRunCommand(command, cwd) {
|
|
2926
2761
|
try {
|
|
@@ -2953,9 +2788,9 @@ var init_poe_agent_plugin_shell = __esm({
|
|
|
2953
2788
|
init_plugin_args();
|
|
2954
2789
|
exec = promisify(execCallback);
|
|
2955
2790
|
shellPlugin = (options = {}) => {
|
|
2956
|
-
const cwd =
|
|
2791
|
+
const cwd = path5.resolve(options.cwd ?? process.cwd());
|
|
2957
2792
|
const allowedPaths = (options.allowedPaths ?? [cwd]).map(
|
|
2958
|
-
(allowedPath) =>
|
|
2793
|
+
(allowedPath) => path5.resolve(cwd, allowedPath)
|
|
2959
2794
|
);
|
|
2960
2795
|
const runCommand = options.runCommand ?? defaultRunCommand;
|
|
2961
2796
|
const runCommandTool = {
|
|
@@ -5282,8 +5117,15 @@ async function resolveApiKey(explicitApiKey) {
|
|
|
5282
5117
|
if (normalizedExplicitApiKey) {
|
|
5283
5118
|
return normalizedExplicitApiKey;
|
|
5284
5119
|
}
|
|
5285
|
-
const { store } =
|
|
5286
|
-
|
|
5120
|
+
const { store } = createSecretStore({
|
|
5121
|
+
backendEnvVar: "POE_AUTH_BACKEND",
|
|
5122
|
+
fileStore: {
|
|
5123
|
+
salt: "poe-code:encrypted-file-auth-store:v1",
|
|
5124
|
+
defaultDirectory: ".poe-code",
|
|
5125
|
+
defaultFileName: "credentials.enc"
|
|
5126
|
+
}
|
|
5127
|
+
});
|
|
5128
|
+
const storedApiKey = normalizeNonEmptyString(await store.get());
|
|
5287
5129
|
if (storedApiKey) {
|
|
5288
5130
|
return storedApiKey;
|
|
5289
5131
|
}
|
|
@@ -5857,16 +5699,16 @@ function getConfigFormat(pathOrFormat) {
|
|
|
5857
5699
|
}
|
|
5858
5700
|
return formatRegistry[formatName];
|
|
5859
5701
|
}
|
|
5860
|
-
function detectFormat(
|
|
5861
|
-
const ext = getExtension(
|
|
5702
|
+
function detectFormat(path6) {
|
|
5703
|
+
const ext = getExtension(path6);
|
|
5862
5704
|
return extensionMap[ext];
|
|
5863
5705
|
}
|
|
5864
|
-
function getExtension(
|
|
5865
|
-
const lastDot =
|
|
5706
|
+
function getExtension(path6) {
|
|
5707
|
+
const lastDot = path6.lastIndexOf(".");
|
|
5866
5708
|
if (lastDot === -1) {
|
|
5867
5709
|
return "";
|
|
5868
5710
|
}
|
|
5869
|
-
return
|
|
5711
|
+
return path6.slice(lastDot).toLowerCase();
|
|
5870
5712
|
}
|
|
5871
5713
|
|
|
5872
5714
|
// packages/config-mutations/src/execution/path-utils.ts
|