@apilift/cli 1.8.13-dev.1794684430.04833e90000e35cfd2a0edcc1cc8a4ddcad7cebc → 1.8.14
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/apilift-capture-server.js +63 -21
- package/dist/apilift-collector.js +790 -31
- package/dist/apilift-native-host.js +1188 -109
- package/dist/apilift.js +8582 -10701
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/skills/discover/SKILL.md +23 -19
- package/dist/plugin/skills/discover/agents/openai.yaml +1 -1
- package/dist/plugin/skills/discover/references/browser-capture.md +9 -7
- package/dist/plugin/skills/discover/references/documented-api.md +10 -4
- package/dist/plugin/skills/discover/references/file-actions.md +19 -0
- package/dist/plugin/skills/discover/references/html-forms-navigation.md +11 -0
- package/dist/plugin/skills/discover/references/metadata.md +4 -4
- package/dist/plugin/skills/discover/references/operation-contract.md +77 -65
- package/dist/plugin/skills/discover/references/recovery.md +3 -3
- package/dist/plugin/skills/use/SKILL.md +21 -7
- package/package.json +2 -2
- package/dist/plugin/skills/discover/references/api-plan.md +0 -77
- package/dist/plugin/skills/discover/references/api-reads.md +0 -68
|
@@ -19755,7 +19755,7 @@ var captureEntry = external_exports.strictObject({
|
|
|
19755
19755
|
target: external_exports.strictObject({ tabId: external_exports.number().int().positive(), sessionId: external_exports.string().nullable(), targetId: external_exports.string().nullable(), targetType: external_exports.string().nullable(), frameId: external_exports.string().nullable(), isTopFrame: external_exports.boolean(), loaderId: external_exports.string().nullable(), documentURL: external_exports.string(), redirectHop: external_exports.number().int().nonnegative().optional() })
|
|
19756
19756
|
});
|
|
19757
19757
|
var nativeRequestSchemas = {
|
|
19758
|
-
hello: request("hello", external_exports.strictObject({ extensionId: text, extensionVersion: text, buildFingerprint: text, capabilities: external_exports.array(text) })),
|
|
19758
|
+
hello: request("hello", external_exports.strictObject({ extensionId: text, extensionVersion: text, buildFingerprint: text.optional(), capabilities: external_exports.array(text) })),
|
|
19759
19759
|
scopes: request("scopes", empty),
|
|
19760
19760
|
candidates: request("candidates", external_exports.strictObject({ clientId: id, origin: url2, candidates: external_exports.array(candidate).max(32), claimError: external_exports.string().min(1).max(400).optional() }), true),
|
|
19761
19761
|
claim: request("claim", external_exports.strictObject({ ...lease, clientId: id, extensionId: text, extensionVersion: text, capabilities: external_exports.array(text), tabId: external_exports.number().int().positive(), tabSelector: id, url: url2, origin: url2 }), true),
|
|
@@ -20043,9 +20043,12 @@ var CaptureStore = class {
|
|
|
20043
20043
|
if (!this.db.prepare("PRAGMA table_info(blobs)").all().some((column) => column.name === "stored_bytes")) this.db.exec("ALTER TABLE blobs ADD COLUMN stored_bytes INTEGER");
|
|
20044
20044
|
if (!hadCandidates) this.db.exec(`INSERT INTO capture_candidates (scope_id,seq,capture_id,entry_json) SELECT e.scope_id,g.first_seq,g.capture_id,e.entry_json FROM capture_entries e JOIN (SELECT scope_id,COALESCE(json_extract(entry_json,'$.captureId'),CAST(seq AS TEXT)) AS capture_id,MIN(seq) AS first_seq,MAX(seq) AS last_seq FROM capture_entries GROUP BY scope_id,capture_id) g ON e.scope_id=g.scope_id AND e.seq=g.last_seq`);
|
|
20045
20045
|
const columns = this.db.prepare("PRAGMA table_info(scopes)").all();
|
|
20046
|
+
if (!columns.some((column) => column.name === "candidates_reported")) this.db.exec("ALTER TABLE scopes ADD COLUMN candidates_reported INTEGER NOT NULL DEFAULT 0");
|
|
20046
20047
|
if (!columns.some((column) => column.name === "owner_session")) this.db.exec("ALTER TABLE scopes ADD COLUMN owner_session TEXT");
|
|
20047
|
-
|
|
20048
|
-
if (!
|
|
20048
|
+
const bridgeColumns = this.db.prepare("PRAGMA table_info(bridge_status)").all();
|
|
20049
|
+
if (!bridgeColumns.some((column) => column.name === "sequence")) this.db.exec("ALTER TABLE bridge_status ADD COLUMN sequence INTEGER NOT NULL DEFAULT 0");
|
|
20050
|
+
if (!bridgeColumns.some((column) => column.name === "capabilities_json")) this.db.exec("ALTER TABLE bridge_status ADD COLUMN capabilities_json TEXT NOT NULL DEFAULT '[]'");
|
|
20051
|
+
if (!bridgeColumns.some((column) => column.name === "extension_build_fingerprint")) this.db.exec("ALTER TABLE bridge_status ADD COLUMN extension_build_fingerprint TEXT");
|
|
20049
20052
|
if (!columns.some((column) => column.name === "start_url")) this.db.exec("ALTER TABLE scopes ADD COLUMN start_url TEXT");
|
|
20050
20053
|
if (!columns.some((column) => column.name === "binding_mode")) this.db.exec("ALTER TABLE scopes ADD COLUMN binding_mode TEXT");
|
|
20051
20054
|
if (!columns.some((column) => column.name === "retained_at")) this.db.exec("ALTER TABLE scopes ADD COLUMN retained_at REAL");
|
|
@@ -20168,8 +20171,11 @@ var CaptureStore = class {
|
|
|
20168
20171
|
return rows.map((row) => ({ kind: row.kind, id: String(row.id), pageOrigin: String(row.page_origin), ...row.lease_id ? { leaseId: String(row.lease_id), ackThrough: Number(row.ack_through) } : {}, ...row.tab_selector ? { tabSelector: String(row.tab_selector) } : {}, ...row.start_url ? { startUrl: String(row.start_url) } : {}, ...row.binding_mode ? { bindingMode: row.binding_mode } : {}, expiresAt: new Date(Number(row.expires_at)).toISOString(), activatedAt: Number(row.activated_at), ...row.window_json ? { window: readJson(row.window_json) } : {}, ...row.owner_session ? { ownerSession: String(row.owner_session) } : {} }));
|
|
20169
20172
|
}
|
|
20170
20173
|
candidates(scopeId) {
|
|
20174
|
+
return this.candidateSnapshot(scopeId).candidates;
|
|
20175
|
+
}
|
|
20176
|
+
candidateSnapshot(scopeId) {
|
|
20171
20177
|
const row = this.row(scopeId);
|
|
20172
|
-
return readJson(row.candidates_json);
|
|
20178
|
+
return { reported: Boolean(row.candidates_reported), candidates: readJson(row.candidates_json) };
|
|
20173
20179
|
}
|
|
20174
20180
|
blob(scopeId, digest) {
|
|
20175
20181
|
const scope2 = this.row(scopeId);
|
|
@@ -20227,8 +20233,11 @@ var CaptureStore = class {
|
|
|
20227
20233
|
wakeBridge() {
|
|
20228
20234
|
this.emit();
|
|
20229
20235
|
}
|
|
20230
|
-
bridgeReady(version2, capabilities = []) {
|
|
20231
|
-
|
|
20236
|
+
bridgeReady(version2, capabilities = [], extensionBuildFingerprint) {
|
|
20237
|
+
const fingerprint = extensionBuildFingerprint && /^[a-z0-9._-]{1,128}$/iu.test(extensionBuildFingerprint) ? extensionBuildFingerprint : null;
|
|
20238
|
+
this.db.prepare(`INSERT INTO bridge_status(id,version,updated_at,capabilities_json,extension_build_fingerprint) VALUES(1,?,?,?,?)
|
|
20239
|
+
ON CONFLICT(id) DO UPDATE SET version=excluded.version,updated_at=excluded.updated_at,capabilities_json=excluded.capabilities_json,
|
|
20240
|
+
extension_build_fingerprint=excluded.extension_build_fingerprint,sequence=bridge_status.sequence+1`).run(version2, this.clock(), json3(capabilities), fingerprint);
|
|
20232
20241
|
}
|
|
20233
20242
|
bridgeCapabilities() {
|
|
20234
20243
|
const row = this.db.prepare("SELECT capabilities_json FROM bridge_status WHERE id=1 AND updated_at>?").get(this.clock() - 6e4);
|
|
@@ -20262,8 +20271,8 @@ var CaptureStore = class {
|
|
|
20262
20271
|
if (request2.payload.origin !== row.page_origin) throw new CaptureError("origin-mismatch", "Candidate page origin does not match the scope");
|
|
20263
20272
|
const candidates = request2.payload.candidates;
|
|
20264
20273
|
const encoded = json3(candidates);
|
|
20265
|
-
if (encoded === row.candidates_json) return {};
|
|
20266
|
-
this.db.prepare("UPDATE scopes SET candidates_json
|
|
20274
|
+
if (encoded === row.candidates_json && row.candidates_reported) return {};
|
|
20275
|
+
this.db.prepare("UPDATE scopes SET candidates_json=?,candidates_reported=1 WHERE id=?").run(encoded, scopeId);
|
|
20267
20276
|
this.emit();
|
|
20268
20277
|
return {};
|
|
20269
20278
|
}
|
|
@@ -20449,6 +20458,15 @@ async function startCaptureServer(options) {
|
|
|
20449
20458
|
await mkdir(root, { recursive: true, mode: 448 });
|
|
20450
20459
|
const store = new CaptureStore(root, options.clock, options.alive);
|
|
20451
20460
|
const token = randomBytes(32).toString("base64url");
|
|
20461
|
+
const setupLinks = /* @__PURE__ */ new Map();
|
|
20462
|
+
const clock = options.clock ?? Date.now;
|
|
20463
|
+
const setupDestination = `${options.siteOrigin ?? "https://apilift.dev"}/dashboard/credentials/setup#`;
|
|
20464
|
+
let closed = false;
|
|
20465
|
+
function active() {
|
|
20466
|
+
const now = clock();
|
|
20467
|
+
for (const [ref, link] of setupLinks) if (link.expiresAt <= now) setupLinks.delete(ref);
|
|
20468
|
+
return store.active() || setupLinks.size > 0;
|
|
20469
|
+
}
|
|
20452
20470
|
let lastActiveAt = Date.now();
|
|
20453
20471
|
async function untilChanged(read, ready, waitMs) {
|
|
20454
20472
|
const deadline = Date.now() + Math.max(0, Math.min(25e3, Number.isFinite(waitMs) ? waitMs : 0));
|
|
@@ -20461,6 +20479,15 @@ async function startCaptureServer(options) {
|
|
|
20461
20479
|
}
|
|
20462
20480
|
const server = createServer(async (request2, response) => {
|
|
20463
20481
|
try {
|
|
20482
|
+
if (request2.method === "GET" && request2.url?.startsWith("/credential-setup/")) {
|
|
20483
|
+
const ref = /^\/credential-setup\/([A-Za-z0-9_-]{22})$/.exec(request2.url)?.[1];
|
|
20484
|
+
const link = ref && request2.headers.host === `127.0.0.1:${request2.socket.localPort}` ? setupLinks.get(ref) : void 0;
|
|
20485
|
+
const headers = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer" };
|
|
20486
|
+
if (link && link.expiresAt > clock()) response.writeHead(303, { ...headers, Location: link.destination });
|
|
20487
|
+
else response.writeHead(404, headers);
|
|
20488
|
+
response.end();
|
|
20489
|
+
return;
|
|
20490
|
+
}
|
|
20464
20491
|
if (!equalToken(request2.headers.authorization?.replace(/^Bearer /, "") ?? "", token)) {
|
|
20465
20492
|
send(response, 401, { error: { code: "unauthorized", message: "Bearer token required" } });
|
|
20466
20493
|
return;
|
|
@@ -20468,7 +20495,7 @@ async function startCaptureServer(options) {
|
|
|
20468
20495
|
const url3 = new URL(request2.url ?? "/", "http://127.0.0.1");
|
|
20469
20496
|
const path = url3.pathname;
|
|
20470
20497
|
if (path === "/health" && request2.method === "GET") {
|
|
20471
|
-
send(response, 200, { ok: true, protocol: "apilift.capture/v1", version: options.version, active:
|
|
20498
|
+
send(response, 200, { ok: true, protocol: "apilift.capture/v1", version: options.version, active: active() });
|
|
20472
20499
|
return;
|
|
20473
20500
|
}
|
|
20474
20501
|
if (path === "/changes" && request2.method === "GET") {
|
|
@@ -20489,13 +20516,20 @@ async function startCaptureServer(options) {
|
|
|
20489
20516
|
if (path === "/bridge/ready" && request2.method === "POST") {
|
|
20490
20517
|
const body2 = object2(await readBody(request2));
|
|
20491
20518
|
if (typeof body2.version !== "string" || body2.capabilities !== void 0 && (!Array.isArray(body2.capabilities) || body2.capabilities.some((value) => typeof value !== "string"))) throw new CaptureError("invalid-bridge-version", "Native host version and supported capabilities are required");
|
|
20492
|
-
|
|
20519
|
+
const fingerprint = typeof body2.extensionBuildFingerprint === "string" ? body2.extensionBuildFingerprint : void 0;
|
|
20520
|
+
store.bridgeReady(body2.version, body2.capabilities, fingerprint);
|
|
20493
20521
|
send(response, 200, { ok: true });
|
|
20494
20522
|
return;
|
|
20495
20523
|
}
|
|
20496
20524
|
if (path === "/scope/candidates" && request2.method === "GET") {
|
|
20497
|
-
const
|
|
20498
|
-
|
|
20525
|
+
const scopeId = url3.searchParams.get("id") ?? "";
|
|
20526
|
+
const reportEmpty = url3.searchParams.get("reportEmpty") === "1";
|
|
20527
|
+
const snapshot = await untilChanged(
|
|
20528
|
+
() => store.candidateSnapshot(scopeId),
|
|
20529
|
+
(value) => value.candidates.length > 0 || reportEmpty && value.reported,
|
|
20530
|
+
Number(url3.searchParams.get("waitMs") ?? 0)
|
|
20531
|
+
);
|
|
20532
|
+
send(response, 200, reportEmpty ? snapshot : { candidates: snapshot.candidates });
|
|
20499
20533
|
return;
|
|
20500
20534
|
}
|
|
20501
20535
|
if (path === "/scope/entry" && request2.method === "GET") {
|
|
@@ -20526,6 +20560,18 @@ async function startCaptureServer(options) {
|
|
|
20526
20560
|
return;
|
|
20527
20561
|
}
|
|
20528
20562
|
const body = object2(await readBody(request2, path === "/job/enqueue" ? 24 * 1024 * 1024 : maxBody));
|
|
20563
|
+
if (path === "/credential-setup") {
|
|
20564
|
+
if (closed) throw new CaptureError("capture-server-unavailable", "The local process is restarting. Retry credentials add");
|
|
20565
|
+
const { destination, expiresAt } = body;
|
|
20566
|
+
const now = clock();
|
|
20567
|
+
if (typeof destination !== "string" || !destination.startsWith(setupDestination) || !/^[A-Za-z0-9_-]+$/.test(destination.slice(setupDestination.length)) || typeof expiresAt !== "number" || !Number.isSafeInteger(expiresAt) || expiresAt <= now || expiresAt > now + 30 * 6e4) {
|
|
20568
|
+
throw new CaptureError("invalid-credential-setup", "Credential setup link does not match this installation's dashboard or expiry");
|
|
20569
|
+
}
|
|
20570
|
+
const ref = randomBytes(16).toString("base64url");
|
|
20571
|
+
setupLinks.set(ref, { destination, expiresAt });
|
|
20572
|
+
send(response, 200, { ref });
|
|
20573
|
+
return;
|
|
20574
|
+
}
|
|
20529
20575
|
if (path === "/scope/open") {
|
|
20530
20576
|
send(response, 200, store.openScope(body));
|
|
20531
20577
|
lastActiveAt = Date.now();
|
|
@@ -20553,11 +20599,9 @@ async function startCaptureServer(options) {
|
|
|
20553
20599
|
return;
|
|
20554
20600
|
}
|
|
20555
20601
|
if (path === "/retire") {
|
|
20556
|
-
if (
|
|
20602
|
+
if (active()) throw new CaptureError("capture-server-busy", "Capture server has active work");
|
|
20557
20603
|
send(response, 200, { ok: true });
|
|
20558
|
-
|
|
20559
|
-
void close().then(options.onRetire);
|
|
20560
|
-
});
|
|
20604
|
+
void close().then(options.onRetire);
|
|
20561
20605
|
return;
|
|
20562
20606
|
}
|
|
20563
20607
|
if (path === "/native") {
|
|
@@ -20585,11 +20629,9 @@ async function startCaptureServer(options) {
|
|
|
20585
20629
|
await writeFile(temp, JSON.stringify(receipt), { mode: 384 });
|
|
20586
20630
|
await chmod(temp, 384);
|
|
20587
20631
|
await rename(temp, receiptPath);
|
|
20588
|
-
let closed = false;
|
|
20589
20632
|
const timer = setInterval(() => {
|
|
20590
|
-
if (
|
|
20591
|
-
|
|
20592
|
-
} else if (store.active()) lastActiveAt = Date.now();
|
|
20633
|
+
if (active()) lastActiveAt = Date.now();
|
|
20634
|
+
else if (Date.now() - lastActiveAt >= (options.idleMs ?? 6e5)) void close().then(options.onRetire);
|
|
20593
20635
|
}, 3e4);
|
|
20594
20636
|
timer.unref();
|
|
20595
20637
|
async function close() {
|
|
@@ -20609,6 +20651,6 @@ async function startCaptureServer(options) {
|
|
|
20609
20651
|
|
|
20610
20652
|
// src/bin/capture-server.ts
|
|
20611
20653
|
enableCompileCache();
|
|
20612
|
-
await startCaptureServer({ root: dataRoot(process.env), version: cliVersion, onRetire: () => {
|
|
20654
|
+
await startCaptureServer({ root: dataRoot(process.env), version: cliVersion, siteOrigin: new URL(process.env.APILIFT_URL || "https://apilift.dev").origin, onRetire: () => {
|
|
20613
20655
|
process.exitCode = 0;
|
|
20614
20656
|
} });
|