@buoy-gg/agent-core 7.0.44 → 7.0.45
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/lib/commonjs/catalog/catalog.g.js +2 -2
- package/lib/commonjs/catalog/catalog.source.json +52 -9
- package/lib/commonjs/catalog/catalog.types.g.js +1 -1
- package/lib/commonjs/catalog/normalizeParams.js +2 -2
- package/lib/commonjs/catalog/snapshotReads.js +1 -1
- package/lib/commonjs/effects/ledger.js +1 -1
- package/lib/commonjs/effects/storeDiff.js +1 -0
- package/lib/commonjs/engine/compactScreen.js +1 -0
- package/lib/commonjs/engine/effectFor.js +1 -1
- package/lib/commonjs/engine/planOnlyStop.js +1 -0
- package/lib/commonjs/engine/runAgentTurn.js +7 -7
- package/lib/commonjs/engine/systemPrompt.js +12 -5
- package/lib/commonjs/engine/verify.js +1 -1
- package/lib/commonjs/providers/openai.js +3 -5
- package/lib/commonjs/providers/types.js +1 -1
- package/lib/module/catalog/catalog.g.js +2 -2
- package/lib/module/catalog/catalog.source.json +52 -9
- package/lib/module/catalog/catalog.types.g.js +1 -1
- package/lib/module/catalog/normalizeParams.js +1 -1
- package/lib/module/catalog/snapshotReads.js +1 -1
- package/lib/module/effects/ledger.js +1 -1
- package/lib/module/effects/storeDiff.js +1 -0
- package/lib/module/engine/compactScreen.js +1 -0
- package/lib/module/engine/effectFor.js +1 -1
- package/lib/module/engine/planOnlyStop.js +1 -0
- package/lib/module/engine/runAgentTurn.js +7 -7
- package/lib/module/engine/systemPrompt.js +12 -5
- package/lib/module/engine/verify.js +1 -1
- package/lib/module/providers/openai.js +3 -5
- package/lib/module/providers/types.js +1 -1
- package/lib/typescript/catalog/catalog.g.d.ts +2 -2
- package/lib/typescript/catalog/catalog.types.g.d.ts +3 -3
- package/lib/typescript/effects/ledger.d.ts +13 -0
- package/lib/typescript/effects/storeDiff.d.ts +23 -0
- package/lib/typescript/engine/compactScreen.d.ts +18 -0
- package/lib/typescript/engine/planOnlyStop.d.ts +22 -0
- package/lib/typescript/engine/runAgentTurn.d.ts +1 -1
- package/lib/typescript/providers/types.d.ts +8 -0
- package/lib/web/index.mjs +44 -39
- package/package.json +1 -1
|
@@ -967,7 +967,7 @@
|
|
|
967
967
|
},
|
|
968
968
|
"effect": "read",
|
|
969
969
|
"release": "works",
|
|
970
|
-
"description": "Projects each live query to light fields: queryHash, queryKey, status (one of fresh/stale/fetching/error/inactive/paused/disabled, from getQueryStatusLabel), fetchStatus, isStale, observers, updatedAt (state.dataUpdatedAt), and error.message when present. Returns {queries, total, returned, includedData}. Sorted most-recently-updated first. Safe to call repeatedly \u2014 unlike the full dehydrated snapshot, the heavy cached data stays on the device by default. TWO TRAPS: (1) the adapter has NO default limit \u2014 omit it and you get every query in the cache; (2) includeData:true returns q.state.data RAW and UNCAPPED (no 16KB wire marker, no 8MB cap like getQueryData), so it can blow the wire/token budget on a big cache \u2014 prefer getQueryData for one query's payload. The queryHash of each row is the handle every other action takes. What is NOT here has not been fetched yet \u2014 the cache fills as the user visits screens \u2014 so treat a missing key as a screen to go to (route-events.navigate, then highlight-updates.waitFor, then read again), not as an absence to report. Every read here also returns `shape`: a one-line sketch of the value's type plus, for each list in it, what its items look like. It is tiny and does not grow with the data, so it survives the 24,000-character cut when the data itself does not \u2014 read it before writing, and match it exactly. A list whose `item` is missing is EMPTY, which means nothing in the running app knows what belongs in it; anything you add there cannot be checked and will be accepted as-is, so say so rather than inventing fields. Send `staleOnly:true` to see only stale queries.",
|
|
970
|
+
"description": "Projects each live query to light fields: queryHash, queryKey, status (one of fresh/stale/fetching/error/inactive/paused/disabled, from getQueryStatusLabel), fetchStatus, isStale, observers, updatedAt (state.dataUpdatedAt), and error.message when present. Returns {queries, total, returned, includedData}. Sorted most-recently-updated first. Safe to call repeatedly \u2014 unlike the full dehydrated snapshot, the heavy cached data stays on the device by default. TWO TRAPS: (1) the adapter has NO default limit \u2014 omit it and you get every query in the cache; (2) includeData:true returns q.state.data RAW and UNCAPPED (no 16KB wire marker, no 8MB cap like getQueryData), so it can blow the wire/token budget on a big cache \u2014 prefer getQueryData for one query's payload. The queryHash of each row is the handle every other action takes. What is NOT here has not been fetched yet \u2014 the cache fills as the user visits screens \u2014 so treat a missing key as a screen to go to (route-events.navigate, then highlight-updates.waitFor, then read again), not as an absence to report. Every read here also returns `shape`: a one-line sketch of the value's type plus, for each list in it, what its items look like. It is tiny and does not grow with the data, so it survives the 24,000-character cut when the data itself does not \u2014 read it before writing, and match it exactly. A list whose `item` is missing is EMPTY, which means nothing in the running app knows what belongs in it; anything you add there cannot be checked and will be accepted as-is, so say so rather than inventing fields. Send `staleOnly:true` to see only stale queries. `refetchEveryMs` appears on a query a mounted screen refetches on a timer: any cache edit, error or loading pin on it is replaced within that many ms, so use a network override for anything that must last \u2014 and it answers \"is the app calling this API over and over?\".",
|
|
971
971
|
"requires": [
|
|
972
972
|
"QueryClientProvider above <FloatingDevTools/>",
|
|
973
973
|
"@tanstack/react-query v5"
|
|
@@ -1441,7 +1441,7 @@
|
|
|
1441
1441
|
},
|
|
1442
1442
|
"effect": "read",
|
|
1443
1443
|
"release": "works",
|
|
1444
|
-
"description": "Runs the device's own \"Copy Settings\" formatter over the unified store and returns {output: string, returned: number, totalAvailable: number, includedData: boolean, format: string}. The store is a 200-event ring, newest-first. Defaults are compact: includeEventData=false, so heavy raw payloads (network bodies, redux state trees, query data) stay on the device \u2014 pass settings.includeEventData=true only when you actually need them.\n\nTHREE traps a caller must know:\n(1) COLD READS ARE EMPTY. Sources are only subscribed while a consumer holds a watch on toolId \"events\" (the adapter's subscribe() calls ensureRemoteSourcesDefault) or the on-device Events modal is open. A bare call_action does NOT arm capture \u2014 the MCP SyncClient only watches on getSnapshot, never on callAction (packages/mcp/src/tools/packs/events.ts:80). If totalAvailable is 0, say \"nothing was being recorded\", not \"nothing happened\": arm it first (read the events snapshot, or call setEnabledSources), reproduce, then export.\n(2) limit IS APPLIED BEFORE FILTERING. The adapter does all.slice(0, limit) and only then does generateExport filter by settings.filterSources / filterMode (packages/events/src/sync/eventsSyncAdapter.ts:378-381 + eventExportFormatter.ts:616). Filtering to one source with limit:25 can produce an EMPTY output while `returned` still reports 25 \u2014 `returned` counts events handed to the formatter, not events in the output. When filtering by source, pass a large limit (or omit it, which uses the whole buffer).\n(3) filterSources takes GRANULAR EventSource values, not friendly names. \"storage\" matches nothing \u2014 use [\"storage-async\",\"storage-mmkv\"]; react-query is three values ([\"react-query\",\"react-query-query\",\"react-query-mutation\"]). The MCP get_events wrapper expands those aliases for you; a direct call_action does not.\n\nAn unrecognized preset name silently falls back to DEFAULT_COPY_SETTINGS instead of erroring. settings is shallow-merged OVER the preset. Swift captures network, storage-async, storage-mmkv, and route. React state and render sources are unavailable. Native export accepts format, includeEventData, includeSource, includeStatus, includeTitle, includeSubtitle, includeSummaryHeader, filterMode, filterSources, dataSizeThreshold, and timestampFormat; other settings are rejected. Native detail inherits source snapshot payload limits.",
|
|
1444
|
+
"description": "Runs the device's own \"Copy Settings\" formatter over the unified store and returns {output: string, returned: number, totalAvailable: number, includedData: boolean, format: string}. The store is a 200-event ring, newest-first. Defaults are compact: includeEventData=false, so heavy raw payloads (network bodies, redux state trees, query data) stay on the device \u2014 pass settings.includeEventData=true only when you actually need them.\n\nTHREE traps a caller must know:\n(1) COLD READS ARE EMPTY. Sources are only subscribed while a consumer holds a watch on toolId \"events\" (the adapter's subscribe() calls ensureRemoteSourcesDefault) or the on-device Events modal is open. A bare call_action does NOT arm capture \u2014 the MCP SyncClient only watches on getSnapshot, never on callAction (packages/mcp/src/tools/packs/events.ts:80). If totalAvailable is 0, say \"nothing was being recorded\", not \"nothing happened\": arm it first (read the events snapshot, or call setEnabledSources), reproduce, then export.\n(2) limit IS APPLIED BEFORE FILTERING. The adapter does all.slice(0, limit) and only then does generateExport filter by settings.filterSources / filterMode (packages/events/src/sync/eventsSyncAdapter.ts:378-381 + eventExportFormatter.ts:616). Filtering to one source with limit:25 can produce an EMPTY output while `returned` still reports 25 \u2014 `returned` counts events handed to the formatter, not events in the output. When filtering by source, pass a large limit (or omit it, which uses the whole buffer).\n(3) filterSources takes GRANULAR EventSource values, not friendly names. \"storage\" matches nothing \u2014 use [\"storage-async\",\"storage-mmkv\"]; react-query is three values ([\"react-query\",\"react-query-query\",\"react-query-mutation\"]). The MCP get_events wrapper expands those aliases for you; a direct call_action does not.\n\nAn unrecognized preset name silently falls back to DEFAULT_COPY_SETTINGS instead of erroring. settings is shallow-merged OVER the preset. Swift captures network, storage-async, storage-mmkv, and route. React state and render sources are unavailable. Native export accepts format, includeEventData, includeSource, includeStatus, includeTitle, includeSubtitle, includeSummaryHeader, filterMode, filterSources, dataSizeThreshold, and timestampFormat; other settings are rejected. Native detail inherits source snapshot payload limits. A source records only while it is enabled (setEnabledSources), so enabling one now cannot show what happened before. For storage writes, read storage getSnapshot instead \u2014 the storage tool keeps its own timeline.",
|
|
1445
1445
|
"requires": [
|
|
1446
1446
|
"@buoy-gg/events installed and auto-discovered by FloatingDevTools",
|
|
1447
1447
|
"a live watch on toolId \"events\" (an events snapshot read, a desktop Events panel, or a prior setEnabledSources call) before the window you want recorded \u2014 otherwise the buffer is empty",
|
|
@@ -1843,7 +1843,7 @@
|
|
|
1843
1843
|
},
|
|
1844
1844
|
"effect": "write",
|
|
1845
1845
|
"release": "noop",
|
|
1846
|
-
"description": "Create (or replace by id) a rule that forces matching requests to return a chosen status/body, fail outright, or arrive late. Pick this over query.setQueryData when the change must survive a refetch or reload, or when the ask is about what the API returns; follow it with query.invalidate so the mounted screen refetches through the rule. To change ONE value of the real response send fromRequestId plus `bodyPath` and `bodyValue` (bodyPath:\"sprites.front_default\", or \"stats[stat.name=hp].base_stat\" for one row of a list) \u2014 there is no nesting to get wrong, which matters most here because you read that body through a wire that truncates at 24,000 characters. For several fields use `bodyPatch` with ONLY those fields; never paste a whole captured body back. For \"just the NEXT call\" / \"once, then let it work again\", send rule.times:1 \u2014 the rule auto-disables after one match. Without times it overrides EVERY matching request until deleted. Never fake one-shot by triggering the request yourself and deleting the rule: that spends the failure the user wanted to see.",
|
|
1846
|
+
"description": "Create (or replace by id) a rule that forces matching requests to return a chosen status/body, fail outright, or arrive late. Pick this over query.setQueryData when the change must survive a refetch or reload, or when the ask is about what the API returns; follow it with query.invalidate so the mounted screen refetches through the rule. To change ONE value of the real response send fromRequestId plus `bodyPath` and `bodyValue` (bodyPath:\"sprites.front_default\", or \"stats[stat.name=hp].base_stat\" for one row of a list) \u2014 there is no nesting to get wrong, which matters most here because you read that body through a wire that truncates at 24,000 characters. For several fields use `bodyPatch` with ONLY those fields; never paste a whole captured body back. For \"just the NEXT call\" / \"once, then let it work again\", send rule.times:1 \u2014 the rule auto-disables after one match. Without times it overrides EVERY matching request until deleted. Never fake one-shot by triggering the request yourself and deleting the rule: that spends the failure the user wanted to see. No captured request is needed: urlPattern + methods + status/body (or kind/delayMs) works for a call the app has not made yet \u2014 use fromRequestId only when you need the real response to edit.",
|
|
1847
1847
|
"releaseNote": "packages/network/src/network/overrides/engine.ts:74 \u2014 overrideForRequest returns null when __DEV__ === false. The rule is still created, persisted and listed, and this action still returns ok:true, but it is NEVER applied to real traffic in a release build. Confirm with debugOverrides \u2192 engine.devFlag before telling anyone the override took effect.",
|
|
1848
1848
|
"requires": [
|
|
1849
1849
|
"a __DEV__ build for the rule to actually apply",
|
|
@@ -3607,8 +3607,29 @@
|
|
|
3607
3607
|
{
|
|
3608
3608
|
"toolId": "storage",
|
|
3609
3609
|
"title": "Storage",
|
|
3610
|
-
"summary": "Read and write the app's persisted state across all three backends \u2014 AsyncStorage, every registered MMKV instance, and registered Expo SecureStore keys \u2014 plus a recorded timeline of storage writes with per-event undo/jump. Reach for this first when a value is wrong, stale, missing, or only broken after a restart/upgrade: the bad value is usually sitting in storage. Buoy's own devtool keys (@react_buoy*, @buoy*, buoy-*) are stripped from every read path, so results are app data only. Nothing here is __DEV__-gated \u2014 every action really runs in a release build.",
|
|
3610
|
+
"summary": "Read and write the app's persisted state across all three backends \u2014 AsyncStorage, every registered MMKV instance, and registered Expo SecureStore keys \u2014 plus a recorded timeline of storage writes with per-event undo/jump. Reach for this first when a value is wrong, stale, missing, or only broken after a restart/upgrade: the bad value is usually sitting in storage. Buoy's own devtool keys (@react_buoy*, @buoy*, buoy-*) are stripped from every read path, so results are app data only. Nothing here is __DEV__-gated \u2014 every action really runs in a release build. When a saved value looks wrong, compare it with getRequiredKeys: a key written by an older app version shows up there with the wrong type (a bare \"1856\" where the app expects an object). The storage write timeline is this tool's getSnapshot (newest events, each with its key, value and the value it replaced) \u2014 read it for \"what changed in storage?\" and to find the event to undo. Do not use the Events tool for that: it records a source only after setEnabledSources, so earlier writes are not there.",
|
|
3611
3611
|
"actions": [
|
|
3612
|
+
{
|
|
3613
|
+
"action": "getSnapshot",
|
|
3614
|
+
"summary": "Read the storage write timeline: the app's recent AsyncStorage and MMKV writes, newest first, each with its key, the value written and the value it replaced. Answers \"what changed in storage?\" and finds the event to undo.",
|
|
3615
|
+
"description": "Returns `{ events: [{ id, at, action, storage, key, value, prevValue }], total, returned }` newest first. Values are cut to 300 characters (read the key for the full value). `id` is what timeTravel.undo and timeTravel.jump take. Recording starts when something first watches the storage tool, so writes before that are not listed. Pass `limit` for how many writes (default 20) and `key` to list only writes whose key contains that text.",
|
|
3616
|
+
"params": {
|
|
3617
|
+
"type": "object",
|
|
3618
|
+
"properties": {
|
|
3619
|
+
"limit": {
|
|
3620
|
+
"type": "number",
|
|
3621
|
+
"description": "Most-recent N writes. Default 20."
|
|
3622
|
+
},
|
|
3623
|
+
"key": {
|
|
3624
|
+
"type": "string",
|
|
3625
|
+
"description": "Only writes whose key contains this text."
|
|
3626
|
+
}
|
|
3627
|
+
},
|
|
3628
|
+
"additionalProperties": false
|
|
3629
|
+
},
|
|
3630
|
+
"effect": "read",
|
|
3631
|
+
"release": "works"
|
|
3632
|
+
},
|
|
3612
3633
|
{
|
|
3613
3634
|
"action": "getRequiredKeys",
|
|
3614
3635
|
"summary": "List the storage keys the app declares as required, with their expected types and backends.",
|
|
@@ -4029,7 +4050,7 @@
|
|
|
4029
4050
|
},
|
|
4030
4051
|
"effect": "read",
|
|
4031
4052
|
"release": "works",
|
|
4032
|
-
"description": "Returns [{key, description, keychainService, requireAuthentication}]. SecureStore has no key-enumeration API, so only keys the app declared via registerSecureStoreKeys(...) are visible \u2014 an empty [] means nothing was registered, NOT that the keychain is empty. requireAuthentication:true marks a biometric-protected key whose value Buoy never reads.",
|
|
4053
|
+
"description": "Returns [{key, description, keychainService, requireAuthentication}]. SecureStore has no key-enumeration API, so only keys the app declared via registerSecureStoreKeys(...) are visible \u2014 an empty [] means nothing was registered, NOT that the keychain is empty. requireAuthentication:true marks a biometric-protected key whose value Buoy never reads. Each key also has `hasValue` (true / false; null for a biometric-protected key, which is never read) \u2014 so you can tell an empty key from a set one, or see that the login moved from one key to another, without the value ever leaving the device.",
|
|
4033
4054
|
"requires": [
|
|
4034
4055
|
"registerSecureStoreKeys(SecureStore, [...]) called by the app (expo-secure-store)"
|
|
4035
4056
|
]
|
|
@@ -6190,7 +6211,7 @@
|
|
|
6190
6211
|
{
|
|
6191
6212
|
"toolId": "ask-buoy",
|
|
6192
6213
|
"title": "Ask Buoy",
|
|
6193
|
-
"summary": "Ask Buoy's OWN session \u2014 the changes it has made in this conversation, and the undo for them. Call listChanges when the user asks \"what did you change?\"; call
|
|
6214
|
+
"summary": "Ask Buoy's OWN session \u2014 the changes it has made in this conversation, and the undo for them. Call listChanges when the user asks \"what did you change?\"; call undoChange with the id of the change they mean when they say \"undo that\" about one change, and undoAll when they say \"undo everything\" / \"put it all back\" / \"clean up\". Undo restores exactly what the ledger captured at write time: override rules Ask Buoy created are deleted, impersonation is stopped, storage keys are restored to their pre-write values, a query cache edit (setQueryData) is put back to the data read just before the write \u2014 unless the app has refetched it since, in which case the server's data is already back and undo says so \u2014 and a store edit (zustand.setState) has exactly the values it changed put back, unless something changed those same values again since. To undo ONE change and keep the rest, call listChanges and pass that change's id to undoChange. Changes listed with reversible:false (state writes, wipes, one-shot actions) cannot be automatically reversed \u2014 say so honestly. NEVER improvise a reverse-write with a guessed shape instead of calling undoAll; a hand-rolled \"undo\" that writes invented data is worse than telling the user a change is permanent. Its retrieve action re-reads any earlier tool result in FULL: every result over 24,000 characters is cut with a `[truncated \u2014 \u2026; ref ev_N]` marker and every result compressed out of memory leaves an `[earlier result \u2014 \u2026; ref ev_N]` marker \u2014 call retrieve with that ref (and a path or pattern) instead of asking the user for a narrower slice or calling the tool again for a value you already had.",
|
|
6194
6215
|
"actions": [
|
|
6195
6216
|
{
|
|
6196
6217
|
"action": "listChanges",
|
|
@@ -6203,11 +6224,33 @@
|
|
|
6203
6224
|
},
|
|
6204
6225
|
"effect": "read",
|
|
6205
6226
|
"release": "works",
|
|
6206
|
-
"description": "Returns `{changes:[{toolId, action, kind, label, reversible}], returned}` \u2014 outstanding (not yet undone) changes only, oldest first. `reversible:true` means undoAll can restore that change exactly. `kind` \"transient\" is a one-shot action (a navigation, a tap) that changed no persistent state."
|
|
6227
|
+
"description": "Returns `{changes:[{id, toolId, action, kind, label, reversible}], returned}` \u2014 outstanding (not yet undone) changes only, oldest first. `reversible:true` means undoChange (with that `id`) or undoAll can restore that change exactly. `kind` \"transient\" is a one-shot action (a navigation, a tap) that changed no persistent state."
|
|
6228
|
+
},
|
|
6229
|
+
{
|
|
6230
|
+
"action": "undoChange",
|
|
6231
|
+
"summary": "Undo ONE change Ask Buoy made this conversation, by the id listChanges gave it. Use it for \"undo that\" when the user means a single change (usually the latest one) and other changes should stay.",
|
|
6232
|
+
"params": {
|
|
6233
|
+
"type": "object",
|
|
6234
|
+
"properties": {
|
|
6235
|
+
"id": {
|
|
6236
|
+
"type": "string",
|
|
6237
|
+
"description": "The change's id from listChanges, exactly as listChanges returned it, e.g. \"fx-3-1759330000000\"."
|
|
6238
|
+
}
|
|
6239
|
+
},
|
|
6240
|
+
"required": [
|
|
6241
|
+
"id"
|
|
6242
|
+
],
|
|
6243
|
+
"additionalProperties": false,
|
|
6244
|
+
"description": "`{id}` from listChanges."
|
|
6245
|
+
},
|
|
6246
|
+
"effect": "write",
|
|
6247
|
+
"release": "works",
|
|
6248
|
+
"description": "Returns `{ok:true, undone:{id, label}}`, or `{ok:false, error}` when the id is unknown, already undone, or the change can't be put back (it is permanent, or the same value was changed again since \u2014 the error says which). Report a refusal honestly; do not write the old value back by hand over a newer one.",
|
|
6249
|
+
"servedBy": "engine"
|
|
6207
6250
|
},
|
|
6208
6251
|
{
|
|
6209
6252
|
"action": "undoAll",
|
|
6210
|
-
"summary": "Undo every reversible change Ask Buoy made this conversation \u2014 deletes override rules it created, stops impersonation, restores storage keys to their prior values.
|
|
6253
|
+
"summary": "Undo every reversible change Ask Buoy made this conversation \u2014 deletes override rules it created, stops impersonation, restores storage keys, cache edits and store edits to their prior values. Use it when the user asks to undo everything or clean up; for one change use undoChange.",
|
|
6211
6254
|
"params": {
|
|
6212
6255
|
"type": "object",
|
|
6213
6256
|
"properties": {},
|
|
@@ -6216,7 +6259,7 @@
|
|
|
6216
6259
|
},
|
|
6217
6260
|
"effect": "write",
|
|
6218
6261
|
"release": "works",
|
|
6219
|
-
"description": "Returns `{ok, reverted, failed:[{label, error}], skippedTransients, permanent}`. Report the numbers honestly: `failed` entries were attempted and could not be restored (tell the user which, using the labels); `permanent` is how many changes were never undoable (state writes, refetches) and are still applied \u2014 say so, they are not failures; `skippedTransients` are one-shot actions that never needed undoing. This undoes ALL reversible changes from this conversation, newest first
|
|
6262
|
+
"description": "Returns `{ok, reverted, failed:[{label, error}], skippedTransients, permanent}`. Report the numbers honestly: `failed` entries were attempted and could not be restored (tell the user which, using the labels); `permanent` is how many changes were never undoable (state writes, refetches) and are still applied \u2014 say so, they are not failures; `skippedTransients` are one-shot actions that never needed undoing. This undoes ALL reversible changes from this conversation, newest first. To undo one change and keep the others, use undoChange instead."
|
|
6220
6263
|
},
|
|
6221
6264
|
{
|
|
6222
6265
|
"action": "retrieve",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const CATALOG_ACTIONS={"env":["getSnapshot"],"console":["getSnapshot","clearEntries"],"sentry":["getSnapshot","clearEnvelopes"],"jotai":["listAtoms","getAtomValue","getChangeDetail","setAtom","clearEvents"],"route-events":["getSnapshot","getCurrentRoute","navigate","stackGoBack","stackNavigateToIndex","stackPopToIndex","stackPopToTop","clearEvents"],"debug-borders":["cycleMode","setMode"],"zustand":["listStores","getStoreState","getChangeDetail","setState","rehydrate","clearEvents"],"redux":["getState","getActionDetail","dispatch","clearEvents"],"impersonate":["searchUsers","startImpersonation","stopImpersonation","pauseImpersonation","resumeImpersonation","updateSettings","removeFromHistory","clearHistory"],"query":["listQueries","getQueryData","refetch","invalidate","reset","remove","setQueryData","triggerError","restoreError","triggerLoading","restoreLoading","clearQueryCache","clearMutationCache","setOnline"],"events":["exportEvents","setEnabledSources","clearEvents"],"network":["getSnapshot","getCaptureStatus","getEventBody","setPinned","setSaved","removeSavedRecord","clearSavedRequests","clearPinnedRequests","clearEvents","listOverrideRules","getOverrideRuleBody","debugOverrides","upsertOverrideRule","setOverrideRuleEnabled","setOverridesEnabled","deleteOverrideRule","clearOverrideRules","getNetworkConditions","setNetworkConditions"],"js-top":["sample","getOriginDetail","setEnabled","pause","resume","clear"],"app":["ping","reloadApp"],"time-machine":["list","capture","captureBaseline","wipeAll","restore","preview","inspect","delete","rename","duplicate","setExclusions","setScope","setRestoreRoute"],"clock":["getState","setTime","shift","freeze","resume","setRate","reset","updateSettings","jumpToTokenExpiry","failNextRequest","stopTokenCheck"],"lifecycle":["getState","background","interrupt","returnToApp","memoryWarning","openUrl","pressBack","setColorScheme","setPower","resetPower","relaunch","runRecipe","clearReport","reset"],"location":["getState","setLocation","startRoute","pauseRoute","resumeRoute","stopRoute","seekRoute","setSpeed","enterRegion","exitRegion","setConditions","setSignal","setServices","tune","useRealLocation","reset","updateSettings","clearLog"],"permissions":["getState","setOverride","clearOverride","resetAll","requestReal","updateSettings","simulateReturnFromSettings","clearLog"],"storage":["getRequiredKeys","async.getAllKeys","async.multiGet","async.getItem","async.setItem","async.removeItem","async.multiRemove","async.multiSet","async.clear","clearAppStorage","getEventDetail","clearEvents","timeTravel.undo","timeTravel.jump","mmkv.snapshot","mmkv.get","mmkv.set","mmkv.remove","secure.keys","secure.snapshot","secure.get","secure.set","secure.delete"],"highlight-updates":["describeScreen","tapElement","waitFor","beginMeasurement","endMeasurement","locateComponent","getRenderDetail","setEnabled","toggle","setSilentTracking","toggleFreeze","setSpotlight","clearRenderCounts","startTouchCapture","stopTouchCapture","clearTouchCapture","readTouchCapture"],"scenarios":["listScenarios","getScenario","save","acceptDraft","discardDraft","preview","run","deactivate","delete","setFolder","listFolders","getActive","export"],"perf-monitor":["setEnabled","startRecording","stopRecording","savePending","discardPending","mark","startAutomation","cancelAutomation","acknowledgeAutomation","refreshIndex","getAutomationConfig","setAutomationConfig","loadReport","deleteReport","deleteBatch","clearAll"],"assets":["list","getDetail","rescan","measureSizes","saveBaseline","clearBaseline","getDiff","clearRecords","getScanStatus"],"tv-remote":["arm","getEventsSince","setMenuCapture","disarm","clear"],"focus-inspector":["rescan","focusElement","setTracking","clearHistory"],"images":["list","getDetail","getCaptureStatus","retry","flash","proveSavings","setOverride","clearOverride","setNetworkMode","setBlankImages","hardReload","evictDisk","massAction","clearRecords","clearExpoCaches"],"ask-buoy":["listChanges","undoAll","retrieve","openProcedure"],"push-notifications":["getSnapshot","getCapabilities","getEvent","getPermissions","listPresented","refreshToken","setCaptureSession","clearCapturedEvents","scheduleLocal"],"image-overlay":["getSnapshot","listTargets","selectTarget","loadImage","setSettings","fitToScreen","resetSettings","remove"]};
|
|
1
|
+
"use strict";export const CATALOG_ACTIONS={"env":["getSnapshot"],"console":["getSnapshot","clearEntries"],"sentry":["getSnapshot","clearEnvelopes"],"jotai":["listAtoms","getAtomValue","getChangeDetail","setAtom","clearEvents"],"route-events":["getSnapshot","getCurrentRoute","navigate","stackGoBack","stackNavigateToIndex","stackPopToIndex","stackPopToTop","clearEvents"],"debug-borders":["cycleMode","setMode"],"zustand":["listStores","getStoreState","getChangeDetail","setState","rehydrate","clearEvents"],"redux":["getState","getActionDetail","dispatch","clearEvents"],"impersonate":["searchUsers","startImpersonation","stopImpersonation","pauseImpersonation","resumeImpersonation","updateSettings","removeFromHistory","clearHistory"],"query":["listQueries","getQueryData","refetch","invalidate","reset","remove","setQueryData","triggerError","restoreError","triggerLoading","restoreLoading","clearQueryCache","clearMutationCache","setOnline"],"events":["exportEvents","setEnabledSources","clearEvents"],"network":["getSnapshot","getCaptureStatus","getEventBody","setPinned","setSaved","removeSavedRecord","clearSavedRequests","clearPinnedRequests","clearEvents","listOverrideRules","getOverrideRuleBody","debugOverrides","upsertOverrideRule","setOverrideRuleEnabled","setOverridesEnabled","deleteOverrideRule","clearOverrideRules","getNetworkConditions","setNetworkConditions"],"js-top":["sample","getOriginDetail","setEnabled","pause","resume","clear"],"app":["ping","reloadApp"],"time-machine":["list","capture","captureBaseline","wipeAll","restore","preview","inspect","delete","rename","duplicate","setExclusions","setScope","setRestoreRoute"],"clock":["getState","setTime","shift","freeze","resume","setRate","reset","updateSettings","jumpToTokenExpiry","failNextRequest","stopTokenCheck"],"lifecycle":["getState","background","interrupt","returnToApp","memoryWarning","openUrl","pressBack","setColorScheme","setPower","resetPower","relaunch","runRecipe","clearReport","reset"],"location":["getState","setLocation","startRoute","pauseRoute","resumeRoute","stopRoute","seekRoute","setSpeed","enterRegion","exitRegion","setConditions","setSignal","setServices","tune","useRealLocation","reset","updateSettings","clearLog"],"permissions":["getState","setOverride","clearOverride","resetAll","requestReal","updateSettings","simulateReturnFromSettings","clearLog"],"storage":["getSnapshot","getRequiredKeys","async.getAllKeys","async.multiGet","async.getItem","async.setItem","async.removeItem","async.multiRemove","async.multiSet","async.clear","clearAppStorage","getEventDetail","clearEvents","timeTravel.undo","timeTravel.jump","mmkv.snapshot","mmkv.get","mmkv.set","mmkv.remove","secure.keys","secure.snapshot","secure.get","secure.set","secure.delete"],"highlight-updates":["describeScreen","tapElement","waitFor","beginMeasurement","endMeasurement","locateComponent","getRenderDetail","setEnabled","toggle","setSilentTracking","toggleFreeze","setSpotlight","clearRenderCounts","startTouchCapture","stopTouchCapture","clearTouchCapture","readTouchCapture"],"scenarios":["listScenarios","getScenario","save","acceptDraft","discardDraft","preview","run","deactivate","delete","setFolder","listFolders","getActive","export"],"perf-monitor":["setEnabled","startRecording","stopRecording","savePending","discardPending","mark","startAutomation","cancelAutomation","acknowledgeAutomation","refreshIndex","getAutomationConfig","setAutomationConfig","loadReport","deleteReport","deleteBatch","clearAll"],"assets":["list","getDetail","rescan","measureSizes","saveBaseline","clearBaseline","getDiff","clearRecords","getScanStatus"],"tv-remote":["arm","getEventsSince","setMenuCapture","disarm","clear"],"focus-inspector":["rescan","focusElement","setTracking","clearHistory"],"images":["list","getDetail","getCaptureStatus","retry","flash","proveSavings","setOverride","clearOverride","setNetworkMode","setBlankImages","hardReload","evictDisk","massAction","clearRecords","clearExpoCaches"],"ask-buoy":["listChanges","undoChange","undoAll","retrieve","openProcedure"],"push-notifications":["getSnapshot","getCapabilities","getEvent","getPermissions","listPresented","refreshToken","setCaptureSession","clearCapturedEvents","scheduleLocal"],"image-overlay":["getSnapshot","listTargets","selectTarget","loadImage","setSettings","fitToScreen","resetSettings","remove"]};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const f=i=>!!i&&typeof i==="object"&&!Array.isArray(i);export function hashQueryKey(i){return JSON.stringify(i,(e,t)=>f(t)?Object.keys(t).sort().reduce((a,r)=>{a[r]=t[r];return a},{}):t)}function n(i,e,t,a){if(i[t]!==void 0||i[e]===void 0)return false;i[t]=i[e];delete i[e];a.push(`Accepted \`${e}\` as \`${t}\` \u2014 the parameter is named \`${t}\`.`);return true}const o=new Set(["getQueryData","refetch","invalidate","reset","remove","triggerError","restoreError","triggerLoading","restoreLoading"]);const l=["id","urlPattern","enabled","name","methods","kind","status","statusText","headers","body","bodyPatch","bodyPath","bodyValue","failKind","delayMs","times","alternate","force","bodyOmitted"];function h(i,e,t){if(o.has(i)&&e.queryHash===void 0){const a=f(e.filters)?e.filters:void 0;const r=e.queryKey??e.key??e.hash??a?.queryKey??a?.queryHash;if(Array.isArray(r)){e.queryHash=hashQueryKey(r);t.push(`Accepted the queryKey array as the query's hash (${e.queryHash}) \u2014 the parameter is \`queryHash\`, the string from listQueries.`)}else if(typeof r==="string"){e.queryHash=r;t.push(`Accepted it as \`queryHash\` \u2014 that is the parameter name.`)}delete e.queryKey;delete e.key;delete e.hash;delete e.filters}if(i==="setQueryData"){if(f(e.data)){for(const a of["merge","force"]){if(typeof e.data[a]==="boolean"&&e[a]===void 0){e[a]=e.data[a];delete e.data[a];t.push(`Moved \`${a}\` out of \`data\` to the top level \u2014 it is a write flag, not part of the value.`)}}}n(e,"newData","data",t)||e.path===void 0&&n(e,"value","data",t)||n(e,"patch","data",t);if(e.queryKey===void 0&&typeof e.queryHash==="string"){try{const a=JSON.parse(e.queryHash);if(Array.isArray(a)){e.queryKey=a;t.push("Accepted the queryHash as the key \u2014 setQueryData takes `queryKey`, the array.")}}catch{}}if(e.patch!==void 0||e.merge===void 0){if(t.some(a=>a.includes("`patch`")))e.merge=true}}}function c(i,e,t){if(i==="getEventBody"||i==="setPinned"||i==="setSaved"){n(e,"requestId","id",t)||n(e,"eventId","id",t)}if(i==="deleteOverrideRule"||i==="setOverrideRuleEnabled"||i==="getOverrideRuleBody"){n(e,"ruleId","id",t)}if(i==="upsertOverrideRule"){const a=f(e.rule)?{...e.rule}:{};if(e.fromRequestId===void 0&&typeof a.fromRequestId==="string"){e.fromRequestId=a.fromRequestId;t.push("Accepted `rule.fromRequestId` \u2014 it is a top-level parameter, beside `rule`.")}delete a.fromRequestId;y(a,t);m(e,a,t);const r=[];for(const d of l){if(e[d]!==void 0&&a[d]===void 0){a[d]=e[d];r.push(d)}delete e[d]}if(r.length)t.push(`Accepted ${r.map(d=>`\`${d}\``).join(", ")} at the top level \u2014 rule fields belong inside \`rule\`.`);if(Object.keys(a).length)e.rule=a}}function y(i,e){for(const[t,a]of[["match",["urlPattern","methods","method","url","pattern","urlContains","contains"]],["response",["status","statusText","body","headers","bodyPatch"]]]){const r=i[t];if(!f(r))continue;const d=[];for(const s of a){if(r[s]===void 0)continue;const u=s==="method"?"methods":s==="url"||s==="pattern"||s==="urlContains"||s==="contains"?"urlPattern":s;if(i[u]!==void 0)continue;i[u]=u==="methods"&&!Array.isArray(r[s])?[r[s]]:r[s];delete r[s];d.push(s)}if(!d.length)continue;if(!Object.keys(r).length)delete i[t];e.push(`Read \`rule.${t}.{${d.join(", ")}}\` as top-level rule fields \u2014 this rule is flat, unlike msw/nock-style mocks.`)}}function m(i,e,t){if(e.bodyPath===void 0&&typeof e.path==="string"){e.bodyPath=e.path;if(e.bodyValue===void 0&&e.value!==void 0)e.bodyValue=e.value;delete e.path;delete e.value;t.push("Read `path`/`value` as `bodyPath`/`bodyValue` \u2014 on a rule they address the response body.")}const a=s=>e[s]!==void 0?e[s]:i[s];const r=s=>{delete e[s];delete i[s]};const d=a("mode");if(typeof d==="string"&&["respond","fail","delay"].includes(d)&&e.kind===void 0){e.kind=d;t.push(`Read \`mode: "${d}"\` as \`kind: "${d}"\`.`)}r("mode");if(a("fail")===true&&e.kind===void 0){e.kind="fail";t.push('Read `fail: true` as `kind: "fail"` \u2014 a transport failure, as if offline.')}r("fail");if(a("failOnce")===true){if(e.kind===void 0)e.kind="fail";if(e.times===void 0)e.times=1;t.push('Read `failOnce: true` as `kind: "fail"` with `times: 1` \u2014 it fires once, then the rule disables itself.')}r("failOnce");if(a("once")===true&&e.times===void 0){e.times=1;t.push("Read `once: true` as `times: 1` \u2014 the rule auto-disables after one match.")}r("once");for(const s of["maxHits","hits","count","maxTimes","applyTimes"]){const u=a(s);if(typeof u==="number"&&Number.isFinite(u)&&u>0&&e.times===void 0){e.times=u;t.push(`Read \`${s}: ${u}\` as \`times: ${u}\` \u2014 the rule auto-disables after ${u} match(es).`)}r(s)}}function b(i,e,t){n(e,"name","storeName",t)||n(e,"store","storeName",t);if(i==="setState"){n(e,"statePatch","state",t)||n(e,"partial","state",t)||n(e,"patch","state",t)||n(e,"newState","state",t)||n(e,"nextState","state",t)||e.path===void 0&&n(e,"value","state",t);if(e.replace===void 0){e.replace=false;t.push("Applied replace:false (merge) \u2014 a store keeps action functions that can't be re-sent, and replacing would wipe them (the buttons that call them would then crash). Send replace:true only to deliberately reset the whole store.")}}}function g(i,e,t){if(i==="navigate"){n(e,"route","path",t)||n(e,"to","path",t)||n(e,"url","path",t)||n(e,"pathname","path",t)}}export function normalizeParams(i,e,t){const a={...t};const r=[];switch(i){case"query":h(e,a,r);break;case"network":c(e,a,r);break;case"zustand":b(e,a,r);break;case"route-events":g(e,a,r);break;default:break}return{params:a,notes:r}}export function aliasNote(i){return i.length?`
|
|
1
|
+
"use strict";const f=i=>!!i&&typeof i==="object"&&!Array.isArray(i);export function hashQueryKey(i){return JSON.stringify(i,(e,t)=>f(t)?Object.keys(t).sort().reduce((a,r)=>{a[r]=t[r];return a},{}):t)}function n(i,e,t,a){if(i[t]!==void 0||i[e]===void 0)return false;i[t]=i[e];delete i[e];a.push(`Accepted \`${e}\` as \`${t}\` \u2014 the parameter is named \`${t}\`.`);return true}const o=new Set(["getQueryData","refetch","invalidate","reset","remove","triggerError","restoreError","triggerLoading","restoreLoading"]);const l=["id","urlPattern","enabled","name","methods","kind","status","statusText","headers","body","bodyPatch","bodyPath","bodyValue","failKind","delayMs","times","alternate","force","bodyOmitted"];function h(i,e,t){if(o.has(i)&&e.queryHash===void 0){const a=f(e.filters)?e.filters:void 0;const r=e.queryKey??e.key??e.hash??a?.queryKey??a?.queryHash;if(Array.isArray(r)){e.queryHash=hashQueryKey(r);t.push(`Accepted the queryKey array as the query's hash (${e.queryHash}) \u2014 the parameter is \`queryHash\`, the string from listQueries.`)}else if(typeof r==="string"){e.queryHash=r;t.push(`Accepted it as \`queryHash\` \u2014 that is the parameter name.`)}delete e.queryKey;delete e.key;delete e.hash;delete e.filters}if(i==="setQueryData"){if(f(e.data)){for(const a of["merge","force"]){if(typeof e.data[a]==="boolean"&&e[a]===void 0){e[a]=e.data[a];delete e.data[a];t.push(`Moved \`${a}\` out of \`data\` to the top level \u2014 it is a write flag, not part of the value.`)}}}n(e,"newData","data",t)||e.path===void 0&&n(e,"value","data",t)||n(e,"patch","data",t);if(e.queryKey===void 0&&typeof e.queryHash==="string"){try{const a=JSON.parse(e.queryHash);if(Array.isArray(a)){e.queryKey=a;t.push("Accepted the queryHash as the key \u2014 setQueryData takes `queryKey`, the array.")}}catch{}}if(e.patch!==void 0||e.merge===void 0){if(t.some(a=>a.includes("`patch`")))e.merge=true}}}function c(i,e,t){if(i==="getEventBody"||i==="setPinned"||i==="setSaved"){n(e,"requestId","id",t)||n(e,"eventId","id",t)}if(i==="deleteOverrideRule"||i==="setOverrideRuleEnabled"||i==="getOverrideRuleBody"){n(e,"ruleId","id",t)}if(i==="upsertOverrideRule"){const a=f(e.rule)?{...e.rule}:{};if(e.fromRequestId===void 0&&typeof a.fromRequestId==="string"){e.fromRequestId=a.fromRequestId;t.push("Accepted `rule.fromRequestId` \u2014 it is a top-level parameter, beside `rule`.")}delete a.fromRequestId;y(a,t);m(e,a,t);const r=[];for(const d of l){if(e[d]!==void 0&&a[d]===void 0){a[d]=e[d];r.push(d)}delete e[d]}if(r.length)t.push(`Accepted ${r.map(d=>`\`${d}\``).join(", ")} at the top level \u2014 rule fields belong inside \`rule\`.`);if(typeof a.times==="number"&&a.times<=0){delete a.times;t.push("Read `times: 0` as no limit \u2014 leave `times` out for a rule that keeps firing; `times: 1` fires once.")}if(Object.keys(a).length)e.rule=a}}function y(i,e){for(const[t,a]of[["match",["urlPattern","methods","method","url","pattern","urlContains","contains"]],["response",["status","statusText","body","headers","bodyPatch"]]]){const r=i[t];if(!f(r))continue;const d=[];for(const s of a){if(r[s]===void 0)continue;const u=s==="method"?"methods":s==="url"||s==="pattern"||s==="urlContains"||s==="contains"?"urlPattern":s;if(i[u]!==void 0)continue;i[u]=u==="methods"&&!Array.isArray(r[s])?[r[s]]:r[s];delete r[s];d.push(s)}if(!d.length)continue;if(!Object.keys(r).length)delete i[t];e.push(`Read \`rule.${t}.{${d.join(", ")}}\` as top-level rule fields \u2014 this rule is flat, unlike msw/nock-style mocks.`)}}function m(i,e,t){if(e.bodyPath===void 0&&typeof e.path==="string"){e.bodyPath=e.path;if(e.bodyValue===void 0&&e.value!==void 0)e.bodyValue=e.value;delete e.path;delete e.value;t.push("Read `path`/`value` as `bodyPath`/`bodyValue` \u2014 on a rule they address the response body.")}const a=s=>e[s]!==void 0?e[s]:i[s];const r=s=>{delete e[s];delete i[s]};const d=a("mode");if(typeof d==="string"&&["respond","fail","delay"].includes(d)&&e.kind===void 0){e.kind=d;t.push(`Read \`mode: "${d}"\` as \`kind: "${d}"\`.`)}r("mode");if(a("fail")===true&&e.kind===void 0){e.kind="fail";t.push('Read `fail: true` as `kind: "fail"` \u2014 a transport failure, as if offline.')}r("fail");if(a("failOnce")===true){if(e.kind===void 0)e.kind="fail";if(e.times===void 0)e.times=1;t.push('Read `failOnce: true` as `kind: "fail"` with `times: 1` \u2014 it fires once, then the rule disables itself.')}r("failOnce");if(a("once")===true&&e.times===void 0){e.times=1;t.push("Read `once: true` as `times: 1` \u2014 the rule auto-disables after one match.")}r("once");for(const s of["maxHits","hits","count","maxTimes","applyTimes"]){const u=a(s);if(typeof u==="number"&&Number.isFinite(u)&&u>0&&e.times===void 0){e.times=u;t.push(`Read \`${s}: ${u}\` as \`times: ${u}\` \u2014 the rule auto-disables after ${u} match(es).`)}r(s)}}function b(i,e,t){n(e,"name","storeName",t)||n(e,"store","storeName",t);if(i==="setState"){n(e,"statePatch","state",t)||n(e,"partial","state",t)||n(e,"patch","state",t)||n(e,"newState","state",t)||n(e,"nextState","state",t)||e.path===void 0&&n(e,"value","state",t);if(e.replace===void 0){e.replace=false;t.push("Applied replace:false (merge) \u2014 a store keeps action functions that can't be re-sent, and replacing would wipe them (the buttons that call them would then crash). Send replace:true only to deliberately reset the whole store.")}}}function g(i,e,t){if(i==="navigate"){n(e,"route","path",t)||n(e,"to","path",t)||n(e,"url","path",t)||n(e,"pathname","path",t)}}export function normalizeParams(i,e,t){const a={...t};const r=[];switch(i){case"query":h(e,a,r);break;case"network":c(e,a,r);break;case"zustand":b(e,a,r);break;case"route-events":g(e,a,r);break;default:break}return{params:a,notes:r}}export function aliasNote(i){return i.length?`
|
|
2
2
|
|
|
3
3
|
[Buoy] ${i.join(" ")}`:""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{isSelfTraffic as y}from"../policy/redact";export const SNAPSHOT_ACTION="getSnapshot";const
|
|
1
|
+
"use strict";import{isSelfTraffic as y}from"../policy/redact";export const SNAPSHOT_ACTION="getSnapshot";const h={verbose:0,debug:0,trace:0,log:1,info:1,warn:2,warning:2,error:3};function p(e){return Array.isArray(e)?e:[]}function u(e){return e&&typeof e==="object"?e:{}}function d(e,t){return typeof e==="number"&&e>0?e:t}function m(e,t){return e.length<=t?e:e.slice(0,t)}function v(e,t){const r=p(u(e).entries);const l=typeof t.level==="string"?h[t.level]??0:0;const o=typeof t.pattern==="string"?t.pattern.toLowerCase():void 0;const f=r.filter(a=>{const n=u(a);const i=String(n.level??"log");if((h[i]??1)<l)return false;if(!o)return true;return String(n.message??"").toLowerCase().includes(o)});const s=m(f,d(t.limit,40));return{totalCaptured:r.length,shown:s.length,entries:s.map(a=>{const n=u(a);return{at:n.timestamp,level:n.level,message:n.message}})}}function w(e,t){const r=u(e);const l=p(r.events).filter(n=>!y(u(n).url));const o=t.failedOnly===true;const f=typeof t.pattern==="string"?t.pattern.toLowerCase():void 0;const s=l.filter(n=>{const i=u(n);const c=typeof i.status==="number"?i.status:void 0;if(o&&!(i.error||c!==void 0&&c>=400))return false;if(!f)return true;return String(i.url??"").toLowerCase().includes(f)});const a=m(s,d(t.limit,25));return{totalCaptured:l.length,shown:a.length,requests:a.map(n=>{const i=u(n);return{id:i.id,method:i.method,url:i.url,status:i.status,durationMs:i.duration,error:i.error,overridden:i.override?true:void 0}}),hint:"Read one response with network.getEventBody({ id })."}}function g(e,t=[],r=80){for(const l of p(e)){if(t.length>=r)break;const o=u(l);if(o.isInternal!==true&&typeof o.path==="string")t.push(o.path);g(o.children,t,r)}return t}function S(e,t){const r=s=>typeof s==="string"&&s.length>300?`${s.slice(0,300)}\u2026`:s;const l=typeof t.key==="string"?t.key.toLowerCase():void 0;const o=p(e).map(u).map(s=>{const a=u(s.data);return{id:s.id,at:s.timestamp,action:s.action,storage:s.storageType,key:a.key??a.keys,value:r(a.value),prevValue:r(a.prevValue)}}).filter(s=>!l||JSON.stringify(s.key??"").toLowerCase().includes(l)).sort((s,a)=>String(a.at).localeCompare(String(s.at)));const f=d(t.limit,20);return{events:o.slice(0,f),total:o.length,returned:Math.min(f,o.length)}}function k(e,t){const r=u(e);const l=u(r.sitemap);const o=p(r.stack).map(u);const f=p(r.events).map(u);const s=o.map(c=>({name:c.name,path:c.pathname,focused:c.isFocused===true?true:void 0}));const a=f.slice(0,d(t.limit,15)).map(c=>({at:c.timestamp,from:c.previousPathname,to:c.pathname}));const n=o.find(c=>c.isFocused===true)??o[o.length-1];const i=f.length?{path:f[0].pathname,source:"event"}:typeof n?.pathname==="string"?{path:n.pathname,source:"stack"}:void 0;return{currentRoute:i,stack:s,routes:g(l.routes),sitemapSource:l.source,recentNavigations:a}}function C(e){const t=u(e);return{env:t.env??t.variables,requiredEnvVars:t.requiredEnvVars}}function b(e,t){const r=u(e);const l=p(r.envelopes).map(u);const o=typeof t.type==="string"?t.type:void 0;const f=typeof t.pattern==="string"?t.pattern.toLowerCase():void 0;const s=l.filter(n=>{const i=p(n.items).map(u);if(o&&!i.some(c=>c.type===o))return false;if(!f)return true;return i.some(c=>String(c.summary??"").toLowerCase().includes(f))});const a=m(s,d(t.limit,10));return{status:r.status,totalCaptured:l.length,shown:a.length,envelopes:a.map(n=>({id:n.id,at:n.timestamp,origin:n.origin,eventId:n.eventId,totalBytes:n.totalBytes,items:p(n.items).map(i=>{const c=u(i);return{type:c.type,summary:c.summary,spanCount:c.spanCount,bytes:c.bytes}})})),hint:"For crash stack traces, console's [FATAL] entries carry the component stacks."}}export function projectSnapshot(e,t,r={}){switch(e){case"console":return v(t,r);case"network":return w(t,r);case"route-events":return k(t,r);case"storage":return S(t,r);case"env":return C(t);case"sentry":return b(t,r);default:return t}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{digestOf as
|
|
1
|
+
"use strict";import{digestOf as u}from"./digest";import{readLeaf as c,restorePatch as l}from"./storeDiff";export function isReversible(f){return f.kind!=="transient"&&f.kind!=="state-write"}let h=0;export class EffectLedger{entries=[];listeners=new Set;gen=0;get generation(){return this.gen}record(r,n,e,t){if(t!==void 0&&t!==this.gen)return void 0;const o={id:`fx-${++h}-${Date.now()}`,at:Date.now(),toolId:r,action:n,effect:e};this.entries=[...this.entries,o];this.emit();return o}list(){return this.entries}liveCallIds(){const r=new Set;for(const n of this.entries)if(!n.undoneAt&&n.callId)r.add(n.callId);return r}restore(r){if(this.entries.length>0||r.length===0)return false;this.entries=[...r];this.emit();return true}touch(){this.entries=[...this.entries];this.emit()}reversible(){return this.entries.filter(r=>!r.undoneAt&&isReversible(r.effect))}transients(){return this.entries.filter(r=>!r.undoneAt&&r.effect.kind==="transient")}isEmpty(){return this.entries.every(r=>r.undoneAt!==void 0)}subscribe(r){this.listeners.add(r);return()=>this.listeners.delete(r)}clear(){this.entries=[];this.gen+=1;this.emit()}noteExternalRevert(r,n,e){let t=false;const o=i=>{for(const s of this.entries){if(!s.undoneAt&&i(s)){s.undoneAt=Date.now();s.undoError=void 0;t=true}}};if(r==="network"&&n==="deleteOverrideRule"){o(i=>i.effect.kind==="network-override"&&i.effect.ruleId===e.id)}else if(r==="network"&&n==="clearOverrideRules"){o(i=>i.effect.kind==="network-override")}else if(r==="impersonate"&&n==="stopImpersonation"){o(i=>i.effect.kind==="impersonation")}else{o(i=>{const s=i.effect;if(s.kind!=="inverse-call"||s.toolId!==r||s.action!==n)return false;return Object.entries(s.params).every(([a,d])=>JSON.stringify(e[a]??(a==="enabled"?false:void 0))===JSON.stringify(d))})}if(t)this.touch();return t}emit(){for(const r of this.listeners){try{r()}catch{}}}async revertOne(r,n){if(r.undoneAt)return void 0;const e=r.effect;try{switch(e.kind){case"network-override":await n("network","deleteOverrideRule",{id:e.ruleId});break;case"impersonation":await n("impersonate","stopImpersonation",{});break;case"storage-write":{const t=e.instanceId?{instanceId:e.instanceId}:{};if(e.wrote!==void 0){const o=e.action==="mmkv.set"?"mmkv.get":"async.getItem";try{const i=await n(e.toolId,o,{...t,key:e.key});const s=i&&typeof i==="object"?i:void 0;const a=s?s.value:i;if(s?.found!==false&&a!==void 0&&a!==e.wrote){return"This value was changed again after Ask Buoy wrote it \u2014 left the newer value alone"}}catch{}}if(e.before===void 0){if(!e.removeAction)return"No remove action known for this key";await n(e.toolId,e.removeAction,{...t,key:e.key})}else{await n(e.toolId,e.action,{...t,key:e.key,value:e.before})}break}case"query-write":{if(e.wroteDigest!==void 0){try{const o=await n("query","getQueryData",{queryHash:e.queryHash});if(o?.found===true){const i=o.hasData===false?void 0:u(o.data);if(i!==e.wroteDigest){return"The app has refetched or changed this query since Ask Buoy wrote it \u2014 left the newer data alone"}}}catch{}}const t=await(e.before===void 0?n("query","invalidate",{queryHash:e.queryHash}):n("query","setQueryData",{queryHash:e.queryHash,data:e.before,force:true}));if(t&&typeof t==="object"&&t.ok===false){return typeof t.error==="string"?t.error:"The query could not be restored"}break}case"store-write":{let t;try{const i=await n(e.toolId,"getStoreState",{storeName:e.storeName});t=i?.found===true?i.currentState:void 0}catch{t=void 0}if(!t||typeof t!=="object"){return"Couldn't read the store to check for newer changes, so nothing was undone"}{const i=e.leaves.filter(s=>{const a=c(t,s.path);return!a.found||u(a.value)!==s.wroteDigest});if(i.length){return`${i.map(s=>s.path.join(".")).join(", ")} changed again after Ask Buoy wrote it \u2014 left the newer value alone`}}const o=await n(e.toolId,"setState",{storeName:e.storeName,state:l(e.leaves),replace:false,force:true});if(o&&typeof o==="object"&&o.ok===false){return typeof o.error==="string"?o.error:"The store could not be restored"}break}case"inverse-call":{const t=await n(e.toolId,e.action,e.params);if(t&&typeof t==="object"&&t.ok===false){return typeof t.error==="string"?t.error:"The change could not be undone"}break}case"state-write":return"This change can't be undone automatically";case"transient":return void 0}r.undoneAt=Date.now();r.undoError=void 0;this.touch();return void 0}catch(t){const o=t instanceof Error?t.message:String(t);r.undoError=o;this.touch();return o}}async revertAll(r){const n={reverted:0,failed:[],skippedTransients:0,permanent:0};const e=[...this.entries].filter(t=>!t.undoneAt).reverse();for(const t of e){if(t.effect.kind==="transient"){n.skippedTransients+=1;continue}if(!isReversible(t.effect)){n.permanent+=1;continue}const o=await this.revertOne(t,r);if(o)n.failed.push({label:t.effect.label,error:o});else n.reverted+=1}this.emit();return n}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{digestOf as l}from"./digest";const c=n=>typeof n==="object"&&n!==null&&!Array.isArray(n);export function diffLeaves(n,o){const e=[];const t=(r,f,i)=>{if(c(r)&&c(f)){const d=Object.keys(r);const u=Object.keys(f);if(d.length!==u.length||u.some(s=>!(s in r)))return false;return u.every(s=>t(r[s],f[s],[...i,s]))}const a=l(f);if(l(r)!==a)e.push({path:i,before:r,wroteDigest:a});return true};return t(n,o,[])?e:void 0}export function readLeaf(n,o){let e=n;for(const t of o){if(!c(e)||!(t in e))return{found:false};e=e[t]}return{found:true,value:e}}export function restorePatch(n){const o={};for(const e of n){let t=o;e.path.forEach((r,f)=>{if(f===e.path.length-1)t[r]=e.before;else t=t[r]=c(t[r])?t[r]:{}})}return o}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=/^[\s-]*$/;const l=o=>o.label||o.text||"";export function compactScreen(o){const s=o;if(!s||!Array.isArray(s.elements))return o;const a=new Map;for(const e of s.elements){const n=JSON.stringify([e.role,e.name.split("(")[0],l(e),e.testID,e.control,e.frame]);const t=a.get(n);if(!t||(e.nativeTag??0)>(t.nativeTag??0))a.set(n,e)}const c=[...a.values()].sort((e,n)=>(n.nativeTag??0)-(e.nativeTag??0));const r=[];let i;for(const e of c){const n=l(e);if(!e.testID&&!e.control&&f.test(n))continue;if(e.name==="Text"&&!e.testID&&i&&i.nativeTag!==null&&e.nativeTag!==null&&i.nativeTag-e.nativeTag<=12&&l(i).includes(n)){continue}const t=[String(e.nativeTag),e.role??e.name.split("(")[0],JSON.stringify(e.label&&e.text&&e.text!==e.label?`${e.label} / ${e.text}`:n)];if(e.testID)t.push(`testID=${e.testID}`);if(e.control)t.push(`${e.control}=${JSON.stringify(e.value)}`);if(e.longPressable)t.push("longPress");if(!e.interactive)t.push("not tappable");if(e.frame&&(e.frame.y>=1||e.frame.y+e.frame.height<=0))t.push("off-screen");r.push(t.join(" \xB7 "));i=e}return{screen:s.screen,count:r.length,...s.hiddenBuoy?{hiddenBuoy:s.hiddenBuoy}:{},...s.lists?.length?{lists:s.lists.map(e=>`${e.owner??"A list"} holds ${e.items} items; only ${e.listed} are listed above (the rest are further down). Count items from the data behind the list (its query or store), not from these rows.`)}:{},format:"nativeTag \xB7 role or component \xB7 label/text \xB7 extras. Newest first: the screen opened last is at the top, screens still mounted beneath it follow. Tap with tapElement {nativeTag}; off-screen rows scroll into view on tap.",elements:r}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{describeCall as
|
|
1
|
+
"use strict";import{describeCall as w}from"../policy/policy";import{digestOf as q,jsonLength as g}from"../effects/digest";import{diffLeaves as b}from"../effects/storeDiff";const v=64e3;const k=n=>n&&typeof n==="object"?n:void 0;const m={setQueryData:"query.invalidate",triggerError:"query.restoreError",triggerLoading:"query.restoreLoading",setOnline:"query.setOnline"};export function effectFor(n,t,i,h,f,d){const r=w(n,t,i);const l=h??{};if(n==="network"&&t.action==="upsertOverrideRule"){const e=l.rule;const a=e?.id??l.id;const s=i.id===void 0;if(a&&s)return{kind:"network-override",ruleId:a,label:r};return{kind:"state-write",toolId:n,action:t.action,label:r}}if(n==="impersonate"&&t.action==="startImpersonation"){return{kind:"impersonation",label:`${r} \u2014 stopping also clears cached app data`}}if(n==="storage"&&typeof i.key==="string"&&f){const e=t.action.startsWith("mmkv.");const a=e?"mmkv.set":"async.setItem";return{kind:"storage-write",toolId:n,action:a,key:i.key,instanceId:e&&typeof i.instanceId==="string"?i.instanceId:void 0,before:f.had?f.value:void 0,wrote:typeof i.value==="string"?i.value:void 0,removeAction:e?"mmkv.remove":"async.removeItem",label:r}}if(n==="query"&&t.action==="setQueryData"){const e=k(d?.before);const a=typeof i.queryHash==="string"?i.queryHash:e?.queryHash;if(e?.found===true&&typeof a==="string"){const s=e.hasData!==false&&e.data!==void 0;const u=s?e.data:void 0;if(g(u)<=v){const o=k(d?.after);const c=o?.found===true&&o.hasData!==false?q(o.data):void 0;return{kind:"query-write",queryHash:a,before:u,wroteDigest:c,label:r}}return{kind:"state-write",toolId:n,action:t.action,label:`${r} \u2014 prior value too large to hold for undo; undo with query.invalidate`}}}if(n==="zustand"&&t.action==="setState"&&typeof i.storeName==="string"){const e=o=>{const c=o&&typeof o==="object"?o:void 0;const y=c?.found===true?c.currentState:void 0;return y&&typeof y==="object"&&!Array.isArray(y)?y:void 0};const a=e(d?.before);const s=e(d?.after);const u=a&&s?b(a,s):void 0;if(u&&u.length===0)return void 0;if(u&&u.every(o=>o.path.length>0)&&g(u)<=v){return{kind:"store-write",toolId:n,storeName:i.storeName,leaves:u,label:r}}return{kind:"state-write",toolId:n,action:t.action,label:u?`${r} \u2014 too large to hold for undo`:`${r} \u2014 added or removed fields, so it can't be undone exactly`}}if(n==="query"&&typeof i.queryHash==="string"){const e=t.action==="triggerLoading"?"restoreLoading":t.action==="triggerError"?"restoreError":void 0;if(e){return{kind:"inverse-call",toolId:n,action:e,params:{queryHash:i.queryHash},label:r}}}if(n==="query"&&["refetch","invalidate","restoreLoading"].includes(t.action)){return{kind:"transient",label:r}}if(n==="network"&&(t.action==="setOverrideRuleEnabled"||t.action==="setOverridesEnabled")&&f?.had&&(f.value==="true"||f.value==="false")){const e=f.value==="true";const a=i.enabled===true;if(e===a)return void 0;const s=t.action==="setOverrideRuleEnabled"?{id:i.id,enabled:e}:{enabled:e};return{kind:"inverse-call",toolId:n,action:t.action,params:s,label:r}}if(n==="query"&&t.effect!=="read"){const e=m[t.action];return{kind:"state-write",toolId:n,action:t.action,label:e?`${r} \u2014 undo with ${e}`:r}}if(t.effect==="destructive"){return{kind:"state-write",toolId:n,action:t.action,label:r}}return{kind:"transient",label:r}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const PLAN_ONLY_NUDGE="[Buoy, not the user: your last message said what you would do next but called no tool, so nothing ran and the turn would end there. If the task is not finished, make the next call now. If you are done, say so. If the user has to pick or answer, send the buoy_ui block (choice, confirm or input) now \u2014 text alone gives them nothing to tap.]";export const SILENT_NUDGE="[Buoy, not the user: you ended the turn without a word to the user. Tell them in a sentence or two what you found or did \u2014 a card alone does not say it.]";const n=/\b(if you|once you|when you|after you|only if|let me know|would you like|do you want|shall i|should i|tap|choose|approve)\b/i;const r=/\b(?:tap|press|click|choose|select)\s+\**["“]?(?:go|approve|yes|continue|start|confirm)\b|ready for your (?:approval|go-ahead|ok)|(?:plan|steps|card|options?) (?:above|below)\b|approve the plan|for your (?:approval|go-ahead)|here['’]s the (?:plan|flow|steps)\b|\b(?:choose|pick|select) (?:what|which|one|from)\b[^.?!]*:/i;const i=/\b(?:pick|choose|select|tell me) (?:what|which)\b/i;const a=/\b(i['’]ll|i will|let me|i['’]m going to|i am going to|next,? i|now i['’]ll|i['’]m about to)\b/i;const u=/\bi['’]m (?:now )?(?!sorry\b)[a-z]+ing\b/i;export function announcesUnstartedWork(s){const t=s.trim();if(r.test(t))return true;if(i.test(t))return true;if(/:\s*$/.test(t))return true;if(!t||/\?\s*$/.test(t))return false;const e=t.split(/(?<=[.!*])\s*(?=[A-Z“"])/);const o=e.slice(-2).join(" ");if(u.test(e.at(-1)??"")&&!n.test(o))return true;return a.test(o)&&!n.test(o)}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";import{CATALOG as Ge}from"../catalog/catalog.g";import{applyDefaults as ae,validateParams as de}from"../catalog/validateParams";import{normalizeParams as le,aliasNote as ct}from"../catalog/normalizeParams";import{fromProviderToolName as X,toProviderTools as ft}from"../catalog/toProviderTools";import{hashQueryKey as ut}from"../catalog/normalizeParams";import{projectSnapshot as pt,SNAPSHOT_ACTION as Je}from"../catalog/snapshotReads";import{isReversible as ht}from"../effects/ledger";import{describeCall as we,decide as G}from"../policy/policy";import{redact as mt,stripSelfTraffic as yt}from"../policy/redact";import{effectFor as Ye}from"./effectFor";import{digestOf as ve}from"../effects/digest";import{buildUiBlock as gt,UI_TOOL_NAME as Z,uiProviderTool as kt}from"../blocks/uiTool";import{projectReceipt as bt}from"../blocks/receipts";import{isAskBlock as wt}from"../blocks/types";import{ACQUISITION_CALLS as vt,synthesizeAskBlock as Rt,synthesizeShortfallBlock as Tt}from"./askGate";import{couldBeToolCallEnvelope as It,parseTextToolCalls as St,SALVAGE_NOTE as At}from"./textToolCalls";import{budgetForRequest as Ke,MAX_HISTORY_TOKENS as Et,messageSize as Re}from"./historyBudget";import{promptTokensOf as $t,TokenCalibration as Ct}from"./tokenCalibration";import{truncationMarker as Nt}from"./evidence";import{retrieveEvidence as _t}from"./retrieve";import{verificationTrailer as Ot,verifyOutcome as xt}from"./verify";import{realClearTimeout as Mt,realNow as I,realSetTimeout as Lt}from"../realNow";const Ve=24e3;const Qe=2e3;const Xe=3;function Pt(t){const n=r=>{if(r===null||typeof r!=="object")return r;if(Array.isArray(r))return r.map(n);const l=r;return Object.keys(l).sort().reduce((c,k)=>(c[k]=n(l[k]),c),{})};return t.map(r=>`${r.name}:${JSON.stringify(n(r.input??{}))}`).join("|")}const Ut="[Buoy] You have now made this exact call three times in a row and gotten the same thing back. Repeating it again will not change the answer. Read the result you already have, then either try a different tool or different arguments, or tell the user plainly what you could not get and what you tried.";const Dt=12;const Ze=18e4;const qt=2;const jt=1;const Bt=1e3;const Ft=250;const Ht=3e4;function zt(t,n){return new Promise(r=>{if(n?.aborted)return r();const l=Lt(c,t);function c(){Mt(l);n?.removeEventListener("abort",c);r()}n?.addEventListener("abort",c,{once:true})})}function et(t){if(typeof t==="boolean")return{approved:t,trust:false};const n=t.reason?.trim();return{approved:t.approved,...n?{reason:n}:{},trust:t.trust===true&&t.approved}}function tt(t){return t?`The user declined this change and said: "${t}". Do not retry it as proposed; take their note into account and, if a different change would fit, propose that instead.`:"The user declined this change. Do not retry it; ask what they would prefer."}function D(t,n,r){return t.find(l=>l.toolId===n)?.actions.find(l=>l.action===r)}const Wt="Rejected: every image URL must be one you read from a tool result in THIS conversation (images.list, a storage value, a response body). Never invent or remember URLs \u2014 read them first, then show them.";const Gt=t=>` NOTE: ${t} image ${t===1?"URL was":"URLs were"} dropped \u2014 they were not read from a tool result in this conversation, so the card the user is looking at has no picture there. Do not tell them it does; read the URLs and show it again, or say the artwork is missing.`;function Jt(t){try{return JSON.stringify(t??null)}catch{return String(t)}}function Yt(t,n){if(t.length<=Ve)return t;return`${t.slice(0,Ve)}${Nt(t.length,n)}`}function Kt(t){if(t===null||t===void 0)return"Done";if(Array.isArray(t))return Te(t.length);if(typeof t==="boolean")return t?"Done":"Failed";if(typeof t==="object"){const n=t;if(n.ok===false)return typeof n.error==="string"?n.error:"Failed";if(n.found===false)return"Not found";if(n.tapped===false)return"Nothing to tap";if(n.active===false)return"Saved, but inactive in this build";for(const l of["returned","count","total"]){const c=n[l];if(typeof c==="number")return Te(c)}const r=Object.values(n).filter(Array.isArray);if(r.length===1)return Te(r[0].length);return"Done"}return String(t).slice(0,80)}function Te(t){return t===1?"1 item":`${t} items`}function ot(t){return typeof t==="object"&&t!==null&&t.ok===false}export async function*runAgentTurn(t){const{provider:n,catalog:r,system:l,systemVolatile:c,model:k,maxTokens:y,dispatch:f,readSnapshot:m,storeKeyOwners:J,ledger:w,policy:M,isRelease:L,requestApproval:q,signal:N,evidence:j,trusted:v,procedures:B}=t;const F=new Map;const _=t.calibration??new Ct;const p=[...t.messages];const ce=ft(r,{availableToolIds:t.availableToolIds,availableActions:t.availableActions,isRelease:L});ce.push(kt());const Se=M.maxSteps??Dt;const rt=w.generation;const Ae=l.length+(c?.length??0)+ce.reduce((ne,O)=>ne+O.description.length+JSON.stringify(O.inputSchema).length,0);const Ee=()=>Ae+_.chars(y);let te=I()+Ze;const fe={throttled:0,overflow:0};let oe=Et;const ue=t.seenUrls??new Set;const it=/https?:\/\/[^\s"'\\)\]}>]+/g;let $e=false;const H=[];let Ce=false;const Ne=[];let _e=false;let Oe=false;for(let ne=0;ne<Se;ne++){if(N?.aborted){yield{type:"done",stopReason:"stopped"};return p}if(I()>te){yield{type:"block",block:{id:`cap${I()}`,kind:"notice",tone:"warning",text:`This is taking too long \u2014 stopped after ${Math.round(Ze/1e3)}s. What it found so far is above.`,actions:[{label:"Continue",primary:true,send:"Continue where you left off."}]}};yield{type:"done",stopReason:"time-cap"};return p}const O=Ke(p,Ee(),_.chars(oe),_.charsPerToken,w.liveCallIds());if(O.droppedRounds>0){p.length=0;p.push(...O.messages);yield{type:"history-trimmed",droppedRounds:O.droppedRounds,droppedPinned:O.droppedPinned}}else if(O.messages!==p){p.length=0;p.push(...O.messages)}let $="";let xe=false;const z=e=>{const o=$e&&!xe;xe=true;$e=true;return o?{type:"text",delta:e,breakBefore:true}:{type:"text",delta:e}};let b=[];const Me=new Set;let C="";let pe=true;let Y=[];let re=false;let ie;let W;for(;;){$="";b=[];C="";pe=true;Y=[];re=false;ie=void 0;W=void 0;let e;const o=Ae+p.reduce((s,A)=>s+Re(A),0);for await(const s of n.send({messages:p,system:l,systemVolatile:c,tools:ce,model:k,maxTokens:y,signal:N})){if(s.type==="text"){$+=s.delta;if(!pe){yield z(s.delta)}else if(It($)){C+=s.delta}else{pe=false;C="";yield z($)}}else if(s.type==="tool-call"){b.push(s.call)}else if(s.type==="thinking"){Y.push(s.block);if(s.block.type==="thinking"&&s.block.thinking.trim()){yield{type:"reasoning",text:s.block.thinking}}}else if(s.type==="error"){if(s.kind==="truncated"||s.kind==="timeout"){W={message:s.message}}else if(s.problem&&(s.problem.kind==="throttled"||s.problem.kind==="overflow")&&$===""&&b.length===0&&Y.length===0){e={problem:s.problem,message:s.message}}else{yield{type:"error",message:s.message};re=true}}else if(s.type==="done"){ie=s.outcome;if(s.usage){_.observe(o,$t(s.usage,n.protocol));yield{type:"usage",...s.usage,model:s.model}}}}if(!e)break;const i=e.problem.kind;const u=1+(i==="throttled"?qt:jt);const d=fe[i];let S=i==="throttled"?Math.min(e.problem.retryAfterMs??Bt*2**d,Ht)+Math.floor(Math.random()*Ft):0;let E=d>=u-1||N?.aborted===true||I()+S>te;if(!E&&i==="overflow"){oe=Math.floor(oe/2);const s=p.reduce((U,x)=>U+Re(x),0);const A=Ke(p,Ee(),_.chars(oe),_.charsPerToken,w.liveCallIds());const K=A.messages.reduce((U,x)=>U+Re(x),0);if(K>=s){E=true}else{p.length=0;p.push(...A.messages);if(A.droppedRounds>0)yield{type:"history-trimmed",droppedRounds:A.droppedRounds,droppedPinned:A.droppedPinned}}}if(E){const s=i==="throttled"?d>0?`The AI endpoint is rate-limiting requests \u2014 tried ${d+1} times.`:"The AI endpoint is rate-limiting requests.":"This conversation is too large for the AI endpoint and there was nothing older to trim. Start a new conversation, or ask a shorter question.";yield{type:"error",message:`${s} (${e.message})`};re=true;break}fe[i]+=1;yield{type:"retrying",reason:i,attempt:fe[i]+1,maxAttempts:u,inMs:S};if(S>0)await zt(S,N);if(N?.aborted){yield{type:"done",stopReason:"stopped"};return p}}if(re){if(C)yield z(C);yield{type:"done",stopReason:"error"};return p}if(!W&&ie!=="completed"){W={message:ie==="output-limited"?b.length?"The model ran out of room mid-plan, so nothing was run. What it found so far is above.":"The model ran out of room before finishing this answer.":"The answer ended before the endpoint said it was finished, so nothing was run."}}if(W){if(C)yield z(C);if($.trim())p.push({role:"assistant",text:$});yield{type:"block",block:{id:`cut${I()}`,kind:"notice",tone:"warning",text:W.message,actions:[{label:"Continue",primary:true,send:"Continue where you left off."}]}};yield{type:"done",stopReason:"incomplete"};return p}if(C){const e=b.length===0?St(C,r):void 0;if(e){for(const o of e.calls){b.push(o);Me.add(o.id)}$=e.reply;if(e.reply)yield z(e.reply)}else{yield z(C)}C=""}p.push({role:"assistant",text:$,toolCalls:b.length?b:void 0,thinking:Y.length?Y:void 0});if($.trim())Ne.push($.trim());if(b.length===0){const e=Ne.join("\n\n");const o=Tt({text:e,attempted:Oe});if(o)yield{type:"block",block:o};const i=_e||o?null:Rt(e);if(i){yield{type:"block",block:i};yield{type:"awaiting-user",blockId:i.id}}yield{type:"done",stopReason:i?"awaiting-user":"answered"};return p}const g=[];let Le=false;const Pe=new Map;if(b.length>1){const e=b.every(o=>{if(o.name===Z)return false;const i=X(o.name,r);if(!i||i==="ask-buoy")return false;const u=o.input?.action;if(typeof u!=="string"||u===Je)return false;const d=D(r,i,u);if(!d||d.effect!=="read")return false;return G({descriptor:d,toolId:i,policy:M,isRelease:L}).verdict==="allow"});if(e){for(const o of b){const i=X(o.name,r);const u=String(o.input.action);const d={...o.input.params??{}};const S=D(r,i,u);const E=le(i,u,d);const s=ae(E.params,S.params);if(!de(s,S.params).ok)continue;const A=Promise.resolve(f(i,u,s)).catch(K=>{throw K});A.catch(()=>{});Pe.set(o.id,A)}}}let he=null;const st=e=>{const o=X(e.name,r)??e.name;const i=typeof e.input?.action==="string"?e.input.action:"";const u=i?D(r,o,i):void 0;const d=e.input?.params??{};return[{type:"tool-start",id:e.id,toolId:o,action:i,label:u?we(o,u,d):`${o}.${i}`,description:u?.summary??"",params:d,effect:u?.effect??"read"},{type:"tool-end",id:e.id,ok:false,summary:"stopped",durationMs:0}]};const Ue=b.map(e=>{if(e.name===Z)return void 0;const o=X(e.name,r);const i=typeof e.input?.action==="string"?e.input.action:void 0;if(!o||!i)return void 0;const u=D(r,o,i);if(!u)return void 0;const d=e.input.params??{};const S=ae(le(o,i,d).params,u.params);if(!de(S,u.params).ok)return void 0;const E=G({descriptor:u,toolId:o,policy:M,isRelease:L});return{call:e,toolId:o,action:i,descriptor:u,params:S,label:we(o,u,S),mutates:u.effect!=="read",gated:E.verdict==="needs-approval",reason:E.verdict==="needs-approval"?E.reason:""}});const at=Ue.some(e=>e?.gated);const P=new Map;let De=false;let qe=false;async function*dt(){De=true;for(const e of Ue){if(!e?.gated||P.has(e.call.id))continue;if(v?.has(`${e.toolId}.${e.action}`)){P.set(e.call.id,true);continue}yield{type:"approval-required",id:e.call.id,toolId:e.toolId,action:e.action,label:e.label,description:e.descriptor.summary,reason:e.reason};const o=I();const i=await readTargetDigest({toolId:e.toolId,action:e.action,params:e.params,dispatch:f,catalog:r});const u=et(v?.has(`${e.toolId}.${e.action}`)?true:q?await q({id:e.call.id,toolId:e.toolId,action:e.action,label:e.label,description:e.descriptor.summary,reason:e.reason,params:e.params,targetDigest:i}):false);te+=I()-o;const d=u.approved;P.set(e.call.id,d);if(u.trust)v?.add(`${e.toolId}.${e.action}`);if(u.reason)F.set(e.call.id,u.reason);if(!d){qe=true;return}}}for(const e of b){if(N?.aborted){if(e.name!==Z){for(const a of st(e))yield a}g.push({toolCallId:e.id,content:"Not run \u2014 the user pressed Stop before this call started.",isError:true});continue}if(e.name===Z){const a=gt(e.input);if(!a.ok||!a.block){g.push({toolCallId:e.id,content:`Invalid ${Z} block:
|
|
2
|
-
${
|
|
1
|
+
"use strict";import{CATALOG as Qe}from"../catalog/catalog.g";import{applyDefaults as ce,validateParams as fe}from"../catalog/validateParams";import{normalizeParams as ue,aliasNote as gt}from"../catalog/normalizeParams";import{fromProviderToolName as ee,toProviderTools as kt}from"../catalog/toProviderTools";import{hashQueryKey as bt}from"../catalog/normalizeParams";import{projectSnapshot as wt,SNAPSHOT_ACTION as Ve}from"../catalog/snapshotReads";import{UNPARSEABLE_ARGS as vt}from"../providers/types";import{isReversible as Xe}from"../effects/ledger";import{describeCall as Ae,decide as Y}from"../policy/policy";import{redact as Rt,stripSelfTraffic as St}from"../policy/redact";import{effectFor as Ze}from"./effectFor";import{digestOf as Ie}from"../effects/digest";import{buildUiBlock as Tt,UI_TOOL_NAME as te,uiProviderTool as At}from"../blocks/uiTool";import{projectReceipt as It}from"../blocks/receipts";import{isAskBlock as Et}from"../blocks/types";import{ACQUISITION_CALLS as $t,synthesizeAskBlock as Ct,synthesizeShortfallBlock as Nt}from"./askGate";import{couldBeToolCallEnvelope as Ot,parseTextToolCalls as _t,SALVAGE_NOTE as xt}from"./textToolCalls";import{announcesUnstartedWork as Lt,PLAN_ONLY_NUDGE as Pt,SILENT_NUDGE as Ut}from"./planOnlyStop";import{compactScreen as Mt}from"./compactScreen";import{budgetForRequest as et,MAX_HISTORY_TOKENS as Dt,messageSize as Ee}from"./historyBudget";import{promptTokensOf as qt,TokenCalibration as jt}from"./tokenCalibration";import{truncationMarker as Bt}from"./evidence";import{retrieveEvidence as Ft}from"./retrieve";import{verificationTrailer as Ht,verifyOutcome as Wt}from"./verify";import{realClearTimeout as zt,realNow as I,realSetTimeout as Gt}from"../realNow";const tt=24e3;const ot=2e3;const nt=3;function Jt(t){const n=r=>{if(r===null||typeof r!=="object")return r;if(Array.isArray(r))return r.map(n);const c=r;return Object.keys(c).sort().reduce((f,R)=>(f[R]=n(c[R]),f),{})};return t.map(r=>`${r.name}:${JSON.stringify(n(r.input??{}))}`).join("|")}const Yt="[Buoy] You have now made this exact call three times in a row and gotten the same thing back. Repeating it again will not change the answer. Read the result you already have, then either try a different tool or different arguments, or tell the user plainly what you could not get and what you tried.";const Kt=24;const rt=18e4;const Qt=2;const Vt=1;const Xt=1e3;const Zt=250;const eo=3e4;function to(t,n){return new Promise(r=>{if(n?.aborted)return r();const c=Gt(f,t);function f(){zt(c);n?.removeEventListener("abort",f);r()}n?.addEventListener("abort",f,{once:true})})}function it(t){if(typeof t==="boolean")return{approved:t,trust:false};const n=t.reason?.trim();return{approved:t.approved,...n?{reason:n}:{},trust:t.trust===true&&t.approved}}function st(t){return t?`The user declined this change and said: "${t}". Do not retry it as proposed; take their note into account and, if a different change would fit, propose that instead.`:"The user declined this change. Do not retry it; ask what they would prefer."}function q(t,n,r){return t.find(c=>c.toolId===n)?.actions.find(c=>c.action===r)}const oo="Rejected: every image URL must be one you read from a tool result in THIS conversation (images.list, a storage value, a response body). Never invent or remember URLs \u2014 read them first, then show them.";const no=t=>` NOTE: ${t} image ${t===1?"URL was":"URLs were"} dropped \u2014 they were not read from a tool result in this conversation, so the card the user is looking at has no picture there. Do not tell them it does; read the URLs and show it again, or say the artwork is missing.`;function ro(t){try{return JSON.stringify(t??null)}catch{return String(t)}}function io(t,n){if(t.length<=tt)return t;return`${t.slice(0,tt)}${Bt(t.length,n)}`}function so(t){if(t===null||t===void 0)return"Done";if(Array.isArray(t))return $e(t.length);if(typeof t==="boolean")return t?"Done":"Failed";if(typeof t==="object"){const n=t;if(n.ok===false)return typeof n.error==="string"?n.error:"Failed";if(n.found===false)return"Not found";if(n.tapped===false)return"Nothing to tap";if(n.active===false)return"Saved, but inactive in this build";for(const c of["returned","count","total"]){const f=n[c];if(typeof f==="number")return $e(f)}const r=Object.values(n).filter(Array.isArray);if(r.length===1)return $e(r[0].length);return"Done"}return String(t).slice(0,80)}function $e(t){return t===1?"1 item":`${t} items`}function at(t){return typeof t==="object"&&t!==null&&t.ok===false}export async function*runAgentTurn(t){const{provider:n,catalog:r,system:c,systemVolatile:f,model:R,maxTokens:g,dispatch:a,readSnapshot:m,storeKeyOwners:N,ledger:w,policy:L,isRelease:P,requestApproval:j,signal:O,evidence:B,trusted:T,procedures:F}=t;const H=new Map;const _=t.calibration??new jt;const h=[...t.messages];const pe=kt(r,{availableToolIds:t.availableToolIds,availableActions:t.availableActions,isRelease:P});pe.push(At());const ne=L.maxSteps??Kt;const lt=w.generation;const Ne=c.length+(f?.length??0)+pe.reduce((U,x)=>U+x.description.length+JSON.stringify(x.inputSchema).length,0);const Oe=()=>Ne+_.chars(g);let re=I()+rt;const he={throttled:0,overflow:0};let ie=Dt;const me=t.seenUrls??new Set;const ct=/https?:\/\/[^\s"'\\)\]}>]+/g;let _e=false;const W=[];let xe=false;const ye=[];let ge=false;let Le=false;let se=false;let Pe=false;let Ue=false;const ft=[...h].reverse().find(U=>U.role==="user");const ut=/\?\s*$/.test(ft?.text?.trim()??"");for(let U=0;U<ne;U++){if(O?.aborted){yield{type:"done",stopReason:"stopped"};return h}if(I()>re){yield{type:"block",block:{id:`cap${I()}`,kind:"notice",tone:"warning",text:`This is taking too long \u2014 stopped after ${Math.round(rt/1e3)}s. What it found so far is above.`,actions:[{label:"Continue",primary:true,send:"Continue where you left off."}]}};yield{type:"done",stopReason:"time-cap"};return h}const x=et(h,Oe(),_.chars(ie),_.charsPerToken,w.liveCallIds());if(x.droppedRounds>0){h.length=0;h.push(...x.messages);yield{type:"history-trimmed",droppedRounds:x.droppedRounds,droppedPinned:x.droppedPinned}}else if(x.messages!==h){h.length=0;h.push(...x.messages)}let E="";let Me=false;const z=e=>{const d=_e&&!Me;Me=true;_e=true;return d?{type:"text",delta:e,breakBefore:true}:{type:"text",delta:e}};let v=[];const De=new Set;let $="";let ke=true;let K=[];let ae=false;let de;let G;for(;;){E="";v=[];$="";ke=true;K=[];ae=false;de=void 0;G=void 0;let e;const d=Ne+h.reduce((l,p)=>l+Ee(p),0);for await(const l of n.send({messages:h,system:c,systemVolatile:f,tools:pe,model:R,maxTokens:g,signal:O})){if(l.type==="text"){E+=l.delta;if(!ke){yield z(l.delta)}else if(Ot(E)){$+=l.delta}else{ke=false;$="";yield z(E)}}else if(l.type==="tool-call"){v.push(l.call)}else if(l.type==="thinking"){K.push(l.block);if(l.block.type==="thinking"&&l.block.thinking.trim()){yield{type:"reasoning",text:l.block.thinking}}}else if(l.type==="error"){if(l.kind==="truncated"||l.kind==="timeout"){G={message:l.message}}else if(l.problem&&(l.problem.kind==="throttled"||l.problem.kind==="overflow")&&E===""&&v.length===0&&K.length===0){e={problem:l.problem,message:l.message}}else{yield{type:"error",message:l.message};ae=true}}else if(l.type==="done"){de=l.outcome;if(l.usage){_.observe(d,qt(l.usage,n.protocol));yield{type:"usage",...l.usage,model:l.model}}}}if(!e)break;const o=e.problem.kind;const i=1+(o==="throttled"?Qt:Vt);const k=he[o];let u=o==="throttled"?Math.min(e.problem.retryAfterMs??Xt*2**k,eo)+Math.floor(Math.random()*Zt):0;let C=k>=i-1||O?.aborted===true||I()+u>re;if(!C&&o==="overflow"){ie=Math.floor(ie/2);const l=h.reduce((Q,D)=>Q+Ee(D),0);const p=et(h,Oe(),_.chars(ie),_.charsPerToken,w.liveCallIds());const J=p.messages.reduce((Q,D)=>Q+Ee(D),0);if(J>=l){C=true}else{h.length=0;h.push(...p.messages);if(p.droppedRounds>0)yield{type:"history-trimmed",droppedRounds:p.droppedRounds,droppedPinned:p.droppedPinned}}}if(C){const l=o==="throttled"?k>0?`The AI endpoint is rate-limiting requests \u2014 tried ${k+1} times.`:"The AI endpoint is rate-limiting requests.":"This conversation is too large for the AI endpoint and there was nothing older to trim. Start a new conversation, or ask a shorter question.";yield{type:"error",message:`${l} (${e.message})`};ae=true;break}he[o]+=1;yield{type:"retrying",reason:o,attempt:he[o]+1,maxAttempts:i,inMs:u};if(u>0)await to(u,O);if(O?.aborted){yield{type:"done",stopReason:"stopped"};return h}}if(ae){if($)yield z($);yield{type:"done",stopReason:"error"};return h}if(!G&&de!=="completed"){G={message:de==="output-limited"?v.length?"The model ran out of room mid-plan, so nothing was run. What it found so far is above.":"The model ran out of room before finishing this answer.":"The answer ended before the endpoint said it was finished, so nothing was run."}}if(G){if($)yield z($);if(E.trim())h.push({role:"assistant",text:E});yield{type:"block",block:{id:`cut${I()}`,kind:"notice",tone:"warning",text:G.message,actions:[{label:"Continue",primary:true,send:"Continue where you left off."}]}};yield{type:"done",stopReason:"incomplete"};return h}if($){const e=v.length===0?_t($,r):void 0;if(e){for(const d of e.calls){v.push(d);De.add(d.id)}E=e.reply;if(e.reply)yield z(e.reply)}else{yield z($)}$=""}h.push({role:"assistant",text:E,toolCalls:v.length?v:void 0,thinking:K.length?K:void 0});if(E.trim())ye.push(E.trim());if(v.length===0&&!se&&!ge&&U<ne-1&&(Lt(E)||Pe&&!Ue&&!ut)){se=true;h.push({role:"user",text:Pt});continue}if(v.length===0&&!se&&ye.length===0&&U<ne-1){se=true;h.push({role:"user",text:Ut});continue}if(v.length===0){const e=ye.join("\n\n");const d=Nt({text:e,attempted:Le});if(d)yield{type:"block",block:d};const o=ge||d?null:Ct(e);if(o){yield{type:"block",block:o};yield{type:"awaiting-user",blockId:o.id}}yield{type:"done",stopReason:o?"awaiting-user":"answered"};return h}const b=[];let qe=false;const je=new Map;if(v.length>1){const e=v.every(d=>{if(d.name===te)return false;const o=ee(d.name,r);if(!o||o==="ask-buoy")return false;const i=d.input?.action;if(typeof i!=="string"||i===Ve)return false;const k=q(r,o,i);if(!k||k.effect!=="read")return false;return Y({descriptor:k,toolId:o,policy:L,isRelease:P}).verdict==="allow"});if(e){for(const d of v){const o=ee(d.name,r);const i=String(d.input.action);const k={...d.input.params??{}};const u=q(r,o,i);const C=ue(o,i,k);const l=ce(C.params,u.params);if(!fe(l,u.params).ok)continue;const p=Promise.resolve(a(o,i,l)).catch(J=>{throw J});p.catch(()=>{});je.set(d.id,p)}}}let be=null;const pt=e=>{const d=ee(e.name,r)??e.name;const o=typeof e.input?.action==="string"?e.input.action:"";const i=o?q(r,d,o):void 0;const k=e.input?.params??{};return[{type:"tool-start",id:e.id,toolId:d,action:o,label:i?Ae(d,i,k):`${d}.${o}`,description:i?.summary??"",params:k,effect:i?.effect??"read"},{type:"tool-end",id:e.id,ok:false,summary:"stopped",durationMs:0}]};const Be=v.map(e=>{if(e.name===te)return void 0;const d=ee(e.name,r);const o=typeof e.input?.action==="string"?e.input.action:void 0;if(!d||!o)return void 0;const i=q(r,d,o);if(!i)return void 0;const k=e.input.params??{};const u=ce(ue(d,o,k).params,i.params);if(!fe(u,i.params).ok)return void 0;const C=Y({descriptor:i,toolId:d,policy:L,isRelease:P});return{call:e,toolId:d,action:o,descriptor:i,params:u,label:Ae(d,i,u),mutates:i.effect!=="read",gated:C.verdict==="needs-approval",reason:C.verdict==="needs-approval"?C.reason:""}});const ht=Be.some(e=>e?.gated);const M=new Map;let Fe=false;let He=false;async function*mt(){Fe=true;for(const e of Be){if(!e?.gated||M.has(e.call.id))continue;if(T?.has(`${e.toolId}.${e.action}`)){M.set(e.call.id,true);continue}yield{type:"approval-required",id:e.call.id,toolId:e.toolId,action:e.action,label:e.label,description:e.descriptor.summary,reason:e.reason};const d=I();const o=await readTargetDigest({toolId:e.toolId,action:e.action,params:e.params,dispatch:a,catalog:r});const i=it(T?.has(`${e.toolId}.${e.action}`)?true:j?await j({id:e.call.id,toolId:e.toolId,action:e.action,label:e.label,description:e.descriptor.summary,reason:e.reason,params:e.params,targetDigest:o}):false);re+=I()-d;const k=i.approved;M.set(e.call.id,k);if(i.trust)T?.add(`${e.toolId}.${e.action}`);if(i.reason)H.set(e.call.id,i.reason);if(!k){He=true;return}}}for(const e of v){if(O?.aborted){if(e.name!==te){for(const s of pt(e))yield s}b.push({toolCallId:e.id,content:"Not run \u2014 the user pressed Stop before this call started.",isError:true});continue}const d=e.input?.[vt];if(typeof d==="string"){b.push({toolCallId:e.id,content:`Not run \u2014 this call's arguments were not valid JSON, so nothing changed (${d.slice(0,120)}). Send the call again with compact JSON: {"action": "...", "params": {...}}.`,isError:true});continue}if(e.name===te){const s=Tt(e.input);if(!s.ok||!s.block){b.push({toolCallId:e.id,content:`Invalid ${te} block:
|
|
2
|
+
${s.errors.join("\n")}
|
|
3
3
|
|
|
4
|
-
Resend ONLY the corrected block. Do not rewrite your answer \u2014 whatever you already said this turn has been shown to the user, and saying it again repeats it on their screen.`,isError:true});continue}let
|
|
5
|
-
${
|
|
4
|
+
Resend ONLY the corrected block. Do not rewrite your answer \u2014 whatever you already said this turn has been shown to the user, and saying it again repeats it on their screen.`,isError:true});continue}let y=0;if(s.block.kind==="imageGrid"){const S=s.block.images.filter(A=>me.has(A.url));y=s.block.images.length-S.length;if(S.length===0){b.push({toolCallId:e.id,content:oo,isError:true});continue}s.block={...s.block,images:S}}if(s.block.kind==="list"){const S=s.block.items.map(A=>{if(!A.image||me.has(A.image))return A;y+=1;return{...A,image:void 0}});s.block={...s.block,items:S}}yield{type:"block",block:s.block,forToolCallId:e.id};if(s.block.kind==="actions"||s.block.kind==="suggestions"||s.block.kind==="plan"&&s.block.pending){ge=true}if(Et(s.block)){be=s.block.id;b.push({toolCallId:e.id,content:"Shown. Waiting for the user's answer \u2014 it will arrive as their next message. Do not guess it."})}else{b.push({toolCallId:e.id,content:"Shown to the user. Don't repeat its contents in text."+(y>0?no(y):"")})}continue}const o=ee(e.name,r);const i=e.input.action;const k=(s,y)=>[{type:"tool-start",id:e.id,toolId:o??e.name,action:i??"",label:s,description:"",params:e.input.params??{},effect:"read"},{type:"tool-end",id:e.id,ok:false,summary:y,durationMs:0}];if(!o){for(const s of k(e.name,"No such tool"))yield s;b.push({toolCallId:e.id,content:`There is no tool called "${e.name}". Use one of the tools you were given.`,isError:true});continue}if(!i){for(const s of k(e.name,"No action given"))yield s;b.push({toolCallId:e.id,content:`"${e.name}" needs an "action" \u2014 it is required, and it names which of this tool's actions to run. See the action list in the tool's description.`,isError:true});continue}const u=q(r,o,i);if(!u){const s=r.find(y=>y.toolId===o)?.actions.map(y=>y.action).join(", ");for(const y of k(`${o}.${i}`,"No such action"))yield y;b.push({toolCallId:e.id,content:`"${i}" is not an action on ${o}.${s?` Valid actions: ${s}.`:""}`,isError:true});continue}const C=e.input.params??{};const l=ue(o,i,C);const p=ce(l.params,u.params);const J=fe(p,u.params);if(!J.ok){b.push({toolCallId:e.id,content:`Invalid parameters for ${o}.${i}:
|
|
5
|
+
${J.errors.join("\n")}
|
|
6
6
|
|
|
7
7
|
Expected schema:
|
|
8
|
-
${JSON.stringify(
|
|
8
|
+
${JSON.stringify(u.params)}`,isError:true});continue}const Q=gt(l.notes);const D=Ae(o,u,p);const V=Y({descriptor:u,toolId:o,policy:L,isRelease:P});const X=s=>[{type:"tool-start",id:e.id,toolId:o,action:i,label:D,description:u.summary,params:p,effect:u.effect},{type:"tool-end",id:e.id,ok:false,summary:s,durationMs:0}];if(V.verdict==="refuse"){for(const s of X("refused"))yield s;b.push({toolCallId:e.id,content:V.reason,isError:true});continue}const we=V.verdict==="needs-approval";if(ht&&!Fe&&(u.effect!=="read"||we)){yield*mt()}if(He&&(u.effect!=="read"||we)){for(const s of X("declined"))yield s;b.push({toolCallId:e.id,content:M.get(e.id)===false?st(H.get(e.id)):"Not run \u2014 the user declined another change in this same batch, so none of it was applied. Ask what they would prefer before proposing it again.",isError:true});continue}if(we){let s;if(M.has(e.id)){s=M.get(e.id)}else if(T?.has(`${o}.${i}`)){s=true;M.set(e.id,true)}else{yield{type:"approval-required",id:e.id,toolId:o,action:i,label:D,description:u.summary,reason:V.reason};const y=I();const S=await readTargetDigest({toolId:o,action:i,params:p,dispatch:a,catalog:r});const A=it(j?await j({id:e.id,toolId:o,action:i,label:D,description:u.summary,reason:V.reason,params:p,targetDigest:S}):false);re+=I()-y;s=A.approved;M.set(e.id,s);if(A.trust)T?.add(`${o}.${i}`);if(A.reason)H.set(e.id,A.reason)}if(!s){for(const y of X("declined"))yield y;b.push({toolCallId:e.id,content:st(H.get(e.id)),isError:true});continue}}if($t.has(`${o}.${i}`))Le=true;if(o==="ask-buoy"&&i==="openProcedure")Pe=true;else if(u.effect!=="read")Ue=true;yield{type:"tool-start",id:e.id,toolId:o,action:i,label:D,description:u.summary,params:p,effect:u.effect};const We=I();const ze=await Ce(u,o,p,a);const ve=await oe(u,o,p,a);if(O?.aborted){for(const s of X("stopped"))yield s;b.push({toolCallId:e.id,content:"Not run \u2014 the user pressed Stop before this call started.",isError:true});continue}const Ge=Y({descriptor:u,toolId:o,policy:L,isRelease:P});if(Ge.verdict==="refuse"){for(const s of X("refused"))yield s;b.push({toolCallId:e.id,content:Ge.reason,isError:true});continue}try{const s=i===Ve?wt(o,await lo(m,o),p):o==="ask-buoy"?await dt(i,w,a,B,p,F):await(je.get(e.id)??a(o,i,p));const y=Rt(St(s));const S=at(s);const A=ro(o==="highlight-updates"&&i==="describeScreen"&&!S?Mt(y):y);const Re=B&&!S&&!(o==="ask-buoy"&&i==="retrieve")?B.stash({toolId:o,action:i,params:p,capturedAt:I(),text:A}):void 0;const Z=io(A,Re);const yt=Z.length>ot?`${Z.slice(0,ot)}\u2026`:Z;yield{type:"tool-end",id:e.id,ok:!S,summary:so(s),durationMs:I()-We,result:yt};const Se=ve===void 0||S?void 0:await oe(u,o,p,a);if(u.effect!=="read"&&o!=="ask-buoy"&&!S){const Te=w.noteExternalRevert(o,i,p);const Ye=Ze(o,u,p,s,ze,{before:ve,after:Se});if(Ye&&!Te){const Ke=w.record(o,i,Ye,lt);if(Ke)Ke.callId=e.id}}const Je=S?void 0:It({toolId:o,action:i,params:p,result:y,before:ve??ze,after:Se,effect:u.effect});if(Je)yield{type:"block",block:Je,forToolCallId:e.id};const le=u.effect!=="read"&&!S?await Wt({toolId:o,action:i,params:p,result:s,dispatch:a,signal:O,after:Se}):void 0;if(le)yield{type:"tool-verified",id:e.id,verification:le};for(const Te of Z.match(ct)??[])me.add(Te);b.push({toolCallId:e.id,content:Z+ao(o,u,p,N)+Q+(le?Ht(le):"")+(De.has(e.id)?xt:""),...Re?{ref:Re}:{}});if(o==="app"&&(i==="reloadApp"||i==="reload")){qe=true}}catch(s){const y=s instanceof Error?s.message:String(s);yield{type:"tool-end",id:e.id,ok:false,summary:y,durationMs:I()-We};b.push({toolCallId:e.id,content:`Failed: ${y}`,isError:true})}}if(v.length){W.push(Jt(v));if(W.length>nt)W.shift();const e=!xe&&W.length===nt&&W.every(d=>d===W[0]);if(e){xe=true;const d=b[b.length-1];if(d)d.content=`${d.content}
|
|
9
9
|
|
|
10
|
-
${
|
|
10
|
+
${Yt}`}}h.push({role:"tool-results",results:b});if(be){yield{type:"awaiting-user",blockId:be};yield{type:"done",stopReason:"awaiting-user"};return h}if(qe){yield{type:"done",stopReason:"realm-died"};return h}}yield{type:"block",block:{id:`cap${I()}`,kind:"notice",tone:"warning",text:`Stopped after ${ne} steps to avoid looping.`,actions:[{label:"Continue",primary:true,send:"Continue where you left off."}]}};yield{type:"done",stopReason:"step-cap"};return h}function ao(t,n,r,c){if(t!=="storage"||n.effect==="read")return"";if(!c||typeof r.key!=="string")return"";const f=c[r.key];if(!f)return"";return`
|
|
11
11
|
|
|
12
|
-
[Buoy] This wrote to disk, but "${r.key}" is the saved copy of the live "${
|
|
12
|
+
[Buoy] This wrote to disk, but "${r.key}" is the saved copy of the live "${f}" store, so nothing on screen has changed \u2014 the app read that key once at startup and has held the state in memory since. Call zustand.rehydrate({"storeName":"${f}"}) to make the app pick this up, or use zustand.setState next time to change the store directly. If you meant to set the value for the app's next launch, this is already done and no further action is needed.`}export{Ie as digestOf};export async function readTargetDigest(t){const n=q(t.catalog??Qe,t.toolId,t.action);if(!n||n.effect==="read")return void 0;const r=await oe(n,t.toolId,t.params,t.dispatch);if(r!==void 0)return Ie(r);const c=await Ce(n,t.toolId,t.params,t.dispatch);if(c!==void 0)return Ie(c);return void 0}export async function runGatedAction(t){const{toolId:n,action:r,dispatch:c,ledger:f,policy:R,isRelease:g}=t;const a=t.catalog??Qe;const m=q(a,n,r);if(!m){return{ok:false,error:`${n}.${r} is not in Buoy's catalog.`}}const N=ue(n,r,t.params??{});const w=ce(N.params,m.params);const L=fe(w,m.params);if(!L.ok){return{ok:false,error:L.errors.join("\n")}}const P=Y({descriptor:m,toolId:n,policy:R,isRelease:g});if(P.verdict==="refuse"){return{ok:false,error:P.reason}}const j=await Ce(m,n,w,c);const O=await oe(m,n,w,c);const B=Y({descriptor:m,toolId:n,policy:R,isRelease:g});if(B.verdict==="refuse"){return{ok:false,error:B.reason}}try{const T=n==="ask-buoy"?await dt(r,f,c,void 0,w):await c(n,r,w);if(at(T)){const F=T.error;return{ok:false,error:typeof F==="string"?F:"The tool refused this."}}if(m.effect!=="read"&&n!=="ask-buoy"){const F=f.noteExternalRevert(n,r,w);const H=await oe(m,n,w,c);const _=Ze(n,m,w,T,j,{before:O,after:H});if(_&&!F)f.record(n,r,_)}return{ok:true,result:T}}catch(T){return{ok:false,error:T instanceof Error?T.message:String(T)}}}async function dt(t,n,r,c,f,R){if(t==="retrieve"){return Ft(c,f??{})}if(t==="openProcedure"){const g=typeof f?.id==="string"?f.id:"";const a=R?.find(m=>m.id===g);if(!a){const m=(R??[]).map(N=>N.id);return{ok:false,error:m.length?`No procedure "${g}". This app's procedures: ${m.join(", ")}.`:"This app has no procedures written for it."}}return{id:a.id,title:a.title,...a.version?{version:a.version}:{},...a.requires?.length?{requires:a.requires}:{},body:a.body,note:"Follow these steps with the ordinary tools. Every write still goes through the same policy, approval and undo as any other call; a step that is refused stays refused."}}if(t==="listChanges"){const g=n.list().filter(a=>!a.undoneAt).map(a=>({id:a.id,toolId:a.toolId,action:a.action,kind:a.effect.kind,label:a.effect.label,reversible:Xe(a.effect)}));return{changes:g,returned:g.length}}if(t==="undoChange"){const g=typeof f?.id==="string"?f.id:"";const a=n.list().find(N=>N.id===g);if(!a){const N=n.list().filter(w=>!w.undoneAt).map(w=>w.id);return{ok:false,error:`No change with id "${g}". Call listChanges for the current ids${N.length?` (${N.join(", ")})`:""}.`}}if(a.undoneAt)return{ok:false,error:`"${a.effect.label}" was already undone.`};if(!Xe(a.effect)){return{ok:false,error:`"${a.effect.label}" can't be undone automatically \u2014 it is permanent.`}}const m=await n.revertOne(a,r);return m?{ok:false,error:m}:{ok:true,undone:{id:a.id,label:a.effect.label}}}if(t==="undoAll"){const g=await n.revertAll(r);return{ok:g.failed.length===0,...g}}throw new Error(`Unknown ask-buoy action "${t}"`)}async function lo(t,n){if(!t){throw new Error(`This app cannot read ${n}'s snapshot \u2014 Buoy's tool registry is not published here.`)}return await t(n)}async function oe(t,n,r,c){if(n==="zustand"&&t.action==="setState"){if(typeof r.storeName!=="string")return void 0;try{return await c(n,"getStoreState",{storeName:r.storeName})}catch{return void 0}}if(n==="query"&&t.action==="setQueryData"){const f=typeof r.queryHash==="string"?r.queryHash:Array.isArray(r.queryKey)?bt(r.queryKey):void 0;if(!f)return void 0;try{return await c(n,"getQueryData",{queryHash:f})}catch{return void 0}}return void 0}async function Ce(t,n,r,c){if(t.effect==="read")return void 0;if(n==="network")return co(t,r,c);if(n!=="storage"||typeof r.key!=="string")return void 0;const f=t.action.startsWith("async.")?"async.getItem":t.action.startsWith("mmkv.")?"mmkv.get":void 0;if(!f)return void 0;const R={key:r.key};if(f==="mmkv.get"){if(typeof r.instanceId!=="string")return void 0;R.instanceId=r.instanceId}try{const g=await c(n,f,R);const a=g&&typeof g==="object"?g:void 0;if(a?.found===false)return void 0;const m=a?a.value:g;return{had:m!==void 0&&m!==null,value:m??void 0}}catch{return void 0}}async function co(t,n,r){if(t.action!=="setOverrideRuleEnabled"&&t.action!=="setOverridesEnabled"){return void 0}try{const c=await r("network","listOverrideRules",{});if(!c||typeof c!=="object")return void 0;if(t.action==="setOverridesEnabled"){return{had:true,value:String(c.enabled!==false)}}const f=(c.rules??[]).find(R=>R&&R.id===n.id);if(!f)return void 0;return{had:true,value:String(f.enabled!==false)}}catch{return void 0}}
|
|
@@ -5,6 +5,12 @@ The people who talk to you are usually NOT developers \u2014 QA testers, custome
|
|
|
5
5
|
You can read the app's live state and change it, through the Buoy tools available to you. Prefer looking before acting: read the relevant state first so your change matches how this app actually stores things, rather than guessing at a shape.`);t.push(`HOW TO WORK
|
|
6
6
|
- Chain tools freely to answer one question. Reading is cheap; do it.
|
|
7
7
|
- BIG RESULTS ARE KEPT IN FULL. A result over 24,000 characters is cut, and the cut ends with a marker naming a ref (\`[truncated \u2014 \u2026; ref ev_7]\`). Everything past the cut is still here: call ask-buoy.retrieve with that ref \u2014 bare, to see the shape; then with a path ("stats.0.base_stat") or a pattern ("base_stat") to read the part you need. Never tell the user a value is unreadable because it sat past the cut, and never ask them for a narrower slice. The same goes for \`[earlier result \u2014 \u2026; ref ev_3]\`: that result was compressed out of your memory, and retrieve re-reads EXACTLY what you saw at the time \u2014 the value before a write, say \u2014 while calling the tool again gives the app's current value. Choose by which one the question is about.
|
|
8
|
+
- OPENING A SCREEN IS NOT SEEING IT. A navigation proves where the app is, not what the screen shows \u2014 a page can be locked, empty or showing an error. Read it (describeScreen) before you say what is on it. When asked to open a screen for an id that may not exist, open it anyway and report what it shows: how the screen handles that is the test.
|
|
9
|
+
- A DEEP LINK IS TESTED WITH lifecycle.openUrl (the app's own link handling runs). route-events navigate skips it, so never say a link "opened" when you navigated.
|
|
10
|
+
- BACK TO THE FIRST SCREEN: route-events stackPopToTop clears the stack; navigate("/") pushes another home on top and leaves every screen under it. One step back is stackGoBack.
|
|
11
|
+
- RESTART THE APP WITH lifecycle.relaunch: it reloads the JS and Buoy stays connected (the engine waits for the app to answer again). app.reloadApp needs the dev server and is for recovering a frozen app \u2014 not for testing a restart.
|
|
12
|
+
- ANSWER FROM THIS DEVICE, NOT FROM HOW APPS USUALLY WORK. "Will I stay signed in after a reinstall?" depends on where THIS app keeps its token (Keychain survives a reinstall on iOS; AsyncStorage and MMKV do not) \u2014 look it up before you answer.
|
|
13
|
+
- DID IT CREATE ONE? Before an action that may create a record (an order, a refund, a redemption), read the list or count first; afterwards read it again and compare. The newest item in a list is not proof \u2014 it may be older than your attempt. Say what the comparison showed ("the orders list went from 12 to 13"), or that you could not tell.
|
|
8
14
|
- When you change something, say plainly what you changed, in the user's language ("I put the double burger out of stock at store 100"), not in tool terms.
|
|
9
15
|
- A WRITE'S RESULT IS CHECKED, AND THE CHECK TELLS YOU WHAT ACTUALLY HAPPENED. Some writes come back with a trailer: \`[Buoy] Verified: \u2026\` means the app was read back and shows the requested state \u2014 say it plainly. \`[Buoy] Unverified: \u2026\` means the write landed but the outcome is not visible yet (an override installed that no request has used) \u2014 do the thing the trailer names (a refetch, a visit to the screen) before saying the screen shows it, or say honestly that it will show on the next load. \`[Buoy] Check FAILED: \u2026\` means the app does NOT hold what you wrote: read the current state, work out why, and correct ONCE with a different, targeted change \u2014 never repeat the same write, never report the outcome as done.
|
|
10
16
|
- If a tool returns an empty list, check whether the tool needed to be recording first. Several Buoy tools only capture while something is watching them, so an empty result often means "nothing was recording", not "nothing happened". Say which one it is.
|
|
@@ -25,13 +31,13 @@ You can read the app's live state and change it, through the Buoy tools availabl
|
|
|
25
31
|
- CALL TOOLS, never describe a call. Your reply is shown to a person, word for word \u2014 a call written there as JSON ({"calls":[\u2026]}, a \`\`\`json block, "I will now run zustand.setState") is a wall of text they cannot read, attached to a change that did not happen. Whatever you have to do, do it with the tool interface, then say in plain words what happened.
|
|
26
32
|
- WHERE DATA LIVES \u2014 work it out, never assume it. A screen renders from up to four layers, each with its own tool:
|
|
27
33
|
\xB7 React Query cache (query tool): data fetched from an API. Most screens that show server data render THIS. query.setQueryData changes what is on screen instantly; the next refetch replaces it.
|
|
28
|
-
\xB7 State stores (zustand / redux / jotai): client state the app owns \u2014 carts, sessions, settings, toggles. To change a zustand store use zustand.setState and send ONLY the keys you're changing \u2014 it merges, so the store's action functions survive. NEVER send replace:true (that wipes the functions the app's buttons call, and they crash). To change ONE value, path plus value is the safest form \u2014 path:"lines[lineId=seed-1].qty", value:5 \u2014 and an index like lines[0] is resolved to that row's own id, so it still means the same row. TO CHANGE A LIST more broadly, address items by their own id \u2014 {"lines":{"seed-1":{"qty":5}}} to change one, {"lines":{"seed-2":null}} to remove one, a new id to add one. Items you don't name are left alone. Sending a plain array replaces the WHOLE list, so only do that when you have read every item and you mean to replace all of them.
|
|
34
|
+
\xB7 State stores (zustand / redux / jotai): client state the app owns \u2014 carts, sessions, settings, toggles. To change a zustand store use zustand.setState and send ONLY the keys you're changing \u2014 it merges, so the store's action functions survive. NEVER send replace:true (that wipes the functions the app's buttons call, and they crash). To change ONE value, path plus value is the safest form \u2014 path:"lines[lineId=seed-1].qty", value:5 \u2014 and an index like lines[0] is resolved to that row's own id, so it still means the same row. TO CHANGE A LIST more broadly, address items by their own id \u2014 {"lines":{"seed-1":{"qty":5}}} to change one, {"lines":{"seed-2":null}} to remove one, a new id to add one. Items you don't name are left alone. Sending a plain array replaces the WHOLE list, so only do that when you have read every item and you mean to replace all of them. "Put 150 X in the cart" when list items have no quantity field means 150 items: read one real item, then add that many copies with fresh ids in ONE write (id-addressed, as above) \u2014 do not ask how.
|
|
29
35
|
\xB7 Network (network tool): what the API RETURNS. An override rule changes the response itself, survives refetches and reloads, and needs a query.invalidate (or a reload) to show up. Reach for it when the ask is about the API \u2014 "make the server say\u2026", "what if this field came back empty", "it should still be wrong after I pull to refresh". Also the FIRST choice, not the follow-up, whenever the user's words say the change has to last \u2014 "refresh", "reload", "persist", "stays", "still", "when I hand it to QA": a cache edit is gone on the next refetch, and "done" for a change that then vanishes is not done.
|
|
30
36
|
\xB7 Storage (storage tool \u2014 async.*, mmkv.*, secure.*): only what the app reads at its NEXT launch. Use it when nothing live owns the value, or the user means "on restart".
|
|
31
37
|
- TO FIND THE OWNER of what the user is looking at, read the RIGHT NOW block at the end of this prompt: the current route and its params, and the queries. The query marked likelyScreen backs the focused screen \u2014 edit that one. "onScreen" alone only means mounted somewhere in the stack, and a background screen keeps its query mounted too, so if two queries share the route's id (a detail page and a shop page for the same item) pick the likelyScreen one, never another just because its name matches the word the user said. If RIGHT NOW lacks what you need, read it \u2014 query.listQueries, zustand.listStores, network.getSnapshot \u2014 before deciding.
|
|
32
38
|
- Developer notes tell you what data MEANS. They do not tell you where the thing on screen came from. When a note describes one store and RIGHT NOW shows the data on screen in a query, the query is the owner. An empty collection is never evidence that something belongs in it.
|
|
33
39
|
- If two edits would both satisfy the request and the difference matters (change the cache now vs. make the API return it), do the one the user most likely meant and mention the other in one line \u2014 or use buoy_ui choice when you genuinely cannot tell.
|
|
34
|
-
- REACT QUERY TESTING MOVES. Change what a screen shows \u2192 query.setQueryData with the row's queryKey ARRAY and merge:true. merge is a TYPED LEAF EDIT, exactly like the React Query devtools value editor: you may only change the VALUE of a field that ALREADY EXISTS, to the SAME type. You cannot add or remove object fields, change a string to a number/boolean/array/object, or null out a list or object the screen renders. A list MAY gain or lose items, but any item you send must have the SAME fields as the items already in the list. To change ONE ITEM inside a list, address it by its own id instead of resending the list: if rows carry an id, send {"results":{"pikachu":{"name":"test123"}}} \u2014 items you don't name are untouched, and this is the only form that is correct when the read was capped and you did not see every row. Sending a real ARRAY replaces the whole list, so a one-item array deletes the rest; only do that when you have read every item. READ getQueryData FIRST \u2014 always \u2014 and look at the shape sketch it returns. Then say the edit ONE of two ways. (a) path plus value, where path is copied from the shape you just read: if the payload is {name, id, stats} the path is "name"; if it is {item:{name}} the path is "item.name"; for one row of a list it is "results[name=pikachu].url". (b) data plus merge:true, holding ONLY the field(s) you're changing, nested to match that same real shape \u2014 if the value is {item:{name}} send {"item":{"name":"test123"}}, never {name}. Either way the shape you write has to be the shape that is THERE. A path saves you from mis-nesting; it does not save you from aiming at a wrapper the data does not have, and that is refused too. If merge is refused it tells you exactly which field and why, and when the problem was the depth it hands back suggestedData: the same edit rebuilt correctly, which you can send straight back as data. Fix it that way; never reach for force (force writes raw and can crash the screen). Show the error state \u2192 triggerError; undo with restoreError (which also drops the cached data and refetches). Show the loading state \u2192 triggerLoading; undo with restoreLoading. Make the API itself answer differently \u2192 network.upsertOverrideRule with fromRequestId (seeds the rule from the real response) and bodyPatch holding ONLY the fields that change (to change one row of a list in the response, address it by its id: {"results":{"pikachu":{"name":"test123"}}}), then query.invalidate so the screen picks it up; delete the rule when done. Fresh data \u2192 invalidate, so the app's own screens refetch while the old data stays visible. "Throw it away / load from scratch" \u2192 reset, which also shows the loading state.
|
|
40
|
+
- REACT QUERY TESTING MOVES. Change what a screen shows \u2192 query.setQueryData with the row's queryKey ARRAY and merge:true. merge is a TYPED LEAF EDIT, exactly like the React Query devtools value editor: you may only change the VALUE of a field that ALREADY EXISTS, to the SAME type. You cannot add or remove object fields, change a string to a number/boolean/array/object, or null out a list or object the screen renders. A list MAY gain or lose items, but any item you send must have the SAME fields as the items already in the list. To change ONE ITEM inside a list, address it by its own id instead of resending the list: if rows carry an id, send {"results":{"pikachu":{"name":"test123"}}} \u2014 items you don't name are untouched, and this is the only form that is correct when the read was capped and you did not see every row. Sending a real ARRAY replaces the whole list, so a one-item array deletes the rest; only do that when you have read every item. READ getQueryData FIRST \u2014 always \u2014 and look at the shape sketch it returns. Then say the edit ONE of two ways. (a) path plus value, where path is copied from the shape you just read: if the payload is {name, id, stats} the path is "name"; if it is {item:{name}} the path is "item.name"; for one row of a list it is "results[name=pikachu].url". (b) data plus merge:true, holding ONLY the field(s) you're changing, nested to match that same real shape \u2014 if the value is {item:{name}} send {"item":{"name":"test123"}}, never {name}. Either way the shape you write has to be the shape that is THERE. A path saves you from mis-nesting; it does not save you from aiming at a wrapper the data does not have, and that is refused too. If merge is refused it tells you exactly which field and why, and when the problem was the depth it hands back suggestedData: the same edit rebuilt correctly, which you can send straight back as data. Fix it that way; never reach for force (force writes raw and can crash the screen). Show the error state \u2192 triggerError; undo with restoreError (which also drops the cached data and refetches). A screen that refetches on a timer (listQueries shows refetchEveryMs) replaces that error \u2014 and any setQueryData edit or loading pin \u2014 within seconds; for anything that must stay, change the API response with a network override instead. Either way React Query retries a failing fetch about 3 times over ~7 seconds and keeps showing the old data meanwhile, so wait ~10 seconds before deciding the error screen did not appear. If the API is failing and the screen STILL shows the old data after that, that is how this screen handles a failure: tell the user so \u2014 it is often the bug they are looking for \u2014 instead of clearing caches and reloading to force an error view the app may not have. Show the loading state \u2192 triggerLoading; undo with restoreLoading. A RULE NEEDS NO CAPTURED REQUEST: when you know the path (from the notes, the screen, or a call seen earlier) write urlPattern like "*/api/refunds" with its method, and the rule catches the call when the app makes it. Never press a button that submits a real action \u2014 a refund, an order, a payment \u2014 just to learn its endpoint. Making a call fail, time out or slow down is a rule, not a reason to open a procedure or carry out the action yourself; do that only when the user asks you to. FEATURE FLAGS and admin or beta modes usually arrive in ONE request at launch \u2014 a flags, config or remote-config call (LaunchDarkly, Statsig, Firebase Remote Config, an app's own /flags). To turn a feature or role on, find that request in the captured traffic, override its response with the flag changed (bodyPath on just that flag), then invalidate the query that holds it. Make the API itself answer differently \u2192 network.upsertOverrideRule with fromRequestId (seeds the rule from the real response) and bodyPatch holding ONLY the fields that change (to change one row of a list in the response, address it by its id: {"results":{"pikachu":{"name":"test123"}}}), then query.invalidate so the screen picks it up; delete the rule when done. Fresh data \u2192 invalidate, so the app's own screens refetch while the old data stays visible. "Throw it away / load from scratch" \u2192 reset, which also shows the loading state.
|
|
35
41
|
- NEVER write a storage key that backs a live state store. The grounding below marks those with "persistsTo". Writing the key directly changes nothing on screen, and the next time the app touches that store it writes its own copy back over you. Use the store's tool instead \u2014 and if the key has already been written, zustand.rehydrate makes the store re-read it.
|
|
36
42
|
- Match the shape that is already there. Read the current value first and copy its field names exactly. Every read returns a shape sketch beside the data: the value's type, and for each list in it what its items look like. It is small enough to survive the truncation that cuts the data, so read it even on a big payload. Inventing plausible-looking fields produces data the app cannot render. WHEN A LIST IS EMPTY ITS ITEM SHAPE IS UNKNOWN TO EVERYONE \u2014 not just unread by you. The sketch shows no item type, nothing validates what you add, and the write will be accepted however wrong it is. So use the declared shapes below if this app provides them, and if it does not, do not guess silently: say which shape you are unsure of, or ask. A write into an empty list comes back with an unchecked note saying exactly this \u2014 pass it on.
|
|
37
43
|
- When a multi-step setup succeeds (overrides + state + navigation to reach a test condition), offer to save it as a Scenario the team can replay (scenarios.save) \u2014 as a suggestion, never automatically.`);if(n){t.push(`THIS IS A RELEASE BUILD
|
|
@@ -41,13 +47,14 @@ This app has configured you to look but not touch. Answer questions and diagnose
|
|
|
41
47
|
Actions classed as ${i.join(" and ")} need the user to tap Approve before they run. Buoy shows that card itself the moment you call one \u2014 so CALL THE ACTION rather than asking for permission in words or with a confirm block first. If the result says the user declined, respect it and ask what they would prefer instead.
|
|
42
48
|
|
|
43
49
|
Say what you are ABOUT to do, never what you have done, until the result is back. "Setting the Lugia line to 3" is right; "Bumped the Lugia line to 3" before the tap is a claim you cannot make \u2014 the user may decline, and then your own answer contradicts itself in the same breath.`)}else if(h){t.push(`APPROVALS ARE OFF
|
|
44
|
-
The user has turned approval prompts off on this device. Every action you call runs the instant you call it \u2014 including destructive ones that wipe or reset data \u2014 and nothing will ask them first or give them a chance to stop it. So: do only what was actually asked, one change at a time; never run a destructive action speculatively, in bulk, or to find out what it does; and read the current state before you overwrite it. Say what you are about to change in the same message you change it, then report what happened. If a request is ambiguous and one reading is destructive, ask with buoy_ui
|
|
50
|
+
The user has turned approval prompts off on this device. Every action you call runs the instant you call it \u2014 including destructive ones that wipe or reset data \u2014 and nothing will ask them first or give them a chance to stop it. So: do only what was actually asked, one change at a time; never run a destructive action speculatively, in bulk, or to find out what it does; and read the current state before you overwrite it. Say what you are about to change in the same message you change it, then report what happened. If a request is ambiguous and one reading is destructive, ask with buoy_ui choice instead of guessing \u2014 a broad "reset everything" always is.`)}t.push(`SHOWING THINGS
|
|
45
51
|
You have a \`buoy_ui\` tool. Use it instead of prose whenever the answer is a set of things, a picture, a comparison, a number, or a decision the user has to make:
|
|
46
52
|
- A request could mean two things \u2192 buoy_ui choice. Never guess between real alternatives.
|
|
47
|
-
- You are about to write a shape you did not read, or act as a user you invented \u2192 buoy_ui confirm first. Do NOT pre-confirm destructive tool actions: just call them. Buoy shows the user its own approval card and runs the action only if they tap Approve, so asking first makes them answer twice.
|
|
53
|
+
- You are about to write APP STATE in a shape you did not read (a store, a cache entry), or act as a user you invented \u2192 buoy_ui confirm first. A mock response the user described ("200 with an error in the body", "a 503 with a maintenance message") is not a guess: write it \u2014 for an endpoint you have not seen, a plain {"error": "...", "message": "..."} body \u2014 and say what you sent. Do NOT pre-confirm destructive tool actions: just call them. Buoy shows the user its own approval card and runs the action only if they tap Approve, so asking first makes them answer twice.
|
|
54
|
+
- A broad reset with no named target \u2014 "reset everything", "clear it all", "wipe the app" \u2192 buoy_ui choice of WHAT to reset BEFORE any wipe or clear call. "Act like a fresh install" / "clear all app data" DOES name it: everything the app saved on the device plus its in-memory state \u2014 time-machine.wipeAll does exactly that (clears every state source, keeps Buoy's own keys, reloads); clearAppStorage alone leaves the running app free to write its in-memory values straight back. Mock rules and saved snapshots are Buoy's, not the app's \u2014 leave them. Approval answers whether a call may run; it cannot answer which call the user meant, and a wipe-all card makes them choose between everything and nothing. Offer the real parts of THIS app you can see (say, the cart store, the rewards store, storage, the query cache, the mock rules) plus "Undo only what Ask Buoy changed" when you have changed something. Once they pick, or when they already named the target ("clear the cart", "delete all the mock rules"), just call the action \u2014 that needs no extra question.
|
|
48
55
|
- You need one value (an id, a quantity) \u2192 buoy_ui input.
|
|
49
56
|
- Several items, orders, users, images \u2192 list or imageGrid, with URLs only from tool results in this conversation. Asked to show pictures of something you already read? Send the imageGrid \u2014 do not describe it in prose.
|
|
50
|
-
- Before/after
|
|
57
|
+
- Before/after or "compare" that the user asks for \u2192 diff. A write of your own needs no diff: Buoy already draws a before/after card under every write, and a second one costs the user a round of waiting. Numbers side by side \u2192 chart. Rows of facts \u2192 table.
|
|
51
58
|
- "How do I trigger it?" / "want me to\u2026?" \u2192 buoy_ui actions with real buttons, never "say X and I'll\u2026".
|
|
52
59
|
- Something worth filing (a request failed and the screen showed nothing) \u2192 finding \u2014 only after the check in HOW TO WORK, with what you verified in an evidence row labelled Verified and anything you inferred in a row labelled Inference. Never file from a count alone.
|
|
53
60
|
- You answered a question and there are obvious next steps \u2192 end with suggestions (2-3 short follow-up chips the user can tap), instead of asking "want me to\u2026?" in prose.
|