@buoy-gg/agent-core 7.0.78 → 7.0.80
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 +752 -9
- package/lib/commonjs/catalog/catalog.types.g.js +1 -1
- package/lib/commonjs/catalog/snapshotReads.js +1 -1
- package/lib/commonjs/effects/ledger.js +1 -1
- package/lib/commonjs/engine/compactScreen.js +1 -1
- package/lib/commonjs/engine/runAgentTurn.js +7 -7
- package/lib/commonjs/engine/systemPrompt.js +12 -12
- package/lib/commonjs/engine/textToolCalls.js +1 -1
- package/lib/commonjs/engine/verify.js +1 -1
- package/lib/commonjs/providers/fallback.js +1 -1
- package/lib/commonjs/session.js +1 -1
- package/lib/module/catalog/catalog.g.js +2 -2
- package/lib/module/catalog/catalog.source.json +752 -9
- package/lib/module/catalog/catalog.types.g.js +1 -1
- package/lib/module/catalog/snapshotReads.js +1 -1
- package/lib/module/effects/ledger.js +1 -1
- package/lib/module/engine/compactScreen.js +1 -1
- package/lib/module/engine/runAgentTurn.js +7 -7
- package/lib/module/engine/systemPrompt.js +12 -12
- package/lib/module/engine/textToolCalls.js +1 -1
- package/lib/module/engine/verify.js +1 -1
- package/lib/module/providers/fallback.js +1 -1
- package/lib/module/session.js +1 -1
- package/lib/typescript/catalog/catalog.g.d.ts +3 -3
- package/lib/typescript/catalog/catalog.types.g.d.ts +6 -2
- package/lib/typescript/effects/ledger.d.ts +8 -2
- package/lib/typescript/engine/runAgentTurn.d.ts +5 -0
- package/lib/typescript/session.d.ts +2 -0
- package/lib/web/index.mjs +56 -55
- package/package.json +1 -1
package/lib/module/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{selectFeed as G}from"./feeds";import{CATALOG as J}from"./catalog/catalog.g";import{buildContextDigest as Q,buildLiveContext as W}from"./context/buildContextPack";import{runAgentTurn as X}from"./engine/runAgentTurn";import{buildLiveBlock as Y,buildSystemPrompt as Z,listableProcedures as _}from"./engine/systemPrompt";import{EffectLedger as g}from"./effects/ledger";import{EvidenceStore as ee}from"./engine/evidence";import{TokenCalibration as te}from"./engine/tokenCalibration";import{compressConsumed as oe,trimHistory as re,trimHistoryReport as I}from"./engine/historyBudget";import{createAnthropicProvider as se}from"./providers/anthropic";import{createOpenAIProvider as le}from"./providers/openai";import{createFallbackProvider as ae}from"./providers/fallback";import{resolveRequireApproval as ne}from"./policy/policy";import{registerSelfEndpoint as M}from"./policy/redact";export{oe as compressConsumed,re as trimHistory,I as trimHistoryReport};export function resumableHistory(e){let o=e.length;while(o>0){const s=e[o-1];if(s.role==="assistant"&&!s.toolCalls?.length)break;o-=1}return e.slice(0,o).map(s=>s.role==="assistant"&&s.thinking?{...s,thinking:void 0}:s)}export function createAskBuoySession(e){const o=G(e.provider?.protocol??e.protocol,e.feedOptions);e={...e,feedOptions:o.options};let s=0;const L=e.catalog??J;const n=new g;const O=e.policy??{};let a=[];const N=new Set;const w=new ee;const c=new te;let p;let x=false;let u=false;const v=new Set;let y=false;let f=0;let k=0;let b={};let S={};M(e.endpoint);const B=(t,r)=>t==="openai"?le(r):se(r);let R=null;if(!e.provider&&e.fallback){const t=e.fallback;M(t.endpoint);const r={...e,endpoint:t.endpoint,model:t.model,feedOptions:G(t.protocol).options};R=ae({provider:B(e.protocol,e),model:e.model},{provider:B(t.protocol,r),model:t.model},h=>e.onModelSwitch?.(h==="second"?"fallback":"primary"))}const z=e.provider??R??B(e.protocol,e);let d=e.availableActions;let i=Object.keys(d);const l={...O};function $(){for(const t of Object.keys(l))delete l[t];Object.assign(l,O);if(u){l.requireApproval=[];l.requireApprovalFor=[]}if(y)l.readOnly=true}function D(){return l}function P(){if(e.system!==void 0){p=e.system;return}p=Z({catalog:L,context:{...e.context,digest:{...b,...e.context?.digest}},isRelease:e.isRelease,readOnly:l.readOnly??false,readOnlySource:O.readOnly?"app":y?"device":void 0,requireApproval:ne(l),approvalsBypassed:u,appName:e.appName,platform:e.platform,availableToolIds:i})}async function j(){if(x)return;x=true;b={};try{b=await Q({dispatch:e.dispatch,readSnapshot:e.readSnapshot,availableToolIds:i,availableActions:d})}catch{}S={};for(const t of b.zustandStores??[]){const r=t;if(r?.persistsTo&&r.name)S[r.persistsTo]=r.name}P()}return{ledger:n,evidence:w,calibration:c,trustedActions:()=>[...v],untrust:t=>{v.delete(t)},get messages(){return a},prime:j,setAvailableActions(t){d=t;i=Object.keys(t)},setApprovalBypass(t){if(u===t)return;u=t;$();if(p)P()},setReadOnly(t){if(y===t)return;y=t;$();if(p)P()},restore(t){if(a.length>0)return;const r=I(resumableHistory(t),c.charsPerToken,n.liveCallIds());a=r.messages;f=r.droppedRounds},async*send(t,r){const h=k;await j();let T;try{T=await W({dispatch:e.dispatch,readSnapshot:e.readSnapshot,availableToolIds:i,availableActions:d})}catch{T=void 0}if(h!==k){yield{type:"done",stopReason:"superseded"};return}const E=Y(T,n.list().map(m=>({label:`${m.toolId}.${m.action}${m.effect.label?` \u2014 ${m.effect.label}`:""}`,undone:m.undoneAt!==void 0})));const K={role:"user",text:t,...o.name==="claude"?{turnId:`turn-${++s}`}:{},...o.options.liveBlock&&o.options.liveBlock!=="system-tail"?{liveBlock:{placement:o.options.liveBlock,text:E}}:{}};const C=a[a.length-1];const U=C?.role==="user"&&(C.systemNotice||C.liveBlock?.placement==="system-msg")?[{role:"assistant",text:"[Buoy: The prior turn stopped before an answer.]"}]:[];const q=I([...a,...U,K],c.charsPerToken,n.liveCallIds());const V=q.messages;const F=q.droppedRounds+f;f=0;if(F>0)yield{type:"history-trimmed",droppedRounds:F,droppedPinned:q.droppedPinned};const H=X({provider:z,catalog:L,messages:V,system:p,systemVolatile:o.options.liveBlock&&o.options.liveBlock!=="system-tail"?void 0:E,feedOptions:o.options,model:e.model,maxTokens:o.options.maxTokens??e.maxTokens??4096,dispatch:e.dispatch,readSnapshot:e.readSnapshot,storeKeyOwners:S,ledger:n,policy:D(),isRelease:e.isRelease,availableToolIds:i,availableActions:d,requestApproval:e.requestApproval,seenUrls:N,evidence:w,calibration:c,trusted:v,procedures:_(e.context?.procedures,i),signal:r});let A=await H.next();while(!A.done){yield A.value;A=await H.next()}if(h===k)a=A.value},reset(){k+=1;R?.reset();a=[];f=0;n.clear();N.clear();w.clear();v.clear();x=false}}}
|
|
1
|
+
"use strict";import{selectFeed as G}from"./feeds";import{CATALOG as J}from"./catalog/catalog.g";import{buildContextDigest as Q,buildLiveContext as W}from"./context/buildContextPack";import{runAgentTurn as X}from"./engine/runAgentTurn";import{buildLiveBlock as Y,buildSystemPrompt as Z,listableProcedures as _}from"./engine/systemPrompt";import{EffectLedger as g}from"./effects/ledger";import{EvidenceStore as ee}from"./engine/evidence";import{TokenCalibration as te}from"./engine/tokenCalibration";import{compressConsumed as oe,trimHistory as re,trimHistoryReport as I}from"./engine/historyBudget";import{createAnthropicProvider as se}from"./providers/anthropic";import{createOpenAIProvider as le}from"./providers/openai";import{createFallbackProvider as ae}from"./providers/fallback";import{resolveRequireApproval as ne}from"./policy/policy";import{registerSelfEndpoint as M}from"./policy/redact";export{oe as compressConsumed,re as trimHistory,I as trimHistoryReport};export function resumableHistory(e){let o=e.length;while(o>0){const s=e[o-1];if(s.role==="assistant"&&!s.toolCalls?.length)break;o-=1}return e.slice(0,o).map(s=>s.role==="assistant"&&s.thinking?{...s,thinking:void 0}:s)}export function createAskBuoySession(e){const o=G(e.provider?.protocol??e.protocol,e.feedOptions);e={...e,feedOptions:o.options};let s=0;const L=e.catalog??J;const n=new g;const O=e.policy??{};let a=[];const N=new Set;const w=new ee;const c=new te;let p;let x=false;let u=false;const v=new Set;let y=false;let f=0;let k=0;let b={};let S={};M(e.endpoint);const B=(t,r)=>t==="openai"?le(r):se(r);let R=null;if(!e.provider&&e.fallback){const t=e.fallback;M(t.endpoint);const r={...e,endpoint:t.endpoint,model:t.model,feedOptions:G(t.protocol).options};R=ae({provider:B(e.protocol,e),model:e.model},{provider:B(t.protocol,r),model:t.model},h=>e.onModelSwitch?.(h==="second"?"fallback":"primary"))}const z=e.provider??R??B(e.protocol,e);let d=e.availableActions;let i=Object.keys(d);const l={...O};function $(){for(const t of Object.keys(l))delete l[t];Object.assign(l,O);if(u){l.requireApproval=[];l.requireApprovalFor=[]}if(y)l.readOnly=true}function D(){return l}function P(){if(e.system!==void 0){p=e.system;return}p=Z({catalog:L,context:{...e.context,digest:{...b,...e.context?.digest}},isRelease:e.isRelease,readOnly:l.readOnly??false,readOnlySource:O.readOnly?"app":y?"device":void 0,requireApproval:ne(l),approvalsBypassed:u,appName:e.appName,platform:e.platform,availableToolIds:i})}async function j(){if(x)return;x=true;b={};try{b=await Q({dispatch:e.dispatch,readSnapshot:e.readSnapshot,availableToolIds:i,availableActions:d})}catch{}S={};for(const t of b.zustandStores??[]){const r=t;if(r?.persistsTo&&r.name)S[r.persistsTo]=r.name}P()}return{ledger:n,evidence:w,calibration:c,trustedActions:()=>[...v],untrust:t=>{v.delete(t)},get messages(){return a},prime:j,setAvailableActions(t){d=t;i=Object.keys(t)},setApprovalBypass(t){if(u===t)return;u=t;$();if(p)P()},setReadOnly(t){if(y===t)return;y=t;$();if(p)P()},restore(t){if(a.length>0)return;const r=I(resumableHistory(t),c.charsPerToken,n.liveCallIds());a=r.messages;f=r.droppedRounds},async*send(t,r){const h=k;await j();let T;try{T=await W({dispatch:e.dispatch,readSnapshot:e.readSnapshot,availableToolIds:i,availableActions:d})}catch{T=void 0}if(h!==k){yield{type:"done",stopReason:"superseded"};return}const E=Y(T,n.list().map(m=>({label:`${m.toolId}.${m.action}${m.effect.label?` \u2014 ${m.effect.label}`:""}`,undone:m.undoneAt!==void 0})));const K={role:"user",text:t,...o.name==="claude"?{turnId:`turn-${++s}`}:{},...o.options.liveBlock&&o.options.liveBlock!=="system-tail"?{liveBlock:{placement:o.options.liveBlock,text:E}}:{}};const C=a[a.length-1];const U=C?.role==="user"&&(C.systemNotice||C.liveBlock?.placement==="system-msg")?[{role:"assistant",text:"[Buoy: The prior turn stopped before an answer.]"}]:[];const q=I([...a,...U,K],c.charsPerToken,n.liveCallIds());const V=q.messages;const F=q.droppedRounds+f;f=0;if(F>0)yield{type:"history-trimmed",droppedRounds:F,droppedPinned:q.droppedPinned};const H=X({provider:z,catalog:L,messages:V,system:p,systemVolatile:o.options.liveBlock&&o.options.liveBlock!=="system-tail"?void 0:E,feedOptions:o.options,model:e.model,maxTokens:o.options.maxTokens??e.maxTokens??4096,dispatch:e.dispatch,readSnapshot:e.readSnapshot,storeKeyOwners:S,ledger:n,policy:D(),isRelease:e.isRelease,inApp:e.inApp,availableToolIds:i,availableActions:d,requestApproval:e.requestApproval,seenUrls:N,evidence:w,calibration:c,trusted:v,procedures:_(e.context?.procedures,i),signal:r});let A=await H.next();while(!A.done){yield A.value;A=await H.next()}if(h===k)a=A.value},reset(){k+=1;R?.reset();a=[];f=0;n.clear();N.clear();w.clear();v.clear();x=false}}}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* GENERATED by scripts/gen-agent-catalog.mjs — do not edit.
|
|
3
3
|
* Source: packages/agent-core/src/catalog/catalog.source.json
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* 35 Buoy tools, 309 actions.
|
|
6
6
|
*/
|
|
7
7
|
import type { ToolDescriptor } from "../types";
|
|
8
8
|
export declare const CATALOG: ToolDescriptor[];
|
|
9
|
-
export declare const CATALOG_TOOL_COUNT =
|
|
10
|
-
export declare const CATALOG_ACTION_COUNT =
|
|
9
|
+
export declare const CATALOG_TOOL_COUNT = 35;
|
|
10
|
+
export declare const CATALOG_ACTION_COUNT = 309;
|
|
11
11
|
//# sourceMappingURL=catalog.g.d.ts.map
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* The catalog's tool ids and action names as types, so a wrong name fails
|
|
6
6
|
* at compile time. `catalog.g.ts` carries the data.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* 35 Buoy tools, 309 actions.
|
|
9
9
|
*/
|
|
10
|
-
export type CatalogToolId = "env" | "console" | "sentry" | "jotai" | "route-events" | "debug-borders" | "zustand" | "redux" | "impersonate" | "query" | "events" | "network" | "js-top" | "app" | "time-machine" | "clock" | "lifecycle" | "location" | "permissions" | "storage" | "highlight-updates" | "scenarios" | "perf-monitor" | "assets" | "tv-remote" | "focus-inspector" | "images" | "ask-buoy" | "push-notifications" | "image-overlay" | "three";
|
|
10
|
+
export type CatalogToolId = "env" | "console" | "sentry" | "jotai" | "route-events" | "debug-borders" | "zustand" | "redux" | "impersonate" | "query" | "events" | "network" | "sockets" | "js-top" | "app" | "time-machine" | "clock" | "lifecycle" | "location" | "permissions" | "storage" | "highlight-updates" | "scenarios" | "perf-monitor" | "assets" | "tv-remote" | "focus-inspector" | "images" | "ask-buoy" | "push-notifications" | "image-overlay" | "memory-leaks" | "ota-update-inspector" | "three" | "bug-links";
|
|
11
11
|
export interface CatalogActionMap {
|
|
12
12
|
"env": "getSnapshot";
|
|
13
13
|
"console": "getSnapshot" | "clearEntries";
|
|
@@ -21,6 +21,7 @@ export interface CatalogActionMap {
|
|
|
21
21
|
"query": "listQueries" | "getQueryData" | "refetch" | "invalidate" | "reset" | "remove" | "setQueryData" | "triggerError" | "restoreError" | "triggerLoading" | "restoreLoading" | "clearQueryCache" | "clearMutationCache" | "setOnline";
|
|
22
22
|
"events": "exportEvents" | "setEnabledSources" | "clearEvents";
|
|
23
23
|
"network": "getSnapshot" | "getCaptureStatus" | "getEventBody" | "setPinned" | "setSaved" | "removeSavedRecord" | "clearSavedRequests" | "clearPinnedRequests" | "clearEvents" | "listOverrideRules" | "getOverrideRuleBody" | "debugOverrides" | "upsertOverrideRule" | "setOverrideRuleEnabled" | "setOverridesEnabled" | "deleteOverrideRule" | "clearOverrideRules" | "getNetworkConditions" | "setNetworkConditions";
|
|
24
|
+
"sockets": "query" | "getFrame" | "act";
|
|
24
25
|
"js-top": "sample" | "getOriginDetail" | "setEnabled" | "pause" | "resume" | "clear";
|
|
25
26
|
"app": "ping" | "reloadApp";
|
|
26
27
|
"time-machine": "list" | "capture" | "captureBaseline" | "wipeAll" | "restore" | "preview" | "inspect" | "delete" | "rename" | "duplicate" | "setExclusions" | "setScope" | "setRestoreRoute";
|
|
@@ -39,7 +40,10 @@ export interface CatalogActionMap {
|
|
|
39
40
|
"ask-buoy": "listChanges" | "undoChange" | "undoAll" | "retrieve" | "openProcedure";
|
|
40
41
|
"push-notifications": "getSnapshot" | "getCapabilities" | "getEvent" | "getPermissions" | "listPresented" | "refreshToken" | "setCaptureSession" | "clearCapturedEvents" | "scheduleLocal";
|
|
41
42
|
"image-overlay": "getSnapshot" | "listTargets" | "selectTarget" | "loadImage" | "setSettings" | "fitToScreen" | "resetSettings" | "remove";
|
|
43
|
+
"memory-leaks": "startCheck" | "startWatch" | "finishWatch" | "stopCheck" | "getReport" | "clearReports";
|
|
44
|
+
"ota-update-inspector": "getState" | "check" | "fetch" | "reload" | "setHeaders" | "setURL" | "setExpected";
|
|
42
45
|
"three": "getScene" | "getStats" | "action";
|
|
46
|
+
"bug-links": "getState" | "report" | "capture" | "load" | "loadAgain" | "undo" | "end" | "leaveSandbox" | "listLinks" | "retry" | "addNote" | "deleteLink" | "setServer";
|
|
43
47
|
}
|
|
44
48
|
export type CatalogAction<T extends CatalogToolId> = CatalogActionMap[T];
|
|
45
49
|
/** Action names per tool — the runtime mirror of {@link CatalogActionMap}. */
|
|
@@ -212,8 +212,14 @@ export declare class EffectLedger {
|
|
|
212
212
|
*/
|
|
213
213
|
noteExternalRevert(toolId: string, action: string, params: Record<string, unknown>): boolean;
|
|
214
214
|
private emit;
|
|
215
|
-
/**
|
|
216
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Undo one entry. Returns an error string, or undefined on success.
|
|
217
|
+
* `refetch: false` is for revertAll, which refetches once after every
|
|
218
|
+
* override is gone instead of once per override.
|
|
219
|
+
*/
|
|
220
|
+
revertOne(entry: LedgerEntry, dispatch: DispatchFn, { refetch }?: {
|
|
221
|
+
refetch?: boolean | undefined;
|
|
222
|
+
}): Promise<string | undefined>;
|
|
217
223
|
/** Undo everything still outstanding, newest first. */
|
|
218
224
|
revertAll(dispatch: DispatchFn): Promise<RevertOutcome>;
|
|
219
225
|
}
|
|
@@ -229,6 +229,11 @@ export interface RunTurnInput {
|
|
|
229
229
|
ledger: EffectLedger;
|
|
230
230
|
policy: AskBuoyPolicy;
|
|
231
231
|
isRelease: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* The engine runs inside the app it drives (Ask Buoy's sheet), so a relaunch
|
|
234
|
+
* reloads the engine too. See `realmWillDie`.
|
|
235
|
+
*/
|
|
236
|
+
inApp?: boolean;
|
|
232
237
|
/** Live tool ids from `listToolActions()`, so absent tools are never offered. */
|
|
233
238
|
availableToolIds?: string[];
|
|
234
239
|
availableActions?: Record<string, string[]>;
|
|
@@ -24,6 +24,8 @@ export interface AskBuoySessionConfig extends ProviderConfig {
|
|
|
24
24
|
context?: ContextPack;
|
|
25
25
|
/** `__DEV__ === false` for this bundle. */
|
|
26
26
|
isRelease: boolean;
|
|
27
|
+
/** The session runs inside the app it drives. See RunTurnInput.inApp. */
|
|
28
|
+
inApp?: boolean;
|
|
27
29
|
appName?: string;
|
|
28
30
|
platform?: string;
|
|
29
31
|
/** Override the built-in catalog. Tests and the desktop port use this. */
|