@apilift/cli 1.9.2 → 1.10.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/apilift-collector.js +226 -119
- package/dist/apilift-native-host.js +128 -68
- package/dist/apilift-session-audit.js +3 -0
- package/dist/apilift.js +1490 -1236
- 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 +3 -1
- package/dist/plugin/skills/use/SKILL.md +3 -1
- package/package.json +2 -2
package/dist/apilift.js
CHANGED
|
@@ -83,136 +83,6 @@ var init_session_capture = __esm({
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
// src/execution-reports.ts
|
|
87
|
-
async function flushExecutionReports(api, state, budgetMs = 1e4) {
|
|
88
|
-
const pending = state.pendingExecutionReports();
|
|
89
|
-
if (!pending.length) return;
|
|
90
|
-
const controller = new AbortController();
|
|
91
|
-
let timer;
|
|
92
|
-
try {
|
|
93
|
-
const acknowledgment = await Promise.race([
|
|
94
|
-
api.call("postExecutions", { body: { reports: pending.map((item) => item.report) }, signal: controller.signal }),
|
|
95
|
-
new Promise((_, reject) => {
|
|
96
|
-
timer = setTimeout(() => {
|
|
97
|
-
controller.abort();
|
|
98
|
-
reject(new Error("Report delivery deferred"));
|
|
99
|
-
}, budgetMs);
|
|
100
|
-
})
|
|
101
|
-
]);
|
|
102
|
-
state.acknowledgeExecutionReports(acknowledgment.results.map((item) => item.id));
|
|
103
|
-
} catch {
|
|
104
|
-
} finally {
|
|
105
|
-
clearTimeout(timer);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
var init_execution_reports = __esm({
|
|
109
|
-
"src/execution-reports.ts"() {
|
|
110
|
-
"use strict";
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// src/commands/feedback.ts
|
|
115
|
-
function prepare(state) {
|
|
116
|
-
state.db.exec("CREATE TABLE IF NOT EXISTS consumer_execution_reference (id TEXT PRIMARY KEY, installation_id TEXT NOT NULL, session_id TEXT NOT NULL, app_id TEXT NOT NULL, app_slug TEXT NOT NULL, action_name TEXT NOT NULL, successful INTEGER NOT NULL)");
|
|
117
|
-
}
|
|
118
|
-
function rememberExecution(state, session, input2) {
|
|
119
|
-
prepare(state);
|
|
120
|
-
const installation = state.installation()?.id;
|
|
121
|
-
if (!installation) return;
|
|
122
|
-
state.db.prepare("INSERT OR IGNORE INTO consumer_execution_reference VALUES (?,?,?,?,?,?,?)").run(input2.id, installation, session.id, input2.appId, input2.appSlug, input2.actionName, Number(input2.successful));
|
|
123
|
-
state.db.prepare("DELETE FROM consumer_execution_reference WHERE installation_id=? AND session_id=? AND rowid NOT IN (SELECT rowid FROM consumer_execution_reference WHERE installation_id=? AND session_id=? ORDER BY rowid DESC LIMIT 64)").run(installation, session.id, installation, session.id);
|
|
124
|
-
}
|
|
125
|
-
async function handleFeedback(invocation, api, state, session) {
|
|
126
|
-
const fail6 = (stderr) => ({ stdout: "", stderr: stderr + "\n", exitCode: 2 });
|
|
127
|
-
if (!session || !invocation.flags.includes("incorrect")) return fail6("Use feedback <app> <action> --incorrect for an incorrect result from this worker\u2019s published execution.");
|
|
128
|
-
prepare(state);
|
|
129
|
-
const [app2, action] = invocation.positionals;
|
|
130
|
-
const explicit = invocation.options.execution;
|
|
131
|
-
const row = state.db.prepare("SELECT id,successful FROM consumer_execution_reference WHERE installation_id=? AND session_id=? AND (app_id=? OR app_slug=?) AND action_name=? AND (? IS NULL OR id=?) ORDER BY rowid DESC LIMIT 1").get(state.installation()?.id ?? "", session.id, app2, app2, action, explicit ?? null, explicit ?? null);
|
|
132
|
-
if (!row) return fail6("No matching retained execution in this worker. Supply --execution with a retained invocation ID; do not rerun a write to report it.");
|
|
133
|
-
if (!row.successful) return fail6("This execution already reported a runtime failure. No additional semantic feedback is needed.");
|
|
134
|
-
await flushExecutionReports(api, state);
|
|
135
|
-
await api.call("executionFeedback", { params: { executionId: row.id }, body: { kind: "semantic-incorrect" } });
|
|
136
|
-
return { stdout: `Recorded incorrect result for ${action}. No app request was sent.
|
|
137
|
-
`, stderr: "", exitCode: 0 };
|
|
138
|
-
}
|
|
139
|
-
var init_feedback = __esm({
|
|
140
|
-
"src/commands/feedback.ts"() {
|
|
141
|
-
"use strict";
|
|
142
|
-
init_execution_reports();
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// src/usage/receipts.ts
|
|
147
|
-
function formatReceipt(id2) {
|
|
148
|
-
return `[apilift receipt:${Buffer.from(id2.replaceAll("-", ""), "hex").toString("base64url")}]
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
var init_receipts = __esm({
|
|
152
|
-
"src/usage/receipts.ts"() {
|
|
153
|
-
"use strict";
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// src/capture-server/windows-owner.ts
|
|
158
|
-
import { Worker } from "node:worker_threads";
|
|
159
|
-
function windowsProcessStart(pid, isAlive) {
|
|
160
|
-
if (!worker) {
|
|
161
|
-
memory = new SharedArrayBuffer(24);
|
|
162
|
-
worker = new Worker(workerSource, { eval: true, workerData: { memory, script } });
|
|
163
|
-
worker.on("error", () => {
|
|
164
|
-
});
|
|
165
|
-
worker.unref();
|
|
166
|
-
}
|
|
167
|
-
const state = new Int32Array(memory, 0, 4), value = new Float64Array(memory, 16, 1);
|
|
168
|
-
const deadline = performance.now() + 8e3;
|
|
169
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
170
|
-
if (!isAlive()) return null;
|
|
171
|
-
const remaining = deadline - performance.now();
|
|
172
|
-
if (remaining <= 0) break;
|
|
173
|
-
const id2 = ++sequence;
|
|
174
|
-
Atomics.store(state, 1, id2);
|
|
175
|
-
Atomics.store(state, 0, 1);
|
|
176
|
-
worker.postMessage({ id: id2, pid });
|
|
177
|
-
const result3 = Atomics.wait(state, 0, 1, Math.min(4e3, remaining));
|
|
178
|
-
const status = Atomics.load(state, 0);
|
|
179
|
-
if (status === 2) return Atomics.load(state, 2) === id2 && Number.isFinite(value[0]) && value[0] > 0 && isAlive() ? value[0] : null;
|
|
180
|
-
if (result3 !== "timed-out" || status !== 1) break;
|
|
181
|
-
}
|
|
182
|
-
void worker.terminate();
|
|
183
|
-
worker = void 0;
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
var script, workerSource, worker, memory, sequence;
|
|
187
|
-
var init_windows_owner = __esm({
|
|
188
|
-
"src/capture-server/windows-owner.ts"() {
|
|
189
|
-
"use strict";
|
|
190
|
-
script = `$ErrorActionPreference='Stop'; while ($null -ne ($line=[Console]::ReadLine())) { $parts=$line.Split('|'); try { $p=[System.Diagnostics.Process]::GetProcessById([int]$parts[1]); $stamp=([DateTimeOffset]$p.StartTime.ToUniversalTime()).ToUnixTimeMilliseconds(); $p.Dispose() } catch { $stamp=0 }; [Console]::WriteLine($parts[0]+'|'+$stamp); [Console]::Out.Flush() }`;
|
|
191
|
-
workerSource = `
|
|
192
|
-
const {workerData}=require('node:worker_threads');
|
|
193
|
-
const {spawn}=require('node:child_process');
|
|
194
|
-
const state=new Int32Array(workerData.memory,0,4), value=new Float64Array(workerData.memory,16,1);
|
|
195
|
-
const child=spawn('powershell.exe',['-NoLogo','-NoProfile','-NonInteractive','-Command',workerData.script],{windowsHide:true,stdio:['pipe','pipe','ignore']});
|
|
196
|
-
const fail=()=>{Atomics.store(state,0,3);Atomics.notify(state,0);};
|
|
197
|
-
child.on('error',fail);child.on('exit',fail);
|
|
198
|
-
let text='';
|
|
199
|
-
child.stdout.on('data',chunk=>{
|
|
200
|
-
text+=chunk.toString();
|
|
201
|
-
let end;
|
|
202
|
-
while((end=text.indexOf('\\n'))>=0){
|
|
203
|
-
const [id,stamp]=text.slice(0,end).trim().split('|').map(Number);text=text.slice(end+1);
|
|
204
|
-
if(id!==Atomics.load(state,1)||Atomics.load(state,0)!==1)continue;
|
|
205
|
-
value[0]=Number.isFinite(stamp)?stamp:0;Atomics.store(state,2,id);Atomics.store(state,0,2);Atomics.notify(state,0);
|
|
206
|
-
}
|
|
207
|
-
if(text.length>1024){child.kill();fail();}
|
|
208
|
-
});
|
|
209
|
-
const {parentPort}=require('node:worker_threads');
|
|
210
|
-
parentPort.on('message',({id,pid})=>{try{child.stdin.write(id+'|'+pid+'\\n');}catch{fail();}});
|
|
211
|
-
`;
|
|
212
|
-
sequence = 0;
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
86
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
217
87
|
var util_exports = {};
|
|
218
88
|
__export(util_exports, {
|
|
@@ -4709,7 +4579,7 @@ function isRef(value) {
|
|
|
4709
4579
|
function cloneIssues(issues) {
|
|
4710
4580
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4711
4581
|
}
|
|
4712
|
-
function isRecursive(inst, stack,
|
|
4582
|
+
function isRecursive(inst, stack, resolve17) {
|
|
4713
4583
|
const cached2 = recursive.get(inst);
|
|
4714
4584
|
if (cached2 !== void 0)
|
|
4715
4585
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4719,7 +4589,7 @@ function isRecursive(inst, stack, resolve16) {
|
|
|
4719
4589
|
let result3 = NONE;
|
|
4720
4590
|
const check2 = (child2) => {
|
|
4721
4591
|
if (result3 !== PROVEN && child2?._zod) {
|
|
4722
|
-
const answer = isRecursive(child2, stack,
|
|
4592
|
+
const answer = isRecursive(child2, stack, resolve17);
|
|
4723
4593
|
if (answer > result3)
|
|
4724
4594
|
result3 = answer;
|
|
4725
4595
|
}
|
|
@@ -4730,7 +4600,7 @@ function isRecursive(inst, stack, resolve16) {
|
|
|
4730
4600
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
4731
4601
|
if (spread && !desc.enumerable)
|
|
4732
4602
|
continue;
|
|
4733
|
-
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4603
|
+
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve17) : NONE;
|
|
4734
4604
|
if (child2 > answer)
|
|
4735
4605
|
answer = child2;
|
|
4736
4606
|
}
|
|
@@ -4794,7 +4664,7 @@ function isRecursive(inst, stack, resolve16) {
|
|
|
4794
4664
|
break;
|
|
4795
4665
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4796
4666
|
case "lazy": {
|
|
4797
|
-
const inner = def._cachedInner ?? (
|
|
4667
|
+
const inner = def._cachedInner ?? (resolve17 ? inst._zod.innerType : void 0);
|
|
4798
4668
|
merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4799
4669
|
break;
|
|
4800
4670
|
}
|
|
@@ -9157,8 +9027,8 @@ var capitalizeFirstCharacter, error33;
|
|
|
9157
9027
|
var init_lt = __esm({
|
|
9158
9028
|
"../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/lt.js"() {
|
|
9159
9029
|
init_util();
|
|
9160
|
-
capitalizeFirstCharacter = (
|
|
9161
|
-
return
|
|
9030
|
+
capitalizeFirstCharacter = (text5) => {
|
|
9031
|
+
return text5.charAt(0).toUpperCase() + text5.slice(1);
|
|
9162
9032
|
};
|
|
9163
9033
|
error33 = () => {
|
|
9164
9034
|
const Sizable = {
|
|
@@ -20572,501 +20442,6 @@ var init_zod = __esm({
|
|
|
20572
20442
|
}
|
|
20573
20443
|
});
|
|
20574
20444
|
|
|
20575
|
-
// ../../packages/protocol/dist/native.js
|
|
20576
|
-
function validateNativeFrameLength(byteLength, direction) {
|
|
20577
|
-
return Number.isInteger(byteLength) && byteLength >= 0 && byteLength <= (direction === "request" ? 512 * 1024 : 1024 * 1024);
|
|
20578
|
-
}
|
|
20579
|
-
var nativeProtocol, nativeOperationSchema, id, text, url2, hash2, json2, empty, scope, lease, scoped, base, request, requirement, credential, effect, candidate, bodyArtifact, inputChunk, preparedBinding, filePart, multipart, filePreparation, captureEntry, nativeRequestSchemas, requestUnion, nativeRequestSchema, identity, nativeHelloResultSchema, nativeScopesResultSchema, nativeCredentialStatusResultSchema, nativeJobSchema, claimResult, captureAck, blobAck, frozenWindow, nativeResultSchemas, nativeErrorSchema, nativeReplySchema, nativeAvailableSchema, nativeMessageSchema;
|
|
20580
|
-
var init_native = __esm({
|
|
20581
|
-
"../../packages/protocol/dist/native.js"() {
|
|
20582
|
-
"use strict";
|
|
20583
|
-
init_zod();
|
|
20584
|
-
nativeProtocol = "apilift.native/v1";
|
|
20585
|
-
nativeOperationSchema = external_exports.enum(["hello", "scopes", "candidates", "claim", "heartbeat", "permit", "window.open", "window.close", "capture.append", "blob.chunk", "jobs.poll", "jobs.body", "jobs.input", "jobs.deliver", "credentials.put", "credentials.status", "credentials.delete", "credentials.rename"]);
|
|
20586
|
-
id = external_exports.string().min(1).max(160);
|
|
20587
|
-
text = external_exports.string().min(1);
|
|
20588
|
-
url2 = external_exports.url().refine((value) => /^https?:\/\//.test(value), "Expected an http(s) URL");
|
|
20589
|
-
hash2 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
20590
|
-
json2 = external_exports.json();
|
|
20591
|
-
empty = external_exports.strictObject({});
|
|
20592
|
-
scope = external_exports.strictObject({ kind: external_exports.enum(["inspect", "execute", "capture"]), id });
|
|
20593
|
-
lease = { leaseId: id };
|
|
20594
|
-
scoped = { scope };
|
|
20595
|
-
base = { protocol: external_exports.literal(nativeProtocol), id };
|
|
20596
|
-
request = (operation2, payload, hasScope = false) => external_exports.strictObject({ ...base, ...hasScope ? scoped : {}, operation: external_exports.literal(operation2), payload });
|
|
20597
|
-
requirement = external_exports.strictObject({ name: text, header: text, prefix: external_exports.string().max(80).optional() });
|
|
20598
|
-
credential = { workspaceId: external_exports.uuid(), appId: external_exports.uuid(), appTitle: text, transportName: text, requirements: external_exports.array(requirement).max(16), draftId: external_exports.uuid().optional() };
|
|
20599
|
-
effect = external_exports.enum(["read", "create", "update", "delete"]);
|
|
20600
|
-
candidate = external_exports.strictObject({ selector: id, tabId: external_exports.number().int().positive(), active: external_exports.boolean(), title: external_exports.string().max(160) });
|
|
20601
|
-
bodyArtifact = external_exports.strictObject({ sha256: hash2, bytes: external_exports.number().int().nonnegative(), encoding: external_exports.literal("utf-8") });
|
|
20602
|
-
inputChunk = external_exports.strictObject({ offset: external_exports.number().int().nonnegative(), dataBase64: external_exports.string().max(240400), complete: external_exports.boolean() });
|
|
20603
|
-
preparedBinding = external_exports.strictObject({ $prepared: external_exports.string().max(2e3) });
|
|
20604
|
-
filePart = external_exports.strictObject({ sha256: hash2, bytes: external_exports.number().int().min(0).max(16 * 1024 * 1024), name: external_exports.string().min(1).max(180), contentType: external_exports.string().min(1).max(100) });
|
|
20605
|
-
multipart = external_exports.array(external_exports.union([external_exports.strictObject({ name: text, value: external_exports.union([external_exports.string().max(65536), external_exports.number(), external_exports.boolean(), preparedBinding]) }), external_exports.strictObject({ name: text, file: filePart })])).min(1).max(64);
|
|
20606
|
-
filePreparation = external_exports.strictObject({ resultPaths: external_exports.array(external_exports.string().max(512)).min(1).max(8).optional(), url: url2, headers: external_exports.record(external_exports.string(), external_exports.string()), response: external_exports.strictObject({ path: external_exports.string().optional(), fields: external_exports.record(external_exports.string(), external_exports.string()).optional() }), urlFrom: external_exports.string().optional(), query: external_exports.record(external_exports.string(), preparedBinding).optional(), headerBindings: external_exports.record(external_exports.string(), preparedBinding).optional() });
|
|
20607
|
-
captureEntry = external_exports.strictObject({
|
|
20608
|
-
captureId: id,
|
|
20609
|
-
transactionId: id,
|
|
20610
|
-
ts: external_exports.number(),
|
|
20611
|
-
label: text,
|
|
20612
|
-
captureOperation: external_exports.strictObject({ entity: text, operation: text, effect }).nullable().optional(),
|
|
20613
|
-
captureInputs: json2.optional(),
|
|
20614
|
-
capturePhase: text.optional(),
|
|
20615
|
-
page: external_exports.string().optional(),
|
|
20616
|
-
kind: text,
|
|
20617
|
-
method: text,
|
|
20618
|
-
url: external_exports.string(),
|
|
20619
|
-
reqHeaders: external_exports.record(external_exports.string(), external_exports.string()),
|
|
20620
|
-
reqBody: external_exports.string().nullable().optional(),
|
|
20621
|
-
reqBodyArtifact: bodyArtifact.optional(),
|
|
20622
|
-
status: external_exports.number().int().nullable(),
|
|
20623
|
-
resHeaders: external_exports.record(external_exports.string(), external_exports.string()),
|
|
20624
|
-
resBody: external_exports.string().nullable().optional(),
|
|
20625
|
-
resBodyArtifact: bodyArtifact.optional(),
|
|
20626
|
-
ms: external_exports.number().nullable(),
|
|
20627
|
-
error: external_exports.string().nullable(),
|
|
20628
|
-
pending: external_exports.boolean(),
|
|
20629
|
-
browserTiming: external_exports.strictObject({ started: external_exports.number().nullable(), finished: external_exports.number().nullable() }).optional(),
|
|
20630
|
-
recorderTiming: external_exports.strictObject({ admitted: external_exports.number(), processed: external_exports.number() }).optional(),
|
|
20631
|
-
reqBodyShape: external_exports.strictObject({ multipart: external_exports.array(external_exports.strictObject({ name: external_exports.string().max(128), type: external_exports.enum(["file", "string"]) })).max(64) }).optional(),
|
|
20632
|
-
reqBodyState: external_exports.string().optional(),
|
|
20633
|
-
resBodyState: external_exports.string().optional(),
|
|
20634
|
-
bodyUnavailable: external_exports.string().optional(),
|
|
20635
|
-
requestMaterialUnavailable: external_exports.string().optional(),
|
|
20636
|
-
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() })
|
|
20637
|
-
});
|
|
20638
|
-
nativeRequestSchemas = {
|
|
20639
|
-
hello: request("hello", external_exports.strictObject({ extensionId: text, extensionVersion: text, buildFingerprint: text.optional(), capabilities: external_exports.array(text) })),
|
|
20640
|
-
scopes: request("scopes", empty),
|
|
20641
|
-
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),
|
|
20642
|
-
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),
|
|
20643
|
-
heartbeat: request("heartbeat", external_exports.strictObject({ ...lease, clientId: id, extensionVersion: text, capabilities: external_exports.array(text), tabId: external_exports.number().int().positive().optional(), tabSelector: id.optional(), url: url2.optional(), origin: url2.optional(), walDepth: external_exports.number().int().nonnegative().optional(), attached: external_exports.boolean().optional(), detached: external_exports.boolean().optional(), gap: external_exports.string().optional(), lost: external_exports.boolean().optional() }), true),
|
|
20644
|
-
permit: request("permit", external_exports.strictObject({ ...lease, label: text.optional(), entity: text.optional(), operation: text.optional(), effect: effect.optional(), inputs: json2.optional(), phase: text.optional() }), true),
|
|
20645
|
-
"window.open": request("window.open", external_exports.strictObject({ ...lease, windowId: id, windowPermit: text, label: text, transactionId: id, captureOperation: external_exports.strictObject({ entity: text, operation: text, effect }).nullable().optional(), captureInputs: json2.optional(), capturePhase: text.optional(), settleMs: external_exports.number().int().nonnegative().optional(), sequenceBefore: external_exports.number().int().nonnegative().optional() }), true),
|
|
20646
|
-
"window.close": request("window.close", external_exports.strictObject({ ...lease, windowId: id, transactionId: id, finalSequence: external_exports.number().int().nonnegative(), stoppedAt: external_exports.number().nonnegative().optional(), captured: external_exports.number().int().nonnegative().optional(), outcome: external_exports.strictObject({ executionState: external_exports.enum(["not-dispatched", "dispatched", "unknown"]).optional(), error: external_exports.string().optional() }).optional() }), true),
|
|
20647
|
-
"capture.append": request("capture.append", external_exports.strictObject({ ...lease, seq: external_exports.number().int().nonnegative(), entries: external_exports.array(captureEntry).max(32) }), true),
|
|
20648
|
-
"blob.chunk": request("blob.chunk", external_exports.strictObject({ ...lease, recording: id.optional(), jobId: id.optional(), sha256: hash2, bytes: external_exports.number().int().nonnegative(), offset: external_exports.number().int().nonnegative(), dataBase64: external_exports.string(), chunkSha256: hash2 }), true),
|
|
20649
|
-
"jobs.poll": request("jobs.poll", external_exports.strictObject({ ...lease, waitMs: external_exports.number().int().min(0).max(25e3), capabilities: external_exports.array(text) }), true),
|
|
20650
|
-
"jobs.body": request("jobs.body", external_exports.strictObject({ ...lease, jobId: id, sha256: hash2, bytes: external_exports.number().int().nonnegative() }), true),
|
|
20651
|
-
"jobs.input": request("jobs.input", external_exports.strictObject({ ...lease, jobId: id, sha256: hash2, offset: external_exports.number().int().nonnegative() }), true),
|
|
20652
|
-
"jobs.deliver": request("jobs.deliver", external_exports.strictObject({ ...lease, jobId: id, result: json2 }), true),
|
|
20653
|
-
"credentials.put": request("credentials.put", external_exports.strictObject({ ...credential, name: text, fields: external_exports.record(external_exports.string(), text), sessionId: external_exports.string().min(1).max(256).regex(/^(?:codex|claude):\S+$/u).optional() })),
|
|
20654
|
-
"credentials.status": request("credentials.status", external_exports.strictObject(credential)),
|
|
20655
|
-
"credentials.delete": request("credentials.delete", external_exports.strictObject({ ...credential, credentialId: external_exports.uuid() })),
|
|
20656
|
-
"credentials.rename": request("credentials.rename", external_exports.strictObject({ ...credential, credentialId: external_exports.uuid(), name: text }))
|
|
20657
|
-
};
|
|
20658
|
-
requestUnion = external_exports.discriminatedUnion("operation", [nativeRequestSchemas.hello, nativeRequestSchemas.scopes, nativeRequestSchemas.candidates, nativeRequestSchemas.claim, nativeRequestSchemas.heartbeat, nativeRequestSchemas.permit, nativeRequestSchemas["window.open"], nativeRequestSchemas["window.close"], nativeRequestSchemas["capture.append"], nativeRequestSchemas["blob.chunk"], nativeRequestSchemas["jobs.poll"], nativeRequestSchemas["jobs.body"], nativeRequestSchemas["jobs.input"], nativeRequestSchemas["jobs.deliver"], nativeRequestSchemas["credentials.put"], nativeRequestSchemas["credentials.status"], nativeRequestSchemas["credentials.delete"], nativeRequestSchemas["credentials.rename"]]);
|
|
20659
|
-
nativeRequestSchema = requestUnion.superRefine((message2, context) => {
|
|
20660
|
-
if (!validateNativeFrameLength(new TextEncoder().encode(JSON.stringify(message2)).length, "request"))
|
|
20661
|
-
context.addIssue({ code: "custom", message: "Native request exceeds the 512 KiB limit" });
|
|
20662
|
-
if (message2.operation === "blob.chunk") {
|
|
20663
|
-
const encoded = message2.payload.dataBase64;
|
|
20664
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded) || atob(encoded).length > 176 * 1024)
|
|
20665
|
-
context.addIssue({ code: "custom", path: ["payload", "dataBase64"], message: "Blob chunk must be valid base64 of at most 176 KiB" });
|
|
20666
|
-
}
|
|
20667
|
-
});
|
|
20668
|
-
identity = external_exports.strictObject({ accountId: external_exports.uuid(), workspaceId: external_exports.uuid(), installationId: external_exports.uuid(), enabled: external_exports.boolean(), internal: external_exports.boolean(), environment: external_exports.enum(["production", "test", "disabled"]), projectKey: external_exports.string(), host: external_exports.string(), expiresAt: text });
|
|
20669
|
-
nativeHelloResultSchema = external_exports.strictObject({ hostVersion: text, hostBuildFingerprint: text, minimumHostVersion: text.optional(), minimumExtensionVersion: text, availableExtensionVersion: text, capabilities: external_exports.array(text), hostRestartRequired: external_exports.boolean(), identity: identity.optional() });
|
|
20670
|
-
nativeScopesResultSchema = external_exports.strictObject({ scopes: external_exports.array(external_exports.strictObject({ kind: external_exports.enum(["inspect", "execute", "capture"]), id, pageOrigin: url2, leaseId: id.optional(), tabSelector: id.optional(), startUrl: url2.optional(), bindingMode: external_exports.enum(["exact-existing-url", "installation-prefix"]).optional(), expiresAt: text.optional(), window: json2.optional(), ackThrough: external_exports.number().int().nonnegative().optional(), activatedAt: external_exports.number().optional() })), identity: identity.optional() });
|
|
20671
|
-
nativeCredentialStatusResultSchema = external_exports.strictObject({ status: external_exports.enum(["configured", "missing"]), credentials: external_exports.array(external_exports.strictObject({ id: external_exports.uuid(), name: text, fields: external_exports.array(text) })) });
|
|
20672
|
-
nativeJobSchema = external_exports.discriminatedUnion("kind", [
|
|
20673
|
-
external_exports.strictObject({ id, kind: external_exports.literal("replay"), effect, method: external_exports.enum(["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]), url: url2, headers: external_exports.record(external_exports.string(), external_exports.string()), body: json2.optional(), multipart: multipart.optional(), anonymous: external_exports.boolean().optional(), fileResponse: external_exports.boolean().optional(), filePreparation: filePreparation.optional(), pageOrigin: url2, allowedRequestOrigin: url2, timeoutMs: external_exports.number().int().positive(), manualRedirects: external_exports.boolean().optional(), contextBaseUrl: url2.optional(), frame: external_exports.strictObject({ selector: text, baseUrl: url2 }).optional(), credentialHeaderNames: external_exports.array(text).optional(), authRecipeDefinition: json2.optional(), authRecipeId: text.optional(), authRecipeHash: hash2.optional(), authRefresh: external_exports.boolean().optional(), semanticProvenance: external_exports.array(json2).optional() }),
|
|
20674
|
-
external_exports.strictObject({ id, kind: external_exports.literal("begin"), label: text, entity: text.optional(), operation: text.optional(), effect: effect.optional(), inputs: json2.optional(), phase: text.optional(), settleMs: external_exports.number().int().nonnegative().optional() }),
|
|
20675
|
-
external_exports.strictObject({ id, kind: external_exports.literal("stop"), windowId: id.optional() }),
|
|
20676
|
-
external_exports.strictObject({ id, kind: external_exports.literal("auth-probe"), captureId: id, field: text.optional(), scope: json2.optional() })
|
|
20677
|
-
]);
|
|
20678
|
-
claimResult = external_exports.strictObject({ ackThrough: external_exports.number().int().nonnegative().optional(), captureBatchMax: external_exports.number().int().min(1).max(32).optional() });
|
|
20679
|
-
captureAck = external_exports.strictObject({ ackThrough: external_exports.number().int().nonnegative(), discardCaptures: external_exports.array(id).optional(), discardRecording: id.optional(), freezeRequired: id.optional() });
|
|
20680
|
-
blobAck = external_exports.strictObject({ offset: external_exports.number().int().nonnegative(), complete: external_exports.boolean() });
|
|
20681
|
-
frozenWindow = external_exports.strictObject({ state: external_exports.literal("frozen"), boundaryConfirmed: external_exports.boolean(), transactionId: id, captured: external_exports.number().int().nonnegative().optional() });
|
|
20682
|
-
nativeResultSchemas = {
|
|
20683
|
-
hello: nativeHelloResultSchema,
|
|
20684
|
-
scopes: nativeScopesResultSchema,
|
|
20685
|
-
candidates: empty,
|
|
20686
|
-
claim: claimResult,
|
|
20687
|
-
heartbeat: claimResult,
|
|
20688
|
-
permit: external_exports.strictObject({ windowPermit: text, label: text.optional(), captureInputs: json2.optional(), capturePhase: text.optional() }),
|
|
20689
|
-
"window.open": empty,
|
|
20690
|
-
"window.close": frozenWindow,
|
|
20691
|
-
"capture.append": captureAck,
|
|
20692
|
-
"blob.chunk": blobAck,
|
|
20693
|
-
"jobs.poll": external_exports.union([nativeJobSchema, empty]),
|
|
20694
|
-
"jobs.body": bodyArtifact,
|
|
20695
|
-
"jobs.input": inputChunk,
|
|
20696
|
-
"jobs.deliver": empty,
|
|
20697
|
-
"credentials.put": nativeCredentialStatusResultSchema,
|
|
20698
|
-
"credentials.status": nativeCredentialStatusResultSchema,
|
|
20699
|
-
"credentials.delete": nativeCredentialStatusResultSchema,
|
|
20700
|
-
"credentials.rename": nativeCredentialStatusResultSchema
|
|
20701
|
-
};
|
|
20702
|
-
nativeErrorSchema = external_exports.strictObject({ code: text, message: text, exitCode: external_exports.number().int().optional(), next: external_exports.string().optional(), executionState: external_exports.enum(["not-dispatched", "dispatched", "unknown"]).optional() });
|
|
20703
|
-
nativeReplySchema = external_exports.discriminatedUnion("ok", [
|
|
20704
|
-
external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), id, ok: external_exports.literal(true), result: external_exports.union([nativeHelloResultSchema, nativeScopesResultSchema, nativeCredentialStatusResultSchema, nativeJobSchema, nativeResultSchemas.permit, nativeResultSchemas["capture.append"], claimResult, blobAck, frozenWindow, bodyArtifact, inputChunk, empty]) }),
|
|
20705
|
-
external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), id, ok: external_exports.literal(false), error: nativeErrorSchema })
|
|
20706
|
-
]).refine((message2) => validateNativeFrameLength(new TextEncoder().encode(JSON.stringify(message2)).length, "response"), "Native response exceeds the 1 MiB limit");
|
|
20707
|
-
nativeAvailableSchema = external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), operation: external_exports.literal("available"), result: external_exports.strictObject({ kind: external_exports.enum(["jobs", "scopes"]) }) });
|
|
20708
|
-
nativeMessageSchema = external_exports.union([nativeRequestSchema, nativeReplySchema, nativeAvailableSchema]);
|
|
20709
|
-
}
|
|
20710
|
-
});
|
|
20711
|
-
|
|
20712
|
-
// ../../packages/protocol/dist/dashboard.js
|
|
20713
|
-
var dashboardProtocol, requirementSchema, intentBase, localSessionId, configureIntent, changeIntent, dashboardMessageSchema, dashboardStatusReplySchema, dashboardConfigureReplySchema;
|
|
20714
|
-
var init_dashboard = __esm({
|
|
20715
|
-
"../../packages/protocol/dist/dashboard.js"() {
|
|
20716
|
-
"use strict";
|
|
20717
|
-
init_zod();
|
|
20718
|
-
dashboardProtocol = "apilift.dashboard/v1";
|
|
20719
|
-
requirementSchema = external_exports.object({
|
|
20720
|
-
name: external_exports.string().regex(/^[a-z][a-z0-9_-]{0,63}$/),
|
|
20721
|
-
header: external_exports.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
|
|
20722
|
-
prefix: external_exports.string().max(80).optional()
|
|
20723
|
-
}).strict();
|
|
20724
|
-
intentBase = external_exports.object({
|
|
20725
|
-
workspaceId: external_exports.uuid(),
|
|
20726
|
-
appId: external_exports.uuid(),
|
|
20727
|
-
appTitle: external_exports.string().min(1),
|
|
20728
|
-
transportName: external_exports.string().min(1),
|
|
20729
|
-
requirements: external_exports.array(requirementSchema).min(1).max(16),
|
|
20730
|
-
draftId: external_exports.uuid().optional()
|
|
20731
|
-
}).strict();
|
|
20732
|
-
localSessionId = external_exports.string().min(1).max(256).regex(/^(?:codex|claude):\S+$/u);
|
|
20733
|
-
configureIntent = intentBase.extend({ instructions: external_exports.string().min(1), sessionId: localSessionId.optional() });
|
|
20734
|
-
changeIntent = intentBase.extend({ credentialId: external_exports.uuid() });
|
|
20735
|
-
dashboardMessageSchema = external_exports.discriminatedUnion("operation", [
|
|
20736
|
-
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.configure"), intent: configureIntent }).strict(),
|
|
20737
|
-
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.status"), intent: intentBase }).strict(),
|
|
20738
|
-
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.delete"), intent: changeIntent }).strict(),
|
|
20739
|
-
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.rename"), intent: changeIntent.extend({ name: external_exports.string().min(1) }) }).strict()
|
|
20740
|
-
]);
|
|
20741
|
-
dashboardStatusReplySchema = external_exports.object({
|
|
20742
|
-
ok: external_exports.literal(true),
|
|
20743
|
-
status: external_exports.enum(["configured", "missing"]),
|
|
20744
|
-
credentials: external_exports.array(external_exports.object({ id: external_exports.uuid(), name: external_exports.string(), fields: external_exports.array(external_exports.string()) }).strict())
|
|
20745
|
-
}).strict();
|
|
20746
|
-
dashboardConfigureReplySchema = external_exports.object({ ok: external_exports.literal(true), status: external_exports.literal("prompt-opened") }).strict();
|
|
20747
|
-
}
|
|
20748
|
-
});
|
|
20749
|
-
|
|
20750
|
-
// ../../packages/protocol/dist/extension.js
|
|
20751
|
-
var extensionProtocol, extensionPageMessageSchema;
|
|
20752
|
-
var init_extension = __esm({
|
|
20753
|
-
"../../packages/protocol/dist/extension.js"() {
|
|
20754
|
-
"use strict";
|
|
20755
|
-
init_zod();
|
|
20756
|
-
extensionProtocol = "apilift.extension/v1";
|
|
20757
|
-
extensionPageMessageSchema = external_exports.discriminatedUnion("operation", [
|
|
20758
|
-
external_exports.object({
|
|
20759
|
-
protocol: external_exports.literal(extensionProtocol),
|
|
20760
|
-
operation: external_exports.literal("credential.store"),
|
|
20761
|
-
payload: external_exports.object({ intentId: external_exports.string().min(1), name: external_exports.string().min(1), fields: external_exports.record(external_exports.string(), external_exports.string()) }).strict()
|
|
20762
|
-
}).strict(),
|
|
20763
|
-
external_exports.object({
|
|
20764
|
-
protocol: external_exports.literal(extensionProtocol),
|
|
20765
|
-
operation: external_exports.literal("telemetry.control"),
|
|
20766
|
-
payload: external_exports.object({ stage: external_exports.enum(["popup_opened", "setup_link_clicked", "onboarding_opened", "credential_saved", "credential_failed"]) }).strict()
|
|
20767
|
-
}).strict()
|
|
20768
|
-
]);
|
|
20769
|
-
}
|
|
20770
|
-
});
|
|
20771
|
-
|
|
20772
|
-
// ../../packages/protocol/dist/multipart.js
|
|
20773
|
-
function parseMultipart(body, contentType) {
|
|
20774
|
-
const boundary = /(?:^|;)\s*boundary=(?:"([^"\r\n]+)"|([^;\s]+))/iu.exec(contentType)?.slice(1).find(Boolean);
|
|
20775
|
-
if (!boundary || boundary.length > 200 || /[\r\n]/u.test(boundary))
|
|
20776
|
-
throw new Error("Multipart boundary is unavailable");
|
|
20777
|
-
const marker = "--" + boundary, parts2 = [];
|
|
20778
|
-
if (!body.startsWith(marker + "\r\n"))
|
|
20779
|
-
throw new Error("Multipart body is incomplete");
|
|
20780
|
-
let at = marker.length + 2;
|
|
20781
|
-
for (; ; ) {
|
|
20782
|
-
const end2 = body.indexOf("\r\n\r\n", at);
|
|
20783
|
-
if (end2 < 0 || end2 - at > 8192)
|
|
20784
|
-
throw new Error("Multipart headers are incomplete");
|
|
20785
|
-
const headers = body.slice(at, end2).split("\r\n");
|
|
20786
|
-
if (headers.some((header2) => !/^content-(?:disposition|type|transfer-encoding):/iu.test(header2)) || headers.some((header2) => /^content-transfer-encoding:/iu.test(header2)))
|
|
20787
|
-
throw new Error("Multipart headers are unsupported");
|
|
20788
|
-
const dispositions = headers.filter((header2) => /^content-disposition:/iu.test(header2));
|
|
20789
|
-
if (dispositions.length !== 1 || !/^content-disposition:\s*form-data(?:;|$)/iu.test(dispositions[0]))
|
|
20790
|
-
throw new Error("Multipart disposition is unavailable");
|
|
20791
|
-
const disposition = dispositions[0], name = /(?:^|;)\s*name="((?:[^"\\\r\n]|\\["\\])*)"/iu.exec(disposition)?.[1]?.replace(/\\(["\\])/gu, "$1");
|
|
20792
|
-
if (!name || name.length > 128)
|
|
20793
|
-
throw new Error("Multipart name is unavailable");
|
|
20794
|
-
const file3 = /(?:^|;)\s*filename(?:\*)?=/iu.test(disposition);
|
|
20795
|
-
const next2 = body.indexOf("\r\n" + marker, end2 + 4);
|
|
20796
|
-
if (next2 < 0)
|
|
20797
|
-
throw new Error("Multipart body is incomplete");
|
|
20798
|
-
const value = body.slice(end2 + 4, next2);
|
|
20799
|
-
if (!file3 && new TextEncoder().encode(value).length > 65536)
|
|
20800
|
-
throw new Error("Multipart scalar exceeds 65536 bytes");
|
|
20801
|
-
parts2.push({ name, value: file3 ? "" : value, file: file3 });
|
|
20802
|
-
if (parts2.length > 64)
|
|
20803
|
-
throw new Error("Multipart body exceeds 64 parts");
|
|
20804
|
-
at = next2 + 2 + marker.length;
|
|
20805
|
-
if (body.slice(at) === "--" || body.slice(at) === "--\r\n")
|
|
20806
|
-
return { boundary, parts: parts2 };
|
|
20807
|
-
if (body.slice(at, at + 2) !== "\r\n")
|
|
20808
|
-
throw new Error("Multipart body is incomplete");
|
|
20809
|
-
at += 2;
|
|
20810
|
-
}
|
|
20811
|
-
}
|
|
20812
|
-
var init_multipart = __esm({
|
|
20813
|
-
"../../packages/protocol/dist/multipart.js"() {
|
|
20814
|
-
"use strict";
|
|
20815
|
-
}
|
|
20816
|
-
});
|
|
20817
|
-
|
|
20818
|
-
// ../../packages/protocol/dist/index.js
|
|
20819
|
-
var init_dist = __esm({
|
|
20820
|
-
"../../packages/protocol/dist/index.js"() {
|
|
20821
|
-
"use strict";
|
|
20822
|
-
init_native();
|
|
20823
|
-
init_dashboard();
|
|
20824
|
-
init_extension();
|
|
20825
|
-
init_multipart();
|
|
20826
|
-
}
|
|
20827
|
-
});
|
|
20828
|
-
|
|
20829
|
-
// src/capture-server/store.ts
|
|
20830
|
-
import { constants, mkdirSync, chmodSync, readFileSync, openSync, closeSync, readSync, writeSync, ftruncateSync, fsyncSync, statSync, rmSync as rmSync2 } from "node:fs";
|
|
20831
|
-
import { execFileSync } from "node:child_process";
|
|
20832
|
-
import { DatabaseSync } from "node:sqlite";
|
|
20833
|
-
function createOwnerVerifier(probe = {}) {
|
|
20834
|
-
const cached2 = /* @__PURE__ */ new Map();
|
|
20835
|
-
const alive = probe.alive ?? pidAlive, now = probe.now ?? Date.now;
|
|
20836
|
-
return (pid, startedAt, fresh = false) => {
|
|
20837
|
-
if (!Number.isInteger(pid) || pid <= 0 || !Number.isFinite(startedAt) || !alive(pid)) {
|
|
20838
|
-
cached2.delete(pid);
|
|
20839
|
-
return false;
|
|
20840
|
-
}
|
|
20841
|
-
if ((probe.platform ?? process.platform) === "linux") return inspectOwner(pid, startedAt, probe);
|
|
20842
|
-
const prior = cached2.get(pid), time3 = now();
|
|
20843
|
-
if (!fresh && prior && prior.startedAt === startedAt && time3 >= prior.checkedAt && time3 - prior.checkedAt < 2e3) return true;
|
|
20844
|
-
cached2.delete(pid);
|
|
20845
|
-
if (!inspectOwner(pid, startedAt, probe)) return false;
|
|
20846
|
-
if (cached2.size >= 256) cached2.delete(cached2.keys().next().value);
|
|
20847
|
-
cached2.set(pid, { startedAt, checkedAt: now() });
|
|
20848
|
-
return true;
|
|
20849
|
-
};
|
|
20850
|
-
}
|
|
20851
|
-
function ownerProcessAlive(pid, expectedStartedAt, probe) {
|
|
20852
|
-
return typeof probe === "object" ? inspectOwner(pid, expectedStartedAt, probe) : defaultOwnerVerifier(pid, expectedStartedAt, probe);
|
|
20853
|
-
}
|
|
20854
|
-
function inspectOwner(pid, expectedStartedAt, probe) {
|
|
20855
|
-
if (!Number.isInteger(pid) || pid <= 0 || !Number.isFinite(expectedStartedAt)) return false;
|
|
20856
|
-
const alive = probe.alive ?? pidAlive;
|
|
20857
|
-
const inspect2 = probe.inspect ?? inspectProcess;
|
|
20858
|
-
const platform4 = probe.platform ?? process.platform;
|
|
20859
|
-
const now = probe.now ?? Date.now;
|
|
20860
|
-
const started = now();
|
|
20861
|
-
const windows = platform4 === "win32";
|
|
20862
|
-
if (platform4 === "linux") {
|
|
20863
|
-
try {
|
|
20864
|
-
const read = probe.read ?? ((path2) => readFileSync(path2, "utf8"));
|
|
20865
|
-
const stat2 = read(`/proc/${pid}/stat`), fields = stat2.slice(stat2.lastIndexOf(")") + 2).trim().split(/\s+/u);
|
|
20866
|
-
if (["Z", "X"].includes(fields[0])) return false;
|
|
20867
|
-
const ticks = Number(fields[19]), boot = Number(/^btime (\d+)$/mu.exec(read("/proc/stat"))?.[1]);
|
|
20868
|
-
const hz = probe.inspect ? Number(inspect2("getconf", ["CLK_TCK"], 2e3)) : linuxClockTicks ??= Number(inspect2("getconf", ["CLK_TCK"], 2e3));
|
|
20869
|
-
const observed = boot * 1e3 + ticks * 1e3 / hz;
|
|
20870
|
-
return Number.isFinite(observed) && hz > 0 && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
20871
|
-
} catch {
|
|
20872
|
-
return false;
|
|
20873
|
-
}
|
|
20874
|
-
}
|
|
20875
|
-
if (windows && !probe.inspect) {
|
|
20876
|
-
const observed = windowsProcessStart(pid, () => alive(pid));
|
|
20877
|
-
return observed !== null && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
20878
|
-
}
|
|
20879
|
-
for (let attempt = 0; attempt < (windows ? 2 : 1); attempt++) {
|
|
20880
|
-
if (!alive(pid)) return false;
|
|
20881
|
-
const remaining = windows ? 8e3 - (now() - started) : 2e3;
|
|
20882
|
-
if (remaining <= 0) return false;
|
|
20883
|
-
try {
|
|
20884
|
-
const raw = windows ? inspect2("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().ToString('o')`], Math.min(4e3, remaining)) : inspect2("ps", ["-o", "lstart=", "-p", String(pid)], 2e3);
|
|
20885
|
-
const observed = Date.parse(windows ? raw.trim() : `${raw.trim()} UTC`);
|
|
20886
|
-
return Number.isFinite(observed) && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
20887
|
-
} catch (error62) {
|
|
20888
|
-
if (!windows || error62.code !== "ETIMEDOUT") return false;
|
|
20889
|
-
}
|
|
20890
|
-
}
|
|
20891
|
-
return false;
|
|
20892
|
-
}
|
|
20893
|
-
var pidAlive, inspectProcess, linuxClockTicks, defaultOwnerVerifier;
|
|
20894
|
-
var init_store = __esm({
|
|
20895
|
-
"src/capture-server/store.ts"() {
|
|
20896
|
-
"use strict";
|
|
20897
|
-
init_windows_owner();
|
|
20898
|
-
init_dist();
|
|
20899
|
-
pidAlive = (candidate2) => {
|
|
20900
|
-
try {
|
|
20901
|
-
process.kill(candidate2, 0);
|
|
20902
|
-
return true;
|
|
20903
|
-
} catch {
|
|
20904
|
-
return false;
|
|
20905
|
-
}
|
|
20906
|
-
};
|
|
20907
|
-
inspectProcess = (command6, args, timeout) => execFileSync(command6, args, { encoding: "utf8", timeout, windowsHide: true, env: { ...process.env, LC_ALL: "C", TZ: "UTC" }, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
20908
|
-
defaultOwnerVerifier = createOwnerVerifier();
|
|
20909
|
-
}
|
|
20910
|
-
});
|
|
20911
|
-
|
|
20912
|
-
// src/discovery/lock.ts
|
|
20913
|
-
import { createHash } from "node:crypto";
|
|
20914
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync as rmSync3, writeFileSync } from "node:fs";
|
|
20915
|
-
import { join as join2 } from "node:path";
|
|
20916
|
-
function lockDiscovery(root2, sessionId, purpose = "discovery") {
|
|
20917
|
-
const name = createHash("sha256").update(sessionId).digest("hex");
|
|
20918
|
-
const directory = join2(root2, "locks", `discovery-${name}`);
|
|
20919
|
-
mkdirSync2(join2(root2, "locks"), { recursive: true, mode: 448 });
|
|
20920
|
-
const owner = { pid: process.pid, startedAt: Date.now() - process.uptime() * 1e3 };
|
|
20921
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
20922
|
-
try {
|
|
20923
|
-
mkdirSync2(directory, { mode: 448 });
|
|
20924
|
-
writeFileSync(join2(directory, "owner.json"), JSON.stringify(owner), { flag: "wx", mode: 384 });
|
|
20925
|
-
return () => {
|
|
20926
|
-
rmSync3(directory, { recursive: true, force: true });
|
|
20927
|
-
};
|
|
20928
|
-
} catch (error62) {
|
|
20929
|
-
if (error62.code !== "EEXIST") throw error62;
|
|
20930
|
-
let held = null;
|
|
20931
|
-
try {
|
|
20932
|
-
held = JSON.parse(readFileSync2(join2(directory, "owner.json"), "utf8"));
|
|
20933
|
-
} catch {
|
|
20934
|
-
}
|
|
20935
|
-
if (!held || ownerProcessAlive(held.pid, held.startedAt)) throw new Error(`${purpose}-command-busy \u2014 This agent already has a command running; wait for it to finish, then retry`);
|
|
20936
|
-
rmSync3(directory, { recursive: true, force: true });
|
|
20937
|
-
}
|
|
20938
|
-
}
|
|
20939
|
-
throw new Error(`${purpose}-command-busy \u2014 Could not acquire the agent's command lock`);
|
|
20940
|
-
}
|
|
20941
|
-
var init_lock = __esm({
|
|
20942
|
-
"src/discovery/lock.ts"() {
|
|
20943
|
-
"use strict";
|
|
20944
|
-
init_store();
|
|
20945
|
-
}
|
|
20946
|
-
});
|
|
20947
|
-
|
|
20948
|
-
// src/version.ts
|
|
20949
|
-
import { readFileSync as readFileSync3 } from "node:fs";
|
|
20950
|
-
var cliVersion;
|
|
20951
|
-
var init_version = __esm({
|
|
20952
|
-
"src/version.ts"() {
|
|
20953
|
-
"use strict";
|
|
20954
|
-
cliVersion = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
20955
|
-
}
|
|
20956
|
-
});
|
|
20957
|
-
|
|
20958
|
-
// ../../packages/core/dist/analytics/index.js
|
|
20959
|
-
function safeSqlState(value) {
|
|
20960
|
-
return typeof value === "string" && sqlStates.has(value) ? value : void 0;
|
|
20961
|
-
}
|
|
20962
|
-
function normalizeRoute(route) {
|
|
20963
|
-
try {
|
|
20964
|
-
const parsed = new URL(route, "https://apilift.dev");
|
|
20965
|
-
return parsed.pathname.replace(/^\/dashboard\/apps\/[^/]+/, "/dashboard/apps/:app").replace(uuid3, ":id").replace(longId, ":id");
|
|
20966
|
-
} catch {
|
|
20967
|
-
return "/invalid";
|
|
20968
|
-
}
|
|
20969
|
-
}
|
|
20970
|
-
function scrubEventProperties(event, input2) {
|
|
20971
|
-
const allowed = eventProperties[event];
|
|
20972
|
-
const result3 = {};
|
|
20973
|
-
for (const [key2, value] of Object.entries(input2)) {
|
|
20974
|
-
if (!allowed.includes(key2))
|
|
20975
|
-
continue;
|
|
20976
|
-
if (key2 === "exception_code") {
|
|
20977
|
-
const code = safeSqlState(value);
|
|
20978
|
-
if (code)
|
|
20979
|
-
result3[key2] = code;
|
|
20980
|
-
continue;
|
|
20981
|
-
}
|
|
20982
|
-
const normalized = key2 === "route" && typeof value === "string" ? normalizeRoute(value) : value;
|
|
20983
|
-
if (typeof normalized === "boolean" || typeof normalized === "number" && Number.isFinite(normalized) || typeof normalized === "string" && safeString.test(normalized))
|
|
20984
|
-
result3[key2] = normalized;
|
|
20985
|
-
}
|
|
20986
|
-
return result3;
|
|
20987
|
-
}
|
|
20988
|
-
var correlation, operation, publication, eventProperties, safeString, uuid3, longId, sqlStates;
|
|
20989
|
-
var init_analytics = __esm({
|
|
20990
|
-
"../../packages/core/dist/analytics/index.js"() {
|
|
20991
|
-
"use strict";
|
|
20992
|
-
correlation = ["invocation_id", "execution_id", "agent_session_id", "task_id", "discovery_session_id"];
|
|
20993
|
-
operation = ["app_id", "action_id", "action_version", "transport", "outcome", "duration_ms", "http_status", "agent", "purpose", "dispatched", "code", "stage"];
|
|
20994
|
-
publication = ["app_id", "resource_kind", "resource_name", "resource_version", "executable", "removed"];
|
|
20995
|
-
eventProperties = {
|
|
20996
|
-
"$pageview": ["route"],
|
|
20997
|
-
navigation_clicked: ["route", "target"],
|
|
20998
|
-
pricing_viewed: ["route"],
|
|
20999
|
-
catalog_viewed: ["route"],
|
|
21000
|
-
app_page_viewed: ["route"],
|
|
21001
|
-
onboarding_entered: ["route"],
|
|
21002
|
-
broken_page_viewed: ["route"],
|
|
21003
|
-
authentication_started: ["source", "stage"],
|
|
21004
|
-
authentication_code_sent: ["source", "stage"],
|
|
21005
|
-
authentication_completed: ["source", "stage"],
|
|
21006
|
-
authentication_failed: ["source", "stage", "code"],
|
|
21007
|
-
onboarding_attempt_started: ["expires_at", "attempt_id", "agent", "stage", "outcome", "source", "target"],
|
|
21008
|
-
onboarding_stage_viewed: ["attempt_id", "agent", "stage", "outcome"],
|
|
21009
|
-
setup_prompt_copied: ["attempt_id", "agent", "stage", "source"],
|
|
21010
|
-
onboarding_next_action_selected: ["attempt_id", "agent", "target"],
|
|
21011
|
-
onboarding_failed: ["stage", "attempt_id", "code", "outcome", "duration_ms"],
|
|
21012
|
-
checkout_requested: ["plan", "interval", "stage", "source"],
|
|
21013
|
-
checkout_ui_changed: ["plan", "interval", "stage", "source"],
|
|
21014
|
-
billing_portal_requested: ["source"],
|
|
21015
|
-
paid_feature_viewed: ["code", "route"],
|
|
21016
|
-
paid_feature_upgrade_opened: ["code", "route"],
|
|
21017
|
-
account_created: [],
|
|
21018
|
-
account_deleted: [],
|
|
21019
|
-
agent_selected: ["agent", "attempt_id", "status"],
|
|
21020
|
-
device_authorization_changed: ["agent", "attempt_id", "status"],
|
|
21021
|
-
onboarding_stage_completed: ["stage", "active", "agent"],
|
|
21022
|
-
installation_readiness_changed: ["stage", "active", "agent"],
|
|
21023
|
-
app_made_public: ["app_id"],
|
|
21024
|
-
execution_finished: [...correlation, ...operation],
|
|
21025
|
-
activation_changed: ["activated"],
|
|
21026
|
-
execution_classified: [...correlation, ...operation, "revision", "execution_finished_at", "coverage", "time_coverage", "baseline_time_ms", "actual_time_ms", "time_difference_ms", "baseline_tokens", "actual_tokens", "token_difference", "provider", "model"],
|
|
21027
|
-
value_snapshot: ["saved_time_ms", "saved_tokens", "saved_value_microusd", "saved_time_ms_available", "saved_tokens_available", "saved_value_microusd_available"],
|
|
21028
|
-
trial_started: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
21029
|
-
trial_progress: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
21030
|
-
trial_expired: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
21031
|
-
trial_completed: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
21032
|
-
payment_completed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
21033
|
-
payment_status_changed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
21034
|
-
payment_failed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
21035
|
-
subscription_changed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
21036
|
-
payment_adjusted: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
21037
|
-
critical_failure: ["code", "count"],
|
|
21038
|
-
cli_command_started: ["invocation_id", "command", "agent", "started_at"],
|
|
21039
|
-
cli_command_finished: [...correlation, ...operation, "command", "exit_code", "platform", "started_at", "finished_at", "result_count", "fallback", "registry_retries", "broker_ms", "bridge_ms", "registry_ms", "binding_ms", "replay_ms", "app_ms", "proof_ms", "reporting_ms"],
|
|
21040
|
-
invocation_attributed: [...correlation, "revision", "attribution_status", "agent", "source_version"],
|
|
21041
|
-
task_observed: ["agent_session_id", "task_id", "agent", "started_at", "source_version"],
|
|
21042
|
-
task_finished: ["agent_session_id", "task_id", "agent", "status", "started_at", "finished_at", "duration_ms", "apilift_active_ms", "source_version"],
|
|
21043
|
-
discovery_session_started: ["discovery_session_id", "app_id", "started_at", "agent", "start_known"],
|
|
21044
|
-
discovery_session_closed: ["discovery_session_id", "app_id", "started_at", "finished_at", "duration_ms", "start_known"],
|
|
21045
|
-
discovery_resource_published: ["discovery_session_id", ...publication],
|
|
21046
|
-
resource_published: publication,
|
|
21047
|
-
telemetry_delivery_health: ["dropped_count"],
|
|
21048
|
-
setup_stage_changed: ["stage", "agent"],
|
|
21049
|
-
discovery_started: ["purpose", "agent"],
|
|
21050
|
-
discovery_finished: ["purpose", "outcome", "duration_ms", "agent"],
|
|
21051
|
-
client_exception: ["code"],
|
|
21052
|
-
native_host_connected: [],
|
|
21053
|
-
native_host_failure: ["code", "operation", "stage", "origin", "failure_count", "duration_ms"],
|
|
21054
|
-
native_host_recovered: ["operation", "stage", "origin", "failure_count", "duration_ms"],
|
|
21055
|
-
extension_installed: ["stage"],
|
|
21056
|
-
extension_connected: ["stage"],
|
|
21057
|
-
extension_disconnected: ["stage"],
|
|
21058
|
-
extension_failure: ["code"],
|
|
21059
|
-
extension_interaction: ["stage", "outcome"],
|
|
21060
|
-
credential_setup_finished: ["stage", "outcome", "code"],
|
|
21061
|
-
"$exception": ["route", "method", "exception_type", "exception_frames", "exception_handled", "exception_level", "exception_code"]
|
|
21062
|
-
};
|
|
21063
|
-
safeString = /^[a-zA-Z0-9_./:{} -]{1,160}$/;
|
|
21064
|
-
uuid3 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
21065
|
-
longId = /\b[a-zA-Z0-9_-]{24,}\b/g;
|
|
21066
|
-
sqlStates = new Set("08000 08001 08003 08004 08006 08007 08P01 22001 22003 22007 22008 22012 22018 22021 22023 22P02 23000 23502 23503 23505 23514 23P01 25006 25P02 28000 28P01 3D000 3F000 40001 40P01 42501 42601 42702 42703 42704 42804 42883 42P01 42P10 53300 53400 54000 54001 55000 55P03 57014 57P01 57P02 57P03 58000 58030 XX000 XX001 XX002".split(" "));
|
|
21067
|
-
}
|
|
21068
|
-
});
|
|
21069
|
-
|
|
21070
20445
|
// ../../packages/core/dist/api/errors.js
|
|
21071
20446
|
function cliExitForError(error62) {
|
|
21072
20447
|
return error62.code === "verification-incomplete" || error62.code === "verification-stale" ? 12 : categoryCliExit[error62.category];
|
|
@@ -21125,6 +20500,7 @@ var init_errors3 = __esm({
|
|
|
21125
20500
|
"publication-budget": "limit",
|
|
21126
20501
|
"publication-throttled": "limit",
|
|
21127
20502
|
"session-limit": "limit",
|
|
20503
|
+
"feedback-throttled": "limit",
|
|
21128
20504
|
"client-upgrade-required": "upgrade",
|
|
21129
20505
|
"backend-unavailable": "unavailable",
|
|
21130
20506
|
"storage-unavailable": "unavailable",
|
|
@@ -21537,11 +20913,11 @@ var require_codegen = __commonJS({
|
|
|
21537
20913
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
21538
20914
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
21539
20915
|
}
|
|
21540
|
-
optimizeNames(names3,
|
|
20916
|
+
optimizeNames(names3, constants5) {
|
|
21541
20917
|
if (!names3[this.name.str])
|
|
21542
20918
|
return;
|
|
21543
20919
|
if (this.rhs)
|
|
21544
|
-
this.rhs = optimizeExpr(this.rhs, names3,
|
|
20920
|
+
this.rhs = optimizeExpr(this.rhs, names3, constants5);
|
|
21545
20921
|
return this;
|
|
21546
20922
|
}
|
|
21547
20923
|
get names() {
|
|
@@ -21558,10 +20934,10 @@ var require_codegen = __commonJS({
|
|
|
21558
20934
|
render({ _n }) {
|
|
21559
20935
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
21560
20936
|
}
|
|
21561
|
-
optimizeNames(names3,
|
|
20937
|
+
optimizeNames(names3, constants5) {
|
|
21562
20938
|
if (this.lhs instanceof code_1.Name && !names3[this.lhs.str] && !this.sideEffects)
|
|
21563
20939
|
return;
|
|
21564
|
-
this.rhs = optimizeExpr(this.rhs, names3,
|
|
20940
|
+
this.rhs = optimizeExpr(this.rhs, names3, constants5);
|
|
21565
20941
|
return this;
|
|
21566
20942
|
}
|
|
21567
20943
|
get names() {
|
|
@@ -21622,8 +20998,8 @@ var require_codegen = __commonJS({
|
|
|
21622
20998
|
optimizeNodes() {
|
|
21623
20999
|
return `${this.code}` ? this : void 0;
|
|
21624
21000
|
}
|
|
21625
|
-
optimizeNames(names3,
|
|
21626
|
-
this.code = optimizeExpr(this.code, names3,
|
|
21001
|
+
optimizeNames(names3, constants5) {
|
|
21002
|
+
this.code = optimizeExpr(this.code, names3, constants5);
|
|
21627
21003
|
return this;
|
|
21628
21004
|
}
|
|
21629
21005
|
get names() {
|
|
@@ -21652,12 +21028,12 @@ var require_codegen = __commonJS({
|
|
|
21652
21028
|
}
|
|
21653
21029
|
return nodes.length > 0 ? this : void 0;
|
|
21654
21030
|
}
|
|
21655
|
-
optimizeNames(names3,
|
|
21031
|
+
optimizeNames(names3, constants5) {
|
|
21656
21032
|
const { nodes } = this;
|
|
21657
21033
|
let i = nodes.length;
|
|
21658
21034
|
while (i--) {
|
|
21659
21035
|
const n = nodes[i];
|
|
21660
|
-
if (n.optimizeNames(names3,
|
|
21036
|
+
if (n.optimizeNames(names3, constants5))
|
|
21661
21037
|
continue;
|
|
21662
21038
|
subtractNames(names3, n.names);
|
|
21663
21039
|
nodes.splice(i, 1);
|
|
@@ -21710,12 +21086,12 @@ var require_codegen = __commonJS({
|
|
|
21710
21086
|
return void 0;
|
|
21711
21087
|
return this;
|
|
21712
21088
|
}
|
|
21713
|
-
optimizeNames(names3,
|
|
21089
|
+
optimizeNames(names3, constants5) {
|
|
21714
21090
|
var _a6;
|
|
21715
|
-
this.else = (_a6 = this.else) === null || _a6 === void 0 ? void 0 : _a6.optimizeNames(names3,
|
|
21716
|
-
if (!(super.optimizeNames(names3,
|
|
21091
|
+
this.else = (_a6 = this.else) === null || _a6 === void 0 ? void 0 : _a6.optimizeNames(names3, constants5);
|
|
21092
|
+
if (!(super.optimizeNames(names3, constants5) || this.else))
|
|
21717
21093
|
return;
|
|
21718
|
-
this.condition = optimizeExpr(this.condition, names3,
|
|
21094
|
+
this.condition = optimizeExpr(this.condition, names3, constants5);
|
|
21719
21095
|
return this;
|
|
21720
21096
|
}
|
|
21721
21097
|
get names() {
|
|
@@ -21738,10 +21114,10 @@ var require_codegen = __commonJS({
|
|
|
21738
21114
|
render(opts) {
|
|
21739
21115
|
return `for(${this.iteration})` + super.render(opts);
|
|
21740
21116
|
}
|
|
21741
|
-
optimizeNames(names3,
|
|
21742
|
-
if (!super.optimizeNames(names3,
|
|
21117
|
+
optimizeNames(names3, constants5) {
|
|
21118
|
+
if (!super.optimizeNames(names3, constants5))
|
|
21743
21119
|
return;
|
|
21744
|
-
this.iteration = optimizeExpr(this.iteration, names3,
|
|
21120
|
+
this.iteration = optimizeExpr(this.iteration, names3, constants5);
|
|
21745
21121
|
return this;
|
|
21746
21122
|
}
|
|
21747
21123
|
get names() {
|
|
@@ -21777,10 +21153,10 @@ var require_codegen = __commonJS({
|
|
|
21777
21153
|
render(opts) {
|
|
21778
21154
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
21779
21155
|
}
|
|
21780
|
-
optimizeNames(names3,
|
|
21781
|
-
if (!super.optimizeNames(names3,
|
|
21156
|
+
optimizeNames(names3, constants5) {
|
|
21157
|
+
if (!super.optimizeNames(names3, constants5))
|
|
21782
21158
|
return;
|
|
21783
|
-
this.iterable = optimizeExpr(this.iterable, names3,
|
|
21159
|
+
this.iterable = optimizeExpr(this.iterable, names3, constants5);
|
|
21784
21160
|
return this;
|
|
21785
21161
|
}
|
|
21786
21162
|
get names() {
|
|
@@ -21822,11 +21198,11 @@ var require_codegen = __commonJS({
|
|
|
21822
21198
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
21823
21199
|
return this;
|
|
21824
21200
|
}
|
|
21825
|
-
optimizeNames(names3,
|
|
21201
|
+
optimizeNames(names3, constants5) {
|
|
21826
21202
|
var _a6, _b;
|
|
21827
|
-
super.optimizeNames(names3,
|
|
21828
|
-
(_a6 = this.catch) === null || _a6 === void 0 ? void 0 : _a6.optimizeNames(names3,
|
|
21829
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names3,
|
|
21203
|
+
super.optimizeNames(names3, constants5);
|
|
21204
|
+
(_a6 = this.catch) === null || _a6 === void 0 ? void 0 : _a6.optimizeNames(names3, constants5);
|
|
21205
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names3, constants5);
|
|
21830
21206
|
return this;
|
|
21831
21207
|
}
|
|
21832
21208
|
get names() {
|
|
@@ -22127,7 +21503,7 @@ var require_codegen = __commonJS({
|
|
|
22127
21503
|
function addExprNames(names3, from) {
|
|
22128
21504
|
return from instanceof code_1._CodeOrName ? addNames(names3, from.names) : names3;
|
|
22129
21505
|
}
|
|
22130
|
-
function optimizeExpr(expr, names3,
|
|
21506
|
+
function optimizeExpr(expr, names3, constants5) {
|
|
22131
21507
|
if (expr instanceof code_1.Name)
|
|
22132
21508
|
return replaceName(expr);
|
|
22133
21509
|
if (!canOptimize(expr))
|
|
@@ -22142,14 +21518,14 @@ var require_codegen = __commonJS({
|
|
|
22142
21518
|
return items;
|
|
22143
21519
|
}, []));
|
|
22144
21520
|
function replaceName(n) {
|
|
22145
|
-
const c =
|
|
21521
|
+
const c = constants5[n.str];
|
|
22146
21522
|
if (c === void 0 || names3[n.str] !== 1)
|
|
22147
21523
|
return n;
|
|
22148
21524
|
delete names3[n.str];
|
|
22149
21525
|
return c;
|
|
22150
21526
|
}
|
|
22151
21527
|
function canOptimize(e) {
|
|
22152
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names3[c.str] === 1 &&
|
|
21528
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names3[c.str] === 1 && constants5[c.str] !== void 0);
|
|
22153
21529
|
}
|
|
22154
21530
|
}
|
|
22155
21531
|
function subtractNames(names3, from) {
|
|
@@ -24111,7 +23487,7 @@ var require_compile = __commonJS({
|
|
|
24111
23487
|
const schOrFunc = root2.refs[ref];
|
|
24112
23488
|
if (schOrFunc)
|
|
24113
23489
|
return schOrFunc;
|
|
24114
|
-
let _sch =
|
|
23490
|
+
let _sch = resolve17.call(this, root2, ref);
|
|
24115
23491
|
if (_sch === void 0) {
|
|
24116
23492
|
const schema = (_a6 = root2.localRefs) === null || _a6 === void 0 ? void 0 : _a6[ref];
|
|
24117
23493
|
const { schemaId } = this.opts;
|
|
@@ -24138,7 +23514,7 @@ var require_compile = __commonJS({
|
|
|
24138
23514
|
function sameSchemaEnv(s1, s2) {
|
|
24139
23515
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
24140
23516
|
}
|
|
24141
|
-
function
|
|
23517
|
+
function resolve17(root2, ref) {
|
|
24142
23518
|
let sch;
|
|
24143
23519
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
24144
23520
|
ref = sch;
|
|
@@ -24769,7 +24145,7 @@ var require_fast_uri = __commonJS({
|
|
|
24769
24145
|
}
|
|
24770
24146
|
return uri;
|
|
24771
24147
|
}
|
|
24772
|
-
function
|
|
24148
|
+
function resolve17(baseURI, relativeURI, options2) {
|
|
24773
24149
|
const schemelessOptions = options2 ? Object.assign({ scheme: "null" }, options2) : { scheme: "null" };
|
|
24774
24150
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
24775
24151
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -25053,7 +24429,7 @@ var require_fast_uri = __commonJS({
|
|
|
25053
24429
|
var fastUri = {
|
|
25054
24430
|
SCHEMES,
|
|
25055
24431
|
normalize: normalize3,
|
|
25056
|
-
resolve:
|
|
24432
|
+
resolve: resolve17,
|
|
25057
24433
|
resolveComponent,
|
|
25058
24434
|
equal,
|
|
25059
24435
|
serialize: serialize2,
|
|
@@ -25468,7 +24844,7 @@ var require_core = __commonJS({
|
|
|
25468
24844
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
25469
24845
|
if (!errors || errors.length === 0)
|
|
25470
24846
|
return "No errors";
|
|
25471
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
24847
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text5, msg) => text5 + separator + msg);
|
|
25472
24848
|
}
|
|
25473
24849
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
25474
24850
|
const rules = this.RULES.all;
|
|
@@ -30403,218 +29779,1101 @@ function essentialOutputSchema(source, paths2, declared = /* @__PURE__ */ new Ma
|
|
|
30403
29779
|
...minItems ? { minItems } : {}
|
|
30404
29780
|
};
|
|
30405
29781
|
}
|
|
30406
|
-
return build(selection, "");
|
|
30407
|
-
}
|
|
30408
|
-
var escape2, arrayIndex, maxIndex;
|
|
30409
|
-
var init_essential_output = __esm({
|
|
30410
|
-
"../../packages/core/dist/definitions/essential-output.js"() {
|
|
29782
|
+
return build(selection, "");
|
|
29783
|
+
}
|
|
29784
|
+
var escape2, arrayIndex, maxIndex;
|
|
29785
|
+
var init_essential_output = __esm({
|
|
29786
|
+
"../../packages/core/dist/definitions/essential-output.js"() {
|
|
29787
|
+
"use strict";
|
|
29788
|
+
init_analysis();
|
|
29789
|
+
escape2 = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
29790
|
+
arrayIndex = /^(?:0|[1-9]\d*)$/u;
|
|
29791
|
+
maxIndex = 127;
|
|
29792
|
+
}
|
|
29793
|
+
});
|
|
29794
|
+
|
|
29795
|
+
// ../../packages/core/dist/definitions/categories.js
|
|
29796
|
+
var labels, descriptions, categories;
|
|
29797
|
+
var init_categories = __esm({
|
|
29798
|
+
"../../packages/core/dist/definitions/categories.js"() {
|
|
29799
|
+
"use strict";
|
|
29800
|
+
init_schema();
|
|
29801
|
+
labels = ["AI", "Communication", "Sales & CRM", "Marketing", "Customer Support & Success", "Productivity & Collaboration", "Content, Design & Files", "Commerce", "Finance & Accounting", "Data & Analytics", "Developer & IT", "People & Learning", "Business Operations", "Legal, Risk & Compliance", "Other"];
|
|
29802
|
+
descriptions = [
|
|
29803
|
+
"General-purpose AI models, agents, assistants, and agent-building platforms.",
|
|
29804
|
+
"Email, messaging, SMS, telephony, video calls, and notifications.",
|
|
29805
|
+
"CRM, leads, contacts, sales intelligence, engagement, and revenue operations.",
|
|
29806
|
+
"Advertising, email marketing, social media, SEO, events, and referrals.",
|
|
29807
|
+
"Help desks, tickets, shared inboxes, customer success, and service feedback.",
|
|
29808
|
+
"Tasks, projects, calendars, scheduling, documents, knowledge bases, forms, and whiteboards.",
|
|
29809
|
+
"Cloud files, design, media, presentations, publishing, and creative review.",
|
|
29810
|
+
"Storefronts, products, orders, fulfillment, inventory, and shipping.",
|
|
29811
|
+
"Payments, billing, banking, accounting, invoices, tax, and expenses.",
|
|
29812
|
+
"Databases, warehouses, spreadsheets, BI, dashboards, and analytics.",
|
|
29813
|
+
"APIs, source control, CI/CD, testing, cloud, monitoring, security, and app building.",
|
|
29814
|
+
"HRIS, payroll, recruiting, performance, workforce management, LMS, and training.",
|
|
29815
|
+
"ERP, procurement, assets, facilities, field operations, and industry-specific operations.",
|
|
29816
|
+
"Contracts, electronic signatures, legal operations, GRC, privacy, audit, and compliance.",
|
|
29817
|
+
"Apps without a clear fit in the primary categories."
|
|
29818
|
+
];
|
|
29819
|
+
categories = categorySlugs.map((slug, index2) => ({ slug, label: labels[index2], description: descriptions[index2] }));
|
|
29820
|
+
}
|
|
29821
|
+
});
|
|
29822
|
+
|
|
29823
|
+
// ../../packages/core/dist/definitions/index.js
|
|
29824
|
+
var init_definitions = __esm({
|
|
29825
|
+
"../../packages/core/dist/definitions/index.js"() {
|
|
29826
|
+
"use strict";
|
|
29827
|
+
init_schema();
|
|
29828
|
+
init_verification();
|
|
29829
|
+
init_essential_output();
|
|
29830
|
+
init_rules();
|
|
29831
|
+
init_analysis();
|
|
29832
|
+
init_metadata();
|
|
29833
|
+
init_categories();
|
|
29834
|
+
init_credential_contract();
|
|
29835
|
+
}
|
|
29836
|
+
});
|
|
29837
|
+
|
|
29838
|
+
// ../../packages/core/dist/api/feedback.js
|
|
29839
|
+
function feedbackTextBytes(text5) {
|
|
29840
|
+
return new TextEncoder().encode(text5).length;
|
|
29841
|
+
}
|
|
29842
|
+
function isFeedbackText(text5) {
|
|
29843
|
+
return !Array.from(text5).some((c) => {
|
|
29844
|
+
const code = c.charCodeAt(0);
|
|
29845
|
+
return code === 127 || code < 32 && ![9, 10, 13].includes(code);
|
|
29846
|
+
});
|
|
29847
|
+
}
|
|
29848
|
+
function scrubFeedbackText(value, knownSecrets = []) {
|
|
29849
|
+
let result3 = value;
|
|
29850
|
+
for (const secret of knownSecrets.filter(Boolean))
|
|
29851
|
+
result3 = result3.split(secret).join("[redacted]");
|
|
29852
|
+
return result3.replace(/^(\s*(?:cookie|set-cookie|authorization)\s*:)[^\r\n]*/gimu, "$1 [redacted]").replace(/\b(?:apl_[A-Za-z0-9_-]{43}|(?:sk|ghp|github_pat|xoxb|xoxp)[_-][A-Za-z0-9_-]{16,}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)\b/gu, "[redacted]").replace(/\b(Bearer|Basic)\s+[A-Za-z0-9+/_.=-]+/giu, "$1 [redacted]").replace(/(["']?(?:authorization|cookie|set-cookie|password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token)["']?\s*[:=]\s*)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;}\r\n]+)/giu, "$1[redacted]").replace(/(https?:\/\/)[^\s/@:]+:[^\s/@]+@/giu, "$1[redacted]@");
|
|
29853
|
+
}
|
|
29854
|
+
function scrubFeedbackReport(report, knownSecrets = []) {
|
|
29855
|
+
const scrub = (v) => scrubFeedbackText(v, knownSecrets);
|
|
29856
|
+
const filename = (v) => {
|
|
29857
|
+
const clean = scrub(v).replace(/[^A-Za-z0-9._-]/gu, "_");
|
|
29858
|
+
return (/^[A-Za-z0-9]/u.test(clean) ? clean : `evidence-${clean}`).slice(0, 120);
|
|
29859
|
+
};
|
|
29860
|
+
return {
|
|
29861
|
+
...report,
|
|
29862
|
+
blocked: scrub(report.blocked),
|
|
29863
|
+
repro: scrub(report.repro),
|
|
29864
|
+
expected: scrub(report.expected),
|
|
29865
|
+
actual: scrub(report.actual),
|
|
29866
|
+
...report.comment ? { comment: scrub(report.comment) } : {},
|
|
29867
|
+
attachments: report.attachments.map((a) => ({ name: filename(a.name), text: scrub(a.text) }))
|
|
29868
|
+
};
|
|
29869
|
+
}
|
|
29870
|
+
var text, safeLabel, feedbackMetadataSchema, feedbackAttachmentSchema, feedbackReportSchema, feedbackStatusSchema;
|
|
29871
|
+
var init_feedback = __esm({
|
|
29872
|
+
"../../packages/core/dist/api/feedback.js"() {
|
|
29873
|
+
"use strict";
|
|
29874
|
+
init_zod();
|
|
29875
|
+
text = external_exports.string().trim().min(1).max(2e3);
|
|
29876
|
+
safeLabel = external_exports.string().min(1).max(120).regex(/^[A-Za-z0-9._-]+$/u);
|
|
29877
|
+
feedbackMetadataSchema = external_exports.strictObject({
|
|
29878
|
+
cliVersion: safeLabel,
|
|
29879
|
+
platform: safeLabel,
|
|
29880
|
+
agent: external_exports.enum(["codex", "claude", "other"]),
|
|
29881
|
+
occurredAt: external_exports.iso.datetime({ offset: true }),
|
|
29882
|
+
invocation: external_exports.strictObject({
|
|
29883
|
+
id: external_exports.uuid(),
|
|
29884
|
+
command: safeLabel,
|
|
29885
|
+
exitCode: external_exports.number().int().min(0).max(255),
|
|
29886
|
+
startedAt: external_exports.iso.datetime({ offset: true }),
|
|
29887
|
+
finishedAt: external_exports.iso.datetime({ offset: true }),
|
|
29888
|
+
diagnostic: safeLabel.optional(),
|
|
29889
|
+
executionId: external_exports.uuid().optional(),
|
|
29890
|
+
discoveryId: external_exports.uuid().optional()
|
|
29891
|
+
}).optional()
|
|
29892
|
+
});
|
|
29893
|
+
feedbackAttachmentSchema = external_exports.strictObject({
|
|
29894
|
+
name: external_exports.string().min(1).max(120).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u),
|
|
29895
|
+
text: external_exports.string().refine(isFeedbackText, "Expected plain UTF-8 text").refine((v) => feedbackTextBytes(v) <= 65536, "Attachment exceeds 64 KiB")
|
|
29896
|
+
});
|
|
29897
|
+
feedbackReportSchema = external_exports.strictObject({
|
|
29898
|
+
id: external_exports.uuid(),
|
|
29899
|
+
kind: external_exports.enum(["apilift", "action"]),
|
|
29900
|
+
blocked: text,
|
|
29901
|
+
repro: text,
|
|
29902
|
+
expected: text,
|
|
29903
|
+
actual: text,
|
|
29904
|
+
comment: text.optional(),
|
|
29905
|
+
app: external_exports.string().min(1).max(120).regex(/^[a-z0-9][a-z0-9-]*$/u).optional(),
|
|
29906
|
+
action: external_exports.string().max(120).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u).optional(),
|
|
29907
|
+
executionId: external_exports.uuid().optional(),
|
|
29908
|
+
incorrectResult: external_exports.literal(true).optional(),
|
|
29909
|
+
metadata: feedbackMetadataSchema,
|
|
29910
|
+
attachments: external_exports.array(feedbackAttachmentSchema).max(5)
|
|
29911
|
+
}).superRefine((v, ctx) => {
|
|
29912
|
+
if (v.kind === "action" ? !v.app || !v.action : v.app !== void 0 || v.action !== void 0 || v.executionId !== void 0 || v.incorrectResult !== void 0)
|
|
29913
|
+
ctx.addIssue({ code: "custom", message: "Action reports require app and action; general reports have no action target" });
|
|
29914
|
+
if (v.incorrectResult && !v.executionId)
|
|
29915
|
+
ctx.addIssue({ code: "custom", message: "Incorrect-result feedback requires an owned execution" });
|
|
29916
|
+
if (v.attachments.reduce((n, a) => n + feedbackTextBytes(a.text), 0) > 262144)
|
|
29917
|
+
ctx.addIssue({ code: "custom", message: "Attachments exceed 256 KiB combined" });
|
|
29918
|
+
if (new Set(v.attachments.map((a) => a.name)).size !== v.attachments.length)
|
|
29919
|
+
ctx.addIssue({ code: "custom", message: "Attachment names must be distinct" });
|
|
29920
|
+
});
|
|
29921
|
+
feedbackStatusSchema = external_exports.enum(["new", "triaged", "resolved", "duplicate", "dismissed"]);
|
|
29922
|
+
}
|
|
29923
|
+
});
|
|
29924
|
+
|
|
29925
|
+
// ../../packages/core/dist/api/contracts.js
|
|
29926
|
+
function apiContract(method, path2, auth, params, query, body, response, errors = []) {
|
|
29927
|
+
const common = ["invalid-request", "client-upgrade-required", "backend-unavailable"];
|
|
29928
|
+
if (auth !== "none")
|
|
29929
|
+
common.push("unauthenticated");
|
|
29930
|
+
if (auth === "installation" || auth === "installation-or-cookie")
|
|
29931
|
+
common.push("installation-revoked");
|
|
29932
|
+
return { method, path: path2, auth, params, query, body, response, errors: [.../* @__PURE__ */ new Set([...common, ...errors])] };
|
|
29933
|
+
}
|
|
29934
|
+
var str, uuid3, iso, hash2, empty, data, agent, knownAgent, path, actionPath, resourcePath, pageQuery, kindName, definition, readinessMachine, readinessAgent, releaseComponent, releaseState, appItem, entitlement, readiness, me, setupStatus, actionSummary, actionDocumentation, bundle, resourceRead, resourceRequirements, safetyReview, billing, executionFeedbackSchema, executionReportSchema, sharedMeasure, CAPTURE_ATTRIBUTION_POLICY, MAX_CAPTURE_PUBLICATION_WITNESSES, publicationWitness, executionMeasurementSchema, baselineSampleSchema, executionAcknowledgement, measurementAcknowledgement, noParams, noQuery, noBody, EXECUTION_TEST_HINT_CAPABILITY, COMPLETE_RESOURCE_PUBLICATION_CAPABILITY, resourcePublicationSchema, resourcePublicationResultSchema, resourceBatchSchema, page, apiContracts;
|
|
29935
|
+
var init_contracts = __esm({
|
|
29936
|
+
"../../packages/core/dist/api/contracts.js"() {
|
|
29937
|
+
"use strict";
|
|
29938
|
+
init_zod();
|
|
29939
|
+
init_definitions();
|
|
29940
|
+
init_errors3();
|
|
29941
|
+
init_feedback();
|
|
29942
|
+
str = external_exports.string().min(1);
|
|
29943
|
+
uuid3 = external_exports.uuid();
|
|
29944
|
+
iso = external_exports.iso.datetime({ offset: true });
|
|
29945
|
+
hash2 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
29946
|
+
empty = external_exports.strictObject({});
|
|
29947
|
+
data = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
29948
|
+
agent = external_exports.enum(["codex", "claude", "other"]);
|
|
29949
|
+
knownAgent = external_exports.enum(["codex", "claude"]);
|
|
29950
|
+
path = external_exports.strictObject({ app: str });
|
|
29951
|
+
actionPath = path.extend({ action: str });
|
|
29952
|
+
resourcePath = path.extend({ kind: resourceKindSchema, name: str });
|
|
29953
|
+
pageQuery = { cursor: str.optional(), limit: external_exports.coerce.number().int().min(1).max(100).default(50) };
|
|
29954
|
+
kindName = external_exports.strictObject({ kind: resourceKindSchema, name: str });
|
|
29955
|
+
definition = external_exports.union([definitionSchemas.app, definitionSchemas.entity, definitionSchemas.action, definitionSchemas.transport, definitionSchemas["browser-context"]]);
|
|
29956
|
+
readinessMachine = external_exports.strictObject({ nativeHostReady: external_exports.boolean().optional(), nativeHostVersion: str.optional(), extensionReady: external_exports.boolean().optional(), extensionVersion: str.optional() });
|
|
29957
|
+
readinessAgent = external_exports.strictObject({ skillsReady: external_exports.boolean().optional(), skillsVersion: str.optional(), browserReady: external_exports.boolean().optional(), verified: external_exports.boolean().optional(), verifiedAt: iso.optional() });
|
|
29958
|
+
releaseComponent = external_exports.strictObject({ version: str, sourceSha: str, minimum: external_exports.record(external_exports.string(), str) });
|
|
29959
|
+
releaseState = external_exports.strictObject({ release: str, components: external_exports.strictObject({ cli: releaseComponent, extension: releaseComponent.extend({ storeVersion: str.optional() }), web: releaseComponent }) });
|
|
29960
|
+
appItem = external_exports.strictObject({ id: uuid3, slug: str, title: str, summary: external_exports.string(), origin: str, category: categorySchema, visibility: external_exports.enum(["public", "private"]), status: external_exports.enum(["building", "active", "restricted"]), iconUrl: str.nullable(), actionCount: external_exports.number().int().nonnegative(), entityCount: external_exports.number().int().nonnegative(), updatedAt: iso });
|
|
29961
|
+
entitlement = external_exports.strictObject({ plan: external_exports.enum(["free", "pro", "cloud"]), source: external_exports.enum(["subscription", "trial", "free"]), features: external_exports.array(str), trialEndsAt: iso.optional(), graceEndsAt: iso.optional() });
|
|
29962
|
+
readiness = external_exports.strictObject({ machine: readinessMachine, agents: external_exports.record(external_exports.string(), readinessAgent) });
|
|
29963
|
+
me = external_exports.strictObject({ account: external_exports.strictObject({ id: uuid3, email: str, name: str, status: external_exports.literal("active") }), workspace: external_exports.strictObject({ id: uuid3, name: str, role: external_exports.literal("owner"), preferences: external_exports.strictObject({ defaultVisibility: external_exports.enum(["public", "private"]), communityChannel: external_exports.enum(["latest", "validated"]), effective: data }) }), installation: external_exports.strictObject({ id: uuid3, label: str, agents: external_exports.array(external_exports.enum(["codex", "claude"])) }), entitlement, analytics: external_exports.strictObject({ enabled: external_exports.boolean(), distinctId: str, environment: external_exports.enum(["production", "test", "disabled"]), internal: external_exports.boolean(), projectKey: external_exports.string(), host: external_exports.string() }), compatibility: external_exports.strictObject({ minimum: external_exports.strictObject({ cli: str, extension: str }), latest: external_exports.strictObject({ cli: str, extension: str }) }) });
|
|
29964
|
+
setupStatus = external_exports.strictObject({ linkCode: external_exports.strictObject({ id: uuid3, agent: knownAgent.nullable(), status: external_exports.enum(["pending", "claimed", "expired"]), expiresAt: iso, installationId: uuid3.nullable() }).nullable(), installation: external_exports.strictObject({ id: uuid3, label: str, readiness, steps: data, agents: external_exports.array(knownAgent) }).nullable() });
|
|
29965
|
+
actionSummary = external_exports.strictObject({ name: str, title: str, summary: external_exports.string(), effect: external_exports.enum(["read", "create", "update", "delete"]).optional(), availability: external_exports.enum(["executable", "unavailable"]), policy: external_exports.enum(["approve", "deny", "disable"]), health: data, documentation: data.optional() });
|
|
29966
|
+
actionDocumentation = external_exports.strictObject({ name: str, title: str, description: external_exports.string(), details: external_exports.string().optional(), effect: external_exports.enum(["read", "create", "update", "delete"]).optional(), availability: external_exports.enum(["executable", "unavailable"]), inputs: jsonSchema, output: jsonSchema.optional(), observedOutput: jsonSchema.optional(), verificationScope: external_exports.unknown().optional(), proof: external_exports.enum(["readback", "absence"]).optional(), unavailable: external_exports.strictObject({ reason: str, evidence: str }).optional(), transport: external_exports.strictObject({ name: str, mode: external_exports.enum(["direct", "browser"]), instructions: str, credentials: external_exports.array(external_exports.strictObject({ name: str, header: str })) }).optional(), version: external_exports.number().int().positive(), executableHash: hash2.optional(), policy: external_exports.enum(["approve", "deny", "disable"]), health: data });
|
|
29967
|
+
bundle = external_exports.strictObject({ suggestTest: external_exports.literal(true).optional(), receipt: external_exports.strictObject({ id: uuid3, dispatchBefore: iso }).optional(), decision: external_exports.literal("allow"), app: external_exports.strictObject({ id: uuid3, slug: str, visibility: external_exports.enum(["public", "private"]) }), action: external_exports.strictObject({ name: str, effect: external_exports.enum(["read", "create", "update", "delete"]) }), closure: external_exports.strictObject({ hash: hash2, status: external_exports.enum(["pending", "validated"]), workspaceStatus: external_exports.literal("successful").nullable(), versions: external_exports.array(external_exports.strictObject({ kind: resourceKindSchema, name: str, version: external_exports.number().int().positive(), executableHash: hash2, versionId: uuid3.optional(), definition: definition.optional() })) }), selection: external_exports.strictObject({ channel: external_exports.enum(["latest", "validated"]), fallback: external_exports.boolean(), replaced: external_exports.strictObject({ closureHash: hash2, reason: str, until: iso.optional() }).optional() }), policy: external_exports.literal("approve") });
|
|
29968
|
+
resourceRead = external_exports.strictObject({ ...kindName.shape, definition, version: external_exports.number().int().positive(), executableHash: hash2.optional(), verification: data.optional(), dependents: external_exports.array(kindName).optional(), nextDependentsCursor: external_exports.string().nullable().optional() });
|
|
29969
|
+
resourceRequirements = external_exports.strictObject({ legacyCredentialContract: str.optional(), credentialContract: str.optional(), destinations: external_exports.array(str).optional(), name: str, title: str, mode: external_exports.enum(["direct", "browser"]), instructions: str, credentials: external_exports.array(external_exports.strictObject({ name: str, header: str, prefix: external_exports.string().optional() })), revision: external_exports.strictObject({ credentialContractHash: hash2.optional(), canRecreate: external_exports.boolean() }).optional() });
|
|
29970
|
+
safetyReview = external_exports.union([external_exports.strictObject({ access: external_exports.literal("locked") }), external_exports.strictObject({ access: external_exports.literal("included"), state: external_exports.enum(["missing", "checking", "ready", "unavailable"]), route: str, findings: data.optional(), checkedAt: iso.optional(), stale: external_exports.boolean().optional(), message: external_exports.string().optional() })]);
|
|
29971
|
+
billing = external_exports.strictObject({ workspaceId: uuid3, paddleCustomerId: str.optional(), entitlement, trial: external_exports.strictObject({ status: external_exports.enum(["active", "ended", "converted"]), startedAt: iso, endsAt: iso, completedAt: iso.optional() }).optional(), subscription: external_exports.strictObject({ id: str, status: str, plan: str, interval: str, currency: str, currentPeriod: external_exports.strictObject({ startsAt: iso, endsAt: iso }), nextBilledAt: iso.optional(), graceEndsAt: iso.optional(), scheduledChange: data.optional() }).optional(), usage: data.optional(), checkout: external_exports.strictObject({ status: external_exports.enum(["pending", "unknown"]), transactionId: str.optional() }).optional(), checkoutAvailable: external_exports.boolean(), paddle: external_exports.strictObject({ environment: external_exports.enum(["sandbox", "production"]), clientToken: str }) });
|
|
29972
|
+
executionFeedbackSchema = external_exports.strictObject({ kind: external_exports.literal("semantic-incorrect") });
|
|
29973
|
+
executionReportSchema = external_exports.strictObject({ id: uuid3, receiptId: uuid3.optional(), appId: uuid3, actionName: str, actionVersion: external_exports.number().int().positive(), closureHash: hash2, purpose: external_exports.enum(["run", "verify"]), clientFamily: external_exports.enum(["cli", "discovery"]), agent, outcome: external_exports.enum(["caller-error", "credential-error", "rate-limit", "app-outage", "interface-error", "uncertain", "network-error", "success", "cancelled"]), diagnostic: external_exports.enum(["operation-unavailable", "response-contract", "proof-failed"]).optional(), httpStatus: external_exports.number().int().optional(), proof: external_exports.enum(["passed", "failed", "unavailable"]).optional(), semanticConfirmed: external_exports.boolean().optional(), connectionFingerprint: hash2.optional(), startedAt: iso, dispatchedAt: iso.optional(), finishedAt: iso });
|
|
29974
|
+
sharedMeasure = { durationMs: external_exports.number().min(0).max(864e5).nullable(), tokens: external_exports.strictObject({ input: external_exports.number().min(0).max(1e8), output: external_exports.number().min(0).max(1e8) }).nullable(), coverage: external_exports.enum(["final", "partial", "unavailable"]), timeCoverage: external_exports.enum(["final", "partial", "unavailable"]), provider: external_exports.enum(["openai", "anthropic", "bedrock", "vertex", "custom"]).nullable(), model: external_exports.string().max(120).regex(/^[A-Za-z0-9._<>[\]:/@-]+$/).nullable() };
|
|
29975
|
+
CAPTURE_ATTRIBUTION_POLICY = "capture-attribution-v2";
|
|
29976
|
+
MAX_CAPTURE_PUBLICATION_WITNESSES = 4096;
|
|
29977
|
+
publicationWitness = external_exports.strictObject({ name: str, version: external_exports.number().int().positive(), requestId: uuid3 });
|
|
29978
|
+
executionMeasurementSchema = external_exports.strictObject({ id: uuid3, executionId: uuid3, revision: external_exports.number().int().positive(), purpose: external_exports.enum(["productive", "discovery", "verification", "setup", "unknown"]), session: hash2.nullable(), worker: hash2.nullable(), policy: external_exports.literal(CAPTURE_ATTRIBUTION_POLICY).optional(), ...sharedMeasure });
|
|
29979
|
+
baselineSampleSchema = external_exports.strictObject({ id: uuid3, revision: external_exports.number().int().positive(), appId: uuid3, actionName: str.nullable(), executableHash: hash2.nullable(), method: external_exports.enum(["browser", "direct"]).nullable(), publishedAction: publicationWitness.omit({ requestId: true }).optional(), policy: external_exports.literal(CAPTURE_ATTRIBUTION_POLICY).optional(), kind: external_exports.enum(["action", "preparation"]).optional(), publications: external_exports.array(publicationWitness).min(1).max(MAX_CAPTURE_PUBLICATION_WITNESSES).optional(), completeness: external_exports.enum(["complete", "prefix"]), occurredAt: iso, ...sharedMeasure });
|
|
29980
|
+
executionAcknowledgement = external_exports.strictObject({ results: external_exports.array(external_exports.strictObject({ id: uuid3, status: external_exports.enum(["accepted", "duplicate", "rejected"]), code: str.optional() })) });
|
|
29981
|
+
measurementAcknowledgement = external_exports.strictObject({ results: external_exports.array(external_exports.strictObject({ id: uuid3, revision: external_exports.number().int().positive(), status: external_exports.enum(["accepted", "duplicate", "pending", "rejected"]), code: str.optional() })) });
|
|
29982
|
+
noParams = empty;
|
|
29983
|
+
noQuery = empty;
|
|
29984
|
+
noBody = empty;
|
|
29985
|
+
EXECUTION_TEST_HINT_CAPABILITY = "execution-test-hint-v1";
|
|
29986
|
+
COMPLETE_RESOURCE_PUBLICATION_CAPABILITY = "complete-resource-publication-v1";
|
|
29987
|
+
resourcePublicationSchema = external_exports.strictObject({ kind: resourceKindSchema, name: str, requestId: uuid3, expectedVersion: external_exports.number().int().positive().nullable(), definition: external_exports.unknown(), verification: data.optional() });
|
|
29988
|
+
resourcePublicationResultSchema = external_exports.strictObject({ attribution: external_exports.strictObject({ method: external_exports.enum(["browser", "direct"]), baseUrl: requestUrlSchema.optional() }).optional(), resource: external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive() }), executableHash: hash2.optional(), closureHash: hash2.optional(), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional() });
|
|
29989
|
+
resourceBatchSchema = external_exports.strictObject({ mode: external_exports.literal("complete-replacement").optional(), resources: external_exports.array(resourcePublicationSchema).min(1).max(128) }).refine((value) => new Set(value.resources.map((r) => `${r.kind}:${r.name}`)).size === value.resources.length, "Select each resource once").refine((value) => new Set(value.resources.map((r) => r.requestId)).size === value.resources.length, "Use distinct resource request ids");
|
|
29990
|
+
page = (item) => external_exports.strictObject({ items: external_exports.array(item), nextCursor: str.nullable().optional() });
|
|
29991
|
+
apiContracts = {
|
|
29992
|
+
submitFeedback: apiContract("POST", "/api/v1/feedback", "installation", noParams, noQuery, feedbackReportSchema, external_exports.strictObject({ id: uuid3, status: external_exports.enum(["accepted", "duplicate"]) }), ["feedback-throttled", "request-replay-mismatch", "execution-not-found", "app-not-found"]),
|
|
29993
|
+
executionFeedback: apiContract("POST", "/api/v1/executions/{executionId}/feedback", "installation", external_exports.strictObject({ executionId: uuid3 }), noQuery, executionFeedbackSchema, external_exports.strictObject({ status: external_exports.enum(["accepted", "duplicate"]) }), ["execution-not-found"]),
|
|
29994
|
+
publishResources: apiContract("PUT", "/api/v1/apps/{app}/resources", "installation", external_exports.strictObject({ app: str }), noQuery, resourceBatchSchema, external_exports.strictObject({ results: external_exports.array(external_exports.union([
|
|
29995
|
+
external_exports.strictObject({ kind: resourceKindSchema, name: str, status: external_exports.enum(["published", "unchanged"]), publication: resourcePublicationResultSchema, currentVersion: external_exports.number().int().positive().nullable().optional() }),
|
|
29996
|
+
external_exports.strictObject({ kind: resourceKindSchema, name: str, status: external_exports.enum(["failed", "blocked"]), error: apiErrorSchema })
|
|
29997
|
+
])) })),
|
|
29998
|
+
createInstallation: apiContract("POST", "/api/v1/installations", "none", noParams, noQuery, external_exports.strictObject({ code: str, agent: knownAgent, machine: external_exports.strictObject({ label: external_exports.string().max(80), os: str, arch: str }) }), external_exports.strictObject({ installation: external_exports.strictObject({ id: uuid3 }), token: str, account: external_exports.strictObject({ id: uuid3, email: str, name: str }), workspace: external_exports.strictObject({ id: uuid3, name: str }), agent: knownAgent, mode: external_exports.literal("attached"), onboardingAttemptId: uuid3 }), ["link-code-invalid", "link-code-expired", "link-code-used"]),
|
|
29999
|
+
attachAgent: apiContract("POST", "/api/v1/installation/agents", "installation", noParams, noQuery, external_exports.strictObject({ code: str, agent: knownAgent }), external_exports.strictObject({ installation: external_exports.strictObject({ id: uuid3 }), account: external_exports.strictObject({ id: uuid3, email: str, name: str }), workspace: external_exports.strictObject({ id: uuid3, name: str }), agent: knownAgent, mode: external_exports.enum(["attached", "reconnected"]), onboardingAttemptId: uuid3 }), ["link-account-mismatch", "link-agent-mismatch"]),
|
|
30000
|
+
updateReadiness: apiContract("PUT", "/api/v1/installation/readiness", "installation", noParams, noQuery, external_exports.strictObject({ machine: readinessMachine.optional(), agent: knownAgent.optional(), agentState: readinessAgent.optional() }), external_exports.strictObject({ machine: readinessMachine, agents: external_exports.record(external_exports.string(), readinessAgent), steps: data.optional() }), ["readiness-incomplete"]),
|
|
30001
|
+
me: apiContract("GET", "/api/v1/me", "installation", noParams, noQuery, noBody, me),
|
|
30002
|
+
setupStatus: apiContract("GET", "/api/v1/setup-status", "cookie", noParams, external_exports.strictObject({ linkCode: uuid3.optional(), installation: uuid3.optional(), agent: knownAgent.optional() }), noBody, setupStatus),
|
|
30003
|
+
acquireSession: apiContract("PUT", "/api/v1/sessions/{id}", "installation", external_exports.strictObject({ id: str }), noQuery, external_exports.strictObject({ purpose: external_exports.enum(["execution", "discovery"]), appId: uuid3.optional() }), data, ["session-limit"]),
|
|
30004
|
+
releaseSession: apiContract("DELETE", "/api/v1/sessions/{id}", "installation", external_exports.strictObject({ id: str }), external_exports.strictObject({ appId: uuid3.optional(), purpose: external_exports.literal("execution").optional() }).refine((v) => Boolean(v.appId) === Boolean(v.purpose), "appId and purpose must be supplied together"), noBody, data),
|
|
30005
|
+
listApps: apiContract("GET", "/api/v1/apps", "installation-or-cookie", noParams, external_exports.strictObject({ q: external_exports.string().max(200).optional(), domain: str.optional(), category: categorySchema.optional(), visibility: external_exports.enum(["public", "private", "all"]).optional(), ids: str.optional(), ...pageQuery }), noBody, page(appItem)),
|
|
30006
|
+
createApp: apiContract("POST", "/api/v1/apps", "installation", noParams, noQuery, external_exports.strictObject({ requestId: uuid3, slug: str, visibility: external_exports.enum(["public", "private"]).optional(), definition: appDefinitionSchema }), data, ["slug-taken"]),
|
|
30007
|
+
getApp: apiContract("GET", "/api/v1/apps/{app}", "installation-or-cookie", path, external_exports.strictObject({ entity: str.optional(), entityCursor: str.optional(), transportCursor: str.optional(), limit: pageQuery.limit }), noBody, appItem.extend({ about: external_exports.string().optional(), safety: data.optional(), entities: external_exports.array(data), transports: external_exports.array(data), nextEntityCursor: str.nullable().optional(), nextTransportCursor: str.nullable().optional() })),
|
|
30008
|
+
listActions: apiContract("GET", "/api/v1/apps/{app}/actions", "installation-or-cookie", path, external_exports.strictObject({ entity: str.optional(), q: external_exports.string().max(200).optional(), names: str.optional(), include: external_exports.literal("documentation").optional(), ...pageQuery }), noBody, page(actionSummary)),
|
|
30009
|
+
getAction: apiContract("GET", "/api/v1/apps/{app}/actions/{action}", "installation-or-cookie", actionPath, external_exports.strictObject({ include: external_exports.literal("schemas").optional() }), noBody, actionDocumentation),
|
|
30010
|
+
getBundle: apiContract("GET", "/api/v1/apps/{app}/actions/{action}/bundle", "installation", actionPath, external_exports.strictObject({ knownVersions: external_exports.string().max(120).optional() }), noBody, bundle, ["session-limit", "action-withheld", "action-disabled", "action-denied", "action-unavailable"]),
|
|
30011
|
+
listResources: apiContract("GET", "/api/v1/apps/{app}/resources", "installation", path, external_exports.strictObject({ kind: resourceKindSchema.optional(), names: str.optional(), ...pageQuery }), noBody, page(external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive(), executableHash: hash2.optional(), updatedAt: iso })).extend({ capabilities: external_exports.array(str).optional() })),
|
|
30012
|
+
getResource: apiContract("GET", "/api/v1/apps/{app}/resources/{kind}/{name}", "installation-or-cookie", resourcePath, external_exports.strictObject({ view: external_exports.enum(["requirements", "authoring"]).optional(), dependentsCursor: external_exports.string().optional() }), noBody, external_exports.union([resourceRead, resourceRequirements])),
|
|
30013
|
+
publishResource: apiContract("PUT", "/api/v1/apps/{app}/resources/{kind}/{name}", "installation", resourcePath, noQuery, external_exports.union([external_exports.strictObject({ requestId: uuid3, expectedVersion: external_exports.number().int().positive().nullable(), definition, verification: data.optional() }), external_exports.strictObject({ requestId: uuid3, expectedVersion: external_exports.number().int().positive(), remove: external_exports.literal(true) })]), external_exports.strictObject({ resource: external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive() }), executableHash: hash2.optional(), closureHash: hash2.optional(), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional() }), ["definition-invalid", "documentation-incomplete", "reference-unresolved", "reference-cycle", "verification-incomplete", "verification-stale", "version-conflict"]),
|
|
30014
|
+
listChanges: apiContract("GET", "/api/v1/apps/{app}/changes", "installation-or-cookie", path, external_exports.strictObject({ resource: str.optional(), ...pageQuery }), noBody, page(external_exports.strictObject({ change: external_exports.number().int().positive(), kind: resourceKindSchema, name: str, version: external_exports.number().int().positive(), event: external_exports.enum(["published", "removed"]), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional(), publishedAt: iso }))),
|
|
30015
|
+
safetyReview: apiContract("GET", "/api/v1/apps/{app}/safety-review", "cookie", path, noQuery, noBody, safetyReview),
|
|
30016
|
+
postExecutions: apiContract("POST", "/api/v1/executions", "installation", noParams, noQuery, external_exports.strictObject({ reports: external_exports.array(external_exports.unknown()).min(1).max(100) }), executionAcknowledgement),
|
|
30017
|
+
postMeasurements: apiContract("POST", "/api/v1/measurements", "installation", noParams, noQuery, external_exports.strictObject({ executions: external_exports.array(external_exports.unknown()).max(100), baselines: external_exports.array(external_exports.unknown()).max(100) }).refine((body) => body.executions.length + body.baselines.length >= 1 && body.executions.length + body.baselines.length <= 100), measurementAcknowledgement),
|
|
30018
|
+
billing: apiContract("GET", "/api/v1/billing", "cookie", noParams, noQuery, noBody, billing),
|
|
30019
|
+
impactApp: apiContract("GET", "/api/v1/impact/apps/{appId}", "cookie", external_exports.strictObject({ appId: uuid3 }), external_exports.strictObject({ range: external_exports.enum(["30d", "90d", "365d"]).optional(), cursor: str.optional(), limit: external_exports.coerce.number().int().min(1).max(100).optional() }), noBody, data),
|
|
30020
|
+
currentRelease: apiContract("GET", "/api/v1/releases/current", "none", noParams, noQuery, noBody, releaseState),
|
|
30021
|
+
replaceRelease: apiContract("PUT", "/api/v1/releases/current", "release-token", noParams, noQuery, releaseState, releaseState, ["release-state-conflict"]),
|
|
30022
|
+
patchReleaseComponents: apiContract("PATCH", "/api/v1/releases/current/components", "release-token", noParams, noQuery, external_exports.strictObject({ observations: external_exports.array(external_exports.strictObject({ component: external_exports.enum(["cli", "extension", "web"]), version: str, sourceSha: str, minimum: external_exports.record(external_exports.string(), str), storeVersion: str.optional() })).min(1) }), releaseState, ["release-state-conflict"]),
|
|
30023
|
+
cloudUsageSegment: apiContract("POST", "/api/v1/internal/cloud-usage/segments", "cloud-usage-token", noParams, noQuery, external_exports.strictObject({ workspaceId: uuid3, subscriptionId: str, idempotencyKey: external_exports.string().min(8).max(160), startedAt: iso, endedAt: iso }), external_exports.strictObject({ id: uuid3, durationSeconds: external_exports.number().int().positive() }), ["usage-overlap"])
|
|
30024
|
+
};
|
|
30025
|
+
}
|
|
30026
|
+
});
|
|
30027
|
+
|
|
30028
|
+
// ../../packages/core/dist/api/client.js
|
|
30029
|
+
function createApiClient(baseUrl, fetcher) {
|
|
30030
|
+
return {
|
|
30031
|
+
async call(key2, input2 = {}) {
|
|
30032
|
+
const contract = apiContracts[key2];
|
|
30033
|
+
const params = contract.params.parse(input2.params ?? {});
|
|
30034
|
+
const query = contract.query.parse(input2.query ?? {});
|
|
30035
|
+
const body = contract.body.parse(input2.body ?? {});
|
|
30036
|
+
const pathname = contract.path.replace(/\{([^{}]+)\}/g, (_, name) => {
|
|
30037
|
+
if (!Object.hasOwn(params, name))
|
|
30038
|
+
throw new TypeError(`Missing path parameter ${name}`);
|
|
30039
|
+
return encodeURIComponent(params[name]);
|
|
30040
|
+
});
|
|
30041
|
+
const target = new URL(pathname, baseUrl);
|
|
30042
|
+
for (const [name, value2] of Object.entries(query))
|
|
30043
|
+
if (value2 !== void 0 && value2 !== null)
|
|
30044
|
+
target.searchParams.set(name, String(value2));
|
|
30045
|
+
const response = await fetcher(target, { method: contract.method, headers: { ...input2.headers, ...contract.method === "GET" || contract.method === "DELETE" ? {} : { "content-type": "application/json" } }, ...contract.method === "GET" || contract.method === "DELETE" ? {} : { body: JSON.stringify(body) }, signal: input2.signal });
|
|
30046
|
+
const value = response.status === 204 ? {} : await response.json();
|
|
30047
|
+
if (!response.ok)
|
|
30048
|
+
throw new ApiClientError(response.status, value);
|
|
30049
|
+
return contract.response.parse(value);
|
|
30050
|
+
}
|
|
30051
|
+
};
|
|
30052
|
+
}
|
|
30053
|
+
var ApiClientError;
|
|
30054
|
+
var init_client = __esm({
|
|
30055
|
+
"../../packages/core/dist/api/client.js"() {
|
|
30056
|
+
"use strict";
|
|
30057
|
+
init_errors3();
|
|
30058
|
+
init_contracts();
|
|
30059
|
+
ApiClientError = class extends Error {
|
|
30060
|
+
status;
|
|
30061
|
+
response;
|
|
30062
|
+
constructor(status, response) {
|
|
30063
|
+
super(apiErrorEnvelopeSchema.safeParse(response).data?.error.message ?? `API returned ${status}`);
|
|
30064
|
+
this.status = status;
|
|
30065
|
+
this.response = response;
|
|
30066
|
+
}
|
|
30067
|
+
};
|
|
30068
|
+
}
|
|
30069
|
+
});
|
|
30070
|
+
|
|
30071
|
+
// ../../packages/core/dist/api/index.js
|
|
30072
|
+
var init_api2 = __esm({
|
|
30073
|
+
"../../packages/core/dist/api/index.js"() {
|
|
30074
|
+
"use strict";
|
|
30075
|
+
init_errors3();
|
|
30076
|
+
init_contracts();
|
|
30077
|
+
init_client();
|
|
30078
|
+
init_feedback();
|
|
30079
|
+
}
|
|
30080
|
+
});
|
|
30081
|
+
|
|
30082
|
+
// src/feedback-store.ts
|
|
30083
|
+
import { createHash } from "node:crypto";
|
|
30084
|
+
function prepareFeedback(state) {
|
|
30085
|
+
state.db.exec(`CREATE TABLE IF NOT EXISTS feedback_outbox (id TEXT PRIMARY KEY, session_id TEXT NOT NULL, registry TEXT NOT NULL, owner TEXT, fingerprint TEXT NOT NULL, body TEXT NOT NULL, delivered INTEGER NOT NULL DEFAULT 0, attempts INTEGER NOT NULL DEFAULT 0, next_attempt_at INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL);
|
|
30086
|
+
CREATE TABLE IF NOT EXISTS feedback_command (id TEXT PRIMARY KEY, session_id TEXT NOT NULL, owner TEXT, registry TEXT NOT NULL, metadata TEXT NOT NULL, created_at INTEGER NOT NULL);
|
|
30087
|
+
CREATE TABLE IF NOT EXISTS feedback_hint (session_id TEXT NOT NULL, owner TEXT NOT NULL, diagnostic TEXT NOT NULL, PRIMARY KEY(session_id,owner,diagnostic));`);
|
|
30088
|
+
state.db.prepare("DELETE FROM feedback_outbox WHERE created_at<?").run(Date.now() - 90 * 864e5);
|
|
30089
|
+
state.db.prepare("DELETE FROM feedback_command WHERE created_at<?").run(Date.now() - 7 * 864e5);
|
|
30090
|
+
}
|
|
30091
|
+
function feedbackOwner(state) {
|
|
30092
|
+
const i = state.installation();
|
|
30093
|
+
return i ? JSON.stringify([i.id, i.accountId, i.workspaceId]) : null;
|
|
30094
|
+
}
|
|
30095
|
+
function rememberFeedbackCommand(state, session, registry2, metadata) {
|
|
30096
|
+
const parsed = feedbackMetadataSchema.safeParse(metadata);
|
|
30097
|
+
if (!parsed.success || !parsed.data.invocation) return;
|
|
30098
|
+
prepareFeedback(state);
|
|
30099
|
+
state.db.prepare("INSERT OR IGNORE INTO feedback_command VALUES (?,?,?,?,?,?)").run(parsed.data.invocation.id, session.id, feedbackOwner(state), registry2, JSON.stringify(parsed.data), Date.now());
|
|
30100
|
+
state.db.prepare("DELETE FROM feedback_command WHERE session_id=? AND rowid NOT IN (SELECT rowid FROM feedback_command WHERE session_id=? ORDER BY rowid DESC LIMIT 64)").run(session.id, session.id);
|
|
30101
|
+
}
|
|
30102
|
+
function retainFeedback(state, session, registry2, body) {
|
|
30103
|
+
prepareFeedback(state);
|
|
30104
|
+
const authored = Object.fromEntries(Object.entries(body).filter(([key2]) => !["id", "metadata"].includes(key2)));
|
|
30105
|
+
const fingerprint2 = createHash("sha256").update(JSON.stringify(authored)).digest("hex");
|
|
30106
|
+
const worker2 = session?.id ?? "unbound", owner = feedbackOwner(state);
|
|
30107
|
+
const existing = state.db.prepare("SELECT id FROM feedback_outbox WHERE session_id=? AND owner IS ? AND registry=? AND fingerprint=?").get(worker2, owner, registry2, fingerprint2);
|
|
30108
|
+
if (existing) return existing.id;
|
|
30109
|
+
const count = state.db.prepare("SELECT count(*) AS n FROM feedback_outbox WHERE delivered=0").get();
|
|
30110
|
+
if (count.n >= 100) throw new Error("Feedback queue is full. Retry retained reports before adding more.");
|
|
30111
|
+
state.db.prepare("INSERT INTO feedback_outbox (id,session_id,registry,owner,fingerprint,body,created_at) VALUES (?,?,?,?,?,?,?)").run(body.id, worker2, registry2, owner, fingerprint2, JSON.stringify(body), Date.now());
|
|
30112
|
+
return body.id;
|
|
30113
|
+
}
|
|
30114
|
+
async function deliverFeedback(state, api, id2) {
|
|
30115
|
+
const installation = state.installation();
|
|
30116
|
+
if (!installation || !api.authenticatedWith(installation.token)) return false;
|
|
30117
|
+
const owner = JSON.stringify([installation.id, installation.accountId, installation.workspaceId]);
|
|
30118
|
+
const row = state.db.prepare("SELECT body,delivered,attempts FROM feedback_outbox WHERE id=? AND owner=? AND registry=?").get(id2, owner, api.cacheNamespace);
|
|
30119
|
+
if (!owner || !row) return false;
|
|
30120
|
+
if (row.delivered) return true;
|
|
30121
|
+
try {
|
|
30122
|
+
const body = feedbackReportSchema.parse(JSON.parse(row.body));
|
|
30123
|
+
const result3 = await api.call("submitFeedback", { body });
|
|
30124
|
+
if (result3.id !== id2 || !["accepted", "duplicate"].includes(result3.status)) return false;
|
|
30125
|
+
state.db.prepare("UPDATE feedback_outbox SET delivered=1 WHERE id=? AND owner=?").run(id2, owner);
|
|
30126
|
+
return true;
|
|
30127
|
+
} catch {
|
|
30128
|
+
state.db.prepare("UPDATE feedback_outbox SET attempts=attempts+1,next_attempt_at=? WHERE id=? AND owner=?").run(Date.now() + Math.min(36e5, 6e4 * 2 ** Math.min(row.attempts, 6)), id2, owner);
|
|
30129
|
+
return false;
|
|
30130
|
+
}
|
|
30131
|
+
}
|
|
30132
|
+
var init_feedback_store = __esm({
|
|
30133
|
+
"src/feedback-store.ts"() {
|
|
30134
|
+
"use strict";
|
|
30135
|
+
init_api2();
|
|
30136
|
+
}
|
|
30137
|
+
});
|
|
30138
|
+
|
|
30139
|
+
// src/execution-reports.ts
|
|
30140
|
+
async function flushExecutionReports(api, state, budgetMs = 1e4) {
|
|
30141
|
+
const pending = state.pendingExecutionReports();
|
|
30142
|
+
if (!pending.length) return;
|
|
30143
|
+
const controller = new AbortController();
|
|
30144
|
+
let timer;
|
|
30145
|
+
try {
|
|
30146
|
+
const acknowledgment = await Promise.race([
|
|
30147
|
+
api.call("postExecutions", { body: { reports: pending.map((item) => item.report) }, signal: controller.signal }),
|
|
30148
|
+
new Promise((_, reject) => {
|
|
30149
|
+
timer = setTimeout(() => {
|
|
30150
|
+
controller.abort();
|
|
30151
|
+
reject(new Error("Report delivery deferred"));
|
|
30152
|
+
}, budgetMs);
|
|
30153
|
+
})
|
|
30154
|
+
]);
|
|
30155
|
+
state.acknowledgeExecutionReports(acknowledgment.results.map((item) => item.id));
|
|
30156
|
+
} catch {
|
|
30157
|
+
} finally {
|
|
30158
|
+
clearTimeout(timer);
|
|
30159
|
+
}
|
|
30160
|
+
}
|
|
30161
|
+
var init_execution_reports = __esm({
|
|
30162
|
+
"src/execution-reports.ts"() {
|
|
30163
|
+
"use strict";
|
|
30164
|
+
}
|
|
30165
|
+
});
|
|
30166
|
+
|
|
30167
|
+
// src/version.ts
|
|
30168
|
+
import { readFileSync } from "node:fs";
|
|
30169
|
+
var cliVersion;
|
|
30170
|
+
var init_version = __esm({
|
|
30171
|
+
"src/version.ts"() {
|
|
30172
|
+
"use strict";
|
|
30173
|
+
cliVersion = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
30174
|
+
}
|
|
30175
|
+
});
|
|
30176
|
+
|
|
30177
|
+
// src/session.ts
|
|
30178
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
30179
|
+
function apiSessionId(installationId, session) {
|
|
30180
|
+
if (!session) return void 0;
|
|
30181
|
+
const hex3 = createHash2("sha256").update("apilift-api-session/v1\0").update(installationId).update("\0").update(session.id).digest("hex");
|
|
30182
|
+
return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-5${hex3.slice(13, 16)}-a${hex3.slice(17, 20)}-${hex3.slice(20, 32)}`;
|
|
30183
|
+
}
|
|
30184
|
+
function agentSession(env, explicitLabel) {
|
|
30185
|
+
explicitLabel ??= env.APILIFT_SESSION;
|
|
30186
|
+
if (explicitLabel !== void 0 && !/^[A-Za-z0-9_-]{1,80}$/u.test(explicitLabel)) return null;
|
|
30187
|
+
const codex = env.CODEX_THREAD_ID || env.CODEX_SESSION_ID;
|
|
30188
|
+
const claude = env.CLAUDE_CODE_SESSION_ID;
|
|
30189
|
+
if (explicitLabel) {
|
|
30190
|
+
const agent2 = claude || env.CLAUDECODE ? "claude" : codex || env.CODEX_HOME ? "codex" : null;
|
|
30191
|
+
return agent2 ? { id: `${agent2}:label:${explicitLabel}`, agent: agent2 } : null;
|
|
30192
|
+
}
|
|
30193
|
+
if (codex && !claude) return { id: `codex:${codex}`, agent: "codex" };
|
|
30194
|
+
if (claude && !codex) return { id: `claude:${claude}`, agent: "claude" };
|
|
30195
|
+
return null;
|
|
30196
|
+
}
|
|
30197
|
+
function commandPrefix(label2) {
|
|
30198
|
+
return `apilift${label2 ? ` --session ${label2}` : ""}`;
|
|
30199
|
+
}
|
|
30200
|
+
var init_session = __esm({
|
|
30201
|
+
"src/session.ts"() {
|
|
30202
|
+
"use strict";
|
|
30203
|
+
}
|
|
30204
|
+
});
|
|
30205
|
+
|
|
30206
|
+
// src/commands/feedback.ts
|
|
30207
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
30208
|
+
import { constants, lstatSync, openSync, fstatSync, readSync, closeSync } from "node:fs";
|
|
30209
|
+
import { basename, resolve } from "node:path";
|
|
30210
|
+
import { platform } from "node:os";
|
|
30211
|
+
function prepare(state) {
|
|
30212
|
+
state.db.exec("CREATE TABLE IF NOT EXISTS consumer_execution_reference (id TEXT PRIMARY KEY, installation_id TEXT NOT NULL, session_id TEXT NOT NULL, app_id TEXT NOT NULL, app_slug TEXT NOT NULL, action_name TEXT NOT NULL, successful INTEGER NOT NULL)");
|
|
30213
|
+
}
|
|
30214
|
+
function rememberExecution(state, session, input2) {
|
|
30215
|
+
prepare(state);
|
|
30216
|
+
const installation = state.installation()?.id;
|
|
30217
|
+
if (!installation) return;
|
|
30218
|
+
state.db.prepare("INSERT OR IGNORE INTO consumer_execution_reference VALUES (?,?,?,?,?,?,?)").run(input2.id, installation, session.id, input2.appId, input2.appSlug, input2.actionName, Number(input2.successful));
|
|
30219
|
+
state.db.prepare("DELETE FROM consumer_execution_reference WHERE installation_id=? AND session_id=? AND rowid NOT IN (SELECT rowid FROM consumer_execution_reference WHERE installation_id=? AND session_id=? ORDER BY rowid DESC LIMIT 64)").run(installation, session.id, installation, session.id);
|
|
30220
|
+
}
|
|
30221
|
+
function readFeedbackAttachment(path2, ordinal) {
|
|
30222
|
+
const absolute = resolve(path2);
|
|
30223
|
+
if (!lstatSync(absolute).isFile()) throw new Error("Attachments must be regular files, not directories or symlinks.");
|
|
30224
|
+
const fd = openSync(absolute, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
30225
|
+
try {
|
|
30226
|
+
const stat2 = fstatSync(fd);
|
|
30227
|
+
if (!stat2.isFile() || stat2.size > 65536) throw new Error("Each attachment must be a regular text file of at most 64 KiB.");
|
|
30228
|
+
const bytes = Buffer.alloc(65537);
|
|
30229
|
+
let size = 0, read = 0;
|
|
30230
|
+
do {
|
|
30231
|
+
read = readSync(fd, bytes, size, bytes.length - size, null);
|
|
30232
|
+
size += read;
|
|
30233
|
+
} while (read && size < bytes.length);
|
|
30234
|
+
if (size > 65536) throw new Error("Attachment exceeds 64 KiB.");
|
|
30235
|
+
const text5 = new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size));
|
|
30236
|
+
if (!isFeedbackText(text5)) throw new Error("Attachments must contain plain UTF-8 text.");
|
|
30237
|
+
const name = basename(path2).replace(/[^A-Za-z0-9._-]/gu, "_").slice(0, 100);
|
|
30238
|
+
return { name: `${ordinal + 1}-${name || "evidence.txt"}`, text: text5 };
|
|
30239
|
+
} finally {
|
|
30240
|
+
closeSync(fd);
|
|
30241
|
+
}
|
|
30242
|
+
}
|
|
30243
|
+
async function handleFeedback(invocation, api, state, session) {
|
|
30244
|
+
const fail6 = (stderr, exitCode = 2) => ({ stdout: "", stderr: stderr + "\n", exitCode });
|
|
30245
|
+
const prefix2 = commandPrefix(invocation.sessionLabel);
|
|
30246
|
+
if (invocation.key === "feedback") return fail6(`Feedback syntax changed. Use ${prefix2} feedback report or ${prefix2} feedback action <app> <action> with --blocked, --repro, --expected and --actual. Add --incorrect for an incorrect result; do not repeat a write.`);
|
|
30247
|
+
prepareFeedback(state);
|
|
30248
|
+
let id2;
|
|
30249
|
+
if (invocation.key === "feedbackRetry") {
|
|
30250
|
+
id2 = invocation.positionals[0];
|
|
30251
|
+
if (!/^[0-9a-f-]{36}$/u.test(id2)) return fail6("Use feedback retry <report-id>.");
|
|
30252
|
+
const row = state.db.prepare("SELECT owner,registry FROM feedback_outbox WHERE id=?").get(id2);
|
|
30253
|
+
if (!row || row.registry !== api.cacheNamespace || row.owner !== null && row.owner !== feedbackOwner(state)) return fail6("No retained feedback belongs to this installation and registry.");
|
|
30254
|
+
if (!row.owner && feedbackOwner(state)) state.db.prepare("UPDATE feedback_outbox SET owner=? WHERE id=? AND owner IS NULL").run(feedbackOwner(state), id2);
|
|
30255
|
+
} else {
|
|
30256
|
+
const required2 = ["blocked", "repro", "expected", "actual"];
|
|
30257
|
+
const missing2 = required2.filter((name) => !invocation.options[name]?.trim());
|
|
30258
|
+
if (missing2.length) return fail6(`Missing ${missing2.map((name) => "--" + name).join(", ")}. Use short factual statements; do not reproduce a mutation for evidence.`);
|
|
30259
|
+
const paths2 = invocation.repeats.attach ?? [];
|
|
30260
|
+
if (paths2.length > 5) return fail6("Attach at most five text files.");
|
|
30261
|
+
let attachments;
|
|
30262
|
+
try {
|
|
30263
|
+
attachments = paths2.map(readFeedbackAttachment);
|
|
30264
|
+
} catch {
|
|
30265
|
+
return fail6("Could not read attachments. Use existing regular UTF-8 text files, no symlinks, at most 64 KiB each.");
|
|
30266
|
+
}
|
|
30267
|
+
let metadata = { cliVersion, platform: platform(), agent: session?.agent ?? "other", occurredAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
30268
|
+
if (invocation.options.from) {
|
|
30269
|
+
const retained = state.db.prepare("SELECT metadata FROM feedback_command WHERE id=? AND session_id=? AND owner IS ? AND registry=?").get(invocation.options.from, session?.id ?? "unbound", feedbackOwner(state), api.cacheNamespace);
|
|
30270
|
+
if (!retained) return fail6("No retained invocation belongs to this worker and installation. Omit --from to report observations without a command reference.");
|
|
30271
|
+
const original = feedbackMetadataSchema.parse(JSON.parse(retained.metadata));
|
|
30272
|
+
metadata = { ...metadata, invocation: original.invocation };
|
|
30273
|
+
}
|
|
30274
|
+
const action = invocation.key === "feedbackAction";
|
|
30275
|
+
let executionId = invocation.options.execution;
|
|
30276
|
+
if (action && (executionId || invocation.flags.includes("incorrect"))) {
|
|
30277
|
+
prepare(state);
|
|
30278
|
+
const [app2, name] = invocation.positionals;
|
|
30279
|
+
const row = state.db.prepare("SELECT id,successful FROM consumer_execution_reference WHERE installation_id=? AND session_id=? AND (app_id=? OR app_slug=?) AND action_name=? AND (? IS NULL OR id=?) ORDER BY rowid DESC LIMIT 1").get(state.installation()?.id ?? "", session?.id ?? "", app2, app2, name, executionId ?? null, executionId ?? null);
|
|
30280
|
+
if (!row || invocation.flags.includes("incorrect") && !row.successful) return fail6("No matching retained successful execution for incorrect-result feedback, or no owned execution for this reference. Omit the execution/incorrect options for a general action issue; never rerun a write.");
|
|
30281
|
+
executionId = row.id;
|
|
30282
|
+
}
|
|
30283
|
+
const candidate2 = {
|
|
30284
|
+
id: randomUUID2(),
|
|
30285
|
+
kind: action ? "action" : "apilift",
|
|
30286
|
+
...Object.fromEntries([...required2, "comment"].filter((k) => invocation.options[k] !== void 0).map((k) => [k, invocation.options[k]])),
|
|
30287
|
+
...action ? { app: invocation.positionals[0], action: invocation.positionals[1] } : {},
|
|
30288
|
+
...executionId ? { executionId } : {},
|
|
30289
|
+
...invocation.flags.includes("incorrect") ? { incorrectResult: true } : {},
|
|
30290
|
+
metadata,
|
|
30291
|
+
attachments
|
|
30292
|
+
};
|
|
30293
|
+
const parsed = feedbackReportSchema.safeParse(candidate2);
|
|
30294
|
+
if (!parsed.success) return fail6("Invalid feedback: use four nonempty fields of at most 2,000 characters each, a valid app/action target, and at most 256 KiB of text attachments.");
|
|
30295
|
+
const body = scrubFeedbackReport(parsed.data, [state.installation()?.token ?? ""]);
|
|
30296
|
+
if (!feedbackReportSchema.safeParse(body).success) return fail6("Sanitized feedback exceeds the field limits. Shorten the selected evidence.");
|
|
30297
|
+
try {
|
|
30298
|
+
id2 = retainFeedback(state, session, api.cacheNamespace, body);
|
|
30299
|
+
} catch {
|
|
30300
|
+
return fail6("Feedback could not be saved locally. Check local storage and retry retained reports if the queue is full.", 5);
|
|
30301
|
+
}
|
|
30302
|
+
}
|
|
30303
|
+
if (!state.installation()) return fail6(`Saved feedback ${id2} locally; not submitted. Link this installation, then run ${prefix2} feedback retry ${id2}.`, 9);
|
|
30304
|
+
await flushExecutionReports(api, state, 100);
|
|
30305
|
+
if (!await deliverFeedback(state, api, id2)) return fail6(`Saved feedback ${id2} locally; delivery pending. Do not resubmit. Retry with ${prefix2} feedback retry ${id2}. Continue independent safe work.`, 5);
|
|
30306
|
+
return { stdout: `Submitted feedback ${id2}.
|
|
30307
|
+
`, stderr: "", exitCode: 0 };
|
|
30308
|
+
}
|
|
30309
|
+
var init_feedback2 = __esm({
|
|
30310
|
+
"src/commands/feedback.ts"() {
|
|
30311
|
+
"use strict";
|
|
30312
|
+
init_execution_reports();
|
|
30313
|
+
init_api2();
|
|
30314
|
+
init_version();
|
|
30315
|
+
init_feedback_store();
|
|
30316
|
+
init_session();
|
|
30317
|
+
}
|
|
30318
|
+
});
|
|
30319
|
+
|
|
30320
|
+
// src/usage/receipts.ts
|
|
30321
|
+
function formatReceipt(id2) {
|
|
30322
|
+
return `[apilift receipt:${Buffer.from(id2.replaceAll("-", ""), "hex").toString("base64url")}]
|
|
30323
|
+
`;
|
|
30324
|
+
}
|
|
30325
|
+
var init_receipts = __esm({
|
|
30326
|
+
"src/usage/receipts.ts"() {
|
|
30327
|
+
"use strict";
|
|
30328
|
+
}
|
|
30329
|
+
});
|
|
30330
|
+
|
|
30331
|
+
// src/capture-server/windows-owner.ts
|
|
30332
|
+
import { Worker } from "node:worker_threads";
|
|
30333
|
+
function windowsProcessStart(pid, isAlive) {
|
|
30334
|
+
if (!worker) {
|
|
30335
|
+
memory = new SharedArrayBuffer(24);
|
|
30336
|
+
worker = new Worker(workerSource, { eval: true, workerData: { memory, script } });
|
|
30337
|
+
worker.on("error", () => {
|
|
30338
|
+
});
|
|
30339
|
+
worker.unref();
|
|
30340
|
+
}
|
|
30341
|
+
const state = new Int32Array(memory, 0, 4), value = new Float64Array(memory, 16, 1);
|
|
30342
|
+
const deadline = performance.now() + 8e3;
|
|
30343
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
30344
|
+
if (!isAlive()) return null;
|
|
30345
|
+
const remaining = deadline - performance.now();
|
|
30346
|
+
if (remaining <= 0) break;
|
|
30347
|
+
const id2 = ++sequence;
|
|
30348
|
+
Atomics.store(state, 1, id2);
|
|
30349
|
+
Atomics.store(state, 0, 1);
|
|
30350
|
+
worker.postMessage({ id: id2, pid });
|
|
30351
|
+
const result3 = Atomics.wait(state, 0, 1, Math.min(4e3, remaining));
|
|
30352
|
+
const status = Atomics.load(state, 0);
|
|
30353
|
+
if (status === 2) return Atomics.load(state, 2) === id2 && Number.isFinite(value[0]) && value[0] > 0 && isAlive() ? value[0] : null;
|
|
30354
|
+
if (result3 !== "timed-out" || status !== 1) break;
|
|
30355
|
+
}
|
|
30356
|
+
void worker.terminate();
|
|
30357
|
+
worker = void 0;
|
|
30358
|
+
return null;
|
|
30359
|
+
}
|
|
30360
|
+
var script, workerSource, worker, memory, sequence;
|
|
30361
|
+
var init_windows_owner = __esm({
|
|
30362
|
+
"src/capture-server/windows-owner.ts"() {
|
|
30363
|
+
"use strict";
|
|
30364
|
+
script = `$ErrorActionPreference='Stop'; while ($null -ne ($line=[Console]::ReadLine())) { $parts=$line.Split('|'); try { $p=[System.Diagnostics.Process]::GetProcessById([int]$parts[1]); $stamp=([DateTimeOffset]$p.StartTime.ToUniversalTime()).ToUnixTimeMilliseconds(); $p.Dispose() } catch { $stamp=0 }; [Console]::WriteLine($parts[0]+'|'+$stamp); [Console]::Out.Flush() }`;
|
|
30365
|
+
workerSource = `
|
|
30366
|
+
const {workerData}=require('node:worker_threads');
|
|
30367
|
+
const {spawn}=require('node:child_process');
|
|
30368
|
+
const state=new Int32Array(workerData.memory,0,4), value=new Float64Array(workerData.memory,16,1);
|
|
30369
|
+
const child=spawn('powershell.exe',['-NoLogo','-NoProfile','-NonInteractive','-Command',workerData.script],{windowsHide:true,stdio:['pipe','pipe','ignore']});
|
|
30370
|
+
const fail=()=>{Atomics.store(state,0,3);Atomics.notify(state,0);};
|
|
30371
|
+
child.on('error',fail);child.on('exit',fail);
|
|
30372
|
+
let text='';
|
|
30373
|
+
child.stdout.on('data',chunk=>{
|
|
30374
|
+
text+=chunk.toString();
|
|
30375
|
+
let end;
|
|
30376
|
+
while((end=text.indexOf('\\n'))>=0){
|
|
30377
|
+
const [id,stamp]=text.slice(0,end).trim().split('|').map(Number);text=text.slice(end+1);
|
|
30378
|
+
if(id!==Atomics.load(state,1)||Atomics.load(state,0)!==1)continue;
|
|
30379
|
+
value[0]=Number.isFinite(stamp)?stamp:0;Atomics.store(state,2,id);Atomics.store(state,0,2);Atomics.notify(state,0);
|
|
30380
|
+
}
|
|
30381
|
+
if(text.length>1024){child.kill();fail();}
|
|
30382
|
+
});
|
|
30383
|
+
const {parentPort}=require('node:worker_threads');
|
|
30384
|
+
parentPort.on('message',({id,pid})=>{try{child.stdin.write(id+'|'+pid+'\\n');}catch{fail();}});
|
|
30385
|
+
`;
|
|
30386
|
+
sequence = 0;
|
|
30387
|
+
}
|
|
30388
|
+
});
|
|
30389
|
+
|
|
30390
|
+
// ../../packages/protocol/dist/native.js
|
|
30391
|
+
function validateNativeFrameLength(byteLength, direction) {
|
|
30392
|
+
return Number.isInteger(byteLength) && byteLength >= 0 && byteLength <= (direction === "request" ? 512 * 1024 : 1024 * 1024);
|
|
30393
|
+
}
|
|
30394
|
+
var nativeProtocol, nativeOperationSchema, id, text2, url2, hash3, json2, empty2, scope, lease, scoped, base, request, requirement, credential, effect, candidate, bodyArtifact, inputChunk, preparedBinding, filePart, multipart, filePreparation, captureEntry, nativeRequestSchemas, requestUnion, nativeRequestSchema, identity, nativeHelloResultSchema, nativeScopesResultSchema, nativeCredentialStatusResultSchema, nativeJobSchema, claimResult, captureAck, blobAck, frozenWindow, nativeResultSchemas, nativeErrorSchema, nativeReplySchema, nativeAvailableSchema, nativeMessageSchema;
|
|
30395
|
+
var init_native = __esm({
|
|
30396
|
+
"../../packages/protocol/dist/native.js"() {
|
|
30397
|
+
"use strict";
|
|
30398
|
+
init_zod();
|
|
30399
|
+
nativeProtocol = "apilift.native/v1";
|
|
30400
|
+
nativeOperationSchema = external_exports.enum(["hello", "scopes", "candidates", "claim", "heartbeat", "permit", "window.open", "window.close", "capture.append", "blob.chunk", "jobs.poll", "jobs.body", "jobs.input", "jobs.deliver", "credentials.put", "credentials.status", "credentials.delete", "credentials.rename"]);
|
|
30401
|
+
id = external_exports.string().min(1).max(160);
|
|
30402
|
+
text2 = external_exports.string().min(1);
|
|
30403
|
+
url2 = external_exports.url().refine((value) => /^https?:\/\//.test(value), "Expected an http(s) URL");
|
|
30404
|
+
hash3 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
30405
|
+
json2 = external_exports.json();
|
|
30406
|
+
empty2 = external_exports.strictObject({});
|
|
30407
|
+
scope = external_exports.strictObject({ kind: external_exports.enum(["inspect", "execute", "capture"]), id });
|
|
30408
|
+
lease = { leaseId: id };
|
|
30409
|
+
scoped = { scope };
|
|
30410
|
+
base = { protocol: external_exports.literal(nativeProtocol), id };
|
|
30411
|
+
request = (operation2, payload, hasScope = false) => external_exports.strictObject({ ...base, ...hasScope ? scoped : {}, operation: external_exports.literal(operation2), payload });
|
|
30412
|
+
requirement = external_exports.strictObject({ name: text2, header: text2, prefix: external_exports.string().max(80).optional() });
|
|
30413
|
+
credential = { workspaceId: external_exports.uuid(), appId: external_exports.uuid(), appTitle: text2, transportName: text2, requirements: external_exports.array(requirement).max(16), draftId: external_exports.uuid().optional() };
|
|
30414
|
+
effect = external_exports.enum(["read", "create", "update", "delete"]);
|
|
30415
|
+
candidate = external_exports.strictObject({ selector: id, tabId: external_exports.number().int().positive(), active: external_exports.boolean(), title: external_exports.string().max(160) });
|
|
30416
|
+
bodyArtifact = external_exports.strictObject({ sha256: hash3, bytes: external_exports.number().int().nonnegative(), encoding: external_exports.literal("utf-8") });
|
|
30417
|
+
inputChunk = external_exports.strictObject({ offset: external_exports.number().int().nonnegative(), dataBase64: external_exports.string().max(240400), complete: external_exports.boolean() });
|
|
30418
|
+
preparedBinding = external_exports.strictObject({ $prepared: external_exports.string().max(2e3) });
|
|
30419
|
+
filePart = external_exports.strictObject({ sha256: hash3, bytes: external_exports.number().int().min(0).max(16 * 1024 * 1024), name: external_exports.string().min(1).max(180), contentType: external_exports.string().min(1).max(100) });
|
|
30420
|
+
multipart = external_exports.array(external_exports.union([external_exports.strictObject({ name: text2, value: external_exports.union([external_exports.string().max(65536), external_exports.number(), external_exports.boolean(), preparedBinding]) }), external_exports.strictObject({ name: text2, file: filePart })])).min(1).max(64);
|
|
30421
|
+
filePreparation = external_exports.strictObject({ resultPaths: external_exports.array(external_exports.string().max(512)).min(1).max(8).optional(), url: url2, headers: external_exports.record(external_exports.string(), external_exports.string()), response: external_exports.strictObject({ path: external_exports.string().optional(), fields: external_exports.record(external_exports.string(), external_exports.string()).optional() }), urlFrom: external_exports.string().optional(), query: external_exports.record(external_exports.string(), preparedBinding).optional(), headerBindings: external_exports.record(external_exports.string(), preparedBinding).optional() });
|
|
30422
|
+
captureEntry = external_exports.strictObject({
|
|
30423
|
+
captureId: id,
|
|
30424
|
+
transactionId: id,
|
|
30425
|
+
ts: external_exports.number(),
|
|
30426
|
+
label: text2,
|
|
30427
|
+
captureOperation: external_exports.strictObject({ entity: text2, operation: text2, effect }).nullable().optional(),
|
|
30428
|
+
captureInputs: json2.optional(),
|
|
30429
|
+
capturePhase: text2.optional(),
|
|
30430
|
+
page: external_exports.string().optional(),
|
|
30431
|
+
kind: text2,
|
|
30432
|
+
method: text2,
|
|
30433
|
+
url: external_exports.string(),
|
|
30434
|
+
reqHeaders: external_exports.record(external_exports.string(), external_exports.string()),
|
|
30435
|
+
reqBody: external_exports.string().nullable().optional(),
|
|
30436
|
+
reqBodyArtifact: bodyArtifact.optional(),
|
|
30437
|
+
status: external_exports.number().int().nullable(),
|
|
30438
|
+
resHeaders: external_exports.record(external_exports.string(), external_exports.string()),
|
|
30439
|
+
resBody: external_exports.string().nullable().optional(),
|
|
30440
|
+
resBodyArtifact: bodyArtifact.optional(),
|
|
30441
|
+
ms: external_exports.number().nullable(),
|
|
30442
|
+
error: external_exports.string().nullable(),
|
|
30443
|
+
pending: external_exports.boolean(),
|
|
30444
|
+
browserTiming: external_exports.strictObject({ started: external_exports.number().nullable(), finished: external_exports.number().nullable() }).optional(),
|
|
30445
|
+
recorderTiming: external_exports.strictObject({ admitted: external_exports.number(), processed: external_exports.number() }).optional(),
|
|
30446
|
+
reqBodyShape: external_exports.strictObject({ multipart: external_exports.array(external_exports.strictObject({ name: external_exports.string().max(128), type: external_exports.enum(["file", "string"]) })).max(64) }).optional(),
|
|
30447
|
+
reqBodyState: external_exports.string().optional(),
|
|
30448
|
+
resBodyState: external_exports.string().optional(),
|
|
30449
|
+
bodyUnavailable: external_exports.string().optional(),
|
|
30450
|
+
requestMaterialUnavailable: external_exports.string().optional(),
|
|
30451
|
+
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() })
|
|
30452
|
+
});
|
|
30453
|
+
nativeRequestSchemas = {
|
|
30454
|
+
hello: request("hello", external_exports.strictObject({ extensionId: text2, extensionVersion: text2, buildFingerprint: text2.optional(), capabilities: external_exports.array(text2) })),
|
|
30455
|
+
scopes: request("scopes", empty2),
|
|
30456
|
+
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),
|
|
30457
|
+
claim: request("claim", external_exports.strictObject({ ...lease, clientId: id, extensionId: text2, extensionVersion: text2, capabilities: external_exports.array(text2), tabId: external_exports.number().int().positive(), tabSelector: id, url: url2, origin: url2 }), true),
|
|
30458
|
+
heartbeat: request("heartbeat", external_exports.strictObject({ ...lease, clientId: id, extensionVersion: text2, capabilities: external_exports.array(text2), tabId: external_exports.number().int().positive().optional(), tabSelector: id.optional(), url: url2.optional(), origin: url2.optional(), walDepth: external_exports.number().int().nonnegative().optional(), attached: external_exports.boolean().optional(), detached: external_exports.boolean().optional(), gap: external_exports.string().optional(), lost: external_exports.boolean().optional() }), true),
|
|
30459
|
+
permit: request("permit", external_exports.strictObject({ ...lease, label: text2.optional(), entity: text2.optional(), operation: text2.optional(), effect: effect.optional(), inputs: json2.optional(), phase: text2.optional() }), true),
|
|
30460
|
+
"window.open": request("window.open", external_exports.strictObject({ ...lease, windowId: id, windowPermit: text2, label: text2, transactionId: id, captureOperation: external_exports.strictObject({ entity: text2, operation: text2, effect }).nullable().optional(), captureInputs: json2.optional(), capturePhase: text2.optional(), settleMs: external_exports.number().int().nonnegative().optional(), sequenceBefore: external_exports.number().int().nonnegative().optional() }), true),
|
|
30461
|
+
"window.close": request("window.close", external_exports.strictObject({ ...lease, windowId: id, transactionId: id, finalSequence: external_exports.number().int().nonnegative(), stoppedAt: external_exports.number().nonnegative().optional(), captured: external_exports.number().int().nonnegative().optional(), outcome: external_exports.strictObject({ executionState: external_exports.enum(["not-dispatched", "dispatched", "unknown"]).optional(), error: external_exports.string().optional() }).optional() }), true),
|
|
30462
|
+
"capture.append": request("capture.append", external_exports.strictObject({ ...lease, seq: external_exports.number().int().nonnegative(), entries: external_exports.array(captureEntry).max(32) }), true),
|
|
30463
|
+
"blob.chunk": request("blob.chunk", external_exports.strictObject({ ...lease, recording: id.optional(), jobId: id.optional(), sha256: hash3, bytes: external_exports.number().int().nonnegative(), offset: external_exports.number().int().nonnegative(), dataBase64: external_exports.string(), chunkSha256: hash3 }), true),
|
|
30464
|
+
"jobs.poll": request("jobs.poll", external_exports.strictObject({ ...lease, waitMs: external_exports.number().int().min(0).max(25e3), capabilities: external_exports.array(text2) }), true),
|
|
30465
|
+
"jobs.body": request("jobs.body", external_exports.strictObject({ ...lease, jobId: id, sha256: hash3, bytes: external_exports.number().int().nonnegative() }), true),
|
|
30466
|
+
"jobs.input": request("jobs.input", external_exports.strictObject({ ...lease, jobId: id, sha256: hash3, offset: external_exports.number().int().nonnegative() }), true),
|
|
30467
|
+
"jobs.deliver": request("jobs.deliver", external_exports.strictObject({ ...lease, jobId: id, result: json2 }), true),
|
|
30468
|
+
"credentials.put": request("credentials.put", external_exports.strictObject({ ...credential, name: text2, fields: external_exports.record(external_exports.string(), text2), sessionId: external_exports.string().min(1).max(256).regex(/^(?:codex|claude):\S+$/u).optional() })),
|
|
30469
|
+
"credentials.status": request("credentials.status", external_exports.strictObject(credential)),
|
|
30470
|
+
"credentials.delete": request("credentials.delete", external_exports.strictObject({ ...credential, credentialId: external_exports.uuid() })),
|
|
30471
|
+
"credentials.rename": request("credentials.rename", external_exports.strictObject({ ...credential, credentialId: external_exports.uuid(), name: text2 }))
|
|
30472
|
+
};
|
|
30473
|
+
requestUnion = external_exports.discriminatedUnion("operation", [nativeRequestSchemas.hello, nativeRequestSchemas.scopes, nativeRequestSchemas.candidates, nativeRequestSchemas.claim, nativeRequestSchemas.heartbeat, nativeRequestSchemas.permit, nativeRequestSchemas["window.open"], nativeRequestSchemas["window.close"], nativeRequestSchemas["capture.append"], nativeRequestSchemas["blob.chunk"], nativeRequestSchemas["jobs.poll"], nativeRequestSchemas["jobs.body"], nativeRequestSchemas["jobs.input"], nativeRequestSchemas["jobs.deliver"], nativeRequestSchemas["credentials.put"], nativeRequestSchemas["credentials.status"], nativeRequestSchemas["credentials.delete"], nativeRequestSchemas["credentials.rename"]]);
|
|
30474
|
+
nativeRequestSchema = requestUnion.superRefine((message2, context) => {
|
|
30475
|
+
if (!validateNativeFrameLength(new TextEncoder().encode(JSON.stringify(message2)).length, "request"))
|
|
30476
|
+
context.addIssue({ code: "custom", message: "Native request exceeds the 512 KiB limit" });
|
|
30477
|
+
if (message2.operation === "blob.chunk") {
|
|
30478
|
+
const encoded = message2.payload.dataBase64;
|
|
30479
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded) || atob(encoded).length > 176 * 1024)
|
|
30480
|
+
context.addIssue({ code: "custom", path: ["payload", "dataBase64"], message: "Blob chunk must be valid base64 of at most 176 KiB" });
|
|
30481
|
+
}
|
|
30482
|
+
});
|
|
30483
|
+
identity = external_exports.strictObject({ accountId: external_exports.uuid(), workspaceId: external_exports.uuid(), installationId: external_exports.uuid(), enabled: external_exports.boolean(), internal: external_exports.boolean(), environment: external_exports.enum(["production", "test", "disabled"]), projectKey: external_exports.string(), host: external_exports.string(), expiresAt: text2 });
|
|
30484
|
+
nativeHelloResultSchema = external_exports.strictObject({ hostVersion: text2, hostBuildFingerprint: text2, minimumHostVersion: text2.optional(), minimumExtensionVersion: text2, availableExtensionVersion: text2, capabilities: external_exports.array(text2), hostRestartRequired: external_exports.boolean(), identity: identity.optional() });
|
|
30485
|
+
nativeScopesResultSchema = external_exports.strictObject({ scopes: external_exports.array(external_exports.strictObject({ kind: external_exports.enum(["inspect", "execute", "capture"]), id, pageOrigin: url2, leaseId: id.optional(), tabSelector: id.optional(), startUrl: url2.optional(), bindingMode: external_exports.enum(["exact-existing-url", "installation-prefix"]).optional(), expiresAt: text2.optional(), window: json2.optional(), ackThrough: external_exports.number().int().nonnegative().optional(), activatedAt: external_exports.number().optional() })), identity: identity.optional() });
|
|
30486
|
+
nativeCredentialStatusResultSchema = external_exports.strictObject({ status: external_exports.enum(["configured", "missing"]), credentials: external_exports.array(external_exports.strictObject({ id: external_exports.uuid(), name: text2, fields: external_exports.array(text2) })) });
|
|
30487
|
+
nativeJobSchema = external_exports.discriminatedUnion("kind", [
|
|
30488
|
+
external_exports.strictObject({ id, kind: external_exports.literal("replay"), effect, method: external_exports.enum(["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]), url: url2, headers: external_exports.record(external_exports.string(), external_exports.string()), body: json2.optional(), multipart: multipart.optional(), anonymous: external_exports.boolean().optional(), fileResponse: external_exports.boolean().optional(), filePreparation: filePreparation.optional(), pageOrigin: url2, allowedRequestOrigin: url2, timeoutMs: external_exports.number().int().positive(), manualRedirects: external_exports.boolean().optional(), contextBaseUrl: url2.optional(), frame: external_exports.strictObject({ selector: text2, baseUrl: url2 }).optional(), credentialHeaderNames: external_exports.array(text2).optional(), authRecipeDefinition: json2.optional(), authRecipeId: text2.optional(), authRecipeHash: hash3.optional(), authRefresh: external_exports.boolean().optional(), semanticProvenance: external_exports.array(json2).optional() }),
|
|
30489
|
+
external_exports.strictObject({ id, kind: external_exports.literal("begin"), label: text2, entity: text2.optional(), operation: text2.optional(), effect: effect.optional(), inputs: json2.optional(), phase: text2.optional(), settleMs: external_exports.number().int().nonnegative().optional() }),
|
|
30490
|
+
external_exports.strictObject({ id, kind: external_exports.literal("stop"), windowId: id.optional() }),
|
|
30491
|
+
external_exports.strictObject({ id, kind: external_exports.literal("auth-probe"), captureId: id, field: text2.optional(), scope: json2.optional() })
|
|
30492
|
+
]);
|
|
30493
|
+
claimResult = external_exports.strictObject({ ackThrough: external_exports.number().int().nonnegative().optional(), captureBatchMax: external_exports.number().int().min(1).max(32).optional() });
|
|
30494
|
+
captureAck = external_exports.strictObject({ ackThrough: external_exports.number().int().nonnegative(), discardCaptures: external_exports.array(id).optional(), discardRecording: id.optional(), freezeRequired: id.optional() });
|
|
30495
|
+
blobAck = external_exports.strictObject({ offset: external_exports.number().int().nonnegative(), complete: external_exports.boolean() });
|
|
30496
|
+
frozenWindow = external_exports.strictObject({ state: external_exports.literal("frozen"), boundaryConfirmed: external_exports.boolean(), transactionId: id, captured: external_exports.number().int().nonnegative().optional() });
|
|
30497
|
+
nativeResultSchemas = {
|
|
30498
|
+
hello: nativeHelloResultSchema,
|
|
30499
|
+
scopes: nativeScopesResultSchema,
|
|
30500
|
+
candidates: empty2,
|
|
30501
|
+
claim: claimResult,
|
|
30502
|
+
heartbeat: claimResult,
|
|
30503
|
+
permit: external_exports.strictObject({ windowPermit: text2, label: text2.optional(), captureInputs: json2.optional(), capturePhase: text2.optional() }),
|
|
30504
|
+
"window.open": empty2,
|
|
30505
|
+
"window.close": frozenWindow,
|
|
30506
|
+
"capture.append": captureAck,
|
|
30507
|
+
"blob.chunk": blobAck,
|
|
30508
|
+
"jobs.poll": external_exports.union([nativeJobSchema, empty2]),
|
|
30509
|
+
"jobs.body": bodyArtifact,
|
|
30510
|
+
"jobs.input": inputChunk,
|
|
30511
|
+
"jobs.deliver": empty2,
|
|
30512
|
+
"credentials.put": nativeCredentialStatusResultSchema,
|
|
30513
|
+
"credentials.status": nativeCredentialStatusResultSchema,
|
|
30514
|
+
"credentials.delete": nativeCredentialStatusResultSchema,
|
|
30515
|
+
"credentials.rename": nativeCredentialStatusResultSchema
|
|
30516
|
+
};
|
|
30517
|
+
nativeErrorSchema = external_exports.strictObject({ code: text2, message: text2, exitCode: external_exports.number().int().optional(), next: external_exports.string().optional(), executionState: external_exports.enum(["not-dispatched", "dispatched", "unknown"]).optional() });
|
|
30518
|
+
nativeReplySchema = external_exports.discriminatedUnion("ok", [
|
|
30519
|
+
external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), id, ok: external_exports.literal(true), result: external_exports.union([nativeHelloResultSchema, nativeScopesResultSchema, nativeCredentialStatusResultSchema, nativeJobSchema, nativeResultSchemas.permit, nativeResultSchemas["capture.append"], claimResult, blobAck, frozenWindow, bodyArtifact, inputChunk, empty2]) }),
|
|
30520
|
+
external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), id, ok: external_exports.literal(false), error: nativeErrorSchema })
|
|
30521
|
+
]).refine((message2) => validateNativeFrameLength(new TextEncoder().encode(JSON.stringify(message2)).length, "response"), "Native response exceeds the 1 MiB limit");
|
|
30522
|
+
nativeAvailableSchema = external_exports.strictObject({ protocol: external_exports.literal(nativeProtocol), operation: external_exports.literal("available"), result: external_exports.strictObject({ kind: external_exports.enum(["jobs", "scopes"]) }) });
|
|
30523
|
+
nativeMessageSchema = external_exports.union([nativeRequestSchema, nativeReplySchema, nativeAvailableSchema]);
|
|
30524
|
+
}
|
|
30525
|
+
});
|
|
30526
|
+
|
|
30527
|
+
// ../../packages/protocol/dist/dashboard.js
|
|
30528
|
+
var dashboardProtocol, requirementSchema, intentBase, localSessionId, configureIntent, changeIntent, dashboardMessageSchema, dashboardStatusReplySchema, dashboardConfigureReplySchema;
|
|
30529
|
+
var init_dashboard = __esm({
|
|
30530
|
+
"../../packages/protocol/dist/dashboard.js"() {
|
|
30531
|
+
"use strict";
|
|
30532
|
+
init_zod();
|
|
30533
|
+
dashboardProtocol = "apilift.dashboard/v1";
|
|
30534
|
+
requirementSchema = external_exports.object({
|
|
30535
|
+
name: external_exports.string().regex(/^[a-z][a-z0-9_-]{0,63}$/),
|
|
30536
|
+
header: external_exports.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),
|
|
30537
|
+
prefix: external_exports.string().max(80).optional()
|
|
30538
|
+
}).strict();
|
|
30539
|
+
intentBase = external_exports.object({
|
|
30540
|
+
workspaceId: external_exports.uuid(),
|
|
30541
|
+
appId: external_exports.uuid(),
|
|
30542
|
+
appTitle: external_exports.string().min(1),
|
|
30543
|
+
transportName: external_exports.string().min(1),
|
|
30544
|
+
requirements: external_exports.array(requirementSchema).min(1).max(16),
|
|
30545
|
+
draftId: external_exports.uuid().optional()
|
|
30546
|
+
}).strict();
|
|
30547
|
+
localSessionId = external_exports.string().min(1).max(256).regex(/^(?:codex|claude):\S+$/u);
|
|
30548
|
+
configureIntent = intentBase.extend({ instructions: external_exports.string().min(1), sessionId: localSessionId.optional() });
|
|
30549
|
+
changeIntent = intentBase.extend({ credentialId: external_exports.uuid() });
|
|
30550
|
+
dashboardMessageSchema = external_exports.discriminatedUnion("operation", [
|
|
30551
|
+
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.configure"), intent: configureIntent }).strict(),
|
|
30552
|
+
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.status"), intent: intentBase }).strict(),
|
|
30553
|
+
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.delete"), intent: changeIntent }).strict(),
|
|
30554
|
+
external_exports.object({ protocol: external_exports.literal(dashboardProtocol), operation: external_exports.literal("credential.rename"), intent: changeIntent.extend({ name: external_exports.string().min(1) }) }).strict()
|
|
30555
|
+
]);
|
|
30556
|
+
dashboardStatusReplySchema = external_exports.object({
|
|
30557
|
+
ok: external_exports.literal(true),
|
|
30558
|
+
status: external_exports.enum(["configured", "missing"]),
|
|
30559
|
+
credentials: external_exports.array(external_exports.object({ id: external_exports.uuid(), name: external_exports.string(), fields: external_exports.array(external_exports.string()) }).strict())
|
|
30560
|
+
}).strict();
|
|
30561
|
+
dashboardConfigureReplySchema = external_exports.object({ ok: external_exports.literal(true), status: external_exports.literal("prompt-opened") }).strict();
|
|
30562
|
+
}
|
|
30563
|
+
});
|
|
30564
|
+
|
|
30565
|
+
// ../../packages/protocol/dist/extension.js
|
|
30566
|
+
var extensionProtocol, extensionPageMessageSchema;
|
|
30567
|
+
var init_extension = __esm({
|
|
30568
|
+
"../../packages/protocol/dist/extension.js"() {
|
|
30411
30569
|
"use strict";
|
|
30412
|
-
|
|
30413
|
-
|
|
30414
|
-
|
|
30415
|
-
|
|
30570
|
+
init_zod();
|
|
30571
|
+
extensionProtocol = "apilift.extension/v1";
|
|
30572
|
+
extensionPageMessageSchema = external_exports.discriminatedUnion("operation", [
|
|
30573
|
+
external_exports.object({
|
|
30574
|
+
protocol: external_exports.literal(extensionProtocol),
|
|
30575
|
+
operation: external_exports.literal("credential.store"),
|
|
30576
|
+
payload: external_exports.object({ intentId: external_exports.string().min(1), name: external_exports.string().min(1), fields: external_exports.record(external_exports.string(), external_exports.string()) }).strict()
|
|
30577
|
+
}).strict(),
|
|
30578
|
+
external_exports.object({
|
|
30579
|
+
protocol: external_exports.literal(extensionProtocol),
|
|
30580
|
+
operation: external_exports.literal("telemetry.control"),
|
|
30581
|
+
payload: external_exports.object({ stage: external_exports.enum(["popup_opened", "setup_link_clicked", "onboarding_opened", "credential_saved", "credential_failed"]) }).strict()
|
|
30582
|
+
}).strict()
|
|
30583
|
+
]);
|
|
30416
30584
|
}
|
|
30417
30585
|
});
|
|
30418
30586
|
|
|
30419
|
-
// ../../packages/
|
|
30420
|
-
|
|
30421
|
-
|
|
30422
|
-
|
|
30587
|
+
// ../../packages/protocol/dist/multipart.js
|
|
30588
|
+
function parseMultipart(body, contentType) {
|
|
30589
|
+
const boundary = /(?:^|;)\s*boundary=(?:"([^"\r\n]+)"|([^;\s]+))/iu.exec(contentType)?.slice(1).find(Boolean);
|
|
30590
|
+
if (!boundary || boundary.length > 200 || /[\r\n]/u.test(boundary))
|
|
30591
|
+
throw new Error("Multipart boundary is unavailable");
|
|
30592
|
+
const marker = "--" + boundary, parts2 = [];
|
|
30593
|
+
if (!body.startsWith(marker + "\r\n"))
|
|
30594
|
+
throw new Error("Multipart body is incomplete");
|
|
30595
|
+
let at = marker.length + 2;
|
|
30596
|
+
for (; ; ) {
|
|
30597
|
+
const end2 = body.indexOf("\r\n\r\n", at);
|
|
30598
|
+
if (end2 < 0 || end2 - at > 8192)
|
|
30599
|
+
throw new Error("Multipart headers are incomplete");
|
|
30600
|
+
const headers = body.slice(at, end2).split("\r\n");
|
|
30601
|
+
if (headers.some((header2) => !/^content-(?:disposition|type|transfer-encoding):/iu.test(header2)) || headers.some((header2) => /^content-transfer-encoding:/iu.test(header2)))
|
|
30602
|
+
throw new Error("Multipart headers are unsupported");
|
|
30603
|
+
const dispositions = headers.filter((header2) => /^content-disposition:/iu.test(header2));
|
|
30604
|
+
if (dispositions.length !== 1 || !/^content-disposition:\s*form-data(?:;|$)/iu.test(dispositions[0]))
|
|
30605
|
+
throw new Error("Multipart disposition is unavailable");
|
|
30606
|
+
const disposition = dispositions[0], name = /(?:^|;)\s*name="((?:[^"\\\r\n]|\\["\\])*)"/iu.exec(disposition)?.[1]?.replace(/\\(["\\])/gu, "$1");
|
|
30607
|
+
if (!name || name.length > 128)
|
|
30608
|
+
throw new Error("Multipart name is unavailable");
|
|
30609
|
+
const file3 = /(?:^|;)\s*filename(?:\*)?=/iu.test(disposition);
|
|
30610
|
+
const next2 = body.indexOf("\r\n" + marker, end2 + 4);
|
|
30611
|
+
if (next2 < 0)
|
|
30612
|
+
throw new Error("Multipart body is incomplete");
|
|
30613
|
+
const value = body.slice(end2 + 4, next2);
|
|
30614
|
+
if (!file3 && new TextEncoder().encode(value).length > 65536)
|
|
30615
|
+
throw new Error("Multipart scalar exceeds 65536 bytes");
|
|
30616
|
+
parts2.push({ name, value: file3 ? "" : value, file: file3 });
|
|
30617
|
+
if (parts2.length > 64)
|
|
30618
|
+
throw new Error("Multipart body exceeds 64 parts");
|
|
30619
|
+
at = next2 + 2 + marker.length;
|
|
30620
|
+
if (body.slice(at) === "--" || body.slice(at) === "--\r\n")
|
|
30621
|
+
return { boundary, parts: parts2 };
|
|
30622
|
+
if (body.slice(at, at + 2) !== "\r\n")
|
|
30623
|
+
throw new Error("Multipart body is incomplete");
|
|
30624
|
+
at += 2;
|
|
30625
|
+
}
|
|
30626
|
+
}
|
|
30627
|
+
var init_multipart = __esm({
|
|
30628
|
+
"../../packages/protocol/dist/multipart.js"() {
|
|
30423
30629
|
"use strict";
|
|
30424
|
-
init_schema();
|
|
30425
|
-
labels = ["AI", "Communication", "Sales & CRM", "Marketing", "Customer Support & Success", "Productivity & Collaboration", "Content, Design & Files", "Commerce", "Finance & Accounting", "Data & Analytics", "Developer & IT", "People & Learning", "Business Operations", "Legal, Risk & Compliance", "Other"];
|
|
30426
|
-
descriptions = [
|
|
30427
|
-
"General-purpose AI models, agents, assistants, and agent-building platforms.",
|
|
30428
|
-
"Email, messaging, SMS, telephony, video calls, and notifications.",
|
|
30429
|
-
"CRM, leads, contacts, sales intelligence, engagement, and revenue operations.",
|
|
30430
|
-
"Advertising, email marketing, social media, SEO, events, and referrals.",
|
|
30431
|
-
"Help desks, tickets, shared inboxes, customer success, and service feedback.",
|
|
30432
|
-
"Tasks, projects, calendars, scheduling, documents, knowledge bases, forms, and whiteboards.",
|
|
30433
|
-
"Cloud files, design, media, presentations, publishing, and creative review.",
|
|
30434
|
-
"Storefronts, products, orders, fulfillment, inventory, and shipping.",
|
|
30435
|
-
"Payments, billing, banking, accounting, invoices, tax, and expenses.",
|
|
30436
|
-
"Databases, warehouses, spreadsheets, BI, dashboards, and analytics.",
|
|
30437
|
-
"APIs, source control, CI/CD, testing, cloud, monitoring, security, and app building.",
|
|
30438
|
-
"HRIS, payroll, recruiting, performance, workforce management, LMS, and training.",
|
|
30439
|
-
"ERP, procurement, assets, facilities, field operations, and industry-specific operations.",
|
|
30440
|
-
"Contracts, electronic signatures, legal operations, GRC, privacy, audit, and compliance.",
|
|
30441
|
-
"Apps without a clear fit in the primary categories."
|
|
30442
|
-
];
|
|
30443
|
-
categories = categorySlugs.map((slug, index2) => ({ slug, label: labels[index2], description: descriptions[index2] }));
|
|
30444
30630
|
}
|
|
30445
30631
|
});
|
|
30446
30632
|
|
|
30447
|
-
// ../../packages/
|
|
30448
|
-
var
|
|
30449
|
-
"../../packages/
|
|
30633
|
+
// ../../packages/protocol/dist/index.js
|
|
30634
|
+
var init_dist = __esm({
|
|
30635
|
+
"../../packages/protocol/dist/index.js"() {
|
|
30450
30636
|
"use strict";
|
|
30451
|
-
|
|
30452
|
-
|
|
30453
|
-
|
|
30454
|
-
|
|
30455
|
-
init_analysis();
|
|
30456
|
-
init_metadata();
|
|
30457
|
-
init_categories();
|
|
30458
|
-
init_credential_contract();
|
|
30637
|
+
init_native();
|
|
30638
|
+
init_dashboard();
|
|
30639
|
+
init_extension();
|
|
30640
|
+
init_multipart();
|
|
30459
30641
|
}
|
|
30460
30642
|
});
|
|
30461
30643
|
|
|
30462
|
-
//
|
|
30463
|
-
|
|
30464
|
-
|
|
30465
|
-
|
|
30466
|
-
|
|
30467
|
-
|
|
30468
|
-
|
|
30469
|
-
return
|
|
30644
|
+
// src/capture-server/store.ts
|
|
30645
|
+
import { constants as constants2, mkdirSync, chmodSync, readFileSync as readFileSync2, openSync as openSync2, closeSync as closeSync2, readSync as readSync2, writeSync, ftruncateSync, fsyncSync, statSync, rmSync as rmSync2 } from "node:fs";
|
|
30646
|
+
import { execFileSync } from "node:child_process";
|
|
30647
|
+
import { DatabaseSync } from "node:sqlite";
|
|
30648
|
+
function createOwnerVerifier(probe = {}) {
|
|
30649
|
+
const cached2 = /* @__PURE__ */ new Map();
|
|
30650
|
+
const alive = probe.alive ?? pidAlive, now = probe.now ?? Date.now;
|
|
30651
|
+
return (pid, startedAt, fresh = false) => {
|
|
30652
|
+
if (!Number.isInteger(pid) || pid <= 0 || !Number.isFinite(startedAt) || !alive(pid)) {
|
|
30653
|
+
cached2.delete(pid);
|
|
30654
|
+
return false;
|
|
30655
|
+
}
|
|
30656
|
+
if ((probe.platform ?? process.platform) === "linux") return inspectOwner(pid, startedAt, probe);
|
|
30657
|
+
const prior = cached2.get(pid), time3 = now();
|
|
30658
|
+
if (!fresh && prior && prior.startedAt === startedAt && time3 >= prior.checkedAt && time3 - prior.checkedAt < 2e3) return true;
|
|
30659
|
+
cached2.delete(pid);
|
|
30660
|
+
if (!inspectOwner(pid, startedAt, probe)) return false;
|
|
30661
|
+
if (cached2.size >= 256) cached2.delete(cached2.keys().next().value);
|
|
30662
|
+
cached2.set(pid, { startedAt, checkedAt: now() });
|
|
30663
|
+
return true;
|
|
30664
|
+
};
|
|
30470
30665
|
}
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
|
|
30666
|
+
function ownerProcessAlive(pid, expectedStartedAt, probe) {
|
|
30667
|
+
return typeof probe === "object" ? inspectOwner(pid, expectedStartedAt, probe) : defaultOwnerVerifier(pid, expectedStartedAt, probe);
|
|
30668
|
+
}
|
|
30669
|
+
function inspectOwner(pid, expectedStartedAt, probe) {
|
|
30670
|
+
if (!Number.isInteger(pid) || pid <= 0 || !Number.isFinite(expectedStartedAt)) return false;
|
|
30671
|
+
const alive = probe.alive ?? pidAlive;
|
|
30672
|
+
const inspect2 = probe.inspect ?? inspectProcess;
|
|
30673
|
+
const platform5 = probe.platform ?? process.platform;
|
|
30674
|
+
const now = probe.now ?? Date.now;
|
|
30675
|
+
const started = now();
|
|
30676
|
+
const windows = platform5 === "win32";
|
|
30677
|
+
if (platform5 === "linux") {
|
|
30678
|
+
try {
|
|
30679
|
+
const read = probe.read ?? ((path2) => readFileSync2(path2, "utf8"));
|
|
30680
|
+
const stat2 = read(`/proc/${pid}/stat`), fields = stat2.slice(stat2.lastIndexOf(")") + 2).trim().split(/\s+/u);
|
|
30681
|
+
if (["Z", "X"].includes(fields[0])) return false;
|
|
30682
|
+
const ticks = Number(fields[19]), boot = Number(/^btime (\d+)$/mu.exec(read("/proc/stat"))?.[1]);
|
|
30683
|
+
const hz = probe.inspect ? Number(inspect2("getconf", ["CLK_TCK"], 2e3)) : linuxClockTicks ??= Number(inspect2("getconf", ["CLK_TCK"], 2e3));
|
|
30684
|
+
const observed = boot * 1e3 + ticks * 1e3 / hz;
|
|
30685
|
+
return Number.isFinite(observed) && hz > 0 && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
30686
|
+
} catch {
|
|
30687
|
+
return false;
|
|
30688
|
+
}
|
|
30689
|
+
}
|
|
30690
|
+
if (windows && !probe.inspect) {
|
|
30691
|
+
const observed = windowsProcessStart(pid, () => alive(pid));
|
|
30692
|
+
return observed !== null && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
30693
|
+
}
|
|
30694
|
+
for (let attempt = 0; attempt < (windows ? 2 : 1); attempt++) {
|
|
30695
|
+
if (!alive(pid)) return false;
|
|
30696
|
+
const remaining = windows ? 8e3 - (now() - started) : 2e3;
|
|
30697
|
+
if (remaining <= 0) return false;
|
|
30698
|
+
try {
|
|
30699
|
+
const raw = windows ? inspect2("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().ToString('o')`], Math.min(4e3, remaining)) : inspect2("ps", ["-o", "lstart=", "-p", String(pid)], 2e3);
|
|
30700
|
+
const observed = Date.parse(windows ? raw.trim() : `${raw.trim()} UTC`);
|
|
30701
|
+
return Number.isFinite(observed) && Math.abs(observed - expectedStartedAt) <= 5e3;
|
|
30702
|
+
} catch (error62) {
|
|
30703
|
+
if (!windows || error62.code !== "ETIMEDOUT") return false;
|
|
30704
|
+
}
|
|
30705
|
+
}
|
|
30706
|
+
return false;
|
|
30707
|
+
}
|
|
30708
|
+
var pidAlive, inspectProcess, linuxClockTicks, defaultOwnerVerifier;
|
|
30709
|
+
var init_store = __esm({
|
|
30710
|
+
"src/capture-server/store.ts"() {
|
|
30474
30711
|
"use strict";
|
|
30475
|
-
|
|
30476
|
-
|
|
30477
|
-
|
|
30478
|
-
|
|
30479
|
-
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30483
|
-
|
|
30484
|
-
agent = external_exports.enum(["codex", "claude", "other"]);
|
|
30485
|
-
knownAgent = external_exports.enum(["codex", "claude"]);
|
|
30486
|
-
path = external_exports.strictObject({ app: str });
|
|
30487
|
-
actionPath = path.extend({ action: str });
|
|
30488
|
-
resourcePath = path.extend({ kind: resourceKindSchema, name: str });
|
|
30489
|
-
pageQuery = { cursor: str.optional(), limit: external_exports.coerce.number().int().min(1).max(100).default(50) };
|
|
30490
|
-
kindName = external_exports.strictObject({ kind: resourceKindSchema, name: str });
|
|
30491
|
-
definition = external_exports.union([definitionSchemas.app, definitionSchemas.entity, definitionSchemas.action, definitionSchemas.transport, definitionSchemas["browser-context"]]);
|
|
30492
|
-
readinessMachine = external_exports.strictObject({ nativeHostReady: external_exports.boolean().optional(), nativeHostVersion: str.optional(), extensionReady: external_exports.boolean().optional(), extensionVersion: str.optional() });
|
|
30493
|
-
readinessAgent = external_exports.strictObject({ skillsReady: external_exports.boolean().optional(), skillsVersion: str.optional(), browserReady: external_exports.boolean().optional(), verified: external_exports.boolean().optional(), verifiedAt: iso.optional() });
|
|
30494
|
-
releaseComponent = external_exports.strictObject({ version: str, sourceSha: str, minimum: external_exports.record(external_exports.string(), str) });
|
|
30495
|
-
releaseState = external_exports.strictObject({ release: str, components: external_exports.strictObject({ cli: releaseComponent, extension: releaseComponent.extend({ storeVersion: str.optional() }), web: releaseComponent }) });
|
|
30496
|
-
appItem = external_exports.strictObject({ id: uuid5, slug: str, title: str, summary: external_exports.string(), origin: str, category: categorySchema, visibility: external_exports.enum(["public", "private"]), status: external_exports.enum(["building", "active", "restricted"]), iconUrl: str.nullable(), actionCount: external_exports.number().int().nonnegative(), entityCount: external_exports.number().int().nonnegative(), updatedAt: iso });
|
|
30497
|
-
entitlement = external_exports.strictObject({ plan: external_exports.enum(["free", "pro", "cloud"]), source: external_exports.enum(["subscription", "trial", "free"]), features: external_exports.array(str), trialEndsAt: iso.optional(), graceEndsAt: iso.optional() });
|
|
30498
|
-
readiness = external_exports.strictObject({ machine: readinessMachine, agents: external_exports.record(external_exports.string(), readinessAgent) });
|
|
30499
|
-
me = external_exports.strictObject({ account: external_exports.strictObject({ id: uuid5, email: str, name: str, status: external_exports.literal("active") }), workspace: external_exports.strictObject({ id: uuid5, name: str, role: external_exports.literal("owner"), preferences: external_exports.strictObject({ defaultVisibility: external_exports.enum(["public", "private"]), communityChannel: external_exports.enum(["latest", "validated"]), effective: data }) }), installation: external_exports.strictObject({ id: uuid5, label: str, agents: external_exports.array(external_exports.enum(["codex", "claude"])) }), entitlement, analytics: external_exports.strictObject({ enabled: external_exports.boolean(), distinctId: str, environment: external_exports.enum(["production", "test", "disabled"]), internal: external_exports.boolean(), projectKey: external_exports.string(), host: external_exports.string() }), compatibility: external_exports.strictObject({ minimum: external_exports.strictObject({ cli: str, extension: str }), latest: external_exports.strictObject({ cli: str, extension: str }) }) });
|
|
30500
|
-
setupStatus = external_exports.strictObject({ linkCode: external_exports.strictObject({ id: uuid5, agent: knownAgent.nullable(), status: external_exports.enum(["pending", "claimed", "expired"]), expiresAt: iso, installationId: uuid5.nullable() }).nullable(), installation: external_exports.strictObject({ id: uuid5, label: str, readiness, steps: data, agents: external_exports.array(knownAgent) }).nullable() });
|
|
30501
|
-
actionSummary = external_exports.strictObject({ name: str, title: str, summary: external_exports.string(), effect: external_exports.enum(["read", "create", "update", "delete"]).optional(), availability: external_exports.enum(["executable", "unavailable"]), policy: external_exports.enum(["approve", "deny", "disable"]), health: data, documentation: data.optional() });
|
|
30502
|
-
actionDocumentation = external_exports.strictObject({ name: str, title: str, description: external_exports.string(), details: external_exports.string().optional(), effect: external_exports.enum(["read", "create", "update", "delete"]).optional(), availability: external_exports.enum(["executable", "unavailable"]), inputs: jsonSchema, output: jsonSchema.optional(), observedOutput: jsonSchema.optional(), verificationScope: external_exports.unknown().optional(), proof: external_exports.enum(["readback", "absence"]).optional(), unavailable: external_exports.strictObject({ reason: str, evidence: str }).optional(), transport: external_exports.strictObject({ name: str, mode: external_exports.enum(["direct", "browser"]), instructions: str, credentials: external_exports.array(external_exports.strictObject({ name: str, header: str })) }).optional(), version: external_exports.number().int().positive(), executableHash: hash3.optional(), policy: external_exports.enum(["approve", "deny", "disable"]), health: data });
|
|
30503
|
-
bundle = external_exports.strictObject({ suggestTest: external_exports.literal(true).optional(), receipt: external_exports.strictObject({ id: uuid5, dispatchBefore: iso }).optional(), decision: external_exports.literal("allow"), app: external_exports.strictObject({ id: uuid5, slug: str, visibility: external_exports.enum(["public", "private"]) }), action: external_exports.strictObject({ name: str, effect: external_exports.enum(["read", "create", "update", "delete"]) }), closure: external_exports.strictObject({ hash: hash3, status: external_exports.enum(["pending", "validated"]), workspaceStatus: external_exports.literal("successful").nullable(), versions: external_exports.array(external_exports.strictObject({ kind: resourceKindSchema, name: str, version: external_exports.number().int().positive(), executableHash: hash3, versionId: uuid5.optional(), definition: definition.optional() })) }), selection: external_exports.strictObject({ channel: external_exports.enum(["latest", "validated"]), fallback: external_exports.boolean(), replaced: external_exports.strictObject({ closureHash: hash3, reason: str, until: iso.optional() }).optional() }), policy: external_exports.literal("approve") });
|
|
30504
|
-
resourceRead = external_exports.strictObject({ ...kindName.shape, definition, version: external_exports.number().int().positive(), executableHash: hash3.optional(), verification: data.optional(), dependents: external_exports.array(kindName).optional(), nextDependentsCursor: external_exports.string().nullable().optional() });
|
|
30505
|
-
resourceRequirements = external_exports.strictObject({ legacyCredentialContract: str.optional(), credentialContract: str.optional(), destinations: external_exports.array(str).optional(), name: str, title: str, mode: external_exports.enum(["direct", "browser"]), instructions: str, credentials: external_exports.array(external_exports.strictObject({ name: str, header: str, prefix: external_exports.string().optional() })), revision: external_exports.strictObject({ credentialContractHash: hash3.optional(), canRecreate: external_exports.boolean() }).optional() });
|
|
30506
|
-
safetyReview = external_exports.union([external_exports.strictObject({ access: external_exports.literal("locked") }), external_exports.strictObject({ access: external_exports.literal("included"), state: external_exports.enum(["missing", "checking", "ready", "unavailable"]), route: str, findings: data.optional(), checkedAt: iso.optional(), stale: external_exports.boolean().optional(), message: external_exports.string().optional() })]);
|
|
30507
|
-
billing = external_exports.strictObject({ workspaceId: uuid5, paddleCustomerId: str.optional(), entitlement, trial: external_exports.strictObject({ status: external_exports.enum(["active", "ended", "converted"]), startedAt: iso, endsAt: iso, completedAt: iso.optional() }).optional(), subscription: external_exports.strictObject({ id: str, status: str, plan: str, interval: str, currency: str, currentPeriod: external_exports.strictObject({ startsAt: iso, endsAt: iso }), nextBilledAt: iso.optional(), graceEndsAt: iso.optional(), scheduledChange: data.optional() }).optional(), usage: data.optional(), checkout: external_exports.strictObject({ status: external_exports.enum(["pending", "unknown"]), transactionId: str.optional() }).optional(), checkoutAvailable: external_exports.boolean(), paddle: external_exports.strictObject({ environment: external_exports.enum(["sandbox", "production"]), clientToken: str }) });
|
|
30508
|
-
executionFeedbackSchema = external_exports.strictObject({ kind: external_exports.literal("semantic-incorrect") });
|
|
30509
|
-
executionReportSchema = external_exports.strictObject({ id: uuid5, receiptId: uuid5.optional(), appId: uuid5, actionName: str, actionVersion: external_exports.number().int().positive(), closureHash: hash3, purpose: external_exports.enum(["run", "verify"]), clientFamily: external_exports.enum(["cli", "discovery"]), agent, outcome: external_exports.enum(["caller-error", "credential-error", "rate-limit", "app-outage", "interface-error", "uncertain", "network-error", "success", "cancelled"]), diagnostic: external_exports.enum(["operation-unavailable", "response-contract", "proof-failed"]).optional(), httpStatus: external_exports.number().int().optional(), proof: external_exports.enum(["passed", "failed", "unavailable"]).optional(), semanticConfirmed: external_exports.boolean().optional(), connectionFingerprint: hash3.optional(), startedAt: iso, dispatchedAt: iso.optional(), finishedAt: iso });
|
|
30510
|
-
sharedMeasure = { durationMs: external_exports.number().min(0).max(864e5).nullable(), tokens: external_exports.strictObject({ input: external_exports.number().min(0).max(1e8), output: external_exports.number().min(0).max(1e8) }).nullable(), coverage: external_exports.enum(["final", "partial", "unavailable"]), timeCoverage: external_exports.enum(["final", "partial", "unavailable"]), provider: external_exports.enum(["openai", "anthropic", "bedrock", "vertex", "custom"]).nullable(), model: external_exports.string().max(120).regex(/^[A-Za-z0-9._<>[\]:/@-]+$/).nullable() };
|
|
30511
|
-
CAPTURE_ATTRIBUTION_POLICY = "capture-attribution-v2";
|
|
30512
|
-
MAX_CAPTURE_PUBLICATION_WITNESSES = 4096;
|
|
30513
|
-
publicationWitness = external_exports.strictObject({ name: str, version: external_exports.number().int().positive(), requestId: uuid5 });
|
|
30514
|
-
executionMeasurementSchema = external_exports.strictObject({ id: uuid5, executionId: uuid5, revision: external_exports.number().int().positive(), purpose: external_exports.enum(["productive", "discovery", "verification", "setup", "unknown"]), session: hash3.nullable(), worker: hash3.nullable(), policy: external_exports.literal(CAPTURE_ATTRIBUTION_POLICY).optional(), ...sharedMeasure });
|
|
30515
|
-
baselineSampleSchema = external_exports.strictObject({ id: uuid5, revision: external_exports.number().int().positive(), appId: uuid5, actionName: str.nullable(), executableHash: hash3.nullable(), method: external_exports.enum(["browser", "direct"]).nullable(), publishedAction: publicationWitness.omit({ requestId: true }).optional(), policy: external_exports.literal(CAPTURE_ATTRIBUTION_POLICY).optional(), kind: external_exports.enum(["action", "preparation"]).optional(), publications: external_exports.array(publicationWitness).min(1).max(MAX_CAPTURE_PUBLICATION_WITNESSES).optional(), completeness: external_exports.enum(["complete", "prefix"]), occurredAt: iso, ...sharedMeasure });
|
|
30516
|
-
executionAcknowledgement = external_exports.strictObject({ results: external_exports.array(external_exports.strictObject({ id: uuid5, status: external_exports.enum(["accepted", "duplicate", "rejected"]), code: str.optional() })) });
|
|
30517
|
-
measurementAcknowledgement = external_exports.strictObject({ results: external_exports.array(external_exports.strictObject({ id: uuid5, revision: external_exports.number().int().positive(), status: external_exports.enum(["accepted", "duplicate", "pending", "rejected"]), code: str.optional() })) });
|
|
30518
|
-
noParams = empty2;
|
|
30519
|
-
noQuery = empty2;
|
|
30520
|
-
noBody = empty2;
|
|
30521
|
-
EXECUTION_TEST_HINT_CAPABILITY = "execution-test-hint-v1";
|
|
30522
|
-
COMPLETE_RESOURCE_PUBLICATION_CAPABILITY = "complete-resource-publication-v1";
|
|
30523
|
-
resourcePublicationSchema = external_exports.strictObject({ kind: resourceKindSchema, name: str, requestId: uuid5, expectedVersion: external_exports.number().int().positive().nullable(), definition: external_exports.unknown(), verification: data.optional() });
|
|
30524
|
-
resourcePublicationResultSchema = external_exports.strictObject({ attribution: external_exports.strictObject({ method: external_exports.enum(["browser", "direct"]), baseUrl: requestUrlSchema.optional() }).optional(), resource: external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive() }), executableHash: hash3.optional(), closureHash: hash3.optional(), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional() });
|
|
30525
|
-
resourceBatchSchema = external_exports.strictObject({ mode: external_exports.literal("complete-replacement").optional(), resources: external_exports.array(resourcePublicationSchema).min(1).max(128) }).refine((value) => new Set(value.resources.map((r) => `${r.kind}:${r.name}`)).size === value.resources.length, "Select each resource once").refine((value) => new Set(value.resources.map((r) => r.requestId)).size === value.resources.length, "Use distinct resource request ids");
|
|
30526
|
-
page = (item) => external_exports.strictObject({ items: external_exports.array(item), nextCursor: str.nullable().optional() });
|
|
30527
|
-
apiContracts = {
|
|
30528
|
-
executionFeedback: apiContract("POST", "/api/v1/executions/{executionId}/feedback", "installation", external_exports.strictObject({ executionId: uuid5 }), noQuery, executionFeedbackSchema, external_exports.strictObject({ status: external_exports.enum(["accepted", "duplicate"]) }), ["execution-not-found"]),
|
|
30529
|
-
publishResources: apiContract("PUT", "/api/v1/apps/{app}/resources", "installation", external_exports.strictObject({ app: str }), noQuery, resourceBatchSchema, external_exports.strictObject({ results: external_exports.array(external_exports.union([
|
|
30530
|
-
external_exports.strictObject({ kind: resourceKindSchema, name: str, status: external_exports.enum(["published", "unchanged"]), publication: resourcePublicationResultSchema, currentVersion: external_exports.number().int().positive().nullable().optional() }),
|
|
30531
|
-
external_exports.strictObject({ kind: resourceKindSchema, name: str, status: external_exports.enum(["failed", "blocked"]), error: apiErrorSchema })
|
|
30532
|
-
])) })),
|
|
30533
|
-
createInstallation: apiContract("POST", "/api/v1/installations", "none", noParams, noQuery, external_exports.strictObject({ code: str, agent: knownAgent, machine: external_exports.strictObject({ label: external_exports.string().max(80), os: str, arch: str }) }), external_exports.strictObject({ installation: external_exports.strictObject({ id: uuid5 }), token: str, account: external_exports.strictObject({ id: uuid5, email: str, name: str }), workspace: external_exports.strictObject({ id: uuid5, name: str }), agent: knownAgent, mode: external_exports.literal("attached"), onboardingAttemptId: uuid5 }), ["link-code-invalid", "link-code-expired", "link-code-used"]),
|
|
30534
|
-
attachAgent: apiContract("POST", "/api/v1/installation/agents", "installation", noParams, noQuery, external_exports.strictObject({ code: str, agent: knownAgent }), external_exports.strictObject({ installation: external_exports.strictObject({ id: uuid5 }), account: external_exports.strictObject({ id: uuid5, email: str, name: str }), workspace: external_exports.strictObject({ id: uuid5, name: str }), agent: knownAgent, mode: external_exports.enum(["attached", "reconnected"]), onboardingAttemptId: uuid5 }), ["link-account-mismatch", "link-agent-mismatch"]),
|
|
30535
|
-
updateReadiness: apiContract("PUT", "/api/v1/installation/readiness", "installation", noParams, noQuery, external_exports.strictObject({ machine: readinessMachine.optional(), agent: knownAgent.optional(), agentState: readinessAgent.optional() }), external_exports.strictObject({ machine: readinessMachine, agents: external_exports.record(external_exports.string(), readinessAgent), steps: data.optional() }), ["readiness-incomplete"]),
|
|
30536
|
-
me: apiContract("GET", "/api/v1/me", "installation", noParams, noQuery, noBody, me),
|
|
30537
|
-
setupStatus: apiContract("GET", "/api/v1/setup-status", "cookie", noParams, external_exports.strictObject({ linkCode: uuid5.optional(), installation: uuid5.optional(), agent: knownAgent.optional() }), noBody, setupStatus),
|
|
30538
|
-
acquireSession: apiContract("PUT", "/api/v1/sessions/{id}", "installation", external_exports.strictObject({ id: str }), noQuery, external_exports.strictObject({ purpose: external_exports.enum(["execution", "discovery"]), appId: uuid5.optional() }), data, ["session-limit"]),
|
|
30539
|
-
releaseSession: apiContract("DELETE", "/api/v1/sessions/{id}", "installation", external_exports.strictObject({ id: str }), external_exports.strictObject({ appId: uuid5.optional(), purpose: external_exports.literal("execution").optional() }).refine((v) => Boolean(v.appId) === Boolean(v.purpose), "appId and purpose must be supplied together"), noBody, data),
|
|
30540
|
-
listApps: apiContract("GET", "/api/v1/apps", "installation-or-cookie", noParams, external_exports.strictObject({ q: external_exports.string().max(200).optional(), domain: str.optional(), category: categorySchema.optional(), visibility: external_exports.enum(["public", "private", "all"]).optional(), ids: str.optional(), ...pageQuery }), noBody, page(appItem)),
|
|
30541
|
-
createApp: apiContract("POST", "/api/v1/apps", "installation", noParams, noQuery, external_exports.strictObject({ requestId: uuid5, slug: str, visibility: external_exports.enum(["public", "private"]).optional(), definition: appDefinitionSchema }), data, ["slug-taken"]),
|
|
30542
|
-
getApp: apiContract("GET", "/api/v1/apps/{app}", "installation-or-cookie", path, external_exports.strictObject({ entity: str.optional(), entityCursor: str.optional(), transportCursor: str.optional(), limit: pageQuery.limit }), noBody, appItem.extend({ about: external_exports.string().optional(), safety: data.optional(), entities: external_exports.array(data), transports: external_exports.array(data), nextEntityCursor: str.nullable().optional(), nextTransportCursor: str.nullable().optional() })),
|
|
30543
|
-
listActions: apiContract("GET", "/api/v1/apps/{app}/actions", "installation-or-cookie", path, external_exports.strictObject({ entity: str.optional(), q: external_exports.string().max(200).optional(), names: str.optional(), include: external_exports.literal("documentation").optional(), ...pageQuery }), noBody, page(actionSummary)),
|
|
30544
|
-
getAction: apiContract("GET", "/api/v1/apps/{app}/actions/{action}", "installation-or-cookie", actionPath, external_exports.strictObject({ include: external_exports.literal("schemas").optional() }), noBody, actionDocumentation),
|
|
30545
|
-
getBundle: apiContract("GET", "/api/v1/apps/{app}/actions/{action}/bundle", "installation", actionPath, external_exports.strictObject({ knownVersions: external_exports.string().max(120).optional() }), noBody, bundle, ["session-limit", "action-withheld", "action-disabled", "action-denied", "action-unavailable"]),
|
|
30546
|
-
listResources: apiContract("GET", "/api/v1/apps/{app}/resources", "installation", path, external_exports.strictObject({ kind: resourceKindSchema.optional(), names: str.optional(), ...pageQuery }), noBody, page(external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive(), executableHash: hash3.optional(), updatedAt: iso })).extend({ capabilities: external_exports.array(str).optional() })),
|
|
30547
|
-
getResource: apiContract("GET", "/api/v1/apps/{app}/resources/{kind}/{name}", "installation-or-cookie", resourcePath, external_exports.strictObject({ view: external_exports.enum(["requirements", "authoring"]).optional(), dependentsCursor: external_exports.string().optional() }), noBody, external_exports.union([resourceRead, resourceRequirements])),
|
|
30548
|
-
publishResource: apiContract("PUT", "/api/v1/apps/{app}/resources/{kind}/{name}", "installation", resourcePath, noQuery, external_exports.union([external_exports.strictObject({ requestId: uuid5, expectedVersion: external_exports.number().int().positive().nullable(), definition, verification: data.optional() }), external_exports.strictObject({ requestId: uuid5, expectedVersion: external_exports.number().int().positive(), remove: external_exports.literal(true) })]), external_exports.strictObject({ resource: external_exports.strictObject({ ...kindName.shape, version: external_exports.number().int().positive() }), executableHash: hash3.optional(), closureHash: hash3.optional(), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional() }), ["definition-invalid", "documentation-incomplete", "reference-unresolved", "reference-cycle", "verification-incomplete", "verification-stale", "version-conflict"]),
|
|
30549
|
-
listChanges: apiContract("GET", "/api/v1/apps/{app}/changes", "installation-or-cookie", path, external_exports.strictObject({ resource: str.optional(), ...pageQuery }), noBody, page(external_exports.strictObject({ change: external_exports.number().int().positive(), kind: resourceKindSchema, name: str, version: external_exports.number().int().positive(), event: external_exports.enum(["published", "removed"]), distribution: external_exports.strictObject({ state: external_exports.enum(["available", "testing", "queued", "paused"]), reason: str.optional(), until: iso.optional() }).optional(), publishedAt: iso }))),
|
|
30550
|
-
safetyReview: apiContract("GET", "/api/v1/apps/{app}/safety-review", "cookie", path, noQuery, noBody, safetyReview),
|
|
30551
|
-
postExecutions: apiContract("POST", "/api/v1/executions", "installation", noParams, noQuery, external_exports.strictObject({ reports: external_exports.array(external_exports.unknown()).min(1).max(100) }), executionAcknowledgement),
|
|
30552
|
-
postMeasurements: apiContract("POST", "/api/v1/measurements", "installation", noParams, noQuery, external_exports.strictObject({ executions: external_exports.array(external_exports.unknown()).max(100), baselines: external_exports.array(external_exports.unknown()).max(100) }).refine((body) => body.executions.length + body.baselines.length >= 1 && body.executions.length + body.baselines.length <= 100), measurementAcknowledgement),
|
|
30553
|
-
billing: apiContract("GET", "/api/v1/billing", "cookie", noParams, noQuery, noBody, billing),
|
|
30554
|
-
impactApp: apiContract("GET", "/api/v1/impact/apps/{appId}", "cookie", external_exports.strictObject({ appId: uuid5 }), external_exports.strictObject({ range: external_exports.enum(["30d", "90d", "365d"]).optional(), cursor: str.optional(), limit: external_exports.coerce.number().int().min(1).max(100).optional() }), noBody, data),
|
|
30555
|
-
currentRelease: apiContract("GET", "/api/v1/releases/current", "none", noParams, noQuery, noBody, releaseState),
|
|
30556
|
-
replaceRelease: apiContract("PUT", "/api/v1/releases/current", "release-token", noParams, noQuery, releaseState, releaseState, ["release-state-conflict"]),
|
|
30557
|
-
patchReleaseComponents: apiContract("PATCH", "/api/v1/releases/current/components", "release-token", noParams, noQuery, external_exports.strictObject({ observations: external_exports.array(external_exports.strictObject({ component: external_exports.enum(["cli", "extension", "web"]), version: str, sourceSha: str, minimum: external_exports.record(external_exports.string(), str), storeVersion: str.optional() })).min(1) }), releaseState, ["release-state-conflict"]),
|
|
30558
|
-
cloudUsageSegment: apiContract("POST", "/api/v1/internal/cloud-usage/segments", "cloud-usage-token", noParams, noQuery, external_exports.strictObject({ workspaceId: uuid5, subscriptionId: str, idempotencyKey: external_exports.string().min(8).max(160), startedAt: iso, endedAt: iso }), external_exports.strictObject({ id: uuid5, durationSeconds: external_exports.number().int().positive() }), ["usage-overlap"])
|
|
30712
|
+
init_windows_owner();
|
|
30713
|
+
init_dist();
|
|
30714
|
+
pidAlive = (candidate2) => {
|
|
30715
|
+
try {
|
|
30716
|
+
process.kill(candidate2, 0);
|
|
30717
|
+
return true;
|
|
30718
|
+
} catch {
|
|
30719
|
+
return false;
|
|
30720
|
+
}
|
|
30559
30721
|
};
|
|
30722
|
+
inspectProcess = (command6, args, timeout) => execFileSync(command6, args, { encoding: "utf8", timeout, windowsHide: true, env: { ...process.env, LC_ALL: "C", TZ: "UTC" }, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
30723
|
+
defaultOwnerVerifier = createOwnerVerifier();
|
|
30560
30724
|
}
|
|
30561
30725
|
});
|
|
30562
30726
|
|
|
30563
|
-
//
|
|
30564
|
-
|
|
30565
|
-
|
|
30566
|
-
|
|
30567
|
-
|
|
30568
|
-
|
|
30569
|
-
|
|
30570
|
-
|
|
30571
|
-
|
|
30572
|
-
|
|
30573
|
-
|
|
30574
|
-
|
|
30575
|
-
});
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
|
|
30584
|
-
|
|
30727
|
+
// src/discovery/lock.ts
|
|
30728
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
30729
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync3, writeFileSync } from "node:fs";
|
|
30730
|
+
import { join as join2 } from "node:path";
|
|
30731
|
+
function lockDiscovery(root2, sessionId, purpose = "discovery") {
|
|
30732
|
+
const name = createHash3("sha256").update(sessionId).digest("hex");
|
|
30733
|
+
const directory = join2(root2, "locks", `discovery-${name}`);
|
|
30734
|
+
mkdirSync2(join2(root2, "locks"), { recursive: true, mode: 448 });
|
|
30735
|
+
const owner = { pid: process.pid, startedAt: Date.now() - process.uptime() * 1e3 };
|
|
30736
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
30737
|
+
try {
|
|
30738
|
+
mkdirSync2(directory, { mode: 448 });
|
|
30739
|
+
writeFileSync(join2(directory, "owner.json"), JSON.stringify(owner), { flag: "wx", mode: 384 });
|
|
30740
|
+
return () => {
|
|
30741
|
+
rmSync3(directory, { recursive: true, force: true });
|
|
30742
|
+
};
|
|
30743
|
+
} catch (error62) {
|
|
30744
|
+
if (error62.code !== "EEXIST") throw error62;
|
|
30745
|
+
let held = null;
|
|
30746
|
+
try {
|
|
30747
|
+
held = JSON.parse(readFileSync3(join2(directory, "owner.json"), "utf8"));
|
|
30748
|
+
} catch {
|
|
30749
|
+
}
|
|
30750
|
+
if (!held || ownerProcessAlive(held.pid, held.startedAt)) throw new Error(`${purpose}-command-busy \u2014 This agent already has a command running; wait for it to finish, then retry`);
|
|
30751
|
+
rmSync3(directory, { recursive: true, force: true });
|
|
30585
30752
|
}
|
|
30586
|
-
}
|
|
30753
|
+
}
|
|
30754
|
+
throw new Error(`${purpose}-command-busy \u2014 Could not acquire the agent's command lock`);
|
|
30587
30755
|
}
|
|
30588
|
-
var
|
|
30589
|
-
|
|
30590
|
-
"../../packages/core/dist/api/client.js"() {
|
|
30756
|
+
var init_lock = __esm({
|
|
30757
|
+
"src/discovery/lock.ts"() {
|
|
30591
30758
|
"use strict";
|
|
30592
|
-
|
|
30593
|
-
init_contracts();
|
|
30594
|
-
ApiClientError = class extends Error {
|
|
30595
|
-
status;
|
|
30596
|
-
response;
|
|
30597
|
-
constructor(status, response) {
|
|
30598
|
-
super(apiErrorEnvelopeSchema.safeParse(response).data?.error.message ?? `API returned ${status}`);
|
|
30599
|
-
this.status = status;
|
|
30600
|
-
this.response = response;
|
|
30601
|
-
}
|
|
30602
|
-
};
|
|
30759
|
+
init_store();
|
|
30603
30760
|
}
|
|
30604
30761
|
});
|
|
30605
30762
|
|
|
30606
|
-
// ../../packages/core/dist/
|
|
30607
|
-
|
|
30608
|
-
"
|
|
30763
|
+
// ../../packages/core/dist/analytics/index.js
|
|
30764
|
+
function safeSqlState(value) {
|
|
30765
|
+
return typeof value === "string" && sqlStates.has(value) ? value : void 0;
|
|
30766
|
+
}
|
|
30767
|
+
function normalizeRoute(route) {
|
|
30768
|
+
try {
|
|
30769
|
+
const parsed = new URL(route, "https://apilift.dev");
|
|
30770
|
+
return parsed.pathname.replace(/^\/dashboard\/apps\/[^/]+/, "/dashboard/apps/:app").replace(uuid5, ":id").replace(longId, ":id");
|
|
30771
|
+
} catch {
|
|
30772
|
+
return "/invalid";
|
|
30773
|
+
}
|
|
30774
|
+
}
|
|
30775
|
+
function scrubEventProperties(event, input2) {
|
|
30776
|
+
const allowed = eventProperties[event];
|
|
30777
|
+
const result3 = {};
|
|
30778
|
+
for (const [key2, value] of Object.entries(input2)) {
|
|
30779
|
+
if (!allowed.includes(key2))
|
|
30780
|
+
continue;
|
|
30781
|
+
if (key2 === "exception_code") {
|
|
30782
|
+
const code = safeSqlState(value);
|
|
30783
|
+
if (code)
|
|
30784
|
+
result3[key2] = code;
|
|
30785
|
+
continue;
|
|
30786
|
+
}
|
|
30787
|
+
const normalized = key2 === "route" && typeof value === "string" ? normalizeRoute(value) : value;
|
|
30788
|
+
if (typeof normalized === "boolean" || typeof normalized === "number" && Number.isFinite(normalized) || typeof normalized === "string" && safeString.test(normalized))
|
|
30789
|
+
result3[key2] = normalized;
|
|
30790
|
+
}
|
|
30791
|
+
return result3;
|
|
30792
|
+
}
|
|
30793
|
+
var correlation, operation, publication, eventProperties, safeString, uuid5, longId, sqlStates;
|
|
30794
|
+
var init_analytics = __esm({
|
|
30795
|
+
"../../packages/core/dist/analytics/index.js"() {
|
|
30609
30796
|
"use strict";
|
|
30610
|
-
|
|
30611
|
-
|
|
30612
|
-
|
|
30797
|
+
correlation = ["invocation_id", "execution_id", "agent_session_id", "task_id", "discovery_session_id"];
|
|
30798
|
+
operation = ["app_id", "action_id", "action_version", "transport", "outcome", "duration_ms", "http_status", "agent", "purpose", "dispatched", "code", "stage"];
|
|
30799
|
+
publication = ["app_id", "resource_kind", "resource_name", "resource_version", "executable", "removed"];
|
|
30800
|
+
eventProperties = {
|
|
30801
|
+
"$pageview": ["route"],
|
|
30802
|
+
navigation_clicked: ["route", "target"],
|
|
30803
|
+
pricing_viewed: ["route"],
|
|
30804
|
+
catalog_viewed: ["route"],
|
|
30805
|
+
app_page_viewed: ["route"],
|
|
30806
|
+
onboarding_entered: ["route"],
|
|
30807
|
+
broken_page_viewed: ["route"],
|
|
30808
|
+
authentication_started: ["source", "stage"],
|
|
30809
|
+
authentication_code_sent: ["source", "stage"],
|
|
30810
|
+
authentication_completed: ["source", "stage"],
|
|
30811
|
+
authentication_failed: ["source", "stage", "code"],
|
|
30812
|
+
onboarding_attempt_started: ["expires_at", "attempt_id", "agent", "stage", "outcome", "source", "target"],
|
|
30813
|
+
onboarding_stage_viewed: ["attempt_id", "agent", "stage", "outcome"],
|
|
30814
|
+
setup_prompt_copied: ["attempt_id", "agent", "stage", "source"],
|
|
30815
|
+
onboarding_next_action_selected: ["attempt_id", "agent", "target"],
|
|
30816
|
+
onboarding_failed: ["stage", "attempt_id", "code", "outcome", "duration_ms"],
|
|
30817
|
+
checkout_requested: ["plan", "interval", "stage", "source"],
|
|
30818
|
+
checkout_ui_changed: ["plan", "interval", "stage", "source"],
|
|
30819
|
+
billing_portal_requested: ["source"],
|
|
30820
|
+
paid_feature_viewed: ["code", "route"],
|
|
30821
|
+
paid_feature_upgrade_opened: ["code", "route"],
|
|
30822
|
+
account_created: [],
|
|
30823
|
+
account_deleted: [],
|
|
30824
|
+
agent_selected: ["agent", "attempt_id", "status"],
|
|
30825
|
+
device_authorization_changed: ["agent", "attempt_id", "status"],
|
|
30826
|
+
onboarding_stage_completed: ["stage", "active", "agent"],
|
|
30827
|
+
installation_readiness_changed: ["stage", "active", "agent"],
|
|
30828
|
+
app_made_public: ["app_id"],
|
|
30829
|
+
execution_finished: [...correlation, ...operation],
|
|
30830
|
+
activation_changed: ["activated"],
|
|
30831
|
+
execution_classified: [...correlation, ...operation, "revision", "execution_finished_at", "coverage", "time_coverage", "baseline_time_ms", "actual_time_ms", "time_difference_ms", "baseline_tokens", "actual_tokens", "token_difference", "provider", "model"],
|
|
30832
|
+
value_snapshot: ["saved_time_ms", "saved_tokens", "saved_value_microusd", "saved_time_ms_available", "saved_tokens_available", "saved_value_microusd_available"],
|
|
30833
|
+
trial_started: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
30834
|
+
trial_progress: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
30835
|
+
trial_expired: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
30836
|
+
trial_completed: ["plan", "trial_day", "trial_days_remaining", "outcome"],
|
|
30837
|
+
payment_completed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
30838
|
+
payment_status_changed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
30839
|
+
payment_failed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
30840
|
+
subscription_changed: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
30841
|
+
payment_adjusted: ["plan", "interval", "status", "previous_status", "currency", "amount", "billing_environment", "synthetic"],
|
|
30842
|
+
critical_failure: ["code", "count"],
|
|
30843
|
+
cli_command_started: ["invocation_id", "command", "agent", "started_at"],
|
|
30844
|
+
cli_command_finished: [...correlation, ...operation, "command", "exit_code", "platform", "started_at", "finished_at", "result_count", "fallback", "registry_retries", "broker_ms", "bridge_ms", "registry_ms", "binding_ms", "replay_ms", "app_ms", "proof_ms", "reporting_ms"],
|
|
30845
|
+
invocation_attributed: [...correlation, "revision", "attribution_status", "agent", "source_version"],
|
|
30846
|
+
task_observed: ["agent_session_id", "task_id", "agent", "started_at", "source_version"],
|
|
30847
|
+
task_finished: ["agent_session_id", "task_id", "agent", "status", "started_at", "finished_at", "duration_ms", "apilift_active_ms", "source_version"],
|
|
30848
|
+
discovery_session_started: ["discovery_session_id", "app_id", "started_at", "agent", "start_known"],
|
|
30849
|
+
discovery_session_closed: ["discovery_session_id", "app_id", "started_at", "finished_at", "duration_ms", "start_known"],
|
|
30850
|
+
discovery_resource_published: ["discovery_session_id", ...publication],
|
|
30851
|
+
resource_published: publication,
|
|
30852
|
+
telemetry_delivery_health: ["dropped_count"],
|
|
30853
|
+
setup_stage_changed: ["stage", "agent"],
|
|
30854
|
+
discovery_started: ["purpose", "agent"],
|
|
30855
|
+
discovery_finished: ["purpose", "outcome", "duration_ms", "agent"],
|
|
30856
|
+
client_exception: ["code"],
|
|
30857
|
+
native_host_connected: [],
|
|
30858
|
+
native_host_failure: ["code", "operation", "stage", "origin", "failure_count", "duration_ms"],
|
|
30859
|
+
native_host_recovered: ["operation", "stage", "origin", "failure_count", "duration_ms"],
|
|
30860
|
+
extension_installed: ["stage"],
|
|
30861
|
+
extension_connected: ["stage"],
|
|
30862
|
+
extension_disconnected: ["stage"],
|
|
30863
|
+
extension_failure: ["code"],
|
|
30864
|
+
extension_interaction: ["stage", "outcome"],
|
|
30865
|
+
credential_setup_finished: ["stage", "outcome", "code"],
|
|
30866
|
+
"$exception": ["route", "method", "exception_type", "exception_frames", "exception_handled", "exception_level", "exception_code"]
|
|
30867
|
+
};
|
|
30868
|
+
safeString = /^[a-zA-Z0-9_./:{} -]{1,160}$/;
|
|
30869
|
+
uuid5 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
30870
|
+
longId = /\b[a-zA-Z0-9_-]{24,}\b/g;
|
|
30871
|
+
sqlStates = new Set("08000 08001 08003 08004 08006 08007 08P01 22001 22003 22007 22008 22012 22018 22021 22023 22P02 23000 23502 23503 23505 23514 23P01 25006 25P02 28000 28P01 3D000 3F000 40001 40P01 42501 42601 42702 42703 42704 42804 42883 42P01 42P10 53300 53400 54000 54001 55000 55P03 57014 57P01 57P02 57P03 58000 58030 XX000 XX001 XX002".split(" "));
|
|
30613
30872
|
}
|
|
30614
30873
|
});
|
|
30615
30874
|
|
|
30616
30875
|
// src/identity-cache.ts
|
|
30617
|
-
import { createHash as
|
|
30876
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
30618
30877
|
var freshMs, retainedMs, IdentityCache;
|
|
30619
30878
|
var init_identity_cache = __esm({
|
|
30620
30879
|
"src/identity-cache.ts"() {
|
|
@@ -30632,7 +30891,7 @@ var init_identity_cache = __esm({
|
|
|
30632
30891
|
}
|
|
30633
30892
|
key() {
|
|
30634
30893
|
const installation = this.state.installation();
|
|
30635
|
-
return installation ?
|
|
30894
|
+
return installation ? createHash4("sha256").update(JSON.stringify([this.site, installation])).digest("hex") : null;
|
|
30636
30895
|
}
|
|
30637
30896
|
fetchedAt() {
|
|
30638
30897
|
const key2 = this.key();
|
|
@@ -30699,7 +30958,7 @@ var init_identity_cache = __esm({
|
|
|
30699
30958
|
});
|
|
30700
30959
|
|
|
30701
30960
|
// src/analytics.ts
|
|
30702
|
-
import { createHash as
|
|
30961
|
+
import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
|
|
30703
30962
|
var EVENT, EU_HOST, CliAnalytics;
|
|
30704
30963
|
var init_analytics2 = __esm({
|
|
30705
30964
|
"src/analytics.ts"() {
|
|
@@ -30728,7 +30987,7 @@ var init_analytics2 = __esm({
|
|
|
30728
30987
|
state.db.exec("CREATE TABLE IF NOT EXISTS cli_onboarding_attempt (id INTEGER PRIMARY KEY CHECK(id=1), attempt_id TEXT NOT NULL, account_id TEXT NOT NULL)");
|
|
30729
30988
|
}
|
|
30730
30989
|
eventId(key2) {
|
|
30731
|
-
const h =
|
|
30990
|
+
const h = createHash5("sha256").update(key2).digest("hex");
|
|
30732
30991
|
return `${h.slice(0, 8)}-${h.slice(8, 12)}-5${h.slice(13, 16)}-a${h.slice(17, 20)}-${h.slice(20, 32)}`;
|
|
30733
30992
|
}
|
|
30734
30993
|
hasRecorded(event, key2) {
|
|
@@ -30752,14 +31011,14 @@ var init_analytics2 = __esm({
|
|
|
30752
31011
|
try {
|
|
30753
31012
|
const identity3 = JSON.parse(row.json);
|
|
30754
31013
|
const installation = this.state.installation();
|
|
30755
|
-
return installation && identity3.installationKey ===
|
|
31014
|
+
return installation && identity3.installationKey === createHash5("sha256").update(JSON.stringify(installation)).digest("hex") && identity3.expiresAt > Date.now() && identity3.accountId === installation.accountId && identity3.workspaceId === installation.workspaceId && identity3.installationId === installation.id ? identity3 : null;
|
|
30756
31015
|
} catch {
|
|
30757
31016
|
return null;
|
|
30758
31017
|
}
|
|
30759
31018
|
}
|
|
30760
31019
|
updateIdentity(me2, now = Date.now()) {
|
|
30761
31020
|
const previous = this.identity();
|
|
30762
|
-
const next2 = { installationKey:
|
|
31021
|
+
const next2 = { installationKey: createHash5("sha256").update(JSON.stringify(this.state.installation())).digest("hex"), accountId: me2.account.id, workspaceId: me2.workspace.id, installationId: me2.installation.id, ...me2.analytics, enabled: me2.analytics.enabled && me2.analytics.environment !== "disabled" && me2.analytics.host === EU_HOST && /^phc_[A-Za-z0-9]+$/u.test(me2.analytics.projectKey), expiresAt: now + 24 * 60 * 6e4 };
|
|
30763
31022
|
if (!next2.enabled || previous && previous.accountId !== next2.accountId) this.state.db.exec("DELETE FROM cli_analytics_queue");
|
|
30764
31023
|
this.state.db.prepare("INSERT INTO cli_analytics_identity (id,json,refreshed_at) VALUES (1,?,?) ON CONFLICT(id) DO UPDATE SET json=excluded.json,refreshed_at=excluded.refreshed_at").run(JSON.stringify(next2), now);
|
|
30765
31024
|
const cutoff = new Date(now - 7 * 864e5).toISOString();
|
|
@@ -30791,7 +31050,7 @@ var init_analytics2 = __esm({
|
|
|
30791
31050
|
if (!installation) return;
|
|
30792
31051
|
const identity3 = this.identity();
|
|
30793
31052
|
if (identity3 && !identity3.enabled) return;
|
|
30794
|
-
const id2 = options2.key ? this.eventId(`${installation.accountId}:${installation.id}:${event}:${options2.key}`) :
|
|
31053
|
+
const id2 = options2.key ? this.eventId(`${installation.accountId}:${installation.id}:${event}:${options2.key}`) : randomUUID3();
|
|
30795
31054
|
const at = options2.occurredAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
30796
31055
|
if (!Number.isFinite(Date.parse(at))) return;
|
|
30797
31056
|
this.state.db.exec("SAVEPOINT analytics_record");
|
|
@@ -30832,7 +31091,7 @@ var init_analytics2 = __esm({
|
|
|
30832
31091
|
});
|
|
30833
31092
|
|
|
30834
31093
|
// src/discovery/drafts.ts
|
|
30835
|
-
import { randomUUID as
|
|
31094
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
30836
31095
|
import { join as join3 } from "node:path";
|
|
30837
31096
|
function pathFor(root2, appSlug, kind, name) {
|
|
30838
31097
|
if (!slugPattern.test(appSlug)) throw new Error("App slug is invalid");
|
|
@@ -30902,7 +31161,7 @@ var init_drafts = __esm({
|
|
|
30902
31161
|
this.state.db.prepare("INSERT OR REPLACE INTO discovery_session VALUES (?,?,?,?)").run(sessionId, appSlug, appId, title2);
|
|
30903
31162
|
const account = this.state.installation()?.accountId;
|
|
30904
31163
|
if (account && !this.lifecycle(sessionId)) {
|
|
30905
|
-
const id2 =
|
|
31164
|
+
const id2 = randomUUID4(), at = active2?.appId === appId && active2.appSlug === appSlug ? null : (/* @__PURE__ */ new Date()).toISOString();
|
|
30906
31165
|
this.state.db.prepare("INSERT INTO discovery_lifecycle(id,session_id,account_id,app_id,started_at) VALUES(?,?,?,?,?)").run(id2, sessionId, account, appId, at);
|
|
30907
31166
|
try {
|
|
30908
31167
|
new CliAnalytics(this.state, cliVersion).record("discovery_session_started", { discovery_session_id: id2, app_id: appId, started_at: at, start_known: at !== null }, { key: id2, ...at ? { occurredAt: at } : {} });
|
|
@@ -30977,7 +31236,7 @@ function retryDelay(response, attempt) {
|
|
|
30977
31236
|
return 250 * 2 ** attempt;
|
|
30978
31237
|
}
|
|
30979
31238
|
function sleep(ms) {
|
|
30980
|
-
return new Promise((
|
|
31239
|
+
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
30981
31240
|
}
|
|
30982
31241
|
function createCliApi(baseUrl, fetcher = fetch, token, sessionId, observe) {
|
|
30983
31242
|
const transport = async (input2, init) => {
|
|
@@ -31016,7 +31275,7 @@ function createCliApi(baseUrl, fetcher = fetch, token, sessionId, observe) {
|
|
|
31016
31275
|
}
|
|
31017
31276
|
}
|
|
31018
31277
|
};
|
|
31019
|
-
return Object.assign(createApiClient(baseUrl, transport), { cacheNamespace: baseUrl });
|
|
31278
|
+
return Object.assign(createApiClient(baseUrl, transport), { cacheNamespace: baseUrl, authenticatedWith: (candidate2) => candidate2 === token });
|
|
31020
31279
|
}
|
|
31021
31280
|
var retryStatuses, ApiDeliveryUncertainError, ApiReadUnavailableError;
|
|
31022
31281
|
var init_api3 = __esm({
|
|
@@ -31151,6 +31410,9 @@ var init_registry = __esm({
|
|
|
31151
31410
|
actionsShow: { path: ["actions", "show"], min: 2, max: 11, values: ["input-template"], flags: ["schema"] },
|
|
31152
31411
|
run: { path: ["run"], min: 2, max: 2, values: ["input", "output"], flags: ["check", "no-context"], repeat: ["select"], actionFlags: true },
|
|
31153
31412
|
feedback: { path: ["feedback"], min: 2, max: 2, values: ["execution"], flags: ["incorrect"] },
|
|
31413
|
+
feedbackReport: { path: ["feedback", "report"], min: 0, max: 0, values: ["blocked", "repro", "expected", "actual", "comment", "from"], repeat: ["attach"] },
|
|
31414
|
+
feedbackAction: { path: ["feedback", "action"], min: 2, max: 2, values: ["blocked", "repro", "expected", "actual", "comment", "from", "execution"], repeat: ["attach"], flags: ["incorrect"] },
|
|
31415
|
+
feedbackRetry: { path: ["feedback", "retry"], min: 1, max: 1 },
|
|
31154
31416
|
credentialsList: { path: ["credentials", "list"], min: 1, max: 2 },
|
|
31155
31417
|
credentialsUse: { path: ["credentials", "use"], min: 3, max: 3 },
|
|
31156
31418
|
credentialsAdd: { path: ["credentials", "add"], min: 2, max: 2, values: ["file"] },
|
|
@@ -31183,35 +31445,6 @@ var init_registry = __esm({
|
|
|
31183
31445
|
}
|
|
31184
31446
|
});
|
|
31185
31447
|
|
|
31186
|
-
// src/session.ts
|
|
31187
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
31188
|
-
function apiSessionId(installationId, session) {
|
|
31189
|
-
if (!session) return void 0;
|
|
31190
|
-
const hex3 = createHash4("sha256").update("apilift-api-session/v1\0").update(installationId).update("\0").update(session.id).digest("hex");
|
|
31191
|
-
return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-5${hex3.slice(13, 16)}-a${hex3.slice(17, 20)}-${hex3.slice(20, 32)}`;
|
|
31192
|
-
}
|
|
31193
|
-
function agentSession(env, explicitLabel) {
|
|
31194
|
-
explicitLabel ??= env.APILIFT_SESSION;
|
|
31195
|
-
if (explicitLabel !== void 0 && !/^[A-Za-z0-9_-]{1,80}$/u.test(explicitLabel)) return null;
|
|
31196
|
-
const codex = env.CODEX_THREAD_ID || env.CODEX_SESSION_ID;
|
|
31197
|
-
const claude = env.CLAUDE_CODE_SESSION_ID;
|
|
31198
|
-
if (explicitLabel) {
|
|
31199
|
-
const agent2 = claude || env.CLAUDECODE ? "claude" : codex || env.CODEX_HOME ? "codex" : null;
|
|
31200
|
-
return agent2 ? { id: `${agent2}:label:${explicitLabel}`, agent: agent2 } : null;
|
|
31201
|
-
}
|
|
31202
|
-
if (codex && !claude) return { id: `codex:${codex}`, agent: "codex" };
|
|
31203
|
-
if (claude && !codex) return { id: `claude:${claude}`, agent: "claude" };
|
|
31204
|
-
return null;
|
|
31205
|
-
}
|
|
31206
|
-
function commandPrefix(label2) {
|
|
31207
|
-
return `apilift${label2 ? ` --session ${label2}` : ""}`;
|
|
31208
|
-
}
|
|
31209
|
-
var init_session = __esm({
|
|
31210
|
-
"src/session.ts"() {
|
|
31211
|
-
"use strict";
|
|
31212
|
-
}
|
|
31213
|
-
});
|
|
31214
|
-
|
|
31215
31448
|
// src/execution/request-url.ts
|
|
31216
31449
|
function resolveRequestUrl(path2, base2) {
|
|
31217
31450
|
if (/^https?:\/\//iu.test(path2)) return new URL(path2);
|
|
@@ -31225,14 +31458,14 @@ var init_request_url = __esm({
|
|
|
31225
31458
|
});
|
|
31226
31459
|
|
|
31227
31460
|
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
31228
|
-
function createScanner(
|
|
31229
|
-
const len =
|
|
31461
|
+
function createScanner(text5, ignoreTrivia = false) {
|
|
31462
|
+
const len = text5.length;
|
|
31230
31463
|
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
31231
31464
|
function scanHexDigits(count, exact) {
|
|
31232
31465
|
let digits = 0;
|
|
31233
31466
|
let value2 = 0;
|
|
31234
31467
|
while (digits < count || !exact) {
|
|
31235
|
-
let ch =
|
|
31468
|
+
let ch = text5.charCodeAt(pos);
|
|
31236
31469
|
if (ch >= 48 && ch <= 57) {
|
|
31237
31470
|
value2 = value2 * 16 + ch - 48;
|
|
31238
31471
|
} else if (ch >= 65 && ch <= 70) {
|
|
@@ -31259,35 +31492,35 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31259
31492
|
}
|
|
31260
31493
|
function scanNumber() {
|
|
31261
31494
|
let start = pos;
|
|
31262
|
-
if (
|
|
31495
|
+
if (text5.charCodeAt(pos) === 48) {
|
|
31263
31496
|
pos++;
|
|
31264
31497
|
} else {
|
|
31265
31498
|
pos++;
|
|
31266
|
-
while (pos <
|
|
31499
|
+
while (pos < text5.length && isDigit(text5.charCodeAt(pos))) {
|
|
31267
31500
|
pos++;
|
|
31268
31501
|
}
|
|
31269
31502
|
}
|
|
31270
|
-
if (pos <
|
|
31503
|
+
if (pos < text5.length && text5.charCodeAt(pos) === 46) {
|
|
31271
31504
|
pos++;
|
|
31272
|
-
if (pos <
|
|
31505
|
+
if (pos < text5.length && isDigit(text5.charCodeAt(pos))) {
|
|
31273
31506
|
pos++;
|
|
31274
|
-
while (pos <
|
|
31507
|
+
while (pos < text5.length && isDigit(text5.charCodeAt(pos))) {
|
|
31275
31508
|
pos++;
|
|
31276
31509
|
}
|
|
31277
31510
|
} else {
|
|
31278
31511
|
scanError = 3;
|
|
31279
|
-
return
|
|
31512
|
+
return text5.substring(start, pos);
|
|
31280
31513
|
}
|
|
31281
31514
|
}
|
|
31282
31515
|
let end2 = pos;
|
|
31283
|
-
if (pos <
|
|
31516
|
+
if (pos < text5.length && (text5.charCodeAt(pos) === 69 || text5.charCodeAt(pos) === 101)) {
|
|
31284
31517
|
pos++;
|
|
31285
|
-
if (pos <
|
|
31518
|
+
if (pos < text5.length && text5.charCodeAt(pos) === 43 || text5.charCodeAt(pos) === 45) {
|
|
31286
31519
|
pos++;
|
|
31287
31520
|
}
|
|
31288
|
-
if (pos <
|
|
31521
|
+
if (pos < text5.length && isDigit(text5.charCodeAt(pos))) {
|
|
31289
31522
|
pos++;
|
|
31290
|
-
while (pos <
|
|
31523
|
+
while (pos < text5.length && isDigit(text5.charCodeAt(pos))) {
|
|
31291
31524
|
pos++;
|
|
31292
31525
|
}
|
|
31293
31526
|
end2 = pos;
|
|
@@ -31295,30 +31528,30 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31295
31528
|
scanError = 3;
|
|
31296
31529
|
}
|
|
31297
31530
|
}
|
|
31298
|
-
return
|
|
31531
|
+
return text5.substring(start, end2);
|
|
31299
31532
|
}
|
|
31300
31533
|
function scanString() {
|
|
31301
31534
|
let result3 = "", start = pos;
|
|
31302
31535
|
while (true) {
|
|
31303
31536
|
if (pos >= len) {
|
|
31304
|
-
result3 +=
|
|
31537
|
+
result3 += text5.substring(start, pos);
|
|
31305
31538
|
scanError = 2;
|
|
31306
31539
|
break;
|
|
31307
31540
|
}
|
|
31308
|
-
const ch =
|
|
31541
|
+
const ch = text5.charCodeAt(pos);
|
|
31309
31542
|
if (ch === 34) {
|
|
31310
|
-
result3 +=
|
|
31543
|
+
result3 += text5.substring(start, pos);
|
|
31311
31544
|
pos++;
|
|
31312
31545
|
break;
|
|
31313
31546
|
}
|
|
31314
31547
|
if (ch === 92) {
|
|
31315
|
-
result3 +=
|
|
31548
|
+
result3 += text5.substring(start, pos);
|
|
31316
31549
|
pos++;
|
|
31317
31550
|
if (pos >= len) {
|
|
31318
31551
|
scanError = 2;
|
|
31319
31552
|
break;
|
|
31320
31553
|
}
|
|
31321
|
-
const ch2 =
|
|
31554
|
+
const ch2 = text5.charCodeAt(pos++);
|
|
31322
31555
|
switch (ch2) {
|
|
31323
31556
|
case 34:
|
|
31324
31557
|
result3 += '"';
|
|
@@ -31360,7 +31593,7 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31360
31593
|
}
|
|
31361
31594
|
if (ch >= 0 && ch <= 31) {
|
|
31362
31595
|
if (isLineBreak(ch)) {
|
|
31363
|
-
result3 +=
|
|
31596
|
+
result3 += text5.substring(start, pos);
|
|
31364
31597
|
scanError = 2;
|
|
31365
31598
|
break;
|
|
31366
31599
|
} else {
|
|
@@ -31381,19 +31614,19 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31381
31614
|
tokenOffset = len;
|
|
31382
31615
|
return token = 17;
|
|
31383
31616
|
}
|
|
31384
|
-
let code =
|
|
31617
|
+
let code = text5.charCodeAt(pos);
|
|
31385
31618
|
if (isWhiteSpace(code)) {
|
|
31386
31619
|
do {
|
|
31387
31620
|
pos++;
|
|
31388
31621
|
value += String.fromCharCode(code);
|
|
31389
|
-
code =
|
|
31622
|
+
code = text5.charCodeAt(pos);
|
|
31390
31623
|
} while (isWhiteSpace(code));
|
|
31391
31624
|
return token = 15;
|
|
31392
31625
|
}
|
|
31393
31626
|
if (isLineBreak(code)) {
|
|
31394
31627
|
pos++;
|
|
31395
31628
|
value += String.fromCharCode(code);
|
|
31396
|
-
if (code === 13 &&
|
|
31629
|
+
if (code === 13 && text5.charCodeAt(pos) === 10) {
|
|
31397
31630
|
pos++;
|
|
31398
31631
|
value += "\n";
|
|
31399
31632
|
}
|
|
@@ -31429,31 +31662,31 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31429
31662
|
// comments
|
|
31430
31663
|
case 47:
|
|
31431
31664
|
const start = pos - 1;
|
|
31432
|
-
if (
|
|
31665
|
+
if (text5.charCodeAt(pos + 1) === 47) {
|
|
31433
31666
|
pos += 2;
|
|
31434
31667
|
while (pos < len) {
|
|
31435
|
-
if (isLineBreak(
|
|
31668
|
+
if (isLineBreak(text5.charCodeAt(pos))) {
|
|
31436
31669
|
break;
|
|
31437
31670
|
}
|
|
31438
31671
|
pos++;
|
|
31439
31672
|
}
|
|
31440
|
-
value =
|
|
31673
|
+
value = text5.substring(start, pos);
|
|
31441
31674
|
return token = 12;
|
|
31442
31675
|
}
|
|
31443
|
-
if (
|
|
31676
|
+
if (text5.charCodeAt(pos + 1) === 42) {
|
|
31444
31677
|
pos += 2;
|
|
31445
31678
|
const safeLength = len - 1;
|
|
31446
31679
|
let commentClosed = false;
|
|
31447
31680
|
while (pos < safeLength) {
|
|
31448
|
-
const ch =
|
|
31449
|
-
if (ch === 42 &&
|
|
31681
|
+
const ch = text5.charCodeAt(pos);
|
|
31682
|
+
if (ch === 42 && text5.charCodeAt(pos + 1) === 47) {
|
|
31450
31683
|
pos += 2;
|
|
31451
31684
|
commentClosed = true;
|
|
31452
31685
|
break;
|
|
31453
31686
|
}
|
|
31454
31687
|
pos++;
|
|
31455
31688
|
if (isLineBreak(ch)) {
|
|
31456
|
-
if (ch === 13 &&
|
|
31689
|
+
if (ch === 13 && text5.charCodeAt(pos) === 10) {
|
|
31457
31690
|
pos++;
|
|
31458
31691
|
}
|
|
31459
31692
|
lineNumber++;
|
|
@@ -31464,7 +31697,7 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31464
31697
|
pos++;
|
|
31465
31698
|
scanError = 1;
|
|
31466
31699
|
}
|
|
31467
|
-
value =
|
|
31700
|
+
value = text5.substring(start, pos);
|
|
31468
31701
|
return token = 13;
|
|
31469
31702
|
}
|
|
31470
31703
|
value += String.fromCharCode(code);
|
|
@@ -31474,7 +31707,7 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31474
31707
|
case 45:
|
|
31475
31708
|
value += String.fromCharCode(code);
|
|
31476
31709
|
pos++;
|
|
31477
|
-
if (pos === len || !isDigit(
|
|
31710
|
+
if (pos === len || !isDigit(text5.charCodeAt(pos))) {
|
|
31478
31711
|
return token = 16;
|
|
31479
31712
|
}
|
|
31480
31713
|
// found a minus, followed by a number so
|
|
@@ -31496,10 +31729,10 @@ function createScanner(text4, ignoreTrivia = false) {
|
|
|
31496
31729
|
default:
|
|
31497
31730
|
while (pos < len && isUnknownContentCharacter(code)) {
|
|
31498
31731
|
pos++;
|
|
31499
|
-
code =
|
|
31732
|
+
code = text5.charCodeAt(pos);
|
|
31500
31733
|
}
|
|
31501
31734
|
if (tokenOffset !== pos) {
|
|
31502
|
-
value =
|
|
31735
|
+
value = text5.substring(tokenOffset, pos);
|
|
31503
31736
|
switch (value) {
|
|
31504
31737
|
case "true":
|
|
31505
31738
|
return token = 8;
|
|
@@ -31754,9 +31987,9 @@ function format(documentText, range, options2) {
|
|
|
31754
31987
|
return token;
|
|
31755
31988
|
}
|
|
31756
31989
|
const editOperations = [];
|
|
31757
|
-
function addEdit(
|
|
31758
|
-
if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !==
|
|
31759
|
-
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content:
|
|
31990
|
+
function addEdit(text5, startOffset, endOffset) {
|
|
31991
|
+
if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text5) {
|
|
31992
|
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text5 });
|
|
31760
31993
|
}
|
|
31761
31994
|
}
|
|
31762
31995
|
let firstToken = scanNext();
|
|
@@ -31904,11 +32137,11 @@ function computeIndentLevel(content, options2) {
|
|
|
31904
32137
|
}
|
|
31905
32138
|
return Math.floor(nChars / tabSize);
|
|
31906
32139
|
}
|
|
31907
|
-
function getEOL(options2,
|
|
31908
|
-
for (let i = 0; i <
|
|
31909
|
-
const ch =
|
|
32140
|
+
function getEOL(options2, text5) {
|
|
32141
|
+
for (let i = 0; i < text5.length; i++) {
|
|
32142
|
+
const ch = text5.charAt(i);
|
|
31910
32143
|
if (ch === "\r") {
|
|
31911
|
-
if (i + 1 <
|
|
32144
|
+
if (i + 1 < text5.length && text5.charAt(i + 1) === "\n") {
|
|
31912
32145
|
return "\r\n";
|
|
31913
32146
|
}
|
|
31914
32147
|
return "\r";
|
|
@@ -31918,8 +32151,8 @@ function getEOL(options2, text4) {
|
|
|
31918
32151
|
}
|
|
31919
32152
|
return options2 && options2.eol || "\n";
|
|
31920
32153
|
}
|
|
31921
|
-
function isEOL(
|
|
31922
|
-
return "\r\n".indexOf(
|
|
32154
|
+
function isEOL(text5, offset) {
|
|
32155
|
+
return "\r\n".indexOf(text5.charAt(offset)) !== -1;
|
|
31923
32156
|
}
|
|
31924
32157
|
var init_format = __esm({
|
|
31925
32158
|
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js"() {
|
|
@@ -31930,7 +32163,7 @@ var init_format = __esm({
|
|
|
31930
32163
|
});
|
|
31931
32164
|
|
|
31932
32165
|
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
31933
|
-
function parse3(
|
|
32166
|
+
function parse3(text5, errors = [], options2 = ParseOptions.DEFAULT) {
|
|
31934
32167
|
let currentProperty = null;
|
|
31935
32168
|
let currentParent = [];
|
|
31936
32169
|
const previousParents = [];
|
|
@@ -31970,10 +32203,10 @@ function parse3(text4, errors = [], options2 = ParseOptions.DEFAULT) {
|
|
|
31970
32203
|
errors.push({ error: error62, offset, length });
|
|
31971
32204
|
}
|
|
31972
32205
|
};
|
|
31973
|
-
visit2(
|
|
32206
|
+
visit2(text5, visitor, options2);
|
|
31974
32207
|
return currentParent[0];
|
|
31975
32208
|
}
|
|
31976
|
-
function parseTree(
|
|
32209
|
+
function parseTree(text5, errors = [], options2 = ParseOptions.DEFAULT) {
|
|
31977
32210
|
let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
|
|
31978
32211
|
function ensurePropertyComplete(endOffset) {
|
|
31979
32212
|
if (currentParent.type === "property") {
|
|
@@ -32024,7 +32257,7 @@ function parseTree(text4, errors = [], options2 = ParseOptions.DEFAULT) {
|
|
|
32024
32257
|
errors.push({ error: error62, offset, length });
|
|
32025
32258
|
}
|
|
32026
32259
|
};
|
|
32027
|
-
visit2(
|
|
32260
|
+
visit2(text5, visitor, options2);
|
|
32028
32261
|
const result3 = currentParent.children[0];
|
|
32029
32262
|
if (result3) {
|
|
32030
32263
|
delete result3.parent;
|
|
@@ -32062,8 +32295,8 @@ function findNodeAtLocation(root2, path2) {
|
|
|
32062
32295
|
}
|
|
32063
32296
|
return node2;
|
|
32064
32297
|
}
|
|
32065
|
-
function visit2(
|
|
32066
|
-
const _scanner = createScanner(
|
|
32298
|
+
function visit2(text5, visitor, options2 = ParseOptions.DEFAULT) {
|
|
32299
|
+
const _scanner = createScanner(text5, false);
|
|
32067
32300
|
const _jsonPath = [];
|
|
32068
32301
|
let suppressedCallbacks = 0;
|
|
32069
32302
|
function toNoArgVisit(visitFunction) {
|
|
@@ -32401,10 +32634,10 @@ var init_parser = __esm({
|
|
|
32401
32634
|
});
|
|
32402
32635
|
|
|
32403
32636
|
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
|
|
32404
|
-
function setProperty(
|
|
32637
|
+
function setProperty(text5, originalPath, value, options2) {
|
|
32405
32638
|
const path2 = originalPath.slice();
|
|
32406
32639
|
const errors = [];
|
|
32407
|
-
const root2 = parseTree(
|
|
32640
|
+
const root2 = parseTree(text5, errors);
|
|
32408
32641
|
let parent2 = void 0;
|
|
32409
32642
|
let lastSegment = void 0;
|
|
32410
32643
|
while (path2.length > 0) {
|
|
@@ -32424,7 +32657,7 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32424
32657
|
if (value === void 0) {
|
|
32425
32658
|
throw new Error("Can not delete in empty document");
|
|
32426
32659
|
}
|
|
32427
|
-
return withFormatting(
|
|
32660
|
+
return withFormatting(text5, { offset: root2 ? root2.offset : 0, length: root2 ? root2.length : 0, content: JSON.stringify(value) }, options2);
|
|
32428
32661
|
} else if (parent2.type === "object" && typeof lastSegment === "string" && Array.isArray(parent2.children)) {
|
|
32429
32662
|
const existing = findNodeAtLocation(parent2, [lastSegment]);
|
|
32430
32663
|
if (existing !== void 0) {
|
|
@@ -32445,9 +32678,9 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32445
32678
|
removeEnd = next2.offset;
|
|
32446
32679
|
}
|
|
32447
32680
|
}
|
|
32448
|
-
return withFormatting(
|
|
32681
|
+
return withFormatting(text5, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options2);
|
|
32449
32682
|
} else {
|
|
32450
|
-
return withFormatting(
|
|
32683
|
+
return withFormatting(text5, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options2);
|
|
32451
32684
|
}
|
|
32452
32685
|
} else {
|
|
32453
32686
|
if (value === void 0) {
|
|
@@ -32464,7 +32697,7 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32464
32697
|
} else {
|
|
32465
32698
|
edit = { offset: parent2.offset + 1, length: 0, content: newProperty + "," };
|
|
32466
32699
|
}
|
|
32467
|
-
return withFormatting(
|
|
32700
|
+
return withFormatting(text5, edit, options2);
|
|
32468
32701
|
}
|
|
32469
32702
|
} else if (parent2.type === "array" && typeof lastSegment === "number" && Array.isArray(parent2.children)) {
|
|
32470
32703
|
const insertIndex = lastSegment;
|
|
@@ -32477,7 +32710,7 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32477
32710
|
const previous = parent2.children[parent2.children.length - 1];
|
|
32478
32711
|
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
32479
32712
|
}
|
|
32480
|
-
return withFormatting(
|
|
32713
|
+
return withFormatting(text5, edit, options2);
|
|
32481
32714
|
} else if (value === void 0 && parent2.children.length >= 0) {
|
|
32482
32715
|
const removalIndex = lastSegment;
|
|
32483
32716
|
const toRemove = parent2.children[removalIndex];
|
|
@@ -32492,7 +32725,7 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32492
32725
|
} else {
|
|
32493
32726
|
edit = { offset: toRemove.offset, length: parent2.children[removalIndex + 1].offset - toRemove.offset, content: "" };
|
|
32494
32727
|
}
|
|
32495
|
-
return withFormatting(
|
|
32728
|
+
return withFormatting(text5, edit, options2);
|
|
32496
32729
|
} else if (value !== void 0) {
|
|
32497
32730
|
let edit;
|
|
32498
32731
|
const newProperty = `${JSON.stringify(value)}`;
|
|
@@ -32506,7 +32739,7 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32506
32739
|
const previous = parent2.children[index2 - 1];
|
|
32507
32740
|
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
32508
32741
|
}
|
|
32509
|
-
return withFormatting(
|
|
32742
|
+
return withFormatting(text5, edit, options2);
|
|
32510
32743
|
} else {
|
|
32511
32744
|
throw new Error(`Can not ${value === void 0 ? "remove" : options2.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
|
|
32512
32745
|
}
|
|
@@ -32514,11 +32747,11 @@ function setProperty(text4, originalPath, value, options2) {
|
|
|
32514
32747
|
throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent2.type}`);
|
|
32515
32748
|
}
|
|
32516
32749
|
}
|
|
32517
|
-
function withFormatting(
|
|
32750
|
+
function withFormatting(text5, edit, options2) {
|
|
32518
32751
|
if (!options2.formattingOptions) {
|
|
32519
32752
|
return [edit];
|
|
32520
32753
|
}
|
|
32521
|
-
let newText = applyEdit(
|
|
32754
|
+
let newText = applyEdit(text5, edit);
|
|
32522
32755
|
let begin = edit.offset;
|
|
32523
32756
|
let end2 = edit.offset + edit.content.length;
|
|
32524
32757
|
if (edit.length === 0 || edit.content.length === 0) {
|
|
@@ -32537,11 +32770,11 @@ function withFormatting(text4, edit, options2) {
|
|
|
32537
32770
|
end2 = Math.max(end2, edit2.offset + edit2.length);
|
|
32538
32771
|
end2 += edit2.content.length - edit2.length;
|
|
32539
32772
|
}
|
|
32540
|
-
const editLength =
|
|
32773
|
+
const editLength = text5.length - (newText.length - end2) - begin;
|
|
32541
32774
|
return [{ offset: begin, length: editLength, content: newText.substring(begin, end2) }];
|
|
32542
32775
|
}
|
|
32543
|
-
function applyEdit(
|
|
32544
|
-
return
|
|
32776
|
+
function applyEdit(text5, edit) {
|
|
32777
|
+
return text5.substring(0, edit.offset) + edit.content + text5.substring(edit.offset + edit.length);
|
|
32545
32778
|
}
|
|
32546
32779
|
var init_edit = __esm({
|
|
32547
32780
|
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js"() {
|
|
@@ -32552,10 +32785,10 @@ var init_edit = __esm({
|
|
|
32552
32785
|
});
|
|
32553
32786
|
|
|
32554
32787
|
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
|
|
32555
|
-
function modify(
|
|
32556
|
-
return setProperty(
|
|
32788
|
+
function modify(text5, path2, value, options2) {
|
|
32789
|
+
return setProperty(text5, path2, value, options2);
|
|
32557
32790
|
}
|
|
32558
|
-
function applyEdits(
|
|
32791
|
+
function applyEdits(text5, edits) {
|
|
32559
32792
|
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
32560
32793
|
const diff = a.offset - b.offset;
|
|
32561
32794
|
if (diff === 0) {
|
|
@@ -32563,17 +32796,17 @@ function applyEdits(text4, edits) {
|
|
|
32563
32796
|
}
|
|
32564
32797
|
return diff;
|
|
32565
32798
|
});
|
|
32566
|
-
let lastModifiedOffset =
|
|
32799
|
+
let lastModifiedOffset = text5.length;
|
|
32567
32800
|
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
32568
32801
|
let e = sortedEdits[i];
|
|
32569
32802
|
if (e.offset + e.length <= lastModifiedOffset) {
|
|
32570
|
-
|
|
32803
|
+
text5 = applyEdit(text5, e);
|
|
32571
32804
|
} else {
|
|
32572
32805
|
throw new Error("Overlapping edit");
|
|
32573
32806
|
}
|
|
32574
32807
|
lastModifiedOffset = e.offset;
|
|
32575
32808
|
}
|
|
32576
|
-
return
|
|
32809
|
+
return text5;
|
|
32577
32810
|
}
|
|
32578
32811
|
var ScanError, SyntaxKind, parse4, visit3, ParseErrorCode;
|
|
32579
32812
|
var init_main = __esm({
|
|
@@ -32635,17 +32868,17 @@ var init_main = __esm({
|
|
|
32635
32868
|
});
|
|
32636
32869
|
|
|
32637
32870
|
// src/discovery/batch-draft.ts
|
|
32638
|
-
import { createHash as
|
|
32871
|
+
import { createHash as createHash6, randomUUID as randomUUID5 } from "node:crypto";
|
|
32639
32872
|
import { existsSync, linkSync, readFileSync as readFileSync4, realpathSync, renameSync, statSync as statSync2, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
32640
32873
|
function readDraftFile(path2) {
|
|
32641
32874
|
const stat2 = statSync2(path2);
|
|
32642
32875
|
if (!stat2.isFile() || stat2.size > maximumBytes) throw Error("Use a regular draft file of at most 8 MiB");
|
|
32643
32876
|
return readFileSync4(path2, "utf8");
|
|
32644
32877
|
}
|
|
32645
|
-
function parseBatch(
|
|
32878
|
+
function parseBatch(text5) {
|
|
32646
32879
|
const errors = [], issues = [], stack = [];
|
|
32647
32880
|
const options2 = { allowTrailingComma: true };
|
|
32648
|
-
visit3(
|
|
32881
|
+
visit3(text5, { onObjectBegin: () => {
|
|
32649
32882
|
stack.push(/* @__PURE__ */ new Set());
|
|
32650
32883
|
}, onObjectProperty: (name, offset) => {
|
|
32651
32884
|
if (stack.at(-1).has(name)) issues.push({ path: `@${offset}`, message: `Duplicate key "${name}"` });
|
|
@@ -32653,7 +32886,7 @@ function parseBatch(text4) {
|
|
|
32653
32886
|
}, onObjectEnd: () => {
|
|
32654
32887
|
stack.pop();
|
|
32655
32888
|
} }, options2);
|
|
32656
|
-
const raw = parse4(
|
|
32889
|
+
const raw = parse4(text5, errors, options2);
|
|
32657
32890
|
if (errors.length || !isObject2(raw)) return { issues: [...issues, { path: "/", message: "Enter a valid JSONC object" }] };
|
|
32658
32891
|
for (const field of Object.keys(raw)) if (!["version", "app", "appId", "baseRevisions", "legacyActions", "transport", "entities", "actions"].includes(field)) issues.push({ path: `/${escape3(field)}`, message: "Unknown draft field" });
|
|
32659
32892
|
if (raw.version !== 2) issues.push({ path: "/version", message: "Definition files use version 2" });
|
|
@@ -32735,10 +32968,10 @@ function defaultGuidance(draft) {
|
|
|
32735
32968
|
].join("\n") + "\n";
|
|
32736
32969
|
}
|
|
32737
32970
|
function createDraftFile(path2, draft, guidance) {
|
|
32738
|
-
const
|
|
32739
|
-
if (Buffer.byteLength(
|
|
32740
|
-
const temporary = `${path2}.${
|
|
32741
|
-
writeFileSync2(temporary,
|
|
32971
|
+
const text5 = (guidance ?? defaultGuidance(draft)) + JSON.stringify(draft, null, 2) + "\n";
|
|
32972
|
+
if (Buffer.byteLength(text5) > maximumBytes) throw Error("Use a draft file of at most 8 MiB");
|
|
32973
|
+
const temporary = `${path2}.${randomUUID5()}.tmp`;
|
|
32974
|
+
writeFileSync2(temporary, text5, { flag: "wx", mode: 384 });
|
|
32742
32975
|
try {
|
|
32743
32976
|
linkSync(temporary, path2);
|
|
32744
32977
|
} finally {
|
|
@@ -32752,7 +32985,7 @@ function updateDraftMetadata(path2, original, edits) {
|
|
|
32752
32985
|
let contents2 = original;
|
|
32753
32986
|
for (const edit of edits) contents2 = applyEdits(contents2, modify(contents2, edit.path, edit.value, formatting));
|
|
32754
32987
|
if (contents2 === original) return true;
|
|
32755
|
-
const temporary = `${actualPath}.${
|
|
32988
|
+
const temporary = `${actualPath}.${randomUUID5()}.tmp`;
|
|
32756
32989
|
writeFileSync2(temporary, contents2, { flag: "wx", mode: statSync2(actualPath).mode & 511 });
|
|
32757
32990
|
try {
|
|
32758
32991
|
if (readDraftFile(actualPath) !== original) return false;
|
|
@@ -32809,7 +33042,7 @@ var init_batch_draft = __esm({
|
|
|
32809
33042
|
isObject2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
32810
33043
|
emptyBatch = (app2, appId) => ({ version: 2, ...app2 ? { app: app2 } : {}, ...appId ? { appId } : {}, entities: {}, actions: {} });
|
|
32811
33044
|
formatting = { formattingOptions: { insertSpaces: true, tabSize: 2 } };
|
|
32812
|
-
definitionFingerprint = (definition2) =>
|
|
33045
|
+
definitionFingerprint = (definition2) => createHash6("sha256").update(canonicalJson(definition2)).digest("hex");
|
|
32813
33046
|
}
|
|
32814
33047
|
});
|
|
32815
33048
|
|
|
@@ -33257,11 +33490,11 @@ var init_esm2 = __esm({
|
|
|
33257
33490
|
this.lastNode = null;
|
|
33258
33491
|
}
|
|
33259
33492
|
oncdatastart() {
|
|
33260
|
-
const
|
|
33261
|
-
const node2 = new CDATA2([
|
|
33493
|
+
const text5 = new Text2("");
|
|
33494
|
+
const node2 = new CDATA2([text5]);
|
|
33262
33495
|
this.addNode(node2);
|
|
33263
|
-
|
|
33264
|
-
this.lastNode =
|
|
33496
|
+
text5.parent = node2;
|
|
33497
|
+
this.lastNode = text5;
|
|
33265
33498
|
}
|
|
33266
33499
|
oncdataend() {
|
|
33267
33500
|
this.lastNode = null;
|
|
@@ -34740,7 +34973,7 @@ __export(static_exports, {
|
|
|
34740
34973
|
merge: () => merge2,
|
|
34741
34974
|
parseHTML: () => parseHTML,
|
|
34742
34975
|
root: () => root,
|
|
34743
|
-
text: () =>
|
|
34976
|
+
text: () => text3,
|
|
34744
34977
|
xml: () => xml
|
|
34745
34978
|
});
|
|
34746
34979
|
function render2(that, dom, options2) {
|
|
@@ -34763,7 +34996,7 @@ function xml(dom) {
|
|
|
34763
34996
|
const options2 = { ...this._options, xmlMode: true };
|
|
34764
34997
|
return render2(this, dom, options2);
|
|
34765
34998
|
}
|
|
34766
|
-
function
|
|
34999
|
+
function text3(elements) {
|
|
34767
35000
|
const elems = elements !== null && elements !== void 0 ? elements : this ? this.root() : [];
|
|
34768
35001
|
let ret = "";
|
|
34769
35002
|
for (let i = 0; i < elems.length; i++) {
|
|
@@ -36575,7 +36808,7 @@ function getAttr(elem, name, xmlMode) {
|
|
|
36575
36808
|
return !xmlMode && rboolean.test(name) ? name : elem.attribs[name];
|
|
36576
36809
|
}
|
|
36577
36810
|
if (elem.name === "option" && name === "value") {
|
|
36578
|
-
return
|
|
36811
|
+
return text3(elem.children);
|
|
36579
36812
|
}
|
|
36580
36813
|
if (elem.name === "input" && (elem.attribs["type"] === "radio" || elem.attribs["type"] === "checkbox") && name === "value") {
|
|
36581
36814
|
return "on";
|
|
@@ -36804,7 +37037,7 @@ function val(value) {
|
|
|
36804
37037
|
}
|
|
36805
37038
|
return this;
|
|
36806
37039
|
}
|
|
36807
|
-
return this.attr("multiple") ? option.toArray().map((el) =>
|
|
37040
|
+
return this.attr("multiple") ? option.toArray().map((el) => text3(el.children)) : option.attr("value");
|
|
36808
37041
|
}
|
|
36809
37042
|
case "input":
|
|
36810
37043
|
case "option": {
|
|
@@ -37732,13 +37965,13 @@ var init_filters = __esm({
|
|
|
37732
37965
|
init_esm7();
|
|
37733
37966
|
import_boolbase3 = __toESM(require_boolbase(), 1);
|
|
37734
37967
|
filters = {
|
|
37735
|
-
contains(next2,
|
|
37968
|
+
contains(next2, text5, { adapter }) {
|
|
37736
37969
|
return function contains2(elem) {
|
|
37737
|
-
return next2(elem) && adapter.getText(elem).includes(
|
|
37970
|
+
return next2(elem) && adapter.getText(elem).includes(text5);
|
|
37738
37971
|
};
|
|
37739
37972
|
},
|
|
37740
|
-
icontains(next2,
|
|
37741
|
-
const itext =
|
|
37973
|
+
icontains(next2, text5, { adapter }) {
|
|
37974
|
+
const itext = text5.toLowerCase();
|
|
37742
37975
|
return function icontains(elem) {
|
|
37743
37976
|
return next2(elem) && adapter.getText(elem).toLowerCase().includes(itext);
|
|
37744
37977
|
};
|
|
@@ -38993,7 +39226,7 @@ __export(manipulation_exports, {
|
|
|
38993
39226
|
prependTo: () => prependTo,
|
|
38994
39227
|
remove: () => remove,
|
|
38995
39228
|
replaceWith: () => replaceWith,
|
|
38996
|
-
text: () =>
|
|
39229
|
+
text: () => text4,
|
|
38997
39230
|
toString: () => toString,
|
|
38998
39231
|
unwrap: () => unwrap,
|
|
38999
39232
|
wrap: () => wrap,
|
|
@@ -39273,12 +39506,12 @@ function html2(str2) {
|
|
|
39273
39506
|
function toString() {
|
|
39274
39507
|
return this._render(this);
|
|
39275
39508
|
}
|
|
39276
|
-
function
|
|
39509
|
+
function text4(str2) {
|
|
39277
39510
|
if (str2 === void 0) {
|
|
39278
|
-
return
|
|
39511
|
+
return text3(this);
|
|
39279
39512
|
}
|
|
39280
39513
|
if (typeof str2 === "function") {
|
|
39281
|
-
return domEach(this, (el, i) => this._make(el).text(str2.call(el, i,
|
|
39514
|
+
return domEach(this, (el, i) => this._make(el).text(str2.call(el, i, text3([el]))));
|
|
39282
39515
|
}
|
|
39283
39516
|
return domEach(this, (el) => {
|
|
39284
39517
|
if (!hasChildren(el))
|
|
@@ -39654,10 +39887,10 @@ var init_slim = __esm({
|
|
|
39654
39887
|
});
|
|
39655
39888
|
|
|
39656
39889
|
// src/execution/html-secrets.ts
|
|
39657
|
-
function htmlSecrets(
|
|
39658
|
-
if (!declaredHtml && !/^\s*</u.test(
|
|
39659
|
-
if (Buffer.byteLength(
|
|
39660
|
-
const $ = load(
|
|
39890
|
+
function htmlSecrets(text5, declaredHtml = false) {
|
|
39891
|
+
if (!declaredHtml && !/^\s*</u.test(text5)) return [];
|
|
39892
|
+
if (Buffer.byteLength(text5) > 48 * 1024 * 1024) throw new Error("HTML exceeds the textual evidence limit");
|
|
39893
|
+
const $ = load(text5), values = [];
|
|
39661
39894
|
$("input,meta").each((_i, element) => {
|
|
39662
39895
|
const node2 = $(element), name = `${node2.attr("name") ?? ""} ${node2.attr("id") ?? ""}`;
|
|
39663
39896
|
if (node2.attr("type") === "password" || /token|csrf|secret|password|api.?key|authorization/iu.test(name)) {
|
|
@@ -39675,29 +39908,29 @@ var init_html_secrets = __esm({
|
|
|
39675
39908
|
});
|
|
39676
39909
|
|
|
39677
39910
|
// src/execution/file-artifacts.ts
|
|
39678
|
-
import { createHash as
|
|
39679
|
-
import { constants as
|
|
39680
|
-
import { basename, isAbsolute, join as join4 } from "node:path";
|
|
39911
|
+
import { createHash as createHash7, randomUUID as randomUUID6 } from "node:crypto";
|
|
39912
|
+
import { constants as constants3, openSync as openSync3, closeSync as closeSync3, fstatSync as fstatSync2, readSync as readSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, lstatSync as lstatSync2 } from "node:fs";
|
|
39913
|
+
import { basename as basename2, isAbsolute, join as join4 } from "node:path";
|
|
39681
39914
|
function localBytes(path2, limit) {
|
|
39682
39915
|
if (!isAbsolute(path2)) throw new Error("File inputs must use an absolute local path");
|
|
39683
|
-
const selected =
|
|
39916
|
+
const selected = lstatSync2(path2);
|
|
39684
39917
|
if (selected.isSymbolicLink() || !selected.isFile()) throw new Error("Select a regular local file, not a symlink or device");
|
|
39685
|
-
const fd =
|
|
39918
|
+
const fd = openSync3(path2, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
|
|
39686
39919
|
try {
|
|
39687
|
-
const before2 =
|
|
39920
|
+
const before2 = fstatSync2(fd);
|
|
39688
39921
|
if (before2.dev !== selected.dev || before2.ino !== selected.ino || !before2.isFile() || before2.size > limit) throw new Error(`File must be a regular file of at most ${limit} bytes`);
|
|
39689
39922
|
const bytes = Buffer.alloc(before2.size + 1);
|
|
39690
39923
|
let count = 0;
|
|
39691
39924
|
while (count < bytes.length) {
|
|
39692
|
-
const read =
|
|
39925
|
+
const read = readSync3(fd, bytes, count, bytes.length - count, count);
|
|
39693
39926
|
if (!read) break;
|
|
39694
39927
|
count += read;
|
|
39695
39928
|
}
|
|
39696
|
-
const after2 =
|
|
39929
|
+
const after2 = fstatSync2(fd);
|
|
39697
39930
|
if (count !== before2.size || after2.size !== before2.size || after2.mtimeMs !== before2.mtimeMs) throw new Error("File changed while reading; supply a stable file");
|
|
39698
39931
|
return bytes.subarray(0, count);
|
|
39699
39932
|
} finally {
|
|
39700
|
-
|
|
39933
|
+
closeSync3(fd);
|
|
39701
39934
|
}
|
|
39702
39935
|
}
|
|
39703
39936
|
function inputFile(path2) {
|
|
@@ -39706,7 +39939,7 @@ function inputFile(path2) {
|
|
|
39706
39939
|
return { sha256: digest2(bytes), bytes: bytes.length, dataBase64: bytes.toString("base64") };
|
|
39707
39940
|
}
|
|
39708
39941
|
function safeFileName(value) {
|
|
39709
|
-
let name =
|
|
39942
|
+
let name = basename2(value.replaceAll("\\", "/")).replace(/[<>:"|?*]/gu, "_").replace(/[ .]+$/u, "");
|
|
39710
39943
|
name = Array.from(name, (char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127 ? "_" : char).join("");
|
|
39711
39944
|
name = Array.from(name).reduce((result3, char) => Buffer.byteLength(result3 + char) <= 180 ? result3 + char : result3, "").replace(/[ .]+$/u, "");
|
|
39712
39945
|
if (!name || name === "." || name === "..") name = "download";
|
|
@@ -39729,7 +39962,7 @@ function saveArtifact(root2, bytes, name, contentType, secrets = []) {
|
|
|
39729
39962
|
const content = Buffer.from(bytes);
|
|
39730
39963
|
for (const raw of secrets.filter(Boolean)) for (const secret of /* @__PURE__ */ new Set([raw, raw.replace(/^[A-Za-z]+ /u, ""), encodeURIComponent(raw), JSON.stringify(raw).slice(1, -1), Buffer.from(raw).toString("base64")])) if (secret && (content.includes(Buffer.from(secret)) || name.includes(secret))) throw new Error("The file contains protected authentication material; no artifact was saved");
|
|
39731
39964
|
if (bytes.length > downloadLimit) throw new Error(`File exceeds the ${downloadLimit}-byte artifact limit`);
|
|
39732
|
-
const safe = safeFileName(name), directory = join4(root2, "artifacts",
|
|
39965
|
+
const safe = safeFileName(name), directory = join4(root2, "artifacts", randomUUID6());
|
|
39733
39966
|
mkdirSync3(directory, { recursive: true, mode: 448 });
|
|
39734
39967
|
const path2 = join4(directory, safe);
|
|
39735
39968
|
writeFileSync3(path2, bytes, { flag: "wx", mode: 384 });
|
|
@@ -39742,8 +39975,8 @@ function saveDownload(root2, bytes, headers, contract, secrets = []) {
|
|
|
39742
39975
|
if (contentType === "text/csv" || contentType === "text/plain") new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
39743
39976
|
if (["text/html", "application/xhtml+xml"].includes(contentType)) {
|
|
39744
39977
|
const charset = /;\s*charset\s*=\s*["']?([^;\s"']+)/iu.exec(headers.get("content-type") ?? "")?.[1] ?? "utf-8";
|
|
39745
|
-
const
|
|
39746
|
-
if (htmlSecrets(
|
|
39978
|
+
const text5 = new TextDecoder(charset, { fatal: true }).decode(bytes);
|
|
39979
|
+
if (htmlSecrets(text5, true).length) throw new Error("The file contains protected authentication material; no artifact was saved");
|
|
39747
39980
|
}
|
|
39748
39981
|
const name = attachmentName(headers.get("content-disposition")) || contract.name;
|
|
39749
39982
|
if (!name) throw new Error("Download has no verified filename; declare a fallback name");
|
|
@@ -39751,7 +39984,7 @@ function saveDownload(root2, bytes, headers, contract, secrets = []) {
|
|
|
39751
39984
|
}
|
|
39752
39985
|
function verifyArtifact(value) {
|
|
39753
39986
|
const file3 = value;
|
|
39754
|
-
if (!file3 || typeof file3.path !== "string" || typeof file3.name !== "string" || safeFileName(file3.name) !== file3.name ||
|
|
39987
|
+
if (!file3 || typeof file3.path !== "string" || typeof file3.name !== "string" || safeFileName(file3.name) !== file3.name || basename2(file3.path) !== file3.name || typeof file3.contentType !== "string" || !Number.isSafeInteger(file3.bytes) || file3.bytes < 0 || file3.bytes > downloadLimit || !/^[0-9a-f]{64}$/u.test(file3.sha256)) throw new Error("File artifact metadata is invalid");
|
|
39755
39988
|
const bytes = localBytes(file3.path, downloadLimit);
|
|
39756
39989
|
if (bytes.length !== file3.bytes || digest2(bytes) !== file3.sha256) throw new Error("File artifact is missing, incomplete or changed; retain the evidence without repeating a mutation");
|
|
39757
39990
|
return file3;
|
|
@@ -39812,8 +40045,8 @@ function csvBytes(source, contract) {
|
|
|
39812
40045
|
if (!Array.isArray(rows) || rows.length > 1e5) throw new Error("CSV source must be an array of at most 100000 rows");
|
|
39813
40046
|
const cell = (value) => {
|
|
39814
40047
|
if (value !== null && !["string", "number", "boolean"].includes(typeof value)) throw new Error("CSV columns must select scalar values or null");
|
|
39815
|
-
const
|
|
39816
|
-
return /[",\r\n]/u.test(
|
|
40048
|
+
const text5 = value === null ? "" : String(value);
|
|
40049
|
+
return /[",\r\n]/u.test(text5) ? `"${text5.replaceAll('"', '""')}"` : text5;
|
|
39817
40050
|
};
|
|
39818
40051
|
const lines = [contract.columns.map((column) => cell(column.name)).join(",")];
|
|
39819
40052
|
let size = Buffer.byteLength(lines[0]) + 2;
|
|
@@ -39849,14 +40082,14 @@ var init_file_artifacts = __esm({
|
|
|
39849
40082
|
init_html_secrets();
|
|
39850
40083
|
uploadLimit = 16 * 1024 * 1024;
|
|
39851
40084
|
downloadLimit = 24 * 1024 * 1024;
|
|
39852
|
-
digest2 = (bytes) =>
|
|
40085
|
+
digest2 = (bytes) => createHash7("sha256").update(bytes).digest("hex");
|
|
39853
40086
|
mime = (value) => value.split(";", 1)[0].trim().toLowerCase();
|
|
39854
40087
|
missing = Symbol("missing");
|
|
39855
40088
|
}
|
|
39856
40089
|
});
|
|
39857
40090
|
|
|
39858
40091
|
// src/execution/web-response.ts
|
|
39859
|
-
import { createHash as
|
|
40092
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
39860
40093
|
function acceptsResponse(status, contract) {
|
|
39861
40094
|
return status >= 200 && status < 400 && (contract?.statuses?.includes(status) ?? status < 300);
|
|
39862
40095
|
}
|
|
@@ -39947,12 +40180,12 @@ function pointer3(value, path2) {
|
|
|
39947
40180
|
}
|
|
39948
40181
|
return value;
|
|
39949
40182
|
}
|
|
39950
|
-
function parseHtml(
|
|
39951
|
-
if (Buffer.byteLength(
|
|
39952
|
-
return load(
|
|
40183
|
+
function parseHtml(text5) {
|
|
40184
|
+
if (Buffer.byteLength(text5) > 48 * 1024 * 1024) throw new ResponseContractFailure("HTML exceeds the textual evidence limit");
|
|
40185
|
+
return load(text5);
|
|
39953
40186
|
}
|
|
39954
|
-
function htmlExtract(
|
|
39955
|
-
const $ = parseHtml(
|
|
40187
|
+
function htmlExtract(text5, contract) {
|
|
40188
|
+
const $ = parseHtml(text5);
|
|
39956
40189
|
if ($(contract.marker).length !== 1) throw new ResponseContractFailure("HTML page marker must match exactly once");
|
|
39957
40190
|
if (contract.errors && $(contract.errors).toArray().some((e) => $(e).text().trim())) throw new ResponseContractFailure("The app returned form validation errors; inspect the retained response before changing inputs");
|
|
39958
40191
|
let work = 0;
|
|
@@ -40027,18 +40260,18 @@ function decodeBody(result3, contract) {
|
|
|
40027
40260
|
const body = result3.body;
|
|
40028
40261
|
const artifact = verifyArtifact(body?.artifact);
|
|
40029
40262
|
if (contract.file && !contract.file.contentTypes.includes(artifact.contentType)) throw new Error("Artifact content type does not match the response contract");
|
|
40030
|
-
if (contract.csv && (artifact.contentType !== "text/csv" ||
|
|
40263
|
+
if (contract.csv && (artifact.contentType !== "text/csv" || createHash8("sha256").update(csvBytes(body?.source, contract.csv)).digest("hex") !== artifact.sha256)) throw new Error("CSV artifact does not match the declared columns and saved source");
|
|
40031
40264
|
return artifact;
|
|
40032
40265
|
} catch (error62) {
|
|
40033
40266
|
throw new ResponseContractFailure(error62 instanceof Error ? error62.message : "File artifact is invalid");
|
|
40034
40267
|
}
|
|
40035
40268
|
}
|
|
40036
40269
|
if (contract?.format === "html") {
|
|
40037
|
-
const
|
|
40038
|
-
if (
|
|
40270
|
+
const text5 = result3.rawText ?? (typeof result3.body === "string" ? result3.body : void 0);
|
|
40271
|
+
if (text5 === void 0 || !contract.html) throw new ResponseContractFailure("The app did not return the declared HTML response");
|
|
40039
40272
|
const mime2 = result3.response.headers.get("content-type");
|
|
40040
40273
|
if (mime2 && !/\b(?:text\/html|application\/xhtml\+xml)\b/iu.test(mime2)) throw new ResponseContractFailure("The app returned an unexpected format for an HTML contract");
|
|
40041
|
-
return htmlExtract(
|
|
40274
|
+
return htmlExtract(text5, contract.html);
|
|
40042
40275
|
}
|
|
40043
40276
|
if (result3.rawText === void 0) return result3.body;
|
|
40044
40277
|
if (!result3.rawText || [204, 205].includes(result3.response.status)) return null;
|
|
@@ -40207,11 +40440,11 @@ function publicObservedResponseSchema(schema, ...evidence) {
|
|
|
40207
40440
|
};
|
|
40208
40441
|
return project(schema);
|
|
40209
40442
|
}
|
|
40210
|
-
function inspectHtml(
|
|
40211
|
-
if (Buffer.byteLength(
|
|
40212
|
-
const $ = load(
|
|
40443
|
+
function inspectHtml(text5, selector) {
|
|
40444
|
+
if (Buffer.byteLength(text5) > 48 * 1024 * 1024) throw new Error("HTML exceeds the textual evidence limit");
|
|
40445
|
+
const $ = load(text5);
|
|
40213
40446
|
if (selector) {
|
|
40214
|
-
const secrets = htmlSecrets(
|
|
40447
|
+
const secrets = htmlSecrets(text5);
|
|
40215
40448
|
const protect = (value) => {
|
|
40216
40449
|
for (const secret of secrets) value = value.split(secret).join("<redacted>");
|
|
40217
40450
|
return value.slice(0, 500);
|
|
@@ -40322,7 +40555,7 @@ var init_observed_shape = __esm({
|
|
|
40322
40555
|
});
|
|
40323
40556
|
|
|
40324
40557
|
// src/discovery/response-observation.ts
|
|
40325
|
-
import { createHash as
|
|
40558
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
40326
40559
|
function unknownJsonShape(schema) {
|
|
40327
40560
|
if (schema === void 0 || schema === true) return true;
|
|
40328
40561
|
if (!isObject2(schema)) return false;
|
|
@@ -40338,15 +40571,15 @@ function observationScope(installation, registry2, sessionId, appId, actionName)
|
|
|
40338
40571
|
}
|
|
40339
40572
|
function identity2(scope2, revision) {
|
|
40340
40573
|
if (!revision.executableHash || !Number.isSafeInteger(revision.version) || revision.version < 1) return;
|
|
40341
|
-
const key2 =
|
|
40574
|
+
const key2 = createHash9("sha256").update(canonicalJson(scope2)).digest("hex");
|
|
40342
40575
|
const { version: version2, executableHash: executableHash2, definition: definition2 } = revision;
|
|
40343
|
-
const fingerprint2 =
|
|
40576
|
+
const fingerprint2 = createHash9("sha256").update(canonicalJson({ version: version2, executableHash: executableHash2, definition: definition2 })).digest("hex");
|
|
40344
40577
|
return { key: key2, fingerprint: fingerprint2 };
|
|
40345
40578
|
}
|
|
40346
40579
|
function boundedObservationInput(...values) {
|
|
40347
40580
|
let remaining = maximumNodes;
|
|
40348
40581
|
let textRemaining = maximumTextLength;
|
|
40349
|
-
const boundedText = (
|
|
40582
|
+
const boundedText = (text5) => text5.length <= maximumScalarLength && (textRemaining -= text5.length) >= 0;
|
|
40350
40583
|
function visit4(value, depth) {
|
|
40351
40584
|
if (--remaining < 0 || depth > maximumDepth) return false;
|
|
40352
40585
|
if (typeof value === "string") return boundedText(value);
|
|
@@ -40460,8 +40693,8 @@ function preparedFields(value, paths2, credentials) {
|
|
|
40460
40693
|
if (!selected || typeof selected !== "object" || !Object.hasOwn(selected, part)) throw new Error("Private preparation omitted a result field");
|
|
40461
40694
|
selected = selected[part];
|
|
40462
40695
|
}
|
|
40463
|
-
const
|
|
40464
|
-
if (!["string", "number", "boolean"].includes(typeof selected) || typeof selected === "number" && !Number.isFinite(selected) || !
|
|
40696
|
+
const text5 = String(selected);
|
|
40697
|
+
if (!["string", "number", "boolean"].includes(typeof selected) || typeof selected === "number" && !Number.isFinite(selected) || !text5 || text5.length > 2048 || [...text5].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) || /\[REDACTED\]|[?#]|:\/\/|^\/\//u.test(text5) || secrets.filter(Boolean).some((secret) => text5 === secret || secret.length >= 4 && (text5.includes(secret) || text5.includes(encodeURIComponent(secret))))) throw new Error("Prepared results must be bounded resource identifiers without signing material or URLs");
|
|
40465
40698
|
return [path2, selected];
|
|
40466
40699
|
}));
|
|
40467
40700
|
}
|
|
@@ -40472,13 +40705,13 @@ var init_prepared_fields = __esm({
|
|
|
40472
40705
|
});
|
|
40473
40706
|
|
|
40474
40707
|
// src/browser-response.ts
|
|
40475
|
-
import { createHash as
|
|
40708
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
40476
40709
|
async function browserResponseBody(client, scopeId, value, maxBytes = 48 * 1024 * 1024) {
|
|
40477
40710
|
if (value.bodyArtifact !== void 0) {
|
|
40478
40711
|
const artifact = value.bodyArtifact;
|
|
40479
40712
|
if (value.body != null || !artifact || typeof artifact.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(artifact.sha256) || !Number.isInteger(artifact.bytes) || Number(artifact.bytes) < 1 || Number(artifact.bytes) > maxBytes || artifact.encoding !== "utf-8") throw new Error("Chrome returned invalid response evidence metadata");
|
|
40480
40713
|
const bytes = await client.blob(scopeId, artifact.sha256);
|
|
40481
|
-
if (!bytes || bytes.length !== artifact.bytes ||
|
|
40714
|
+
if (!bytes || bytes.length !== artifact.bytes || createHash10("sha256").update(bytes).digest("hex") !== artifact.sha256) throw new Error("Chrome response evidence is missing or failed its integrity check");
|
|
40482
40715
|
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
40483
40716
|
}
|
|
40484
40717
|
if (value.body == null) return null;
|
|
@@ -40492,10 +40725,10 @@ var init_browser_response = __esm({
|
|
|
40492
40725
|
});
|
|
40493
40726
|
|
|
40494
40727
|
// src/execution-cache.ts
|
|
40495
|
-
import { createHash as
|
|
40728
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
40496
40729
|
async function executionBundle(api, state, app2, action) {
|
|
40497
40730
|
state.db.exec("CREATE TABLE IF NOT EXISTS execution_content (scope TEXT NOT NULL, app TEXT NOT NULL, action TEXT NOT NULL, versions TEXT NOT NULL, touched_at INTEGER NOT NULL, PRIMARY KEY(scope,app,action))");
|
|
40498
|
-
const scope2 =
|
|
40731
|
+
const scope2 = createHash11("sha256").update(JSON.stringify([api.cacheNamespace, state.installation()])).digest("hex");
|
|
40499
40732
|
const row = state.db.prepare("SELECT versions FROM execution_content WHERE scope=? AND app=? AND action=?").get(scope2, app2, action);
|
|
40500
40733
|
let cached2 = [];
|
|
40501
40734
|
try {
|
|
@@ -40511,7 +40744,7 @@ async function executionBundle(api, state, app2, action) {
|
|
|
40511
40744
|
}
|
|
40512
40745
|
}
|
|
40513
40746
|
const bundle2 = await api.call("getBundle", { params: { app: app2, action }, query: { knownVersions: known.map((version2) => version2.versionId).join(",") } });
|
|
40514
|
-
if (scope2 !==
|
|
40747
|
+
if (scope2 !== createHash11("sha256").update(JSON.stringify([api.cacheNamespace, state.installation()])).digest("hex")) throw new Error("execution-identity-changed");
|
|
40515
40748
|
for (const version2 of bundle2.closure.versions) {
|
|
40516
40749
|
if (!version2.definition) version2.definition = known.find((prior) => prior.versionId === version2.versionId && prior.kind === version2.kind && prior.name === version2.name && prior.executableHash === version2.executableHash)?.definition;
|
|
40517
40750
|
if (!version2.definition) throw new Error("execution-content-missing");
|
|
@@ -40531,7 +40764,7 @@ var init_execution_cache = __esm({
|
|
|
40531
40764
|
|
|
40532
40765
|
// src/timings.ts
|
|
40533
40766
|
import { appendFileSync } from "node:fs";
|
|
40534
|
-
import { resolve } from "node:path";
|
|
40767
|
+
import { resolve as resolve2 } from "node:path";
|
|
40535
40768
|
function executionTimings() {
|
|
40536
40769
|
return { brokerMs: 0, bridgeMs: 0, registryMs: 0, bindingMs: 0, replayMs: 0, appMs: 0, proofMs: 0, reportingMs: 0 };
|
|
40537
40770
|
}
|
|
@@ -40546,7 +40779,7 @@ async function timed(timings, stage, work) {
|
|
|
40546
40779
|
function saveTimings(timings, commandMs) {
|
|
40547
40780
|
if (!process.env.APILIFT_TIMING_FILE) return;
|
|
40548
40781
|
try {
|
|
40549
|
-
appendFileSync(
|
|
40782
|
+
appendFileSync(resolve2(process.env.APILIFT_TIMING_FILE), JSON.stringify({ ...Object.fromEntries(Object.entries(timings).map(([key2, value]) => [key2, Math.round(value * 100) / 100])), commandMs: Math.round(commandMs * 100) / 100 }) + "\n", { mode: 384 });
|
|
40550
40783
|
} catch {
|
|
40551
40784
|
}
|
|
40552
40785
|
}
|
|
@@ -40557,16 +40790,16 @@ var init_timings = __esm({
|
|
|
40557
40790
|
});
|
|
40558
40791
|
|
|
40559
40792
|
// src/files.ts
|
|
40560
|
-
import { randomUUID as
|
|
40561
|
-
import { accessSync, constants as
|
|
40562
|
-
import { dirname, join as join5, resolve as
|
|
40793
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
40794
|
+
import { accessSync, constants as constants4, existsSync as existsSync2, statSync as statSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
40795
|
+
import { dirname, join as join5, resolve as resolve3 } from "node:path";
|
|
40563
40796
|
function outputDestination(file3) {
|
|
40564
|
-
const target =
|
|
40797
|
+
const target = resolve3(file3);
|
|
40565
40798
|
if (existsSync2(target)) {
|
|
40566
40799
|
if (!statSync3(target).isFile()) throw new Error("Output destination must be a regular file");
|
|
40567
|
-
accessSync(target,
|
|
40800
|
+
accessSync(target, constants4.W_OK);
|
|
40568
40801
|
}
|
|
40569
|
-
const probe = join5(dirname(target), `.apilift-output-check-${
|
|
40802
|
+
const probe = join5(dirname(target), `.apilift-output-check-${randomUUID7()}`);
|
|
40570
40803
|
try {
|
|
40571
40804
|
writeFileSync4(probe, "", { flag: "wx", mode: 384 });
|
|
40572
40805
|
} finally {
|
|
@@ -40584,7 +40817,7 @@ var init_files = __esm({
|
|
|
40584
40817
|
});
|
|
40585
40818
|
|
|
40586
40819
|
// src/execution/operation-claims.ts
|
|
40587
|
-
import { createHash as
|
|
40820
|
+
import { createHash as createHash12, randomUUID as randomUUID8 } from "node:crypto";
|
|
40588
40821
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync4, renameSync as renameSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
40589
40822
|
import { join as join6 } from "node:path";
|
|
40590
40823
|
var OperationRefused, OperationClaim;
|
|
@@ -40603,13 +40836,13 @@ var init_operation_claims = __esm({
|
|
|
40603
40836
|
constructor(db, root2, id2, binding2) {
|
|
40604
40837
|
this.db = db;
|
|
40605
40838
|
this.root = root2;
|
|
40606
|
-
this.key =
|
|
40607
|
-
this.binding =
|
|
40839
|
+
this.key = createHash12("sha256").update(id2).digest("hex");
|
|
40840
|
+
this.binding = createHash12("sha256").update(canonicalJson(binding2)).digest("hex");
|
|
40608
40841
|
db.exec("CREATE TABLE IF NOT EXISTS mutation_operation (id TEXT PRIMARY KEY, binding TEXT NOT NULL, tab TEXT, owner TEXT NOT NULL, output TEXT)");
|
|
40609
40842
|
}
|
|
40610
40843
|
key;
|
|
40611
40844
|
binding;
|
|
40612
|
-
owner =
|
|
40845
|
+
owner = randomUUID8();
|
|
40613
40846
|
inspect(tab) {
|
|
40614
40847
|
const row = this.db.prepare("SELECT binding, tab, owner, output FROM mutation_operation WHERE id=?").get(this.key);
|
|
40615
40848
|
if (!row) return;
|
|
@@ -40651,7 +40884,7 @@ var init_operation_claims = __esm({
|
|
|
40651
40884
|
});
|
|
40652
40885
|
|
|
40653
40886
|
// src/discovery/file-setup.ts
|
|
40654
|
-
import { randomUUID as
|
|
40887
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
40655
40888
|
import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
40656
40889
|
import { join as join7 } from "node:path";
|
|
40657
40890
|
function setupTarget(source) {
|
|
@@ -40713,7 +40946,7 @@ var init_file_setup = __esm({
|
|
|
40713
40946
|
return this.state.db.prepare("SELECT request_id,body,operation FROM discovery_setup_publication WHERE account_id=? AND workspace_id=? AND app=? AND kind=? AND name=?").get(...this.scope);
|
|
40714
40947
|
}
|
|
40715
40948
|
prepare(operation2, body) {
|
|
40716
|
-
this.state.db.prepare("INSERT OR IGNORE INTO discovery_setup_publication VALUES (?,?,?,?,?,?,?,?)").run(...this.scope,
|
|
40949
|
+
this.state.db.prepare("INSERT OR IGNORE INTO discovery_setup_publication VALUES (?,?,?,?,?,?,?,?)").run(...this.scope, randomUUID9(), canonicalJson(body), operation2);
|
|
40717
40950
|
return this.pending();
|
|
40718
40951
|
}
|
|
40719
40952
|
settle(requestId) {
|
|
@@ -40728,7 +40961,7 @@ var init_file_setup = __esm({
|
|
|
40728
40961
|
artifactPath() {
|
|
40729
40962
|
const dir = join7(this.root, "discovery-probes");
|
|
40730
40963
|
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
40731
|
-
return join7(dir, `${
|
|
40964
|
+
return join7(dir, `${randomUUID9()}.json`);
|
|
40732
40965
|
}
|
|
40733
40966
|
};
|
|
40734
40967
|
}
|
|
@@ -40736,7 +40969,7 @@ var init_file_setup = __esm({
|
|
|
40736
40969
|
|
|
40737
40970
|
// src/discovery/semantic-review.ts
|
|
40738
40971
|
import { existsSync as existsSync3, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync4 } from "node:fs";
|
|
40739
|
-
import { isAbsolute as isAbsolute2, resolve as
|
|
40972
|
+
import { isAbsolute as isAbsolute2, resolve as resolve4 } from "node:path";
|
|
40740
40973
|
import { isDeepStrictEqual } from "node:util";
|
|
40741
40974
|
function json3(value, seen = /* @__PURE__ */ new Set()) {
|
|
40742
40975
|
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
@@ -40875,7 +41108,7 @@ function comparisonSource(entry2, inputs, resultPath) {
|
|
|
40875
41108
|
const file3 = realpathSync2(entry2.file);
|
|
40876
41109
|
const stats = statSync4(file3);
|
|
40877
41110
|
if (resultPath) {
|
|
40878
|
-
if (
|
|
41111
|
+
if (resolve4(entry2.file) === resolve4(resultPath)) throw new Error();
|
|
40879
41112
|
if (existsSync3(resultPath)) {
|
|
40880
41113
|
const current = statSync4(resultPath);
|
|
40881
41114
|
if (file3 === realpathSync2(resultPath) || stats.dev === current.dev && stats.ino === current.ino) throw new Error();
|
|
@@ -41094,7 +41327,7 @@ var init_envelope = __esm({
|
|
|
41094
41327
|
});
|
|
41095
41328
|
|
|
41096
41329
|
// src/discovery/credential-draft.ts
|
|
41097
|
-
import { createHash as
|
|
41330
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
41098
41331
|
function readCredentialDraft(filePath, target) {
|
|
41099
41332
|
const source = readDraftFile(filePath);
|
|
41100
41333
|
if (target) {
|
|
@@ -41112,7 +41345,7 @@ function readCredentialDraft(filePath, target) {
|
|
|
41112
41345
|
const transport = checked.definition;
|
|
41113
41346
|
if (credentialAuthoringIssues(transport).length) throw new Error(`Replace the encoded Basic credential contract in ${filePath}: declare raw saved fields and definition.httpBasic with no prefix. Apilift encodes at dispatch; do not ask the person to encode a key`);
|
|
41114
41347
|
if (!transport.description.trim()) throw new Error(`Research credential acquisition and edit /definition/description in ${filePath}. Run discover check with this file before secure setup`);
|
|
41115
|
-
return { transport, fingerprint:
|
|
41348
|
+
return { transport, fingerprint: createHash13("sha256").update(canonicalJson(target ? { app: target.app, appId: target.appId, name: target.name, transport } : transport)).digest("hex") };
|
|
41116
41349
|
}
|
|
41117
41350
|
var init_credential_draft = __esm({
|
|
41118
41351
|
"src/discovery/credential-draft.ts"() {
|
|
@@ -41143,13 +41376,13 @@ var init_process = __esm({
|
|
|
41143
41376
|
});
|
|
41144
41377
|
|
|
41145
41378
|
// src/capture-server/demand.ts
|
|
41146
|
-
import { randomUUID as
|
|
41379
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
41147
41380
|
import { join as join8 } from "node:path";
|
|
41148
41381
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
41149
41382
|
async function waitForBridge(root2, version2, timeoutMs = 9e4, wake, compatibleBrokerVersion) {
|
|
41150
41383
|
const db = open2(root2);
|
|
41151
41384
|
db.exec("PRAGMA busy_timeout=1000");
|
|
41152
|
-
const id2 =
|
|
41385
|
+
const id2 = randomUUID10(), now = Date.now(), ownerStartedAt = now - process.uptime() * 1e3;
|
|
41153
41386
|
const expiry = now + timeoutMs;
|
|
41154
41387
|
const sequenced = db.prepare("PRAGMA table_info(bridge_status)").all().some((column) => column.name === "sequence");
|
|
41155
41388
|
let priorSequence = -1;
|
|
@@ -41173,7 +41406,7 @@ async function waitForBridge(root2, version2, timeoutMs = 9e4, wake, compatibleB
|
|
|
41173
41406
|
process.stderr.write("Waiting for the Apilift browser connection.\n");
|
|
41174
41407
|
announced = true;
|
|
41175
41408
|
}
|
|
41176
|
-
await new Promise((
|
|
41409
|
+
await new Promise((resolve17) => setTimeout(resolve17, 20));
|
|
41177
41410
|
}
|
|
41178
41411
|
throw Object.assign(new Error(`The Apilift browser did not respond within ${timeoutMs / 1e3} seconds. Verify that Chrome is running with the extension enabled, then retry this command. No app action was sent.`), { code: "extension-unavailable" });
|
|
41179
41412
|
} finally {
|
|
@@ -41194,8 +41427,8 @@ var init_demand = __esm({
|
|
|
41194
41427
|
});
|
|
41195
41428
|
|
|
41196
41429
|
// src/capture-server/client.ts
|
|
41197
|
-
import { createHash as
|
|
41198
|
-
import { chmodSync as chmodSync3, existsSync as existsSync4, lstatSync as
|
|
41430
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
41431
|
+
import { chmodSync as chmodSync3, existsSync as existsSync4, lstatSync as lstatSync3, mkdirSync as mkdirSync6, readFileSync as readFileSync6, realpathSync as realpathSync3, rmSync as rmSync4 } from "node:fs";
|
|
41199
41432
|
import { dirname as dirname2, join as join9 } from "node:path";
|
|
41200
41433
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
41201
41434
|
function knownLegacyBroker(version2) {
|
|
@@ -41245,8 +41478,8 @@ async function ensureCaptureServer(options2) {
|
|
|
41245
41478
|
const key2 = realpathSync3(locks);
|
|
41246
41479
|
const previous = localBrokerQueue.get(key2);
|
|
41247
41480
|
let release;
|
|
41248
|
-
const done = new Promise((
|
|
41249
|
-
release =
|
|
41481
|
+
const done = new Promise((resolve17) => {
|
|
41482
|
+
release = resolve17;
|
|
41250
41483
|
});
|
|
41251
41484
|
localBrokerQueue.set(key2, done);
|
|
41252
41485
|
try {
|
|
@@ -41315,7 +41548,7 @@ async function ensureCaptureServerUnderUpdateLock(options2) {
|
|
|
41315
41548
|
} catch {
|
|
41316
41549
|
}
|
|
41317
41550
|
}
|
|
41318
|
-
await new Promise((
|
|
41551
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
41319
41552
|
}
|
|
41320
41553
|
throw new Error("Capture server did not become ready within 10 seconds");
|
|
41321
41554
|
} finally {
|
|
@@ -41387,7 +41620,7 @@ var init_client2 = __esm({
|
|
|
41387
41620
|
throw Object.assign(new Error(issue2.error?.message ?? `Capture server HTTP ${response.status}`), { code: issue2.error?.code ?? "capture-server-error" });
|
|
41388
41621
|
}
|
|
41389
41622
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
41390
|
-
if (
|
|
41623
|
+
if (createHash14("sha256").update(bytes).digest("hex") !== digest6) throw Object.assign(new Error("Selected body digest does not match stored bytes"), { code: "blob-integrity" });
|
|
41391
41624
|
return bytes;
|
|
41392
41625
|
}
|
|
41393
41626
|
openScope(input2) {
|
|
@@ -41512,7 +41745,7 @@ async function inspectTabs(client, appId, contextId, pageOrigin) {
|
|
|
41512
41745
|
const remaining = Math.max(0, deadline - Date.now());
|
|
41513
41746
|
const { candidates, reported } = await client.candidates(scope2.id, client.legacyBridge ? 0 : Math.min(remaining, 1e3), !client.legacyBridge);
|
|
41514
41747
|
if (candidates.length || reported === true) return candidates;
|
|
41515
|
-
if (Date.now() < deadline) await new Promise((
|
|
41748
|
+
if (Date.now() < deadline) await new Promise((resolve17) => setTimeout(resolve17, client.legacyBridge ? 250 : 10));
|
|
41516
41749
|
} while (Date.now() < deadline);
|
|
41517
41750
|
return [];
|
|
41518
41751
|
} finally {
|
|
@@ -41573,7 +41806,7 @@ var init_browser = __esm({
|
|
|
41573
41806
|
init_demand();
|
|
41574
41807
|
ok = (stdout) => ({ stdout, stderr: "", exitCode: 0 });
|
|
41575
41808
|
fail = (stderr, exitCode = 5) => ({ stdout: "", stderr, exitCode });
|
|
41576
|
-
command = (invocation,
|
|
41809
|
+
command = (invocation, text5) => `apilift${invocation.sessionLabel ? ` --session ${invocation.sessionLabel}` : ""} ${text5}`;
|
|
41577
41810
|
BrowserControlError = class extends Error {
|
|
41578
41811
|
constructor(message2, code, dispatched = false) {
|
|
41579
41812
|
super(message2);
|
|
@@ -41586,14 +41819,14 @@ var init_browser = __esm({
|
|
|
41586
41819
|
|
|
41587
41820
|
// src/state.ts
|
|
41588
41821
|
import { chmodSync as chmodSync4, mkdirSync as mkdirSync7 } from "node:fs";
|
|
41589
|
-
import { homedir, platform } from "node:os";
|
|
41590
|
-
import { isAbsolute as isAbsolute3, join as join11, resolve as
|
|
41822
|
+
import { homedir, platform as platform2 } from "node:os";
|
|
41823
|
+
import { isAbsolute as isAbsolute3, join as join11, resolve as resolve5 } from "node:path";
|
|
41591
41824
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
41592
41825
|
function dataRoot(env) {
|
|
41593
|
-
if (env.APILIFT_HOME) return
|
|
41826
|
+
if (env.APILIFT_HOME) return resolve5(env.APILIFT_HOME);
|
|
41594
41827
|
const home = homedir();
|
|
41595
|
-
if (
|
|
41596
|
-
if (
|
|
41828
|
+
if (platform2() === "darwin") return join11(home, "Library", "Application Support", "apilift");
|
|
41829
|
+
if (platform2() === "win32") return join11(env.LOCALAPPDATA || join11(home, "AppData", "Local"), "apilift");
|
|
41597
41830
|
return join11(env.XDG_DATA_HOME && isAbsolute3(env.XDG_DATA_HOME) ? env.XDG_DATA_HOME : join11(home, ".local", "share"), "apilift");
|
|
41598
41831
|
}
|
|
41599
41832
|
var LocalState;
|
|
@@ -41711,7 +41944,7 @@ var init_state = __esm({
|
|
|
41711
41944
|
});
|
|
41712
41945
|
|
|
41713
41946
|
// src/native-host/credentials.ts
|
|
41714
|
-
import { createCipheriv, createDecipheriv, randomBytes, randomUUID as
|
|
41947
|
+
import { createCipheriv, createDecipheriv, randomBytes, randomUUID as randomUUID11 } from "node:crypto";
|
|
41715
41948
|
var CredentialError, sameNames, sameRequirements, CredentialStore;
|
|
41716
41949
|
var init_credentials = __esm({
|
|
41717
41950
|
"src/native-host/credentials.ts"() {
|
|
@@ -41802,7 +42035,7 @@ var init_credentials = __esm({
|
|
|
41802
42035
|
if (!name || name.length > 80) throw new CredentialError("credential-label-invalid", "Credential label must be 1\u201380 characters");
|
|
41803
42036
|
const names3 = binding2.requirements.map((item) => item.name);
|
|
41804
42037
|
if (!sameNames(Object.keys(binding2.fields), names3) || Object.values(binding2.fields).some((value) => !value)) throw new CredentialError("credential-fields-invalid", "Credential fields do not match the current transport requirements");
|
|
41805
|
-
const id2 =
|
|
42038
|
+
const id2 = randomUUID11(), key2 = randomBytes(32), iv = randomBytes(12), cipher = createCipheriv("aes-256-gcm", key2, iv);
|
|
41806
42039
|
const ciphertext = Buffer.concat([cipher.update(JSON.stringify(binding2.fields), "utf8"), cipher.final()]), tag = cipher.getAuthTag();
|
|
41807
42040
|
await this.vault.put(id2, key2.toString("base64"));
|
|
41808
42041
|
try {
|
|
@@ -41958,9 +42191,9 @@ var init_vault = __esm({
|
|
|
41958
42191
|
});
|
|
41959
42192
|
|
|
41960
42193
|
// src/commands/run.ts
|
|
41961
|
-
import { randomUUID as
|
|
42194
|
+
import { randomUUID as randomUUID12, randomBytes as randomBytes2, createHmac } from "node:crypto";
|
|
41962
42195
|
import { readFileSync as readFileSync7, renameSync as renameSync3, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8 } from "node:fs";
|
|
41963
|
-
import { dirname as dirname4, resolve as
|
|
42196
|
+
import { dirname as dirname4, resolve as resolve6, join as join12 } from "node:path";
|
|
41964
42197
|
function pointer5(value, path2) {
|
|
41965
42198
|
if (path2 === "") return value;
|
|
41966
42199
|
if (!path2.startsWith("/") || /~(?![01])/u.test(path2)) throw new Error(`Invalid JSON Pointer ${path2}`);
|
|
@@ -42022,14 +42255,14 @@ function actionFlags(args, schema) {
|
|
|
42022
42255
|
}
|
|
42023
42256
|
function jsonInput(raw, stdin) {
|
|
42024
42257
|
if (!raw) return {};
|
|
42025
|
-
let
|
|
42026
|
-
if (raw === "-")
|
|
42027
|
-
else if (raw.startsWith("@"))
|
|
42028
|
-
else
|
|
42258
|
+
let text5;
|
|
42259
|
+
if (raw === "-") text5 = stdin();
|
|
42260
|
+
else if (raw.startsWith("@")) text5 = readFileSync7(raw.slice(1), "utf8");
|
|
42261
|
+
else text5 = raw;
|
|
42029
42262
|
const errors = [];
|
|
42030
42263
|
const objects2 = [];
|
|
42031
42264
|
let duplicate;
|
|
42032
|
-
visit3(
|
|
42265
|
+
visit3(text5, { onObjectBegin: () => {
|
|
42033
42266
|
objects2.push(/* @__PURE__ */ new Set());
|
|
42034
42267
|
}, onObjectProperty: (name) => {
|
|
42035
42268
|
const current = objects2.at(-1);
|
|
@@ -42038,7 +42271,7 @@ function jsonInput(raw, stdin) {
|
|
|
42038
42271
|
}, onObjectEnd: () => {
|
|
42039
42272
|
objects2.pop();
|
|
42040
42273
|
} }, { allowTrailingComma: true });
|
|
42041
|
-
const value = parse4(
|
|
42274
|
+
const value = parse4(text5, errors, { allowTrailingComma: true });
|
|
42042
42275
|
if (errors.length) throw new Error("--input is not valid JSON/JSONC");
|
|
42043
42276
|
if (duplicate) throw new Error(`--input repeats the ${duplicate} key`);
|
|
42044
42277
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("--input must be a JSON object");
|
|
@@ -42271,10 +42504,10 @@ function urlInputSecrets(request2) {
|
|
|
42271
42504
|
const querySecrets = [...searchParams].filter(([name, value]) => value.length >= 16 || /token|nonce|sig|policy|key|credential|auth|secret/iu.test(name)).map(([, value]) => value);
|
|
42272
42505
|
return [...new Set([request2.inputUrl, request2.url.href, ...search ? [pathname + search, search] : [], ...querySecrets].filter(Boolean))];
|
|
42273
42506
|
}
|
|
42274
|
-
function decodedBody(
|
|
42275
|
-
if (!
|
|
42507
|
+
function decodedBody(text5, status, allowNonJsonProbe) {
|
|
42508
|
+
if (!text5) return null;
|
|
42276
42509
|
try {
|
|
42277
|
-
return JSON.parse(
|
|
42510
|
+
return JSON.parse(text5);
|
|
42278
42511
|
} catch {
|
|
42279
42512
|
if (allowNonJsonProbe) return { responseFormat: "non-JSON", httpStatus: status };
|
|
42280
42513
|
throw new ResponseContractFailure("The app returned non-JSON data for a JSON response contract");
|
|
@@ -42283,8 +42516,8 @@ function decodedBody(text4, status, allowNonJsonProbe) {
|
|
|
42283
42516
|
async function responseBody(response, allowNonJsonProbe = false) {
|
|
42284
42517
|
if (response.status === 204 || response.status === 205) return null;
|
|
42285
42518
|
if (!response.ok && !response.headers.get("content-type")?.includes("json")) return null;
|
|
42286
|
-
const
|
|
42287
|
-
return decodedBody(
|
|
42519
|
+
const text5 = await response.text();
|
|
42520
|
+
return decodedBody(text5, response.status, allowNonJsonProbe);
|
|
42288
42521
|
}
|
|
42289
42522
|
function selectPointers(full, paths2) {
|
|
42290
42523
|
const selection = {};
|
|
@@ -42312,8 +42545,8 @@ function selectPointers(full, paths2) {
|
|
|
42312
42545
|
return selection;
|
|
42313
42546
|
}
|
|
42314
42547
|
function writeOutput(path2, content) {
|
|
42315
|
-
path2 =
|
|
42316
|
-
const pending = join12(dirname4(path2), `.apilift-output-${
|
|
42548
|
+
path2 = resolve6(path2);
|
|
42549
|
+
const pending = join12(dirname4(path2), `.apilift-output-${randomUUID12()}`);
|
|
42317
42550
|
try {
|
|
42318
42551
|
writeFileSync6(pending, content, { flag: "wx", mode: 384 });
|
|
42319
42552
|
renameSync3(pending, path2);
|
|
@@ -42413,7 +42646,7 @@ async function sendBrowser(root2, appId, contextName, pageOrigin, effect2, trans
|
|
|
42413
42646
|
if (selection.timings) selection.timings.bindingMs += performance.now() - bindingStarted;
|
|
42414
42647
|
}
|
|
42415
42648
|
const replayStarted = performance.now();
|
|
42416
|
-
const id2 =
|
|
42649
|
+
const id2 = randomUUID12();
|
|
42417
42650
|
try {
|
|
42418
42651
|
const headers = Object.fromEntries(new Headers(prepared.init.headers).entries());
|
|
42419
42652
|
const responseMetadata = Boolean(selection.responseContract?.statuses || selection.responseContract?.headers);
|
|
@@ -42482,7 +42715,7 @@ async function sendBrowser(root2, appId, contextName, pageOrigin, effect2, trans
|
|
|
42482
42715
|
return { response, body: decoded, ...retained ? { preparedFields: value.preparedFields } : {}, ...!allowNonJsonProbe ? { rawText: evidence ?? "" } : {}, finalUrl: typeof value.url === "string" ? value.url : prepared.url.href, redirected: value.redirected === true, ...value.profileId ? { profileId: value.profileId } : {} };
|
|
42483
42716
|
}
|
|
42484
42717
|
if (held.status === "uncertain") throw new Error("Chrome execution outcome is uncertain");
|
|
42485
|
-
await new Promise((
|
|
42718
|
+
await new Promise((resolve17) => setTimeout(resolve17, client.legacyBridge ? 200 : 10));
|
|
42486
42719
|
} while (Date.now() < deadline);
|
|
42487
42720
|
throw new Error("Chrome did not return a result within the app I/O budget");
|
|
42488
42721
|
} finally {
|
|
@@ -42512,7 +42745,7 @@ async function handleRun(invocation, api, state, session, fetcher, root2, stdin
|
|
|
42512
42745
|
if (outputPath || invocation.repeats.select?.length) {
|
|
42513
42746
|
const directory = join12(root2, "results");
|
|
42514
42747
|
mkdirSync8(directory, { recursive: true, mode: 448 });
|
|
42515
|
-
recoveryPath = outputDestination(join12(directory, `${
|
|
42748
|
+
recoveryPath = outputDestination(join12(directory, `${randomUUID12()}.json`));
|
|
42516
42749
|
}
|
|
42517
42750
|
} catch (error62) {
|
|
42518
42751
|
return failure2("invalid-output", `invalid-output \u2014 ${error62 instanceof Error ? error62.message : "Output destination is unusable"}. No app request was sent.
|
|
@@ -42610,7 +42843,7 @@ No app request was sent.
|
|
|
42610
42843
|
Inspect current action documentation: ${prefix2(`actions show ${appName} ${actionName}`)}
|
|
42611
42844
|
`);
|
|
42612
42845
|
}
|
|
42613
|
-
const generated = Object.fromEntries(Object.entries(action.generated ?? {}).map(([name, spec]) => [name, `${spec.prefix ?? ""}${
|
|
42846
|
+
const generated = Object.fromEntries(Object.entries(action.generated ?? {}).map(([name, spec]) => [name, `${spec.prefix ?? ""}${randomUUID12()}`]));
|
|
42614
42847
|
let prepared;
|
|
42615
42848
|
try {
|
|
42616
42849
|
if (typeof action.request.url !== "string" && inputs.sources[action.request.url.$input] !== "explicit") throw new Error("Supply the URL input explicitly");
|
|
@@ -42718,7 +42951,7 @@ Private historical result: ${error62.path}
|
|
|
42718
42951
|
markPrimary();
|
|
42719
42952
|
return timed(timings, "appMs", () => send(fetcher, request2));
|
|
42720
42953
|
};
|
|
42721
|
-
const reportId =
|
|
42954
|
+
const reportId = randomUUID12();
|
|
42722
42955
|
let outcome = "network-error";
|
|
42723
42956
|
let diagnostic;
|
|
42724
42957
|
let observationSaved = false;
|
|
@@ -42961,12 +43194,12 @@ function privateEvidence(value, credentials) {
|
|
|
42961
43194
|
});
|
|
42962
43195
|
let redacted2 = JSON.stringify(value).includes("[REDACTED]");
|
|
42963
43196
|
const ordered = [...secrets].filter(Boolean).sort((a, b) => b.length - a.length);
|
|
42964
|
-
const hide2 = (
|
|
42965
|
-
for (const secret of ordered) if (
|
|
43197
|
+
const hide2 = (text5) => {
|
|
43198
|
+
for (const secret of ordered) if (text5.includes(secret)) {
|
|
42966
43199
|
redacted2 = true;
|
|
42967
|
-
|
|
43200
|
+
text5 = text5.split(secret).join("[REDACTED]");
|
|
42968
43201
|
}
|
|
42969
|
-
return
|
|
43202
|
+
return text5;
|
|
42970
43203
|
};
|
|
42971
43204
|
const visit4 = (child2) => {
|
|
42972
43205
|
if (typeof child2 === "string") {
|
|
@@ -42998,7 +43231,7 @@ async function executeDraftVerification(input2) {
|
|
|
42998
43231
|
const schema = input2.kind === "action" ? action.inputs ?? { type: "object", properties: {}, additionalProperties: false } : probe.inputs ?? { type: "object", properties: {}, additionalProperties: false };
|
|
42999
43232
|
let values;
|
|
43000
43233
|
let prepared;
|
|
43001
|
-
const generated = input2.primaryEvidence?.generated ?? (input2.kind === "action" && action && "generated" in action ? Object.fromEntries(Object.entries(action.generated ?? {}).map(([name, spec]) => [name, `${spec.prefix ?? ""}${
|
|
43234
|
+
const generated = input2.primaryEvidence?.generated ?? (input2.kind === "action" && action && "generated" in action ? Object.fromEntries(Object.entries(action.generated ?? {}).map(([name, spec]) => [name, `${spec.prefix ?? ""}${randomUUID12()}`])) : {});
|
|
43002
43235
|
try {
|
|
43003
43236
|
values = effectiveInputs(schema, input2.primaryEvidence?.inputs ?? input2.sampleInputs, {}, true).values;
|
|
43004
43237
|
const request2 = input2.kind === "action" ? action.request : probe.request;
|
|
@@ -43056,7 +43289,7 @@ async function executeDraftVerification(input2) {
|
|
|
43056
43289
|
const installation = input2.state.installation();
|
|
43057
43290
|
const store = new CredentialStore(input2.root, new KeyringVault());
|
|
43058
43291
|
try {
|
|
43059
|
-
credentialDraftId =
|
|
43292
|
+
credentialDraftId = randomUUID12();
|
|
43060
43293
|
store.registerDraft({ workspaceId: installation.workspaceId, appId: input2.appId, appTitle: input2.appSlug, transportName: input2.name, requirements: transport.credentials ?? [], credentialContract: credentialContractKey(transport), destinations: transport.allowedOrigins, draftId: credentialDraftId, expiresAt: new Date(Date.now() + 30 * 6e4).toISOString(), file: { path: input2.draftFile, app: input2.appSlug, account: installation.accountId, fingerprint: current.fingerprint, sessionId: input2.session.id } });
|
|
43061
43294
|
} finally {
|
|
43062
43295
|
store.close();
|
|
@@ -43181,7 +43414,7 @@ var init_run = __esm({
|
|
|
43181
43414
|
"use strict";
|
|
43182
43415
|
init_request_url();
|
|
43183
43416
|
init_response_observation();
|
|
43184
|
-
|
|
43417
|
+
init_feedback2();
|
|
43185
43418
|
init_definitions();
|
|
43186
43419
|
init_file_artifacts();
|
|
43187
43420
|
init_prepared_fields();
|
|
@@ -43219,7 +43452,7 @@ var init_run = __esm({
|
|
|
43219
43452
|
// src/commands/catalog.ts
|
|
43220
43453
|
import { mkdtempSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
43221
43454
|
import { tmpdir } from "node:os";
|
|
43222
|
-
import { resolve as
|
|
43455
|
+
import { resolve as resolve7, join as join13 } from "node:path";
|
|
43223
43456
|
function numberOption(value, fallback, max) {
|
|
43224
43457
|
if (!value) return fallback;
|
|
43225
43458
|
const number4 = Number(value);
|
|
@@ -43608,7 +43841,7 @@ If the interface needs an operation: ${prefix2(`apps update ${appName}`)}
|
|
|
43608
43841
|
if (invocation.flags.includes("schema")) return ok2(`${JSON.stringify(docs.map((doc) => ({ name: doc.name, inputs: doc.inputs, output: doc.output ?? null })), null, 2)}
|
|
43609
43842
|
`, true);
|
|
43610
43843
|
if (invocation.options["input-template"]) {
|
|
43611
|
-
const path2 =
|
|
43844
|
+
const path2 = resolve7(invocation.options["input-template"]);
|
|
43612
43845
|
writeFileSync7(path2, inputTemplate(docs[0].inputs), { flag: "wx", mode: 384 });
|
|
43613
43846
|
return ok2(`Wrote an editable input template to ${path2}. Replace examples with real values before running:
|
|
43614
43847
|
${prefix2(`run ${appName} ${names3[0]} --input @${path2} --check`)}
|
|
@@ -43706,8 +43939,8 @@ var init_connection_revision = __esm({
|
|
|
43706
43939
|
});
|
|
43707
43940
|
|
|
43708
43941
|
// src/commands/credentials.ts
|
|
43709
|
-
import { randomUUID as
|
|
43710
|
-
import { resolve as
|
|
43942
|
+
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
43943
|
+
import { resolve as resolve8 } from "node:path";
|
|
43711
43944
|
async function app(api, ref) {
|
|
43712
43945
|
return api.call("getApp", { params: { app: ref } });
|
|
43713
43946
|
}
|
|
@@ -43801,7 +44034,7 @@ This does not revoke it inside the app or log Chrome out. Sessions that selected
|
|
|
43801
44034
|
` : `"${name}" was already unavailable for ${selectedApp.title}'s ${transportName} connection.
|
|
43802
44035
|
`);
|
|
43803
44036
|
}
|
|
43804
|
-
const draftFile = invocation.key === "credentialsAdd" && invocation.options.file ?
|
|
44037
|
+
const draftFile = invocation.key === "credentialsAdd" && invocation.options.file ? resolve8(invocation.options.file) : void 0;
|
|
43805
44038
|
let draftContract = null;
|
|
43806
44039
|
if (draftFile) {
|
|
43807
44040
|
const target = { app: selectedApp.slug, kind: "transport", name: transportName, expectedVersion: null };
|
|
@@ -43863,7 +44096,7 @@ ${current.instructions}
|
|
|
43863
44096
|
Open ${command3(invocation, `apps update ${selectedApp.slug}`)}, then ${command3(invocation, `discover draft transport ${transportName} --out <file>`)}.
|
|
43864
44097
|
`, 2);
|
|
43865
44098
|
const expiresAt = new Date(Date.now() + 30 * 6e4).toISOString();
|
|
43866
|
-
const draftId = draftFile && draftContract ?
|
|
44099
|
+
const draftId = draftFile && draftContract ? randomUUID13() : void 0;
|
|
43867
44100
|
if (draftId && draftFile && draftContract) store.registerDraft({ ...current, draftId, expiresAt, file: { path: draftFile, app: selectedApp.slug, account: installation.accountId, fingerprint: draftContract.fingerprint, sessionId: session.id } });
|
|
43868
44101
|
const link = { ...draftId ? { draftId } : {}, appId: selectedApp.id, appTitle: selectedApp.title, transportName, instructions: current.instructions, requirements: current.requirements, sessionId: session.id, expiresAt };
|
|
43869
44102
|
const destination = `${siteUrl2}/dashboard/credentials/setup#${Buffer.from(canonicalJson(link)).toString("base64url")}`;
|
|
@@ -43917,7 +44150,7 @@ var init_credentials2 = __esm({
|
|
|
43917
44150
|
init_browser();
|
|
43918
44151
|
ok3 = (stdout) => ({ stdout, stderr: "", exitCode: 0 });
|
|
43919
44152
|
fail4 = (stderr, exitCode = 5) => ({ stdout: "", stderr, exitCode });
|
|
43920
|
-
command3 = (invocation,
|
|
44153
|
+
command3 = (invocation, text5) => `apilift${invocation.sessionLabel ? ` --session ${invocation.sessionLabel}` : ""} ${text5}`;
|
|
43921
44154
|
compatible = (left, right) => canonicalJson([...left].sort((a, b) => a.name.localeCompare(b.name))) === canonicalJson([...right].sort((a, b) => a.name.localeCompare(b.name)));
|
|
43922
44155
|
}
|
|
43923
44156
|
});
|
|
@@ -44541,8 +44774,8 @@ async function compileLegacyCaptureAction(raw, load2) {
|
|
|
44541
44774
|
else omitted.set(path2, name);
|
|
44542
44775
|
}
|
|
44543
44776
|
}
|
|
44544
|
-
const
|
|
44545
|
-
const literals = Array.isArray(
|
|
44777
|
+
const constants5 = raw.constants ?? [];
|
|
44778
|
+
const literals = Array.isArray(constants5) ? constants5.map((path2) => [path2, { retain: true }]) : isObject2(constants5) ? Object.entries(constants5).map(([path2, constant]) => [path2, { constant }]) : [];
|
|
44546
44779
|
for (const [path2, binding2] of literals) {
|
|
44547
44780
|
if (typeof path2 !== "string" || !path2.startsWith("/request/") || !pointer6.test(path2) || bindings.has(path2) || omitted.has(path2)) throw Error("Invalid retained constant binding");
|
|
44548
44781
|
bindings.set(path2, binding2);
|
|
@@ -44873,7 +45106,7 @@ function pruneUnusedSharedTypes(root2, injected) {
|
|
|
44873
45106
|
}
|
|
44874
45107
|
function patchResponseFields(root2, fields) {
|
|
44875
45108
|
if (!object8(root2) || !object8(fields) || Object.keys(fields).length > 128) throw Error("outputFields requires a response schema and at most 128 result-path schema corrections");
|
|
44876
|
-
const
|
|
45109
|
+
const resolve17 = (value) => {
|
|
44877
45110
|
const seen = /* @__PURE__ */ new Set();
|
|
44878
45111
|
while (typeof value.$ref === "string") {
|
|
44879
45112
|
const ref = value.$ref;
|
|
@@ -44905,7 +45138,7 @@ function patchResponseFields(root2, fields) {
|
|
|
44905
45138
|
const visit4 = (raw, index2) => {
|
|
44906
45139
|
if (--budget < 0 || index2 > 64) throw Error(`Output field correction exceeds traversal limits: ${path2}`);
|
|
44907
45140
|
if (!object8(raw)) return;
|
|
44908
|
-
const node2 =
|
|
45141
|
+
const node2 = resolve17(raw), positions = active2.get(node2) ?? /* @__PURE__ */ new Set();
|
|
44909
45142
|
if (positions.has(index2)) return;
|
|
44910
45143
|
positions.add(index2);
|
|
44911
45144
|
active2.set(node2, positions);
|
|
@@ -45008,16 +45241,16 @@ var init_api_filter_tree = __esm({
|
|
|
45008
45241
|
|
|
45009
45242
|
// src/discovery/api-input-docs.ts
|
|
45010
45243
|
function documentSelectedInputScope(description2, omitted) {
|
|
45011
|
-
let
|
|
45244
|
+
let text5 = description2;
|
|
45012
45245
|
for (const name of omitted) {
|
|
45013
45246
|
const token = name.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
45014
|
-
|
|
45015
|
-
|
|
45016
|
-
|
|
45247
|
+
text5 = text5.replace(new RegExp(`(?:^|(?<=[.!?])\\s+)Ignored when \`${token}\` is provided\\.(?=\\s|$)`, "gu"), "");
|
|
45248
|
+
text5 = text5.replace(new RegExp(` \u2014 ignored when \`${token}\` is provided(?: \\([^()\\n]*\\))?\\.(?=\\s|$)`, "gu"), ".");
|
|
45249
|
+
text5 = text5.replace(new RegExp(`Independent of \`${token}\` \\(which keys off ([^()\\n]+)\\)`, "gu"), "Independent of $1");
|
|
45017
45250
|
}
|
|
45018
|
-
|
|
45019
|
-
const remaining = omitted.filter((name) =>
|
|
45020
|
-
return remaining.length ? `${
|
|
45251
|
+
text5 = text5.trim();
|
|
45252
|
+
const remaining = omitted.filter((name) => text5.includes("`" + name + "`"));
|
|
45253
|
+
return remaining.length ? `${text5} This action does not expose ${remaining.map((name) => "`" + name + "`").join(", ")}; documentation conditions involving those inputs do not apply here.` : text5;
|
|
45021
45254
|
}
|
|
45022
45255
|
function documentReferencedInputMeaning(definition2) {
|
|
45023
45256
|
const inputs = definition2.inputs, response = definition2.response;
|
|
@@ -45037,24 +45270,24 @@ function documentReferencedInputMeaning(definition2) {
|
|
|
45037
45270
|
});
|
|
45038
45271
|
};
|
|
45039
45272
|
visit4(response.schema);
|
|
45040
|
-
const prefixes = (
|
|
45273
|
+
const prefixes = (text5) => [...text5.matchAll(/`([^`*\s]+)\*`/gu)].map((match) => match[1]);
|
|
45041
45274
|
for (const [name, field] of Object.entries(inputs.properties)) {
|
|
45042
45275
|
if (!object10(field) || typeof field.description !== "string" || !Array.isArray(field.enum) || !field.enum.length || field.enum.some((value) => typeof value !== "string")) continue;
|
|
45043
45276
|
const values = field.enum;
|
|
45044
45277
|
const link = `Same values accepted by \`${name}\` query param.`;
|
|
45045
|
-
const matches = [...descriptions2].filter((
|
|
45278
|
+
const matches = [...descriptions2].filter((text6) => text6.includes(link) && prefixes(text6).length > 1 && values.every((value) => prefixes(text6).some((prefix2) => String(value).startsWith(prefix2))));
|
|
45046
45279
|
if (matches.length !== 1) continue;
|
|
45047
45280
|
const meaning = matches[0].replace(link, "").trim();
|
|
45048
45281
|
if (meaning.length > 1200) continue;
|
|
45049
45282
|
let corrected = false;
|
|
45050
|
-
const
|
|
45283
|
+
const text5 = field.description.replace(/, raised during [^.!?\n]+ \(`([^`*\s]+)\*`\)(?=\.)/gu, (clause, prefix2) => {
|
|
45051
45284
|
if (values.some((value) => !String(value).startsWith(prefix2))) {
|
|
45052
45285
|
corrected = true;
|
|
45053
45286
|
return "";
|
|
45054
45287
|
}
|
|
45055
45288
|
return clause;
|
|
45056
45289
|
});
|
|
45057
|
-
if (corrected) field.description = `${
|
|
45290
|
+
if (corrected) field.description = `${text5} ${meaning}`;
|
|
45058
45291
|
}
|
|
45059
45292
|
}
|
|
45060
45293
|
function documentInputVocabulary(definition2, collection) {
|
|
@@ -45198,31 +45431,31 @@ function compileInputList(previous, raw, root2, overrideEncoding) {
|
|
|
45198
45431
|
const encoding = overrideEncoding ?? raw.encoding;
|
|
45199
45432
|
if (!["comma", "space", "pipe"].includes(String(encoding))) throw Error("Declare list.encoding as comma, space or pipe from documented or observed serialization");
|
|
45200
45433
|
const separator = encoding === "comma" ? "," : encoding === "space" ? " " : "|";
|
|
45201
|
-
const
|
|
45434
|
+
const resolve17 = (node2, depth = 0) => {
|
|
45202
45435
|
if (!object12(node2) || depth > 16) throw Error("List items need a bounded scalar schema");
|
|
45203
45436
|
if (typeof node2.$ref !== "string") return node2;
|
|
45204
45437
|
if (!node2.$ref.startsWith("#/")) throw Error("List item references must be local");
|
|
45205
45438
|
if (Object.keys(node2).some((k) => k !== "$ref" && k !== "x-source" && !annotations2.has(k))) throw Error("List item references with sibling constraints need an explicit item schema");
|
|
45206
45439
|
let target = root2;
|
|
45207
45440
|
for (const part of node2.$ref.slice(2).split("/")) target = object12(target) ? target[part.replaceAll("~1", "/").replaceAll("~0", "~")] : void 0;
|
|
45208
|
-
return
|
|
45441
|
+
return resolve17(target, depth + 1);
|
|
45209
45442
|
};
|
|
45210
|
-
const base2 =
|
|
45443
|
+
const base2 = resolve17(previous), branches = [base2, ...["oneOf", "anyOf"].flatMap((key2) => Array.isArray(base2[key2]) ? base2[key2].map((b) => resolve17(b)) : [])];
|
|
45211
45444
|
if (branches.length > 1 && Object.keys(base2).some((k) => !["oneOf", "anyOf", "x-source"].includes(k) && !annotations2.has(k))) throw Error("Imported union constraints need an explicit schema and encoding");
|
|
45212
45445
|
if (branches.filter((b) => b.type === "array").length > 1) throw Error("Multiple imported array variants need an explicit schema and encoding");
|
|
45213
45446
|
const array2 = branches.find((b) => b.type === "array");
|
|
45214
45447
|
if (array2 && Object.keys(array2).some((k) => !["type", "items"].includes(k) && !annotations2.has(k))) throw Error("Imported list collection constraints need an explicit schema and encoding");
|
|
45215
45448
|
const minimumItems = array2 ? 0 : 1;
|
|
45216
45449
|
let item;
|
|
45217
|
-
if (raw.items !== void 0) item =
|
|
45450
|
+
if (raw.items !== void 0) item = resolve17(raw.items);
|
|
45218
45451
|
else {
|
|
45219
45452
|
const scalars = branches.filter((b) => ["string", "integer", "number", "boolean"].includes(String(b.type)));
|
|
45220
|
-
if (array2) item =
|
|
45453
|
+
if (array2) item = resolve17(array2.items);
|
|
45221
45454
|
else if (scalars.length === 1) item = scalars[0];
|
|
45222
45455
|
else throw Error("Declare list.items explicitly when the imported argument has no unique scalar item type");
|
|
45223
45456
|
}
|
|
45224
45457
|
if (raw.items !== void 0 && (item.enum !== void 0 || item.const !== void 0)) {
|
|
45225
|
-
const documented = array2 ?
|
|
45458
|
+
const documented = array2 ? resolve17(array2.items) : branches.find((branch) => ["string", "integer", "number", "boolean"].includes(String(branch.type)));
|
|
45226
45459
|
if (!documented || documented.enum === void 0 && documented.const === void 0) throw Error("List encoding cannot turn an open documented item domain into a closed enum. Preserve open items and give known values as examples or notes; an explicitly documented domain correction belongs in a separate schema patch with its evidence.");
|
|
45227
45460
|
const oldChoices = Array.isArray(documented.enum) ? documented.enum : [documented.const];
|
|
45228
45461
|
const newChoices = Array.isArray(item.enum) ? item.enum : [item.const];
|
|
@@ -45316,7 +45549,7 @@ var init_api_lookup = __esm({
|
|
|
45316
45549
|
});
|
|
45317
45550
|
|
|
45318
45551
|
// src/discovery/openapi-operation.ts
|
|
45319
|
-
import { createHash as
|
|
45552
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
45320
45553
|
function importOperation(document, selector, responseTypes, omittedInputs = [], omittedDefaults = []) {
|
|
45321
45554
|
const method = String(selector.method).toUpperCase(), path2 = String(selector.path);
|
|
45322
45555
|
const paths2 = object14(document.paths) ? document.paths : {};
|
|
@@ -45382,7 +45615,7 @@ function importOperation(document, selector, responseTypes, omittedInputs = [],
|
|
|
45382
45615
|
if (typeof result3.$ref === "string") {
|
|
45383
45616
|
const ref = result3.$ref;
|
|
45384
45617
|
const label3 = ref.split("/").at(-1).replace(/[^a-zA-Z0-9_-]/gu, "-").slice(0, 80);
|
|
45385
|
-
const key2 = `${direction}-${label3}-${
|
|
45618
|
+
const key2 = `${direction}-${label3}-${createHash15("sha256").update(ref).digest("hex").slice(0, 8)}`;
|
|
45386
45619
|
if (!Object.hasOwn(defs, key2)) {
|
|
45387
45620
|
defs[key2] = {};
|
|
45388
45621
|
defs[key2] = schema(reference(ref), direction);
|
|
@@ -45674,8 +45907,8 @@ var init_batch_import = __esm({
|
|
|
45674
45907
|
});
|
|
45675
45908
|
|
|
45676
45909
|
// src/discovery/legacy-api-import.ts
|
|
45677
|
-
import { createHash as
|
|
45678
|
-
import { dirname as dirname5, resolve as
|
|
45910
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
45911
|
+
import { dirname as dirname5, resolve as resolve9 } from "node:path";
|
|
45679
45912
|
function legacyPlanActions(plan) {
|
|
45680
45913
|
if (isObject2(plan.actions) && plan.reads === void 0) return plan.actions;
|
|
45681
45914
|
if (!isObject2(plan.reads) || plan.actions !== void 0) throw Error("The retained API plan needs one actions or reads map");
|
|
@@ -45707,8 +45940,8 @@ function compileLegacyDocumentedAction(raw, plan, file3) {
|
|
|
45707
45940
|
if (!isObject2(raw.operation)) throw Error("Name the retained OpenAPI source, method and path");
|
|
45708
45941
|
const source = isObject2(plan.sources) ? plan.sources[String(raw.operation.source)] : void 0;
|
|
45709
45942
|
if (!isObject2(source) || source.kind !== "openapi") throw Error("Operation source must name a retained OpenAPI document");
|
|
45710
|
-
const content = source.file === void 0 ? source.document : readDraftFile(
|
|
45711
|
-
const hash4 =
|
|
45943
|
+
const content = source.file === void 0 ? source.document : readDraftFile(resolve9(dirname5(file3), String(source.file)));
|
|
45944
|
+
const hash4 = createHash16("sha256").update(JSON.stringify(content) ?? "").digest("hex");
|
|
45712
45945
|
if (source.sha256 !== void 0 && source.sha256 !== hash4) throw Error("Retained documentation differs from its pinned hash. Review the source before migrating");
|
|
45713
45946
|
const parseErrors = [];
|
|
45714
45947
|
const document = typeof content === "string" ? parse4(content, parseErrors, { allowTrailingComma: true }) : clone4(content);
|
|
@@ -45938,7 +46171,7 @@ var init_legacy_api_import = __esm({
|
|
|
45938
46171
|
});
|
|
45939
46172
|
|
|
45940
46173
|
// src/discovery/batch-publication.ts
|
|
45941
|
-
import { createHash as
|
|
46174
|
+
import { createHash as createHash17, randomUUID as randomUUID14 } from "node:crypto";
|
|
45942
46175
|
function needsOutputReview(definition2) {
|
|
45943
46176
|
if (!usesBatchDiscovery(definition2) || !isObject2(definition2) || !isObject2(definition2.response)) return false;
|
|
45944
46177
|
const response = definition2.response;
|
|
@@ -45947,7 +46180,7 @@ function needsOutputReview(definition2) {
|
|
|
45947
46180
|
async function publishBatch(input2) {
|
|
45948
46181
|
const { path: path2, source, draft, members: members2, issues, state, appId, api, sessionLabel, onPublished } = input2;
|
|
45949
46182
|
const installation = state.installation();
|
|
45950
|
-
const sourceKey =
|
|
46183
|
+
const sourceKey = createHash17("sha256").update(path2).digest("hex");
|
|
45951
46184
|
const scope2 = [installation?.accountId ?? "", installation?.workspaceId ?? "", appId];
|
|
45952
46185
|
state.db.exec(`CREATE TABLE IF NOT EXISTS discovery_file_publication (
|
|
45953
46186
|
request_id TEXT PRIMARY KEY, account_id TEXT NOT NULL, workspace_id TEXT NOT NULL, app_id TEXT NOT NULL,
|
|
@@ -46089,7 +46322,7 @@ Export the current definition with discover draft --app ${draft.app} --include $
|
|
|
46089
46322
|
const rows = remaining.map((member) => ({
|
|
46090
46323
|
kind: member.kind,
|
|
46091
46324
|
name: member.name,
|
|
46092
|
-
request_id:
|
|
46325
|
+
request_id: randomUUID14(),
|
|
46093
46326
|
source_key: sourceKey,
|
|
46094
46327
|
owner_session: input2.sessionId ?? null,
|
|
46095
46328
|
body: canonicalJson({ expectedVersion: recoveredBases.get(key(member)) ?? draft.baseRevisions?.[key(member)] ?? null, definition: member.definition })
|
|
@@ -46195,9 +46428,9 @@ var init_capture_setup = __esm({
|
|
|
46195
46428
|
});
|
|
46196
46429
|
|
|
46197
46430
|
// src/discovery/capture-catalog.ts
|
|
46198
|
-
import { createHash as
|
|
46431
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
46199
46432
|
function digest3(value) {
|
|
46200
|
-
return
|
|
46433
|
+
return createHash18("sha256").update(JSON.stringify(value)).digest("hex");
|
|
46201
46434
|
}
|
|
46202
46435
|
function shape(value, depth = 0) {
|
|
46203
46436
|
if (depth === 12) return "nested";
|
|
@@ -46247,21 +46480,21 @@ var init_capture_catalog = __esm({
|
|
|
46247
46480
|
});
|
|
46248
46481
|
|
|
46249
46482
|
// src/usage/ledger.ts
|
|
46250
|
-
import { createHash as
|
|
46483
|
+
import { createHash as createHash19, createHmac as createHmac2, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
|
|
46251
46484
|
import { chmodSync as chmodSync5, mkdirSync as mkdirSync9, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
46252
46485
|
import { join as join14 } from "node:path";
|
|
46253
46486
|
import { DatabaseSync as DatabaseSync5 } from "node:sqlite";
|
|
46254
46487
|
function executionMeasurementScope(installation, registry2) {
|
|
46255
|
-
return
|
|
46488
|
+
return createHash19("sha256").update(JSON.stringify([installation.accountId, installation.workspaceId, installation.id, new URL(registry2).origin])).digest("hex");
|
|
46256
46489
|
}
|
|
46257
46490
|
function purposeFor(key2) {
|
|
46258
46491
|
return key2.startsWith("discover") || key2 === "appsNew" || key2 === "appsUpdate" ? "discovery" : key2.startsWith("setup") ? "setup" : "unknown";
|
|
46259
46492
|
}
|
|
46260
46493
|
function countedCommand(key2) {
|
|
46261
|
-
return !["root", "version", "helpCommands", "appsSearch", "actionsList", "actionsSearch", "actionsShow", "transportsShow", "appsHistory", "contextShow"].includes(key2);
|
|
46494
|
+
return !key2.startsWith("feedback") && !["root", "version", "helpCommands", "appsSearch", "actionsList", "actionsSearch", "actionsShow", "transportsShow", "appsHistory", "contextShow"].includes(key2);
|
|
46262
46495
|
}
|
|
46263
46496
|
function newInvocationId() {
|
|
46264
|
-
return
|
|
46497
|
+
return randomUUID15();
|
|
46265
46498
|
}
|
|
46266
46499
|
var UsageLedger;
|
|
46267
46500
|
var init_ledger = __esm({
|
|
@@ -46347,7 +46580,7 @@ var init_ledger = __esm({
|
|
|
46347
46580
|
this.db.prepare("INSERT INTO usage_meta (key,value) VALUES ('account_id',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value").run(accountId);
|
|
46348
46581
|
}
|
|
46349
46582
|
clearForRevocation() {
|
|
46350
|
-
this.clearForAccountChange(`revoked:${
|
|
46583
|
+
this.clearForAccountChange(`revoked:${randomUUID15()}`);
|
|
46351
46584
|
this.db.prepare("DELETE FROM usage_meta WHERE key='account_id'").run();
|
|
46352
46585
|
}
|
|
46353
46586
|
prune() {
|
|
@@ -46369,7 +46602,7 @@ var init_ledger = __esm({
|
|
|
46369
46602
|
});
|
|
46370
46603
|
|
|
46371
46604
|
// src/usage/baselines.ts
|
|
46372
|
-
import { createHash as
|
|
46605
|
+
import { createHash as createHash20, randomUUID as randomUUID16 } from "node:crypto";
|
|
46373
46606
|
import { chmodSync as chmodSync6, mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "node:fs";
|
|
46374
46607
|
import { join as join15 } from "node:path";
|
|
46375
46608
|
function withBaselines(root2, work) {
|
|
@@ -46390,7 +46623,7 @@ var init_baselines = __esm({
|
|
|
46390
46623
|
init_api2();
|
|
46391
46624
|
init_ledger();
|
|
46392
46625
|
captureAttributionPolicy = CAPTURE_ATTRIBUTION_POLICY;
|
|
46393
|
-
baselineScopeKey = (account, workspace, registry2) =>
|
|
46626
|
+
baselineScopeKey = (account, workspace, registry2) => createHash20("sha256").update(JSON.stringify([account, workspace, registry2])).digest("hex");
|
|
46394
46627
|
BaselineStore = class {
|
|
46395
46628
|
constructor(ledger) {
|
|
46396
46629
|
this.ledger = ledger;
|
|
@@ -46440,14 +46673,14 @@ var init_baselines = __esm({
|
|
|
46440
46673
|
return this.write(() => {
|
|
46441
46674
|
const found = this.ledger.db.prepare("SELECT id FROM baseline_candidate WHERE scope_key=? AND app_id=? AND session_id=? AND draft_id=? AND kind='action'").get(this.scope, appId, sessionId, captureId);
|
|
46442
46675
|
if (found) return found.id;
|
|
46443
|
-
const id2 =
|
|
46676
|
+
const id2 = randomUUID16(), date5 = at.toISOString();
|
|
46444
46677
|
this.ledger.db.prepare("UPDATE baseline_candidate SET observation_finished_at=?,observation_reason='next-capture' WHERE scope_key=? AND session_id=? AND observation_version=2 AND kind='action' AND observation_finished_at IS NULL").run(date5, this.scope, sessionId);
|
|
46445
46678
|
this.ledger.db.prepare("INSERT INTO baseline_candidate(id,draft_id,app_id,session_id,method,started_at,observation_version,policy,kind,publications_json,scope_key) VALUES (?,?,?,?,'browser',?,2,?,'action','[]',?)").run(id2, captureId, appId, sessionId, date5, captureAttributionPolicy, this.scope);
|
|
46446
46679
|
return id2;
|
|
46447
46680
|
});
|
|
46448
46681
|
}
|
|
46449
46682
|
rememberSelection(input2) {
|
|
46450
|
-
this.rememberSelectionKey({ ...input2, fileHash:
|
|
46683
|
+
this.rememberSelectionKey({ ...input2, fileHash: createHash20("sha256").update(input2.file).digest("hex") });
|
|
46451
46684
|
}
|
|
46452
46685
|
rememberSelectionKey(input2) {
|
|
46453
46686
|
this.ledger.db.prepare("INSERT OR IGNORE INTO baseline_lineage VALUES (?,?,?,?,?,?,?)").run(this.scope, input2.appId, input2.captureId, input2.sessionId, input2.fileHash, input2.name, input2.signature);
|
|
@@ -46456,7 +46689,7 @@ var init_baselines = __esm({
|
|
|
46456
46689
|
return new Set(this.ledger.db.prepare("SELECT DISTINCT capture_id FROM baseline_lineage WHERE scope=? AND app_id=? AND file_hash=? AND member=?").all(this.scope, appId, fileHash, name).map((row) => row.capture_id));
|
|
46457
46690
|
}
|
|
46458
46691
|
selectedCapture(appId, file3, name, signature) {
|
|
46459
|
-
return this.selectedCaptureKey(appId,
|
|
46692
|
+
return this.selectedCaptureKey(appId, createHash20("sha256").update(file3).digest("hex"), name, signature);
|
|
46460
46693
|
}
|
|
46461
46694
|
selectedCaptureKey(appId, fileHash, name, signature) {
|
|
46462
46695
|
const rows = this.ledger.db.prepare("SELECT capture_id,file_hash,member FROM baseline_lineage WHERE scope=? AND app_id=? AND signature=?").all(this.scope, appId, signature);
|
|
@@ -46482,7 +46715,7 @@ var init_baselines = __esm({
|
|
|
46482
46715
|
return;
|
|
46483
46716
|
}
|
|
46484
46717
|
const start = this.ledger.db.prepare("SELECT started_at FROM baseline_preparation_start WHERE session_id=? AND app_slug=?").get(this.preparationSession(sessionId), appSlug);
|
|
46485
|
-
this.ledger.db.prepare("INSERT INTO baseline_candidate(id,draft_id,app_id,session_id,method,started_at,stopped_at,observation_finished_at,observation_reason,observation_version,policy,kind,scope_key,publications_json,documentation_sources_json,documentation_hosts_json) VALUES (?,?,?,?,?,?,?,?,'preparation-complete',2,?,'preparation',?,'[]',?,?)").run(
|
|
46718
|
+
this.ledger.db.prepare("INSERT INTO baseline_candidate(id,draft_id,app_id,session_id,method,started_at,stopped_at,observation_finished_at,observation_reason,observation_version,policy,kind,scope_key,publications_json,documentation_sources_json,documentation_hosts_json) VALUES (?,?,?,?,?,?,?,?,'preparation-complete',2,?,'preparation',?,'[]',?,?)").run(randomUUID16(), draftId, appId, sessionId, method, start?.started_at ?? date5, date5, date5, captureAttributionPolicy, this.scope, sourceJson, hostJson);
|
|
46486
46719
|
});
|
|
46487
46720
|
}
|
|
46488
46721
|
/** False retains an unresolved receipt without invalidating existing links. */
|
|
@@ -46513,10 +46746,10 @@ var init_baselines = __esm({
|
|
|
46513
46746
|
finishPreparation(sessionId, appSlug, appId, method, at = /* @__PURE__ */ new Date()) {
|
|
46514
46747
|
const row = this.ledger.db.prepare("SELECT started_at FROM baseline_preparation_start WHERE session_id=? AND app_slug=?").get(this.preparationSession(sessionId), appSlug);
|
|
46515
46748
|
if (!row || this.ledger.db.prepare("SELECT 1 FROM baseline_candidate WHERE draft_id=?").get(`preparation:${sessionId}:${appId}:${method}`)) return;
|
|
46516
|
-
this.ledger.db.prepare("INSERT INTO baseline_candidate (id,draft_id,app_id,session_id,method,started_at,stopped_at) VALUES (?,?,?,?,?,?,?)").run(
|
|
46749
|
+
this.ledger.db.prepare("INSERT INTO baseline_candidate (id,draft_id,app_id,session_id,method,started_at,stopped_at) VALUES (?,?,?,?,?,?,?)").run(randomUUID16(), `preparation:${sessionId}:${appId}:${method}`, appId, sessionId, method, row.started_at, at.toISOString());
|
|
46517
46750
|
}
|
|
46518
46751
|
startCapture(draftId, appId, sessionId, at = /* @__PURE__ */ new Date()) {
|
|
46519
|
-
const id2 =
|
|
46752
|
+
const id2 = randomUUID16();
|
|
46520
46753
|
this.ledger.db.prepare("UPDATE baseline_candidate SET observation_finished_at=?,observation_reason='next-capture' WHERE session_id=? AND observation_version=1 AND observation_finished_at IS NULL").run(at.toISOString(), sessionId);
|
|
46521
46754
|
this.ledger.db.prepare("INSERT INTO baseline_candidate (id,draft_id,app_id,session_id,method,started_at,observation_version) VALUES (?,?,?,?,?,?,1)").run(id2, draftId, appId, sessionId, "browser", at.toISOString());
|
|
46522
46755
|
return id2;
|
|
@@ -46547,7 +46780,7 @@ var init_baselines = __esm({
|
|
|
46547
46780
|
this.ledger.db.prepare("UPDATE baseline_candidate SET observation_finished_at=?,observation_reason=CASE WHEN stopped_at IS NULL THEN 'cancelled' ELSE 'released' END WHERE draft_id=? AND method='browser' AND observation_version IN (1,2) AND observation_finished_at IS NULL").run(at.toISOString(), draftId);
|
|
46548
46781
|
}
|
|
46549
46782
|
recordDirect(input2) {
|
|
46550
|
-
const id2 =
|
|
46783
|
+
const id2 = randomUUID16(), at = input2.at ?? /* @__PURE__ */ new Date();
|
|
46551
46784
|
const dir = join15(this.ledger.root, "pending-baselines");
|
|
46552
46785
|
mkdirSync10(dir, { recursive: true, mode: 448 });
|
|
46553
46786
|
chmodSync6(dir, 448);
|
|
@@ -46612,8 +46845,8 @@ var init_baselines = __esm({
|
|
|
46612
46845
|
});
|
|
46613
46846
|
|
|
46614
46847
|
// src/usage/transcript.ts
|
|
46615
|
-
import { createHash as
|
|
46616
|
-
import { basename as
|
|
46848
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
46849
|
+
import { basename as basename3, isAbsolute as isAbsolute4, join as join16, normalize } from "node:path";
|
|
46617
46850
|
import { DatabaseSync as DatabaseSync6 } from "node:sqlite";
|
|
46618
46851
|
function documentationHostHash(value) {
|
|
46619
46852
|
try {
|
|
@@ -46642,13 +46875,13 @@ var init_transcript = __esm({
|
|
|
46642
46875
|
init_receipts();
|
|
46643
46876
|
MAX_LINE = 4 * 1024 * 1024;
|
|
46644
46877
|
CHUNK = 64 * 1024;
|
|
46645
|
-
digest4 = (value) =>
|
|
46878
|
+
digest4 = (value) => createHash21("sha256").update(value).digest("hex");
|
|
46646
46879
|
}
|
|
46647
46880
|
});
|
|
46648
46881
|
|
|
46649
46882
|
// src/usage/discovery-attribution.ts
|
|
46650
|
-
import { createHash as
|
|
46651
|
-
import { resolve as
|
|
46883
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
46884
|
+
import { resolve as resolve10 } from "node:path";
|
|
46652
46885
|
function observationSignature(definition2, baseUrl) {
|
|
46653
46886
|
if (!definition2.request || typeof definition2.request !== "object") return null;
|
|
46654
46887
|
function normalize3(value) {
|
|
@@ -46665,7 +46898,7 @@ function observationSignature(definition2, baseUrl) {
|
|
|
46665
46898
|
return null;
|
|
46666
46899
|
}
|
|
46667
46900
|
}
|
|
46668
|
-
return
|
|
46901
|
+
return createHash22("sha256").update(canonicalJson({
|
|
46669
46902
|
request: request2,
|
|
46670
46903
|
pagination: definition2.response?.pagination ?? null
|
|
46671
46904
|
})).digest("hex");
|
|
@@ -46681,7 +46914,7 @@ function withDiscoveryMeasurements(root2, state, registry2, work) {
|
|
|
46681
46914
|
function rememberSelectedObservation(root2, state, registry2, input2) {
|
|
46682
46915
|
try {
|
|
46683
46916
|
const signature = observationSignature(input2.definition);
|
|
46684
|
-
if (signature) withDiscoveryMeasurements(root2, state, registry2, (store) => store.rememberSelection({ ...input2, file:
|
|
46917
|
+
if (signature) withDiscoveryMeasurements(root2, state, registry2, (store) => store.rememberSelection({ ...input2, file: resolve10(input2.file), signature }));
|
|
46685
46918
|
} catch {
|
|
46686
46919
|
}
|
|
46687
46920
|
}
|
|
@@ -46703,8 +46936,8 @@ var init_discovery_attribution = __esm({
|
|
|
46703
46936
|
|
|
46704
46937
|
// src/commands/discover.ts
|
|
46705
46938
|
import { existsSync as existsSync5, mkdirSync as mkdirSync11, renameSync as renameSync4, writeFileSync as writeFileSync10 } from "node:fs";
|
|
46706
|
-
import { randomUUID as
|
|
46707
|
-
import { join as join17, resolve as
|
|
46939
|
+
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
46940
|
+
import { join as join17, resolve as resolve11 } from "node:path";
|
|
46708
46941
|
async function currentResource(api, appId, kind, name) {
|
|
46709
46942
|
try {
|
|
46710
46943
|
const resource = await api.call("getResource", { params: { app: appId, kind: backendKind(kind), name } });
|
|
@@ -47060,7 +47293,7 @@ async function awaitCaptureJob(client, id2) {
|
|
|
47060
47293
|
do {
|
|
47061
47294
|
const job = await captureJobResult(client, id2);
|
|
47062
47295
|
if (["delivered", "uncertain", "missing"].includes(job.status)) return job;
|
|
47063
|
-
await new Promise((
|
|
47296
|
+
await new Promise((resolve17) => setTimeout(resolve17, 200));
|
|
47064
47297
|
} while (Date.now() < deadline);
|
|
47065
47298
|
return { status: "pending" };
|
|
47066
47299
|
}
|
|
@@ -47160,7 +47393,7 @@ async function refreshCandidate(item, scopeId, root2, deadline, waitForResponse,
|
|
|
47160
47393
|
}
|
|
47161
47394
|
if (latest) item = latest;
|
|
47162
47395
|
if (!waitForResponse || !item.entry.pending) return item;
|
|
47163
|
-
await new Promise((
|
|
47396
|
+
await new Promise((resolve17) => setTimeout(resolve17, 100));
|
|
47164
47397
|
} while (Date.now() < deadline);
|
|
47165
47398
|
return item;
|
|
47166
47399
|
}
|
|
@@ -47184,7 +47417,7 @@ async function selectedBody(item, part, scopeId, root2, deadline = Date.now() +
|
|
|
47184
47417
|
if (bytes.length !== artifact.bytes) throw new Error("Selected body length does not match its artifact");
|
|
47185
47418
|
return bytes.toString("utf8");
|
|
47186
47419
|
}
|
|
47187
|
-
await new Promise((
|
|
47420
|
+
await new Promise((resolve17) => setTimeout(resolve17, 100));
|
|
47188
47421
|
} while (Date.now() < deadline);
|
|
47189
47422
|
return null;
|
|
47190
47423
|
}
|
|
@@ -47341,7 +47574,7 @@ function writeCaptureCatalog(row, root2) {
|
|
|
47341
47574
|
const catalog = join17(folder, "operations.json");
|
|
47342
47575
|
const operations = captureCatalog(captureEntries(row));
|
|
47343
47576
|
mkdirSync11(folder, { recursive: true, mode: 448 });
|
|
47344
|
-
const temporary = join17(folder, `operations-${
|
|
47577
|
+
const temporary = join17(folder, `operations-${randomUUID17()}.tmp`);
|
|
47345
47578
|
writeFileSync10(temporary, JSON.stringify({ recording: row.draft_id, operations }, null, 2), { mode: 384 });
|
|
47346
47579
|
renameSync4(temporary, catalog);
|
|
47347
47580
|
return { catalog, operations };
|
|
@@ -47391,7 +47624,7 @@ async function captureDraft(invocation, api, state, store, session, root2) {
|
|
|
47391
47624
|
await checkTabOwnership(client, origin, tab.selector, app2.slug, command4(invocation, "").trim());
|
|
47392
47625
|
await api.call("acquireSession", { params: { id: apiSessionId(installation.id, session) }, body: { purpose: "discovery", appId: app2.id } });
|
|
47393
47626
|
const scope2 = await client.openScope({ kind: "capture", appId: app2.id, contextId, pageOrigin: origin, tabSelector: tab.selector, ownerPid: client.receipt.pid, ownerStartedAt: Date.parse(client.receipt.startedAt), ownerSession: session.id });
|
|
47394
|
-
const jobId =
|
|
47627
|
+
const jobId = randomUUID17();
|
|
47395
47628
|
let captureId;
|
|
47396
47629
|
try {
|
|
47397
47630
|
captureId = captures.start(session.id, app2.id, tab.selector, tab.tabId, origin, scope2.id, jobId);
|
|
@@ -47459,14 +47692,14 @@ Review: ${command4(invocation, "discover status")}
|
|
|
47459
47692
|
}
|
|
47460
47693
|
const previous = row.phase === "stopping" && row.job_id ? await captureJobResult(client, row.job_id) : null;
|
|
47461
47694
|
if (previous?.status === "missing" && await releaseUnconfirmedCapture(client, state, id2, row.scope_id, root2, table)) return ok4(lostCaptureMessage);
|
|
47462
|
-
let stopId = row.phase === "stopping" && row.job_id ? row.job_id :
|
|
47695
|
+
let stopId = row.phase === "stopping" && row.job_id ? row.job_id : randomUUID17();
|
|
47463
47696
|
if (row.phase !== "stopping") {
|
|
47464
47697
|
state.db.prepare(`UPDATE ${table} SET phase='stopping',job_id=? WHERE draft_id=?`).run(stopId, id2);
|
|
47465
47698
|
await client.enqueueJob(row.scope_id, { job: { id: stopId, kind: "stop" } });
|
|
47466
47699
|
} else if (row.job_id) {
|
|
47467
47700
|
if (previous?.status === "missing" || previous?.status === "delivered" && previous.result?.boundaryConfirmed !== true) {
|
|
47468
47701
|
const failedId = stopId;
|
|
47469
|
-
stopId =
|
|
47702
|
+
stopId = randomUUID17();
|
|
47470
47703
|
state.db.prepare(`UPDATE ${table} SET job_id=? WHERE draft_id=?`).run(stopId, id2);
|
|
47471
47704
|
await client.enqueueJob(row.scope_id, { job: { id: stopId, kind: "stop" } });
|
|
47472
47705
|
await client.acknowledgeJob(failedId);
|
|
@@ -47535,7 +47768,7 @@ Inspect a returned candidate: ${command4(invocation, `discover capture show c${p
|
|
|
47535
47768
|
if (key2 === "discoverCaptureAuth" && recording) {
|
|
47536
47769
|
if (!authFieldPointers(item.entry).length) return fail5("No probeable authentication header on this candidate.\n");
|
|
47537
47770
|
if (row.phase !== "closed" || !row.scope_id) return fail5("Transient source evidence was released or expired. Recover with a safe read; do not repeat a mutation.\n", 12);
|
|
47538
|
-
const client = await captureClient(root2), jobId =
|
|
47771
|
+
const client = await captureClient(root2), jobId = randomUUID17();
|
|
47539
47772
|
try {
|
|
47540
47773
|
await client.enqueueJob(row.scope_id, { job: { id: jobId, kind: "auth-probe", captureId: String(item.entry.captureId) } });
|
|
47541
47774
|
const job = await awaitCaptureJob(client, jobId);
|
|
@@ -47729,7 +47962,7 @@ function previousWrite(store, item) {
|
|
|
47729
47962
|
return store.hasDispatchedRequestAttempt(item.id) || !!attempt && attempt.state !== "client-rejected";
|
|
47730
47963
|
}
|
|
47731
47964
|
async function migrateFile(invocation, api, state, store, session, app2, appId, root2) {
|
|
47732
|
-
const sourcePath = invocation.positionals[0] ?
|
|
47965
|
+
const sourcePath = invocation.positionals[0] ? resolve11(invocation.positionals[0]) : void 0;
|
|
47733
47966
|
const path2 = invocation.options.out;
|
|
47734
47967
|
const exists = (table) => !!state.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
47735
47968
|
const retained = store.retained(app2).filter((draft2) => draft2.appId === appId && (!draft2.ownerSessionId || draft2.ownerSessionId === session.id));
|
|
@@ -47750,8 +47983,8 @@ async function migrateFile(invocation, api, state, store, session, app2, appId,
|
|
|
47750
47983
|
}
|
|
47751
47984
|
}
|
|
47752
47985
|
}
|
|
47753
|
-
const selected = sourcePath ? retained.find((item) =>
|
|
47754
|
-
const set2 = sourcePath ? sets.find((item) =>
|
|
47986
|
+
const selected = sourcePath ? retained.find((item) => resolve11(item.filePath) === sourcePath) : void 0;
|
|
47987
|
+
const set2 = sourcePath ? sets.find((item) => resolve11(item.file_path) === sourcePath) ?? (selected && membership.get(selected.id)) : sets.length === 1 ? sets[0] : void 0;
|
|
47755
47988
|
if (!sourcePath && sets.length > 1) return fail5(`Choose an authoritative retained source:
|
|
47756
47989
|
${sets.map((item) => item.file_path).join("\n")}
|
|
47757
47990
|
`, 8);
|
|
@@ -47856,9 +48089,9 @@ async function handleDiscover(invocation, api, state, session, fetcher, root2) {
|
|
|
47856
48089
|
}
|
|
47857
48090
|
try {
|
|
47858
48091
|
if (!invocation.options.out && ["appsNew", "discoverDraft", "discoverCaptureSelect", "discoverRemove", "discoverMigrate"].includes(key2)) {
|
|
47859
|
-
const directory =
|
|
48092
|
+
const directory = resolve11(root2, "discovery-files");
|
|
47860
48093
|
mkdirSync11(directory, { recursive: true, mode: 448 });
|
|
47861
|
-
invocation = { ...invocation, options: { ...invocation.options, out: join17(directory, `${
|
|
48094
|
+
invocation = { ...invocation, options: { ...invocation.options, out: join17(directory, `${randomUUID17()}.jsonc`) } };
|
|
47862
48095
|
}
|
|
47863
48096
|
if (key2 === "appsHistory") {
|
|
47864
48097
|
const limit = Number(invocation.options.limit ?? 20);
|
|
@@ -47889,7 +48122,7 @@ ${page2.nextCursor ? `Next cursor: ${page2.nextCursor}
|
|
|
47889
48122
|
let jobId = row.job_id;
|
|
47890
48123
|
const prior = row.phase === "stopping" && jobId ? await captureJobResult(client, jobId) : null;
|
|
47891
48124
|
if (!jobId || row.phase !== "stopping" || prior?.status === "missing") {
|
|
47892
|
-
jobId =
|
|
48125
|
+
jobId = randomUUID17();
|
|
47893
48126
|
state.db.prepare("UPDATE discovery_capture SET phase='stopping',job_id=? WHERE draft_id=?").run(jobId, legacyRecording.id);
|
|
47894
48127
|
await client.enqueueJob(row.scope_id, { job: { id: jobId, kind: "stop" } });
|
|
47895
48128
|
}
|
|
@@ -47954,7 +48187,7 @@ Record a UI workflow: ${command4(invocation, "discover capture start")}
|
|
|
47954
48187
|
return status ? ok4(status) : ok4("No discovery recording or pending publication.\n");
|
|
47955
48188
|
}
|
|
47956
48189
|
if (key2 === "discoverCheck" || key2 === "discoverPublish" || key2 === "discoverTransportProbe") {
|
|
47957
|
-
const path2 =
|
|
48190
|
+
const path2 = resolve11(invocation.positionals[0]);
|
|
47958
48191
|
const source = readDraftFile(path2);
|
|
47959
48192
|
const setup = setupTarget(source);
|
|
47960
48193
|
if (key2 === "discoverTransportProbe") {
|
|
@@ -48047,7 +48280,7 @@ Record a UI workflow: ${command4(invocation, "discover capture start")}
|
|
|
48047
48280
|
if (await currentResource(api, app2.id, "entity", entity)) delete imported.draft.entities[entity];
|
|
48048
48281
|
}
|
|
48049
48282
|
writeBatch(path2, imported.draft);
|
|
48050
|
-
if (app2) rememberDocumentation(root2, state, api.cacheNamespace, session.id, app2,
|
|
48283
|
+
if (app2) rememberDocumentation(root2, state, api.cacheNamespace, session.id, app2, resolve11(invocation.options.from));
|
|
48051
48284
|
} else {
|
|
48052
48285
|
const draft = emptyBatch(app2?.slug ?? slug, app2?.id);
|
|
48053
48286
|
if (invocation.options.transport) draft.transport = invocation.options.transport;
|
|
@@ -48141,13 +48374,13 @@ Publish: ${command4(invocation, `discover publish ${quotePath(path2)}`)}
|
|
|
48141
48374
|
});
|
|
48142
48375
|
|
|
48143
48376
|
// src/output.ts
|
|
48144
|
-
import { randomUUID as
|
|
48377
|
+
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
48145
48378
|
import { chmod, mkdtemp, open as open3, rename } from "node:fs/promises";
|
|
48146
48379
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
48147
48380
|
import { join as join18 } from "node:path";
|
|
48148
48381
|
async function completedFile(directory, name, content) {
|
|
48149
48382
|
const target = join18(directory, name);
|
|
48150
|
-
const pending = join18(directory, `.${name}-${
|
|
48383
|
+
const pending = join18(directory, `.${name}-${randomUUID18()}`);
|
|
48151
48384
|
const handle2 = await open3(pending, "wx", 384);
|
|
48152
48385
|
try {
|
|
48153
48386
|
await handle2.writeFile(content, "utf8");
|
|
@@ -48207,12 +48440,12 @@ var init_output = __esm({
|
|
|
48207
48440
|
// ../../node_modules/.pnpm/tinyexec@1.3.1/node_modules/tinyexec/dist/main.mjs
|
|
48208
48441
|
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
48209
48442
|
import { cwd } from "node:process";
|
|
48210
|
-
import { basename as
|
|
48443
|
+
import { basename as basename4, delimiter, dirname as dirname6, normalize as normalize2, resolve as resolve12 } from "node:path";
|
|
48211
48444
|
import { fileURLToPath } from "node:url";
|
|
48212
48445
|
import { pipeline } from "node:stream/promises";
|
|
48213
48446
|
import { PassThrough } from "node:stream";
|
|
48214
48447
|
import readline from "node:readline";
|
|
48215
|
-
import { closeSync as
|
|
48448
|
+
import { closeSync as closeSync4, openSync as openSync4, readSync as readSync4, statSync as statSync5 } from "node:fs";
|
|
48216
48449
|
function getPathFromEnv(env) {
|
|
48217
48450
|
for (const key2 in env) {
|
|
48218
48451
|
if (!Object.prototype.hasOwnProperty.call(env, key2) || !isPathLikePattern.test(key2)) continue;
|
|
@@ -48231,7 +48464,7 @@ function addNodeBinToPath(cwd2, path2) {
|
|
|
48231
48464
|
let currentPath = typeof cwd2 === "string" ? cwd2 : fileURLToPath(cwd2, { windows: false });
|
|
48232
48465
|
let lastPath;
|
|
48233
48466
|
do {
|
|
48234
|
-
nodeBinPaths.push(
|
|
48467
|
+
nodeBinPaths.push(resolve12(currentPath, "node_modules", ".bin"));
|
|
48235
48468
|
lastPath = currentPath;
|
|
48236
48469
|
currentPath = dirname6(currentPath);
|
|
48237
48470
|
} while (currentPath !== lastPath);
|
|
@@ -48265,11 +48498,11 @@ function normalizeSpawnCommand(command6, args = [], options2 = {}) {
|
|
|
48265
48498
|
const buffer = Buffer.alloc(size);
|
|
48266
48499
|
let fd = null;
|
|
48267
48500
|
try {
|
|
48268
|
-
fd =
|
|
48269
|
-
|
|
48501
|
+
fd = openSync4(file3, "r");
|
|
48502
|
+
readSync4(fd, buffer, 0, size, 0);
|
|
48270
48503
|
} catch {
|
|
48271
48504
|
} finally {
|
|
48272
|
-
if (fd !== null)
|
|
48505
|
+
if (fd !== null) closeSync4(fd);
|
|
48273
48506
|
}
|
|
48274
48507
|
const match = buffer.toString().match(shebangRegExp);
|
|
48275
48508
|
if (match !== null) {
|
|
@@ -48277,7 +48510,7 @@ function normalizeSpawnCommand(command6, args = [], options2 = {}) {
|
|
|
48277
48510
|
const separatorIndex = line.indexOf(" ");
|
|
48278
48511
|
const path2 = separatorIndex !== -1 ? line.slice(0, separatorIndex) : line;
|
|
48279
48512
|
const argument = separatorIndex !== -1 ? line.slice(separatorIndex + 1) : "";
|
|
48280
|
-
const binary =
|
|
48513
|
+
const binary = basename4(path2);
|
|
48281
48514
|
shebang = binary === "env" ? argument || null : binary;
|
|
48282
48515
|
}
|
|
48283
48516
|
}
|
|
@@ -48325,7 +48558,7 @@ function resolveCommand(command6, options2) {
|
|
|
48325
48558
|
if (command6.includes(".") && pathExt[0] !== "") pathExt = ["", ...pathExt];
|
|
48326
48559
|
for (const extensions of [pathExt, noPathExt]) for (const path2 of pathEnv) {
|
|
48327
48560
|
const unquoted = path2.startsWith('"') && path2.endsWith('"') && path2.length > 1 ? path2.slice(1, -1) : path2;
|
|
48328
|
-
const dest =
|
|
48561
|
+
const dest = resolve12(cwd$3, unquoted, command6);
|
|
48329
48562
|
for (const ext of extensions) {
|
|
48330
48563
|
const destWithExt = dest + ext;
|
|
48331
48564
|
try {
|
|
@@ -48394,9 +48627,9 @@ function xSync(command6, args, options2) {
|
|
|
48394
48627
|
return killed;
|
|
48395
48628
|
},
|
|
48396
48629
|
*[Symbol.iterator]() {
|
|
48397
|
-
for (const
|
|
48398
|
-
if (!
|
|
48399
|
-
const lines =
|
|
48630
|
+
for (const text5 of [stdout, stderr]) {
|
|
48631
|
+
if (!text5) continue;
|
|
48632
|
+
const lines = text5.split(LINE_SEPARATOR_REGEX);
|
|
48400
48633
|
if (lines[lines.length - 1] === "") lines.pop();
|
|
48401
48634
|
yield* lines;
|
|
48402
48635
|
}
|
|
@@ -48495,8 +48728,8 @@ var init_main2 = __esm({
|
|
|
48495
48728
|
};
|
|
48496
48729
|
this._command = command6;
|
|
48497
48730
|
this._args = args ?? [];
|
|
48498
|
-
this._processClosed = new Promise((
|
|
48499
|
-
this._resolveClose =
|
|
48731
|
+
this._processClosed = new Promise((resolve17) => {
|
|
48732
|
+
this._resolveClose = resolve17;
|
|
48500
48733
|
});
|
|
48501
48734
|
}
|
|
48502
48735
|
kill(signal) {
|
|
@@ -48579,8 +48812,8 @@ var init_main2 = __esm({
|
|
|
48579
48812
|
}
|
|
48580
48813
|
_resetState() {
|
|
48581
48814
|
this._aborted = false;
|
|
48582
|
-
this._processClosed = new Promise((
|
|
48583
|
-
this._resolveClose =
|
|
48815
|
+
this._processClosed = new Promise((resolve17) => {
|
|
48816
|
+
this._resolveClose = resolve17;
|
|
48584
48817
|
});
|
|
48585
48818
|
this._thrownError = void 0;
|
|
48586
48819
|
}
|
|
@@ -48605,10 +48838,10 @@ var init_main2 = __esm({
|
|
|
48605
48838
|
});
|
|
48606
48839
|
|
|
48607
48840
|
// src/plugin.ts
|
|
48608
|
-
import { createHash as
|
|
48841
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
48609
48842
|
import { cpSync, existsSync as existsSync6, mkdirSync as mkdirSync12, readFileSync as readFileSync8, readdirSync, renameSync as renameSync5, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "node:fs";
|
|
48610
48843
|
import { homedir as homedir2 } from "node:os";
|
|
48611
|
-
import { dirname as dirname7, join as join19, resolve as
|
|
48844
|
+
import { dirname as dirname7, join as join19, resolve as resolve13 } from "node:path";
|
|
48612
48845
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48613
48846
|
function missingSkill(root2) {
|
|
48614
48847
|
return skillNames.find((name) => !existsSync6(join19(root2, "skills", name, "SKILL.md")));
|
|
@@ -48623,7 +48856,7 @@ function files(root2, relative = "") {
|
|
|
48623
48856
|
}).sort();
|
|
48624
48857
|
}
|
|
48625
48858
|
function digest5(root2) {
|
|
48626
|
-
const hash4 =
|
|
48859
|
+
const hash4 = createHash23("sha256");
|
|
48627
48860
|
for (const path2 of files(root2)) hash4.update(path2).update("\0").update(readFileSync8(join19(root2, path2))).update("\0");
|
|
48628
48861
|
return hash4.digest("hex");
|
|
48629
48862
|
}
|
|
@@ -48667,14 +48900,14 @@ function active(agent2, expected) {
|
|
|
48667
48900
|
}
|
|
48668
48901
|
function inspectAgentPlugin(agent2, env, sourceOverride) {
|
|
48669
48902
|
if (env.APILIFT_DEV_PLUGIN_ROOT) return { ready: false, version: "development", detail: "Development plugin activation has not been verified" };
|
|
48670
|
-
const source =
|
|
48903
|
+
const source = resolve13(sourceOverride || join19(dirname7(fileURLToPath2(import.meta.url)), "plugin"));
|
|
48671
48904
|
const missing2 = missingSkill(source);
|
|
48672
48905
|
if (missing2) return { ready: false, version: "unknown", detail: `CLI package is missing its ${missing2} skill` };
|
|
48673
48906
|
const version2 = readJson(join19(source, `.${agent2}-plugin`, "plugin.json"))?.version;
|
|
48674
48907
|
if (typeof version2 !== "string" || !/^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?$/.test(version2)) throw new Error("Plugin package version is invalid");
|
|
48675
48908
|
const bundleDigest = digest5(source);
|
|
48676
48909
|
const expected = agent2 === "codex" ? `${version2}+codex.${bundleDigest.slice(0, 12)}` : version2;
|
|
48677
|
-
const home =
|
|
48910
|
+
const home = resolve13(env.APILIFT_AGENT_HOME || homedir2());
|
|
48678
48911
|
const plugin = agent2 === "codex" ? join19(home, "plugins", "apilift") : join19(home, ".agents", "plugins", "plugins", "apilift");
|
|
48679
48912
|
const marker = readJson(join19(plugin, markerName));
|
|
48680
48913
|
const staged = marker?.package === "apilift" && marker.bundleDigest === bundleDigest && marker.version === version2 && completeCopy(source, plugin);
|
|
@@ -48685,21 +48918,21 @@ function inspectAgentPlugin(agent2, env, sourceOverride) {
|
|
|
48685
48918
|
}
|
|
48686
48919
|
function ensureAgentPlugin(agent2, env, sourceOverride) {
|
|
48687
48920
|
if (env.APILIFT_DEV_PLUGIN_ROOT) {
|
|
48688
|
-
const source2 =
|
|
48921
|
+
const source2 = resolve13(env.APILIFT_DEV_PLUGIN_ROOT);
|
|
48689
48922
|
const missing3 = missingSkill(source2);
|
|
48690
48923
|
if (missing3) throw new Error(`Development plugin ${missing3} skill is missing`);
|
|
48691
48924
|
const bundleDigest2 = digest5(source2);
|
|
48692
|
-
const root2 =
|
|
48925
|
+
const root2 = resolve13(env.APILIFT_HOME || join19(homedir2(), ".local", "share", "apilift"));
|
|
48693
48926
|
writeJson(join19(root2, "agent-plugins", `${agent2}.json`), { root: source2, digest: bundleDigest2 });
|
|
48694
48927
|
return { ready: false, version: `dev+${bundleDigest2.slice(0, 12)}`, detail: "Development plugin source recorded; activation was not verified" };
|
|
48695
48928
|
}
|
|
48696
|
-
const source =
|
|
48929
|
+
const source = resolve13(sourceOverride || join19(dirname7(fileURLToPath2(import.meta.url)), "plugin"));
|
|
48697
48930
|
const missing2 = missingSkill(source);
|
|
48698
48931
|
if (missing2) throw new Error(`CLI package is missing its ${missing2} skill`);
|
|
48699
48932
|
const version2 = readJson(join19(source, `.${agent2}-plugin`, "plugin.json"))?.version;
|
|
48700
48933
|
if (typeof version2 !== "string" || !/^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?$/.test(version2)) throw new Error("Plugin package version is invalid");
|
|
48701
48934
|
const bundleDigest = digest5(source);
|
|
48702
|
-
const home =
|
|
48935
|
+
const home = resolve13(env.APILIFT_AGENT_HOME || homedir2());
|
|
48703
48936
|
const marketplace = join19(home, ".agents", "plugins");
|
|
48704
48937
|
const plugin = agent2 === "codex" ? join19(home, "plugins", "apilift") : join19(marketplace, "plugins", "apilift");
|
|
48705
48938
|
const marker = readJson(join19(plugin, markerName));
|
|
@@ -48768,13 +49001,13 @@ var init_plugin = __esm({
|
|
|
48768
49001
|
|
|
48769
49002
|
// src/usage/ownership.ts
|
|
48770
49003
|
import { mkdirSync as mkdirSync13, chmodSync as chmodSync7, existsSync as existsSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync12, renameSync as renameSync6, unlinkSync as unlinkSync5, statSync as statSync6 } from "node:fs";
|
|
48771
|
-
import { createHash as
|
|
49004
|
+
import { createHash as createHash24, randomUUID as randomUUID19 } from "node:crypto";
|
|
48772
49005
|
import { join as join20, dirname as dirname8, isAbsolute as isAbsolute5 } from "node:path";
|
|
48773
49006
|
import { DatabaseSync as DatabaseSync7 } from "node:sqlite";
|
|
48774
49007
|
function requestCollectorTarget(root2, entry2, env) {
|
|
48775
49008
|
const owner = readOwner(root2);
|
|
48776
49009
|
if (!owner) return;
|
|
48777
|
-
const pending = join20(root2, "usage", `.collector-target-${
|
|
49010
|
+
const pending = join20(root2, "usage", `.collector-target-${randomUUID19()}`);
|
|
48778
49011
|
try {
|
|
48779
49012
|
const target = { owner: owner.id, entry: entry2, interpreter: process.execPath, fingerprint: sourceFingerprint(entry2), env: Object.fromEntries(runtimeKeys.map((key2) => [key2, env[key2] ?? null])) };
|
|
48780
49013
|
writeFileSync12(pending, JSON.stringify(target), { mode: 384 });
|
|
@@ -48824,7 +49057,7 @@ var init_ownership = __esm({
|
|
|
48824
49057
|
"use strict";
|
|
48825
49058
|
ownerLifetimeMs = 6e4;
|
|
48826
49059
|
targetFile = (root2) => join20(root2, "usage", "collector-target.json");
|
|
48827
|
-
sourceFingerprint = (entry2) =>
|
|
49060
|
+
sourceFingerprint = (entry2) => createHash24("sha256").update(readFileSync9(entry2)).digest("hex");
|
|
48828
49061
|
runtimeKeys = ["APILIFT_URL", "CODEX_HOME", "CLAUDE_CONFIG_DIR", "APILIFT_BIN", "APILIFT_DEV_PLUGIN_ROOT"];
|
|
48829
49062
|
ownerFile = (root2) => join20(root2, "usage", "collector-owner.json");
|
|
48830
49063
|
}
|
|
@@ -49710,10 +49943,10 @@ var require_truncate = __commonJS({
|
|
|
49710
49943
|
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js"(exports, module) {
|
|
49711
49944
|
"use strict";
|
|
49712
49945
|
var parse8 = require_parse();
|
|
49713
|
-
var
|
|
49946
|
+
var constants5 = require_constants();
|
|
49714
49947
|
var SemVer = require_semver();
|
|
49715
49948
|
var truncate = (version2, truncation, options2) => {
|
|
49716
|
-
if (!
|
|
49949
|
+
if (!constants5.RELEASE_TYPES.includes(truncation)) {
|
|
49717
49950
|
return null;
|
|
49718
49951
|
}
|
|
49719
49952
|
const clonedVersion = cloneInputVersion(version2, options2);
|
|
@@ -50762,7 +50995,7 @@ var require_semver2 = __commonJS({
|
|
|
50762
50995
|
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js"(exports, module) {
|
|
50763
50996
|
"use strict";
|
|
50764
50997
|
var internalRe = require_re();
|
|
50765
|
-
var
|
|
50998
|
+
var constants5 = require_constants();
|
|
50766
50999
|
var SemVer = require_semver();
|
|
50767
51000
|
var identifiers = require_identifiers();
|
|
50768
51001
|
var parse8 = require_parse();
|
|
@@ -50846,8 +51079,8 @@ var require_semver2 = __commonJS({
|
|
|
50846
51079
|
re: internalRe.re,
|
|
50847
51080
|
src: internalRe.src,
|
|
50848
51081
|
tokens: internalRe.t,
|
|
50849
|
-
SEMVER_SPEC_VERSION:
|
|
50850
|
-
RELEASE_TYPES:
|
|
51082
|
+
SEMVER_SPEC_VERSION: constants5.SEMVER_SPEC_VERSION,
|
|
51083
|
+
RELEASE_TYPES: constants5.RELEASE_TYPES,
|
|
50851
51084
|
compareIdentifiers: identifiers.compareIdentifiers,
|
|
50852
51085
|
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
50853
51086
|
};
|
|
@@ -50895,11 +51128,11 @@ var init_compat2 = __esm({
|
|
|
50895
51128
|
});
|
|
50896
51129
|
|
|
50897
51130
|
// src/native-host/registration.ts
|
|
50898
|
-
import { createHash as
|
|
51131
|
+
import { createHash as createHash25, randomUUID as randomUUID20 } from "node:crypto";
|
|
50899
51132
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
50900
51133
|
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync13 } from "node:fs";
|
|
50901
|
-
import { homedir as homedir3, platform as
|
|
50902
|
-
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join21, resolve as
|
|
51134
|
+
import { homedir as homedir3, platform as platform3 } from "node:os";
|
|
51135
|
+
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join21, resolve as resolve14 } from "node:path";
|
|
50903
51136
|
import { chmod as chmod2, mkdir, readFile, rename as rename2, writeFile, copyFile, rm, stat } from "node:fs/promises";
|
|
50904
51137
|
function batchLiteral(value) {
|
|
50905
51138
|
if (/["\r\n\0]/u.test(value)) throw new Error("Native host launcher values contain unsupported control characters");
|
|
@@ -50962,8 +51195,8 @@ function registerWindowsHost(hostName, manifest, owned, run2 = execFileSync2, wr
|
|
|
50962
51195
|
}
|
|
50963
51196
|
if (write) for (const view of /* @__PURE__ */ new Set(["32", ...present])) run2("reg.exe", ["add", key2, "/ve", "/t", "REG_SZ", "/d", manifest, "/f", `/reg:${view}`], options2);
|
|
50964
51197
|
}
|
|
50965
|
-
function manifestDirectory(env = process.env, system = { platform:
|
|
50966
|
-
if (env.APILIFT_NATIVE_MESSAGING_DIR) return
|
|
51198
|
+
function manifestDirectory(env = process.env, system = { platform: platform3(), home: homedir3() }) {
|
|
51199
|
+
if (env.APILIFT_NATIVE_MESSAGING_DIR) return resolve14(env.APILIFT_NATIVE_MESSAGING_DIR);
|
|
50967
51200
|
const home = system.home;
|
|
50968
51201
|
if (system.platform === "darwin") return join21(home, "Library", "Application Support", "Google", "Chrome", "NativeMessagingHosts");
|
|
50969
51202
|
if (system.platform === "win32") throw new Error("Windows native-host registration needs a data-root manifest and HKCU registry entry");
|
|
@@ -50977,13 +51210,13 @@ async function registerNativeHost(options2) {
|
|
|
50977
51210
|
if (![options2.root, options2.hostScript, options2.nodePath ?? process.execPath].every(isAbsolute6)) throw new Error("Native host paths must be absolute");
|
|
50978
51211
|
const siteUrl2 = options2.siteUrl ? new URL(options2.siteUrl) : null;
|
|
50979
51212
|
if (siteUrl2 && (!["http:", "https:"].includes(siteUrl2.protocol) || siteUrl2.origin !== options2.siteUrl)) throw new Error("Native host site URL must be an http(s) origin");
|
|
50980
|
-
const root2 =
|
|
51213
|
+
const root2 = resolve14(options2.root), hostScript = resolve14(options2.hostScript), nodePath = resolve14(options2.nodePath ?? process.execPath);
|
|
50981
51214
|
const nativeRoot = join21(root2, "native-host");
|
|
50982
|
-
const manifestRoot = env.APILIFT_NATIVE_MESSAGING_DIR ?
|
|
50983
|
-
const launcher = join21(nativeRoot,
|
|
51215
|
+
const manifestRoot = env.APILIFT_NATIVE_MESSAGING_DIR ? resolve14(env.APILIFT_NATIVE_MESSAGING_DIR) : platform3() === "win32" ? nativeRoot : manifestDirectory(env);
|
|
51216
|
+
const launcher = join21(nativeRoot, platform3() === "win32" ? "launcher.cmd" : "launcher.sh");
|
|
50984
51217
|
const manifest = join21(manifestRoot, `${hostName}.json`);
|
|
50985
51218
|
const manifests = [manifest];
|
|
50986
|
-
if (
|
|
51219
|
+
if (platform3() === "linux" && !env.APILIFT_NATIVE_MESSAGING_DIR) {
|
|
50987
51220
|
for (const browser of ["google-chrome-beta", "google-chrome-unstable", "chromium"]) {
|
|
50988
51221
|
const profile = join21(dirname9(dirname9(manifestRoot)), browser);
|
|
50989
51222
|
if (await stat(profile).then((value) => value.isDirectory()).catch(() => false)) manifests.push(join21(profile, "NativeMessagingHosts", `${hostName}.json`));
|
|
@@ -51010,16 +51243,16 @@ async function registerNativeHost(options2) {
|
|
|
51010
51243
|
};
|
|
51011
51244
|
await guard(launcher);
|
|
51012
51245
|
for (const path2 of manifests) await guard(path2);
|
|
51013
|
-
if (
|
|
51246
|
+
if (platform3() === "win32" && !env.APILIFT_NATIVE_MESSAGING_DIR) {
|
|
51014
51247
|
const bytes = await readFile(manifest).catch(() => null);
|
|
51015
51248
|
registerWindowsHost(hostName, manifest, Boolean(bytes && previous[manifest] === fingerprint(bytes)), execFileSync2, false, registryBackup);
|
|
51016
51249
|
}
|
|
51017
51250
|
await mkdir(nativeRoot, { recursive: true, mode: 448 });
|
|
51018
51251
|
await mkdir(manifestRoot, { recursive: true, mode: 448 });
|
|
51019
|
-
const launcherText = nativeLauncher({ root: root2, hostName, nodePath, hostScript, manifestRoot, site: siteUrl2?.origin },
|
|
51252
|
+
const launcherText = nativeLauncher({ root: root2, hostName, nodePath, hostScript, manifestRoot, site: siteUrl2?.origin }, platform3() === "win32");
|
|
51020
51253
|
const manifestText = JSON.stringify({ name: hostName, description: "Apilift browser bridge", path: launcher, type: "stdio", allowed_origins: [`chrome-extension://${options2.extensionId}/`] }, null, 2) + "\n";
|
|
51021
51254
|
const atomicWrite = async (path2, bytes, mode) => {
|
|
51022
|
-
const temp = join21(dirname9(path2), `.${hostName}-${
|
|
51255
|
+
const temp = join21(dirname9(path2), `.${hostName}-${randomUUID20()}.tmp`);
|
|
51023
51256
|
try {
|
|
51024
51257
|
await writeFile(temp, bytes, { mode, flag: "wx" });
|
|
51025
51258
|
await chmod2(temp, mode);
|
|
@@ -51028,21 +51261,21 @@ async function registerNativeHost(options2) {
|
|
|
51028
51261
|
await rm(temp, { force: true });
|
|
51029
51262
|
}
|
|
51030
51263
|
};
|
|
51031
|
-
await atomicWrite(launcher, launcherText,
|
|
51264
|
+
await atomicWrite(launcher, launcherText, platform3() === "win32" ? 384 : 448);
|
|
51032
51265
|
for (const path2 of manifests) {
|
|
51033
51266
|
await mkdir(dirname9(path2), { recursive: true, mode: 448 });
|
|
51034
51267
|
await atomicWrite(path2, manifestText, 384);
|
|
51035
51268
|
}
|
|
51036
51269
|
const receipt = { ...previous, [launcher]: fingerprint(launcherText), ...Object.fromEntries(manifests.map((path2) => [path2, fingerprint(manifestText)])) };
|
|
51037
51270
|
await atomicWrite(receiptPath, JSON.stringify(receipt, null, 2) + "\n", 384);
|
|
51038
|
-
if (
|
|
51271
|
+
if (platform3() === "win32" && !env.APILIFT_NATIVE_MESSAGING_DIR) registerWindowsHost(hostName, manifest, true, execFileSync2, true, registryBackup);
|
|
51039
51272
|
return { launcher, manifest, hostName };
|
|
51040
51273
|
}
|
|
51041
51274
|
var fingerprint, hostNames, validId, posixQuote, absoluteEnv;
|
|
51042
51275
|
var init_registration = __esm({
|
|
51043
51276
|
"src/native-host/registration.ts"() {
|
|
51044
51277
|
"use strict";
|
|
51045
|
-
fingerprint = (bytes) =>
|
|
51278
|
+
fingerprint = (bytes) => createHash25("sha256").update(bytes).digest("hex");
|
|
51046
51279
|
hostNames = /* @__PURE__ */ new Set(["com.apilift.browser", "com.apilift.browser.dev"]);
|
|
51047
51280
|
validId = /^[a-p]{32}$/;
|
|
51048
51281
|
posixQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
@@ -51052,14 +51285,14 @@ var init_registration = __esm({
|
|
|
51052
51285
|
|
|
51053
51286
|
// src/windows-launcher.ts
|
|
51054
51287
|
import { readFileSync as readFileSync10, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "node:fs";
|
|
51055
|
-
import { dirname as dirname10, join as join22, resolve as
|
|
51056
|
-
function repairWindowsNpmLauncher(entrypoint,
|
|
51057
|
-
if (
|
|
51058
|
-
const packageRoot = dirname10(dirname10(
|
|
51059
|
-
const prefix2 =
|
|
51288
|
+
import { dirname as dirname10, join as join22, resolve as resolve15 } from "node:path";
|
|
51289
|
+
function repairWindowsNpmLauncher(entrypoint, platform5 = process.platform) {
|
|
51290
|
+
if (platform5 !== "win32") return;
|
|
51291
|
+
const packageRoot = dirname10(dirname10(resolve15(entrypoint)));
|
|
51292
|
+
const prefix2 = resolve15(packageRoot, "../../..");
|
|
51060
51293
|
const expected = join22(prefix2, "node_modules", "@apilift", "cli", "dist", "apilift.js");
|
|
51061
51294
|
const pkg = JSON.parse(readFileSync10(join22(packageRoot, "package.json"), "utf8"));
|
|
51062
|
-
if (expected.toLowerCase() !==
|
|
51295
|
+
if (expected.toLowerCase() !== resolve15(entrypoint).toLowerCase() || pkg.name !== "@apilift/cli" || pkg.bin?.apilift?.replace(/^\.\//u, "") !== "dist/apilift.js") throw new Error("The owned Windows npm launcher could not be verified");
|
|
51063
51296
|
writeFileSync14(join22(prefix2, "apilift.cmd"), [
|
|
51064
51297
|
"@echo off",
|
|
51065
51298
|
"setlocal DisableDelayedExpansion",
|
|
@@ -51081,7 +51314,7 @@ var init_windows_launcher = __esm({
|
|
|
51081
51314
|
|
|
51082
51315
|
// src/update.ts
|
|
51083
51316
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
51084
|
-
import { dirname as dirname11, join as join23, resolve as
|
|
51317
|
+
import { dirname as dirname11, join as join23, resolve as resolve16, sep, isAbsolute as isAbsolute7 } from "node:path";
|
|
51085
51318
|
import { mkdirSync as mkdirSync15, realpathSync as realpathSync5, writeFileSync as writeFileSync15, readFileSync as readFileSync11 } from "node:fs";
|
|
51086
51319
|
import { DatabaseSync as DatabaseSync8 } from "node:sqlite";
|
|
51087
51320
|
function globalPackage(script2, prefix2) {
|
|
@@ -51089,7 +51322,7 @@ function globalPackage(script2, prefix2) {
|
|
|
51089
51322
|
try {
|
|
51090
51323
|
return realpathSync5(path2);
|
|
51091
51324
|
} catch {
|
|
51092
|
-
return
|
|
51325
|
+
return resolve16(path2);
|
|
51093
51326
|
}
|
|
51094
51327
|
};
|
|
51095
51328
|
const normalized = canonical(script2).toLowerCase();
|
|
@@ -51117,7 +51350,7 @@ async function installationManager(script2, runner, env) {
|
|
|
51117
51350
|
try {
|
|
51118
51351
|
return realpathSync5(path2);
|
|
51119
51352
|
} catch {
|
|
51120
|
-
return
|
|
51353
|
+
return resolve16(path2);
|
|
51121
51354
|
}
|
|
51122
51355
|
};
|
|
51123
51356
|
const selected = (await pnpmInstallations(runner, env)).find((candidate2) => canonical(candidate2.entrypoint) === canonical(script2));
|
|
@@ -51299,7 +51532,7 @@ var init_windows_installation = __esm({
|
|
|
51299
51532
|
});
|
|
51300
51533
|
|
|
51301
51534
|
// src/setup-check.ts
|
|
51302
|
-
import { randomUUID as
|
|
51535
|
+
import { randomUUID as randomUUID21 } from "node:crypto";
|
|
51303
51536
|
import { existsSync as existsSync9, readFileSync as readFileSync12, realpathSync as realpathSync7, writeFileSync as writeFileSync16 } from "node:fs";
|
|
51304
51537
|
import { dirname as dirname12, join as join24 } from "node:path";
|
|
51305
51538
|
async function setupCheckBody(client, scopeId, value) {
|
|
@@ -51325,7 +51558,7 @@ function setupChallenge(root2, agent2, site) {
|
|
|
51325
51558
|
if (new URL(saved.url).origin === site && Number.isFinite(saved.createdAt) && Date.now() - saved.createdAt < 10 * 6e4) return saved;
|
|
51326
51559
|
} catch {
|
|
51327
51560
|
}
|
|
51328
|
-
const challenge = { url: `${site}/setup-check?challenge=${
|
|
51561
|
+
const challenge = { url: `${site}/setup-check?challenge=${randomUUID21()}`, createdAt: Date.now() };
|
|
51329
51562
|
writeFileSync16(file3, JSON.stringify(challenge), { mode: 384 });
|
|
51330
51563
|
return challenge;
|
|
51331
51564
|
}
|
|
@@ -51341,7 +51574,7 @@ async function setupReadiness(api, waitForReport, timeoutMs = 1e4) {
|
|
|
51341
51574
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
51342
51575
|
let readiness2 = await api.call("updateReadiness", { body: {}, ...waitForReport ? { signal } : {} });
|
|
51343
51576
|
while (waitForReport && (!readiness2.machine.nativeHostReady || !readiness2.machine.extensionReady) && Date.now() < deadline) {
|
|
51344
|
-
await new Promise((
|
|
51577
|
+
await new Promise((resolve17) => setTimeout(resolve17, Math.min(250, Math.max(0, deadline - Date.now()))));
|
|
51345
51578
|
if (signal.aborted || Date.now() >= deadline) break;
|
|
51346
51579
|
try {
|
|
51347
51580
|
readiness2 = await api.call("updateReadiness", { body: {}, signal });
|
|
@@ -51364,14 +51597,14 @@ async function verifySetupCheck(root2, challenge) {
|
|
|
51364
51597
|
do {
|
|
51365
51598
|
candidates = (await client.candidates(inspect2.id)).candidates;
|
|
51366
51599
|
if (candidates.length) break;
|
|
51367
|
-
await new Promise((
|
|
51600
|
+
await new Promise((resolve17) => setTimeout(resolve17, 200));
|
|
51368
51601
|
} while (Date.now() < deadline);
|
|
51369
51602
|
} finally {
|
|
51370
51603
|
await client.closeScope(inspect2.id);
|
|
51371
51604
|
}
|
|
51372
51605
|
if (candidates.length !== 1) return { ok: false, reason: candidates.length ? "More than one exact check tab matched" : "The extension did not report the exact check tab within 10 seconds" };
|
|
51373
51606
|
const execute = await client.openScope({ kind: "execute", tabSelector: candidates[0].selector, ...scopeInput });
|
|
51374
|
-
const id2 =
|
|
51607
|
+
const id2 = randomUUID21();
|
|
51375
51608
|
try {
|
|
51376
51609
|
await client.enqueueJob(execute.id, { job: { id: id2, kind: "replay", effect: "read", method: "GET", url: challenge.url, headers: {}, pageOrigin, allowedRequestOrigin: pageOrigin, timeoutMs: 2e4 } });
|
|
51377
51610
|
const deadline = Date.now() + 3e4;
|
|
@@ -51390,7 +51623,7 @@ async function verifySetupCheck(root2, challenge) {
|
|
|
51390
51623
|
return body.includes("Apilift can reach this tab") ? { ok: true } : { ok: false, reason: "The safe check response did not contain the expected page marker" };
|
|
51391
51624
|
}
|
|
51392
51625
|
if (held.status === "uncertain") return { ok: false, reason: "Chrome reported an uncertain check outcome" };
|
|
51393
|
-
await new Promise((
|
|
51626
|
+
await new Promise((resolve17) => setTimeout(resolve17, 200));
|
|
51394
51627
|
} while (Date.now() < deadline);
|
|
51395
51628
|
return { ok: false, reason: `Chrome did not return the safe check result within 30 seconds (job ${lastStatus})` };
|
|
51396
51629
|
} finally {
|
|
@@ -51453,7 +51686,7 @@ var cli_exports = {};
|
|
|
51453
51686
|
__export(cli_exports, {
|
|
51454
51687
|
runCli: () => runCli
|
|
51455
51688
|
});
|
|
51456
|
-
import { hostname as hostname3, platform as
|
|
51689
|
+
import { hostname as hostname3, platform as platform4, arch } from "node:os";
|
|
51457
51690
|
import { join as join25 } from "node:path";
|
|
51458
51691
|
import { mkdirSync as mkdirSync16 } from "node:fs";
|
|
51459
51692
|
function result2(stdout = "", exitCode = 0, stderr = "", dispatched = false, code) {
|
|
@@ -51490,7 +51723,9 @@ function commandHelp(identity3) {
|
|
|
51490
51723
|
apilift actions show <app> <action>... [--schema] [--input-template <file>] (1\u201310 actions)
|
|
51491
51724
|
apilift run [--test] <app> <action> [action flags] [--input <JSON|@file|->] [--select <pointer>] [--output <file>] [--check] [--no-context]
|
|
51492
51725
|
apilift --operation-id <id> run <app> <mutation> [action flags] [--input <JSON|@file|->]
|
|
51493
|
-
apilift feedback <
|
|
51726
|
+
apilift feedback report --blocked <text> --repro <text> --expected <text> --actual <text> [--comment <text>] [--attach <file>] [--from <id>]
|
|
51727
|
+
apilift feedback action <app> <action> --blocked <text> --repro <text> --expected <text> --actual <text> [--comment <text>] [--attach <file>] [--from <id>] [--execution <id>] [--incorrect]
|
|
51728
|
+
apilift feedback retry <id>
|
|
51494
51729
|
apilift context set <name> <value> [--app <app>]
|
|
51495
51730
|
apilift context show [--app <app>]
|
|
51496
51731
|
apilift context unset <name> [--app <app>]
|
|
@@ -51592,7 +51827,7 @@ The page supplies a one-time code. Finish linking with that exact code:
|
|
|
51592
51827
|
${prefix2} setup continue
|
|
51593
51828
|
`, 0, "", true);
|
|
51594
51829
|
}
|
|
51595
|
-
const linked = await api2.call("createInstallation", { body: { code, agent: session.agent, machine: { label: hostname3().slice(0, 80), os:
|
|
51830
|
+
const linked = await api2.call("createInstallation", { body: { code, agent: session.agent, machine: { label: hostname3().slice(0, 80), os: platform4(), arch: arch() } } });
|
|
51596
51831
|
try {
|
|
51597
51832
|
state.saveInstallation({ id: linked.installation.id, token: linked.token, accountId: linked.account.id, workspaceId: linked.workspace.id });
|
|
51598
51833
|
new CliAnalytics(state, cliVersion, fetcher).saveOnboardingAttempt(linked.onboardingAttemptId);
|
|
@@ -51603,6 +51838,7 @@ The page supplies a one-time code. Finish linking with that exact code:
|
|
|
51603
51838
|
${prefix2} setup continue
|
|
51604
51839
|
`, 0, "", true);
|
|
51605
51840
|
}
|
|
51841
|
+
if (invocation.key.startsWith("feedback")) return await handleFeedback(invocation, createCliApi(site, fetcher, installed?.token, installed ? apiSessionId(installed.id, session) : void 0), state, session);
|
|
51606
51842
|
if (!installed) return result2("", 9, `installation-required \u2014 This machine is not linked. No app request was sent.
|
|
51607
51843
|
Open ${site}/dashboard/get-started and then run:
|
|
51608
51844
|
${prefix2} setup --code <code>
|
|
@@ -51640,7 +51876,6 @@ Open ${site}/dashboard/get-started and then run:
|
|
|
51640
51876
|
}
|
|
51641
51877
|
return output2;
|
|
51642
51878
|
}
|
|
51643
|
-
if (invocation.key === "feedback") return await handleFeedback(invocation, api, state, session);
|
|
51644
51879
|
if (invocation.key === "run") return await handleRun(invocation, api, state, session, fetcher, dataRoot(env), void 0, onReport);
|
|
51645
51880
|
if (invocation.key === "setupContinue") {
|
|
51646
51881
|
await api.call("me");
|
|
@@ -51830,6 +52065,24 @@ ${apiError2.hint ? `${apiError2.hint}
|
|
|
51830
52065
|
}
|
|
51831
52066
|
}
|
|
51832
52067
|
}
|
|
52068
|
+
if (session && invocationId && parsed.invocation && !parsed.invocation.key.startsWith("feedback")) {
|
|
52069
|
+
try {
|
|
52070
|
+
const state = new LocalState(dataRoot(env));
|
|
52071
|
+
try {
|
|
52072
|
+
const diagnostic = output2.exitCode === 0 ? void 0 : String(output2.analytics?.code ?? metadata.code ?? output2.stderr.match(/^([a-z][a-z0-9-]+) —/u)?.[1] ?? "command-failed");
|
|
52073
|
+
rememberFeedbackCommand(state, session, siteUrl(env), { cliVersion, platform: platform4(), agent: session.agent, occurredAt: startedAt, invocation: { id: invocationId, command: parsed.invocation.key, exitCode: output2.exitCode, startedAt, finishedAt: (/* @__PURE__ */ new Date()).toISOString(), diagnostic, ...executionId ? { executionId } : {}, ...metadata.discovery_session_id ? { discoveryId: metadata.discovery_session_id } : {} } });
|
|
52074
|
+
if (output2.exitCode !== 0 && !["setup", "setupContinue"].includes(parsed.invocation.key)) {
|
|
52075
|
+
prepareFeedback(state);
|
|
52076
|
+
const inserted = state.db.prepare("INSERT OR IGNORE INTO feedback_hint VALUES (?,?,?)").run(session.id, feedbackOwner(state) ?? "unlinked", `${siteUrl(env)}:${parsed.invocation.key}:${diagnostic}`);
|
|
52077
|
+
if (inserted.changes) output2 = { ...output2, stderr: output2.stderr + `Report this issue once: ${commandPrefix(parsed.invocation.sessionLabel)} feedback report --from ${invocationId} --blocked "..." --repro "..." --expected "..." --actual "...". Use retained evidence; do not repeat a mutation.
|
|
52078
|
+
` };
|
|
52079
|
+
}
|
|
52080
|
+
} finally {
|
|
52081
|
+
state.close();
|
|
52082
|
+
}
|
|
52083
|
+
} catch {
|
|
52084
|
+
}
|
|
52085
|
+
}
|
|
51833
52086
|
const runPurpose = output2.analytics?.purpose === "discovery" || output2.analytics?.purpose === "verification" ? output2.analytics.purpose : void 0;
|
|
51834
52087
|
let printedOut = "", printedErr = "";
|
|
51835
52088
|
const exitCode = await finalizeOutput(output2, { stdout: (value) => {
|
|
@@ -51857,7 +52110,7 @@ ${apiError2.hint ? `${apiError2.hint}
|
|
|
51857
52110
|
const life = state.db.prepare("SELECT id FROM discovery_lifecycle WHERE session_id=? AND account_id=? AND finished_at IS NULL").get(session.id, state.installation()?.accountId ?? "");
|
|
51858
52111
|
metadata.discovery_session_id = life?.id;
|
|
51859
52112
|
}
|
|
51860
|
-
analytics.record("cli_command_finished", { ...metadata, ...output2.analytics, invocation_id: invocationId, execution_id: executionId, command: parsed.invocation.key, purpose: runPurpose ?? purposeFor(parsed.invocation.key), stage: output2.analytics?.stage ?? metadata.stage ?? (parsed.invocation.key === "run" ? "preflight" : purposeFor(parsed.invocation.key) === "unknown" ? "lookup" : purposeFor(parsed.invocation.key)), outcome: String(exitCode), exit_code: exitCode, duration_ms: duration3, agent: session?.agent, platform:
|
|
52113
|
+
analytics.record("cli_command_finished", { ...metadata, ...output2.analytics, invocation_id: invocationId, execution_id: executionId, command: parsed.invocation.key, purpose: runPurpose ?? purposeFor(parsed.invocation.key), stage: output2.analytics?.stage ?? metadata.stage ?? (parsed.invocation.key === "run" ? "preflight" : purposeFor(parsed.invocation.key) === "unknown" ? "lookup" : purposeFor(parsed.invocation.key)), outcome: String(exitCode), exit_code: exitCode, duration_ms: duration3, agent: session?.agent, platform: platform4(), started_at: startedAt, finished_at: (/* @__PURE__ */ new Date()).toISOString(), dispatched: ["run", "discoverTransportProbe"].includes(parsed.invocation.key) ? metadata.stage === "registry" ? false : !!output2.dispatched : void 0, ...exitCode !== output2.exitCode ? { code: "output-delivery-failed", stage: "output" } : {} }, { key: invocationId });
|
|
51861
52114
|
if (unexpected) analytics.record("client_exception", { code: "internal-error" });
|
|
51862
52115
|
if (exitCode === 0 && ["appsNew", "appsUpdate"].includes(parsed.invocation.key)) analytics.record("discovery_started", { purpose: "discovery", agent: session?.agent });
|
|
51863
52116
|
if (exitCode === 0 && parsed.invocation.key === "discoverClose") analytics.record("discovery_finished", { purpose: "discovery", outcome: "closed", duration_ms: duration3, agent: session?.agent });
|
|
@@ -51880,7 +52133,8 @@ var init_cli = __esm({
|
|
|
51880
52133
|
"src/cli.ts"() {
|
|
51881
52134
|
"use strict";
|
|
51882
52135
|
init_session_capture();
|
|
51883
|
-
|
|
52136
|
+
init_feedback_store();
|
|
52137
|
+
init_feedback2();
|
|
51884
52138
|
init_receipts();
|
|
51885
52139
|
init_lock();
|
|
51886
52140
|
init_drafts();
|