@agimon-ai/po-ios 0.0.1-alpha.42 → 0.0.1-alpha.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/server.cjs +111 -16
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +111 -16
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/index.d.mts +9 -0
- package/dist/index.d.mts.map +1 -1
- package/native/device-runner/PoRunnerUITests/Runner.swift +13 -0
- package/native/sim-helper/Sources/PoIosCore/Protocol.swift +5 -0
- package/native/sim-helper/Sources/PoIosSimHelper/Backends.swift +31 -0
- package/native/sim-helper/Sources/PoIosSimHelper/PrivateApis.swift +5 -0
- package/native/sim-helper/Sources/PoIosSimHelper/main.swift +4 -0
- package/native/sim-helper/Tests/PoIosCoreTests/ProtocolTests.swift +8 -0
- package/package.json +12 -10
- package/src/prompts/codemode-how-to-ios/SKILL.md +16 -0
|
@@ -36,10 +36,12 @@ 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 = require("@agimon-ai/po-artifact");
|
|
39
40
|
let _agimon_ai_po_artifact_artifactFiles = require("@agimon-ai/po-artifact/artifactFiles");
|
|
40
41
|
let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
|
|
41
42
|
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
42
43
|
let _agimon_ai_po_core_packageApi = require("@agimon-ai/po-core/packageApi");
|
|
44
|
+
let _agimon_ai_po_core_inputTemplate = require("@agimon-ai/po-core/inputTemplate");
|
|
43
45
|
let typebox_value = require("typebox/value");
|
|
44
46
|
let typebox = require("typebox");
|
|
45
47
|
let _agimon_ai_po_core_pluginProtocol = require("@agimon-ai/po-core/pluginProtocol");
|
|
@@ -373,6 +375,10 @@ const IOS_MIGRATIONS = [
|
|
|
373
375
|
{
|
|
374
376
|
version: 3,
|
|
375
377
|
statements: ["ALTER TABLE ios_lease ADD COLUMN kind TEXT NOT NULL DEFAULT 'simulator'"]
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
version: 4,
|
|
381
|
+
statements: ["CREATE TABLE ios_sensitive_device (udid TEXT PRIMARY KEY) STRICT"]
|
|
376
382
|
}
|
|
377
383
|
];
|
|
378
384
|
/** po-vault's lease shape: take a free or expired lock, or renew your own. */
|
|
@@ -448,6 +454,15 @@ function createPoolStore(database) {
|
|
|
448
454
|
});
|
|
449
455
|
};
|
|
450
456
|
return {
|
|
457
|
+
async suppressCapture(udid) {
|
|
458
|
+
await database.run("INSERT OR IGNORE INTO ios_sensitive_device (udid) VALUES (?)", udid);
|
|
459
|
+
},
|
|
460
|
+
async isCaptureSuppressed(udid) {
|
|
461
|
+
return await database.get("SELECT udid FROM ios_sensitive_device WHERE udid = ?", udid) !== void 0;
|
|
462
|
+
},
|
|
463
|
+
async clearCaptureSuppression(udid) {
|
|
464
|
+
await database.run("DELETE FROM ios_sensitive_device WHERE udid = ?", udid);
|
|
465
|
+
},
|
|
451
466
|
async registerServer(server) {
|
|
452
467
|
await database.run(`INSERT INTO ios_server (server_id, pid, started_at, heartbeat_at, max_booted) VALUES (?, ?, ?, ?, ?)
|
|
453
468
|
ON CONFLICT (server_id) DO UPDATE SET heartbeat_at = excluded.heartbeat_at, max_booted = excluded.max_booted`, server.server_id, server.pid, server.started_at, server.heartbeat_at, server.max_booted);
|
|
@@ -986,6 +1001,7 @@ function createDevicePool(options) {
|
|
|
986
1001
|
try {
|
|
987
1002
|
if (booted) await simctl.shutdown(udid);
|
|
988
1003
|
await simctl.erase(udid);
|
|
1004
|
+
await store.clearCaptureSuppression(udid);
|
|
989
1005
|
await store.settle(udid, {
|
|
990
1006
|
state: "shutdown",
|
|
991
1007
|
dirty: false,
|
|
@@ -1026,7 +1042,10 @@ function createDevicePool(options) {
|
|
|
1026
1042
|
};
|
|
1027
1043
|
const bootAndLease = async (udid, needsErase, lease, signal) => {
|
|
1028
1044
|
try {
|
|
1029
|
-
if (needsErase)
|
|
1045
|
+
if (needsErase) {
|
|
1046
|
+
await simctl.erase(udid);
|
|
1047
|
+
await store.clearCaptureSuppression(udid);
|
|
1048
|
+
}
|
|
1030
1049
|
await simctl.boot(udid);
|
|
1031
1050
|
} catch (error) {
|
|
1032
1051
|
await store.settle(udid, {
|
|
@@ -1217,6 +1236,13 @@ function createDevicePool(options) {
|
|
|
1217
1236
|
devicectl: options.devicectl,
|
|
1218
1237
|
...options.deviceRunner === void 0 ? {} : { deviceRunner: options.deviceRunner },
|
|
1219
1238
|
...options.recorder === void 0 ? {} : { recorder: options.recorder },
|
|
1239
|
+
async suppressSensitiveCapture(udid) {
|
|
1240
|
+
await store.suppressCapture(udid);
|
|
1241
|
+
await options.recorder?.stop(udid);
|
|
1242
|
+
},
|
|
1243
|
+
async assertCaptureAllowed(udid) {
|
|
1244
|
+
if (await store.isCaptureSuppressed(udid)) throw new IosError("IOS_INVALID_ARGUMENT", "Capture and observation are suppressed after sensitive input.");
|
|
1245
|
+
},
|
|
1220
1246
|
async start() {
|
|
1221
1247
|
if (!supported) return;
|
|
1222
1248
|
await store.registerServer({
|
|
@@ -1532,6 +1558,12 @@ function createSimHelper(options) {
|
|
|
1532
1558
|
};
|
|
1533
1559
|
return await send(target, "observe", udid, params, signal);
|
|
1534
1560
|
},
|
|
1561
|
+
async inputTarget(udid, signal) {
|
|
1562
|
+
const { child: target } = await ready();
|
|
1563
|
+
const result = await send(target, "inputTarget", udid, {}, signal);
|
|
1564
|
+
if (typeof result?.bundleId !== "string" || !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(result.bundleId)) throw unavailable$2("The iOS helper cannot identify the foreground app for sensitive input.");
|
|
1565
|
+
return { bundleId: result.bundleId };
|
|
1566
|
+
},
|
|
1535
1567
|
async act(udid, action, signal) {
|
|
1536
1568
|
const { child: target } = await ready();
|
|
1537
1569
|
await send(target, "act", udid, action, signal);
|
|
@@ -1724,7 +1756,7 @@ function createDeviceRunner(options) {
|
|
|
1724
1756
|
kill: stopWire,
|
|
1725
1757
|
write(line) {
|
|
1726
1758
|
const request = JSON.parse(line);
|
|
1727
|
-
if (request.op === "observe" || request.op === "act") request.params.bundleIds = [...launched.get(udid) ?? []];
|
|
1759
|
+
if (request.op === "observe" || request.op === "act" || request.op === "inputTarget") request.params.bundleIds = [...launched.get(udid) ?? []];
|
|
1728
1760
|
socket.write(JSON.stringify(request));
|
|
1729
1761
|
}
|
|
1730
1762
|
};
|
|
@@ -1748,6 +1780,7 @@ function createDeviceRunner(options) {
|
|
|
1748
1780
|
probe: (requestSignal) => helper.probe(requestSignal),
|
|
1749
1781
|
observe: (target, limits, requestSignal) => helper.observe(target, limits, requestSignal),
|
|
1750
1782
|
act: (target, action, requestSignal) => helper.act(target, action, requestSignal),
|
|
1783
|
+
inputTarget: (target, requestSignal) => helper.inputTarget(target, requestSignal),
|
|
1751
1784
|
forget: async () => forget(udid),
|
|
1752
1785
|
dispose: async () => forget(udid)
|
|
1753
1786
|
};
|
|
@@ -2403,6 +2436,7 @@ function createIosActivity(options) {
|
|
|
2403
2436
|
try {
|
|
2404
2437
|
return await pool.withLease(options.owner, leaseId, async (lease) => {
|
|
2405
2438
|
activeSignal.throwIfAborted();
|
|
2439
|
+
await pool.assertCaptureAllowed?.(lease.udid);
|
|
2406
2440
|
if (lease.kind !== "simulator") return {
|
|
2407
2441
|
state: "capture-unavailable",
|
|
2408
2442
|
message: "Physical iPhone screen capture is not available on this host."
|
|
@@ -3143,7 +3177,7 @@ declare const ios: {
|
|
|
3143
3177
|
observe(options?: OnLease & ElementQuery & ObserveOptions): Promise<IosSnapshot | IosSnapshotFile>;
|
|
3144
3178
|
/** Taps an element (by ref or query) at its center, or a point. Throws IOS_AMBIGUOUS with nth hints when a query matches several. */
|
|
3145
3179
|
tap(target: OnLease & Target): Promise<{ x: number; y: number; ref?: string; label?: string }>;
|
|
3146
|
-
/** Types text, tapping the target first when
|
|
3180
|
+
/** Types text, tapping the target first when given. Profile {{ env.NAME }} and {{ secrets.NAME }} interpolate host-side; secrets require an approved native app and suppress capture. submit presses return afterwards. */
|
|
3147
3181
|
type(options: OnLease & Partial<Target> & { text: string; submit?: boolean }): Promise<void>;
|
|
3148
3182
|
/** Swipes from one point to another, or in a direction across the screen or an element. up drags the finger upward. */
|
|
3149
3183
|
swipe(options: OnLease & ElementRef & { from?: Point; to?: Point; direction?: 'up' | 'down' | 'left' | 'right'; durationMs?: number }): Promise<void>;
|
|
@@ -3313,6 +3347,7 @@ function createIosNamespace(options) {
|
|
|
3313
3347
|
members.screenshot = async (input) => {
|
|
3314
3348
|
const params = parse(LeaseOnlySchema, input, "screenshot");
|
|
3315
3349
|
return onLease(params.leaseId, async (lease, live) => {
|
|
3350
|
+
await live.assertCaptureAllowed?.(lease.udid);
|
|
3316
3351
|
const directory = await options.files.directory("screenshots");
|
|
3317
3352
|
if (directory === void 0) throw new IosError("IOS_UNSUPPORTED_HOST", "This host keeps no session artifacts to save screenshots in.");
|
|
3318
3353
|
const savedPath = `${directory}/ios-${lease.udid.slice(0, 8)}-${String(Date.now())}.png`;
|
|
@@ -3339,6 +3374,7 @@ function createIosNamespace(options) {
|
|
|
3339
3374
|
const params = parse(StartRecordingSchema, input, "startRecording");
|
|
3340
3375
|
const maxSeconds = params.maxSeconds ?? 600;
|
|
3341
3376
|
return onLease(params.leaseId, async (lease, live) => {
|
|
3377
|
+
await live.assertCaptureAllowed?.(lease.udid);
|
|
3342
3378
|
const recorder = recorderOf(live);
|
|
3343
3379
|
const directory = await options.files.directory("recordings");
|
|
3344
3380
|
if (directory === void 0) throw new IosError("IOS_UNSUPPORTED_HOST", "This host keeps no session artifacts to save recordings in.");
|
|
@@ -3358,6 +3394,7 @@ function createIosNamespace(options) {
|
|
|
3358
3394
|
members.stopRecording = async (input) => {
|
|
3359
3395
|
const params = parse(LeaseOnlySchema, input, "stopRecording");
|
|
3360
3396
|
return onLease(params.leaseId, async (lease, live) => {
|
|
3397
|
+
await live.assertCaptureAllowed?.(lease.udid);
|
|
3361
3398
|
const finished = await recorderOf(live).stop(lease.udid);
|
|
3362
3399
|
if (finished === void 0) throw new IosError("IOS_INVALID_ARGUMENT", "Nothing is recording on this lease; call ios.startRecording first.");
|
|
3363
3400
|
const bytes = await options.files.exists(finished.filePath) ? await options.files.size(finished.filePath) : 0;
|
|
@@ -3374,6 +3411,7 @@ function createIosNamespace(options) {
|
|
|
3374
3411
|
const predicate = [...params.process ? [`process == "${params.process}"`] : [], ...params.subsystem ? [`subsystem == "${params.subsystem}"`] : []].join(" AND ");
|
|
3375
3412
|
const maxLines = params.maxLines ?? 200;
|
|
3376
3413
|
return onLease(params.leaseId, async (lease, live) => {
|
|
3414
|
+
await live.assertCaptureAllowed?.(lease.udid);
|
|
3377
3415
|
if (lease.kind === "device") {
|
|
3378
3416
|
if (predicate) throw new IosError("IOS_INVALID_ARGUMENT", "On a phone ios.logs reads the launched app console only; process and subsystem do not apply.");
|
|
3379
3417
|
const since = Date.now() - (params.lastSeconds ?? 60) * 1e3;
|
|
@@ -3401,7 +3439,10 @@ function createIosNamespace(options) {
|
|
|
3401
3439
|
if (live.helper === void 0) throw new IosError("IOS_HELPER_UNAVAILABLE", "Accessibility and touch need the iOS helper, which this server does not run.");
|
|
3402
3440
|
return live.helper;
|
|
3403
3441
|
};
|
|
3404
|
-
const snapshot = async (live, lease, limits = {}) =>
|
|
3442
|
+
const snapshot = async (live, lease, limits = {}) => {
|
|
3443
|
+
await live.assertCaptureAllowed?.(lease.udid);
|
|
3444
|
+
return toSnapshot(await (await helperOf(live, lease)).observe(lease.udid, limits, run.signal));
|
|
3445
|
+
};
|
|
3405
3446
|
/** The point a target names, resolved against a fresh snapshot so a stale ref fails instead of tapping blind. */
|
|
3406
3447
|
const pointOf = async (live, lease, input, call) => {
|
|
3407
3448
|
const kind = targetKind(input, call);
|
|
@@ -3493,17 +3534,61 @@ function createIosNamespace(options) {
|
|
|
3493
3534
|
};
|
|
3494
3535
|
members.type = async (input) => {
|
|
3495
3536
|
const params = parse(TypeTextSchema, input, "type");
|
|
3537
|
+
const templated = (0, _agimon_ai_po_core_inputTemplate.hasInputTemplate)(params.text);
|
|
3538
|
+
const parts = templated ? (0, _agimon_ai_po_core_inputTemplate.parseInputTemplate)(params.text) : void 0;
|
|
3496
3539
|
await onLease(params.leaseId, async (lease, live) => {
|
|
3497
|
-
const
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3540
|
+
const type = async () => {
|
|
3541
|
+
const helper = await helperOf(live, lease);
|
|
3542
|
+
const target = await pointOf(live, lease, params, "type");
|
|
3543
|
+
if (target !== void 0) await helper.act(lease.udid, {
|
|
3544
|
+
kind: "tap",
|
|
3545
|
+
...target.point
|
|
3546
|
+
}, run.signal);
|
|
3547
|
+
if (!parts) {
|
|
3548
|
+
await helper.act(lease.udid, {
|
|
3549
|
+
kind: "type",
|
|
3550
|
+
text: params.submit ? `${params.text}\n` : params.text
|
|
3551
|
+
}, run.signal);
|
|
3552
|
+
return;
|
|
3553
|
+
}
|
|
3554
|
+
const profile = options.profile?.();
|
|
3555
|
+
if (!profile) throw new Error("Profile input is unavailable.");
|
|
3556
|
+
const selection = profile.readSelection();
|
|
3557
|
+
const generation = selection.generation;
|
|
3558
|
+
const signal = AbortSignal.any([run.signal, selection.signal]);
|
|
3559
|
+
signal.throwIfAborted();
|
|
3560
|
+
const usesSecret = parts.some((part) => part.kind === "secret");
|
|
3561
|
+
let bundleId;
|
|
3562
|
+
if (usesSecret) {
|
|
3563
|
+
if (!helper.inputTarget || !live.suppressSensitiveCapture || !live.assertCaptureAllowed) throw new Error("Sensitive input protection is unavailable.");
|
|
3564
|
+
bundleId = (await helper.inputTarget(lease.udid, signal)).bundleId;
|
|
3565
|
+
await live.suppressSensitiveCapture(lease.udid);
|
|
3566
|
+
}
|
|
3567
|
+
const text = await (0, _agimon_ai_po_core_inputTemplate.renderInputTemplate)(parts, {
|
|
3568
|
+
readEnv: (name) => Object.hasOwn(selection.env ?? {}, name) ? selection.env[name] : void 0,
|
|
3569
|
+
resolveSecret: (name) => profile.resolveInputSecret(name, {
|
|
3570
|
+
surface: "ios",
|
|
3571
|
+
target: bundleId,
|
|
3572
|
+
signal
|
|
3573
|
+
}),
|
|
3574
|
+
onResolved: () => void 0,
|
|
3575
|
+
signal
|
|
3576
|
+
});
|
|
3577
|
+
signal.throwIfAborted();
|
|
3578
|
+
if (profile.readSelection().generation !== generation) throw new Error("The profile changed during input.");
|
|
3579
|
+
if (bundleId !== void 0 && (await helper.inputTarget(lease.udid, signal)).bundleId !== bundleId) throw new Error("The native input target changed.");
|
|
3580
|
+
await helper.act(lease.udid, {
|
|
3581
|
+
kind: "type",
|
|
3582
|
+
text: params.submit ? `${text}\n` : text,
|
|
3583
|
+
...bundleId === void 0 ? {} : { expectedBundleId: bundleId }
|
|
3584
|
+
}, signal);
|
|
3585
|
+
};
|
|
3586
|
+
if (!templated) return type();
|
|
3587
|
+
try {
|
|
3588
|
+
await type();
|
|
3589
|
+
} catch {
|
|
3590
|
+
throw new IosError("IOS_INVALID_ARGUMENT", "Profile template input failed.");
|
|
3591
|
+
}
|
|
3507
3592
|
});
|
|
3508
3593
|
};
|
|
3509
3594
|
members.swipe = async (input) => {
|
|
@@ -3601,6 +3686,7 @@ const iosActivityChannel = "ios_activity";
|
|
|
3601
3686
|
const iosActivityReaderEvent = "po-ios:activity-reader";
|
|
3602
3687
|
//#endregion
|
|
3603
3688
|
//#region src/extensions/workspaces/sessions/(backend)/root.server.ts
|
|
3689
|
+
const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
|
|
3604
3690
|
/** Leases belong to the root session; build artifacts remain owned by their host session. */
|
|
3605
3691
|
var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context, host }) => {
|
|
3606
3692
|
const { sessionId, environment } = host.context;
|
|
@@ -3608,6 +3694,14 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
3608
3694
|
const owner = (0, _agimon_ai_po_core_childProcess.resolveRootSessionId)(sessionId, environment ?? {});
|
|
3609
3695
|
let disposed = false;
|
|
3610
3696
|
let pool;
|
|
3697
|
+
let profile;
|
|
3698
|
+
context.inject([PROFILE_RUNTIME_SERVICE], (scoped) => {
|
|
3699
|
+
const live = scoped.get(PROFILE_RUNTIME_SERVICE);
|
|
3700
|
+
profile = live;
|
|
3701
|
+
return () => {
|
|
3702
|
+
if (profile === live) profile = void 0;
|
|
3703
|
+
};
|
|
3704
|
+
});
|
|
3611
3705
|
let artifacts;
|
|
3612
3706
|
let db;
|
|
3613
3707
|
let temporaryDirectory;
|
|
@@ -3620,8 +3714,8 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
3620
3714
|
if (pool === live) pool = void 0;
|
|
3621
3715
|
};
|
|
3622
3716
|
});
|
|
3623
|
-
context.inject([
|
|
3624
|
-
const storage = scoped.get(
|
|
3717
|
+
context.inject([_agimon_ai_po_artifact.ARTIFACTS_SERVICE], (scoped) => {
|
|
3718
|
+
const storage = scoped.get(_agimon_ai_po_artifact.ARTIFACTS_SERVICE);
|
|
3625
3719
|
artifacts = storage;
|
|
3626
3720
|
return () => {
|
|
3627
3721
|
if (artifacts === storage) {
|
|
@@ -3703,6 +3797,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
3703
3797
|
owner,
|
|
3704
3798
|
pool: () => pool,
|
|
3705
3799
|
builds: getBuilds,
|
|
3800
|
+
profile: () => profile,
|
|
3706
3801
|
files: {
|
|
3707
3802
|
async exists(filePath) {
|
|
3708
3803
|
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));
|