@maxceem/agw 0.14.0 → 0.15.0
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/agw.mjs +29 -21
- package/package.json +2 -1
package/dist/agw.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// <define:__AGW_MANIFEST__>
|
|
9
|
-
var define_AGW_MANIFEST_default = { version: "0.
|
|
9
|
+
var define_AGW_MANIFEST_default = { version: "0.15.0", wrangler: "4.96.0", upgradeFrom: ["0.15.0", "0.14.0", "0.13.1", "0.13.0", "0.12.1", "0.12.0", "0.11.2", "0.11.1", "0.11.0", "0.10.11", "0.10.10", "0.10.9", "0.10.8", "0.10.7", "0.10.6", "0.10.5", "0.10.4", "0.10.3", "0.10.2", "0.10.1", "0.10.0", "0.9.3", "0.9.2", "0.9.1", "0.9.0", "0.8.3", "0.8.2", "0.8.1", "0.8.0", "0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.15.0/gateway-0.15.0.tar.gz", sha256: "a16f9357ee510e03ba06f1d9ddc531057d00fef1750a0318969da72b8c3ef282", manifest: "48e6067ef1475bf894a3f00021c5caf3ee2140fae57f64d487f32e2f93e2553f" } };
|
|
10
10
|
|
|
11
11
|
// src/main.ts
|
|
12
12
|
import { Writable as Writable2 } from "node:stream";
|
|
@@ -22622,7 +22622,7 @@ function snippetRemedy(code, appId, language) {
|
|
|
22622
22622
|
|
|
22623
22623
|
// src/conversations.ts
|
|
22624
22624
|
import { mkdir as mkdir2, readFile as readFile3, stat, writeFile } from "node:fs/promises";
|
|
22625
|
-
import { dirname,
|
|
22625
|
+
import { dirname, isAbsolute, relative, resolve as resolve2 } from "node:path";
|
|
22626
22626
|
import { gunzipSync } from "node:zlib";
|
|
22627
22627
|
|
|
22628
22628
|
// src/usage.ts
|
|
@@ -22686,6 +22686,14 @@ async function sizeOf(path) {
|
|
|
22686
22686
|
return null;
|
|
22687
22687
|
}
|
|
22688
22688
|
}
|
|
22689
|
+
function inside(output2, name) {
|
|
22690
|
+
const path = resolve2(output2, name);
|
|
22691
|
+
const rel = relative(output2, path);
|
|
22692
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) {
|
|
22693
|
+
fail("invalid_response", "The deployment named a conversation file outside the export folder.", void 0, 3);
|
|
22694
|
+
}
|
|
22695
|
+
return path;
|
|
22696
|
+
}
|
|
22689
22697
|
async function save(path, bytes) {
|
|
22690
22698
|
await mkdir2(dirname(path), { recursive: true });
|
|
22691
22699
|
await writeFile(path, bytes);
|
|
@@ -22715,7 +22723,7 @@ async function conversationsCommand(ctx, appId, flags) {
|
|
|
22715
22723
|
})).data;
|
|
22716
22724
|
for (const file2 of page2.files) {
|
|
22717
22725
|
result.files += 1;
|
|
22718
|
-
const path =
|
|
22726
|
+
const path = inside(output2, file2.name);
|
|
22719
22727
|
batches.push(path);
|
|
22720
22728
|
if (await sizeOf(path) === file2.size) continue;
|
|
22721
22729
|
const bytes = await ctx.client.download("getAppConversationFile", {
|
|
@@ -22735,7 +22743,7 @@ async function conversationsCommand(ctx, appId, flags) {
|
|
|
22735
22743
|
for (const match of text2.matchAll(MEDIA_REFERENCE)) names.add(match[1]);
|
|
22736
22744
|
}
|
|
22737
22745
|
for (const name of names) {
|
|
22738
|
-
const path =
|
|
22746
|
+
const path = inside(output2, name);
|
|
22739
22747
|
if (await sizeOf(path) !== null) continue;
|
|
22740
22748
|
const bytes = await ctx.client.download("getAppConversationFile", {
|
|
22741
22749
|
params: { app: appId },
|
|
@@ -26322,11 +26330,11 @@ async function openBrowser(url2) {
|
|
|
26322
26330
|
// src/deployment.ts
|
|
26323
26331
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
26324
26332
|
import { writeFile as writeFile4, unlink as unlink2 } from "node:fs/promises";
|
|
26325
|
-
import { join as
|
|
26333
|
+
import { join as join4 } from "node:path";
|
|
26326
26334
|
|
|
26327
26335
|
// src/release.ts
|
|
26328
26336
|
import { readFile as readFile4, lstat as lstat2, mkdir as mkdir3, rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
26329
|
-
import { join as
|
|
26337
|
+
import { join as join2, dirname as dirname2 } from "node:path";
|
|
26330
26338
|
import { fileURLToPath } from "node:url";
|
|
26331
26339
|
import { createHash as createHash3, randomBytes as randomBytes3 } from "node:crypto";
|
|
26332
26340
|
|
|
@@ -26451,7 +26459,7 @@ async function fetchArchive(url2) {
|
|
|
26451
26459
|
async function extract(archive, directory) {
|
|
26452
26460
|
await mkdir3(directory, { recursive: true, mode: 448 });
|
|
26453
26461
|
for (const entry of readArchive(archive)) {
|
|
26454
|
-
const path =
|
|
26462
|
+
const path = join2(directory, entry.path);
|
|
26455
26463
|
if (entry.directory) {
|
|
26456
26464
|
await mkdir3(path, { recursive: true, mode: 448 });
|
|
26457
26465
|
continue;
|
|
@@ -26461,9 +26469,9 @@ async function extract(archive, directory) {
|
|
|
26461
26469
|
}
|
|
26462
26470
|
}
|
|
26463
26471
|
async function cachedRelease(version2, integrity, source) {
|
|
26464
|
-
const root = source.cache ??
|
|
26465
|
-
const directory =
|
|
26466
|
-
const cached2 = await readFile4(
|
|
26472
|
+
const root = source.cache ?? join2(cacheDirectory(), "releases");
|
|
26473
|
+
const directory = join2(root, version2);
|
|
26474
|
+
const cached2 = await readFile4(join2(directory, "manifest.json")).catch(() => null);
|
|
26467
26475
|
if (cached2 && digest(cached2) === integrity.manifest) return directory;
|
|
26468
26476
|
const supplied = source.archive ?? process.env["AGW_RELEASE_ARCHIVE"] ?? void 0;
|
|
26469
26477
|
let archive;
|
|
@@ -26487,10 +26495,10 @@ async function cachedRelease(version2, integrity, source) {
|
|
|
26487
26495
|
4
|
|
26488
26496
|
);
|
|
26489
26497
|
await protectedDirectory(root);
|
|
26490
|
-
const staging =
|
|
26498
|
+
const staging = join2(root, `.${version2}-${randomBytes3(8).toString("hex")}`);
|
|
26491
26499
|
try {
|
|
26492
26500
|
await extract(archive, staging);
|
|
26493
|
-
const manifest2 = await readFile4(
|
|
26501
|
+
const manifest2 = await readFile4(join2(staging, "manifest.json")).catch(() => null);
|
|
26494
26502
|
if (!manifest2 || digest(manifest2) !== integrity.manifest)
|
|
26495
26503
|
fail(
|
|
26496
26504
|
"release_integrity",
|
|
@@ -26516,7 +26524,7 @@ async function release2(requested = VERSION, base = dirname2(fileURLToPath(impor
|
|
|
26516
26524
|
if (major === void 0 || minor === void 0 || major < 22 || major === 22 && minor < 19)
|
|
26517
26525
|
fail("unsupported_runtime", "Node.js 22.19.0 or newer is required.");
|
|
26518
26526
|
const integrity = source.integrity === void 0 ? RELEASE : source.integrity;
|
|
26519
|
-
const packaged =
|
|
26527
|
+
const packaged = join2(base, "release", requested);
|
|
26520
26528
|
const local = await lstat2(packaged).catch(() => null);
|
|
26521
26529
|
let directory;
|
|
26522
26530
|
if (local?.isDirectory()) directory = packaged;
|
|
@@ -26530,7 +26538,7 @@ async function release2(requested = VERSION, base = dirname2(fileURLToPath(impor
|
|
|
26530
26538
|
);
|
|
26531
26539
|
let serialized;
|
|
26532
26540
|
try {
|
|
26533
|
-
serialized = await readFile4(
|
|
26541
|
+
serialized = await readFile4(join2(directory, "manifest.json"), "utf8");
|
|
26534
26542
|
} catch {
|
|
26535
26543
|
fail(
|
|
26536
26544
|
"release_missing",
|
|
@@ -26550,7 +26558,7 @@ async function release2(requested = VERSION, base = dirname2(fileURLToPath(impor
|
|
|
26550
26558
|
for (const [path, hash2] of Object.entries(manifest2.files)) {
|
|
26551
26559
|
if (path.startsWith("/") || path.split(/[\\/]/).some((p) => p === ".." || p === ""))
|
|
26552
26560
|
fail("release_integrity", "Release includes an unsafe path.");
|
|
26553
|
-
const file2 =
|
|
26561
|
+
const file2 = join2(directory, path);
|
|
26554
26562
|
const info = await lstat2(file2);
|
|
26555
26563
|
if (!info.isFile() || info.isSymbolicLink() || digest(await readFile4(file2)) !== hash2)
|
|
26556
26564
|
fail("release_integrity", "Release asset integrity check failed.");
|
|
@@ -26559,7 +26567,7 @@ async function release2(requested = VERSION, base = dirname2(fileURLToPath(impor
|
|
|
26559
26567
|
directory,
|
|
26560
26568
|
manifest: manifest2,
|
|
26561
26569
|
config: JSON.parse(
|
|
26562
|
-
await readFile4(
|
|
26570
|
+
await readFile4(join2(directory, "wrangler.json"), "utf8")
|
|
26563
26571
|
)
|
|
26564
26572
|
};
|
|
26565
26573
|
}
|
|
@@ -26816,7 +26824,7 @@ async function whileWarming(run, sleep = delay3, report = (line) => process.stde
|
|
|
26816
26824
|
|
|
26817
26825
|
// src/installation.ts
|
|
26818
26826
|
import { cp, writeFile as writeFile3 } from "node:fs/promises";
|
|
26819
|
-
import { join as
|
|
26827
|
+
import { join as join3 } from "node:path";
|
|
26820
26828
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
26821
26829
|
async function advance(ctx, journal, phase, patch = {}) {
|
|
26822
26830
|
const fields = journal;
|
|
@@ -26843,9 +26851,9 @@ function selectedInstallation(ctx) {
|
|
|
26843
26851
|
};
|
|
26844
26852
|
}
|
|
26845
26853
|
async function configFile(ctx, journal, artifact) {
|
|
26846
|
-
const directory =
|
|
26854
|
+
const directory = join3(ctx.store.directory, "deployments", journal.id);
|
|
26847
26855
|
await protectedDirectory(directory);
|
|
26848
|
-
await cp(artifact.directory,
|
|
26856
|
+
await cp(artifact.directory, join3(directory, "release"), { recursive: true });
|
|
26849
26857
|
const config2 = {
|
|
26850
26858
|
...artifact.config,
|
|
26851
26859
|
name: journal.name,
|
|
@@ -26873,7 +26881,7 @@ async function configFile(ctx, journal, artifact) {
|
|
|
26873
26881
|
}))
|
|
26874
26882
|
} : {}
|
|
26875
26883
|
};
|
|
26876
|
-
const path =
|
|
26884
|
+
const path = join3(directory, "wrangler.json");
|
|
26877
26885
|
await writeFile3(path, JSON.stringify(config2, null, 2), { mode: 384 });
|
|
26878
26886
|
return { path, directory, config: config2 };
|
|
26879
26887
|
}
|
|
@@ -27220,7 +27228,7 @@ async function install(ctx, cf, journal, artifact, url2, domain2) {
|
|
|
27220
27228
|
// the account is this CLI's however soon anyone else finds the address.
|
|
27221
27229
|
CLI_BOOTSTRAP_TOKEN_DIGEST: createHash4("sha256").update(journal.bootstrap.token).digest("hex")
|
|
27222
27230
|
};
|
|
27223
|
-
const secretPath =
|
|
27231
|
+
const secretPath = join4(file2.directory, "secrets.json");
|
|
27224
27232
|
await writeFile4(secretPath, JSON.stringify(secrets), {
|
|
27225
27233
|
mode: 384
|
|
27226
27234
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxceem/agw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Manage App AI Gateway from a terminal or coding agent: providers, iOS and server apps, usage, and self-hosted deployment on Cloudflare",
|
|
6
6
|
"keywords": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"bugs": "https://github.com/maxceem/app-ai-gateway/issues",
|
|
28
28
|
"upgradeFrom": [
|
|
29
|
+
"0.14.0",
|
|
29
30
|
"0.13.1",
|
|
30
31
|
"0.13.0",
|
|
31
32
|
"0.12.1",
|