@buoy-gg/agent-core 7.0.33

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.
Files changed (138) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +42 -0
  3. package/lib/commonjs/blocks/receipts.js +702 -0
  4. package/lib/commonjs/blocks/receipts.js.map +1 -0
  5. package/lib/commonjs/blocks/types.js +119 -0
  6. package/lib/commonjs/blocks/types.js.map +1 -0
  7. package/lib/commonjs/blocks/uiTool.js +994 -0
  8. package/lib/commonjs/blocks/uiTool.js.map +1 -0
  9. package/lib/commonjs/catalog/catalog.g.js +4044 -0
  10. package/lib/commonjs/catalog/catalog.g.js.map +1 -0
  11. package/lib/commonjs/catalog/catalog.source.json +4956 -0
  12. package/lib/commonjs/catalog/snapshotReads.js +256 -0
  13. package/lib/commonjs/catalog/snapshotReads.js.map +1 -0
  14. package/lib/commonjs/catalog/toProviderTools.js +107 -0
  15. package/lib/commonjs/catalog/toProviderTools.js.map +1 -0
  16. package/lib/commonjs/catalog/validateParams.js +129 -0
  17. package/lib/commonjs/catalog/validateParams.js.map +1 -0
  18. package/lib/commonjs/context/buildContextPack.js +141 -0
  19. package/lib/commonjs/context/buildContextPack.js.map +1 -0
  20. package/lib/commonjs/effects/ledger.js +229 -0
  21. package/lib/commonjs/effects/ledger.js.map +1 -0
  22. package/lib/commonjs/engine/effectFor.js +95 -0
  23. package/lib/commonjs/engine/effectFor.js.map +1 -0
  24. package/lib/commonjs/engine/runAgentTurn.js +667 -0
  25. package/lib/commonjs/engine/runAgentTurn.js.map +1 -0
  26. package/lib/commonjs/engine/systemPrompt.js +86 -0
  27. package/lib/commonjs/engine/systemPrompt.js.map +1 -0
  28. package/lib/commonjs/index.js +288 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/package.json +1 -0
  31. package/lib/commonjs/policy/labels.js +303 -0
  32. package/lib/commonjs/policy/labels.js.map +1 -0
  33. package/lib/commonjs/policy/policy.js +143 -0
  34. package/lib/commonjs/policy/policy.js.map +1 -0
  35. package/lib/commonjs/policy/redact.js +135 -0
  36. package/lib/commonjs/policy/redact.js.map +1 -0
  37. package/lib/commonjs/providers/anthropic.js +272 -0
  38. package/lib/commonjs/providers/anthropic.js.map +1 -0
  39. package/lib/commonjs/providers/openai.js +193 -0
  40. package/lib/commonjs/providers/openai.js.map +1 -0
  41. package/lib/commonjs/providers/sse.js +104 -0
  42. package/lib/commonjs/providers/sse.js.map +1 -0
  43. package/lib/commonjs/providers/types.js +6 -0
  44. package/lib/commonjs/providers/types.js.map +1 -0
  45. package/lib/commonjs/session.js +173 -0
  46. package/lib/commonjs/session.js.map +1 -0
  47. package/lib/commonjs/types.js +2 -0
  48. package/lib/commonjs/types.js.map +1 -0
  49. package/lib/module/blocks/receipts.js +696 -0
  50. package/lib/module/blocks/receipts.js.map +1 -0
  51. package/lib/module/blocks/types.js +113 -0
  52. package/lib/module/blocks/types.js.map +1 -0
  53. package/lib/module/blocks/uiTool.js +987 -0
  54. package/lib/module/blocks/uiTool.js.map +1 -0
  55. package/lib/module/catalog/catalog.g.js +4040 -0
  56. package/lib/module/catalog/catalog.g.js.map +1 -0
  57. package/lib/module/catalog/catalog.source.json +4956 -0
  58. package/lib/module/catalog/snapshotReads.js +252 -0
  59. package/lib/module/catalog/snapshotReads.js.map +1 -0
  60. package/lib/module/catalog/toProviderTools.js +101 -0
  61. package/lib/module/catalog/toProviderTools.js.map +1 -0
  62. package/lib/module/catalog/validateParams.js +124 -0
  63. package/lib/module/catalog/validateParams.js.map +1 -0
  64. package/lib/module/context/buildContextPack.js +138 -0
  65. package/lib/module/context/buildContextPack.js.map +1 -0
  66. package/lib/module/effects/ledger.js +223 -0
  67. package/lib/module/effects/ledger.js.map +1 -0
  68. package/lib/module/engine/effectFor.js +91 -0
  69. package/lib/module/engine/effectFor.js.map +1 -0
  70. package/lib/module/engine/runAgentTurn.js +663 -0
  71. package/lib/module/engine/runAgentTurn.js.map +1 -0
  72. package/lib/module/engine/systemPrompt.js +82 -0
  73. package/lib/module/engine/systemPrompt.js.map +1 -0
  74. package/lib/module/index.js +30 -0
  75. package/lib/module/index.js.map +1 -0
  76. package/lib/module/policy/labels.js +296 -0
  77. package/lib/module/policy/labels.js.map +1 -0
  78. package/lib/module/policy/policy.js +137 -0
  79. package/lib/module/policy/policy.js.map +1 -0
  80. package/lib/module/policy/redact.js +128 -0
  81. package/lib/module/policy/redact.js.map +1 -0
  82. package/lib/module/providers/anthropic.js +268 -0
  83. package/lib/module/providers/anthropic.js.map +1 -0
  84. package/lib/module/providers/openai.js +189 -0
  85. package/lib/module/providers/openai.js.map +1 -0
  86. package/lib/module/providers/sse.js +99 -0
  87. package/lib/module/providers/sse.js.map +1 -0
  88. package/lib/module/providers/types.js +4 -0
  89. package/lib/module/providers/types.js.map +1 -0
  90. package/lib/module/session.js +168 -0
  91. package/lib/module/session.js.map +1 -0
  92. package/lib/module/types.js +2 -0
  93. package/lib/module/types.js.map +1 -0
  94. package/lib/typescript/blocks/receipts.d.ts +32 -0
  95. package/lib/typescript/blocks/receipts.d.ts.map +1 -0
  96. package/lib/typescript/blocks/types.d.ts +576 -0
  97. package/lib/typescript/blocks/types.d.ts.map +1 -0
  98. package/lib/typescript/blocks/uiTool.d.ts +15 -0
  99. package/lib/typescript/blocks/uiTool.d.ts.map +1 -0
  100. package/lib/typescript/catalog/catalog.g.d.ts +11 -0
  101. package/lib/typescript/catalog/catalog.g.d.ts.map +1 -0
  102. package/lib/typescript/catalog/snapshotReads.d.ts +37 -0
  103. package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -0
  104. package/lib/typescript/catalog/toProviderTools.d.ts +52 -0
  105. package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -0
  106. package/lib/typescript/catalog/validateParams.d.ts +33 -0
  107. package/lib/typescript/catalog/validateParams.d.ts.map +1 -0
  108. package/lib/typescript/context/buildContextPack.d.ts +32 -0
  109. package/lib/typescript/context/buildContextPack.d.ts.map +1 -0
  110. package/lib/typescript/effects/ledger.d.ts +119 -0
  111. package/lib/typescript/effects/ledger.d.ts.map +1 -0
  112. package/lib/typescript/engine/effectFor.d.ts +21 -0
  113. package/lib/typescript/engine/effectFor.d.ts.map +1 -0
  114. package/lib/typescript/engine/runAgentTurn.d.ts +140 -0
  115. package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -0
  116. package/lib/typescript/engine/systemPrompt.d.ts +49 -0
  117. package/lib/typescript/engine/systemPrompt.d.ts.map +1 -0
  118. package/lib/typescript/index.d.ts +29 -0
  119. package/lib/typescript/index.d.ts.map +1 -0
  120. package/lib/typescript/policy/labels.d.ts +10 -0
  121. package/lib/typescript/policy/labels.d.ts.map +1 -0
  122. package/lib/typescript/policy/policy.d.ts +106 -0
  123. package/lib/typescript/policy/policy.d.ts.map +1 -0
  124. package/lib/typescript/policy/redact.d.ts +37 -0
  125. package/lib/typescript/policy/redact.d.ts.map +1 -0
  126. package/lib/typescript/providers/anthropic.d.ts +22 -0
  127. package/lib/typescript/providers/anthropic.d.ts.map +1 -0
  128. package/lib/typescript/providers/openai.d.ts +19 -0
  129. package/lib/typescript/providers/openai.d.ts.map +1 -0
  130. package/lib/typescript/providers/sse.d.ts +18 -0
  131. package/lib/typescript/providers/sse.d.ts.map +1 -0
  132. package/lib/typescript/providers/types.d.ts +129 -0
  133. package/lib/typescript/providers/types.d.ts.map +1 -0
  134. package/lib/typescript/session.d.ts +58 -0
  135. package/lib/typescript/session.d.ts.map +1 -0
  136. package/lib/typescript/types.d.ts +119 -0
  137. package/lib/typescript/types.d.ts.map +1 -0
  138. package/package.json +58 -0
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.humanise = humanise;
7
+ exports.titleCall = titleCall;
8
+ exports.toolTitle = toolTitle;
9
+ var _catalog = require("../catalog/catalog.g");
10
+ /**
11
+ * Human titles for tool calls.
12
+ *
13
+ * The catalog's `summary` field is written FOR THE MODEL — "Navigate the
14
+ * device to a concrete path (pushes by default; replace:true swaps the
15
+ * current screen)". Shown to a QA person in a 300pt-wide chat row it was
16
+ * truncated to "Navigate the device to a concrete path (pushes by default;
17
+ * replace:tru…", which is the worst of both worlds: too long to fit and too
18
+ * technical to help. The transcript, the changes bar and the approval card
19
+ * all render THIS layer instead: a short present-tense sentence with the one
20
+ * or two parameters a person would recognise ("Open /bag", "Update the cart
21
+ * store"), and the catalog sentence is kept alongside as the expandable
22
+ * "what this does" detail.
23
+ *
24
+ * Phrases are keyed `toolId.action`. `{a|b.c}` interpolates the first defined
25
+ * string/number among those parameter paths; a placeholder that resolves to
26
+ * nothing disappears with its surrounding space. Anything not phrased here
27
+ * falls back to the humanised action name plus the tool title, which is
28
+ * still short and still honest — never the model-facing paragraph.
29
+ */
30
+
31
+ const PHRASES = {
32
+ // Routes
33
+ "route-events.getSnapshot": "Check which screen is open",
34
+ "route-events.getCurrentRoute": "Check the current screen",
35
+ "route-events.navigate": "Open {path}",
36
+ "route-events.stackGoBack": "Go back one screen",
37
+ "route-events.stackNavigateToIndex": "Jump to screen {index} in the stack",
38
+ "route-events.stackPopToIndex": "Go back to screen {index}",
39
+ "route-events.stackPopToTop": "Go back to the first screen",
40
+ // State stores
41
+ "zustand.listStores": "List the app's stores",
42
+ "zustand.getStoreState": "Read the {storeName} store",
43
+ "zustand.getChangeDetail": "Inspect a store change",
44
+ "zustand.setState": "Update the {storeName} store",
45
+ "zustand.rehydrate": "Reload the {storeName} store from disk",
46
+ "redux.getState": "Read the Redux state",
47
+ "redux.getActionDetail": "Inspect a Redux action",
48
+ "redux.dispatch": "Dispatch {action.type}",
49
+ "jotai.listAtoms": "List the app's atoms",
50
+ "jotai.getAtomValue": "Read atom {label}",
51
+ "jotai.getChangeDetail": "Inspect an atom change",
52
+ "jotai.setAtom": "Set atom {label}",
53
+ // React Query
54
+ "query.listQueries": "List cached queries",
55
+ "query.getQueryData": "Read cached data for {queryHash}",
56
+ "query.refetch": "Refetch {queryHash}",
57
+ "query.invalidate": "Refresh {queryHash}",
58
+ "query.reset": "Reset {queryHash}",
59
+ "query.remove": "Drop {queryHash} from the cache",
60
+ "query.setQueryData": "Replace cached data for {queryHash|queryKey}",
61
+ "query.triggerError": "Force {queryHash} into an error",
62
+ "query.restoreError": "Clear the forced error on {queryHash}",
63
+ "query.triggerLoading": "Force {queryHash} to keep loading",
64
+ "query.restoreLoading": "Clear the forced loading on {queryHash}",
65
+ "query.clearQueryCache": "Clear the query cache",
66
+ "query.clearMutationCache": "Clear the mutation cache",
67
+ // Network
68
+ "network.getSnapshot": "Read recent network requests",
69
+ "network.getCaptureStatus": "Check network capture",
70
+ "network.getEventBody": "Read a request's body",
71
+ "network.setPinned": "Pin a request",
72
+ "network.setSaved": "Save a request",
73
+ "network.removeSavedRecord": "Remove saved request {key}",
74
+ "network.clearSavedRequests": "Clear saved requests",
75
+ "network.clearPinnedRequests": "Clear pinned requests",
76
+ "network.listOverrideRules": "List network overrides",
77
+ "network.getOverrideRuleBody": "Read a network override",
78
+ "network.debugOverrides": "Check overrides for {url}",
79
+ "network.upsertOverrideRule": "Add a network override",
80
+ "network.deleteOverrideRule": "Delete a network override",
81
+ "network.clearOverrideRules": "Clear all network overrides",
82
+ // Storage
83
+ "storage.async.getAllKeys": "List saved storage keys",
84
+ "storage.async.multiGet": "Read saved values",
85
+ "storage.async.getItem": "Read saved value {key}",
86
+ "storage.async.setItem": "Save {key}",
87
+ "storage.async.removeItem": "Delete saved value {key}",
88
+ "storage.async.multiRemove": "Delete saved values",
89
+ "storage.async.multiSet": "Save several values",
90
+ "storage.async.clear": "Clear all saved app data",
91
+ "storage.clearAppStorage": "Clear all saved app data",
92
+ "storage.getEventDetail": "Inspect a storage change",
93
+ "storage.timeTravel.undo": "Undo a storage change",
94
+ "storage.timeTravel.jump": "Rewind storage to an earlier point",
95
+ "storage.mmkv.snapshot": "Read MMKV storage",
96
+ "storage.mmkv.get": "Read {key} from MMKV",
97
+ "storage.mmkv.set": "Save {key} to MMKV",
98
+ "storage.mmkv.remove": "Delete {key} from MMKV",
99
+ "storage.secure.keys": "List secure storage keys",
100
+ "storage.secure.snapshot": "Read secure storage",
101
+ "storage.secure.get": "Read secure value {key}",
102
+ "storage.secure.set": "Save secure value {key}",
103
+ "storage.secure.delete": "Delete secure value {key}",
104
+ // Console / env / events
105
+ "console.getSnapshot": "Read recent console logs",
106
+ "console.clearEntries": "Clear the console",
107
+ "env.getSnapshot": "Read environment variables",
108
+ "events.exportEvents": "Export recent events",
109
+ "events.setEnabledSources": "Change which events are recorded",
110
+ "sentry.getSnapshot": "Read what's been sent to Sentry",
111
+ "sentry.clearEnvelopes": "Clear captured Sentry traffic",
112
+ // Ask Buoy's own session
113
+ "ask-buoy.listChanges": "List Ask Buoy's changes",
114
+ "ask-buoy.undoAll": "Undo everything Ask Buoy changed",
115
+ // Screen
116
+ "highlight-updates.describeScreen": "Look at what's on screen",
117
+ "highlight-updates.tapElement": "Tap {query|testID|text}",
118
+ "highlight-updates.waitFor": "Wait for {query|testID}",
119
+ "highlight-updates.locateComponent": "Find {query} on screen",
120
+ "highlight-updates.getRenderDetail": "Inspect a component's renders",
121
+ "highlight-updates.beginMeasurement": "Start counting renders",
122
+ "highlight-updates.endMeasurement": "Stop counting renders",
123
+ "highlight-updates.clearRenderCounts": "Clear render counts",
124
+ "debug-borders.cycleMode": "Cycle debug borders",
125
+ "debug-borders.setMode": "Set debug borders to {mode}",
126
+ // Impersonate
127
+ "impersonate.searchUsers": "Search users for {query}",
128
+ "impersonate.startImpersonation": "Impersonate {user.name|user.email|user.id}",
129
+ "impersonate.stopImpersonation": "Stop impersonating",
130
+ "impersonate.pauseImpersonation": "Pause impersonation",
131
+ "impersonate.resumeImpersonation": "Resume impersonation",
132
+ "impersonate.clearHistory": "Clear impersonation history",
133
+ // App / time machine / scenarios / perf
134
+ "app.ping": "Check the app is responding",
135
+ "app.reloadApp": "Reload the app",
136
+ "time-machine.list": "List saved snapshots",
137
+ "time-machine.capture": "Save a snapshot {name}",
138
+ "time-machine.captureBaseline": "Save a baseline snapshot",
139
+ "time-machine.restore": "Restore snapshot {id}",
140
+ "time-machine.preview": "Preview snapshot {id}",
141
+ "time-machine.inspect": "Inspect snapshot {id}",
142
+ "time-machine.delete": "Delete snapshot {id}",
143
+ "time-machine.rename": "Rename a snapshot to {name}",
144
+ "time-machine.duplicate": "Duplicate snapshot {id}",
145
+ "time-machine.wipeAll": "Delete every snapshot",
146
+ "scenarios.listScenarios": "List scenarios",
147
+ "scenarios.getScenario": "Read scenario {id}",
148
+ "scenarios.run": "Run scenario {id}",
149
+ "scenarios.preview": "Preview scenario {id}",
150
+ "scenarios.deactivate": "Stop the active scenario",
151
+ "scenarios.delete": "Delete scenario {id}",
152
+ "perf-monitor.startRecording": "Start recording performance",
153
+ "perf-monitor.stopRecording": "Stop recording performance",
154
+ "perf-monitor.mark": "Mark {label} on the timeline",
155
+ "perf-monitor.loadReport": "Load a performance report",
156
+ "perf-monitor.clearAll": "Clear all performance reports",
157
+ "js-top.sample": "Sample the JS thread",
158
+ "js-top.getOriginDetail": "Inspect {key} on the JS thread",
159
+ // Assets / images
160
+ "assets.list": "List bundled assets",
161
+ "assets.getDetail": "Inspect an asset",
162
+ "assets.rescan": "Rescan bundled assets",
163
+ "assets.measureSizes": "Measure asset sizes",
164
+ "images.list": "List loaded images",
165
+ "images.getDetail": "Inspect an image",
166
+ "images.getCaptureStatus": "Check image capture",
167
+ "images.retry": "Retry loading an image",
168
+ "images.flash": "Flash an image on screen",
169
+ "images.setNetworkMode": "Set image network mode to {mode}",
170
+ "images.clearExpoCaches": "Clear the image caches",
171
+ // TV
172
+ "tv-remote.arm": "Start capturing remote presses",
173
+ "tv-remote.disarm": "Stop capturing remote presses",
174
+ "focus-inspector.rescan": "Rescan focusable elements",
175
+ "focus-inspector.focusElement": "Move focus to an element"
176
+ };
177
+
178
+ /** Boolean-switch actions read better as two sentences than one template. */
179
+ const SWITCHES = {
180
+ "query.setOnline": {
181
+ param: "online",
182
+ on: "Put the app back online",
183
+ off: "Take the app offline"
184
+ },
185
+ "network.setOverridesEnabled": {
186
+ param: "enabled",
187
+ on: "Turn network overrides on",
188
+ off: "Turn network overrides off"
189
+ },
190
+ "network.setOverrideRuleEnabled": {
191
+ param: "enabled",
192
+ on: "Enable a network override",
193
+ off: "Disable a network override"
194
+ },
195
+ "highlight-updates.setEnabled": {
196
+ param: "enabled",
197
+ on: "Turn render highlighting on",
198
+ off: "Turn render highlighting off"
199
+ },
200
+ "perf-monitor.setEnabled": {
201
+ param: "enabled",
202
+ on: "Turn the perf monitor on",
203
+ off: "Turn the perf monitor off"
204
+ },
205
+ "js-top.setEnabled": {
206
+ param: "enabled",
207
+ on: "Turn JS Top on",
208
+ off: "Turn JS Top off"
209
+ },
210
+ "images.setBlankImages": {
211
+ param: "enabled",
212
+ on: "Blank out every image",
213
+ off: "Show images again"
214
+ },
215
+ "focus-inspector.setTracking": {
216
+ param: "enabled",
217
+ on: "Start tracking focus",
218
+ off: "Stop tracking focus"
219
+ },
220
+ "highlight-updates.setSilentTracking": {
221
+ param: "enabled",
222
+ on: "Track renders silently",
223
+ off: "Stop silent render tracking"
224
+ }
225
+ };
226
+ const TOOL_TITLES = Object.fromEntries(_catalog.CATALOG.map(t => [t.toolId, cleanTitle(t.title)]));
227
+
228
+ /** "JS TOP (JS-thread task manager)" → "JS Top"; everything else as-is. */
229
+ function cleanTitle(title) {
230
+ const base = title.replace(/\s*\(.*\)\s*$/, "").trim();
231
+ if (base !== base.toUpperCase() || base.length <= 3) return base;
232
+ return base.split(" ").map(w => w.length <= 2 ? w : w.charAt(0) + w.slice(1).toLowerCase()).join(" ");
233
+ }
234
+
235
+ /** The display name of a tool: "Routes", "Zustand", "React Query". */
236
+ function toolTitle(toolId) {
237
+ return TOOL_TITLES[toolId] ?? humanise(toolId);
238
+ }
239
+ const MAX_VALUE = 48;
240
+ function readPath(params, path) {
241
+ let cur = params;
242
+ for (const seg of path.split(".")) {
243
+ if (!cur || typeof cur !== "object") return undefined;
244
+ cur = cur[seg];
245
+ }
246
+ if (typeof cur === "string" && cur.trim()) return truncate(cur.trim());
247
+ if (typeof cur === "number") return String(cur);
248
+ return undefined;
249
+ }
250
+ function truncate(value) {
251
+ return value.length > MAX_VALUE ? `${value.slice(0, MAX_VALUE - 1)}…` : value;
252
+ }
253
+ function fill(template, params) {
254
+ return template.replace(/\{([^}]+)\}/g, (_, spec) => {
255
+ for (const path of spec.split("|")) {
256
+ const v = readPath(params, path.trim());
257
+ if (v !== undefined) return v;
258
+ }
259
+ return "";
260
+ }).replace(/\s{2,}/g, " ").trim();
261
+ }
262
+
263
+ /** `getStoreState` → "Get store state"; `async.getItem` → "Get item". */
264
+ function humanise(action) {
265
+ const last = action.split(".").pop() ?? action;
266
+ const words = last.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").toLowerCase();
267
+ return words.charAt(0).toUpperCase() + words.slice(1);
268
+ }
269
+
270
+ /** The one or two parameters a person would recognise in a fallback title. */
271
+ function notableParams(params) {
272
+ const parts = [];
273
+ for (const key of ["key", "id", "url", "name", "route", "path", "userId", "storeId", "type"]) {
274
+ const v = readPath(params, key);
275
+ if (v !== undefined) parts.push(v);
276
+ if (parts.length >= 2) break;
277
+ }
278
+ return parts.join(", ");
279
+ }
280
+
281
+ /**
282
+ * A short, present-tense title for a call — the thing a transcript row, a
283
+ * ledger row and an approval card all show first.
284
+ */
285
+ function titleCall(toolId, action, params) {
286
+ const key = `${toolId}.${action}`;
287
+ const sw = SWITCHES[key];
288
+ if (sw) return params[sw.param] === false ? sw.off : sw.on;
289
+ const phrase = PHRASES[key];
290
+ if (phrase) {
291
+ const out = fill(phrase, params);
292
+ if (out) return out;
293
+ }
294
+
295
+ // Generic verbs the whole suite shares.
296
+ const leaf = action.split(".").pop() ?? action;
297
+ if (leaf === "clearEvents") return `Clear the ${toolTitle(toolId)} timeline`;
298
+ if (leaf === "getSnapshot") return `Read ${toolTitle(toolId)}`;
299
+ const detail = notableParams(params);
300
+ const base = `${humanise(action)} in ${toolTitle(toolId)}`;
301
+ return detail ? `${base} (${detail})` : base;
302
+ }
303
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_catalog","require","PHRASES","SWITCHES","param","on","off","TOOL_TITLES","Object","fromEntries","CATALOG","map","t","toolId","cleanTitle","title","base","replace","trim","toUpperCase","length","split","w","charAt","slice","toLowerCase","join","toolTitle","humanise","MAX_VALUE","readPath","params","path","cur","seg","undefined","truncate","String","value","fill","template","_","spec","v","action","last","pop","words","notableParams","parts","key","push","titleCall","sw","phrase","out","leaf","detail"],"sourceRoot":"../../../src","sources":["policy/labels.ts"],"mappings":";;;;;;;;AAoBA,IAAAA,QAAA,GAAAC,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAMC,OAA+B,GAAG;EACtC;EACA,0BAA0B,EAAE,4BAA4B;EACxD,8BAA8B,EAAE,0BAA0B;EAC1D,uBAAuB,EAAE,aAAa;EACtC,0BAA0B,EAAE,oBAAoB;EAChD,mCAAmC,EAAE,qCAAqC;EAC1E,8BAA8B,EAAE,2BAA2B;EAC3D,4BAA4B,EAAE,6BAA6B;EAE3D;EACA,oBAAoB,EAAE,uBAAuB;EAC7C,uBAAuB,EAAE,4BAA4B;EACrD,yBAAyB,EAAE,wBAAwB;EACnD,kBAAkB,EAAE,8BAA8B;EAClD,mBAAmB,EAAE,wCAAwC;EAC7D,gBAAgB,EAAE,sBAAsB;EACxC,uBAAuB,EAAE,wBAAwB;EACjD,gBAAgB,EAAE,wBAAwB;EAC1C,iBAAiB,EAAE,sBAAsB;EACzC,oBAAoB,EAAE,mBAAmB;EACzC,uBAAuB,EAAE,wBAAwB;EACjD,eAAe,EAAE,kBAAkB;EAEnC;EACA,mBAAmB,EAAE,qBAAqB;EAC1C,oBAAoB,EAAE,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AEjC,MAAMS,EAAE,GAAGlD,QAAQ,CAAC+C,GAAG,CAAC;EACxB,IAAIG,EAAE,EAAE,OAAOtB,MAAM,CAACsB,EAAE,CAACjD,KAAK,CAAC,KAAK,KAAK,GAAGiD,EAAE,CAAC/C,GAAG,GAAG+C,EAAE,CAAChD,EAAE;EAE1D,MAAMiD,MAAM,GAAGpD,OAAO,CAACgD,GAAG,CAAC;EAC3B,IAAII,MAAM,EAAE;IACV,MAAMC,GAAG,GAAGhB,IAAI,CAACe,MAAM,EAAEvB,MAAM,CAAC;IAChC,IAAIwB,GAAG,EAAE,OAAOA,GAAG;EACrB;;EAEA;EACA,MAAMC,IAAI,GAAGZ,MAAM,CAACvB,KAAK,CAAC,GAAG,CAAC,CAACyB,GAAG,CAAC,CAAC,IAAIF,MAAM;EAC9C,IAAIY,IAAI,KAAK,aAAa,EAAE,OAAO,aAAa7B,SAAS,CAACd,MAAM,CAAC,WAAW;EAC5E,IAAI2C,IAAI,KAAK,aAAa,EAAE,OAAO,QAAQ7B,SAAS,CAACd,MAAM,CAAC,EAAE;EAE9D,MAAM4C,MAAM,GAAGT,aAAa,CAACjB,MAAM,CAAC;EACpC,MAAMf,IAAI,GAAG,GAAGY,QAAQ,CAACgB,MAAM,CAAC,OAAOjB,SAAS,CAACd,MAAM,CAAC,EAAE;EAC1D,OAAO4C,MAAM,GAAG,GAAGzC,IAAI,KAAKyC,MAAM,GAAG,GAAGzC,IAAI;AAC9C","ignoreList":[]}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_REQUIRE_APPROVAL = void 0;
7
+ exports.decide = decide;
8
+ exports.describeCall = describeCall;
9
+ exports.resolveRequireApproval = resolveRequireApproval;
10
+ var _labels = require("./labels");
11
+ /**
12
+ * What the agent is allowed to do, decided before dispatch.
13
+ *
14
+ * The default: reads and writes auto-run — the banner plus the effect ledger
15
+ * keep the user in control — but DESTRUCTIVE actions need a human tap unless
16
+ * the app explicitly passes `requireApproval: []`. Auto-running wipes proved
17
+ * too sharp in live evals (five destructive calls in one confused turn), and
18
+ * the approval gate is also the blast-radius control if injected text in a
19
+ * tool result ever steers the model.
20
+ *
21
+ * The one thing the policy layer will not do is let the agent report success
22
+ * for an action that cannot work in this build. Several Buoy actions return
23
+ * `{ok:true}` and do nothing once `__DEV__` is false — `upsertOverrideRule`
24
+ * persists a rule the engine never consults — and a QA tester who files a bug
25
+ * against data that was never applied is a worse outcome than no agent at all.
26
+ * So `release !== "works"` is refused BEFORE dispatch, with the reason handed
27
+ * back to the model as the tool result, and `unknown` fails closed.
28
+ */
29
+
30
+ /**
31
+ * One allow rule. A call is permitted when it matches ANY rule; every field a
32
+ * rule specifies must match. So a support seat that may impersonate and look
33
+ * at anything, and nothing else, is two rules:
34
+ *
35
+ * allow: [{ effect: "read" }, { toolId: "impersonate" }]
36
+ */
37
+
38
+ /** The one place the approval default lives; `decide` and the system prompt both resolve through it. */
39
+ const DEFAULT_REQUIRE_APPROVAL = exports.DEFAULT_REQUIRE_APPROVAL = ["destructive"];
40
+ function resolveRequireApproval(policy) {
41
+ return policy.requireApproval ?? DEFAULT_REQUIRE_APPROVAL;
42
+ }
43
+ /** SecureStore VALUE reads — gated behind `policy.secureReads`. Names stay open. */
44
+ const SECURE_VALUE_READS = new Set(["secure.get", "secure.snapshot"]);
45
+ function decide({
46
+ descriptor,
47
+ toolId,
48
+ policy,
49
+ isRelease
50
+ }) {
51
+ for (const rule of policy.deny ?? []) {
52
+ if (rule.toolId === toolId && (!rule.action || rule.action === descriptor.action)) {
53
+ return {
54
+ verdict: "refuse",
55
+ reason: "This action is disabled in this app."
56
+ };
57
+ }
58
+ }
59
+ if (isRelease && descriptor.release !== "works") {
60
+ return {
61
+ verdict: "refuse",
62
+ reason: releaseRefusal(descriptor)
63
+ };
64
+ }
65
+ if (policy.allow) {
66
+ const permitted = policy.allow.some(rule => (rule.toolId === undefined || rule.toolId === toolId) && (rule.action === undefined || rule.action === descriptor.action) && (rule.effect === undefined || rule.effect === descriptor.effect));
67
+ if (!permitted) {
68
+ return {
69
+ verdict: "refuse",
70
+ reason: "This action isn't on Ask Buoy's allow list in this app."
71
+ };
72
+ }
73
+ }
74
+ if (toolId === "storage" && SECURE_VALUE_READS.has(descriptor.action) && policy.secureReads !== true) {
75
+ return {
76
+ verdict: "refuse",
77
+ reason: "Reading SecureStore values is off by default — they are credentials, and they would be sent to the configured model endpoint. Key names are still readable via secure.keys; the app can opt in with policy.secureReads: true."
78
+ };
79
+ }
80
+ if (descriptor.effect !== "read" && policy.readOnly) {
81
+ return {
82
+ verdict: "refuse",
83
+ reason: "Ask Buoy is in read-only mode in this app, so it can look at state but not change it."
84
+ };
85
+ }
86
+ for (const rule of policy.requireApprovalFor ?? []) {
87
+ if (rule.toolId === toolId && (!rule.action || rule.action === descriptor.action)) {
88
+ return {
89
+ verdict: "needs-approval",
90
+ reason: "This app asks for a tap before this particular action runs."
91
+ };
92
+ }
93
+ }
94
+ if (descriptor.effect === "read") return {
95
+ verdict: "allow"
96
+ };
97
+ if (resolveRequireApproval(policy).includes(descriptor.effect)) {
98
+ return {
99
+ verdict: "needs-approval",
100
+ reason: descriptor.effect === "destructive" ? "This will wipe or reset something and can't be undone." : "This will change the app's state."
101
+ };
102
+ }
103
+ return {
104
+ verdict: "allow"
105
+ };
106
+ }
107
+
108
+ /**
109
+ * The message the model gets back instead of a result. Written to be relayed
110
+ * to a non-developer, because it usually will be.
111
+ */
112
+ function releaseRefusal(d) {
113
+ const base = `\`${d.action}\` does not work in this build (a release build).`;
114
+ switch (d.release) {
115
+ case "noop":
116
+ return `${base} It would report success and change nothing, so Buoy refused to run it rather than let you be told it worked. ${d.releaseNote ?? ""}`.trim();
117
+ case "empty":
118
+ return `${base} It relies on React's developer hook, which React Native only installs in development builds, so it can only ever return empty results here. ${d.releaseNote ?? ""}`.trim();
119
+ case "throws":
120
+ return `${base} It is explicitly disabled outside development. ${d.releaseNote ?? ""}`.trim();
121
+ default:
122
+ return `${base} Buoy could not confirm it behaves correctly outside development, so it refused rather than guess.`;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * A short, domain-flavoured title for what a call will do — the first line of
128
+ * a transcript row, a ledger row and an approval card.
129
+ *
130
+ * The raw tool payload is deliberately NOT what gets shown. A QA person cannot
131
+ * evaluate `redux_dispatch({type:'SET_ENTITLEMENTS', payload:{...}})`, and an
132
+ * approval prompt nobody can read is a rubber stamp, which is worse than no
133
+ * prompt because it looks like oversight.
134
+ *
135
+ * Nor is the catalog `summary`: that sentence is written for the model and
136
+ * ran to three lines in a phone-width row before it was cut off. The phrasing
137
+ * lives in ./labels.ts; the catalog sentence travels separately on the event
138
+ * as `description`, for a row the user chooses to expand.
139
+ */
140
+ function describeCall(toolId, descriptor, params) {
141
+ return (0, _labels.titleCall)(toolId, descriptor.action, params);
142
+ }
143
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_labels","require","DEFAULT_REQUIRE_APPROVAL","exports","resolveRequireApproval","policy","requireApproval","SECURE_VALUE_READS","Set","decide","descriptor","toolId","isRelease","rule","deny","action","verdict","reason","release","releaseRefusal","allow","permitted","some","undefined","effect","has","secureReads","readOnly","requireApprovalFor","includes","d","base","releaseNote","trim","describeCall","params","titleCall"],"sourceRoot":"../../../src","sources":["policy/policy.ts"],"mappings":";;;;;;;;;AAmBA,IAAAA,OAAA,GAAAC,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA;AACO,MAAMC,wBAAwC,GAAAC,OAAA,CAAAD,wBAAA,GAAG,CAAC,aAAa,CAAC;AAEhE,SAASE,sBAAsBA,CAACC,MAAqB,EAAkB;EAC5E,OAAOA,MAAM,CAACC,eAAe,IAAIJ,wBAAwB;AAC3D;AAeA;AACA,MAAMK,kBAA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,CAAC;IAC5L,KAAK,QAAQ;MACX,OAAO,GAAGF,IAAI,mDAAmDD,CAAC,CAACE,WAAW,IAAI,EAAE,EAAE,CAACC,IAAI,CAAC,CAAC;IAC/F;MACE,OAAO,GAAGF,IAAI,oGAAoG;EACtH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAC1BvB,MAAc,EACdD,UAA4B,EAC5ByB,MAA+B,EACvB;EACR,OAAO,IAAAC,iBAAS,EAACzB,MAAM,EAAED,UAAU,CAACK,MAAM,EAAEoB,MAAM,CAAC;AACrD","ignoreList":[]}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isSelfTraffic = isSelfTraffic;
7
+ exports.redact = redact;
8
+ exports.registerSelfEndpoint = registerSelfEndpoint;
9
+ exports.stripSelfTraffic = stripSelfTraffic;
10
+ /**
11
+ * Scrub tool results before they leave the device.
12
+ *
13
+ * Two separate reasons, and the second is the one people forget:
14
+ *
15
+ * 1. EGRESS. Tool results go to the customer's own model endpoint. That is
16
+ * their data boundary, not ours — but a response body carrying an
17
+ * `Authorization` header or a Buoy `licenseKey` is a credential, and
18
+ * credentials do not belong in a chat transcript that may be retained for
19
+ * 30 days for abuse monitoring.
20
+ * 2. SELF-INJECTION. Buoy's own network interceptor captures the agent's
21
+ * requests to the model endpoint. Without exclusion, the model reads back
22
+ * its own request headers — including whatever the host app's `headers()`
23
+ * returned — out of `network.getRequests`. That is a credential leak and a
24
+ * prompt-injection channel in one call.
25
+ */
26
+
27
+ const SECRET_KEYS = ["authorization", "cookie", "set-cookie", "x-api-key", "api-key", "apikey", "proxy-authorization", "x-auth-token", "licensekey", "license_key", "refresh_token", "access_token", "id_token", "password", "secret", "client_secret"];
28
+ const REDACTED = "[redacted by Buoy]";
29
+
30
+ /**
31
+ * Credential SHAPES, for values whose key name gives nothing away — a JWT
32
+ * stored under `session`, a Bearer header quoted inside a response body. The
33
+ * key-name check alone let those through whole. Same shapes the broker wire
34
+ * scrubber uses; duplicated here because agent-core cannot depend on ask-buoy.
35
+ */
36
+ const SECRET_VALUE_PATTERNS = [{
37
+ re: /\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,
38
+ label: "[bearer token removed]"
39
+ }, {
40
+ re: /\beyJ[A-Za-z0-9._-]{20,}/g,
41
+ label: "[jwt removed]"
42
+ }, {
43
+ re: /\bsk-[A-Za-z0-9_-]{16,}/g,
44
+ label: "[api key removed]"
45
+ }, {
46
+ re: /\bBUOY-[A-Z0-9-]{8,}/g,
47
+ label: "[license key removed]"
48
+ }, {
49
+ re: /("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?[^\s"',}]{6,}/gi,
50
+ label: "[credential removed]"
51
+ }];
52
+ function scrubString(s) {
53
+ let out = s;
54
+ for (const {
55
+ re,
56
+ label
57
+ } of SECRET_VALUE_PATTERNS) {
58
+ out = out.replace(re, label);
59
+ }
60
+ return out;
61
+ }
62
+ function isSecretKey(key) {
63
+ const k = key.toLowerCase();
64
+ return SECRET_KEYS.some(s => k === s || k.endsWith(s) || k.includes(s));
65
+ }
66
+
67
+ /**
68
+ * Deep-redact by key name AND by value shape. Depth-limited because tool
69
+ * results can be deeply nested state trees and a runaway walk on a megabyte
70
+ * payload is a frame drop on the JS thread the app is also using.
71
+ */
72
+ function redact(value, depth = 0) {
73
+ if (typeof value === "string") return scrubString(value);
74
+ if (depth > 12 || value === null || typeof value !== "object") return value;
75
+ if (Array.isArray(value)) {
76
+ return value.map(v => redact(v, depth + 1));
77
+ }
78
+ const out = {};
79
+ for (const [key, v] of Object.entries(value)) {
80
+ out[key] = isSecretKey(key) ? REDACTED : redact(v, depth + 1);
81
+ }
82
+ return out;
83
+ }
84
+
85
+ /**
86
+ * Hosts that must never appear in a tool result, because they are the agent's
87
+ * own traffic. Registered by the runtime from the configured endpoint.
88
+ */
89
+ const selfHosts = new Set();
90
+ function registerSelfEndpoint(endpoint) {
91
+ try {
92
+ // No URL polyfill assumptions — a plain parse is enough for a host match.
93
+ const match = /^[a-z]+:\/\/([^/?#]+)/i.exec(endpoint);
94
+ if (match?.[1]) selfHosts.add(match[1].toLowerCase());
95
+ } catch {
96
+ /* an unparseable endpoint just means no exclusion */
97
+ }
98
+ }
99
+ function isSelfTraffic(url) {
100
+ if (typeof url !== "string") return false;
101
+ const lower = url.toLowerCase();
102
+ for (const host of selfHosts) {
103
+ if (lower.includes(host)) return true;
104
+ }
105
+ return false;
106
+ }
107
+ function hasSelfUrl(item) {
108
+ if (!item || typeof item !== "object") return false;
109
+ const rec = item;
110
+ return isSelfTraffic(rec.url ?? rec.uri ?? rec.href);
111
+ }
112
+
113
+ /**
114
+ * Drop the agent's own requests out of a network-shaped result before the
115
+ * model sees them.
116
+ *
117
+ * WALKS INTO OBJECTS, not just top-level arrays. A network reader returns
118
+ * `{ totalCaptured, requests: [...] }`, not a bare array, and a version of
119
+ * this that only handled the bare array quietly did nothing — the agent's own
120
+ * POST to the model endpoint, headers and all, came straight back to it out
121
+ * of the network read. Depth-limited for the same reason `redact` is: this
122
+ * runs on the JS thread the app is drawing on.
123
+ */
124
+ function stripSelfTraffic(value, depth = 0) {
125
+ if (depth > 6 || value === null || typeof value !== "object") return value;
126
+ if (Array.isArray(value)) {
127
+ return value.filter(item => !hasSelfUrl(item)).map(item => stripSelfTraffic(item, depth + 1));
128
+ }
129
+ const out = {};
130
+ for (const [key, v] of Object.entries(value)) {
131
+ out[key] = stripSelfTraffic(v, depth + 1);
132
+ }
133
+ return out;
134
+ }
135
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SECRET_KEYS","REDACTED","SECRET_VALUE_PATTERNS","re","label","scrubString","s","out","replace","isSecretKey","key","k","toLowerCase","some","endsWith","includes","redact","value","depth","Array","isArray","map","v","Object","entries","selfHosts","Set","registerSelfEndpoint","endpoint","match","exec","add","isSelfTraffic","url","lower","host","hasSelfUrl","item","rec","uri","href","stripSelfTraffic","filter"],"sourceRoot":"../../../src","sources":["policy/redact.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,WAAW,GAAG,CAClB,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,CAChB;AAED,MAAMC,QAAQ,GAAG,oBAAoB;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAsD,GAAG,CAC7D;EAAEC,EAAE,EAAE,uCAAuC;EAAEC,KAAK,EAAE;AAAyB,CAAC,EAChF;EAAED,EAAE,EAAE,2BAA2B;EAAEC,KAAK,EAAE;AAAgB,CAAC,EAC3D;EAAED,EAAE,EAAE,0BAA0B;EAAEC,KAAK,EAAE;AAAoB,CAAC,EAC9D;EAAED,EAAE,EAAE,uBAAuB;EAAEC,KAAK,EAAE;AAAwB,CAAC,EAC/D;EACED,EAAE,EAAE,0HAA0H;EAC9HC,KAAK,EAAE;AACT,CAAC,CACF;AAED,SAASC,WAAWA,CAACC,CAAS,EAAU;EACtC,IAAIC,GAAG,GAAGD,CAAC;EACX,KAAK,MAAM;IAAEH,EAAE;IAAEC;EAAM,CAAC,IAAIF,qBAAqB,EAAE;IACjDK,GAAG,GAAGA,GAAG,CAACC,OAAO,CAACL,EAAE,EAAEC,KAAK,CAAC;EAC9B;EACA,OAAOG,GAAG;AACZ;AAEA,SAASE,WAAWA,CAACC,GAAW,EAAW;EACzC,MAAMC,CAAC,GAAGD,GAAG,CAACE,WAAW,CAAC,CAAC;EAC3B,OAAOZ,WAAW,CAACa,IAAI,CAAEP,CA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