@adelin-io/cli 0.1.1 → 0.1.2
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/authoring-release.json +4 -4
- package/package.json +1 -1
- package/runtime-integrity.json +2 -2
- package/scripts/adelin.mjs +54 -10
- package/scripts/runtime.mjs +276 -80
- package/skill/authoring/local-workflow.md +20 -6
- package/skill/design/design-guide.md +3 -1
package/authoring-release.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@adelin-io/cli",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"compilerVersion": "6.0.3",
|
|
6
6
|
"hostProtocol": 1,
|
|
7
7
|
"files": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"skill/authoring/content-binding.md": "124090ebdd6011bdd7c5f9c94f715ab15ad2af7741fae90fc5d3e2c7a2f442a8",
|
|
18
18
|
"skill/authoring/i18n.md": "a264167e27b9ea02c76647146601ee0d1d9a83e9d33d7cd60d9d0b39d9ee1f60",
|
|
19
19
|
"skill/authoring/language.md": "c3c9b3db109b6164206a09ec1a55a47912beedb4ab150e06cdb97c110e966d71",
|
|
20
|
-
"skill/authoring/local-workflow.md": "
|
|
20
|
+
"skill/authoring/local-workflow.md": "6f0547dbe424f29ac63e47447938555976b3b68d17acb4b59c5bfca9669f624b",
|
|
21
21
|
"skill/authoring/offline/connectivity.md": "e00cb804cfdcda2950cb190432e8f36cd13d99b36075b5ceec71438671393e81",
|
|
22
22
|
"skill/authoring/offline/example.md": "2e79d91f05d7a55b4a3f136f0db28d02e458c9fc24b77ab0e074fff7ab635447",
|
|
23
23
|
"skill/authoring/offline/history-sync.md": "65652b536a84c47ddf04519e3dac35a9bed836fba67043fd43dabd77af3cd3ec",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"skill/design/approved/vesper-phone-home.jpg": "b514f036fa9d348ca93008c5e9645e0d3ccbaafe669694fed020ca5c6cf6fbcb",
|
|
45
45
|
"skill/design/approved/vesper-tv-detail.jpg": "7a909bb8710d9c648782a62feeb93b4f48badb14659cc9532785764116158f77",
|
|
46
46
|
"skill/design/approved/vesper-tv-home.jpg": "9e3368be141b6dce4aa803042ff832f5358ca344968a7ed104e47850e701ddf3",
|
|
47
|
-
"skill/design/design-guide.md": "
|
|
47
|
+
"skill/design/design-guide.md": "cc981df68755971801f826532c16d4aa15c1c3b0c09638d99dba1714c165302f",
|
|
48
48
|
"skill/design/edge-to-edge.md": "d163b0e3ae393377546508d7eab0d44cfab139d022a360e993a734c73394119e",
|
|
49
49
|
"skill/design/icons.md": "c3c6dfc57d2d346dac34ef6f876371943ed36e810730edc224196bc967da9248",
|
|
50
50
|
"skill/design/responsive-layout.md": "c83763be82e29ec16799256aa4a0d8e4570bce117b1a29d6d90ca3c98ccf7449",
|
|
@@ -170,5 +170,5 @@
|
|
|
170
170
|
"types/adelin-worklets.d.ts": "f56edc56715df189933f180605ee8c41a785d11ad0c0d454258f1c1f71159ab9",
|
|
171
171
|
"workspace-tsconfig.json": "a1321a0ea06e5fb9d4e3c1a7d92045e730b44114ab10553172142cb978b9147a"
|
|
172
172
|
},
|
|
173
|
-
"contractId": "
|
|
173
|
+
"contractId": "8f56f8f54c1f441c218acd7db57623287fe50853f8128c0556ec39b64a1af341"
|
|
174
174
|
}
|
package/package.json
CHANGED
package/runtime-integrity.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/adelin.mjs": "
|
|
2
|
+
"scripts/adelin.mjs": "df74e500250b78aa62372b558c86192c712afa66934d672fabc725699dd1a041",
|
|
3
3
|
"scripts/assemble-checkout.mjs": "3f35e00a76075b3b0e8c72b5477184a986b15ae1e933317ceaad9a08cbeb589c",
|
|
4
4
|
"scripts/local-save.mjs": "334aeca83827b44985dcd95fc609fdb58a85a6a66ef5cbbc02f593e6b1309d18",
|
|
5
5
|
"scripts/materialize.mjs": "c2c6313c49e43e413624314de3504afd3f46654e0e745523baf70c95c287e866",
|
|
6
|
-
"scripts/runtime.mjs": "
|
|
6
|
+
"scripts/runtime.mjs": "c866bf1a2f9ee4cb38ef2b6d4cf104ae29667a752ca5006ddc71e1386f03d1f5",
|
|
7
7
|
"scripts/typecheck.mjs": "2ed3b248bd1d8f8152cda2a57f8975da39028e5eb63a7475678af6fc5117042c",
|
|
8
8
|
"scripts/workspace-state.mjs": "f6dd0710797f61994dc8e235cf006f7923e90bb754e399aa99df1aa0caf8d350"
|
|
9
9
|
}
|
package/scripts/adelin.mjs
CHANGED
|
@@ -1497,6 +1497,7 @@ var fieldKeyValue, LIBRARY_MESSAGES, aliases, keyPattern, fail, flagged, str, ta
|
|
|
1497
1497
|
RECONSENT_REQUIRED: "Explicit approval required.",
|
|
1498
1498
|
APP_SELECTION_CHANGED: "App access changed. Start login again.",
|
|
1499
1499
|
INTERACTION_COMPLETED: "This approval has already been used.",
|
|
1500
|
+
TOOL_UNAVAILABLE: "This tool is not available for this connection. Run adelin login to sign in again.",
|
|
1500
1501
|
INVALID_CURSOR: "Invalid cursor.",
|
|
1501
1502
|
STALE_CURSOR: "Library changed. Restart pagination.",
|
|
1502
1503
|
READ_ITEM_TOO_LARGE: "Item exceeds read limits.",
|
|
@@ -1807,7 +1808,10 @@ var MAX_RESPONSE_BYTES, CliRemote, init_cli_remote = __esm({
|
|
|
1807
1808
|
}
|
|
1808
1809
|
if (!response2.ok) {
|
|
1809
1810
|
await response2.body?.cancel();
|
|
1810
|
-
let refused2 =
|
|
1811
|
+
let refused2 = Object.assign(
|
|
1812
|
+
libraryError({ 401: "AUTH_REQUIRED", 403: "ACCESS_DENIED", 409: "APP_SELECTION_CHANGED" }[response2.status] ?? "REMOTE_UNAVAILABLE"),
|
|
1813
|
+
{ status: response2.status }
|
|
1814
|
+
), retry = response2.headers.get("retry-after"), seconds = retry !== null && /^\d+(?:\.\d+)?$/.test(retry) ? Number(retry) : NaN, retryAfterMs = Number.isFinite(seconds) ? Math.ceil(seconds * 1e3) : retry ? Math.max(0, Date.parse(retry) - Date.now()) : NaN;
|
|
1811
1815
|
throw response2.status === 429 ? Object.assign(refused2, { rateLimited: !0, ...Number.isFinite(retryAfterMs) ? { retryAfterMs } : {} }) : refused2;
|
|
1812
1816
|
}
|
|
1813
1817
|
let continuation = response2.headers?.get("x-adelin-continuation");
|
|
@@ -1816,11 +1820,11 @@ var MAX_RESPONSE_BYTES, CliRemote, init_cli_remote = __esm({
|
|
|
1816
1820
|
this.continuation = continuation, this.onContinuation?.(continuation);
|
|
1817
1821
|
}
|
|
1818
1822
|
let value = await readResponse(response2);
|
|
1819
|
-
if (value?.error) throw libraryError(value.error.code
|
|
1823
|
+
if (value?.error) throw libraryError(value.error.code !== -32602 ? value.error.code : value.error.message === "Unknown tool" ? "TOOL_UNAVAILABLE" : "INVALID_ARGUMENT");
|
|
1820
1824
|
if (!value?.result) throw libraryError("INVALID_RESPONSE");
|
|
1821
1825
|
return value.result;
|
|
1822
1826
|
} catch (error) {
|
|
1823
|
-
throw error?.code === "UPDATE_REQUIRED" ? error : signal.aborted || error?.name === "TimeoutError" || error?.name === "AbortError" ? libraryError("REQUEST_TIMEOUT") : error?.code ? Object.assign(libraryError(error.code), error.rateLimited === !0 ? {
|
|
1827
|
+
throw error?.code === "UPDATE_REQUIRED" ? error : signal.aborted || error?.name === "TimeoutError" || error?.name === "AbortError" ? libraryError("REQUEST_TIMEOUT") : error?.code ? Object.assign(libraryError(error.code), error.status ? { status: error.status } : {}, error.rateLimited === !0 ? {
|
|
1824
1828
|
rateLimited: !0,
|
|
1825
1829
|
...Number.isFinite(error.retryAfterMs) ? { retryAfterMs: error.retryAfterMs } : {}
|
|
1826
1830
|
} : {}) : libraryError("REMOTE_UNAVAILABLE");
|
|
@@ -3677,7 +3681,22 @@ function stagingTarget(ticket, body) {
|
|
|
3677
3681
|
if (!(r2 || local) || target.username || target.password || target.hash || bucketEnv !== "prod" || !UUID11.test(ticket.jobId) || pathJobId !== ticket.jobId || Object.keys(headers).sort().join() !== TICKET_HEADERS || headers["content-length"] !== String(Buffer.byteLength(body)) || headers["if-none-match"] !== "*" || headers["x-amz-checksum-sha256"] !== createHash5("sha256").update(body).digest("base64") || !Number.isSafeInteger(ticket.expiresAt) || ticket.expiresAt <= Date.now()) throw new Error("Invalid staging upload.");
|
|
3678
3682
|
return target;
|
|
3679
3683
|
}
|
|
3680
|
-
|
|
3684
|
+
function cleanServerMessage(value) {
|
|
3685
|
+
return typeof value == "string" ? value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 500) : "";
|
|
3686
|
+
}
|
|
3687
|
+
async function rejection(response2, action) {
|
|
3688
|
+
let serverCode, serverMessage = "";
|
|
3689
|
+
try {
|
|
3690
|
+
let parsed = JSON.parse((await response2.text()).slice(0, 4096));
|
|
3691
|
+
typeof parsed?.error == "string" && SERVER_CODE.test(parsed.error) && (serverCode = parsed.error, serverMessage = cleanServerMessage(parsed.message));
|
|
3692
|
+
} catch {
|
|
3693
|
+
}
|
|
3694
|
+
return Object.assign(
|
|
3695
|
+
new Error(`Adelin rejected the local ${action} request (${response2.status}).`),
|
|
3696
|
+
{ status: response2.status, action, ...serverCode && { serverCode }, ...serverMessage && { serverMessage } }
|
|
3697
|
+
);
|
|
3698
|
+
}
|
|
3699
|
+
var ACTION, MAX_DEVICE_BYTES, UUID11, STAGING_PATH, R2_HOST, TICKET_HEADERS, SERVER_CODE, LocalBuildTransport, init_local_build_transport = __esm({
|
|
3681
3700
|
"skills/adelin-app-generation/scripts/local-build-transport.mjs"() {
|
|
3682
3701
|
init_cli_server();
|
|
3683
3702
|
ACTION = Object.freeze({
|
|
@@ -3698,6 +3717,7 @@ var ACTION, MAX_DEVICE_BYTES, UUID11, STAGING_PATH, R2_HOST, TICKET_HEADERS, Loc
|
|
|
3698
3717
|
handover_edit_session: "handover"
|
|
3699
3718
|
}), MAX_DEVICE_BYTES = 3 * 1024 * 1024;
|
|
3700
3719
|
UUID11 = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/, STAGING_PATH = /^\/adelin-(prod|dev)-compiler-staging\/[A-Za-z0-9-]{1,64}\/([a-f0-9-]{36})\/source\.json$/, R2_HOST = /^[a-f0-9]{32}\.r2\.cloudflarestorage\.com$/, TICKET_HEADERS = "content-length,if-none-match,x-amz-checksum-sha256";
|
|
3720
|
+
SERVER_CODE = /^[A-Z][A-Z0-9_]{2,63}$/;
|
|
3701
3721
|
LocalBuildTransport = class {
|
|
3702
3722
|
constructor(mcpUrl, fetcher = fetch, { release = null } = {}) {
|
|
3703
3723
|
this.url = new URL(validateMcpUrl(mcpUrl)), this.fetcher = fetcher, this.privateKey = null, this.publicKey = null, this.token = null, this.tuple = null, this.expiresAt = 0, this.release = release, this.continuation = null;
|
|
@@ -3780,7 +3800,7 @@ ${digest3}`), signature = sign2(null, bytes, this.privateKey).toString("base64ur
|
|
|
3780
3800
|
}), refusal3 = response2.status === 400 && (action === "ask" || action === "choose");
|
|
3781
3801
|
if (response2.status === 426)
|
|
3782
3802
|
throw await response2.body?.cancel(), Object.assign(new Error("Adelin authoring needs an update. Run adelin setup."), { code: "UPDATE_REQUIRED" });
|
|
3783
|
-
if (!response2.ok && !refusal3) throw
|
|
3803
|
+
if (!response2.ok && !refusal3) throw await rejection(response2, action);
|
|
3784
3804
|
let continuation = response2.headers?.get("x-adelin-continuation");
|
|
3785
3805
|
if (continuation) {
|
|
3786
3806
|
if (continuation.length > 16384 || !/^[A-Za-z0-9_.-]+$/.test(continuation)) throw new Error("Invalid build continuation.");
|
|
@@ -3854,7 +3874,19 @@ async function createMcpHost({
|
|
|
3854
3874
|
if (candidate2.manifest.hostProtocol !== HOST_PROTOCOL) throw incompatible();
|
|
3855
3875
|
let runtimeModule = await loadRuntime(candidate2);
|
|
3856
3876
|
if (runtimeModule.HOST_PROTOCOL !== HOST_PROTOCOL || typeof runtimeModule.createRuntime != "function") throw incompatible();
|
|
3857
|
-
let runtime2 = runtimeModule.createRuntime(remote, transport, {
|
|
3877
|
+
let runtime2 = runtimeModule.createRuntime(remote, transport, {
|
|
3878
|
+
...runtimeOptions,
|
|
3879
|
+
hostState,
|
|
3880
|
+
project,
|
|
3881
|
+
release: candidate2,
|
|
3882
|
+
onToolsChanged: () => {
|
|
3883
|
+
try {
|
|
3884
|
+
server.sendToolListChanged().catch(() => {
|
|
3885
|
+
});
|
|
3886
|
+
} catch {
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
});
|
|
3858
3890
|
if (["callTool", "listTools", "prepareHandover", "pause", "resume", "close"].some((name) => typeof runtime2?.[name] != "function"))
|
|
3859
3891
|
throw incompatible();
|
|
3860
3892
|
return { runtimeModule, runtime: runtime2 };
|
|
@@ -3940,7 +3972,7 @@ async function createMcpHost({
|
|
|
3940
3972
|
return response({ error: "GENERATION_CONTEXT_UNAVAILABLE", message: "Adelin could not read the current guidance or the project instructions." }, !0);
|
|
3941
3973
|
}
|
|
3942
3974
|
}
|
|
3943
|
-
if (!CONTINUATIONS.has(name)) {
|
|
3975
|
+
if (!CONTINUATIONS.has(name) && name !== "connection_status") {
|
|
3944
3976
|
if (blocked) return withNotice(refused(blocked));
|
|
3945
3977
|
if (generation !== current.manifest.contractId) return withNotice(refused("GENERATION_CONTEXT_CHANGED"));
|
|
3946
3978
|
if (!current.source)
|
|
@@ -4484,7 +4516,8 @@ function setup({
|
|
|
4484
4516
|
skillPaths: skills.map((skill) => skill.path),
|
|
4485
4517
|
mcpUrl,
|
|
4486
4518
|
workspaces,
|
|
4487
|
-
signIn: "Run adelin login."
|
|
4519
|
+
signIn: "Run adelin login.",
|
|
4520
|
+
restart: configurations.some((plan) => plan.next !== plan.before)
|
|
4488
4521
|
};
|
|
4489
4522
|
}
|
|
4490
4523
|
|
|
@@ -7677,6 +7710,7 @@ async function main(args = process.argv.slice(2), context = {}) {
|
|
|
7677
7710
|
cliPath: release.launcher ?? fileURLToPath4(import.meta.url)
|
|
7678
7711
|
});
|
|
7679
7712
|
process.stdout.write(`Adelin setup updated in ${installed.project}.
|
|
7713
|
+
`), installed.restart && process.stdout.write(`Restart your coding client so it loads the Adelin connection.
|
|
7680
7714
|
`);
|
|
7681
7715
|
for (let workspace of installed.workspaces)
|
|
7682
7716
|
workspace.status === "blocked" ? (process.stderr.write(`${workspace.workspace}: ${workspace.message}
|
|
@@ -7720,7 +7754,18 @@ ${value}
|
|
|
7720
7754
|
`);
|
|
7721
7755
|
return;
|
|
7722
7756
|
}
|
|
7723
|
-
await remoteFor(auth).call("connection_status", {}),
|
|
7757
|
+
let reply = await remoteFor(auth).call("connection_status", {}), scope = "";
|
|
7758
|
+
try {
|
|
7759
|
+
let { allApps } = JSON.parse(reply.content[0].text);
|
|
7760
|
+
typeof allApps == "boolean" && (scope = allApps ? " Access: all apps." : " Access: selected apps.");
|
|
7761
|
+
} catch {
|
|
7762
|
+
}
|
|
7763
|
+
let ready = !1;
|
|
7764
|
+
try {
|
|
7765
|
+
ready = inspectProjectSetup(flags.project ?? process.cwd(), release).status === "current";
|
|
7766
|
+
} catch {
|
|
7767
|
+
}
|
|
7768
|
+
process.stdout.write((ready ? "Connected to Adelin. Project setup is current." : "Connected to Adelin, but this project is not set up. Run adelin setup in this project or worktree.") + scope + `
|
|
7724
7769
|
`);
|
|
7725
7770
|
return;
|
|
7726
7771
|
}
|
|
@@ -7741,7 +7786,6 @@ ${value}
|
|
|
7741
7786
|
return;
|
|
7742
7787
|
}
|
|
7743
7788
|
if (command === "mcp") {
|
|
7744
|
-
await auth.accessToken();
|
|
7745
7789
|
let { createMcpHost: createMcpHost2 } = await Promise.resolve().then(() => (init_cli_mcp_host(), cli_mcp_host_exports));
|
|
7746
7790
|
await serveMcp(await createMcpHost2({ release, updater, auth, mcpUrl: url, initialNotice: context.updateNotice }));
|
|
7747
7791
|
return;
|
package/scripts/runtime.mjs
CHANGED
|
@@ -1830,8 +1830,8 @@ function createAgentViewPublisher(host, options2) {
|
|
|
1830
1830
|
async function onFrame(gen, data, viewportWidth, viewportHeight) {
|
|
1831
1831
|
if (gen !== generation) return;
|
|
1832
1832
|
latest = data;
|
|
1833
|
-
let
|
|
1834
|
-
if (
|
|
1833
|
+
let wait3 = Math.max(0, lastSent + 1e3 / fpsCap - Date.now());
|
|
1834
|
+
if (wait3 && await delay2(wait3), gen !== generation || latest !== data) return;
|
|
1835
1835
|
lastSent = Date.now();
|
|
1836
1836
|
let size = jpegSize2(data);
|
|
1837
1837
|
if (!size) return;
|
|
@@ -2837,7 +2837,7 @@ var init_src = __esm({
|
|
|
2837
2837
|
});
|
|
2838
2838
|
|
|
2839
2839
|
// skills/adelin-app-generation/scripts/local-builder.mjs
|
|
2840
|
-
import { randomBytes as randomBytes7 } from "node:crypto";
|
|
2840
|
+
import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
|
|
2841
2841
|
import { mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync5, realpathSync as realpathSync6, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
2842
2842
|
import { tmpdir } from "node:os";
|
|
2843
2843
|
import { dirname as dirname8, isAbsolute as isAbsolute4, join as join11, relative as relative3, resolve as resolve11, sep as sep3 } from "node:path";
|
|
@@ -2909,10 +2909,10 @@ var LocalBuildSession = class {
|
|
|
2909
2909
|
now = () => Date.now(),
|
|
2910
2910
|
idleMs = IDLE_MS,
|
|
2911
2911
|
fingerprint = workspaceFingerprint,
|
|
2912
|
-
wait:
|
|
2912
|
+
wait: wait3 = sleep,
|
|
2913
2913
|
choiceWaitMs = CHOICE_WAIT_MS
|
|
2914
2914
|
} = {}) {
|
|
2915
|
-
this.remote = remote2, this.wait =
|
|
2915
|
+
this.remote = remote2, this.wait = wait3, this.choiceWaitMs = choiceWaitMs, this.now = now, this.idleMs = idleMs, this.fingerprint = fingerprint, this.session = null, this.pending = null, this.busy = !1, this.renewing = !1, this.state = "closed";
|
|
2916
2916
|
}
|
|
2917
2917
|
async call(name, args) {
|
|
2918
2918
|
return toolValue(await this.remote.call(name, args), name === "device_operation" ? 3 * 1024 * 1024 : void 0);
|
|
@@ -3297,6 +3297,12 @@ function settle(root, appId, pending) {
|
|
|
3297
3297
|
throw new Error("Workspace support changed during refresh.");
|
|
3298
3298
|
manifest.text !== nextManifest && overwrite(root, manifest.path, nextManifest, manifest.text), currentContract !== desired.contractId && overwrite(root, contract.path, json({ schema: 1, appId, contractId: desired.contractId }), contract.text), optionalText(pending.path, MAX_BUNDLE_BYTES * 2) === pending.text && unlinkSync(pending.path);
|
|
3299
3299
|
}
|
|
3300
|
+
function inspectWorkspaceSupport(workspace, appId, release2) {
|
|
3301
|
+
let root = workspaceRoot(workspace), manifest = manifestAt(root, appId).value, contract = contractAt(root, appId).value, desired = desiredSupport(release2, appId);
|
|
3302
|
+
if (guardWorkspace(root), readJournal(root, appId)) return { status: "stale", message: "A workspace support refresh is pending." };
|
|
3303
|
+
let blocked = conflicts(root, manifest.support, desired.stamps);
|
|
3304
|
+
return blocked.length ? { status: "blocked", message: `Workspace support conflict at ${blocked.join(", ")}.` } : { status: contract?.contractId === desired.contractId && same(manifest.support, desired.stamps) ? "current" : "stale", contractId: contract?.contractId ?? null };
|
|
3305
|
+
}
|
|
3300
3306
|
function claimPath(root, pending, order, kind2) {
|
|
3301
3307
|
return stateFile(root, `.adelin-support-${pending.journal.id}-${order}.${kind2}`);
|
|
3302
3308
|
}
|
|
@@ -3376,8 +3382,7 @@ function syncWorkspaceSupportLocked(workspace, appId, release2) {
|
|
|
3376
3382
|
}
|
|
3377
3383
|
|
|
3378
3384
|
// skills/adelin-app-generation/scripts/cli-project.mjs
|
|
3379
|
-
var CLIENTS = ["codex", "claude", "opencode"], SETUP_FILE = ".adelin/project-setup.json"
|
|
3380
|
-
var json2 = (value) => JSON.stringify(value, null, 2) + `
|
|
3385
|
+
var CLIENTS = ["codex", "claude", "opencode"], SETUP_FILE = ".adelin/project-setup.json", CODEX_BEGIN = "# BEGIN ADELIN MCP SETUP", CODEX_END = "# END ADELIN MCP SETUP", CODEX_CONFIG = ".codex/config.toml", CLAUDE_CONFIG = ".mcp.json", OPENCODE_CONFIGS = ["opencode.jsonc", "opencode.json"], production = () => !0, buildMode = () => production() ? "production" : "development", same2 = (a, b) => JSON.stringify(a) === JSON.stringify(b), json2 = (value) => JSON.stringify(value, null, 2) + `
|
|
3381
3386
|
`, record2 = (value) => value && typeof value == "object" && !Array.isArray(value);
|
|
3382
3387
|
function optionalFile(path, maxBytes) {
|
|
3383
3388
|
return assertNoSymlinkAncestors2(path), lstatIfPresent2(path) ? readSafeFile3(path, maxBytes).toString("utf8") : null;
|
|
@@ -3450,6 +3455,28 @@ function loadProjectRegistration(root) {
|
|
|
3450
3455
|
}
|
|
3451
3456
|
return { path, before, data: data?.project === root ? data : empty };
|
|
3452
3457
|
}
|
|
3458
|
+
function clientConfigFile(root, client) {
|
|
3459
|
+
return client === "codex" ? CODEX_CONFIG : client === "claude" ? CLAUDE_CONFIG : OPENCODE_CONFIGS.find((path) => lstatIfPresent2(join3(root, path))) ?? OPENCODE_CONFIGS.at(-1);
|
|
3460
|
+
}
|
|
3461
|
+
function codexBlock(fields2) {
|
|
3462
|
+
return `${CODEX_BEGIN}
|
|
3463
|
+
[mcp_servers.adelin]
|
|
3464
|
+
command = ${JSON.stringify(fields2.command)}
|
|
3465
|
+
args = ${JSON.stringify(fields2.args)}
|
|
3466
|
+
${CODEX_END}
|
|
3467
|
+
`;
|
|
3468
|
+
}
|
|
3469
|
+
function clientIsCurrent(root, client, registered) {
|
|
3470
|
+
let file = clientConfigFile(root, client);
|
|
3471
|
+
if (file !== registered?.file || !record2(registered.fields)) return !1;
|
|
3472
|
+
let text4 = optionalFile(join3(root, file));
|
|
3473
|
+
if (text4 === null) return !1;
|
|
3474
|
+
if (client === "codex") return text4.includes(codexBlock(registered.fields));
|
|
3475
|
+
let errors = [], config = parse(text4, errors, { allowTrailingComma: !0 });
|
|
3476
|
+
if (errors.length || !record2(config)) return !1;
|
|
3477
|
+
let existing = client === "claude" ? config.mcpServers?.adelin : (record2(config.mcp?.servers) ? config.mcp.servers : config.mcp)?.adelin;
|
|
3478
|
+
return existing?.type !== (client === "claude" ? "stdio" : "local") ? !1 : same2(existing.command, registered.fields.command) && (client !== "claude" || same2(existing.args, registered.fields.args));
|
|
3479
|
+
}
|
|
3453
3480
|
function assertWorkspaceWorktree(project, workspace) {
|
|
3454
3481
|
let root = projectRoot(project), target2 = resolve3(workspace);
|
|
3455
3482
|
if (!within(root, target2)) throw new Error("Workspace is outside the registered project.");
|
|
@@ -3467,12 +3494,53 @@ function workspaceIn(root, input) {
|
|
|
3467
3494
|
throw new Error("Workspace is not a physical directory in this project.");
|
|
3468
3495
|
return input;
|
|
3469
3496
|
}
|
|
3497
|
+
function knownWorkspaces(root) {
|
|
3498
|
+
let { data } = loadProjectRegistration(root), entries2 = { ...data.workspaces }, rootManifest = optionalFile(join3(root, MANIFEST3));
|
|
3499
|
+
if (rootManifest !== null && !Object.hasOwn(entries2, root))
|
|
3500
|
+
try {
|
|
3501
|
+
let appId = loadJson(rootManifest, "workspace manifest")?.appId;
|
|
3502
|
+
parseManifest3(rootManifest, appId), entries2[root] = appId;
|
|
3503
|
+
} catch (error) {
|
|
3504
|
+
return [{ workspace: root, status: "blocked", message: error.message }, ...Object.entries(entries2).map(([workspace, appId]) => checkedWorkspace(root, workspace, appId))];
|
|
3505
|
+
}
|
|
3506
|
+
return Object.entries(entries2).map(([workspace, appId]) => checkedWorkspace(root, workspace, appId));
|
|
3507
|
+
}
|
|
3508
|
+
function checkedWorkspace(root, workspace, appId) {
|
|
3509
|
+
try {
|
|
3510
|
+
if (!UUID2.test(appId)) throw new Error("Invalid registered app identity.");
|
|
3511
|
+
return { workspace: workspaceIn(root, workspace), appId };
|
|
3512
|
+
} catch (error) {
|
|
3513
|
+
return { workspace, appId, status: "blocked", message: error.message };
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3470
3516
|
function registerWorkspace(project, workspace, appId) {
|
|
3471
3517
|
let root = projectRoot(project), path = workspaceIn(root, resolve3(workspace));
|
|
3472
3518
|
parseManifest3(readSafeFile3(join3(path, MANIFEST3)), appId), ignoreSetupArtifacts(root, gitProject(root), [join3(path, ".adelin-operations")]);
|
|
3473
3519
|
let { path: registry, before, data } = loadProjectRegistration(root);
|
|
3474
3520
|
return data.workspaces[path] !== appId && (data.workspaces[path] = appId, atomicText(registry, json2(data), before)), { workspace: path, appId };
|
|
3475
3521
|
}
|
|
3522
|
+
function skillRelativePath(client) {
|
|
3523
|
+
return join3(client === "claude" ? ".claude" : ".agents", "skills", "adelin-app-generation");
|
|
3524
|
+
}
|
|
3525
|
+
function inspectProjectSetup(project, release2) {
|
|
3526
|
+
let root = projectRoot(project), { data } = loadProjectRegistration(root), connection = data.connections[buildMode()], clients = Object.keys(connection?.clients ?? {}), workspaces = knownWorkspaces(root).map((entry) => {
|
|
3527
|
+
if (entry.status || !release2) return entry;
|
|
3528
|
+
try {
|
|
3529
|
+
return { ...entry, ...inspectWorkspaceSupport(entry.workspace, entry.appId, release2) };
|
|
3530
|
+
} catch (error) {
|
|
3531
|
+
return { ...entry, status: "blocked", message: error.message };
|
|
3532
|
+
}
|
|
3533
|
+
}), configurationCurrent = clients.length > 0;
|
|
3534
|
+
for (let client of clients)
|
|
3535
|
+
try {
|
|
3536
|
+
let path = skillRelativePath(client), target2 = connection.skills[path], link = join3(root, path);
|
|
3537
|
+
assertNoSymlinkAncestors2(dirname(link)), (!lstatIfPresent2(link)?.isSymbolicLink() || resolve3(dirname(link), readlinkSync(link)) !== target2 || realpathSync(link) !== realpathSync(release2?.skillRoot ?? target2) || !clientIsCurrent(root, client, connection.clients[client])) && (configurationCurrent = !1);
|
|
3538
|
+
} catch {
|
|
3539
|
+
configurationCurrent = !1;
|
|
3540
|
+
}
|
|
3541
|
+
let supportCurrent = !release2 || connection?.contractId === release2.manifest.contractId && workspaces.every((entry) => entry.status === "current");
|
|
3542
|
+
return { status: clients.length ? configurationCurrent && supportCurrent ? "current" : "stale" : "unregistered", configurationCurrent, project: root, clients, workspaces, mcpUrl: connection?.mcpUrl };
|
|
3543
|
+
}
|
|
3476
3544
|
function ignoreSetupArtifacts(root, repository, paths) {
|
|
3477
3545
|
if (!repository) return;
|
|
3478
3546
|
let path = resolve3(root, git(root, ["rev-parse", "--git-path", "info/exclude"]).trimEnd());
|
|
@@ -3491,7 +3559,8 @@ import { typecheck } from "./typecheck.mjs";
|
|
|
3491
3559
|
|
|
3492
3560
|
// skills/adelin-app-generation/scripts/__generated__/library-localized-rules.mjs
|
|
3493
3561
|
var LANGUAGE_TAG_PATTERN = /^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/;
|
|
3494
|
-
var MAX_LOCALIZED_KEYS = 32, MAX_APP_LANGUAGES = 20
|
|
3562
|
+
var MAX_LOCALIZED_KEYS = 32, MAX_APP_LANGUAGES = 20;
|
|
3563
|
+
var CONTROL_RE = /[\u0000-\u001f\u007f]/;
|
|
3495
3564
|
function plainObject(value) {
|
|
3496
3565
|
return typeof value == "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
3497
3566
|
}
|
|
@@ -3605,6 +3674,7 @@ var fieldKeyValue = (v) => {
|
|
|
3605
3674
|
RECONSENT_REQUIRED: "Explicit approval required.",
|
|
3606
3675
|
APP_SELECTION_CHANGED: "App access changed. Start login again.",
|
|
3607
3676
|
INTERACTION_COMPLETED: "This approval has already been used.",
|
|
3677
|
+
TOOL_UNAVAILABLE: "This tool is not available for this connection. Run adelin login to sign in again.",
|
|
3608
3678
|
INVALID_CURSOR: "Invalid cursor.",
|
|
3609
3679
|
STALE_CURSOR: "Library changed. Restart pagination.",
|
|
3610
3680
|
READ_ITEM_TOO_LARGE: "Item exceeds read limits.",
|
|
@@ -4655,7 +4725,7 @@ function normalizeLibraryArgs(operation, args) {
|
|
|
4655
4725
|
return result;
|
|
4656
4726
|
}
|
|
4657
4727
|
async function advanceSampleImportLoop({ call, now = Date.now, sleep: sleep2 = (ms) => new Promise((done) => setTimeout(done, ms)) }, args) {
|
|
4658
|
-
let { app_id, import_id, max_steps, wait_seconds } = normalizeSampleImport("advance", args), deadline = now() + wait_seconds * 1e3, refresh = { operation: "library tree" }, current = null, steps = 0, mediaFailures = 0, finish = (stopReason, failure) => ({ import: current, steps, ...stopReason ? { stopReason } : {}, refresh, ...failure ? { error: failure.error } : {} }),
|
|
4728
|
+
let { app_id, import_id, max_steps, wait_seconds } = normalizeSampleImport("advance", args), deadline = now() + wait_seconds * 1e3, refresh = { operation: "library tree" }, current = null, steps = 0, mediaFailures = 0, finish = (stopReason, failure) => ({ import: current, steps, ...stopReason ? { stopReason } : {}, refresh, ...failure ? { error: failure.error } : {} }), wait3 = async (ms) => steps >= max_steps || !Number.isFinite(ms) || ms < 0 || now() + ms > deadline ? !1 : (await sleep2(ms), now() <= deadline);
|
|
4659
4729
|
for (; steps < max_steps; ) {
|
|
4660
4730
|
steps++;
|
|
4661
4731
|
let reply, hint = 1e3;
|
|
@@ -4673,13 +4743,13 @@ async function advanceSampleImportLoop({ call, now = Date.now, sleep: sleep2 = (
|
|
|
4673
4743
|
if (steps >= max_steps) return finish("budget", reply);
|
|
4674
4744
|
continue;
|
|
4675
4745
|
}
|
|
4676
|
-
if (mediaFailures = 0, ["RETRYABLE_CONFLICT", "MUTATION_UNAVAILABLE"].includes(code) && await
|
|
4746
|
+
if (mediaFailures = 0, ["RETRYABLE_CONFLICT", "MUTATION_UNAVAILABLE"].includes(code) && await wait3(hint)) continue;
|
|
4677
4747
|
return finish(null, reply);
|
|
4678
4748
|
}
|
|
4679
4749
|
if (mediaFailures = 0, current = reply.data, current.next === "none") return finish("complete");
|
|
4680
4750
|
if (current.next === "blocked") return finish("blocked", libraryFailure("SAMPLE_IMPORT_BLOCKED"));
|
|
4681
4751
|
if (!current.progressed && current.busyUntil) {
|
|
4682
|
-
if (await
|
|
4752
|
+
if (await wait3(Math.max(0, Date.parse(current.busyUntil) - now()))) continue;
|
|
4683
4753
|
return finish("busy");
|
|
4684
4754
|
}
|
|
4685
4755
|
if (!current.progressed) return finish("no_progress");
|
|
@@ -5643,11 +5713,11 @@ function decodeMedia(result, operation, input) {
|
|
|
5643
5713
|
return mediaFailure("INVALID_RESPONSE");
|
|
5644
5714
|
}
|
|
5645
5715
|
}
|
|
5646
|
-
function statusReceipt(decoded,
|
|
5716
|
+
function statusReceipt(decoded, wait3) {
|
|
5647
5717
|
let { id: id11, name, kind: kind2, status: status2, stage, failureReason, retranscodeFailureReason, canRetranscode, original, playable, snapshot } = decoded.data.asset;
|
|
5648
5718
|
return { ok: !0, operation: "status", appId: decoded.appId, data: {
|
|
5649
5719
|
asset: { id: id11, name, kind: kind2, status: status2, stage, failureReason, retranscodeFailureReason, canRetranscode, original, playable, snapshot },
|
|
5650
|
-
wait: { seconds:
|
|
5720
|
+
wait: { seconds: wait3.seconds, waitedSeconds: wait3.waitedSeconds, polls: wait3.polls, changed: wait3.changed, timedOut: wait3.timedOut, from: wait3.from, lastError: wait3.lastError }
|
|
5651
5721
|
} };
|
|
5652
5722
|
}
|
|
5653
5723
|
var MUTATION_SIMPLE = [
|
|
@@ -5672,7 +5742,7 @@ var MUTATION_SIMPLE = [
|
|
|
5672
5742
|
"MEDIA_ENTITLEMENT_DENIED",
|
|
5673
5743
|
"MEDIA_ORGANIZATION_NOT_FOUND",
|
|
5674
5744
|
"MEDIA_ORGANIZATION_PLAN_UNAVAILABLE"
|
|
5675
|
-
], PREVIEW_STATUSES = ["created", ...UPLOAD_STATUSES], OUTCOMES = ["trashed", "cancelling", "deleting"], keys = (value, required, optional = []) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype || required.some((key4) => !Object.hasOwn(value, key4)) || Object.keys(value).some((key4) => !required.includes(key4) && !optional.includes(key4))) && fail3(), value), chars = (max) => (value) => ((typeof value != "string" || [...value].length > max || /[\u0000-\u001f\u007f]/.test(value)) && fail3(), value), httpStatus = (value) => ((!Number.isSafeInteger(value) || value < 400 || value > 599) && fail3(), value), iso = (value) => new Date(instant(value)).toISOString(),
|
|
5745
|
+
], PREVIEW_STATUSES = ["created", ...UPLOAD_STATUSES], OUTCOMES = ["trashed", "cancelling", "deleting"], keys = (value, required, optional = []) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype || required.some((key4) => !Object.hasOwn(value, key4)) || Object.keys(value).some((key4) => !required.includes(key4) && !optional.includes(key4))) && fail3(), value), chars = (max) => (value) => ((typeof value != "string" || [...value].length > max || /[\u0000-\u001f\u007f]/.test(value)) && fail3(), value), httpStatus = (value) => ((!Number.isSafeInteger(value) || value < 400 || value > 599) && fail3(), value), iso = (value) => new Date(instant(value)).toISOString(), same3 = (value, expected) => (value !== expected && fail3(), value), replayed = (value) => {
|
|
5676
5746
|
value.replayed !== void 0 && value.replayed !== !0 && fail3();
|
|
5677
5747
|
}, PROFILE_STATES = {
|
|
5678
5748
|
"profile.create": ["created"],
|
|
@@ -5683,7 +5753,7 @@ var MUTATION_SIMPLE = [
|
|
|
5683
5753
|
}, PROFILE_CODES = ["MEDIA_PROFILE_INVALID", "MEDIA_PROFILE_NAME_TAKEN", "MEDIA_PROFILE_LAST", "MEDIA_PROFILE_NOT_FOUND"], PROFILE_CONFLICT = "The profiles changed since they were read. Use profilesRevision, or read them again.", isProfileAction = (action) => Object.hasOwn(PROFILE_STATES, action), skippedRows = (value) => {
|
|
5684
5754
|
let rows = array2(shape({ uploadId: id5, error: oneOf2(["NOT_FOUND", "MEDIA_ORIGINAL_BUSY", "MEDIA_ORIGINAL_GONE"]) }), 100)(value);
|
|
5685
5755
|
return unique(rows, "uploadId"), rows;
|
|
5686
|
-
}, ROW_ERRORS = ["MEDIA_ASSET_NOT_FOUND", "MEDIA_ORIGINAL_BUSY", "MEDIA_ORIGINAL_GONE", "MEDIA_ORIGINAL_EFFECT_CHANGED", "MEDIA_ORIGINAL_DELETE_FAILED"], resultRow = (value) => value?.ok === !0 ? (Object.hasOwn(value, "restorableUntil") ? shape({ uploadId: id5, ok: boolean2, effect: oneOf2(EFFECTS), restorableUntil: iso }) : shape({ uploadId: id5, ok: boolean2, effect: (v) =>
|
|
5756
|
+
}, ROW_ERRORS = ["MEDIA_ASSET_NOT_FOUND", "MEDIA_ORIGINAL_BUSY", "MEDIA_ORIGINAL_GONE", "MEDIA_ORIGINAL_EFFECT_CHANGED", "MEDIA_ORIGINAL_DELETE_FAILED"], resultRow = (value) => value?.ok === !0 ? (Object.hasOwn(value, "restorableUntil") ? shape({ uploadId: id5, ok: boolean2, effect: oneOf2(EFFECTS), restorableUntil: iso }) : shape({ uploadId: id5, ok: boolean2, effect: (v) => same3(v, "whole_upload") }))(value) : shape({ uploadId: id5, ok: (v) => same3(v, !1), error: oneOf2(ROW_ERRORS) })(value), hasPreviewId = (request) => typeof request.payload?.preview_id == "string";
|
|
5687
5757
|
function coversRequest(rows, request) {
|
|
5688
5758
|
let listed = rows.map((row) => row.uploadId), asked = request.payload.asset_ids;
|
|
5689
5759
|
(new Set(listed).size !== listed.length || listed.length !== asked.length || listed.some((uploadId) => !asked.includes(uploadId))) && fail3();
|
|
@@ -5704,9 +5774,9 @@ function mutationRefusal(value, request) {
|
|
|
5704
5774
|
return mediaFailure(code, field2 ? `${field2}: refused by Adelin` : void 0);
|
|
5705
5775
|
}
|
|
5706
5776
|
if (code === "CONFLICT" && isProfileAction(request.action))
|
|
5707
|
-
return keys(value, ["ok", "error", "operationId", "profilesRevision"]),
|
|
5777
|
+
return keys(value, ["ok", "error", "operationId", "profilesRevision"]), same3(value.operationId, request.operation_id), mutationFailure(code, { message: PROFILE_CONFLICT, profilesRevision: digest(value.profilesRevision) });
|
|
5708
5778
|
if (code === "CONFLICT") {
|
|
5709
|
-
keys(value, ["ok", "error", "operationId", "latestState"]),
|
|
5779
|
+
keys(value, ["ok", "error", "operationId", "latestState"]), same3(value.operationId, request.operation_id);
|
|
5710
5780
|
let latestState = shape({ id: id5, status: oneOf2([...PREVIEW_STATUSES, "removing", "removed"]), name: chars(200), snapshot: digest })(value.latestState);
|
|
5711
5781
|
return mutationFailure(code, { latestState });
|
|
5712
5782
|
}
|
|
@@ -5740,7 +5810,7 @@ function mutationRefusal(value, request) {
|
|
|
5740
5810
|
return MUTATION_SIMPLE.includes(code) ? (keys(value, ["ok", "error"]), mutationFailure(code)) : fail3();
|
|
5741
5811
|
}
|
|
5742
5812
|
function mediaPreview(value, request) {
|
|
5743
|
-
keys(value, ["ok", "previewId", "mutationRevision", "items", "nextCursor", "digest", "acknowledgement"]), id5(value.previewId), digest(value.digest), digest(value.acknowledgement),
|
|
5813
|
+
keys(value, ["ok", "previewId", "mutationRevision", "items", "nextCursor", "digest", "acknowledgement"]), id5(value.previewId), digest(value.digest), digest(value.acknowledgement), same3(value.nextCursor, null), (typeof value.mutationRevision != "string" || !/^(0|[1-9][0-9]{0,18})$/.test(value.mutationRevision) || !Array.isArray(value.items) || value.items.length !== 1) && fail3();
|
|
5744
5814
|
let item = shape({
|
|
5745
5815
|
type: oneOf2(["asset"]),
|
|
5746
5816
|
id: id5,
|
|
@@ -5749,9 +5819,9 @@ function mediaPreview(value, request) {
|
|
|
5749
5819
|
kind: maybe2(oneOf2(["video", "audio"])),
|
|
5750
5820
|
status: oneOf2(PREVIEW_STATUSES),
|
|
5751
5821
|
outcome: oneOf2(OUTCOMES),
|
|
5752
|
-
usedInCount: (value2) =>
|
|
5822
|
+
usedInCount: (value2) => same3(value2, 0)
|
|
5753
5823
|
})(value.items[0]);
|
|
5754
|
-
request.action === "asset.delete" ?
|
|
5824
|
+
request.action === "asset.delete" ? same3(item.id, request.payload.asset_id) : same3(value.previewId, request.preview_id);
|
|
5755
5825
|
let { ok, ...data } = value;
|
|
5756
5826
|
return { ...data, confirmation: { preview_id: value.previewId, digest: value.digest, acknowledgement: value.acknowledgement } };
|
|
5757
5827
|
}
|
|
@@ -5760,13 +5830,13 @@ var RECEIPTS = {
|
|
|
5760
5830
|
keys(value, ["ok", "operationId", "state", "assetId", "name", "snapshot"], ["replayed"]), oneOf2(["renamed", "unchanged"])(value.state), chars(200)(value.name), digest(value.snapshot);
|
|
5761
5831
|
},
|
|
5762
5832
|
"asset.delete": (value) => {
|
|
5763
|
-
keys(value, ["ok", "operationId", "state", "assetId", "outcome"], ["replayed", "restorableUntil"]),
|
|
5833
|
+
keys(value, ["ok", "operationId", "state", "assetId", "outcome"], ["replayed", "restorableUntil"]), same3(value.state, "completed"), oneOf2(OUTCOMES)(value.outcome), value.outcome === "trashed" !== Object.hasOwn(value, "restorableUntil") && fail3(), value.outcome === "trashed" && (value.restorableUntil = iso(value.restorableUntil));
|
|
5764
5834
|
},
|
|
5765
5835
|
"asset.restore": (value) => {
|
|
5766
|
-
keys(value, ["ok", "operationId", "state", "assetId", "effect"], ["replayed"]),
|
|
5836
|
+
keys(value, ["ok", "operationId", "state", "assetId", "effect"], ["replayed"]), same3(value.state, "restored"), oneOf2(EFFECTS)(value.effect);
|
|
5767
5837
|
},
|
|
5768
5838
|
"asset.transcode": (value) => {
|
|
5769
|
-
keys(value, ["ok", "operationId", "state", "assetId", "generation", "profile"], ["replayed", "enqueue"]),
|
|
5839
|
+
keys(value, ["ok", "operationId", "state", "assetId", "generation", "profile"], ["replayed", "enqueue"]), same3(value.state, "queued"), count2(value.generation) < 1 && fail3(), shape({ id: id5, name: chars(80) })(value.profile), value.enqueue !== void 0 && oneOf2(["done", "deferred"])(value.enqueue);
|
|
5770
5840
|
},
|
|
5771
5841
|
transfer: (value) => {
|
|
5772
5842
|
keys(value, ["ok", "operationId", "state", "assetId", "status"]), oneOf2(["started", "completed", "cancelling"])(value.state), oneOf2([...PREVIEW_STATUSES, "removing", "removed"])(value.status);
|
|
@@ -5774,13 +5844,13 @@ var RECEIPTS = {
|
|
|
5774
5844
|
};
|
|
5775
5845
|
function profileReceipt(value, request) {
|
|
5776
5846
|
let inspect = request.action === "operation.inspect", deleted = value.state === "deleted";
|
|
5777
|
-
keys(value, ["ok", "operationId", "state", "profileId", "defaultProfileId", "defaultChanged", "profilesRevision", ...deleted ? [] : ["profile"]], ["replayed"]), oneOf2(inspect ? [...new Set(Object.values(PROFILE_STATES).flat())] : PROFILE_STATES[request.action])(value.state), replayed(value), id5(value.profileId), maybe2(id5)(value.defaultProfileId), boolean2(value.defaultChanged), digest(value.profilesRevision),
|
|
5847
|
+
keys(value, ["ok", "operationId", "state", "profileId", "defaultProfileId", "defaultChanged", "profilesRevision", ...deleted ? [] : ["profile"]], ["replayed"]), oneOf2(inspect ? [...new Set(Object.values(PROFILE_STATES).flat())] : PROFILE_STATES[request.action])(value.state), replayed(value), id5(value.profileId), maybe2(id5)(value.defaultProfileId), boolean2(value.defaultChanged), digest(value.profilesRevision), same3(value.operationId, inspect ? request.target_operation_id : request.operation_id), deleted && value.defaultProfileId === value.profileId && fail3(), !deleted && (profile(value.profile).id !== value.profileId || value.profile.isDefault !== (value.defaultProfileId === value.profileId)) && fail3(), value.state === "unchanged" && value.defaultChanged && fail3(), request.action === "profile.duplicate" && (value.profileId === request.payload.profile_id || value.profile.isDefault || value.defaultChanged) && fail3(), ["profile.update", "profile.delete", "profile.default"].includes(request.action) && same3(value.profileId, request.payload.profile_id), request.action === "profile.default" && !value.profile.isDefault && fail3();
|
|
5778
5848
|
let { ok, ...data } = value;
|
|
5779
5849
|
return data;
|
|
5780
5850
|
}
|
|
5781
5851
|
function originalDeletion(value, request) {
|
|
5782
5852
|
if (!hasPreviewId(request)) {
|
|
5783
|
-
keys(value, ["ok", "state", "uploads", "skipped", "totalFreesBytes", "previewId", "expiresAt", "message"]),
|
|
5853
|
+
keys(value, ["ok", "state", "uploads", "skipped", "totalFreesBytes", "previewId", "expiresAt", "message"]), same3(value.state, "preview"), str2(1e3)(value.message);
|
|
5784
5854
|
let plan = deletionPlan(value);
|
|
5785
5855
|
return plan.uploads.length || fail3(), coversRequest([...plan.uploads, ...plan.skipped], request), { state: "preview", ...plan, message: value.message };
|
|
5786
5856
|
}
|
|
@@ -5794,7 +5864,7 @@ function mediaReceipt(value, request) {
|
|
|
5794
5864
|
if (isProfileAction(request.action) || inspect && Object.hasOwn(value ?? {}, "profileId")) return profileReceipt(value, request);
|
|
5795
5865
|
if (request.action === "original.delete") return originalDeletion(value, request);
|
|
5796
5866
|
let kind2 = inspect ? receiptKind(value) : request.action;
|
|
5797
|
-
Object.hasOwn(RECEIPTS, kind2) || fail3(), RECEIPTS[kind2](value), replayed(value), id5(value.assetId),
|
|
5867
|
+
Object.hasOwn(RECEIPTS, kind2) || fail3(), RECEIPTS[kind2](value), replayed(value), id5(value.assetId), same3(value.operationId, inspect ? request.target_operation_id : request.operation_id), inspect || same3(value.assetId, request.payload.asset_id);
|
|
5798
5868
|
let { ok, ...data } = value;
|
|
5799
5869
|
return kind2 === "asset.delete" ? { ...data, storageCleanup: value.outcome === "trashed" ? "after_restore_window" : "pending" } : data;
|
|
5800
5870
|
}
|
|
@@ -7432,7 +7502,7 @@ function leaks2(value, allowed) {
|
|
|
7432
7502
|
}
|
|
7433
7503
|
var fail5 = () => {
|
|
7434
7504
|
throw Error("INVALID_RESPONSE");
|
|
7435
|
-
}, keys2 = (value, required, optional = []) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype || required.some((key4) => !Object.hasOwn(value, key4)) || Object.keys(value).some((key4) => !required.includes(key4) && !optional.includes(key4))) && fail5(), value), check = (test) => (value) => (test(value) || fail5(), value), str3 = (max = 1e3) => check((v) => typeof v == "string" && v.length <= max && !/[\u0000-\u001f\u007f]/.test(v)), count3 = check((v) => Number.isSafeInteger(v) && v >= 0), boolean3 = check((v) => typeof v == "boolean"), id7 = check((v) => typeof v == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(v)), digest2 = check((v) => typeof v == "string" && /^[0-9a-f]{64}$/.test(v)), instant2 = check((v) => typeof v == "string" && v.length <= 40 && !Number.isNaN(Date.parse(v))), word = check((v) => typeof v == "string" && v.length <= 64 && /^[a-z][a-z_-]*$/.test(v)), cursor3 = check((v) => typeof v == "string" && v.length <= 2048 && /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{43}$/.test(v)), oneOf3 = (values) => check((v) => values.includes(v)), maybe3 = (test) => (value) => value === null ? null : test(value),
|
|
7505
|
+
}, keys2 = (value, required, optional = []) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype || required.some((key4) => !Object.hasOwn(value, key4)) || Object.keys(value).some((key4) => !required.includes(key4) && !optional.includes(key4))) && fail5(), value), check = (test) => (value) => (test(value) || fail5(), value), str3 = (max = 1e3) => check((v) => typeof v == "string" && v.length <= max && !/[\u0000-\u001f\u007f]/.test(v)), count3 = check((v) => Number.isSafeInteger(v) && v >= 0), boolean3 = check((v) => typeof v == "boolean"), id7 = check((v) => typeof v == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(v)), digest2 = check((v) => typeof v == "string" && /^[0-9a-f]{64}$/.test(v)), instant2 = check((v) => typeof v == "string" && v.length <= 40 && !Number.isNaN(Date.parse(v))), word = check((v) => typeof v == "string" && v.length <= 64 && /^[a-z][a-z_-]*$/.test(v)), cursor3 = check((v) => typeof v == "string" && v.length <= 2048 && /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{43}$/.test(v)), oneOf3 = (values) => check((v) => values.includes(v)), maybe3 = (test) => (value) => value === null ? null : test(value), same4 = (expected) => check((v) => v === expected), shape2 = (fields2) => (value) => {
|
|
7436
7506
|
keys2(value, Object.keys(fields2));
|
|
7437
7507
|
for (let [key4, test] of Object.entries(fields2)) test(value[key4]);
|
|
7438
7508
|
return value;
|
|
@@ -7460,7 +7530,7 @@ var fail5 = () => {
|
|
|
7460
7530
|
sourceState: maybe3(word),
|
|
7461
7531
|
importStatus: maybe3(word),
|
|
7462
7532
|
snapshot: digest2
|
|
7463
|
-
}, weekly = shape2({ kind:
|
|
7533
|
+
}, weekly = shape2({ kind: same4("weekly"), timeZone: str3(64), days: array3(shape2({ weekday: check((v) => Number.isInteger(v) && v >= 1 && v <= 7), times: array3(str3(5), 48) }), 7) }), schedule2 = (value) => value?.kind === "once" ? shape2({ kind: same4("once"), startsAt: instant2, timeZone: str3(64) })(value) : weekly(value), zoned = (withLocal = !1) => shape2({ startsAt: instant2, timeZone: str3(64), ...withLocal ? { local: str3(40) } : {} });
|
|
7464
7534
|
function paged(data, input, item, extra = {}) {
|
|
7465
7535
|
shape2({ ...extra, items: array3(item, 100), page: shape2({ limit: count3, returned: count3, nextCursor: maybe3(cursor3) }) })(data), (data.page.limit !== (input.limit ?? DEFAULT_LIMIT) || data.page.returned !== data.items.length || data.items.length > data.page.limit) && fail5();
|
|
7466
7536
|
}
|
|
@@ -7470,7 +7540,7 @@ var DATA2 = {
|
|
|
7470
7540
|
},
|
|
7471
7541
|
get(data, input) {
|
|
7472
7542
|
shape2({
|
|
7473
|
-
entryId:
|
|
7543
|
+
entryId: same4(input.entry_id),
|
|
7474
7544
|
provisioning: word,
|
|
7475
7545
|
stream: maybe3(shape2(DETAIL)),
|
|
7476
7546
|
schedule: shape2({ revision: count3, schedule: maybe3(schedule2), announcement: maybe3(zoned()) })
|
|
@@ -7478,17 +7548,17 @@ var DATA2 = {
|
|
|
7478
7548
|
},
|
|
7479
7549
|
viewers(data, input) {
|
|
7480
7550
|
let counted = data?.state === "fresh" || data?.state === "stale";
|
|
7481
|
-
return shape2({ entryId:
|
|
7551
|
+
return shape2({ entryId: same4(input.entry_id), source: word, unit: word, state: oneOf3(["fresh", "stale", "unavailable"]), ...counted ? { count: count3, observedAt: instant2 } : {} })(data), { ...data, summary: viewerSummary(data) };
|
|
7482
7552
|
},
|
|
7483
7553
|
recordings(data, input) {
|
|
7484
7554
|
paged(data, input, shape2({ ...RECORDING, settings: maybe3(settings), canSave: boolean3 }));
|
|
7485
7555
|
},
|
|
7486
7556
|
"saved-recordings"(data, input) {
|
|
7487
|
-
paged(data, input, shape2({ entryId: id7, title: str3(), completedAt: maybe3(instant2) }), { entryId:
|
|
7557
|
+
paged(data, input, shape2({ entryId: id7, title: str3(), completedAt: maybe3(instant2) }), { entryId: same4(input.entry_id) });
|
|
7488
7558
|
},
|
|
7489
7559
|
preview(data, input) {
|
|
7490
7560
|
return shape2({
|
|
7491
|
-
entryId:
|
|
7561
|
+
entryId: same4(input.entry_id),
|
|
7492
7562
|
hlsUrl: check((v) => typeof v == "string" && v.length <= 4096 && /^https?:\/\/[^\s]+$/.test(v)),
|
|
7493
7563
|
sessionId: str3(200),
|
|
7494
7564
|
expiresAt: count3,
|
|
@@ -7518,32 +7588,32 @@ var policy = shape2({ saveMode: word, retentionHours: count3, countSource: word,
|
|
|
7518
7588
|
return Object.hasOwn(value, "settings") && maybe3(settings)(value.settings), expected && value.id !== expected && fail5(), value;
|
|
7519
7589
|
}, ownEntry = (c) => check((v) => id7(v) && (c.entryId === null || v === c.entryId)), RESULTS = {
|
|
7520
7590
|
"stream.provision": (v, c) => {
|
|
7521
|
-
ownEntry(c)(v.entryId), v.state === "stopped" ? (keys2(v, [...HEAD, "entryId", "outcome"]),
|
|
7591
|
+
ownEntry(c)(v.entryId), v.state === "stopped" ? (keys2(v, [...HEAD, "entryId", "outcome"]), same4("cancelled")(v.outcome)) : (keys2(v, [...HEAD, "entryId", "streamRevision"]), same4("completed")(v.state), digest2(v.streamRevision));
|
|
7522
7592
|
},
|
|
7523
7593
|
"stream.options": (v, c) => {
|
|
7524
7594
|
let stopped = v.state === "stopped";
|
|
7525
|
-
keys2(v, [...HEAD, "entryId", "options", "latencyEffect", "streamRevision", ...stopped ? ["outcome"] : []]), oneOf3(["completed", "stopped"])(v.state), stopped &&
|
|
7595
|
+
keys2(v, [...HEAD, "entryId", "options", "latencyEffect", "streamRevision", ...stopped ? ["outcome"] : []]), oneOf3(["completed", "stopped"])(v.state), stopped && same4("not_applied")(v.outcome), ownEntry(c)(v.entryId), options(v.options), same4("unknown")(v.latencyEffect), digest2(v.streamRevision);
|
|
7526
7596
|
},
|
|
7527
7597
|
"stream.recording_settings": (v, c) => {
|
|
7528
|
-
keys2(v, [...HEAD, "entryId", "recordingSettings", "streamRevision"]),
|
|
7598
|
+
keys2(v, [...HEAD, "entryId", "recordingSettings", "streamRevision"]), same4("completed")(v.state), ownEntry(c)(v.entryId), settings(v.recordingSettings), digest2(v.streamRevision);
|
|
7529
7599
|
},
|
|
7530
7600
|
"stream.reset": (v, c) => {
|
|
7531
|
-
v.state === "stopped" ? (keys2(v, [...HEAD, "entryId", "outcome"]),
|
|
7601
|
+
v.state === "stopped" ? (keys2(v, [...HEAD, "entryId", "outcome"]), same4("not_applied")(v.outcome)) : (keys2(v, [...HEAD, "entryId", "warningCode", "outcome"]), same4("completed")(v.state), same4("reset")(v.outcome), same4("LIVE_RESET_INTERRUPTS_BROADCAST")(v.warningCode)), ownEntry(c)(v.entryId);
|
|
7532
7602
|
},
|
|
7533
7603
|
"stream.delete": (v, c) => {
|
|
7534
|
-
keys2(v, [...HEAD, "deleted", "entryResults", "warningCode"]),
|
|
7604
|
+
keys2(v, [...HEAD, "deleted", "entryResults", "warningCode"]), same4("completed")(v.state), shape2({ entryId: ownEntry(c) })(v.deleted), oneOf3([null, "LIVE_DELETE_INTERRUPTS_BROADCAST"])(v.warningCode), array3(shape2({ entryId: id7, status: oneOf3(["deleted", "not_found", "retry-required"]) }), 101)(v.entryResults);
|
|
7535
7605
|
},
|
|
7536
7606
|
"schedule.set": (v, c) => {
|
|
7537
|
-
keys2(v, [...HEAD, "entryId", "revision", "schedule", "announcement"]),
|
|
7607
|
+
keys2(v, [...HEAD, "entryId", "revision", "schedule", "announcement"]), same4("completed")(v.state), ownEntry(c)(v.entryId), count3(v.revision), schedule2(v.schedule), zoned(!0)(v.announcement);
|
|
7538
7608
|
},
|
|
7539
7609
|
"schedule.clear": (v, c) => {
|
|
7540
|
-
keys2(v, [...HEAD, "entryId", "revision", "schedule", "announcement"]),
|
|
7610
|
+
keys2(v, [...HEAD, "entryId", "revision", "schedule", "announcement"]), same4("completed")(v.state), ownEntry(c)(v.entryId), count3(v.revision), same4(null)(v.schedule), same4(null)(v.announcement);
|
|
7541
7611
|
},
|
|
7542
7612
|
"recording.promote": (v, c) => {
|
|
7543
|
-
keys2(v, [...HEAD, "recording"]),
|
|
7613
|
+
keys2(v, [...HEAD, "recording"]), same4("completed")(v.state), recordingOf(c.recordingId)(v.recording);
|
|
7544
7614
|
},
|
|
7545
7615
|
"recording.reconfigure": (v, c) => {
|
|
7546
|
-
keys2(v, [...HEAD, "recording", "streamSettingsChanged"]),
|
|
7616
|
+
keys2(v, [...HEAD, "recording", "streamSettingsChanged"]), same4("completed")(v.state), recordingOf(c.recordingId)(v.recording), boolean3(v.streamSettingsChanged);
|
|
7547
7617
|
}
|
|
7548
7618
|
};
|
|
7549
7619
|
function success(v, c) {
|
|
@@ -7554,10 +7624,10 @@ function success(v, c) {
|
|
|
7554
7624
|
RESULTS[c.action](v, c);
|
|
7555
7625
|
}
|
|
7556
7626
|
var ITEMS = {
|
|
7557
|
-
reset: shape2({ type:
|
|
7558
|
-
liveItem: shape2({ type:
|
|
7559
|
-
savedRecording: shape2({ type:
|
|
7560
|
-
unsavedRecordings: shape2({ type:
|
|
7627
|
+
reset: shape2({ type: same4("reset"), entryId: id7, title: str3(2e3), liveNow: boolean3, warningCode: same4("LIVE_RESET_INTERRUPTS_BROADCAST"), effect: str3(2e3) }),
|
|
7628
|
+
liveItem: shape2({ type: same4("liveItem"), entryId: id7, title: str3(2e3), provisioned: boolean3, liveNow: boolean3, warningCode: oneOf3([null, "LIVE_DELETE_INTERRUPTS_BROADCAST"]) }),
|
|
7629
|
+
savedRecording: shape2({ type: same4("savedRecording"), entryId: id7, title: str3(2e3), completedAt: maybe3(instant2), selected: boolean3 }),
|
|
7630
|
+
unsavedRecordings: shape2({ type: same4("unsavedRecordings"), count: count3, note: str3(2e3) })
|
|
7561
7631
|
};
|
|
7562
7632
|
function previewPage(v, kinds, entryId) {
|
|
7563
7633
|
keys2(v, ["ok", "previewId", "entryId", "digest", "items", "nextCursor", "policy"], ["acknowledgement"]), id7(v.previewId), id7(v.entryId), digest2(v.digest), maybe3(digest2)(v.nextCursor), (entryId && v.entryId !== entryId || v.nextCursor === null != (v.acknowledgement !== void 0)) && fail5(), v.acknowledgement !== void 0 && digest2(v.acknowledgement), array3((item) => {
|
|
@@ -7565,10 +7635,10 @@ function previewPage(v, kinds, entryId) {
|
|
|
7565
7635
|
}, 100)(v.items);
|
|
7566
7636
|
}
|
|
7567
7637
|
var DETAILS = {
|
|
7568
|
-
operationId: (v, c) =>
|
|
7638
|
+
operationId: (v, c) => same4(c.operationId)(v),
|
|
7569
7639
|
retryable: boolean3,
|
|
7570
7640
|
state: word,
|
|
7571
|
-
entryId: (v, c) =>
|
|
7641
|
+
entryId: (v, c) => same4(c.entryId)(v),
|
|
7572
7642
|
reason: word,
|
|
7573
7643
|
candidates: (v) => {
|
|
7574
7644
|
(!Array.isArray(v) || v.length !== 2) && fail5(), v.forEach(instant2);
|
|
@@ -7589,7 +7659,7 @@ function refusal2(v, c, request) {
|
|
|
7589
7659
|
if (code === "LIVE_DELETE_SELECTION_TOO_LARGE" || code === "LIVE_SCHEDULE_INVALID")
|
|
7590
7660
|
return keys2(v, ["ok", "error", "policy"], ["field"]), liveFailure(code, void 0, typeof v.field == "string" && /^[a-z_.[\]0-9]{1,80}$/.test(v.field) ? { field: v.field } : {});
|
|
7591
7661
|
if (code === "CONFLICT")
|
|
7592
|
-
return keys2(v, ["ok", "error", "policy", "operationId", "latestState"]),
|
|
7662
|
+
return keys2(v, ["ok", "error", "policy", "operationId", "latestState"]), same4(c.operationId)(v.operationId), (c.action.startsWith("schedule.") ? shape2({ revision: count3, schedule: maybe3(schedule2), announcement: maybe3(zoned(!0)) }) : c.action === "recording.reconfigure" ? recordingOf(c.recordingId) : shape2({ ...STREAM, streamRevision: digest2, recordingSettings: settings }))(v.latestState), c.action.startsWith("stream.") && v.latestState.entryId !== c.entryId && fail5(), liveFailure(code, void 0, { operationId: v.operationId, latestState: v.latestState });
|
|
7593
7663
|
let extra = Object.fromEntries(Object.entries(v).filter(([key4]) => !["ok", "error", "policy"].includes(key4)).map(([key4, value]) => (Object.hasOwn(DETAILS, key4) || fail5(), DETAILS[key4](value, c), [key4, value])));
|
|
7594
7664
|
return liveFailure(code, void 0, extra);
|
|
7595
7665
|
}
|
|
@@ -7989,6 +8059,22 @@ function stagingTarget(ticket, body) {
|
|
|
7989
8059
|
if (!(r2 || local) || target2.username || target2.password || target2.hash || bucketEnv !== "prod" || !UUID11.test(ticket.jobId) || pathJobId !== ticket.jobId || Object.keys(headers).sort().join() !== TICKET_HEADERS || headers["content-length"] !== String(Buffer.byteLength(body)) || headers["if-none-match"] !== "*" || headers["x-amz-checksum-sha256"] !== createHash5("sha256").update(body).digest("base64") || !Number.isSafeInteger(ticket.expiresAt) || ticket.expiresAt <= Date.now()) throw new Error("Invalid staging upload.");
|
|
7990
8060
|
return target2;
|
|
7991
8061
|
}
|
|
8062
|
+
var SERVER_CODE = /^[A-Z][A-Z0-9_]{2,63}$/;
|
|
8063
|
+
function cleanServerMessage(value) {
|
|
8064
|
+
return typeof value == "string" ? value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 500) : "";
|
|
8065
|
+
}
|
|
8066
|
+
async function rejection(response2, action) {
|
|
8067
|
+
let serverCode, serverMessage = "";
|
|
8068
|
+
try {
|
|
8069
|
+
let parsed = JSON.parse((await response2.text()).slice(0, 4096));
|
|
8070
|
+
typeof parsed?.error == "string" && SERVER_CODE.test(parsed.error) && (serverCode = parsed.error, serverMessage = cleanServerMessage(parsed.message));
|
|
8071
|
+
} catch {
|
|
8072
|
+
}
|
|
8073
|
+
return Object.assign(
|
|
8074
|
+
new Error(`Adelin rejected the local ${action} request (${response2.status}).`),
|
|
8075
|
+
{ status: response2.status, action, ...serverCode && { serverCode }, ...serverMessage && { serverMessage } }
|
|
8076
|
+
);
|
|
8077
|
+
}
|
|
7992
8078
|
var LocalBuildTransport = class {
|
|
7993
8079
|
constructor(mcpUrl, fetcher = fetch, { release: release2 = null } = {}) {
|
|
7994
8080
|
this.url = new URL(validateMcpUrl(mcpUrl)), this.fetcher = fetcher, this.privateKey = null, this.publicKey = null, this.token = null, this.tuple = null, this.expiresAt = 0, this.release = release2, this.continuation = null;
|
|
@@ -8071,7 +8157,7 @@ ${digest4}`), signature = sign2(null, bytes2, this.privateKey).toString("base64u
|
|
|
8071
8157
|
}), refusal3 = response2.status === 400 && (action === "ask" || action === "choose");
|
|
8072
8158
|
if (response2.status === 426)
|
|
8073
8159
|
throw await response2.body?.cancel(), Object.assign(new Error("Adelin authoring needs an update. Run adelin setup."), { code: "UPDATE_REQUIRED" });
|
|
8074
|
-
if (!response2.ok && !refusal3) throw
|
|
8160
|
+
if (!response2.ok && !refusal3) throw await rejection(response2, action);
|
|
8075
8161
|
let continuation = response2.headers?.get("x-adelin-continuation");
|
|
8076
8162
|
if (continuation) {
|
|
8077
8163
|
if (continuation.length > 16384 || !/^[A-Za-z0-9_.-]+$/.test(continuation)) throw new Error("Invalid build continuation.");
|
|
@@ -8180,11 +8266,13 @@ var UUID12 = "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-
|
|
|
8180
8266
|
"connection_status",
|
|
8181
8267
|
"select_app",
|
|
8182
8268
|
"list_editable_apps",
|
|
8269
|
+
"list_app_templates",
|
|
8270
|
+
"list_app_organizations",
|
|
8183
8271
|
"get_content_schema",
|
|
8184
8272
|
...Object.keys(APP_REQUIREMENTS_TOOLS),
|
|
8185
8273
|
...Object.keys(APP_MEMORY_TOOLS),
|
|
8186
8274
|
...ARTIFACT_TOOLS
|
|
8187
|
-
]), metadataTools = { ...APP_REQUIREMENTS_TOOLS, ...APP_MEMORY_TOOLS }, metadataWrites = /* @__PURE__ */ new Set(["update_app_requirements", "mutate_app_memory"]), privateMetadataFields = ["lease_id", "chat_session_id", "epoch", "resume_proof"], appDenied = "This connection can't access this app. Open Settings \u2192 Connected code agents \u2192 Manage apps to review its access.", saveDenied = "App access was removed or this connection ended. Your local files are unchanged. Review access in Settings before trying again.", VIEW_RETRY_MS = 500, VIEW_RETRY_MAX_MS = 3e4, remoteFailed = "Adelin request failed. Your local files are unchanged. Try again.", choiceRefusals = {
|
|
8275
|
+
]), metadataTools = { ...APP_REQUIREMENTS_TOOLS, ...APP_MEMORY_TOOLS }, metadataWrites = /* @__PURE__ */ new Set(["update_app_requirements", "mutate_app_memory"]), privateMetadataFields = ["lease_id", "chat_session_id", "epoch", "resume_proof"], CREATION_POLL_MS = 250, CREATION_WAIT_MS = 25e3, appDenied = "This connection can't access this app. Open Settings \u2192 Connected code agents \u2192 Manage apps to review its access.", saveDenied = "App access was removed or this connection ended. Your local files are unchanged. Review access in Settings before trying again.", VIEW_RETRY_MS = 500, VIEW_RETRY_MAX_MS = 3e4, remoteFailed = "Adelin request failed. Try again.", CREATION_TOOLS = /* @__PURE__ */ new Set(["list_app_templates", "list_app_organizations", "create_app", "advance_app_creation"]), creationUnavailable = "App creation isn't available for this connection. Run adelin login and allow private file transfers when you sign in.", toolUnavailable = "This Adelin tool isn't available for this connection. Run adelin login to sign in again.", saveFailed = "Adelin request failed. Your local files are unchanged. Try again.", NO_APPS_HINT = "No apps are available to this connection. Call list_app_organizations and create_app to make one, or approve apps in Settings \u2192 Connected code agents \u2192 Manage apps.", SERVER_CODE2 = /^[A-Z][A-Z0-9_]{2,63}$/, REJECTED = /^Adelin rejected the local (\w+) request \((\d{3})\)\.$/, SAVE_ACTIONS = ["heartbeat", "prepare", "build", "reconcile", "close", "agent_view"], choiceRefusals = {
|
|
8188
8276
|
DESIGNS_NOT_IN_SESSION: "Offer 1\u20134 designs you created or revised with create_artifact or update_artifact while this app was open.",
|
|
8189
8277
|
CHOICE_REFUSED: "That design is not one of the options, or the session has ended."
|
|
8190
8278
|
}, fields = {
|
|
@@ -8297,6 +8385,30 @@ var UUID12 = "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-
|
|
|
8297
8385
|
}
|
|
8298
8386
|
},
|
|
8299
8387
|
...[...mediaTools, ...mediaTransferTools, ...filesTools, ...liveTools, liveCredentialsTool].map(({ name, description: description2, annotations, inputSchema }) => ({ name, description: description2, annotations, inputSchema })),
|
|
8388
|
+
{
|
|
8389
|
+
name: "create_app",
|
|
8390
|
+
description: "Create a new Adelin app, from a template (template_id and template_digest from list_app_templates) or from scratch (languages, the first is primary, and sample_content, possibly empty). Waits until the app is ready, up to about 45 seconds. After state ready, call open_app with the returned app_id to start editing. If state is waiting, call resume_app_creation. Every result after the app exists carries app_id, creation_id and idempotency_key; never create another app for a creation you can resume. Errors such as APP_PLAN_LIMIT are returned as they are; show upgradeUrl to the user.",
|
|
8391
|
+
annotations: { readOnlyHint: !1, destructiveHint: !1, idempotentHint: !0 },
|
|
8392
|
+
inputSchema: closed5({
|
|
8393
|
+
organization_id: { type: "string", pattern: UUID12 },
|
|
8394
|
+
name: { type: "string", minLength: 3, maxLength: 256 },
|
|
8395
|
+
devices: { type: "array", minItems: 1, maxItems: 3, uniqueItems: !0, items: { enum: ["mobile", "web", "tv"] } },
|
|
8396
|
+
start: { oneOf: [
|
|
8397
|
+
closed5({ template_id: { type: "string", minLength: 1, maxLength: 80 }, template_digest: { type: "string", pattern: "^[0-9a-f]{64}$" } }, ["template_id", "template_digest"]),
|
|
8398
|
+
closed5({ scratch: closed5({
|
|
8399
|
+
languages: { type: "array", minItems: 1, items: { type: "string" } },
|
|
8400
|
+
sample_content: { type: "array", uniqueItems: !0, items: { type: "string" } }
|
|
8401
|
+
}, ["languages", "sample_content"]) }, ["scratch"])
|
|
8402
|
+
] },
|
|
8403
|
+
idempotency_key: { type: "string", pattern: "^[A-Za-z0-9._:-]{1,128}$" }
|
|
8404
|
+
}, ["organization_id", "name", "devices", "start"])
|
|
8405
|
+
},
|
|
8406
|
+
{
|
|
8407
|
+
name: "resume_app_creation",
|
|
8408
|
+
description: "Keep waiting for an app that create_app returned as waiting, or as failed with a message to retry later. Pass its app_id and creation_id. After state ready, call open_app with the app_id.",
|
|
8409
|
+
annotations: { readOnlyHint: !1, destructiveHint: !1, idempotentHint: !0 },
|
|
8410
|
+
inputSchema: closed5({ app_id: fields.app_id, creation_id: { type: "string", minLength: 4, maxLength: 64 } }, ["app_id", "creation_id"])
|
|
8411
|
+
},
|
|
8300
8412
|
{
|
|
8301
8413
|
name: "open_app",
|
|
8302
8414
|
description: "Checkout an app into a local workspace and start one edit session.",
|
|
@@ -8394,15 +8506,20 @@ function valueOf(result, saving = !1, limit3 = 2 * 1024 * 1024) {
|
|
|
8394
8506
|
}
|
|
8395
8507
|
if (!value || typeof value != "object" || Array.isArray(value))
|
|
8396
8508
|
throw new Error("Adelin returned an invalid tool result.");
|
|
8397
|
-
if (result.isError || "error" in value)
|
|
8398
|
-
|
|
8399
|
-
if (value.error === "INVALID_ARGUMENT") throw invalidArgument();
|
|
8400
|
-
if (Object.hasOwn(choiceRefusals, value.error)) throw new Error(choiceRefusals[value.error]);
|
|
8401
|
-
let denied = value.error === "APP_NOT_EDITABLE" || value.error === "UNAUTHORIZED";
|
|
8402
|
-
throw new Error(denied ? saving ? saveDenied : appDenied : remoteFailed);
|
|
8403
|
-
}
|
|
8509
|
+
if (result.isError || "error" in value)
|
|
8510
|
+
throw value.error === "UPDATE_REQUIRED" ? updateRequired() : value.error === "INVALID_ARGUMENT" ? invalidArgument() : Object.hasOwn(choiceRefusals, value.error) ? new Error(choiceRefusals[value.error]) : value.error === "APP_NOT_EDITABLE" || value.error === "UNAUTHORIZED" ? new Error(saving ? saveDenied : appDenied) : typeof value.error == "string" && SERVER_CODE2.test(value.error) ? reported(value.error, cleanServerMessage(value.message) || `Adelin refused the request (${value.error}).`) : new Error(saving ? saveFailed : remoteFailed);
|
|
8404
8511
|
return value;
|
|
8405
8512
|
}
|
|
8513
|
+
var reported = (code, message, extra = {}) => Object.assign(new Error(message), { code, expose: !0, ...extra }), transient = (error) => error?.expose === !0 && (error.code === "REQUEST_TIMEOUT" || error.code === "REMOTE_UNAVAILABLE" && !(error.status < 500));
|
|
8514
|
+
function remoteError(error, saving = !1, name = "") {
|
|
8515
|
+
let code = error?.code;
|
|
8516
|
+
if (code === "TOOL_UNAVAILABLE") return reported(code, CREATION_TOOLS.has(name) ? creationUnavailable : toolUnavailable);
|
|
8517
|
+
if (code === "INVALID_ARGUMENT") return invalidArgument();
|
|
8518
|
+
if (code === "UPDATE_REQUIRED") return updateRequired();
|
|
8519
|
+
if (code === "AUTH_REQUIRED") return reported("SIGN_IN_REQUIRED", "Run adelin login.");
|
|
8520
|
+
let rejected = REJECTED.exec(error instanceof Error ? error.message : ""), status2 = Number.isSafeInteger(error?.status) ? error.status : rejected ? Number(rejected[2]) : void 0, action = error?.action ?? rejected?.[1];
|
|
8521
|
+
return saving && (status2 === 401 || status2 === 403) && SAVE_ACTIONS.includes(action) ? new Error(saveDenied) : code === "ACCESS_DENIED" ? reported(code, appDenied, { status: status2 }) : code === "APP_SELECTION_CHANGED" ? reported(code, "App access changed while this request ran. Retry it, and run adelin login if it happens again.", { status: status2 }) : code === "REQUEST_TIMEOUT" ? reported(code, "Adelin did not answer in time. Try again.") : typeof error?.serverCode == "string" ? reported(error.serverCode, error.serverMessage || `Adelin refused the ${action ?? "request"} (${error.serverCode}, HTTP ${status2}).`, { status: status2 }) : status2 !== void 0 ? reported("REMOTE_UNAVAILABLE", `Adelin answered HTTP ${status2}${action ? ` to the ${action} request` : ""}.`, { status: status2 }) : code === "REMOTE_UNAVAILABLE" ? reported(code, "Adelin could not be reached. Try again shortly.") : new Error(saving ? saveFailed : remoteFailed);
|
|
8522
|
+
}
|
|
8406
8523
|
var CONFLICT_MESSAGES = {
|
|
8407
8524
|
chat_reply: "The builder's App Creator chat is replying right now. Call open_app again after retryAt; Adelin hands the app over once the reply ends.",
|
|
8408
8525
|
someone_else: "Another person is editing this app. Tell the builder, and call open_app again once they have left it.",
|
|
@@ -8425,28 +8542,66 @@ async function safeCall(remote2, name, args, saving = !1) {
|
|
|
8425
8542
|
try {
|
|
8426
8543
|
result = await remote2.call(name, args);
|
|
8427
8544
|
} catch (error) {
|
|
8428
|
-
|
|
8429
|
-
if (error?.code === "UPDATE_REQUIRED") throw updateRequired();
|
|
8430
|
-
let denied = saving && error instanceof Error && /^Adelin rejected the local (heartbeat|prepare|build|reconcile|close|agent_view) request \((401|403)\)\.$/.test(error.message);
|
|
8431
|
-
throw new Error(denied ? saveDenied : remoteFailed);
|
|
8545
|
+
throw remoteError(error, saving, name);
|
|
8432
8546
|
}
|
|
8433
8547
|
let conflict = name === "open_edit_session" ? editConflict(result) : null;
|
|
8434
8548
|
if (conflict) return { content: [{ type: "text", text: JSON.stringify(conflict) }] };
|
|
8435
8549
|
let text4 = ARTIFACT_TOOLS.includes(name) && result?.isError && result.content?.length === 1 ? result.content[0].text : null;
|
|
8436
8550
|
return typeof text4 == "string" && text4.length <= 4096 && /^[A-Z][A-Z_]{2,63}: /.test(text4) ? { isError: !0, content: [{ type: "text", text: text4 }] } : (valueOf(result, saving, name === "device_operation" ? MAX_DEVICE_BYTES : void 0), result);
|
|
8437
8551
|
}
|
|
8552
|
+
async function creationCall(remote2, name, args) {
|
|
8553
|
+
let result;
|
|
8554
|
+
try {
|
|
8555
|
+
result = await remote2.call(name, args);
|
|
8556
|
+
} catch (error) {
|
|
8557
|
+
throw remoteError(error, !1, name);
|
|
8558
|
+
}
|
|
8559
|
+
try {
|
|
8560
|
+
let value = JSON.parse(result.content[0].text);
|
|
8561
|
+
return value && typeof value == "object" && !Array.isArray(value) ? { value, isError: !!result.isError } : null;
|
|
8562
|
+
} catch {
|
|
8563
|
+
return null;
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8566
|
+
function failureBody(error) {
|
|
8567
|
+
return {
|
|
8568
|
+
error: error?.expose === !0 || ["UPDATE_REQUIRED", "PROJECT_SETUP_REQUIRED"].includes(error?.code) ? error.code : "ADELIN_TOOL_FAILED",
|
|
8569
|
+
message: error instanceof Error ? error.message.slice(0, 500) : "Adelin tool failed.",
|
|
8570
|
+
...error?.expose === !0 && Number.isSafeInteger(error.status) ? { status: error.status } : {}
|
|
8571
|
+
};
|
|
8572
|
+
}
|
|
8573
|
+
var wait2 = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
8574
|
+
async function finishCreation(remote2, appId, creationId, { pollMs, waitMs, sleep: sleep2 }, { startedAt = Date.now(), idempotencyKey } = {}) {
|
|
8575
|
+
let deadline = startedAt + waitMs, ids3 = { app_id: appId, creation_id: creationId, ...idempotencyKey ? { idempotency_key: idempotencyKey } : {} }, phase;
|
|
8576
|
+
for (; ; ) {
|
|
8577
|
+
if (Date.now() >= deadline) return response({ state: "waiting", ...ids3 });
|
|
8578
|
+
let step = null;
|
|
8579
|
+
try {
|
|
8580
|
+
step = await creationCall(remote2, "advance_app_creation", { app_id: appId, creation_id: creationId });
|
|
8581
|
+
} catch (error) {
|
|
8582
|
+
if (!transient(error)) return response({ ...ids3, ...failureBody(error) }, !0);
|
|
8583
|
+
}
|
|
8584
|
+
if (step?.value.state === "ready") return response({ state: "ready", app_id: appId, next: "open_app" });
|
|
8585
|
+
if (step?.value.state === "failed" || step && step.isError) return response({ ...step.value, ...ids3 }, !0);
|
|
8586
|
+
let unchanged = step && step.value.phase === phase;
|
|
8587
|
+
phase = step?.value.phase, (unchanged || !step) && await sleep2(pollMs);
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8438
8590
|
var PREVIEW_REFUSED = "The preview is not available to this session (the session ended, preview control is off for this account, or access was withdrawn).", PREVIEW_DOWN = "The preview could not be opened right now. Try again shortly.", AGENT_VIEW_HINT = "Call show_agent_view when the builder wants to watch or control your preview browser.", BROWSER_DOWNLOADING = "The preview browser is downloading (about 130 MB) once; preview tools work in a minute or two.", DEVICE_ROUTE = "Your previews run on the cloud device shown in Adelin, so there is no local preview browser to show.", APP_CREATOR_WATCHING = "The builder is watching your preview browser in App Creator, where they can click, scroll and type; Alt/Option-click points you at an element. Nothing new was opened.", BROWSER_FAILURES = {
|
|
8439
8591
|
INVALID_ARGUMENTS: "Adelin refused these arguments for the preview.",
|
|
8440
8592
|
LAUNCH_FAILED: "The preview browser could not start on this machine. Try again shortly."
|
|
8441
8593
|
};
|
|
8594
|
+
function previewFailure(error) {
|
|
8595
|
+
return error?.status === 401 || error?.status === 403 ? PREVIEW_REFUSED : error?.expose === !0 ? `The preview could not be opened. ${error.message}` : PREVIEW_DOWN;
|
|
8596
|
+
}
|
|
8442
8597
|
async function routeAndRun(session, browser, tool2, args) {
|
|
8443
8598
|
if (!session.session || session.state !== "active") return previewRefusalContent("Open an app first.");
|
|
8444
8599
|
let ask = async (pass) => {
|
|
8445
8600
|
let reply;
|
|
8446
8601
|
try {
|
|
8447
8602
|
reply = await session.previewPass({ ...args.target ? { target: args.target } : {}, pass });
|
|
8448
|
-
} catch {
|
|
8449
|
-
return previewRefusalContent(
|
|
8603
|
+
} catch (error) {
|
|
8604
|
+
return previewRefusalContent(previewFailure(error));
|
|
8450
8605
|
}
|
|
8451
8606
|
return reply?.status === 429 ? previewRateLimitedContent(Number.isSafeInteger(reply.result?.refillPerMinute) ? reply.result.refillPerMinute : 60) : reply?.status === 403 ? previewRefusalContent(PREVIEW_REFUSED) : reply?.status === 200 && parsePreviewRoute(reply.result) || previewRefusalContent(PREVIEW_DOWN);
|
|
8452
8607
|
}, run = async (route2) => {
|
|
@@ -8477,8 +8632,8 @@ async function showAgentView(session, browser, openPage) {
|
|
|
8477
8632
|
let reply;
|
|
8478
8633
|
try {
|
|
8479
8634
|
reply = await session.previewPass({ pass: !0 });
|
|
8480
|
-
} catch {
|
|
8481
|
-
return { kind: "unavailable", reason:
|
|
8635
|
+
} catch (error) {
|
|
8636
|
+
return { kind: "unavailable", reason: previewFailure(error) };
|
|
8482
8637
|
}
|
|
8483
8638
|
if (reply?.status === 403) return { kind: "unavailable", reason: PREVIEW_REFUSED };
|
|
8484
8639
|
let route = reply?.status === 200 ? parsePreviewRoute(reply.result) : null;
|
|
@@ -8617,9 +8772,11 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8617
8772
|
viewRetryMs = VIEW_RETRY_MS,
|
|
8618
8773
|
heartbeatMs = HEARTBEAT_MS,
|
|
8619
8774
|
hostState = {},
|
|
8775
|
+
appCreation = {},
|
|
8620
8776
|
release: release2 = null,
|
|
8621
8777
|
project = process.cwd(),
|
|
8622
8778
|
standalone = !0,
|
|
8779
|
+
onToolsChanged,
|
|
8623
8780
|
...options2
|
|
8624
8781
|
} = {}) {
|
|
8625
8782
|
let safeRemote = { call: (name, args) => safeCall(remote2, name, args) }, sessionRemote = {
|
|
@@ -8642,7 +8799,7 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8642
8799
|
} catch (error) {
|
|
8643
8800
|
throw Object.assign(new Error(`${error.message} Run adelin setup in this project or worktree.`), { code: "PROJECT_SETUP_REQUIRED" });
|
|
8644
8801
|
}
|
|
8645
|
-
}, schemas = new Map(localTools.map((tool2) => [tool2.name, tool2.inputSchema])), remoteTools = async () => {
|
|
8802
|
+
}, creationTiming = { pollMs: appCreation.pollMs ?? CREATION_POLL_MS, waitMs: appCreation.waitMs ?? CREATION_WAIT_MS, sleep: appCreation.sleep ?? wait2 }, schemas = new Map(localTools.map((tool2) => [tool2.name, tool2.inputSchema])), remoteTools = async () => {
|
|
8646
8803
|
let tools = (await remote2.listTools()).filter((tool2) => exposed.has(tool2.name)).map((tool2) => {
|
|
8647
8804
|
if (!metadataWrites.has(tool2.name)) return tool2;
|
|
8648
8805
|
let inputSchema = structuredClone(tool2.inputSchema);
|
|
@@ -8651,9 +8808,10 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8651
8808
|
});
|
|
8652
8809
|
for (let tool2 of tools) schemas.set(tool2.name, tool2.inputSchema);
|
|
8653
8810
|
return tools;
|
|
8654
|
-
}, listTools = async () => {
|
|
8811
|
+
}, remoteListed = !1, notifyTools = onToolsChanged, listTools = async () => {
|
|
8655
8812
|
try {
|
|
8656
|
-
|
|
8813
|
+
let tools = await remoteTools();
|
|
8814
|
+
return remoteListed = !0, { tools: [...tools, ...localTools] };
|
|
8657
8815
|
} catch {
|
|
8658
8816
|
if (standalone) throw new Error(remoteFailed);
|
|
8659
8817
|
return { tools: localTools };
|
|
@@ -8757,6 +8915,33 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8757
8915
|
if (preview2) return await routeAndRun(session, previewBrowser, preview2, args);
|
|
8758
8916
|
if (name === "show_agent_view") return await showAgentView(session, previewBrowser, openPage);
|
|
8759
8917
|
if (name === "record_choice") return response(await session.recordChoice(args.request_id, args.artifact_id, args.note));
|
|
8918
|
+
if (name === "create_app") {
|
|
8919
|
+
let startedAt = Date.now(), input = { ...args, idempotency_key: args.idempotency_key ?? randomUUID7() }, created = null, failure = null;
|
|
8920
|
+
for (let attempt = 0; attempt < 3 && !created; attempt++)
|
|
8921
|
+
try {
|
|
8922
|
+
created = await creationCall(remote2, "create_app", input);
|
|
8923
|
+
} catch (error) {
|
|
8924
|
+
if (!transient(error)) return response({ ...failureBody(error), idempotency_key: input.idempotency_key }, !0);
|
|
8925
|
+
failure = error;
|
|
8926
|
+
}
|
|
8927
|
+
return created ? created.isError || "error" in created.value ? response({ ...created.value, idempotency_key: input.idempotency_key }, !0) : created.value.state === "ready" ? response({ state: "ready", app_id: created.value.app_id, next: "open_app" }) : await finishCreation(
|
|
8928
|
+
remote2,
|
|
8929
|
+
created.value.app_id,
|
|
8930
|
+
created.value.creation_id,
|
|
8931
|
+
creationTiming,
|
|
8932
|
+
{ startedAt, idempotencyKey: input.idempotency_key }
|
|
8933
|
+
) : response({ ...failureBody(failure ?? new Error(remoteFailed)), idempotency_key: input.idempotency_key }, !0);
|
|
8934
|
+
}
|
|
8935
|
+
if (name === "connection_status") {
|
|
8936
|
+
let setupState = "setup_required";
|
|
8937
|
+
try {
|
|
8938
|
+
inspectProjectSetup(project, release2).status === "current" && (setupState = "current");
|
|
8939
|
+
} catch {
|
|
8940
|
+
}
|
|
8941
|
+
let { allApps, ...status2 } = valueOf(await safeRemote.call(name, args));
|
|
8942
|
+
return response({ ...status2, project: setupState, ...typeof allApps == "boolean" ? { scope: allApps ? "all_apps" : "selected" } : {} });
|
|
8943
|
+
}
|
|
8944
|
+
if (name === "resume_app_creation") return await finishCreation(remote2, args.app_id, args.creation_id, creationTiming);
|
|
8760
8945
|
if (!exposed.has(name))
|
|
8761
8946
|
throw new Error("Unknown Adelin tool.");
|
|
8762
8947
|
if (Object.hasOwn(metadataTools, name)) {
|
|
@@ -8778,14 +8963,19 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8778
8963
|
let result = await safeRemote.call(name, payload);
|
|
8779
8964
|
return result.isError ? result : response(metadataTools[name].result.parse(valueOf(result)));
|
|
8780
8965
|
}
|
|
8781
|
-
|
|
8966
|
+
let reply = await safeRemote.call(name, args);
|
|
8967
|
+
if (name !== "list_editable_apps") return reply;
|
|
8968
|
+
let listed = valueOf(reply);
|
|
8969
|
+
return Array.isArray(listed.apps) && !listed.apps.length ? response({ ...listed, hint: NO_APPS_HINT }) : reply;
|
|
8782
8970
|
} catch (error) {
|
|
8783
|
-
return error?.code === "INVALID_ARGUMENT" ? response(refused(), !0) : response(
|
|
8784
|
-
error: ["UPDATE_REQUIRED", "PROJECT_SETUP_REQUIRED"].includes(error?.code) ? error.code : "ADELIN_TOOL_FAILED",
|
|
8785
|
-
message: error instanceof Error ? error.message.slice(0, 500) : "Adelin tool failed."
|
|
8786
|
-
}, !0);
|
|
8971
|
+
return error?.code === "INVALID_ARGUMENT" ? response(refused(), !0) : response(failureBody(error), !0);
|
|
8787
8972
|
}
|
|
8788
8973
|
}, timer = null, ticking = null, tick = () => ticking ??= (async () => {
|
|
8974
|
+
if (!remoteListed)
|
|
8975
|
+
try {
|
|
8976
|
+
await remoteTools(), remoteListed = !0, notifyTools?.();
|
|
8977
|
+
} catch {
|
|
8978
|
+
}
|
|
8789
8979
|
if (session.session && transport.expiresAt < Date.now() + 6e4)
|
|
8790
8980
|
try {
|
|
8791
8981
|
let { appId, leaseId, chatSessionId, epoch } = session.session, ticket = valueOf(await safeRemote.call("authorize_local_build", {
|
|
@@ -8827,15 +9017,18 @@ function createLocalBuilder(remote2, transport, {
|
|
|
8827
9017
|
if (!standalone) return runtime;
|
|
8828
9018
|
let server = new Server(
|
|
8829
9019
|
{ name: "adelin", version: "1.0.0" },
|
|
8830
|
-
{ capabilities: { tools: {} }, instructions: "Use open_app, check_app, build_app, and close_app. App files move directly through the local CLI. show_agent_view lets the builder watch and control your preview browser." }
|
|
9020
|
+
{ capabilities: { tools: { listChanged: !0 } }, instructions: "Use open_app, check_app, build_app, and close_app. App files move directly through the local CLI. show_agent_view lets the builder watch and control your preview browser." }
|
|
8831
9021
|
);
|
|
8832
|
-
return server.setRequestHandler(ListToolsRequestSchema, listTools), server.setRequestHandler(CallToolRequestSchema, ({ params }) => callTool(params)),
|
|
9022
|
+
return server.setRequestHandler(ListToolsRequestSchema, listTools), server.setRequestHandler(CallToolRequestSchema, ({ params }) => callTool(params)), notifyTools ??= () => {
|
|
9023
|
+
server.sendToolListChanged().catch(() => {
|
|
9024
|
+
});
|
|
9025
|
+
}, resume(), { ...runtime, server, close: async () => {
|
|
8833
9026
|
await close(), await server.close();
|
|
8834
9027
|
} };
|
|
8835
9028
|
}
|
|
8836
9029
|
|
|
8837
9030
|
// skills/adelin-app-generation/scripts/cli-remote.mjs
|
|
8838
|
-
import { randomUUID as
|
|
9031
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
8839
9032
|
var MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
8840
9033
|
async function readResponse(response2) {
|
|
8841
9034
|
if (!response2.body) throw libraryError("INVALID_RESPONSE");
|
|
@@ -8866,7 +9059,7 @@ var CliRemote = class {
|
|
|
8866
9059
|
try {
|
|
8867
9060
|
let payload = JSON.stringify({
|
|
8868
9061
|
jsonrpc: "2.0",
|
|
8869
|
-
id:
|
|
9062
|
+
id: randomUUID8(),
|
|
8870
9063
|
method,
|
|
8871
9064
|
...params === void 0 ? {} : { params }
|
|
8872
9065
|
}), send = async (token3) => this.fetcher(this.auth.mcpUrl, {
|
|
@@ -8908,7 +9101,10 @@ var CliRemote = class {
|
|
|
8908
9101
|
}
|
|
8909
9102
|
if (!response2.ok) {
|
|
8910
9103
|
await response2.body?.cancel();
|
|
8911
|
-
let refused =
|
|
9104
|
+
let refused = Object.assign(
|
|
9105
|
+
libraryError({ 401: "AUTH_REQUIRED", 403: "ACCESS_DENIED", 409: "APP_SELECTION_CHANGED" }[response2.status] ?? "REMOTE_UNAVAILABLE"),
|
|
9106
|
+
{ status: response2.status }
|
|
9107
|
+
), retry = response2.headers.get("retry-after"), seconds = retry !== null && /^\d+(?:\.\d+)?$/.test(retry) ? Number(retry) : NaN, retryAfterMs = Number.isFinite(seconds) ? Math.ceil(seconds * 1e3) : retry ? Math.max(0, Date.parse(retry) - Date.now()) : NaN;
|
|
8912
9108
|
throw response2.status === 429 ? Object.assign(refused, { rateLimited: !0, ...Number.isFinite(retryAfterMs) ? { retryAfterMs } : {} }) : refused;
|
|
8913
9109
|
}
|
|
8914
9110
|
let continuation = response2.headers?.get("x-adelin-continuation");
|
|
@@ -8917,11 +9113,11 @@ var CliRemote = class {
|
|
|
8917
9113
|
this.continuation = continuation, this.onContinuation?.(continuation);
|
|
8918
9114
|
}
|
|
8919
9115
|
let value = await readResponse(response2);
|
|
8920
|
-
if (value?.error) throw libraryError(value.error.code
|
|
9116
|
+
if (value?.error) throw libraryError(value.error.code !== -32602 ? value.error.code : value.error.message === "Unknown tool" ? "TOOL_UNAVAILABLE" : "INVALID_ARGUMENT");
|
|
8921
9117
|
if (!value?.result) throw libraryError("INVALID_RESPONSE");
|
|
8922
9118
|
return value.result;
|
|
8923
9119
|
} catch (error) {
|
|
8924
|
-
throw error?.code === "UPDATE_REQUIRED" ? error : signal.aborted || error?.name === "TimeoutError" || error?.name === "AbortError" ? libraryError("REQUEST_TIMEOUT") : error?.code ? Object.assign(libraryError(error.code), error.rateLimited === !0 ? {
|
|
9120
|
+
throw error?.code === "UPDATE_REQUIRED" ? error : signal.aborted || error?.name === "TimeoutError" || error?.name === "AbortError" ? libraryError("REQUEST_TIMEOUT") : error?.code ? Object.assign(libraryError(error.code), error.status ? { status: error.status } : {}, error.rateLimited === !0 ? {
|
|
8925
9121
|
rateLimited: !0,
|
|
8926
9122
|
...Number.isFinite(error.retryAfterMs) ? { retryAfterMs: error.retryAfterMs } : {}
|
|
8927
9123
|
} : {}) : libraryError("REMOTE_UNAVAILABLE");
|
|
@@ -20,19 +20,33 @@ The CLI stores sign-in per user in `adelin/auth.json` under the user config dire
|
|
|
20
20
|
|
|
21
21
|
The CLI and background upload workers on the same host serialize every sign-in save, logout and token refresh through an exclusive loopback listener keyed by the canonical credential path. The listener exchanges no credential data, and the operating system releases it when its process exits or crashes. A second process reuses the rotated credential; logout waits for an active refresh, then removes only that server's sign-in so the refresh cannot recreate it. Another credential operation or an unrelated service occupying the same local port causes a wait with a 30-second deadline before a retry refusal. A loopback permission failure also refuses the operation without changing stored credentials.
|
|
22
22
|
|
|
23
|
-
Local byte transfers and live-key access require a native loopback connection requesting `local-transfer` and `live-credentials`. The sign-in page names the unverified requester and offers separate unchecked approvals for private file transfers and saving live keys locally. A client name never authenticates its publisher. Live-key approval requires local-transfer approval and
|
|
23
|
+
Local byte transfers and live-key access require a native loopback connection requesting `local-transfer` and `live-credentials`. The sign-in page names the unverified requester and offers separate unchecked approvals for private file transfers and saving live keys locally. A client name never authenticates its publisher. Live-key approval requires local-transfer approval and `live.manage` in at least one app the connection covers. These approvals belong to the current account, client and grant; removing or expiring consent denies subsequent sensitive actions.
|
|
24
24
|
|
|
25
25
|
`adelin logout` revokes the current connection and removes its local sign-in. `adelin logout --local-only` removes only the local sign-in; it does not revoke the app grant. Revoking the connection in account settings ends its app grants. Follow [private local output](#private-local-output) for deliberately written credential files, their handling and rotation.
|
|
26
26
|
|
|
27
27
|
## Choose and open an app
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
At sign-in the builder chooses **All apps, including new ones** (the default) or **Only selected apps**. Apps you create are always usable by that connection. **Settings → Connected code agents → Manage apps** adds or removes apps and switches mode without signing in again. With all apps, the connection can do what the builder's current role allows in each app, checked on every call, so a role change narrows or widens it at once. With selected apps, each app keeps the capabilities approved for it, and the builder's current role can only narrow them. Live stream keys need a separate opt-in at sign-in. `connection_status` reports `scope` (`all_apps` or `selected`) and project setup state. When signed out, tools answer `SIGN_IN_REQUIRED`: tell the builder to run `adelin login`; the Adelin tools appear shortly after login without restarting the agent.
|
|
30
30
|
|
|
31
|
-
Call `list_editable_apps` (`limit` 1–25, default 10, and `nextCursor` as `cursor`) or `select_app(app_id)` to choose an allowed app. `select_app` returns `app` or `APP_NOT_EDITABLE`. Arguments outside a tool's input schema, on any tool, return `{ok:false,error:{code:"INVALID_ARGUMENT",message}}` with `isError: true` and change nothing. The message names the first wrong field and what was expected, for example `mode is not accepted for entry.patch` or `payload.patch.title: expected string`, and never repeats the value sent; correct that field and call again. The `library_mutate` description lists each action's payload and which actions accept `mode`.
|
|
31
|
+
Call `list_editable_apps` (`limit` 1–25, default 10, and `nextCursor` as `cursor`) or `select_app(app_id)` to choose an allowed app. `select_app` returns `app` or `APP_NOT_EDITABLE`. Arguments outside a tool's input schema, on any tool, return `{ok:false,error:{code:"INVALID_ARGUMENT",message}}` with `isError: true` and change nothing. The message names the first wrong field and what was expected, for example `mode is not accepted for entry.patch` or `payload.patch.title: expected string`, and never repeats the value sent; correct that field and call again. The `library_mutate` description lists each action's payload and which actions accept `mode`. To make a new app, follow [create an app](#create-an-app).
|
|
32
|
+
|
|
33
|
+
### Create an app {#create-an-app}
|
|
34
|
+
|
|
35
|
+
Ask one thing at a time, in this order:
|
|
36
|
+
|
|
37
|
+
1. The app name.
|
|
38
|
+
2. A template or from scratch. Call `list_app_templates` (`id`, `name`, `description`, `digest`, `sampleContent`, `devices`, `previewUrl`, `tvPreviewUrl`) and offer each with its name, a one-line description and its preview link.
|
|
39
|
+
3. For scratch only: the languages (first is primary, 1–20) and the sample content (`Movies`, `Series`, `Courses`, `Travel`) or none.
|
|
40
|
+
4. The devices (`mobile`, `web`, `tv`).
|
|
41
|
+
5. The organization, only when `list_app_organizations` returns more than one (it shows `appCount` and `appLimit` for each).
|
|
42
|
+
|
|
43
|
+
Then call `create_app {organization_id, name, devices, start}`, where `start` is `{template_id, template_digest}` or `{scratch: {languages, sample_content}}`. A result of `ready` carries the app: call `open_app`. `create_app` waits up to about 45 seconds. A result of `waiting` carries `app_id` and `creation_id`: call `resume_app_creation` with both until it is ready. A `failed` result after the app exists carries the same ids and the `idempotency_key`: follow its message, and when it says to retry later, call `resume_app_creation` rather than creating another app. A scratch app opens as an empty workspace; the first successful build makes it renderable.
|
|
44
|
+
|
|
45
|
+
On an error, give the builder its message. `APP_PLAN_LIMIT`: give them the `upgradeUrl`. `TEMPLATE_CHANGED`: call `list_app_templates` again and confirm the template. `ORG_NOT_MANAGEABLE`: choose another organization. When the error includes `idempotency_key`, pass it as `idempotency_key` when retrying so the app is not created twice.
|
|
32
46
|
|
|
33
47
|
Call `open_app(app_id, workspace)` with an absolute or project-relative folder for local source. For a new workspace, the CLI transfers an authenticated checkout directly, verifies its chunks and app identity, and installs the files into an empty destination. For an existing workspace, it validates the app identity and reuses the files, base versions and pending journal. Reopening does not refresh or overwrite local edits. It opens the one edit session for that app and returns bounded outcomes without source bytes or lease credentials. If the builder has the app open in App Creator with an idle chat, opening it hands the app to you, and App Creator shows your work while you have it. An occupied app returns `conflict` with a retry time and a message naming who holds it (a chat reply in progress, another person, another agent); do not open a second editor to bypass it.
|
|
34
48
|
|
|
35
|
-
For content inspection without editing, use the bounded library reads below. A library-only account can approve `library.view` without `ai.manage`, open_app, a checkout or an edit lease. Do not use `list_editable_apps` as a library eligibility test. Supply
|
|
49
|
+
For content inspection without editing, use the bounded library reads below. A library-only account can approve `library.view` without `ai.manage`, open_app, a checkout or an edit lease. Do not use `list_editable_apps` as a library eligibility test. Supply an allowed app ID on each call; editing selection does not supply it implicitly.
|
|
36
50
|
|
|
37
51
|
For opening, resuming, recording progress and correcting working context, follow the
|
|
38
52
|
[shared app-memory guide](app-memory.md). `open_app` returns fresh accepted requirements
|
|
@@ -107,7 +121,7 @@ File versions are allocated by the server. Failed attempts can leave gaps, so ve
|
|
|
107
121
|
|
|
108
122
|
## Bounded library reads
|
|
109
123
|
|
|
110
|
-
|
|
124
|
+
Reads need a connection that covers the app (all apps, or the app selected with `library.view`). Current `library.view` permission is checked on every page. Manage permission never implies view permission, and a token or cursor never replaces current authority. Every CLI command requires `--app UUID`; every local MCP call requires `app_id: UUID`. Commands carry no server URL: the released CLI always talks to Adelin's server, and a development build of the CLI targets a local server and also accepts `--url`. Do not supply an actor, grant or credential in read arguments.
|
|
111
125
|
|
|
112
126
|
| CLI syntax | Local MCP operation | Result |
|
|
113
127
|
|---|---|---|
|
|
@@ -133,7 +147,7 @@ How file fields read on a published entry is described under Entry files.
|
|
|
133
147
|
|
|
134
148
|
A page stops adding rows once its JSON envelope would pass 32768 UTF-8 bytes (32 KiB), so a page fits a coding client's tool-output limit; about 45 tree rows fit. `returned` is then below `limit` while `nextCursor` is set: keep paging. Publish candidates page by `limit` alone. A page always carries at least one row, the complete envelope is limited to 262144 bytes (256 KiB), and each indivisible row or entry core to 65536 bytes (64 KiB). Each collection permits at most 5000 rows, and projected snapshots at most 8388608 bytes (8 MiB). Oversized items fail with `READ_ITEM_TOO_LARGE`; tree or snapshot overflow uses `LIBRARY_TREE_TOO_LARGE` or `READ_SNAPSHOT_TOO_LARGE`, never silent truncation. Transport responses are capped at 4194304 bytes with a 30-second deadline and at most one authentication refresh.
|
|
135
149
|
|
|
136
|
-
The CLI writes exactly one JSON envelope and newline to stdout: `{ok:true,operation,appId,data}` with exit 0, or `{ok:false,error:{code,message}}` with exit 1. Help is text with exit 0. MCP returns the same JSON in one text block and `isError: !ok`. Errors do not include raw remote text, credentials or internal diagnostics. `AUTH_REQUIRED` requires login; `ACCESS_DENIED` requires reviewing
|
|
150
|
+
The CLI writes exactly one JSON envelope and newline to stdout: `{ok:true,operation,appId,data}` with exit 0, or `{ok:false,error:{code,message}}` with exit 1. Help is text with exit 0. MCP returns the same JSON in one text block and `isError: !ok`. Errors do not include raw remote text, credentials or internal diagnostics. `AUTH_REQUIRED` requires login; `ACCESS_DENIED` requires reviewing the connection's app access in Settings → Connected code agents. `APP_SELECTION_CHANGED` means app access changed while the request ran: retry once, then run `adelin login` if it repeats. `TOOL_UNAVAILABLE` means this connection was not granted the tool; run `adelin login` and approve the access it needs. `INTERACTION_COMPLETED` means an old approval cannot be replayed. `NOT_FOUND` does not distinguish missing from foreign objects. Correct `INVALID_ARGUMENT` input; do not blindly retry size, stale-state or permission errors.
|
|
137
151
|
|
|
138
152
|
## Sample content import
|
|
139
153
|
|
|
@@ -202,7 +202,9 @@ platforms the builder requested. Keep device frames when chosen. Label every fra
|
|
|
202
202
|
screen and alternative, for example “TV · Home · B” or “Phone · Sign-in · A”, so feedback identifies
|
|
203
203
|
an exact design. A TV group must contain TV-oriented layouts and sign-in, never a phone form
|
|
204
204
|
relabelled as TV. Use platform-specific frame styles; resizing the surrounding board must not turn
|
|
205
|
-
a TV frame into a phone layout. The
|
|
205
|
+
a TV frame into a phone layout. The viewer supplies Fit all, zoom and pan for the complete board;
|
|
206
|
+
keep device frames at their intended logical sizes and let the builder zoom in to inspect them.
|
|
207
|
+
Do not add your own navigation script or shrink every screen to fit the builder's browser window.
|
|
206
208
|
Show the alternatives together, without separate simulated device viewports or a static viewport
|
|
207
209
|
picker. Keep every frame readable rather than shrinking the entire board to one device's size.
|
|
208
210
|
|