peachsim 0.1.2405 → 0.1.2408
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/cli/agent-note.ts +231 -0
- package/cli/cli-update.ts +2 -2
- package/cli/cloud-dispatch.ts +1 -1
- package/cli/commands/agent.ts +29 -26
- package/cli/commands/stream.ts +11 -7
- package/cli/main.ts +16 -2
- package/cli/outbound-endpoints.ts +16 -1
- package/dist-lib/agent-daemon-client.cjs +23 -3
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +201 -60
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +200 -59
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +356 -100
- package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +4 -4
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +3 -3
- package/dist-lib/native-app-identity-project.mjs +3 -3
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +56 -55
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +367 -106
- package/dist-lib/swift-compile.cjs +195 -54
- package/dist-lib/swift-compile.mjs +195 -54
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +198 -57
- package/dist-lib/vite.cjs +4 -4
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/install.sh +1 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/skills/peach-setup/SKILL.md +8 -3
- package/src/agent-daemon-client.ts +35 -2
- package/src/agent-prompt.ts +68 -0
- package/src/canvas-agent-note-delivery.ts +83 -0
- package/src/host/agent-host.ts +128 -18
- package/src/swift-compile.ts +124 -66
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-import.ts +99 -0
- package/src/xcode-header-search.ts +33 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { AgentDaemonClient, connectToDaemon } from '../src/agent-daemon-client'
|
|
5
|
+
import {
|
|
6
|
+
CANVAS_AGENT_ID_MAX_CHARS,
|
|
7
|
+
readCanvasAgentId,
|
|
8
|
+
type AgentInspectMessage,
|
|
9
|
+
} from '../src/agent-prompt'
|
|
10
|
+
import { cloudCanvasAgentNoteUrl } from '../src/canvas-agent-note-delivery'
|
|
11
|
+
import { rnxPublicBrand } from '../src/public-brand'
|
|
12
|
+
import { authHeaderValue, resolveCliAuth } from './auth'
|
|
13
|
+
import { resolveCloudSessionForParsed } from './cloud-client'
|
|
14
|
+
import { readLocalStreamRecord } from './commands/stream'
|
|
15
|
+
import { getCliIdentity, readCurrentTarget } from './current-sim'
|
|
16
|
+
import { CliUsageError } from './usage-error'
|
|
17
|
+
import { parseBridgeCliArgs } from './ws-bridge'
|
|
18
|
+
|
|
19
|
+
export function inspectArtifactDirectory(messageId: string): string {
|
|
20
|
+
if (!/^inspect-[a-f0-9-]+$/.test(messageId))
|
|
21
|
+
throw new Error('invalid inspect message id')
|
|
22
|
+
return join(tmpdir(), 'peach-inspect', messageId)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function saveCanvasNoteArtifacts(message: AgentInspectMessage) {
|
|
26
|
+
const dir = inspectArtifactDirectory(message.id)
|
|
27
|
+
const crop = message.crop
|
|
28
|
+
const prefix = /^data:image\/(webp|png);base64,/.exec(crop ?? '')
|
|
29
|
+
if (!prefix || !crop) throw new Error('inspect message crop is missing')
|
|
30
|
+
const cropPath = join(dir, `crop.${prefix[1]}`)
|
|
31
|
+
const inspectPath = join(dir, 'inspect.json')
|
|
32
|
+
const describePath = join(dir, 'describe.txt')
|
|
33
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
34
|
+
writeFileSync(cropPath, Buffer.from(crop.slice(prefix[0].length), 'base64'), {
|
|
35
|
+
mode: 0o600,
|
|
36
|
+
})
|
|
37
|
+
const { crop: _crop, ...metadata } = message
|
|
38
|
+
writeFileSync(inspectPath, JSON.stringify(metadata, null, 2) + '\n', { mode: 0o600 })
|
|
39
|
+
writeFileSync(
|
|
40
|
+
describePath,
|
|
41
|
+
[message.prompt.inspectSummary, message.prompt.inspectTrace]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join('\n') + '\n',
|
|
44
|
+
{ mode: 0o600 },
|
|
45
|
+
)
|
|
46
|
+
return { cropPath, inspectPath, describePath, screenshotPath: null }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function canvasNoteSource(message: AgentInspectMessage): string | undefined {
|
|
50
|
+
return [message.prompt.inspectSummary, message.prompt.inspectTrace]
|
|
51
|
+
.flatMap((value) => value?.split('\n') ?? [])
|
|
52
|
+
.find((line) => /^# source\b/i.test(line.trim()))
|
|
53
|
+
?.trim()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function inboxTarget(args: string[], port?: number) {
|
|
57
|
+
const parsed = parseBridgeCliArgs(args, { port })
|
|
58
|
+
const identity = getCliIdentity()
|
|
59
|
+
const recipientId = identity.stable
|
|
60
|
+
? readCanvasAgentId(
|
|
61
|
+
identity.key.length > CANVAS_AGENT_ID_MAX_CHARS
|
|
62
|
+
? `${identity.key.slice(0, CANVAS_AGENT_ID_MAX_CHARS - 1)}…`
|
|
63
|
+
: identity.key,
|
|
64
|
+
)
|
|
65
|
+
: undefined
|
|
66
|
+
const cloud = resolveCloudSessionForParsed(parsed)
|
|
67
|
+
const simId = cloud?.service === 'box' ? cloud.boxId : (cloud?.simId ?? parsed.simId)
|
|
68
|
+
const stream = !cloud && simId ? readLocalStreamRecord(simId) : null
|
|
69
|
+
const pin = readCurrentTarget()
|
|
70
|
+
const local =
|
|
71
|
+
!cloud && simId
|
|
72
|
+
? {
|
|
73
|
+
simId,
|
|
74
|
+
port: parsed.explicitPort
|
|
75
|
+
? parsed.wsPort
|
|
76
|
+
: ((pin?.simId === simId ? pin.bridgePort : undefined) ?? parsed.wsPort),
|
|
77
|
+
}
|
|
78
|
+
: null
|
|
79
|
+
const externalId = cloud
|
|
80
|
+
? simId
|
|
81
|
+
: stream
|
|
82
|
+
? new URL(stream.watchUrl).pathname.split('/').at(-1)
|
|
83
|
+
: null
|
|
84
|
+
const auth = externalId ? resolveCliAuth() : null
|
|
85
|
+
const origin =
|
|
86
|
+
stream?.origin ??
|
|
87
|
+
(process.env.PEACH_API_ORIGIN?.trim() ||
|
|
88
|
+
(auth?.kind === 'session' ? auth.origin : rnxPublicBrand.origin))
|
|
89
|
+
const remote =
|
|
90
|
+
externalId && auth
|
|
91
|
+
? {
|
|
92
|
+
url: cloudCanvasAgentNoteUrl(origin, {
|
|
93
|
+
kind: cloud?.service === 'box' ? 'box' : 'sim',
|
|
94
|
+
externalId,
|
|
95
|
+
}),
|
|
96
|
+
authorization: authHeaderValue(auth),
|
|
97
|
+
}
|
|
98
|
+
: null
|
|
99
|
+
return { local, remote, simId, recipientId }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type CloudInbox = NonNullable<ReturnType<typeof inboxTarget>['remote']>
|
|
103
|
+
|
|
104
|
+
async function requestCloudNote<T>(
|
|
105
|
+
remote: CloudInbox,
|
|
106
|
+
recipientId: string,
|
|
107
|
+
action: 'wait' | 'take',
|
|
108
|
+
wait: boolean,
|
|
109
|
+
signal?: AbortSignal,
|
|
110
|
+
): Promise<T> {
|
|
111
|
+
const timeout = AbortSignal.timeout(wait ? 25_000 : 2_000)
|
|
112
|
+
const response = await fetch(remote.url, {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
headers: { authorization: remote.authorization, 'content-type': 'application/json' },
|
|
115
|
+
body: JSON.stringify({ action, recipientId, wait }),
|
|
116
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
117
|
+
})
|
|
118
|
+
if (!response.ok) throw new CliUsageError(`note inbox returned HTTP ${response.status}`)
|
|
119
|
+
return response.json()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function takeCloudNote(remote: CloudInbox, recipientId: string, wait: boolean) {
|
|
123
|
+
const { message } = await requestCloudNote<{ message: AgentInspectMessage | null }>(
|
|
124
|
+
remote,
|
|
125
|
+
recipientId,
|
|
126
|
+
'take',
|
|
127
|
+
wait,
|
|
128
|
+
)
|
|
129
|
+
return message
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function listenToStreamNotes(
|
|
133
|
+
client: AgentDaemonClient,
|
|
134
|
+
simId: string,
|
|
135
|
+
remote: CloudInbox,
|
|
136
|
+
recipientId: string,
|
|
137
|
+
): Promise<AgentInspectMessage> {
|
|
138
|
+
while (true) {
|
|
139
|
+
const stop = new AbortController()
|
|
140
|
+
const local = client.listenForInspect(simId, recipientId)
|
|
141
|
+
const waitForCloud = async () => {
|
|
142
|
+
while (!stop.signal.aborted) {
|
|
143
|
+
const { pending } = await requestCloudNote<{ pending: boolean }>(
|
|
144
|
+
remote,
|
|
145
|
+
recipientId,
|
|
146
|
+
'wait',
|
|
147
|
+
true,
|
|
148
|
+
stop.signal,
|
|
149
|
+
)
|
|
150
|
+
if (pending) break
|
|
151
|
+
}
|
|
152
|
+
return null
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const delivery = await Promise.race([local, waitForCloud()])
|
|
156
|
+
if (delivery) return delivery
|
|
157
|
+
if (!(await client.cancelInspectListener(simId))) return await local
|
|
158
|
+
const cloud = await takeCloudNote(remote, recipientId, false)
|
|
159
|
+
if (cloud) return cloud
|
|
160
|
+
} finally {
|
|
161
|
+
stop.abort()
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function listenForAgentInspect(args: string[], port?: number) {
|
|
167
|
+
const { local, remote, simId, recipientId } = inboxTarget(args, port)
|
|
168
|
+
if (remote && !local) {
|
|
169
|
+
if (!recipientId)
|
|
170
|
+
throw new CliUsageError(
|
|
171
|
+
'Set PEACH_CLI_IDENTITY to the identity driving the simulator.',
|
|
172
|
+
)
|
|
173
|
+
while (true) {
|
|
174
|
+
const message = await takeCloudNote(remote, recipientId, true)
|
|
175
|
+
if (message) return message
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!local) {
|
|
179
|
+
throw new CliUsageError(
|
|
180
|
+
simId
|
|
181
|
+
? 'Sign in to receive notes for the remote simulator.'
|
|
182
|
+
: 'No current simulator. Run peach use <id> or pass --sim <id>.',
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
const client = await connectToDaemon({
|
|
186
|
+
port: local.port,
|
|
187
|
+
commandTimeoutMs: 0,
|
|
188
|
+
clientLabel: 'peach-agent-listen',
|
|
189
|
+
})
|
|
190
|
+
try {
|
|
191
|
+
if (remote && recipientId)
|
|
192
|
+
return await listenToStreamNotes(client, local.simId, remote, recipientId)
|
|
193
|
+
return await client.listenForInspect(local.simId, recipientId)
|
|
194
|
+
} finally {
|
|
195
|
+
client.close()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function printPendingCanvasNote(args: string[], port?: number) {
|
|
200
|
+
const { local, remote, recipientId } = inboxTarget(args, port)
|
|
201
|
+
if (!recipientId) return
|
|
202
|
+
let message: AgentInspectMessage | null = null
|
|
203
|
+
if (local) {
|
|
204
|
+
const client = new AgentDaemonClient({
|
|
205
|
+
port: local.port,
|
|
206
|
+
connectTimeoutMs: 250,
|
|
207
|
+
commandTimeoutMs: 500,
|
|
208
|
+
})
|
|
209
|
+
try {
|
|
210
|
+
message = await client
|
|
211
|
+
.takeInspectMessage(local.simId, recipientId)
|
|
212
|
+
.catch(() => null)
|
|
213
|
+
} finally {
|
|
214
|
+
client.close()
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!message && remote) message = await takeCloudNote(remote, recipientId, false)
|
|
218
|
+
if (!message) return
|
|
219
|
+
const artifacts = saveCanvasNoteArtifacts(message)
|
|
220
|
+
const line = [
|
|
221
|
+
message.prompt.text,
|
|
222
|
+
message.prompt.inspectSummary,
|
|
223
|
+
canvasNoteSource(message),
|
|
224
|
+
]
|
|
225
|
+
.filter(Boolean)
|
|
226
|
+
.map((part) => JSON.stringify(part?.replace(/[\p{Cc}\p{Zl}\p{Zp}]/gu, ' ')))
|
|
227
|
+
.join(' ')
|
|
228
|
+
process.stderr.write(
|
|
229
|
+
`PEACH INSPECT ${message.id} ${line} Crop: ${artifacts.cropPath}\n`,
|
|
230
|
+
)
|
|
231
|
+
}
|
package/cli/cli-update.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { compareSemver } from '@contrast/runtime-delivery'
|
|
|
4
4
|
import { automaticPeachUpdatesEnabled } from '../src/automatic-update-policy'
|
|
5
5
|
import { getCliVersion } from '../src/cli-version'
|
|
6
6
|
import { cliUpdateFilePath } from '../src/home-paths'
|
|
7
|
-
import { isAgentEnv } from './commands/inspect/env'
|
|
8
7
|
import { DEFAULT_CLI_RELEASE_ORIGIN } from './cli-release-origin'
|
|
8
|
+
import { isAgentEnv } from './commands/inspect/env'
|
|
9
9
|
|
|
10
10
|
export const CLI_UPDATE_CHECK_INTERVAL_MS = 20 * 60 * 60 * 1000
|
|
11
11
|
export const CLI_UPDATE_NOTIFICATION_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1000
|
|
@@ -261,7 +261,7 @@ export async function refreshCliUpdateCache(
|
|
|
261
261
|
)
|
|
262
262
|
const latestVersion = (
|
|
263
263
|
await fetchCliReleaseFile(
|
|
264
|
-
`${releaseOrigin}/channels/
|
|
264
|
+
`${releaseOrigin}/channels/ready`,
|
|
265
265
|
options.timeoutMs ?? 8_000,
|
|
266
266
|
)
|
|
267
267
|
)
|
package/cli/cloud-dispatch.ts
CHANGED
package/cli/commands/agent.ts
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
// wrapper is live.
|
|
13
13
|
|
|
14
14
|
import fs from 'node:fs'
|
|
15
|
-
import os from 'node:os'
|
|
16
15
|
import path from 'node:path'
|
|
17
16
|
import {
|
|
18
17
|
AgentDaemonError,
|
|
@@ -29,7 +28,12 @@ import {
|
|
|
29
28
|
listSessions,
|
|
30
29
|
upsertProject,
|
|
31
30
|
} from '../../src/attached-projects'
|
|
32
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
canvasNoteSource,
|
|
33
|
+
inspectArtifactDirectory,
|
|
34
|
+
listenForAgentInspect,
|
|
35
|
+
saveCanvasNoteArtifacts,
|
|
36
|
+
} from '../agent-note'
|
|
33
37
|
import { printCommandHelp } from '../help'
|
|
34
38
|
import { createBridge, resolveDefaultBridgePort } from '../ws-bridge'
|
|
35
39
|
import { inspectDescribe } from './inspect/core'
|
|
@@ -70,7 +74,7 @@ export async function runAgentCommand(
|
|
|
70
74
|
case 'watch':
|
|
71
75
|
return await cmdWatch(rest)
|
|
72
76
|
case 'listen':
|
|
73
|
-
return await cmdListen(rest)
|
|
77
|
+
return await cmdListen(rest, opts.port)
|
|
74
78
|
case 'info':
|
|
75
79
|
return await cmdInfo(rest)
|
|
76
80
|
case 'transcript':
|
|
@@ -341,26 +345,13 @@ async function cmdWatch(argv: string[]): Promise<number> {
|
|
|
341
345
|
return exit
|
|
342
346
|
}
|
|
343
347
|
|
|
344
|
-
async function cmdListen(argv: string[]): Promise<number> {
|
|
345
|
-
const
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const client = await connectToDaemon({
|
|
352
|
-
port: daemonPort,
|
|
353
|
-
commandTimeoutMs: 0,
|
|
354
|
-
clientLabel: 'peach-agent-listen',
|
|
355
|
-
})
|
|
356
|
-
try {
|
|
357
|
-
const message = await client.listenForInspect(simId)
|
|
358
|
-
const artifacts = await saveInspectArtifacts(message)
|
|
359
|
-
printInspectMessage(message, artifacts)
|
|
360
|
-
return 0
|
|
361
|
-
} finally {
|
|
362
|
-
client.close()
|
|
363
|
-
}
|
|
348
|
+
async function cmdListen(argv: string[], port?: number): Promise<number> {
|
|
349
|
+
const message = await listenForAgentInspect(argv, port)
|
|
350
|
+
const artifacts = message.crop
|
|
351
|
+
? saveCanvasNoteArtifacts(message)
|
|
352
|
+
: await saveInspectArtifacts(message)
|
|
353
|
+
printInspectMessage(message, artifacts)
|
|
354
|
+
return 0
|
|
364
355
|
}
|
|
365
356
|
|
|
366
357
|
async function saveInspectArtifacts(message: AgentInspectMessage): Promise<{
|
|
@@ -368,7 +359,7 @@ async function saveInspectArtifacts(message: AgentInspectMessage): Promise<{
|
|
|
368
359
|
describePath: string
|
|
369
360
|
screenshotPath: string | null
|
|
370
361
|
}> {
|
|
371
|
-
const dir =
|
|
362
|
+
const dir = inspectArtifactDirectory(message.id)
|
|
372
363
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
373
364
|
const inspectPath = path.join(dir, 'inspect.json')
|
|
374
365
|
const describePath = path.join(dir, 'describe.txt')
|
|
@@ -424,7 +415,12 @@ async function saveInspectArtifacts(message: AgentInspectMessage): Promise<{
|
|
|
424
415
|
|
|
425
416
|
function printInspectMessage(
|
|
426
417
|
message: AgentInspectMessage,
|
|
427
|
-
artifacts: {
|
|
418
|
+
artifacts: {
|
|
419
|
+
inspectPath: string
|
|
420
|
+
describePath: string
|
|
421
|
+
screenshotPath: string | null
|
|
422
|
+
cropPath?: string
|
|
423
|
+
},
|
|
428
424
|
): void {
|
|
429
425
|
const request = message.prompt.displayText ?? message.prompt.text
|
|
430
426
|
const context = [
|
|
@@ -434,14 +430,17 @@ function printInspectMessage(
|
|
|
434
430
|
.map((line) => line.trim())
|
|
435
431
|
.filter((line, index, lines) => line && lines.indexOf(line) === index)
|
|
436
432
|
.slice(0, 4)
|
|
433
|
+
const source = message.crop ? canvasNoteSource(message) : undefined
|
|
437
434
|
const lines = [
|
|
438
435
|
`PEACH INSPECT ${message.id}`,
|
|
439
436
|
`Request: ${request}`,
|
|
440
437
|
`Sim: ${message.simId}`,
|
|
441
438
|
...context.map((line, index) => `${index === 0 ? 'Target' : 'Context'}: ${line}`),
|
|
439
|
+
...(source && !context.includes(source) ? [`Context: ${source}`] : []),
|
|
442
440
|
`Describe: ${artifacts.describePath}`,
|
|
443
441
|
`Inspect: ${artifacts.inspectPath}`,
|
|
444
442
|
...(artifacts.screenshotPath ? [`Screenshot: ${artifacts.screenshotPath}`] : []),
|
|
443
|
+
...(artifacts.cropPath ? [`Crop: ${artifacts.cropPath}`] : []),
|
|
445
444
|
`More: peach agent info ${message.id}`,
|
|
446
445
|
]
|
|
447
446
|
process.stdout.write(lines.join('\n') + '\n')
|
|
@@ -453,7 +452,7 @@ async function cmdInfo(argv: string[]): Promise<number> {
|
|
|
453
452
|
process.stderr.write('usage: peach agent info <message-id>\n')
|
|
454
453
|
return 2
|
|
455
454
|
}
|
|
456
|
-
const dir =
|
|
455
|
+
const dir = inspectArtifactDirectory(messageId)
|
|
457
456
|
const inspectPath = path.join(dir, 'inspect.json')
|
|
458
457
|
if (!fs.existsSync(inspectPath)) {
|
|
459
458
|
process.stderr.write(`inspect message not found: ${messageId}\n`)
|
|
@@ -470,6 +469,10 @@ async function cmdInfo(argv: string[]): Promise<number> {
|
|
|
470
469
|
screenshot: fs.existsSync(path.join(dir, 'screenshot.png'))
|
|
471
470
|
? path.join(dir, 'screenshot.png')
|
|
472
471
|
: null,
|
|
472
|
+
crop:
|
|
473
|
+
['crop.webp', 'crop.png']
|
|
474
|
+
.map((file) => path.join(dir, file))
|
|
475
|
+
.find((file) => fs.existsSync(file)) ?? null,
|
|
473
476
|
},
|
|
474
477
|
},
|
|
475
478
|
null,
|
package/cli/commands/stream.ts
CHANGED
|
@@ -21,6 +21,16 @@ const recordSchema = z.object({
|
|
|
21
21
|
watchUrl: z.string(),
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
+
export function readLocalStreamRecord(simId: string) {
|
|
25
|
+
const file = join(rnxHomeDir(), 'streams', `${encodeURIComponent(simId)}.json`)
|
|
26
|
+
try {
|
|
27
|
+
return recordSchema.parse(JSON.parse(readFileSync(file, 'utf8')))
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null
|
|
30
|
+
throw error
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
export async function runStreamCommand(
|
|
25
35
|
args: string[],
|
|
26
36
|
opts: { port?: number } = {},
|
|
@@ -64,13 +74,7 @@ export async function runStreamCommand(
|
|
|
64
74
|
}
|
|
65
75
|
if (action === 'stop') {
|
|
66
76
|
await callInBridge(bridge, 'SootSim.bridges.videoStream.stop')
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
record = recordSchema.parse(JSON.parse(readFileSync(file, 'utf8')))
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
|
|
72
|
-
throw error
|
|
73
|
-
}
|
|
77
|
+
const record = readLocalStreamRecord(simId)
|
|
74
78
|
if (record) await stopSession(record)
|
|
75
79
|
rmSync(file, { force: true })
|
|
76
80
|
console.log(' stream: off')
|
package/cli/main.ts
CHANGED
|
@@ -426,7 +426,17 @@ if (
|
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
const { dispatchCloudBoundary } = await import('./cloud-dispatch')
|
|
429
|
+
const { CLOUD_TARGET_COMMANDS, dispatchCloudBoundary } = await import('./cloud-dispatch')
|
|
430
|
+
if (
|
|
431
|
+
!isReadOnlyInvocation &&
|
|
432
|
+
!redact &&
|
|
433
|
+
(TOP_LEVEL_RUNTIME_COMMANDS.has(command) ||
|
|
434
|
+
CLOUD_TARGET_COMMANDS.has(command) ||
|
|
435
|
+
command === 'canvas')
|
|
436
|
+
) {
|
|
437
|
+
const { printPendingCanvasNote } = await import('./agent-note')
|
|
438
|
+
await printPendingCanvasNote(commandArgsWithSim, port).catch(() => {})
|
|
439
|
+
}
|
|
430
440
|
const cloudBoundary = await dispatchCloudBoundary({
|
|
431
441
|
command,
|
|
432
442
|
args: commandArgsWithSim,
|
|
@@ -805,7 +815,11 @@ try {
|
|
|
805
815
|
|
|
806
816
|
case 'agent': {
|
|
807
817
|
const { runAgentCommand } = await import('./commands/agent')
|
|
808
|
-
const
|
|
818
|
+
const args =
|
|
819
|
+
parsed.commandArgs[0] === 'listen' && globalSimTarget
|
|
820
|
+
? ['listen', '--sim', globalSimTarget, ...parsed.commandArgs.slice(1)]
|
|
821
|
+
: parsed.commandArgs
|
|
822
|
+
const code = await runAgentCommand(args, { port })
|
|
809
823
|
await exitWithFlush(code)
|
|
810
824
|
}
|
|
811
825
|
|
|
@@ -99,10 +99,17 @@ export const OUTBOUND_ENDPOINTS: Record<string, OutboundEndpointDeclaration> = {
|
|
|
99
99
|
payload:
|
|
100
100
|
"explicit auth, billing, preview, issue report, test, generated-flow or stream request; a stream registration names the checkout's GitHub owner/repo; a stored login may refresh auth/subscription state",
|
|
101
101
|
},
|
|
102
|
+
peach_canvas_notes: {
|
|
103
|
+
category: 'explicit-user-action',
|
|
104
|
+
destination: 'configured product API origin, /api/account/rnx-cloud/agent-notes/<id>',
|
|
105
|
+
preConsent: false,
|
|
106
|
+
payload:
|
|
107
|
+
'a note sent from a running canvas item carries text, element or mark context, source and crop; receipt checks send the note id, and a signed-in CLI requests notes for its own driving identity',
|
|
108
|
+
},
|
|
102
109
|
cli_delivery: {
|
|
103
110
|
category: 'explicit-user-action',
|
|
104
111
|
destination:
|
|
105
|
-
'https://r2.rnxsim.com/rnx-cli/channels/
|
|
112
|
+
'https://r2.rnxsim.com/rnx-cli/channels/ready and the selected executable/checksum',
|
|
106
113
|
preConsent: false,
|
|
107
114
|
payload: 'requested CLI version, platform, and architecture only',
|
|
108
115
|
},
|
|
@@ -333,6 +340,14 @@ export interface OutboundCallDeclaration {
|
|
|
333
340
|
// a new fetch, websocket, node HTTP request, or TCP connection has no entry and
|
|
334
341
|
// fails scripts/check/outbound-endpoints.ts until its destination and consent behavior are declared.
|
|
335
342
|
export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> = {
|
|
343
|
+
'packages/peachsim/cli/agent-note.ts :: fetch :: remote.url': {
|
|
344
|
+
category: 'peach_canvas_notes',
|
|
345
|
+
count: 1,
|
|
346
|
+
},
|
|
347
|
+
'packages/peachsim/src/canvas-agent-note-delivery.ts :: fetch-alias :: endpoint': {
|
|
348
|
+
category: 'peach_canvas_notes',
|
|
349
|
+
count: 1,
|
|
350
|
+
},
|
|
336
351
|
'packages/peach-engine/src/guest/tcp-relay.ts :: websocket :: url': {
|
|
337
352
|
category: 'guest_app_network',
|
|
338
353
|
count: 1,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -96,6 +96,11 @@ function rnxSelfInvocation() {
|
|
|
96
96
|
return { executable: process.execPath, prefixArgs: [entry] };
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
// src/agent-prompt.ts
|
|
100
|
+
var MAX_NOTE_CROP_LENGTH = 2 * 1024 * 1024;
|
|
101
|
+
var MAX_CANVAS_AGENT_NOTE_BODY_BYTES = MAX_NOTE_CROP_LENGTH + 256 * 1024;
|
|
102
|
+
var AGENT_NOTE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
103
|
+
|
|
99
104
|
// src/home-paths.ts
|
|
100
105
|
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
101
106
|
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
@@ -253,11 +258,14 @@ var AgentDaemonClient = class {
|
|
|
253
258
|
this.commandTimeoutMs = opts.commandTimeoutMs ?? 15e3;
|
|
254
259
|
this.ws = new import_ws.WebSocket(`ws://127.0.0.1:${this.port}`);
|
|
255
260
|
this.ready = new Promise((resolve, reject) => {
|
|
261
|
+
const timeout = opts.connectTimeoutMs ? setTimeout(() => this.ws.terminate(), opts.connectTimeoutMs) : void 0;
|
|
256
262
|
const onOpen = () => {
|
|
263
|
+
clearTimeout(timeout);
|
|
257
264
|
this.ws.off("error", onError);
|
|
258
265
|
resolve();
|
|
259
266
|
};
|
|
260
267
|
const onError = (err) => {
|
|
268
|
+
clearTimeout(timeout);
|
|
261
269
|
this.ws.off("open", onOpen);
|
|
262
270
|
reject(
|
|
263
271
|
new AgentDaemonError(
|
|
@@ -304,8 +312,20 @@ var AgentDaemonClient = class {
|
|
|
304
312
|
prompt
|
|
305
313
|
});
|
|
306
314
|
}
|
|
307
|
-
async listenForInspect(simId) {
|
|
308
|
-
return this.send("agent:listen-inspect", { simId });
|
|
315
|
+
async listenForInspect(simId, recipientId) {
|
|
316
|
+
return this.send("agent:listen-inspect", { simId, recipientId });
|
|
317
|
+
}
|
|
318
|
+
async cancelInspectListener(simId) {
|
|
319
|
+
return this.send("agent:cancel-listen-inspect", { simId });
|
|
320
|
+
}
|
|
321
|
+
async takeInspectMessage(simId, recipientId) {
|
|
322
|
+
return this.send("agent:take-inspect-message", { simId, recipientId });
|
|
323
|
+
}
|
|
324
|
+
async sendCanvasNote(simId, note) {
|
|
325
|
+
return this.send("agent:send-canvas-note", { simId, note });
|
|
326
|
+
}
|
|
327
|
+
async canvasNoteStatus(simId, messageId) {
|
|
328
|
+
return this.send("agent:canvas-note-status", { simId, messageId });
|
|
309
329
|
}
|
|
310
330
|
async getInspectListenerStatus(simId) {
|
|
311
331
|
return this.send("agent:get-inspect-listener-status", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|