@agimon-ai/po-ios 0.0.1-alpha.2 → 0.0.1-alpha.21
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/README.md +13 -3
- package/dist/apiContracts.cjs +190 -4
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +0 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +188 -3
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{contracts-DH0gdDYT.mjs → contracts-BQjfOjy0.mjs} +3 -2
- package/dist/{contracts-DH0gdDYT.mjs.map → contracts-BQjfOjy0.mjs.map} +1 -1
- package/dist/{contracts-BsO_lEi8.cjs → contracts-EZxEDrrj.cjs} +8 -1
- package/dist/{contracts-BsO_lEi8.cjs.map → contracts-EZxEDrrj.cjs.map} +1 -1
- package/dist/extensions/native.mjs +1310 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +786 -41
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +789 -44
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +1025 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +50 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +54 -7
- package/src/prompts/codemode-how-to-ios/SKILL.md +16 -1
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
const require_contracts = require("../contracts-
|
|
27
|
+
const require_contracts = require("../contracts-EZxEDrrj.cjs");
|
|
28
28
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
29
29
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
30
30
|
let _agimon_ai_po_db = require("@agimon-ai/po-db");
|
|
@@ -36,10 +36,13 @@ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
|
|
|
36
36
|
let node_crypto = require("node:crypto");
|
|
37
37
|
let node_child_process = require("node:child_process");
|
|
38
38
|
let node_net = require("node:net");
|
|
39
|
+
let _agimon_ai_po_artifact_artifactFiles = require("@agimon-ai/po-artifact/artifactFiles");
|
|
39
40
|
let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
|
|
40
41
|
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
42
|
+
let _agimon_ai_po_core_packageApi = require("@agimon-ai/po-core/packageApi");
|
|
41
43
|
let typebox_value = require("typebox/value");
|
|
42
44
|
let typebox = require("typebox");
|
|
45
|
+
let _agimon_ai_po_core_pluginProtocol = require("@agimon-ai/po-core/pluginProtocol");
|
|
43
46
|
//#region src/services/iosError/index.ts
|
|
44
47
|
/** Every failure a script can branch on carries a stable `code`; the message says what to do next. */
|
|
45
48
|
var IosError = class extends Error {
|
|
@@ -819,6 +822,7 @@ function resolvePoolConfig(raw) {
|
|
|
819
822
|
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
820
823
|
function createDevicePool(options) {
|
|
821
824
|
const { store, simctl, probe, config, serverId } = options;
|
|
825
|
+
const availability = { ...options.availability };
|
|
822
826
|
const now = options.now ?? Date.now;
|
|
823
827
|
const pollMs = options.pollMs ?? 750;
|
|
824
828
|
const notice = (message) => options.onNotice?.(`iOS pool: ${message}`);
|
|
@@ -1228,6 +1232,7 @@ function createDevicePool(options) {
|
|
|
1228
1232
|
const lease = leases.get(device.udid);
|
|
1229
1233
|
return {
|
|
1230
1234
|
...device,
|
|
1235
|
+
availability: availability[device.udid] ?? "available",
|
|
1231
1236
|
leased: lease !== void 0,
|
|
1232
1237
|
...lease !== void 0 && lease.owner_root === owner ? { leaseId: lease.lease_id } : {}
|
|
1233
1238
|
};
|
|
@@ -1237,6 +1242,9 @@ function createDevicePool(options) {
|
|
|
1237
1242
|
requireSupported();
|
|
1238
1243
|
if (stopped) throw new IosError("IOS_POOL_BUSY", "The iOS pool is stopping.");
|
|
1239
1244
|
signal?.throwIfAborted();
|
|
1245
|
+
const existing = (await store.leasesOf(owner)).find((lease) => lease.kind === "device" && lease.udid === udid);
|
|
1246
|
+
if (existing !== void 0) return view(existing);
|
|
1247
|
+
if (availability[udid] === "excluded") throw new IosError("IOS_INVALID_ARGUMENT", "This phone is excluded from Po in the active global iOS settings.");
|
|
1240
1248
|
const devicectl = requireDevicectl();
|
|
1241
1249
|
const device = (await devicectl.listDevices(signal)).find((candidate) => candidate.udid === udid);
|
|
1242
1250
|
if (device === void 0) throw new IosError("IOS_INVALID_ARGUMENT", `No physical device ${udid} is visible. Call ios.devices() to list them.`);
|
|
@@ -1296,11 +1304,11 @@ function createDevicePool(options) {
|
|
|
1296
1304
|
}
|
|
1297
1305
|
//#endregion
|
|
1298
1306
|
//#region src/services/simHelper/index.ts
|
|
1299
|
-
const unavailable$
|
|
1307
|
+
const unavailable$2 = (message) => new IosError("IOS_HELPER_UNAVAILABLE", message);
|
|
1300
1308
|
function replyError(error) {
|
|
1301
1309
|
const code = typeof error?.code === "string" ? error.code : "";
|
|
1302
1310
|
const message = typeof error?.message === "string" ? error.message : "The iOS helper failed.";
|
|
1303
|
-
return require_contracts.IOS_ERROR_CODES.includes(code) ? new IosError(code, message) : unavailable$
|
|
1311
|
+
return require_contracts.IOS_ERROR_CODES.includes(code) ? new IosError(code, message) : unavailable$2(`${code ? `${code}: ` : ""}${message}`);
|
|
1304
1312
|
}
|
|
1305
1313
|
/**
|
|
1306
1314
|
* Client for the resident Swift helper. Requests dispatch in order, matched by id. A timeout stops the process;
|
|
@@ -1328,7 +1336,7 @@ function createSimHelper(options) {
|
|
|
1328
1336
|
const failAll = (error, target) => {
|
|
1329
1337
|
for (const [id, entry] of pending) if (target === void 0 || entry.target === target) take(id)?.reject(error);
|
|
1330
1338
|
};
|
|
1331
|
-
const stop = (target, error = unavailable$
|
|
1339
|
+
const stop = (target, error = unavailable$2("The iOS helper stopped; it restarts on the next call.")) => {
|
|
1332
1340
|
if (current === target) {
|
|
1333
1341
|
current = void 0;
|
|
1334
1342
|
dispatch = Promise.resolve();
|
|
@@ -1339,7 +1347,7 @@ function createSimHelper(options) {
|
|
|
1339
1347
|
};
|
|
1340
1348
|
const send = (target, op, udid, params, signal) => new Promise((resolve, reject) => {
|
|
1341
1349
|
if (disposed || current !== target) {
|
|
1342
|
-
reject(unavailable$
|
|
1350
|
+
reject(unavailable$2("The iOS helper is not running."));
|
|
1343
1351
|
return;
|
|
1344
1352
|
}
|
|
1345
1353
|
if (signal?.aborted) {
|
|
@@ -1350,7 +1358,7 @@ function createSimHelper(options) {
|
|
|
1350
1358
|
const aborted = () => take(id)?.reject(signal?.reason);
|
|
1351
1359
|
const timer = setTimeout(() => {
|
|
1352
1360
|
if (current === target) starting = void 0;
|
|
1353
|
-
stop(target, unavailable$
|
|
1361
|
+
stop(target, unavailable$2(`The iOS helper did not answer ${op} within ${String(timeoutMs)} ms. It restarts on the next call.`));
|
|
1354
1362
|
}, timeoutMs);
|
|
1355
1363
|
pending.set(id, {
|
|
1356
1364
|
target,
|
|
@@ -1380,10 +1388,10 @@ function createSimHelper(options) {
|
|
|
1380
1388
|
const launch = async (rebuild) => {
|
|
1381
1389
|
const recent = starts.filter((started) => now() - started < require_contracts.HELPER_RESTART_WINDOW_MS);
|
|
1382
1390
|
starts.splice(0, starts.length, ...recent);
|
|
1383
|
-
if (starts.length >= 3) throw unavailable$
|
|
1391
|
+
if (starts.length >= 3) throw unavailable$2("The iOS helper keeps failing; it restarted three times in five minutes. Try again later.");
|
|
1384
1392
|
starts.push(now());
|
|
1385
1393
|
const binary = await options.binary(rebuild);
|
|
1386
|
-
if (disposed) throw unavailable$
|
|
1394
|
+
if (disposed) throw unavailable$2("The iOS helper is shut down.");
|
|
1387
1395
|
const spawned = options.spawn(binary);
|
|
1388
1396
|
current = spawned;
|
|
1389
1397
|
spawned.onLine((line) => {
|
|
@@ -1407,12 +1415,12 @@ function createSimHelper(options) {
|
|
|
1407
1415
|
starting = void 0;
|
|
1408
1416
|
dispatch = Promise.resolve();
|
|
1409
1417
|
}
|
|
1410
|
-
failAll(unavailable$
|
|
1418
|
+
failAll(unavailable$2(`The iOS helper exited (code ${String(code)}); it restarts on the next call.`), spawned);
|
|
1411
1419
|
});
|
|
1412
1420
|
let probe;
|
|
1413
1421
|
try {
|
|
1414
1422
|
const result = await send(spawned, "probe", void 0, {});
|
|
1415
|
-
if (result === null || typeof result !== "object" || !("protocolVersion" in result) || !Number.isInteger(result.protocolVersion) || !("missing" in result) || !Array.isArray(result.missing) || !result.missing.every((capability) => typeof capability === "string")) throw unavailable$
|
|
1423
|
+
if (result === null || typeof result !== "object" || !("protocolVersion" in result) || !Number.isInteger(result.protocolVersion) || !("missing" in result) || !Array.isArray(result.missing) || !result.missing.every((capability) => typeof capability === "string")) throw unavailable$2("The iOS helper returned an invalid probe.");
|
|
1416
1424
|
probe = result;
|
|
1417
1425
|
} catch (error) {
|
|
1418
1426
|
await stop(spawned);
|
|
@@ -1420,7 +1428,7 @@ function createSimHelper(options) {
|
|
|
1420
1428
|
}
|
|
1421
1429
|
if (probe.protocolVersion !== 1) {
|
|
1422
1430
|
await stop(spawned);
|
|
1423
|
-
if (rebuild) throw unavailable$
|
|
1431
|
+
if (rebuild) throw unavailable$2(`The iOS helper speaks protocol ${String(probe.protocolVersion)}, not ${String(1)}, even after a rebuild.`);
|
|
1424
1432
|
return launch(true);
|
|
1425
1433
|
}
|
|
1426
1434
|
return {
|
|
@@ -1430,7 +1438,7 @@ function createSimHelper(options) {
|
|
|
1430
1438
|
};
|
|
1431
1439
|
const ready = async () => {
|
|
1432
1440
|
await stopping;
|
|
1433
|
-
if (disposed) throw unavailable$
|
|
1441
|
+
if (disposed) throw unavailable$2("The iOS helper is shut down.");
|
|
1434
1442
|
if (starting === void 0) {
|
|
1435
1443
|
const attempt = launch(false).catch((error) => {
|
|
1436
1444
|
if (starting === attempt) starting = void 0;
|
|
@@ -1459,7 +1467,7 @@ function createSimHelper(options) {
|
|
|
1459
1467
|
},
|
|
1460
1468
|
async dispose() {
|
|
1461
1469
|
disposed = true;
|
|
1462
|
-
if (current !== void 0) await stop(current, unavailable$
|
|
1470
|
+
if (current !== void 0) await stop(current, unavailable$2("The iOS helper is shut down."));
|
|
1463
1471
|
else await stopping;
|
|
1464
1472
|
}
|
|
1465
1473
|
};
|
|
@@ -1470,7 +1478,7 @@ const PORT = 47100;
|
|
|
1470
1478
|
const RUNNER_BUNDLE = "ai.agimon.po.iosrunner";
|
|
1471
1479
|
const BUILD_TIMEOUT_MS = 3e5;
|
|
1472
1480
|
const RUN_TIMEOUT_MS = 6048e5;
|
|
1473
|
-
const unavailable = (message) => new IosError("IOS_HELPER_UNAVAILABLE", message);
|
|
1481
|
+
const unavailable$1 = (message) => new IosError("IOS_HELPER_UNAVAILABLE", message);
|
|
1474
1482
|
/** Signed XCUITest sessions, one per leased physical device. Host access stays injected. */
|
|
1475
1483
|
function createDeviceRunner(options) {
|
|
1476
1484
|
const sessions = /* @__PURE__ */ new Map();
|
|
@@ -1483,7 +1491,7 @@ function createDeviceRunner(options) {
|
|
|
1483
1491
|
};
|
|
1484
1492
|
const stopSession = (udid, session) => {
|
|
1485
1493
|
session.stopping ??= Promise.resolve().then(async () => {
|
|
1486
|
-
session.controller.abort(unavailable("The device runner stopped."));
|
|
1494
|
+
session.controller.abort(unavailable$1("The device runner stopped."));
|
|
1487
1495
|
await session.socket?.kill();
|
|
1488
1496
|
await session.command?.catch(() => void 0);
|
|
1489
1497
|
await uninstall(udid, session);
|
|
@@ -1498,7 +1506,7 @@ function createDeviceRunner(options) {
|
|
|
1498
1506
|
};
|
|
1499
1507
|
const clean = (udid, session) => {
|
|
1500
1508
|
session.cleanup ??= Promise.resolve().then(async () => {
|
|
1501
|
-
session.controller.abort(unavailable("The device runner stopped."));
|
|
1509
|
+
session.controller.abort(unavailable$1("The device runner stopped."));
|
|
1502
1510
|
const helper = session.helper;
|
|
1503
1511
|
session.helper = void 0;
|
|
1504
1512
|
if (helper) await helper.dispose();
|
|
@@ -1514,15 +1522,15 @@ function createDeviceRunner(options) {
|
|
|
1514
1522
|
launched.delete(udid);
|
|
1515
1523
|
const session = sessions.get(udid);
|
|
1516
1524
|
if (!session) return;
|
|
1517
|
-
session.controller.abort(unavailable("The device runner was released."));
|
|
1525
|
+
session.controller.abort(unavailable$1("The device runner was released."));
|
|
1518
1526
|
await session.ready.catch(() => void 0);
|
|
1519
1527
|
await clean(udid, session);
|
|
1520
1528
|
};
|
|
1521
1529
|
const start = async (udid, session) => {
|
|
1522
1530
|
const { signal } = session.controller;
|
|
1523
|
-
const timeout = setTimeout(() => session.controller.abort(unavailable("The device runner startup timed out.")), options.startupTimeoutMs ?? 42e4);
|
|
1531
|
+
const timeout = setTimeout(() => session.controller.abort(unavailable$1("The device runner startup timed out.")), options.startupTimeoutMs ?? 42e4);
|
|
1524
1532
|
try {
|
|
1525
|
-
if (!options.developmentTeam?.trim()) throw unavailable("Configure ios.device.developmentTeam before using accessibility on a physical device.");
|
|
1533
|
+
if (!options.developmentTeam?.trim()) throw unavailable$1("Configure ios.device.developmentTeam before using accessibility on a physical device.");
|
|
1526
1534
|
signal.throwIfAborted();
|
|
1527
1535
|
const directory = `${options.cacheRoot}/${(0, node_crypto.randomUUID)()}`;
|
|
1528
1536
|
await options.files.createDir(directory);
|
|
@@ -1554,11 +1562,11 @@ function createDeviceRunner(options) {
|
|
|
1554
1562
|
session.command = building.then(() => void 0);
|
|
1555
1563
|
session.command.catch(() => void 0);
|
|
1556
1564
|
const built = await building;
|
|
1557
|
-
if (built.exitCode !== 0) throw unavailable(`The device runner failed to build:\n${(built.stderr || built.stdout).slice(-2e3)}`);
|
|
1565
|
+
if (built.exitCode !== 0) throw unavailable$1(`The device runner failed to build:\n${(built.stderr || built.stdout).slice(-2e3)}`);
|
|
1558
1566
|
signal.throwIfAborted();
|
|
1559
1567
|
const products = `${derived}/Build/Products`;
|
|
1560
1568
|
const testRuns = (await options.files.list(products)).filter((name) => name.endsWith(".xctestrun"));
|
|
1561
|
-
if (testRuns.length !== 1) throw unavailable("Expected one built XCUITest run configuration.");
|
|
1569
|
+
if (testRuns.length !== 1) throw unavailable$1("Expected one built XCUITest run configuration.");
|
|
1562
1570
|
const token = (0, node_crypto.randomBytes)(32).toString("hex");
|
|
1563
1571
|
let host;
|
|
1564
1572
|
let ready = false;
|
|
@@ -1604,7 +1612,7 @@ function createDeviceRunner(options) {
|
|
|
1604
1612
|
});
|
|
1605
1613
|
while (true) {
|
|
1606
1614
|
signal.throwIfAborted();
|
|
1607
|
-
if (session.exited) throw unavailable("xcodebuild exited before the device runner was ready.");
|
|
1615
|
+
if (session.exited) throw unavailable$1("xcodebuild exited before the device runner was ready.");
|
|
1608
1616
|
status(await options.readStatus(resultBundle));
|
|
1609
1617
|
signal.throwIfAborted();
|
|
1610
1618
|
if (host && ready) break;
|
|
@@ -1647,7 +1655,7 @@ function createDeviceRunner(options) {
|
|
|
1647
1655
|
const helper = createSimHelper({
|
|
1648
1656
|
binary: async () => {
|
|
1649
1657
|
signal.throwIfAborted();
|
|
1650
|
-
if (used) throw unavailable("The device runner disconnected; release and acquire the device again.");
|
|
1658
|
+
if (used) throw unavailable$1("The device runner disconnected; release and acquire the device again.");
|
|
1651
1659
|
used = true;
|
|
1652
1660
|
return "device-runner";
|
|
1653
1661
|
},
|
|
@@ -1659,7 +1667,7 @@ function createDeviceRunner(options) {
|
|
|
1659
1667
|
session.helper = helper;
|
|
1660
1668
|
await helper.probe(signal);
|
|
1661
1669
|
signal.throwIfAborted();
|
|
1662
|
-
if (session.exited) throw unavailable("xcodebuild exited during the device runner handshake.");
|
|
1670
|
+
if (session.exited) throw unavailable$1("xcodebuild exited during the device runner handshake.");
|
|
1663
1671
|
return {
|
|
1664
1672
|
probe: (requestSignal) => helper.probe(requestSignal),
|
|
1665
1673
|
observe: (target, requestSignal) => helper.observe(target, requestSignal),
|
|
@@ -1679,7 +1687,7 @@ function createDeviceRunner(options) {
|
|
|
1679
1687
|
};
|
|
1680
1688
|
const service = {
|
|
1681
1689
|
get(udid, signal) {
|
|
1682
|
-
if (disposed) return Promise.reject(unavailable("The device runner service is shut down."));
|
|
1690
|
+
if (disposed) return Promise.reject(unavailable$1("The device runner service is shut down."));
|
|
1683
1691
|
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
1684
1692
|
const existing = sessions.get(udid);
|
|
1685
1693
|
if (existing?.cleanupError !== void 0) return Promise.reject(existing.cleanupError);
|
|
@@ -1959,17 +1967,24 @@ async function connectTcp(options) {
|
|
|
1959
1967
|
async function readIosSettings(fs, poHome, onNotice) {
|
|
1960
1968
|
const file = node_path.default.join(poHome, "config.yaml");
|
|
1961
1969
|
const text = await fs.readTextFile(file, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT);
|
|
1962
|
-
if (!text.ok) return {
|
|
1970
|
+
if (!text.ok) return {
|
|
1971
|
+
pool: resolvePoolConfig(void 0),
|
|
1972
|
+
availability: {}
|
|
1973
|
+
};
|
|
1963
1974
|
try {
|
|
1964
1975
|
const ios = (0, _agimon_ai_po_config.parsePoConfig)(text.value, file, { lenient: true }).config.ios;
|
|
1965
1976
|
return {
|
|
1966
1977
|
pool: resolvePoolConfig(ios?.pool),
|
|
1967
1978
|
...ios?.helperPath ? { helperPath: ios.helperPath } : {},
|
|
1968
|
-
...ios?.device?.developmentTeam ? { developmentTeam: ios.device.developmentTeam } : {}
|
|
1979
|
+
...ios?.device?.developmentTeam ? { developmentTeam: ios.device.developmentTeam } : {},
|
|
1980
|
+
availability: ios?.device?.availability ?? {}
|
|
1969
1981
|
};
|
|
1970
1982
|
} catch (error) {
|
|
1971
1983
|
onNotice(`iOS pool: ignoring ios settings in ${file}: ${error.message}`);
|
|
1972
|
-
return {
|
|
1984
|
+
return {
|
|
1985
|
+
pool: resolvePoolConfig(void 0),
|
|
1986
|
+
availability: {}
|
|
1987
|
+
};
|
|
1973
1988
|
}
|
|
1974
1989
|
}
|
|
1975
1990
|
/** The resident accessibility helper, built on first use from the package's Swift sources. */
|
|
@@ -2010,6 +2025,7 @@ async function activatePool(activation) {
|
|
|
2010
2025
|
const deviceSet = node_path.default.join(poHome, "ios", require_contracts.IOS_DEVICE_SET_DIRECTORY);
|
|
2011
2026
|
const onNotice = (message) => activation.host.context.onNotice(message);
|
|
2012
2027
|
let pool;
|
|
2028
|
+
let runtime;
|
|
2013
2029
|
const provider = activation.context.inject([
|
|
2014
2030
|
_agimon_ai_po_db.PO_DB_SERVICE,
|
|
2015
2031
|
_agimon_ai_po_core_platform.PO_FS_SERVICE,
|
|
@@ -2023,6 +2039,14 @@ async function activatePool(activation) {
|
|
|
2023
2039
|
const run = createShellRunner((0, _agimon_ai_po_core_platform.requirePoShell)(injected), environment);
|
|
2024
2040
|
const store = createPoolStore(db.database);
|
|
2025
2041
|
const settings = await readIosSettings(fs, poHome, onNotice);
|
|
2042
|
+
runtime = {
|
|
2043
|
+
configFile: node_path.default.join(poHome, "config.yaml"),
|
|
2044
|
+
applied: {
|
|
2045
|
+
pool: settings.pool,
|
|
2046
|
+
...settings.developmentTeam ? { developmentTeam: settings.developmentTeam } : {},
|
|
2047
|
+
availability: settings.availability
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2026
2050
|
const serverId = crypto.randomUUID();
|
|
2027
2051
|
const devicectl = createDeviceCtl({
|
|
2028
2052
|
run,
|
|
@@ -2068,6 +2092,7 @@ async function activatePool(activation) {
|
|
|
2068
2092
|
simctl: createSimctl(run, deviceSet),
|
|
2069
2093
|
probe: createNodeProcessProbe(run),
|
|
2070
2094
|
config: settings.pool,
|
|
2095
|
+
availability: runtime.applied.availability,
|
|
2071
2096
|
serverId,
|
|
2072
2097
|
helper: createHelper({
|
|
2073
2098
|
run,
|
|
@@ -2086,7 +2111,12 @@ async function activatePool(activation) {
|
|
|
2086
2111
|
});
|
|
2087
2112
|
await pool.start();
|
|
2088
2113
|
}
|
|
2089
|
-
|
|
2114
|
+
const releasePool = await activation.provide(require_contracts.IOS_POOL_CONTRACT, pool);
|
|
2115
|
+
const releaseSettings = await activation.provide(require_contracts.IOS_SETTINGS_CONTRACT, runtime);
|
|
2116
|
+
return async () => {
|
|
2117
|
+
await releaseSettings();
|
|
2118
|
+
await releasePool();
|
|
2119
|
+
};
|
|
2090
2120
|
});
|
|
2091
2121
|
try {
|
|
2092
2122
|
await provider.await();
|
|
@@ -2101,9 +2131,23 @@ async function activatePool(activation) {
|
|
|
2101
2131
|
};
|
|
2102
2132
|
}
|
|
2103
2133
|
/** Every non-session installation offers its pool to the host's existing global ownership registry. */
|
|
2104
|
-
function createIosGlobalRoot(plugin, level = "global") {
|
|
2134
|
+
async function createIosGlobalRoot(plugin, level = "global") {
|
|
2135
|
+
let scope;
|
|
2136
|
+
const binding = plugin.context.inject([_agimon_ai_po_core_serverPlugin.PO_SERVER_SCOPE_SERVICE], (injected) => {
|
|
2137
|
+
scope = (0, _agimon_ai_po_core_serverPlugin.requirePoServerScope)(injected);
|
|
2138
|
+
return () => {
|
|
2139
|
+
scope = void 0;
|
|
2140
|
+
};
|
|
2141
|
+
});
|
|
2142
|
+
await binding.await();
|
|
2105
2143
|
return {
|
|
2106
|
-
value:
|
|
2144
|
+
value: { resolveIosServices: () => ({
|
|
2145
|
+
pool: scope?.resolve(require_contracts.IOS_POOL_CONTRACT),
|
|
2146
|
+
runtime: scope?.resolve(require_contracts.IOS_SETTINGS_CONTRACT)
|
|
2147
|
+
}) },
|
|
2148
|
+
onDispose: async () => {
|
|
2149
|
+
await binding.dispose();
|
|
2150
|
+
},
|
|
2107
2151
|
onStart: () => {
|
|
2108
2152
|
if (plugin.host.scope !== level) return;
|
|
2109
2153
|
plugin.context.inject([_agimon_ai_po_core_serverPlugin.PO_GLOBAL_SERVICES_SERVICE], (injected) => (0, _agimon_ai_po_core_serverPlugin.readPoGlobalServices)(injected)?.register(plugin.host, {
|
|
@@ -2120,6 +2164,277 @@ var root_server_default$2 = (0, _agimon_ai_po_core_extensionFile.defineRoot)(cre
|
|
|
2120
2164
|
//#region src/extensions/workspaces/(backend)/root.server.ts
|
|
2121
2165
|
var root_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plugin) => createIosGlobalRoot(plugin, "workspace"), { inject: [_agimon_ai_po_db.PO_DB_CONTRACT] });
|
|
2122
2166
|
//#endregion
|
|
2167
|
+
//#region src/services/iosActivity/index.ts
|
|
2168
|
+
const MAX_FRAME_BYTES = 4194304;
|
|
2169
|
+
const PNG_SIGNATURE = [
|
|
2170
|
+
137,
|
|
2171
|
+
80,
|
|
2172
|
+
78,
|
|
2173
|
+
71,
|
|
2174
|
+
13,
|
|
2175
|
+
10,
|
|
2176
|
+
26,
|
|
2177
|
+
10
|
|
2178
|
+
];
|
|
2179
|
+
/** Reads only the root session's leases. Frame files are private scratch, never artifacts. */
|
|
2180
|
+
function createIosActivity(options) {
|
|
2181
|
+
const aborter = new AbortController();
|
|
2182
|
+
const pending = /* @__PURE__ */ new Map();
|
|
2183
|
+
const capture = async (leaseId, signal) => {
|
|
2184
|
+
const pool = options.pool();
|
|
2185
|
+
if (!pool || aborter.signal.aborted) return { state: "released" };
|
|
2186
|
+
const activeSignal = signal ? AbortSignal.any([aborter.signal, signal]) : aborter.signal;
|
|
2187
|
+
try {
|
|
2188
|
+
return await pool.withLease(options.owner, leaseId, async (lease) => {
|
|
2189
|
+
activeSignal.throwIfAborted();
|
|
2190
|
+
if (lease.kind !== "simulator") return {
|
|
2191
|
+
state: "capture-unavailable",
|
|
2192
|
+
message: "Physical iPhone screen capture is not available on this host."
|
|
2193
|
+
};
|
|
2194
|
+
const directory = await options.files.directory();
|
|
2195
|
+
if (!directory) return {
|
|
2196
|
+
state: "capture-unavailable",
|
|
2197
|
+
message: "This host has no private session frame storage."
|
|
2198
|
+
};
|
|
2199
|
+
const filePath = node_path.default.join(directory, `frame-${(0, node_crypto.randomUUID)()}.png`);
|
|
2200
|
+
let bytes;
|
|
2201
|
+
try {
|
|
2202
|
+
await pool.simctl.screenshot(lease.udid, filePath, require_contracts.SCREENSHOT_MAX_PIXELS, activeSignal);
|
|
2203
|
+
activeSignal.throwIfAborted();
|
|
2204
|
+
bytes = await options.files.read(filePath, MAX_FRAME_BYTES);
|
|
2205
|
+
if (!PNG_SIGNATURE.every((byte, index) => bytes[index] === byte)) throw new Error("Invalid frame image.");
|
|
2206
|
+
} finally {
|
|
2207
|
+
await options.files.remove(filePath);
|
|
2208
|
+
}
|
|
2209
|
+
activeSignal.throwIfAborted();
|
|
2210
|
+
if (options.pool() !== pool) return { state: "released" };
|
|
2211
|
+
await pool.resolveLease(options.owner, leaseId);
|
|
2212
|
+
activeSignal.throwIfAborted();
|
|
2213
|
+
if (options.pool() !== pool) return { state: "released" };
|
|
2214
|
+
const hash = (0, node_crypto.createHash)("sha256").update(bytes).digest("hex");
|
|
2215
|
+
return {
|
|
2216
|
+
state: "ok",
|
|
2217
|
+
src: `data:image/png;base64,${Buffer.from(bytes).toString("base64")}`,
|
|
2218
|
+
hash,
|
|
2219
|
+
capturedAt: Date.now()
|
|
2220
|
+
};
|
|
2221
|
+
});
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
if (aborter.signal.aborted || activeSignal.aborted) return { state: "released" };
|
|
2224
|
+
if (error instanceof IosError && ["IOS_NO_LEASE", "IOS_LEASE_LOST"].includes(error.code)) return { state: "released" };
|
|
2225
|
+
return {
|
|
2226
|
+
state: "error",
|
|
2227
|
+
message: "Po could not capture this simulator screen."
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
return {
|
|
2232
|
+
async read() {
|
|
2233
|
+
const pool = options.pool();
|
|
2234
|
+
if (!pool || aborter.signal.aborted) return {
|
|
2235
|
+
supported: false,
|
|
2236
|
+
devices: [],
|
|
2237
|
+
error: "The iOS pool is not running on this host."
|
|
2238
|
+
};
|
|
2239
|
+
const [status, phones, build] = await Promise.all([
|
|
2240
|
+
pool.status(options.owner),
|
|
2241
|
+
pool.devices(options.owner),
|
|
2242
|
+
options.latestBuild?.()
|
|
2243
|
+
]);
|
|
2244
|
+
if (aborter.signal.aborted || options.pool() !== pool) return {
|
|
2245
|
+
supported: false,
|
|
2246
|
+
devices: []
|
|
2247
|
+
};
|
|
2248
|
+
const devices = status.devices.map((device) => ({
|
|
2249
|
+
id: device.udid,
|
|
2250
|
+
name: device.label ?? device.name,
|
|
2251
|
+
kind: "simulator",
|
|
2252
|
+
detail: device.state,
|
|
2253
|
+
state: device.leaseId ? "owned" : device.leased ? "other-session" : "available",
|
|
2254
|
+
...device.leaseId ? { leaseId: device.leaseId } : {},
|
|
2255
|
+
capture: "available"
|
|
2256
|
+
}));
|
|
2257
|
+
devices.push(...phones.map((phone) => ({
|
|
2258
|
+
id: phone.udid,
|
|
2259
|
+
name: phone.name,
|
|
2260
|
+
kind: "device",
|
|
2261
|
+
detail: `${phone.model} · ${phone.osVersion}`,
|
|
2262
|
+
state: phone.leaseId ? "owned" : phone.leased ? "other-session" : phone.connected ? "available" : "disconnected",
|
|
2263
|
+
...phone.leaseId ? { leaseId: phone.leaseId } : {},
|
|
2264
|
+
capture: "unsupported"
|
|
2265
|
+
})));
|
|
2266
|
+
return {
|
|
2267
|
+
supported: status.supported,
|
|
2268
|
+
devices,
|
|
2269
|
+
...build ? { build } : {}
|
|
2270
|
+
};
|
|
2271
|
+
},
|
|
2272
|
+
async frame(leaseId, since, signal) {
|
|
2273
|
+
if (signal?.aborted || aborter.signal.aborted) return { state: "released" };
|
|
2274
|
+
let work = pending.get(leaseId);
|
|
2275
|
+
if (!work) {
|
|
2276
|
+
work = capture(leaseId, signal);
|
|
2277
|
+
pending.set(leaseId, work);
|
|
2278
|
+
}
|
|
2279
|
+
try {
|
|
2280
|
+
const reply = await work;
|
|
2281
|
+
if (signal?.aborted || aborter.signal.aborted) return { state: "released" };
|
|
2282
|
+
return reply.state === "ok" && reply.hash === since ? {
|
|
2283
|
+
state: "unchanged",
|
|
2284
|
+
hash: reply.hash,
|
|
2285
|
+
capturedAt: reply.capturedAt
|
|
2286
|
+
} : reply;
|
|
2287
|
+
} finally {
|
|
2288
|
+
if (pending.get(leaseId) === work) pending.delete(leaseId);
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
async dispose() {
|
|
2292
|
+
aborter.abort();
|
|
2293
|
+
await Promise.allSettled(pending.values());
|
|
2294
|
+
pending.clear();
|
|
2295
|
+
}
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
//#endregion
|
|
2299
|
+
//#region src/services/iosBuilds/index.ts
|
|
2300
|
+
function validPath(value) {
|
|
2301
|
+
return typeof value === "string" && value.length > 0 && !value.split("").some((character) => character === "\\" || character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127) && value.split("/").every((part) => part !== "" && part !== "." && part !== ".." && !part.includes(":"));
|
|
2302
|
+
}
|
|
2303
|
+
function invalidName(name) {
|
|
2304
|
+
return name.split("").some((character) => character === "/" || character === "\\" || character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127);
|
|
2305
|
+
}
|
|
2306
|
+
function view(build) {
|
|
2307
|
+
return {
|
|
2308
|
+
id: build.id,
|
|
2309
|
+
name: build.name,
|
|
2310
|
+
size: build.size,
|
|
2311
|
+
artifactPath: build.artifactPath,
|
|
2312
|
+
registeredAt: build.registeredAt
|
|
2313
|
+
};
|
|
2314
|
+
}
|
|
2315
|
+
function records(value, sessionId) {
|
|
2316
|
+
if (value === void 0 || value === null) return [];
|
|
2317
|
+
if (!Array.isArray(value)) throw new Error("Invalid iOS build registry.");
|
|
2318
|
+
return value.map((entry) => {
|
|
2319
|
+
const build = entry;
|
|
2320
|
+
if (!build || build.sessionId !== sessionId || typeof build.id !== "string" || !/^[a-zA-Z0-9_-]{16,128}$/u.test(build.id) || !validPath(build.artifactPath) || typeof build.name !== "string" || !build.name || invalidName(build.name) || typeof build.registeredAt !== "string" || !Number.isFinite(Date.parse(build.registeredAt)) || typeof build.identity !== "string" || !build.identity || !Number.isSafeInteger(build.size) || (build.size ?? -1) < 0) throw new Error("Invalid or foreign iOS build registry.");
|
|
2321
|
+
return build;
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
/** Registration is a trusted code-mode producer action, not inferred from artifact inventory. */
|
|
2325
|
+
function createIosBuilds(options) {
|
|
2326
|
+
let pending = Promise.resolve();
|
|
2327
|
+
const load = async () => records(await options.registry.read(), options.sessionId);
|
|
2328
|
+
const open = async (build) => {
|
|
2329
|
+
const opened = await options.openArtifact(build.artifactPath);
|
|
2330
|
+
if (opened.identity !== build.identity || opened.size !== build.size) {
|
|
2331
|
+
await opened.close();
|
|
2332
|
+
throw new Error("Registered iOS build changed.");
|
|
2333
|
+
}
|
|
2334
|
+
return opened;
|
|
2335
|
+
};
|
|
2336
|
+
return {
|
|
2337
|
+
artifactDirectory: options.artifactDirectory,
|
|
2338
|
+
async latest() {
|
|
2339
|
+
await pending;
|
|
2340
|
+
const build = (await load()).at(-1);
|
|
2341
|
+
if (build === void 0) return void 0;
|
|
2342
|
+
try {
|
|
2343
|
+
await (await open(build)).close();
|
|
2344
|
+
return view(build);
|
|
2345
|
+
} catch {
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
},
|
|
2349
|
+
register(input) {
|
|
2350
|
+
const work = pending.then(async () => {
|
|
2351
|
+
if (!validPath(input.artifactPath) || Object.keys(input).some((key) => key !== "artifactPath" && key !== "name")) throw new Error("Register an artifact-relative build path only.");
|
|
2352
|
+
const name = input.name ?? input.artifactPath.split("/").at(-1);
|
|
2353
|
+
if (typeof name !== "string" || !name.trim() || name.length > 255 || invalidName(name)) throw new Error("Invalid build name.");
|
|
2354
|
+
const opened = await options.openArtifact(input.artifactPath);
|
|
2355
|
+
const { size, identity } = opened;
|
|
2356
|
+
await opened.close();
|
|
2357
|
+
if (!Number.isSafeInteger(size) || size < 0 || !identity) throw new Error("Build must be a regular file.");
|
|
2358
|
+
const build = {
|
|
2359
|
+
id: crypto.randomUUID(),
|
|
2360
|
+
sessionId: options.sessionId,
|
|
2361
|
+
artifactPath: input.artifactPath,
|
|
2362
|
+
name,
|
|
2363
|
+
registeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2364
|
+
size,
|
|
2365
|
+
identity
|
|
2366
|
+
};
|
|
2367
|
+
await options.registry.write([build]);
|
|
2368
|
+
return view(build);
|
|
2369
|
+
});
|
|
2370
|
+
pending = work.catch(() => void 0);
|
|
2371
|
+
return work;
|
|
2372
|
+
},
|
|
2373
|
+
async share(buildId) {
|
|
2374
|
+
await pending;
|
|
2375
|
+
const build = (await load()).find((entry) => entry.id === buildId);
|
|
2376
|
+
if (build === void 0) return {
|
|
2377
|
+
ok: false,
|
|
2378
|
+
reason: "missing",
|
|
2379
|
+
message: "This build is not registered in this session."
|
|
2380
|
+
};
|
|
2381
|
+
try {
|
|
2382
|
+
await (await open(build)).close();
|
|
2383
|
+
} catch {
|
|
2384
|
+
return {
|
|
2385
|
+
ok: false,
|
|
2386
|
+
reason: "changed",
|
|
2387
|
+
message: "This build changed, was removed, or is no longer accessible. Register a new build."
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
if (options.shareRegisteredFile === void 0) return {
|
|
2391
|
+
ok: false,
|
|
2392
|
+
reason: "unavailable",
|
|
2393
|
+
message: "This host cannot share registered builds."
|
|
2394
|
+
};
|
|
2395
|
+
try {
|
|
2396
|
+
const shared = await options.shareRegisteredFile({
|
|
2397
|
+
fileName: build.name,
|
|
2398
|
+
open: () => open(build)
|
|
2399
|
+
});
|
|
2400
|
+
return {
|
|
2401
|
+
ok: true,
|
|
2402
|
+
url: shared.url,
|
|
2403
|
+
expiresAt: shared.expiresAt
|
|
2404
|
+
};
|
|
2405
|
+
} catch (error) {
|
|
2406
|
+
return error instanceof Error && error.message === _agimon_ai_po_core_packageApi.PO_SHARE_FILE_REMOTE_OFF_MESSAGE ? {
|
|
2407
|
+
ok: false,
|
|
2408
|
+
reason: "remote-off",
|
|
2409
|
+
message: "Remote access is off. Turn it on to download this build."
|
|
2410
|
+
} : {
|
|
2411
|
+
ok: false,
|
|
2412
|
+
reason: "unavailable",
|
|
2413
|
+
message: "This build cannot be shared right now."
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
}
|
|
2419
|
+
/** Durable latest-build slot in the existing shared DB, never in producer-writable artifacts. */
|
|
2420
|
+
async function createIosBuildRegistry(db, sessionId) {
|
|
2421
|
+
await db.migrate("ios_builds", [{
|
|
2422
|
+
version: 1,
|
|
2423
|
+
statements: ["CREATE TABLE ios_builds_latest (session_id TEXT PRIMARY KEY, registration_json TEXT NOT NULL)"]
|
|
2424
|
+
}]);
|
|
2425
|
+
return {
|
|
2426
|
+
async read() {
|
|
2427
|
+
const row = await db.database.get("SELECT registration_json FROM ios_builds_latest WHERE session_id = ?", sessionId);
|
|
2428
|
+
return row === void 0 ? void 0 : JSON.parse(row.registration_json);
|
|
2429
|
+
},
|
|
2430
|
+
async write(value) {
|
|
2431
|
+
const validated = records(value, sessionId);
|
|
2432
|
+
if (validated.length !== 1) throw new Error("Expected one latest registered iOS build.");
|
|
2433
|
+
await db.database.run("INSERT INTO ios_builds_latest (session_id, registration_json) VALUES (?, ?) ON CONFLICT(session_id) DO UPDATE SET registration_json = excluded.registration_json", sessionId, JSON.stringify(validated));
|
|
2434
|
+
}
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
//#endregion
|
|
2123
2438
|
//#region src/schemas/ios.ts
|
|
2124
2439
|
const BundleId = typebox.Type.String({ pattern: "^[A-Za-z0-9.-]{1,155}$" });
|
|
2125
2440
|
const LeaseId = typebox.Type.String({
|
|
@@ -2488,6 +2803,10 @@ interface ElementRef extends ElementQuery { ref?: string; nth?: number }
|
|
|
2488
2803
|
type Target = ElementRef | Point;
|
|
2489
2804
|
|
|
2490
2805
|
declare const ios: {
|
|
2806
|
+
/** Host-owned artifact destination. Save a completed build here before registerBuild. */
|
|
2807
|
+
buildDirectory(): Promise<{ path: string }>;
|
|
2808
|
+
/** Explicit producer registration, artifact-relative path only. Does not publish a URL or prove install eligibility. */
|
|
2809
|
+
registerBuild(input: { artifactPath: string; name?: string }): Promise<{ id: string; name: string; size: number; artifactPath: string; registeredAt: string }>;
|
|
2491
2810
|
/** The shared simulator pool: caps, devices, who holds them, and the queue. */
|
|
2492
2811
|
status(): Promise<IosStatus>;
|
|
2493
2812
|
/**
|
|
@@ -2601,6 +2920,30 @@ function createIosNamespace(options) {
|
|
|
2601
2920
|
return live.devicectl;
|
|
2602
2921
|
};
|
|
2603
2922
|
const members = Object.create(null);
|
|
2923
|
+
members.buildDirectory = async () => {
|
|
2924
|
+
run.signal.throwIfAborted();
|
|
2925
|
+
if (disposed) throw new Error("iOS namespace run is disposed.");
|
|
2926
|
+
const builds = await options.builds?.();
|
|
2927
|
+
run.signal.throwIfAborted();
|
|
2928
|
+
if (disposed) throw new Error("iOS namespace run is disposed.");
|
|
2929
|
+
if (builds === void 0) throw new IosError("IOS_UNSUPPORTED_HOST", "This host keeps no registered iOS builds.");
|
|
2930
|
+
return { path: builds.artifactDirectory };
|
|
2931
|
+
};
|
|
2932
|
+
members.registerBuild = async (input) => {
|
|
2933
|
+
run.signal.throwIfAborted();
|
|
2934
|
+
if (disposed) throw new Error("iOS namespace run is disposed.");
|
|
2935
|
+
const builds = await options.builds?.();
|
|
2936
|
+
run.signal.throwIfAborted();
|
|
2937
|
+
if (disposed) throw new Error("iOS namespace run is disposed.");
|
|
2938
|
+
if (builds === void 0) throw new IosError("IOS_UNSUPPORTED_HOST", "This host keeps no registered iOS builds.");
|
|
2939
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) throw new IosError("IOS_INVALID_ARGUMENT", "ios.registerBuild needs artifactPath and optional name.");
|
|
2940
|
+
const params = input;
|
|
2941
|
+
if (typeof params.artifactPath !== "string" || params.name !== void 0 && typeof params.name !== "string" || Object.keys(params).some((key) => key !== "artifactPath" && key !== "name")) throw new IosError("IOS_INVALID_ARGUMENT", "ios.registerBuild needs artifactPath and optional name only.");
|
|
2942
|
+
return builds.register({
|
|
2943
|
+
artifactPath: params.artifactPath,
|
|
2944
|
+
...params.name === void 0 ? {} : { name: params.name }
|
|
2945
|
+
});
|
|
2946
|
+
};
|
|
2604
2947
|
members.status = async () => pool().status(options.owner);
|
|
2605
2948
|
members.acquire = async (input) => {
|
|
2606
2949
|
const params = parse(AcquireSchema, input, "acquire");
|
|
@@ -2883,18 +3226,25 @@ function createIosNamespace(options) {
|
|
|
2883
3226
|
};
|
|
2884
3227
|
}
|
|
2885
3228
|
//#endregion
|
|
3229
|
+
//#region src/types/iosUi.ts
|
|
3230
|
+
/** JSON-only iOS UI contracts. Lease ownership and paths are resolved by the server. */
|
|
3231
|
+
const iosActivityChannel = "ios_activity";
|
|
3232
|
+
const iosActivityReaderEvent = "po-ios:activity-reader";
|
|
3233
|
+
//#endregion
|
|
2886
3234
|
//#region src/extensions/workspaces/sessions/(backend)/root.server.ts
|
|
2887
3235
|
const SCREENSHOTS_DIRECTORY = "ios-screenshots";
|
|
2888
|
-
/**
|
|
2889
|
-
* Contributes `ios` to code mode over the global pool. Leases belong to the root session, so subagents share
|
|
2890
|
-
* their parent's simulator; only the root's own disposal releases them. The pool, code mode and artifacts are
|
|
2891
|
-
* injected softly, so a session without them still mounts.
|
|
2892
|
-
*/
|
|
3236
|
+
/** Leases belong to the root session; build artifacts remain owned by their host session. */
|
|
2893
3237
|
var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context, host }) => {
|
|
2894
3238
|
const { sessionId, environment } = host.context;
|
|
2895
|
-
if (!sessionId)
|
|
3239
|
+
if (!sessionId) throw new Error("The iOS session UI requires a session identity.");
|
|
2896
3240
|
const owner = (0, _agimon_ai_po_core_childProcess.resolveRootSessionId)(sessionId, environment ?? {});
|
|
3241
|
+
let disposed = false;
|
|
2897
3242
|
let pool;
|
|
3243
|
+
let artifacts;
|
|
3244
|
+
let db;
|
|
3245
|
+
let temporaryDirectory;
|
|
3246
|
+
let builds;
|
|
3247
|
+
let preparingBuilds;
|
|
2898
3248
|
context.inject([require_contracts.IOS_POOL_SERVICE], (scoped) => {
|
|
2899
3249
|
const live = scoped.get(require_contracts.IOS_POOL_SERVICE);
|
|
2900
3250
|
pool = live;
|
|
@@ -2902,18 +3252,89 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
2902
3252
|
if (pool === live) pool = void 0;
|
|
2903
3253
|
};
|
|
2904
3254
|
});
|
|
2905
|
-
let artifacts;
|
|
2906
3255
|
context.inject(["po/artifacts"], (scoped) => {
|
|
2907
3256
|
const storage = scoped.get("po/artifacts");
|
|
2908
3257
|
artifacts = storage;
|
|
2909
3258
|
return () => {
|
|
2910
|
-
if (artifacts === storage)
|
|
3259
|
+
if (artifacts === storage) {
|
|
3260
|
+
artifacts = void 0;
|
|
3261
|
+
builds = void 0;
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
});
|
|
3265
|
+
context.inject([_agimon_ai_po_db.PO_DB_SERVICE], (scoped) => {
|
|
3266
|
+
const live = (0, _agimon_ai_po_db.requirePoDb)(scoped);
|
|
3267
|
+
db = live;
|
|
3268
|
+
return () => {
|
|
3269
|
+
if (db === live) {
|
|
3270
|
+
db = void 0;
|
|
3271
|
+
builds = void 0;
|
|
3272
|
+
}
|
|
3273
|
+
};
|
|
3274
|
+
});
|
|
3275
|
+
context.inject([_agimon_ai_po_core_platform.PO_SESSION_FILES_SERVICE], (scoped) => {
|
|
3276
|
+
const directory = scoped.get(_agimon_ai_po_core_platform.PO_SESSION_FILES_SERVICE).temporaryDirectory;
|
|
3277
|
+
temporaryDirectory = directory;
|
|
3278
|
+
return () => {
|
|
3279
|
+
if (temporaryDirectory === directory) temporaryDirectory = void 0;
|
|
2911
3280
|
};
|
|
2912
3281
|
});
|
|
3282
|
+
const getBuilds = async () => {
|
|
3283
|
+
if (disposed || !artifacts || !db) return void 0;
|
|
3284
|
+
if (builds) return builds;
|
|
3285
|
+
if (preparingBuilds) return preparingBuilds;
|
|
3286
|
+
const storage = artifacts;
|
|
3287
|
+
const database = db;
|
|
3288
|
+
const work = (async () => {
|
|
3289
|
+
const artifactDirectory = await storage.rootForSession(sessionId, environment ?? {});
|
|
3290
|
+
if (!artifactDirectory) return void 0;
|
|
3291
|
+
const registry = await createIosBuildRegistry(database, sessionId);
|
|
3292
|
+
if (disposed || artifacts !== storage || db !== database) return void 0;
|
|
3293
|
+
builds = createIosBuilds({
|
|
3294
|
+
sessionId,
|
|
3295
|
+
artifactDirectory,
|
|
3296
|
+
registry,
|
|
3297
|
+
openArtifact: (relativePath) => (0, _agimon_ai_po_artifact_artifactFiles.openArtifactDownload)(artifactDirectory, relativePath),
|
|
3298
|
+
...host.context.shareRegisteredFile ? { shareRegisteredFile: (input) => host.context.shareRegisteredFile(input) } : {}
|
|
3299
|
+
});
|
|
3300
|
+
return builds;
|
|
3301
|
+
})();
|
|
3302
|
+
preparingBuilds = work;
|
|
3303
|
+
try {
|
|
3304
|
+
return await work;
|
|
3305
|
+
} finally {
|
|
3306
|
+
if (preparingBuilds === work) preparingBuilds = void 0;
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
const ui = createIosActivity({
|
|
3310
|
+
owner,
|
|
3311
|
+
pool: () => pool,
|
|
3312
|
+
latestBuild: async () => (await getBuilds())?.latest(),
|
|
3313
|
+
files: {
|
|
3314
|
+
async directory() {
|
|
3315
|
+
if (!temporaryDirectory) return void 0;
|
|
3316
|
+
const directory = node_path.default.join(temporaryDirectory, "ios-frames");
|
|
3317
|
+
(0, _agimon_ai_po_core_platform.getOrThrow)(await (0, _agimon_ai_po_core_platform.requirePoFs)(context).createDir(directory, { recursive: true }, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
|
|
3318
|
+
return directory;
|
|
3319
|
+
},
|
|
3320
|
+
async read(filePath, maxBytes) {
|
|
3321
|
+
const fs = (0, _agimon_ai_po_core_platform.requirePoFs)(context);
|
|
3322
|
+
if ((0, _agimon_ai_po_core_platform.getOrThrow)(await fs.fileInfo(filePath, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT)).size > maxBytes) throw new Error("Simulator frame is too large.");
|
|
3323
|
+
const bytes = (0, _agimon_ai_po_core_platform.getOrThrow)(await fs.readBinaryFile(filePath, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
|
|
3324
|
+
if (bytes.length > maxBytes) throw new Error("Simulator frame changed while reading.");
|
|
3325
|
+
return bytes;
|
|
3326
|
+
},
|
|
3327
|
+
async remove(filePath) {
|
|
3328
|
+
(0, _agimon_ai_po_core_platform.getOrThrow)(await (0, _agimon_ai_po_core_platform.requirePoFs)(context).remove(filePath, { force: true }, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
});
|
|
3332
|
+
host.context.directEvents?.publish(iosActivityReaderEvent, sessionId, ui);
|
|
2913
3333
|
const namespace = createIosNamespace({
|
|
2914
3334
|
sessionId,
|
|
2915
3335
|
owner,
|
|
2916
3336
|
pool: () => pool,
|
|
3337
|
+
builds: getBuilds,
|
|
2917
3338
|
files: {
|
|
2918
3339
|
async exists(filePath) {
|
|
2919
3340
|
return (0, _agimon_ai_po_core_platform.getOrThrow)(await (0, _agimon_ai_po_core_platform.requirePoFs)(context).exists(filePath, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
|
|
@@ -2924,7 +3345,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
2924
3345
|
async screenshotsDirectory() {
|
|
2925
3346
|
const root = await artifacts?.rootForSession(sessionId, environment ?? {});
|
|
2926
3347
|
if (root === void 0) return void 0;
|
|
2927
|
-
const directory =
|
|
3348
|
+
const directory = node_path.default.join(root, SCREENSHOTS_DIRECTORY);
|
|
2928
3349
|
(0, _agimon_ai_po_core_platform.getOrThrow)(await (0, _agimon_ai_po_core_platform.requirePoFs)(context).createDir(directory, { recursive: true }, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
|
|
2929
3350
|
return directory;
|
|
2930
3351
|
}
|
|
@@ -2935,13 +3356,310 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
2935
3356
|
return () => registration?.dispose();
|
|
2936
3357
|
});
|
|
2937
3358
|
return {
|
|
2938
|
-
value: {
|
|
3359
|
+
value: {
|
|
3360
|
+
ui,
|
|
3361
|
+
getBuilds
|
|
3362
|
+
},
|
|
2939
3363
|
onDispose: async () => {
|
|
3364
|
+
disposed = true;
|
|
3365
|
+
host.context.directEvents?.publish(iosActivityReaderEvent, sessionId, void 0);
|
|
3366
|
+
await ui.dispose();
|
|
2940
3367
|
if (owner === sessionId) await pool?.releaseAll(owner);
|
|
2941
3368
|
}
|
|
2942
3369
|
};
|
|
2943
3370
|
});
|
|
2944
3371
|
//#endregion
|
|
3372
|
+
//#region src/schemas/iosSettingsMethods.ts
|
|
3373
|
+
const Availability = typebox.Type.Union([typebox.Type.Literal("available"), typebox.Type.Literal("excluded")]);
|
|
3374
|
+
const Pool = typebox.Type.Object({
|
|
3375
|
+
minBooted: typebox.Type.Number(),
|
|
3376
|
+
maxBooted: typebox.Type.Number(),
|
|
3377
|
+
maxDevices: typebox.Type.Number(),
|
|
3378
|
+
idleShutdownMinutes: typebox.Type.Number(),
|
|
3379
|
+
waitTimeoutSeconds: typebox.Type.Number(),
|
|
3380
|
+
deviceType: typebox.Type.Optional(typebox.Type.String()),
|
|
3381
|
+
runtime: typebox.Type.Optional(typebox.Type.String())
|
|
3382
|
+
});
|
|
3383
|
+
/** Read-only activation snapshot and discovered inventory. Never starts signing, leases or runtimes. */
|
|
3384
|
+
const iosSettingsMethod = (0, _agimon_ai_po_core_pluginProtocol.definePoPluginMethod)({
|
|
3385
|
+
service: "ios",
|
|
3386
|
+
method: "settings",
|
|
3387
|
+
scope: "global",
|
|
3388
|
+
direction: "client-to-server",
|
|
3389
|
+
input: typebox.Type.Object({}, { additionalProperties: false }),
|
|
3390
|
+
output: typebox.Type.Object({
|
|
3391
|
+
active: typebox.Type.Boolean(),
|
|
3392
|
+
configFile: typebox.Type.String(),
|
|
3393
|
+
applied: typebox.Type.Optional(typebox.Type.Object({
|
|
3394
|
+
pool: Pool,
|
|
3395
|
+
developmentTeam: typebox.Type.Optional(typebox.Type.String()),
|
|
3396
|
+
availability: typebox.Type.Record(typebox.Type.String(), Availability)
|
|
3397
|
+
})),
|
|
3398
|
+
phones: typebox.Type.Array(typebox.Type.Object({
|
|
3399
|
+
udid: typebox.Type.String(),
|
|
3400
|
+
name: typebox.Type.String(),
|
|
3401
|
+
paired: typebox.Type.Boolean(),
|
|
3402
|
+
connected: typebox.Type.Boolean(),
|
|
3403
|
+
leased: typebox.Type.Boolean(),
|
|
3404
|
+
availability: Availability
|
|
3405
|
+
})),
|
|
3406
|
+
runtimes: typebox.Type.Array(typebox.Type.Object({
|
|
3407
|
+
identifier: typebox.Type.String(),
|
|
3408
|
+
name: typebox.Type.String(),
|
|
3409
|
+
isAvailable: typebox.Type.Boolean(),
|
|
3410
|
+
models: typebox.Type.Array(typebox.Type.Object({
|
|
3411
|
+
identifier: typebox.Type.String(),
|
|
3412
|
+
name: typebox.Type.String()
|
|
3413
|
+
}))
|
|
3414
|
+
})),
|
|
3415
|
+
inventoryError: typebox.Type.Optional(typebox.Type.String()),
|
|
3416
|
+
runtimeError: typebox.Type.Optional(typebox.Type.String())
|
|
3417
|
+
})
|
|
3418
|
+
});
|
|
3419
|
+
//#endregion
|
|
3420
|
+
//#region src/extensions/(backend)/_lib/settingsMethod.server.ts
|
|
3421
|
+
function createIosSettingsMethod(host, root) {
|
|
3422
|
+
return (0, _agimon_ai_po_core_serverPlugin.defineServerMethod)(iosSettingsMethod, async () => {
|
|
3423
|
+
const { pool, runtime } = root.resolveIosServices();
|
|
3424
|
+
const result = {
|
|
3425
|
+
active: pool !== void 0 && runtime !== void 0,
|
|
3426
|
+
configFile: runtime?.configFile ?? (host.context.homeDirectory ? `${(0, _agimon_ai_po_core_piSettings.poHomeDirectory)(host.context.homeDirectory, host.context.environment ?? {})}/config.yaml` : ""),
|
|
3427
|
+
...runtime ? { applied: runtime.applied } : {},
|
|
3428
|
+
phones: [],
|
|
3429
|
+
runtimes: []
|
|
3430
|
+
};
|
|
3431
|
+
if (!pool) return {
|
|
3432
|
+
...result,
|
|
3433
|
+
inventoryError: "The iOS service is not active.",
|
|
3434
|
+
runtimeError: "The iOS service is not active."
|
|
3435
|
+
};
|
|
3436
|
+
await Promise.all([pool.devices().then((phones) => {
|
|
3437
|
+
result.phones = phones.map(({ udid, name, paired, connected, leased, availability }) => ({
|
|
3438
|
+
udid,
|
|
3439
|
+
name,
|
|
3440
|
+
paired,
|
|
3441
|
+
connected,
|
|
3442
|
+
leased,
|
|
3443
|
+
availability
|
|
3444
|
+
}));
|
|
3445
|
+
}).catch(() => {
|
|
3446
|
+
result.inventoryError = "Physical phone inventory is unavailable on this host.";
|
|
3447
|
+
}), pool.simctl.listRuntimes().then((runtimes) => {
|
|
3448
|
+
result.runtimes = runtimes.filter((runtime) => runtime.platform === "iOS").map((runtime) => ({
|
|
3449
|
+
identifier: runtime.identifier,
|
|
3450
|
+
name: runtime.name,
|
|
3451
|
+
isAvailable: runtime.isAvailable,
|
|
3452
|
+
models: runtime.supportedDeviceTypes.map(({ identifier, name }) => ({
|
|
3453
|
+
identifier,
|
|
3454
|
+
name
|
|
3455
|
+
}))
|
|
3456
|
+
}));
|
|
3457
|
+
}).catch(() => {
|
|
3458
|
+
result.runtimeError = "Simulator models and runtimes could not be discovered on this host.";
|
|
3459
|
+
})]);
|
|
3460
|
+
return result;
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
//#endregion
|
|
3464
|
+
//#region src/extensions/(backend)/method/settings.server.ts
|
|
3465
|
+
var settings_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)(({ host, root }) => host.scope === "global" ? createIosSettingsMethod(host, root) : void 0, { cardinality: "optional" });
|
|
3466
|
+
//#endregion
|
|
3467
|
+
//#region src/extensions/workspaces/sessions/(backend)/channel/_lib/ios-activity.server.ts
|
|
3468
|
+
const POLL_INTERVAL_MS = 2e3;
|
|
3469
|
+
const unavailable = {
|
|
3470
|
+
supported: false,
|
|
3471
|
+
devices: [],
|
|
3472
|
+
error: "The iOS pool is not connected."
|
|
3473
|
+
};
|
|
3474
|
+
/** Metadata only. Screen capture is a separate authenticated, session-bound request. */
|
|
3475
|
+
function createIosActivityChannel(intervalMs = POLL_INTERVAL_MS) {
|
|
3476
|
+
return {
|
|
3477
|
+
frameType: iosActivityChannel,
|
|
3478
|
+
start(host) {
|
|
3479
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
3480
|
+
let closed = false;
|
|
3481
|
+
const poll = async (session) => {
|
|
3482
|
+
if (closed || session.pending || !session.reader) return;
|
|
3483
|
+
const reader = session.reader;
|
|
3484
|
+
session.pending = true;
|
|
3485
|
+
try {
|
|
3486
|
+
const payload = await reader.read();
|
|
3487
|
+
if (closed || sessions.get(session.scope.sessionId) !== session || session.reader !== reader) return;
|
|
3488
|
+
if (JSON.stringify(session.payload) !== JSON.stringify(payload)) {
|
|
3489
|
+
session.payload = payload;
|
|
3490
|
+
host.publish(session.scope.sessionId, payload);
|
|
3491
|
+
}
|
|
3492
|
+
} catch {
|
|
3493
|
+
if (!closed && sessions.get(session.scope.sessionId) === session && session.reader === reader) {
|
|
3494
|
+
session.payload = {
|
|
3495
|
+
supported: false,
|
|
3496
|
+
devices: [],
|
|
3497
|
+
error: "Po could not read this session’s iOS devices."
|
|
3498
|
+
};
|
|
3499
|
+
host.publish(session.scope.sessionId, session.payload);
|
|
3500
|
+
host.onNotice("iOS Activity could not read the session device inventory.");
|
|
3501
|
+
}
|
|
3502
|
+
} finally {
|
|
3503
|
+
session.pending = false;
|
|
3504
|
+
}
|
|
3505
|
+
};
|
|
3506
|
+
const timer = setInterval(() => {
|
|
3507
|
+
for (const session of sessions.values()) poll(session);
|
|
3508
|
+
}, intervalMs);
|
|
3509
|
+
timer.unref?.();
|
|
3510
|
+
return {
|
|
3511
|
+
payloadFor(scope) {
|
|
3512
|
+
return sessions.get(scope.sessionId)?.payload;
|
|
3513
|
+
},
|
|
3514
|
+
sessionAdded(scope) {
|
|
3515
|
+
if (sessions.has(scope.sessionId)) return;
|
|
3516
|
+
const session = {
|
|
3517
|
+
scope,
|
|
3518
|
+
payload: unavailable,
|
|
3519
|
+
pending: false,
|
|
3520
|
+
unsubscribe: () => void 0
|
|
3521
|
+
};
|
|
3522
|
+
sessions.set(scope.sessionId, session);
|
|
3523
|
+
session.unsubscribe = host.directEvents.subscribe(iosActivityReaderEvent, scope.sessionId, (value) => {
|
|
3524
|
+
if (sessions.get(scope.sessionId) !== session) return;
|
|
3525
|
+
session.reader = value && typeof value === "object" && typeof value.read === "function" ? value : void 0;
|
|
3526
|
+
if (session.reader) poll(session);
|
|
3527
|
+
else {
|
|
3528
|
+
session.payload = unavailable;
|
|
3529
|
+
host.publish(scope.sessionId, unavailable);
|
|
3530
|
+
}
|
|
3531
|
+
}, { replayLatest: true });
|
|
3532
|
+
poll(session);
|
|
3533
|
+
},
|
|
3534
|
+
sessionRemoved(sessionId) {
|
|
3535
|
+
sessions.get(sessionId)?.unsubscribe();
|
|
3536
|
+
sessions.delete(sessionId);
|
|
3537
|
+
},
|
|
3538
|
+
close() {
|
|
3539
|
+
closed = true;
|
|
3540
|
+
clearInterval(timer);
|
|
3541
|
+
for (const session of sessions.values()) session.unsubscribe();
|
|
3542
|
+
sessions.clear();
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
//#endregion
|
|
3549
|
+
//#region src/extensions/workspaces/sessions/(backend)/channel/ios-activity.server.ts
|
|
3550
|
+
var ios_activity_server_default = (0, _agimon_ai_po_core_extensionFile.defineChannel)(createIosActivityChannel);
|
|
3551
|
+
//#endregion
|
|
3552
|
+
//#region src/schemas/iosUiMethods.ts
|
|
3553
|
+
const address = {
|
|
3554
|
+
service: "ios",
|
|
3555
|
+
scope: "session",
|
|
3556
|
+
direction: "client-to-server"
|
|
3557
|
+
};
|
|
3558
|
+
const Hash = typebox.Type.String({ pattern: "^[a-f0-9]{64}$" });
|
|
3559
|
+
const CapturedAt = typebox.Type.Number({ minimum: 0 });
|
|
3560
|
+
const IosActivitySchema = typebox.Type.Object({
|
|
3561
|
+
supported: typebox.Type.Boolean(),
|
|
3562
|
+
devices: typebox.Type.Array(typebox.Type.Object({
|
|
3563
|
+
id: typebox.Type.String(),
|
|
3564
|
+
name: typebox.Type.String(),
|
|
3565
|
+
kind: typebox.Type.Union([typebox.Type.Literal("simulator"), typebox.Type.Literal("device")]),
|
|
3566
|
+
detail: typebox.Type.String(),
|
|
3567
|
+
state: typebox.Type.Union([
|
|
3568
|
+
typebox.Type.Literal("owned"),
|
|
3569
|
+
typebox.Type.Literal("other-session"),
|
|
3570
|
+
typebox.Type.Literal("available"),
|
|
3571
|
+
typebox.Type.Literal("disconnected")
|
|
3572
|
+
]),
|
|
3573
|
+
leaseId: typebox.Type.Optional(typebox.Type.String()),
|
|
3574
|
+
capture: typebox.Type.Union([typebox.Type.Literal("available"), typebox.Type.Literal("unsupported")])
|
|
3575
|
+
})),
|
|
3576
|
+
build: typebox.Type.Optional(typebox.Type.Object({
|
|
3577
|
+
id: typebox.Type.String(),
|
|
3578
|
+
name: typebox.Type.String(),
|
|
3579
|
+
size: typebox.Type.Integer({ minimum: 0 }),
|
|
3580
|
+
artifactPath: typebox.Type.String(),
|
|
3581
|
+
registeredAt: typebox.Type.String()
|
|
3582
|
+
})),
|
|
3583
|
+
error: typebox.Type.Optional(typebox.Type.String())
|
|
3584
|
+
});
|
|
3585
|
+
const iosStatusMethod = (0, _agimon_ai_po_core_pluginProtocol.definePoPluginMethod)({
|
|
3586
|
+
...address,
|
|
3587
|
+
method: "status",
|
|
3588
|
+
input: typebox.Type.Object({}, { additionalProperties: false }),
|
|
3589
|
+
output: IosActivitySchema
|
|
3590
|
+
});
|
|
3591
|
+
const iosFrameMethod = (0, _agimon_ai_po_core_pluginProtocol.definePoPluginMethod)({
|
|
3592
|
+
...address,
|
|
3593
|
+
method: "frame",
|
|
3594
|
+
input: typebox.Type.Object({
|
|
3595
|
+
leaseId: typebox.Type.String({
|
|
3596
|
+
minLength: 1,
|
|
3597
|
+
maxLength: 128
|
|
3598
|
+
}),
|
|
3599
|
+
since: typebox.Type.Optional(Hash)
|
|
3600
|
+
}, { additionalProperties: false }),
|
|
3601
|
+
output: typebox.Type.Union([
|
|
3602
|
+
typebox.Type.Object({
|
|
3603
|
+
state: typebox.Type.Literal("ok"),
|
|
3604
|
+
src: typebox.Type.String({ maxLength: 6291456 }),
|
|
3605
|
+
hash: Hash,
|
|
3606
|
+
capturedAt: CapturedAt
|
|
3607
|
+
}),
|
|
3608
|
+
typebox.Type.Object({
|
|
3609
|
+
state: typebox.Type.Literal("unchanged"),
|
|
3610
|
+
hash: Hash,
|
|
3611
|
+
capturedAt: CapturedAt
|
|
3612
|
+
}),
|
|
3613
|
+
typebox.Type.Object({ state: typebox.Type.Literal("released") }),
|
|
3614
|
+
typebox.Type.Object({
|
|
3615
|
+
state: typebox.Type.Literal("capture-unavailable"),
|
|
3616
|
+
message: typebox.Type.String()
|
|
3617
|
+
}),
|
|
3618
|
+
typebox.Type.Object({
|
|
3619
|
+
state: typebox.Type.Literal("error"),
|
|
3620
|
+
message: typebox.Type.String()
|
|
3621
|
+
})
|
|
3622
|
+
])
|
|
3623
|
+
});
|
|
3624
|
+
const iosShareBuildMethod = (0, _agimon_ai_po_core_pluginProtocol.definePoPluginMethod)({
|
|
3625
|
+
...address,
|
|
3626
|
+
method: "shareBuild",
|
|
3627
|
+
input: typebox.Type.Object({ buildId: typebox.Type.String({
|
|
3628
|
+
minLength: 16,
|
|
3629
|
+
maxLength: 128
|
|
3630
|
+
}) }, { additionalProperties: false }),
|
|
3631
|
+
output: typebox.Type.Union([typebox.Type.Object({
|
|
3632
|
+
ok: typebox.Type.Literal(true),
|
|
3633
|
+
url: typebox.Type.String(),
|
|
3634
|
+
expiresAt: typebox.Type.Number()
|
|
3635
|
+
}), typebox.Type.Object({
|
|
3636
|
+
ok: typebox.Type.Literal(false),
|
|
3637
|
+
reason: typebox.Type.Union([
|
|
3638
|
+
typebox.Type.Literal("remote-off"),
|
|
3639
|
+
typebox.Type.Literal("changed"),
|
|
3640
|
+
typebox.Type.Literal("missing"),
|
|
3641
|
+
typebox.Type.Literal("unavailable")
|
|
3642
|
+
]),
|
|
3643
|
+
message: typebox.Type.String()
|
|
3644
|
+
})])
|
|
3645
|
+
});
|
|
3646
|
+
//#endregion
|
|
3647
|
+
//#region src/extensions/workspaces/sessions/(backend)/method/frame.server.ts
|
|
3648
|
+
var frame_server_default = (0, _agimon_ai_po_core_extensionFile.defineMethod)(({ root }) => (0, _agimon_ai_po_core_serverPlugin.defineServerMethod)(iosFrameMethod, ({ leaseId, since }, caller) => root.ui.frame(leaseId, since, caller.signal)));
|
|
3649
|
+
//#endregion
|
|
3650
|
+
//#region src/extensions/workspaces/sessions/(backend)/method/share-build.server.ts
|
|
3651
|
+
var share_build_server_default = (0, _agimon_ai_po_core_extensionFile.defineMethod)(({ root }) => (0, _agimon_ai_po_core_serverPlugin.defineServerMethod)(iosShareBuildMethod, async ({ buildId }) => {
|
|
3652
|
+
const builds = await root.getBuilds();
|
|
3653
|
+
return builds ? builds.share(buildId) : {
|
|
3654
|
+
ok: false,
|
|
3655
|
+
reason: "unavailable",
|
|
3656
|
+
message: "Session build storage is not available."
|
|
3657
|
+
};
|
|
3658
|
+
}));
|
|
3659
|
+
//#endregion
|
|
3660
|
+
//#region src/extensions/workspaces/sessions/(backend)/method/status.server.ts
|
|
3661
|
+
var status_server_default = (0, _agimon_ai_po_core_extensionFile.defineMethod)(({ root }) => (0, _agimon_ai_po_core_serverPlugin.defineServerMethod)(iosStatusMethod, () => root.ui.read()));
|
|
3662
|
+
//#endregion
|
|
2945
3663
|
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-ios.server.ts
|
|
2946
3664
|
var codemode_how_to_ios_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
2947
3665
|
name: "codemode-how-to-ios",
|
|
@@ -2954,6 +3672,12 @@ var codemode_how_to_ios_server_default = (0, _agimon_ai_po_core_extensionFile.de
|
|
|
2954
3672
|
//#endregion
|
|
2955
3673
|
//#region generated/server.ts
|
|
2956
3674
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
3675
|
+
/* v8 ignore next -- generated normalization branch */
|
|
3676
|
+
const defined = (values) => values.filter((value) => value !== void 0);
|
|
3677
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
3678
|
+
...identity,
|
|
3679
|
+
...value
|
|
3680
|
+
};
|
|
2957
3681
|
const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
2958
3682
|
name: "@agimon-ai/po-ios",
|
|
2959
3683
|
providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default$2, root_server_default$1, root_server_default),
|
|
@@ -2968,8 +3692,15 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
2968
3692
|
}),
|
|
2969
3693
|
global: async (context) => {
|
|
2970
3694
|
const scopeGlobal = await context.scopeRoot("global", root_server_default$2, context);
|
|
3695
|
+
const contextGlobal = {
|
|
3696
|
+
...context,
|
|
3697
|
+
root: scopeGlobal.value
|
|
3698
|
+
};
|
|
2971
3699
|
return {
|
|
2972
3700
|
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
|
|
3701
|
+
get methods() {
|
|
3702
|
+
return defined([at(settings_server_default, contextGlobal)]);
|
|
3703
|
+
},
|
|
2973
3704
|
services: [...scopeGlobal.services ?? []]
|
|
2974
3705
|
};
|
|
2975
3706
|
},
|
|
@@ -2982,6 +3713,9 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
2982
3713
|
const scopeWorkspace = await context.scopeRoot("workspace", root_server_default$1, contextGlobal);
|
|
2983
3714
|
return {
|
|
2984
3715
|
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal, scopeWorkspace),
|
|
3716
|
+
get methods() {
|
|
3717
|
+
return defined([context.hosted("global") ? void 0 : at(settings_server_default, contextGlobal)]);
|
|
3718
|
+
},
|
|
2985
3719
|
services: [...scopeGlobal.services ?? [], ...scopeWorkspace.services ?? []]
|
|
2986
3720
|
};
|
|
2987
3721
|
},
|
|
@@ -3003,6 +3737,17 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
3003
3737
|
};
|
|
3004
3738
|
return {
|
|
3005
3739
|
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal, scopeWorkspace, scopeSession),
|
|
3740
|
+
get channels() {
|
|
3741
|
+
return [() => via({ frameType: "ios_activity" }, at(ios_activity_server_default, contextSession))];
|
|
3742
|
+
},
|
|
3743
|
+
get methods() {
|
|
3744
|
+
return defined([
|
|
3745
|
+
context.hosted("global") ? void 0 : at(settings_server_default, contextGlobal),
|
|
3746
|
+
at(frame_server_default, contextSession),
|
|
3747
|
+
at(share_build_server_default, contextSession),
|
|
3748
|
+
at(status_server_default, contextSession)
|
|
3749
|
+
]);
|
|
3750
|
+
},
|
|
3006
3751
|
get resources() {
|
|
3007
3752
|
return [at(codemode_how_to_ios_server_default, contextSession)];
|
|
3008
3753
|
},
|