@buoy-gg/agent-core 7.0.40 → 7.0.42
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/blocks/receipts.js +1 -761
- package/lib/commonjs/blocks/runId.js +1 -31
- package/lib/commonjs/blocks/types.js +1 -140
- package/lib/commonjs/blocks/uiTool.js +6 -1405
- package/lib/commonjs/catalog/catalog.g.js +5 -4207
- package/lib/commonjs/catalog/catalog.source.json +656 -12
- package/lib/commonjs/catalog/catalog.types.g.js +1 -44
- package/lib/commonjs/catalog/normalizeParams.js +2 -332
- package/lib/commonjs/catalog/signature.js +1 -68
- package/lib/commonjs/catalog/snapshotReads.js +1 -263
- package/lib/commonjs/catalog/toProviderTools.js +2 -145
- package/lib/commonjs/catalog/validateParams.js +1 -129
- package/lib/commonjs/context/buildContextPack.js +1 -489
- package/lib/commonjs/effects/digest.js +1 -34
- package/lib/commonjs/effects/ledger.js +1 -325
- package/lib/commonjs/engine/askGate.js +1 -287
- package/lib/commonjs/engine/effectFor.js +1 -176
- package/lib/commonjs/engine/evidence.js +3 -111
- package/lib/commonjs/engine/historyBudget.js +1 -363
- package/lib/commonjs/engine/retrieve.js +1 -214
- package/lib/commonjs/engine/runAgentTurn.js +8 -1803
- package/lib/commonjs/engine/systemPrompt.js +54 -163
- package/lib/commonjs/engine/textToolCalls.js +1 -276
- package/lib/commonjs/engine/tokenCalibration.js +1 -81
- package/lib/commonjs/engine/verify.js +4 -297
- package/lib/commonjs/index.js +1 -384
- package/lib/commonjs/policy/labels.js +1 -319
- package/lib/commonjs/policy/policy.js +1 -148
- package/lib/commonjs/policy/redact.js +1 -172
- package/lib/commonjs/providers/anthropic.js +3 -445
- package/lib/commonjs/providers/openai.js +4 -324
- package/lib/commonjs/providers/problem.js +1 -98
- package/lib/commonjs/providers/sse.js +1 -240
- package/lib/commonjs/providers/streamTimer.js +1 -123
- package/lib/commonjs/providers/transport.js +1 -123
- package/lib/commonjs/providers/types.js +1 -6
- package/lib/commonjs/providers/xhrStream.js +1 -212
- package/lib/commonjs/realNow.js +1 -0
- package/lib/commonjs/session.js +1 -393
- package/lib/commonjs/types.js +0 -1
- package/lib/module/blocks/receipts.js +1 -755
- package/lib/module/blocks/runId.js +1 -26
- package/lib/module/blocks/types.js +1 -134
- package/lib/module/blocks/uiTool.js +6 -1396
- package/lib/module/catalog/catalog.g.js +5 -4203
- package/lib/module/catalog/catalog.source.json +656 -12
- package/lib/module/catalog/catalog.types.g.js +1 -40
- package/lib/module/catalog/normalizeParams.js +2 -326
- package/lib/module/catalog/signature.js +1 -63
- package/lib/module/catalog/snapshotReads.js +1 -259
- package/lib/module/catalog/toProviderTools.js +2 -139
- package/lib/module/catalog/validateParams.js +1 -124
- package/lib/module/context/buildContextPack.js +1 -485
- package/lib/module/effects/digest.js +1 -29
- package/lib/module/effects/ledger.js +1 -319
- package/lib/module/engine/askGate.js +1 -280
- package/lib/module/engine/effectFor.js +1 -173
- package/lib/module/engine/evidence.js +3 -105
- package/lib/module/engine/historyBudget.js +1 -355
- package/lib/module/engine/retrieve.js +1 -210
- package/lib/module/engine/runAgentTurn.js +8 -1794
- package/lib/module/engine/systemPrompt.js +54 -157
- package/lib/module/engine/textToolCalls.js +1 -270
- package/lib/module/engine/tokenCalibration.js +1 -75
- package/lib/module/engine/verify.js +4 -289
- package/lib/module/index.js +1 -35
- package/lib/module/policy/labels.js +1 -312
- package/lib/module/policy/policy.js +1 -142
- package/lib/module/policy/redact.js +1 -165
- package/lib/module/providers/anthropic.js +3 -441
- package/lib/module/providers/openai.js +4 -320
- package/lib/module/providers/problem.js +1 -92
- package/lib/module/providers/sse.js +1 -231
- package/lib/module/providers/streamTimer.js +1 -118
- package/lib/module/providers/transport.js +1 -119
- package/lib/module/providers/types.js +1 -4
- package/lib/module/providers/xhrStream.js +1 -207
- package/lib/module/realNow.js +1 -0
- package/lib/module/session.js +1 -369
- package/lib/module/types.js +0 -1
- package/lib/typescript/catalog/catalog.g.d.ts +3 -3
- package/lib/typescript/catalog/catalog.types.g.d.ts +7 -4
- package/lib/typescript/effects/ledger.d.ts +16 -1
- package/lib/typescript/providers/problem.d.ts +0 -20
- package/lib/typescript/providers/streamTimer.d.ts +0 -24
- package/lib/typescript/realNow.d.ts +18 -0
- package/lib/web/index.mjs +152 -0
- package/package.json +24 -3
- package/lib/commonjs/blocks/receipts.js.map +0 -1
- package/lib/commonjs/blocks/runId.js.map +0 -1
- package/lib/commonjs/blocks/types.js.map +0 -1
- package/lib/commonjs/blocks/uiTool.js.map +0 -1
- package/lib/commonjs/catalog/catalog.g.js.map +0 -1
- package/lib/commonjs/catalog/catalog.types.g.js.map +0 -1
- package/lib/commonjs/catalog/normalizeParams.js.map +0 -1
- package/lib/commonjs/catalog/signature.js.map +0 -1
- package/lib/commonjs/catalog/snapshotReads.js.map +0 -1
- package/lib/commonjs/catalog/toProviderTools.js.map +0 -1
- package/lib/commonjs/catalog/validateParams.js.map +0 -1
- package/lib/commonjs/context/buildContextPack.js.map +0 -1
- package/lib/commonjs/effects/digest.js.map +0 -1
- package/lib/commonjs/effects/ledger.js.map +0 -1
- package/lib/commonjs/engine/askGate.js.map +0 -1
- package/lib/commonjs/engine/effectFor.js.map +0 -1
- package/lib/commonjs/engine/evidence.js.map +0 -1
- package/lib/commonjs/engine/historyBudget.js.map +0 -1
- package/lib/commonjs/engine/retrieve.js.map +0 -1
- package/lib/commonjs/engine/runAgentTurn.js.map +0 -1
- package/lib/commonjs/engine/systemPrompt.js.map +0 -1
- package/lib/commonjs/engine/textToolCalls.js.map +0 -1
- package/lib/commonjs/engine/tokenCalibration.js.map +0 -1
- package/lib/commonjs/engine/verify.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/policy/labels.js.map +0 -1
- package/lib/commonjs/policy/policy.js.map +0 -1
- package/lib/commonjs/policy/redact.js.map +0 -1
- package/lib/commonjs/providers/anthropic.js.map +0 -1
- package/lib/commonjs/providers/openai.js.map +0 -1
- package/lib/commonjs/providers/problem.js.map +0 -1
- package/lib/commonjs/providers/sse.js.map +0 -1
- package/lib/commonjs/providers/streamTimer.js.map +0 -1
- package/lib/commonjs/providers/transport.js.map +0 -1
- package/lib/commonjs/providers/types.js.map +0 -1
- package/lib/commonjs/providers/xhrStream.js.map +0 -1
- package/lib/commonjs/session.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/blocks/receipts.js.map +0 -1
- package/lib/module/blocks/runId.js.map +0 -1
- package/lib/module/blocks/types.js.map +0 -1
- package/lib/module/blocks/uiTool.js.map +0 -1
- package/lib/module/catalog/catalog.g.js.map +0 -1
- package/lib/module/catalog/catalog.types.g.js.map +0 -1
- package/lib/module/catalog/normalizeParams.js.map +0 -1
- package/lib/module/catalog/signature.js.map +0 -1
- package/lib/module/catalog/snapshotReads.js.map +0 -1
- package/lib/module/catalog/toProviderTools.js.map +0 -1
- package/lib/module/catalog/validateParams.js.map +0 -1
- package/lib/module/context/buildContextPack.js.map +0 -1
- package/lib/module/effects/digest.js.map +0 -1
- package/lib/module/effects/ledger.js.map +0 -1
- package/lib/module/engine/askGate.js.map +0 -1
- package/lib/module/engine/effectFor.js.map +0 -1
- package/lib/module/engine/evidence.js.map +0 -1
- package/lib/module/engine/historyBudget.js.map +0 -1
- package/lib/module/engine/retrieve.js.map +0 -1
- package/lib/module/engine/runAgentTurn.js.map +0 -1
- package/lib/module/engine/systemPrompt.js.map +0 -1
- package/lib/module/engine/textToolCalls.js.map +0 -1
- package/lib/module/engine/tokenCalibration.js.map +0 -1
- package/lib/module/engine/verify.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/policy/labels.js.map +0 -1
- package/lib/module/policy/policy.js.map +0 -1
- package/lib/module/policy/redact.js.map +0 -1
- package/lib/module/providers/anthropic.js.map +0 -1
- package/lib/module/providers/openai.js.map +0 -1
- package/lib/module/providers/problem.js.map +0 -1
- package/lib/module/providers/sse.js.map +0 -1
- package/lib/module/providers/streamTimer.js.map +0 -1
- package/lib/module/providers/transport.js.map +0 -1
- package/lib/module/providers/types.js.map +0 -1
- package/lib/module/providers/xhrStream.js.map +0 -1
- package/lib/module/session.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/blocks/receipts.d.ts.map +0 -1
- package/lib/typescript/blocks/runId.d.ts.map +0 -1
- package/lib/typescript/blocks/types.d.ts.map +0 -1
- package/lib/typescript/blocks/uiTool.d.ts.map +0 -1
- package/lib/typescript/catalog/catalog.g.d.ts.map +0 -1
- package/lib/typescript/catalog/catalog.types.g.d.ts.map +0 -1
- package/lib/typescript/catalog/normalizeParams.d.ts.map +0 -1
- package/lib/typescript/catalog/signature.d.ts.map +0 -1
- package/lib/typescript/catalog/snapshotReads.d.ts.map +0 -1
- package/lib/typescript/catalog/toProviderTools.d.ts.map +0 -1
- package/lib/typescript/catalog/validateParams.d.ts.map +0 -1
- package/lib/typescript/context/buildContextPack.d.ts.map +0 -1
- package/lib/typescript/effects/digest.d.ts.map +0 -1
- package/lib/typescript/effects/ledger.d.ts.map +0 -1
- package/lib/typescript/engine/askGate.d.ts.map +0 -1
- package/lib/typescript/engine/effectFor.d.ts.map +0 -1
- package/lib/typescript/engine/evidence.d.ts.map +0 -1
- package/lib/typescript/engine/historyBudget.d.ts.map +0 -1
- package/lib/typescript/engine/retrieve.d.ts.map +0 -1
- package/lib/typescript/engine/runAgentTurn.d.ts.map +0 -1
- package/lib/typescript/engine/systemPrompt.d.ts.map +0 -1
- package/lib/typescript/engine/textToolCalls.d.ts.map +0 -1
- package/lib/typescript/engine/tokenCalibration.d.ts.map +0 -1
- package/lib/typescript/engine/verify.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/policy/labels.d.ts.map +0 -1
- package/lib/typescript/policy/policy.d.ts.map +0 -1
- package/lib/typescript/policy/redact.d.ts.map +0 -1
- package/lib/typescript/providers/anthropic.d.ts.map +0 -1
- package/lib/typescript/providers/openai.d.ts.map +0 -1
- package/lib/typescript/providers/problem.d.ts.map +0 -1
- package/lib/typescript/providers/sse.d.ts.map +0 -1
- package/lib/typescript/providers/streamTimer.d.ts.map +0 -1
- package/lib/typescript/providers/transport.d.ts.map +0 -1
- package/lib/typescript/providers/types.d.ts.map +0 -1
- package/lib/typescript/providers/xhrStream.d.ts.map +0 -1
- package/lib/typescript/session.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
|
@@ -1,44 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CATALOG_ACTIONS = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* GENERATED by scripts/gen-agent-catalog.mjs — do not edit.
|
|
9
|
-
* Source: packages/agent-core/src/catalog/catalog.source.json
|
|
10
|
-
*
|
|
11
|
-
* The catalog's tool ids and action names as types, so a wrong name fails
|
|
12
|
-
* at compile time. `catalog.g.ts` carries the data.
|
|
13
|
-
*
|
|
14
|
-
* 24 Buoy tools, 196 actions.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/** Action names per tool — the runtime mirror of {@link CatalogActionMap}. */
|
|
18
|
-
const CATALOG_ACTIONS = exports.CATALOG_ACTIONS = {
|
|
19
|
-
"env": ["getSnapshot"],
|
|
20
|
-
"console": ["getSnapshot", "clearEntries"],
|
|
21
|
-
"sentry": ["getSnapshot", "clearEnvelopes"],
|
|
22
|
-
"jotai": ["listAtoms", "getAtomValue", "getChangeDetail", "setAtom", "clearEvents"],
|
|
23
|
-
"route-events": ["getSnapshot", "getCurrentRoute", "navigate", "stackGoBack", "stackNavigateToIndex", "stackPopToIndex", "stackPopToTop", "clearEvents"],
|
|
24
|
-
"debug-borders": ["cycleMode", "setMode"],
|
|
25
|
-
"zustand": ["listStores", "getStoreState", "getChangeDetail", "setState", "rehydrate", "clearEvents"],
|
|
26
|
-
"redux": ["getState", "getActionDetail", "dispatch", "clearEvents"],
|
|
27
|
-
"impersonate": ["searchUsers", "startImpersonation", "stopImpersonation", "pauseImpersonation", "resumeImpersonation", "updateSettings", "removeFromHistory", "clearHistory"],
|
|
28
|
-
"query": ["listQueries", "getQueryData", "refetch", "invalidate", "reset", "remove", "setQueryData", "triggerError", "restoreError", "triggerLoading", "restoreLoading", "clearQueryCache", "clearMutationCache", "setOnline"],
|
|
29
|
-
"events": ["exportEvents", "setEnabledSources", "clearEvents"],
|
|
30
|
-
"network": ["getSnapshot", "getCaptureStatus", "getEventBody", "setPinned", "setSaved", "removeSavedRecord", "clearSavedRequests", "clearPinnedRequests", "clearEvents", "listOverrideRules", "getOverrideRuleBody", "debugOverrides", "upsertOverrideRule", "setOverrideRuleEnabled", "setOverridesEnabled", "deleteOverrideRule", "clearOverrideRules", "getNetworkConditions", "setNetworkConditions"],
|
|
31
|
-
"js-top": ["sample", "getOriginDetail", "setEnabled", "pause", "resume", "clear"],
|
|
32
|
-
"app": ["ping", "reloadApp"],
|
|
33
|
-
"time-machine": ["list", "capture", "captureBaseline", "wipeAll", "restore", "preview", "inspect", "delete", "rename", "duplicate", "setExclusions", "setScope", "setRestoreRoute"],
|
|
34
|
-
"storage": ["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"],
|
|
35
|
-
"highlight-updates": ["describeScreen", "tapElement", "waitFor", "beginMeasurement", "endMeasurement", "locateComponent", "getRenderDetail", "setEnabled", "toggle", "setSilentTracking", "toggleFreeze", "setSpotlight", "clearRenderCounts"],
|
|
36
|
-
"scenarios": ["listScenarios", "getScenario", "save", "acceptDraft", "discardDraft", "preview", "run", "deactivate", "delete", "setFolder", "listFolders", "getActive", "export"],
|
|
37
|
-
"perf-monitor": ["setEnabled", "startRecording", "stopRecording", "savePending", "discardPending", "mark", "startAutomation", "cancelAutomation", "acknowledgeAutomation", "refreshIndex", "getAutomationConfig", "setAutomationConfig", "loadReport", "deleteReport", "deleteBatch", "clearAll"],
|
|
38
|
-
"assets": ["list", "getDetail", "rescan", "measureSizes", "saveBaseline", "clearBaseline", "getDiff", "clearRecords", "getScanStatus"],
|
|
39
|
-
"tv-remote": ["arm", "getEventsSince", "setMenuCapture", "disarm", "clear"],
|
|
40
|
-
"focus-inspector": ["rescan", "focusElement", "setTracking", "clearHistory"],
|
|
41
|
-
"images": ["list", "getDetail", "getCaptureStatus", "retry", "flash", "proveSavings", "setOverride", "clearOverride", "setNetworkMode", "setBlankImages", "hardReload", "evictDisk", "massAction", "clearRecords", "clearExpoCaches"],
|
|
42
|
-
"ask-buoy": ["listChanges", "undoAll", "retrieve", "openProcedure"]
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=catalog.types.g.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CATALOG_ACTIONS=void 0;const CATALOG_ACTIONS=exports.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"],"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,333 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.aliasNote=aliasNote;exports.hashQueryKey=hashQueryKey;exports.normalizeParams=normalizeParams;const isPlainObject=r=>!!r&&typeof r==="object"&&!Array.isArray(r);function hashQueryKey(r){return JSON.stringify(r,(e,t)=>isPlainObject(t)?Object.keys(t).sort().reduce((a,i)=>{a[i]=t[i];return a},{}):t)}function alias(r,e,t,a){if(r[t]!==void 0||r[e]===void 0)return false;r[t]=r[e];delete r[e];a.push(`Accepted \`${e}\` as \`${t}\` \u2014 the parameter is named \`${t}\`.`);return true}const QUERY_HASH_ACTIONS=new Set(["getQueryData","refetch","invalidate","reset","remove","triggerError","restoreError","triggerLoading","restoreLoading"]);const RULE_FIELDS=["id","urlPattern","enabled","name","methods","kind","status","statusText","headers","body","bodyPatch","bodyPath","bodyValue","failKind","delayMs","times","alternate","force","bodyOmitted"];function normalizeQuery(r,e,t){if(QUERY_HASH_ACTIONS.has(r)&&e.queryHash===void 0){const a=isPlainObject(e.filters)?e.filters:void 0;const i=e.queryKey??e.key??e.hash??a?.queryKey??a?.queryHash;if(Array.isArray(i)){e.queryHash=hashQueryKey(i);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 i==="string"){e.queryHash=i;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(r==="setQueryData"){if(isPlainObject(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.`)}}}alias(e,"newData","data",t)||e.path===void 0&&alias(e,"value","data",t)||alias(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 normalizeNetwork(r,e,t){if(r==="getEventBody"||r==="setPinned"||r==="setSaved"){alias(e,"requestId","id",t)||alias(e,"eventId","id",t)}if(r==="deleteOverrideRule"||r==="setOverrideRuleEnabled"||r==="getOverrideRuleBody"){alias(e,"ruleId","id",t)}if(r==="upsertOverrideRule"){const a=isPlainObject(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;unwrapRuleSections(a,t);ruleIntentWords(e,a,t);const i=[];for(const d of RULE_FIELDS){if(e[d]!==void 0&&a[d]===void 0){a[d]=e[d];i.push(d)}delete e[d]}if(i.length)t.push(`Accepted ${i.map(d=>`\`${d}\``).join(", ")} at the top level \u2014 rule fields belong inside \`rule\`.`);if(Object.keys(a).length)e.rule=a}}function unwrapRuleSections(r,e){for(const[t,a]of[["match",["urlPattern","methods","method","url","pattern","urlContains","contains"]],["response",["status","statusText","body","headers","bodyPatch"]]]){const i=r[t];if(!isPlainObject(i))continue;const d=[];for(const s of a){if(i[s]===void 0)continue;const n=s==="method"?"methods":s==="url"||s==="pattern"||s==="urlContains"||s==="contains"?"urlPattern":s;if(r[n]!==void 0)continue;r[n]=n==="methods"&&!Array.isArray(i[s])?[i[s]]:i[s];delete i[s];d.push(s)}if(!d.length)continue;if(!Object.keys(i).length)delete r[t];e.push(`Read \`rule.${t}.{${d.join(", ")}}\` as top-level rule fields \u2014 this rule is flat, unlike msw/nock-style mocks.`)}}function ruleIntentWords(r,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]:r[s];const i=s=>{delete e[s];delete r[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}"\`.`)}i("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.')}i("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.')}i("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.")}i("once");for(const s of["maxHits","hits","count","maxTimes","applyTimes"]){const n=a(s);if(typeof n==="number"&&Number.isFinite(n)&&n>0&&e.times===void 0){e.times=n;t.push(`Read \`${s}: ${n}\` as \`times: ${n}\` \u2014 the rule auto-disables after ${n} match(es).`)}i(s)}}function normalizeZustand(r,e,t){alias(e,"name","storeName",t)||alias(e,"store","storeName",t);if(r==="setState"){alias(e,"statePatch","state",t)||alias(e,"partial","state",t)||alias(e,"patch","state",t)||alias(e,"newState","state",t)||alias(e,"nextState","state",t)||e.path===void 0&&alias(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 normalizeRoutes(r,e,t){if(r==="navigate"){alias(e,"route","path",t)||alias(e,"to","path",t)||alias(e,"url","path",t)||alias(e,"pathname","path",t)}}function normalizeParams(r,e,t){const a={...t};const i=[];switch(r){case"query":normalizeQuery(e,a,i);break;case"network":normalizeNetwork(e,a,i);break;case"zustand":normalizeZustand(e,a,i);break;case"route-events":normalizeRoutes(e,a,i);break;default:break}return{params:a,notes:i}}function aliasNote(r){return r.length?`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.aliasNote = aliasNote;
|
|
7
|
-
exports.hashQueryKey = hashQueryKey;
|
|
8
|
-
exports.normalizeParams = normalizeParams;
|
|
9
|
-
/**
|
|
10
|
-
* Parameter aliases — accept what models actually send.
|
|
11
|
-
*
|
|
12
|
-
* The provider sees ONE tool per Buoy tool with `params` as an open object
|
|
13
|
-
* (see toProviderTools.ts), so the per-action parameter names live in prose
|
|
14
|
-
* and every model has to reproduce them from memory. A sweep of 18 models
|
|
15
|
-
* against the live app showed the same handful of misses over and over, on
|
|
16
|
-
* cheap models AND on gpt-5 and Gemini 2.5 Pro:
|
|
17
|
-
*
|
|
18
|
-
* queryKey: [...] where the action wants queryHash (by far the #1 miss —
|
|
19
|
-
* the RIGHT NOW block shows keys as arrays, and
|
|
20
|
-
* setQueryData takes queryKey, so the model reuses it)
|
|
21
|
-
* requestId where network.getEventBody wants id
|
|
22
|
-
* newState/patch where zustand.setState wants state
|
|
23
|
-
* name where zustand wants storeName
|
|
24
|
-
* bodyPatch/body/… at the top level of upsertOverrideRule instead of inside `rule`
|
|
25
|
-
*
|
|
26
|
-
* A validation error names the right field, but a cheap model repeats the same
|
|
27
|
-
* wrong call or gives up, and the user sees "nothing happened". Every one of
|
|
28
|
-
* these is mechanically unambiguous, so it is fixed HERE, before validation,
|
|
29
|
-
* and the result carries a one-line note so the model learns the real name
|
|
30
|
-
* without failing the call. Nothing here guesses: an alias only fires when the
|
|
31
|
-
* canonical field is absent and the alias is present.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
const isPlainObject = v => !!v && typeof v === "object" && !Array.isArray(v);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* TanStack's default `hashKey`: JSON.stringify with plain-object keys sorted,
|
|
38
|
-
* so `["todos", {page:1, sort:"a"}]` hashes the same whatever order the model
|
|
39
|
-
* wrote the object in.
|
|
40
|
-
*/
|
|
41
|
-
function hashQueryKey(key) {
|
|
42
|
-
return JSON.stringify(key, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((acc, k) => {
|
|
43
|
-
acc[k] = val[k];
|
|
44
|
-
return acc;
|
|
45
|
-
}, {}) : val);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Rename `from` to `to` when `to` is absent and `from` is present. */
|
|
49
|
-
function alias(p, from, to, notes) {
|
|
50
|
-
if (p[to] !== undefined || p[from] === undefined) return false;
|
|
51
|
-
p[to] = p[from];
|
|
52
|
-
delete p[from];
|
|
53
|
-
notes.push(`Accepted \`${from}\` as \`${to}\` — the parameter is named \`${to}\`.`);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
const QUERY_HASH_ACTIONS = new Set(["getQueryData", "refetch", "invalidate", "reset", "remove", "triggerError", "restoreError", "triggerLoading", "restoreLoading"]);
|
|
57
|
-
|
|
58
|
-
/** Fields that belong inside `rule` for network.upsertOverrideRule. */
|
|
59
|
-
const RULE_FIELDS = ["id", "urlPattern", "enabled", "name", "methods", "kind", "status", "statusText", "headers", "body", "bodyPatch", "bodyPath", "bodyValue", "failKind", "delayMs", "times", "alternate", "force", "bodyOmitted"];
|
|
60
|
-
function normalizeQuery(action, p, notes) {
|
|
61
|
-
if (QUERY_HASH_ACTIONS.has(action) && p.queryHash === undefined) {
|
|
62
|
-
// `filters: { queryKey }` — the TanStack client-API shape.
|
|
63
|
-
const filters = isPlainObject(p.filters) ? p.filters : undefined;
|
|
64
|
-
const key = p.queryKey ?? p.key ?? p.hash ?? filters?.queryKey ?? filters?.queryHash;
|
|
65
|
-
if (Array.isArray(key)) {
|
|
66
|
-
p.queryHash = hashQueryKey(key);
|
|
67
|
-
notes.push(`Accepted the queryKey array as the query's hash (${p.queryHash}) — the parameter is \`queryHash\`, the string from listQueries.`);
|
|
68
|
-
} else if (typeof key === "string") {
|
|
69
|
-
// A hash string under another name, or a loose "a,b,c" spelling the
|
|
70
|
-
// adapter resolves against the live cache.
|
|
71
|
-
p.queryHash = key;
|
|
72
|
-
notes.push(`Accepted it as \`queryHash\` — that is the parameter name.`);
|
|
73
|
-
}
|
|
74
|
-
delete p.queryKey;
|
|
75
|
-
delete p.key;
|
|
76
|
-
delete p.hash;
|
|
77
|
-
delete p.filters;
|
|
78
|
-
}
|
|
79
|
-
if (action === "setQueryData") {
|
|
80
|
-
// Models routinely tuck the write FLAGS inside `data` — `data: {item:{…},
|
|
81
|
-
// merge:true}` — which turns a merge into a replace and leaves a junk
|
|
82
|
-
// `merge`/`force` key in the cache. Lift a boolean flag out of `data` to
|
|
83
|
-
// the top level when the top level doesn't already set it. Guarded to
|
|
84
|
-
// booleans so a real data field named "merge" is never disturbed.
|
|
85
|
-
if (isPlainObject(p.data)) {
|
|
86
|
-
for (const flag of ["merge", "force"]) {
|
|
87
|
-
if (typeof p.data[flag] === "boolean" && p[flag] === undefined) {
|
|
88
|
-
p[flag] = p.data[flag];
|
|
89
|
-
delete p.data[flag];
|
|
90
|
-
notes.push(`Moved \`${flag}\` out of \`data\` to the top level — it is a write flag, not part of the value.`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// `value` normally means "the patch, spelled differently". But alongside
|
|
95
|
-
// `path` it means the OPPOSITE — the single value that path is set to — so
|
|
96
|
-
// rewriting it there would turn `path:"item.name", value:"x"` into a
|
|
97
|
-
// top-level patch of `"x"`, silently. Only the path form reserves it.
|
|
98
|
-
alias(p, "newData", "data", notes) || p.path === undefined && alias(p, "value", "data", notes) || alias(p, "patch", "data", notes);
|
|
99
|
-
if (p.queryKey === undefined && typeof p.queryHash === "string") {
|
|
100
|
-
try {
|
|
101
|
-
const parsed = JSON.parse(p.queryHash);
|
|
102
|
-
if (Array.isArray(parsed)) {
|
|
103
|
-
p.queryKey = parsed;
|
|
104
|
-
notes.push("Accepted the queryHash as the key — setQueryData takes `queryKey`, the array.");
|
|
105
|
-
}
|
|
106
|
-
} catch {
|
|
107
|
-
/* leave it; validation will say what is missing */
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (p.patch !== undefined || p.merge === undefined) {
|
|
111
|
-
// A caller that said "patch" meant merge.
|
|
112
|
-
if (notes.some(n => n.includes("`patch`"))) p.merge = true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function normalizeNetwork(action, p, notes) {
|
|
117
|
-
if (action === "getEventBody" || action === "setPinned" || action === "setSaved") {
|
|
118
|
-
alias(p, "requestId", "id", notes) || alias(p, "eventId", "id", notes);
|
|
119
|
-
}
|
|
120
|
-
if (action === "deleteOverrideRule" || action === "setOverrideRuleEnabled" || action === "getOverrideRuleBody") {
|
|
121
|
-
alias(p, "ruleId", "id", notes);
|
|
122
|
-
}
|
|
123
|
-
if (action === "upsertOverrideRule") {
|
|
124
|
-
const rule = isPlainObject(p.rule) ? {
|
|
125
|
-
...p.rule
|
|
126
|
-
} : {};
|
|
127
|
-
// fromRequestId is a TOP-LEVEL field; models tuck it into the rule.
|
|
128
|
-
if (p.fromRequestId === undefined && typeof rule.fromRequestId === "string") {
|
|
129
|
-
p.fromRequestId = rule.fromRequestId;
|
|
130
|
-
notes.push("Accepted `rule.fromRequestId` — it is a top-level parameter, beside `rule`.");
|
|
131
|
-
}
|
|
132
|
-
delete rule.fromRequestId;
|
|
133
|
-
unwrapRuleSections(rule, notes);
|
|
134
|
-
ruleIntentWords(p, rule, notes);
|
|
135
|
-
// Rule fields sent flat at the top level move inside `rule`.
|
|
136
|
-
const moved = [];
|
|
137
|
-
for (const f of RULE_FIELDS) {
|
|
138
|
-
if (p[f] !== undefined && rule[f] === undefined) {
|
|
139
|
-
rule[f] = p[f];
|
|
140
|
-
moved.push(f);
|
|
141
|
-
}
|
|
142
|
-
delete p[f];
|
|
143
|
-
}
|
|
144
|
-
if (moved.length) notes.push(`Accepted ${moved.map(f => `\`${f}\``).join(", ")} at the top level — rule fields belong inside \`rule\`.`);
|
|
145
|
-
if (Object.keys(rule).length) p.rule = rule;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Flatten the `match` / `response` wrappers models borrow from other mocking
|
|
151
|
-
* libraries.
|
|
152
|
-
*
|
|
153
|
-
* Our rule is flat — `{urlPattern, methods, status, body, times}`. Nearly every
|
|
154
|
-
* HTTP-mocking library a model has read is not: msw, nock and WireMock all group
|
|
155
|
-
* the matcher and the reply into separate objects. So a model that has never
|
|
156
|
-
* seen our schema (and it has not — `params` is an unconstrained object) writes
|
|
157
|
-
* the convention it knows. Measured: Claude sent
|
|
158
|
-
* `{times: 1, match: {method, urlPattern}, response: {status, body}}` — every
|
|
159
|
-
* value correct, in the shape the rest of the world uses.
|
|
160
|
-
*
|
|
161
|
-
* Only these two wrapper names, and only fields that are really ours: an
|
|
162
|
-
* unrecognised key inside one is left where it is rather than hoisted, so this
|
|
163
|
-
* cannot quietly invent a rule field that does not exist.
|
|
164
|
-
*/
|
|
165
|
-
function unwrapRuleSections(rule, notes) {
|
|
166
|
-
for (const [wrapper, fields] of [["match", ["urlPattern", "methods", "method", "url", "pattern", "urlContains", "contains"]], ["response", ["status", "statusText", "body", "headers", "bodyPatch"]]]) {
|
|
167
|
-
const inner = rule[wrapper];
|
|
168
|
-
if (!isPlainObject(inner)) continue;
|
|
169
|
-
const moved = [];
|
|
170
|
-
for (const f of fields) {
|
|
171
|
-
if (inner[f] === undefined) continue;
|
|
172
|
-
// `method` and `url` are that library's spelling of ours.
|
|
173
|
-
const target = f === "method" ? "methods" : f === "url" || f === "pattern" || f === "urlContains" || f === "contains" ? "urlPattern" : f;
|
|
174
|
-
if (rule[target] !== undefined) continue;
|
|
175
|
-
rule[target] = target === "methods" && !Array.isArray(inner[f]) ? [inner[f]] : inner[f];
|
|
176
|
-
delete inner[f];
|
|
177
|
-
moved.push(f);
|
|
178
|
-
}
|
|
179
|
-
if (!moved.length) continue;
|
|
180
|
-
// Everything recognised moved out; drop the wrapper only if nothing is left,
|
|
181
|
-
// so a leftover key still surfaces as a schema error rather than vanishing.
|
|
182
|
-
if (!Object.keys(inner).length) delete rule[wrapper];
|
|
183
|
-
notes.push(`Read \`rule.${wrapper}.{${moved.join(", ")}}\` as top-level rule fields — this rule is flat, unlike msw/nock-style mocks.`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* The words models reach for when describing an override rule, mapped to the
|
|
189
|
-
* fields the rule actually has.
|
|
190
|
-
*
|
|
191
|
-
* MEASURED, not invented. On `api-sim/next-call-fails-once` — "make the next
|
|
192
|
-
* menu request fail, just the next one" — every model that acted picked the
|
|
193
|
-
* right tool and explained the right reason, then wrote the rule like this:
|
|
194
|
-
*
|
|
195
|
-
* grok ×3 {fail: true, once: true}
|
|
196
|
-
* composer {fail: true} and {maxHits: 1, fail: true}
|
|
197
|
-
* opus {status: 500, enabled: true}
|
|
198
|
-
*
|
|
199
|
-
* The schema wants `{kind: "fail", times: 1}`. Ten of fourteen attempts on that
|
|
200
|
-
* case graded `acceptable` rather than `best` for no reason except this — the
|
|
201
|
-
* budget was expressed as `once`/`maxHits` and silently dropped, leaving a rule
|
|
202
|
-
* that never expires.
|
|
203
|
-
*
|
|
204
|
-
* It is NOT a missing instruction. `times` is documented as "Use 1 for 'make the
|
|
205
|
-
* next call fail' so it cannot linger" — very nearly the user's own sentence —
|
|
206
|
-
* and every model read past it. That is the same finding as the nesting-depth
|
|
207
|
-
* work: the fix has to be structural, not a better sentence.
|
|
208
|
-
*
|
|
209
|
-
* Each mapping only ever makes a rule NARROWER (a budget where there was none,
|
|
210
|
-
* a transport failure where the kind was unstated), so a misread costs a rule
|
|
211
|
-
* that stops too early rather than one that runs forever.
|
|
212
|
-
*/
|
|
213
|
-
function ruleIntentWords(p, rule, notes) {
|
|
214
|
-
// `path`/`value` is what the state tools call this, and a model that learned
|
|
215
|
-
// it on `zustand.setState` or `query.setQueryData` writes the same words here.
|
|
216
|
-
// A rule has no other meaning for either name, so accept them.
|
|
217
|
-
if (rule.bodyPath === undefined && typeof rule.path === "string") {
|
|
218
|
-
rule.bodyPath = rule.path;
|
|
219
|
-
if (rule.bodyValue === undefined && rule.value !== undefined) rule.bodyValue = rule.value;
|
|
220
|
-
delete rule.path;
|
|
221
|
-
delete rule.value;
|
|
222
|
-
notes.push("Read `path`/`value` as `bodyPath`/`bodyValue` — on a rule they address the response body.");
|
|
223
|
-
}
|
|
224
|
-
const read = key => rule[key] !== undefined ? rule[key] : p[key];
|
|
225
|
-
const drop = key => {
|
|
226
|
-
delete rule[key];
|
|
227
|
-
delete p[key];
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
// `mode` is the other library's name for `kind`, and models use it verbatim:
|
|
231
|
-
// measured on `api-sim/api-down`, alongside `match.urlContains`.
|
|
232
|
-
const mode = read("mode");
|
|
233
|
-
if (typeof mode === "string" && ["respond", "fail", "delay"].includes(mode) && rule.kind === undefined) {
|
|
234
|
-
rule.kind = mode;
|
|
235
|
-
notes.push(`Read \`mode: "${mode}"\` as \`kind: "${mode}"\`.`);
|
|
236
|
-
}
|
|
237
|
-
drop("mode");
|
|
238
|
-
|
|
239
|
-
// "fail" as a flag, rather than kind:"fail".
|
|
240
|
-
if (read("fail") === true && rule.kind === undefined) {
|
|
241
|
-
rule.kind = "fail";
|
|
242
|
-
notes.push("Read `fail: true` as `kind: \"fail\"` — a transport failure, as if offline.");
|
|
243
|
-
}
|
|
244
|
-
drop("fail");
|
|
245
|
-
|
|
246
|
-
// "just once" / "only the next one", in the several ways it gets written.
|
|
247
|
-
if (read("failOnce") === true) {
|
|
248
|
-
if (rule.kind === undefined) rule.kind = "fail";
|
|
249
|
-
if (rule.times === undefined) rule.times = 1;
|
|
250
|
-
notes.push("Read `failOnce: true` as `kind: \"fail\"` with `times: 1` — it fires once, then the rule disables itself.");
|
|
251
|
-
}
|
|
252
|
-
drop("failOnce");
|
|
253
|
-
if (read("once") === true && rule.times === undefined) {
|
|
254
|
-
rule.times = 1;
|
|
255
|
-
notes.push("Read `once: true` as `times: 1` — the rule auto-disables after one match.");
|
|
256
|
-
}
|
|
257
|
-
drop("once");
|
|
258
|
-
|
|
259
|
-
// A numeric budget under any of its other names. `limit` is deliberately NOT
|
|
260
|
-
// here: it means "how many to list" on half the actions in this catalog, and
|
|
261
|
-
// a wrong guess about a budget is a rule that stops early on a request the
|
|
262
|
-
// caller still needed.
|
|
263
|
-
for (const key of ["maxHits", "hits", "count", "maxTimes", "applyTimes"]) {
|
|
264
|
-
const v = read(key);
|
|
265
|
-
if (typeof v === "number" && Number.isFinite(v) && v > 0 && rule.times === undefined) {
|
|
266
|
-
rule.times = v;
|
|
267
|
-
notes.push(`Read \`${key}: ${v}\` as \`times: ${v}\` — the rule auto-disables after ${v} match(es).`);
|
|
268
|
-
}
|
|
269
|
-
drop(key);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function normalizeZustand(action, p, notes) {
|
|
273
|
-
alias(p, "name", "storeName", notes) || alias(p, "store", "storeName", notes);
|
|
274
|
-
if (action === "setState") {
|
|
275
|
-
alias(p, "statePatch", "state", notes) || alias(p, "partial", "state", notes) || alias(p, "patch", "state", notes) || alias(p, "newState", "state", notes) || alias(p, "nextState", "state", notes) ||
|
|
276
|
-
// See the same guard on setQueryData: with `path`, `value` is the value
|
|
277
|
-
// being set, not another spelling of the patch.
|
|
278
|
-
p.path === undefined && alias(p, "value", "state", notes);
|
|
279
|
-
// ALWAYS merge, never replace, unless the caller explicitly said replace.
|
|
280
|
-
// The adapter defaults replace:true, which throws away everything not sent
|
|
281
|
-
// — including the store's ACTION FUNCTIONS (setQty, removeLine, …), which
|
|
282
|
-
// can't cross the JSON wire, so a remote caller never has them to re-send.
|
|
283
|
-
// The data then looks right but the buttons that call those methods crash.
|
|
284
|
-
// A merge (replace:false) shallow-merges the fields sent and keeps the
|
|
285
|
-
// functions and untouched keys intact.
|
|
286
|
-
if (p.replace === undefined) {
|
|
287
|
-
p.replace = false;
|
|
288
|
-
notes.push("Applied replace:false (merge) — 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.");
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function normalizeRoutes(action, p, notes) {
|
|
293
|
-
if (action === "navigate") {
|
|
294
|
-
alias(p, "route", "path", notes) || alias(p, "to", "path", notes) || alias(p, "url", "path", notes) || alias(p, "pathname", "path", notes);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Fix the unambiguous parameter-name misses before validation. Returns the
|
|
300
|
-
* same object shape validation expects plus the notes to append to the result.
|
|
301
|
-
*/
|
|
302
|
-
function normalizeParams(toolId, action, raw) {
|
|
303
|
-
const p = {
|
|
304
|
-
...raw
|
|
305
|
-
};
|
|
306
|
-
const notes = [];
|
|
307
|
-
switch (toolId) {
|
|
308
|
-
case "query":
|
|
309
|
-
normalizeQuery(action, p, notes);
|
|
310
|
-
break;
|
|
311
|
-
case "network":
|
|
312
|
-
normalizeNetwork(action, p, notes);
|
|
313
|
-
break;
|
|
314
|
-
case "zustand":
|
|
315
|
-
normalizeZustand(action, p, notes);
|
|
316
|
-
break;
|
|
317
|
-
case "route-events":
|
|
318
|
-
normalizeRoutes(action, p, notes);
|
|
319
|
-
break;
|
|
320
|
-
default:
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
params: p,
|
|
325
|
-
notes
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/** The one-line trailer appended to a tool result when aliases fired. */
|
|
330
|
-
function aliasNote(notes) {
|
|
331
|
-
return notes.length ? `\n\n[Buoy] ${notes.join(" ")}` : "";
|
|
332
|
-
}
|
|
333
|
-
//# sourceMappingURL=normalizeParams.js.map
|
|
3
|
+
[Buoy] ${r.join(" ")}`:""}
|
|
@@ -1,68 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.paramsLine = paramsLine;
|
|
7
|
-
exports.signature = signature;
|
|
8
|
-
/**
|
|
9
|
-
* Rendering a JSON Schema as the one-line signature a model reads.
|
|
10
|
-
*
|
|
11
|
-
* Lifted out of `blocks/uiTool.ts`, where it was written for `buoy_ui` and
|
|
12
|
-
* where its own comment records the result that justifies using it everywhere:
|
|
13
|
-
*
|
|
14
|
-
* > `uiProviderTool` used to send `params: { type: "object" }` and 26 lines
|
|
15
|
-
* > of prose about what each kind is FOR — and not one field name. The model
|
|
16
|
-
* > was being asked to guess `images` vs `items` and `chips` vs `options`,
|
|
17
|
-
* > and it guessed wrong three rounds running.
|
|
18
|
-
*
|
|
19
|
-
* The other 24 tools still send exactly that: an open `params` object and a
|
|
20
|
-
* sentence promising the error will explain the shape. `normalizeParams.ts`
|
|
21
|
-
* exists to catch the five misses that produced most often. This renders the
|
|
22
|
-
* field names instead, from the SAME schema `validateParams` enforces, so what
|
|
23
|
-
* the model reads can never drift from what the validator accepts.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/** `{ url*, alt?, caption? }` — `*` marks required. */
|
|
27
|
-
function signature(schema, depth = 0) {
|
|
28
|
-
if (!schema || typeof schema !== "object") return "any";
|
|
29
|
-
const s = schema;
|
|
30
|
-
if (Array.isArray(s.anyOf)) {
|
|
31
|
-
return s.anyOf.map(b => signature(b, depth)).join(" | ");
|
|
32
|
-
}
|
|
33
|
-
if (s.type === "array") {
|
|
34
|
-
const cap = typeof s.maxItems === "number" ? ` ≤${s.maxItems}` : "";
|
|
35
|
-
return `[${signature(s.items, depth + 1)}${cap}]`;
|
|
36
|
-
}
|
|
37
|
-
if (s.type === "object" || s.properties) {
|
|
38
|
-
const props = s.properties ?? {};
|
|
39
|
-
const names = Object.keys(props);
|
|
40
|
-
if (!names.length) return "{…}";
|
|
41
|
-
// Three levels is every field a model has to name; below that lives the
|
|
42
|
-
// action's `dispatch`, which the prose already describes.
|
|
43
|
-
if (depth >= 3) return "{…}";
|
|
44
|
-
const required = new Set(s.required ?? []);
|
|
45
|
-
const fields = names.map(name => {
|
|
46
|
-
const inner = signature(props[name], depth + 1);
|
|
47
|
-
const mark = required.has(name) ? "*" : "";
|
|
48
|
-
return inner === "any" ? `${name}${mark}` : `${name}${mark}: ${inner}`;
|
|
49
|
-
});
|
|
50
|
-
return `{ ${fields.join(", ")} }`;
|
|
51
|
-
}
|
|
52
|
-
if (Array.isArray(s.enum)) return s.enum.map(v => `"${String(v)}"`).join("|");
|
|
53
|
-
return typeof s.type === "string" ? s.type : "any";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The `params:` line under an action, or "" when the action takes none.
|
|
58
|
-
*
|
|
59
|
-
* Actions with no declared properties (71 of 192) get nothing rather than an
|
|
60
|
-
* empty `{}` — a line that says the action takes no arguments is already said
|
|
61
|
-
* by its absence, and 71 of them would be pure noise.
|
|
62
|
-
*/
|
|
63
|
-
function paramsLine(schema) {
|
|
64
|
-
const props = schema?.properties;
|
|
65
|
-
if (!props || Object.keys(props).length === 0) return "";
|
|
66
|
-
return `params: ${signature(schema)}`;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=signature.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.paramsLine=paramsLine;exports.signature=signature;function signature(n,t=0){if(!n||typeof n!=="object")return"any";const r=n;if(Array.isArray(r.anyOf)){return r.anyOf.map(e=>signature(e,t)).join(" | ")}if(r.type==="array"){const e=typeof r.maxItems==="number"?` \u2264${r.maxItems}`:"";return`[${signature(r.items,t+1)}${e}]`}if(r.type==="object"||r.properties){const e=r.properties??{};const i=Object.keys(e);if(!i.length)return"{\u2026}";if(t>=3)return"{\u2026}";const u=new Set(r.required??[]);const a=i.map(s=>{const o=signature(e[s],t+1);const p=u.has(s)?"*":"";return o==="any"?`${s}${p}`:`${s}${p}: ${o}`});return`{ ${a.join(", ")} }`}if(Array.isArray(r.enum))return r.enum.map(e=>`"${String(e)}"`).join("|");return typeof r.type==="string"?r.type:"any"}function paramsLine(n){const t=n?.properties;if(!t||Object.keys(t).length===0)return"";return`params: ${signature(n)}`}
|