agentfootprint 9.68.0 → 9.70.0
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/CLAUDE.md +2 -0
- package/ai-instructions/setup.sh +0 -0
- package/bin/agentfootprint-index.mjs +0 -0
- package/bin/agentfootprint-lint-tools.mjs +0 -0
- package/canonical-notes.json +16 -0
- package/dist/adapters/browser/agentcore.js +203 -0
- package/dist/adapters/browser/agentcore.js.map +1 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/artifacts/placement.js +21 -7
- package/dist/artifacts/placement.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +7 -1
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/tools.js +32 -1
- package/dist/core/tools.js.map +1 -1
- package/dist/doors/providers.js +9 -3
- package/dist/doors/providers.js.map +1 -1
- package/dist/esm/adapters/browser/agentcore.d.ts +141 -0
- package/dist/esm/adapters/browser/agentcore.js +199 -0
- package/dist/esm/adapters/browser/agentcore.js.map +1 -0
- package/dist/esm/adapters/types.d.ts +82 -0
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/artifacts/placement.d.ts +22 -7
- package/dist/esm/artifacts/placement.js +21 -7
- package/dist/esm/artifacts/placement.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +3 -2
- package/dist/esm/core/agent/stages/toolCalls.js +7 -1
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +3 -2
- package/dist/esm/core/tools.d.ts +55 -0
- package/dist/esm/core/tools.js +30 -0
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/doors/providers.d.ts +1 -0
- package/dist/esm/doors/providers.js +4 -0
- package/dist/esm/doors/providers.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/types.d.ts +2 -1
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/types/adapters/browser/agentcore.d.ts +142 -0
- package/dist/types/adapters/browser/agentcore.d.ts.map +1 -0
- package/dist/types/adapters/types.d.ts +82 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/artifacts/placement.d.ts +22 -7
- package/dist/types/artifacts/placement.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +3 -2
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +3 -2
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/tools.d.ts +55 -0
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/doors/providers.d.ts +1 -0
- package/dist/types/doors/providers.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +2 -1
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentCoreBrowser — AWS Bedrock AgentCore **Browser** as a {@link BrowserRunner}.
|
|
3
|
+
*
|
|
4
|
+
* A managed Chrome in AWS's account that an agent can drive, a person can watch
|
|
5
|
+
* live, and — the part this adapter exists for — a person can TAKE OVER
|
|
6
|
+
* mid-session and hand back.
|
|
7
|
+
*
|
|
8
|
+
* ── Two channels, and only one of them is here ───────────────────────────────
|
|
9
|
+
* A browser session has two doors, and confusing them wastes a day:
|
|
10
|
+
*
|
|
11
|
+
* 1. **The automation stream** — a CDP WebSocket. Navigate, find an element,
|
|
12
|
+
* fill a form: everything page-shaped happens here, driven by Playwright
|
|
13
|
+
* or another CDP client. This adapter hands you
|
|
14
|
+
* {@link BrowserSession.automationEndpoint} and stays out of the way. It
|
|
15
|
+
* does not depend on Playwright and does not drive the page for you.
|
|
16
|
+
* 2. **`InvokeBrowser`** — the data-plane operation this adapter calls. It is
|
|
17
|
+
* OS-LEVEL input ABOVE the page: mouse, keyboard, screenshots. Its action
|
|
18
|
+
* union, read off the SDK rather than remembered, is exactly
|
|
19
|
+
* `mouseClick | mouseMove | mouseDrag | mouseScroll | keyType | keyPress |
|
|
20
|
+
* keyShortcut | screenshot`. **There is no navigate action**, and a reader
|
|
21
|
+
* expecting one is looking at the wrong door.
|
|
22
|
+
*
|
|
23
|
+
* ── The takeover ─────────────────────────────────────────────────────────────
|
|
24
|
+
* `UpdateBrowserStream` with `automationStreamUpdate.streamStatus` set to
|
|
25
|
+
* `DISABLED` stops the automation channel and leaves the live-view user in
|
|
26
|
+
* control; `ENABLED` gives it back. That is `handControlTo('person' | 'agent')`
|
|
27
|
+
* here, and it composes with this library's check-in: the agent pauses, a
|
|
28
|
+
* person finishes the login, the agent resumes on the page they left — and both
|
|
29
|
+
* handovers are ordinary events in the trace.
|
|
30
|
+
*
|
|
31
|
+
* ── How this talks to the SDK (the 9.4.0 law) ────────────────────────────────
|
|
32
|
+
* Through `client.send(new SomeCommand(input))`, never a method on the client —
|
|
33
|
+
* a bare `@aws-sdk/client-*` Client carries `send` and `destroy` and nothing
|
|
34
|
+
* else. Every command name and request shape below was read off a real install
|
|
35
|
+
* of `@aws-sdk/client-bedrock-agentcore` **3.1118.0**, including the action
|
|
36
|
+
* union above and `ScreenshotResult`'s `{ status, error?, data? }`.
|
|
37
|
+
*
|
|
38
|
+
* ── One documented contradiction, left as AWS wrote it ───────────────────────
|
|
39
|
+
* The devguide says a session defaults to 15 minutes; `StartBrowserSession`'s
|
|
40
|
+
* API reference says 3600 seconds. This adapter sends nothing unless you pass
|
|
41
|
+
* `sessionTimeoutSeconds`, so the default is whatever the service applies —
|
|
42
|
+
* rather than this file picking a side in somebody else's disagreement.
|
|
43
|
+
*
|
|
44
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
|
|
45
|
+
* `start()` first runs, or never, if you inject `_client` / `_sdk`.
|
|
46
|
+
*/
|
|
47
|
+
import type { BrowserRunner } from '../types.js';
|
|
48
|
+
/** AWS's managed browser. A custom `CreateBrowser` resource id goes here instead. */
|
|
49
|
+
export declare const AWS_SYSTEM_BROWSER = "aws.browser.v1";
|
|
50
|
+
export interface AgentCoreBrowserOptions {
|
|
51
|
+
/** AWS region. Falls back to the SDK's own resolution when omitted. */
|
|
52
|
+
readonly region?: string;
|
|
53
|
+
/** Which browser resource. Default {@link AWS_SYSTEM_BROWSER}. */
|
|
54
|
+
readonly browserIdentifier?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Session lifetime in seconds. **Left unset by default on purpose** — AWS's
|
|
57
|
+
* own devguide (15 minutes) and API reference (3600 seconds) disagree, so
|
|
58
|
+
* sending nothing lets the service apply whichever it actually means.
|
|
59
|
+
*/
|
|
60
|
+
readonly sessionTimeoutSeconds?: number;
|
|
61
|
+
/** Viewport for the session, when you want one that is not the default. */
|
|
62
|
+
readonly viewport?: {
|
|
63
|
+
readonly width: number;
|
|
64
|
+
readonly height: number;
|
|
65
|
+
};
|
|
66
|
+
/** Stable runner id (default `'agentcore-browser'`). */
|
|
67
|
+
readonly id?: string;
|
|
68
|
+
/** Test seam — inject a client implementing {@link AgentCoreBrowserClientLike}. */
|
|
69
|
+
readonly _client?: AgentCoreBrowserClientLike;
|
|
70
|
+
/** @internal Test injection — the AWS SDK module. */
|
|
71
|
+
readonly _sdk?: BedrockAgentCoreBrowserSdkModule;
|
|
72
|
+
}
|
|
73
|
+
/** The operation-semantic surface this adapter calls. */
|
|
74
|
+
export interface AgentCoreBrowserClientLike {
|
|
75
|
+
startBrowserSession(input: {
|
|
76
|
+
readonly browserIdentifier: string;
|
|
77
|
+
readonly name?: string;
|
|
78
|
+
readonly sessionTimeoutSeconds?: number;
|
|
79
|
+
readonly viewPort?: {
|
|
80
|
+
readonly width: number;
|
|
81
|
+
readonly height: number;
|
|
82
|
+
};
|
|
83
|
+
}): Promise<{
|
|
84
|
+
readonly sessionId?: string;
|
|
85
|
+
readonly streams?: {
|
|
86
|
+
readonly automationStream?: {
|
|
87
|
+
readonly streamEndpoint?: string;
|
|
88
|
+
};
|
|
89
|
+
readonly liveViewStream?: {
|
|
90
|
+
readonly streamEndpoint?: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
invokeBrowser(input: {
|
|
95
|
+
readonly browserIdentifier: string;
|
|
96
|
+
readonly sessionId: string;
|
|
97
|
+
readonly action: Readonly<Record<string, unknown>>;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
readonly result?: Readonly<Record<string, unknown>>;
|
|
100
|
+
}>;
|
|
101
|
+
updateBrowserStream(input: {
|
|
102
|
+
readonly browserIdentifier: string;
|
|
103
|
+
readonly sessionId: string;
|
|
104
|
+
readonly streamUpdate: {
|
|
105
|
+
readonly automationStreamUpdate: {
|
|
106
|
+
readonly streamStatus: 'ENABLED' | 'DISABLED';
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
}): Promise<void>;
|
|
110
|
+
stopBrowserSession(input: {
|
|
111
|
+
readonly browserIdentifier: string;
|
|
112
|
+
readonly sessionId: string;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
/** The slice of `@aws-sdk/client-bedrock-agentcore` this shim touches. */
|
|
116
|
+
export interface BedrockAgentCoreBrowserSdkModule {
|
|
117
|
+
readonly BedrockAgentCoreClient?: new (config: {
|
|
118
|
+
region?: string;
|
|
119
|
+
}) => {
|
|
120
|
+
send(cmd: unknown): Promise<unknown>;
|
|
121
|
+
};
|
|
122
|
+
readonly StartBrowserSessionCommand?: new (input: unknown) => unknown;
|
|
123
|
+
readonly InvokeBrowserCommand?: new (input: unknown) => unknown;
|
|
124
|
+
readonly UpdateBrowserStreamCommand?: new (input: unknown) => unknown;
|
|
125
|
+
readonly StopBrowserSessionCommand?: new (input: unknown) => unknown;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Build a {@link BrowserRunner} backed by AgentCore Browser.
|
|
129
|
+
*
|
|
130
|
+
* @example A session, a person taking over, and the agent resuming
|
|
131
|
+
* const browser = agentCoreBrowser({ region: 'us-east-1' });
|
|
132
|
+
* const session = await browser.start({ key: toolSessionKey(ctx, 'run') });
|
|
133
|
+
*
|
|
134
|
+
* // Page work goes over CDP, not through this adapter:
|
|
135
|
+
* // const page = await chromium.connectOverCDP(session.automationEndpoint!)
|
|
136
|
+
*
|
|
137
|
+
* await session.handControlTo?.('person'); // they finish the login
|
|
138
|
+
* await session.handControlTo?.('agent'); // and the agent carries on
|
|
139
|
+
* await session.stop();
|
|
140
|
+
*/
|
|
141
|
+
export declare function agentCoreBrowser(options?: AgentCoreBrowserOptions): BrowserRunner;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentCoreBrowser — AWS Bedrock AgentCore **Browser** as a {@link BrowserRunner}.
|
|
3
|
+
*
|
|
4
|
+
* A managed Chrome in AWS's account that an agent can drive, a person can watch
|
|
5
|
+
* live, and — the part this adapter exists for — a person can TAKE OVER
|
|
6
|
+
* mid-session and hand back.
|
|
7
|
+
*
|
|
8
|
+
* ── Two channels, and only one of them is here ───────────────────────────────
|
|
9
|
+
* A browser session has two doors, and confusing them wastes a day:
|
|
10
|
+
*
|
|
11
|
+
* 1. **The automation stream** — a CDP WebSocket. Navigate, find an element,
|
|
12
|
+
* fill a form: everything page-shaped happens here, driven by Playwright
|
|
13
|
+
* or another CDP client. This adapter hands you
|
|
14
|
+
* {@link BrowserSession.automationEndpoint} and stays out of the way. It
|
|
15
|
+
* does not depend on Playwright and does not drive the page for you.
|
|
16
|
+
* 2. **`InvokeBrowser`** — the data-plane operation this adapter calls. It is
|
|
17
|
+
* OS-LEVEL input ABOVE the page: mouse, keyboard, screenshots. Its action
|
|
18
|
+
* union, read off the SDK rather than remembered, is exactly
|
|
19
|
+
* `mouseClick | mouseMove | mouseDrag | mouseScroll | keyType | keyPress |
|
|
20
|
+
* keyShortcut | screenshot`. **There is no navigate action**, and a reader
|
|
21
|
+
* expecting one is looking at the wrong door.
|
|
22
|
+
*
|
|
23
|
+
* ── The takeover ─────────────────────────────────────────────────────────────
|
|
24
|
+
* `UpdateBrowserStream` with `automationStreamUpdate.streamStatus` set to
|
|
25
|
+
* `DISABLED` stops the automation channel and leaves the live-view user in
|
|
26
|
+
* control; `ENABLED` gives it back. That is `handControlTo('person' | 'agent')`
|
|
27
|
+
* here, and it composes with this library's check-in: the agent pauses, a
|
|
28
|
+
* person finishes the login, the agent resumes on the page they left — and both
|
|
29
|
+
* handovers are ordinary events in the trace.
|
|
30
|
+
*
|
|
31
|
+
* ── How this talks to the SDK (the 9.4.0 law) ────────────────────────────────
|
|
32
|
+
* Through `client.send(new SomeCommand(input))`, never a method on the client —
|
|
33
|
+
* a bare `@aws-sdk/client-*` Client carries `send` and `destroy` and nothing
|
|
34
|
+
* else. Every command name and request shape below was read off a real install
|
|
35
|
+
* of `@aws-sdk/client-bedrock-agentcore` **3.1118.0**, including the action
|
|
36
|
+
* union above and `ScreenshotResult`'s `{ status, error?, data? }`.
|
|
37
|
+
*
|
|
38
|
+
* ── One documented contradiction, left as AWS wrote it ───────────────────────
|
|
39
|
+
* The devguide says a session defaults to 15 minutes; `StartBrowserSession`'s
|
|
40
|
+
* API reference says 3600 seconds. This adapter sends nothing unless you pass
|
|
41
|
+
* `sessionTimeoutSeconds`, so the default is whatever the service applies —
|
|
42
|
+
* rather than this file picking a side in somebody else's disagreement.
|
|
43
|
+
*
|
|
44
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
|
|
45
|
+
* `start()` first runs, or never, if you inject `_client` / `_sdk`.
|
|
46
|
+
*/
|
|
47
|
+
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
48
|
+
/** AWS's managed browser. A custom `CreateBrowser` resource id goes here instead. */
|
|
49
|
+
export const AWS_SYSTEM_BROWSER = 'aws.browser.v1';
|
|
50
|
+
const BUTTONS = { left: 'LEFT', middle: 'MIDDLE', right: 'RIGHT' };
|
|
51
|
+
function createBrowserClient(options) {
|
|
52
|
+
let mod;
|
|
53
|
+
if (options._sdk) {
|
|
54
|
+
mod = options._sdk;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
try {
|
|
58
|
+
mod = lazyRequire('@aws-sdk/client-bedrock-agentcore');
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new Error('agentCoreBrowser requires the `@aws-sdk/client-bedrock-agentcore` peer dependency.\n' +
|
|
62
|
+
' Install: npm install @aws-sdk/client-bedrock-agentcore\n' +
|
|
63
|
+
' Or pass `_client` for a pre-built or mock client.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!mod.BedrockAgentCoreClient) {
|
|
67
|
+
throw new Error('agentCoreBrowser: `@aws-sdk/client-bedrock-agentcore` is installed but ' +
|
|
68
|
+
'`BedrockAgentCoreClient` was not found. Update the SDK.');
|
|
69
|
+
}
|
|
70
|
+
const sdk = new mod.BedrockAgentCoreClient({ ...(options.region && { region: options.region }) });
|
|
71
|
+
const send = async (Ctor, name, input) => {
|
|
72
|
+
if (!Ctor) {
|
|
73
|
+
throw new Error(`agentCoreBrowser: \`@aws-sdk/client-bedrock-agentcore\` is missing ${name}. ` +
|
|
74
|
+
'Upgrade the SDK, or pass `_client` with your own mapping.');
|
|
75
|
+
}
|
|
76
|
+
return sdk.send(new Ctor(input));
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
async startBrowserSession(input) {
|
|
80
|
+
return (await send(mod.StartBrowserSessionCommand, 'StartBrowserSessionCommand', input));
|
|
81
|
+
},
|
|
82
|
+
async invokeBrowser(input) {
|
|
83
|
+
return (await send(mod.InvokeBrowserCommand, 'InvokeBrowserCommand', input));
|
|
84
|
+
},
|
|
85
|
+
async updateBrowserStream(input) {
|
|
86
|
+
await send(mod.UpdateBrowserStreamCommand, 'UpdateBrowserStreamCommand', input);
|
|
87
|
+
},
|
|
88
|
+
async stopBrowserSession(input) {
|
|
89
|
+
await send(mod.StopBrowserSessionCommand, 'StopBrowserSessionCommand', input);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Build a {@link BrowserRunner} backed by AgentCore Browser.
|
|
95
|
+
*
|
|
96
|
+
* @example A session, a person taking over, and the agent resuming
|
|
97
|
+
* const browser = agentCoreBrowser({ region: 'us-east-1' });
|
|
98
|
+
* const session = await browser.start({ key: toolSessionKey(ctx, 'run') });
|
|
99
|
+
*
|
|
100
|
+
* // Page work goes over CDP, not through this adapter:
|
|
101
|
+
* // const page = await chromium.connectOverCDP(session.automationEndpoint!)
|
|
102
|
+
*
|
|
103
|
+
* await session.handControlTo?.('person'); // they finish the login
|
|
104
|
+
* await session.handControlTo?.('agent'); // and the agent carries on
|
|
105
|
+
* await session.stop();
|
|
106
|
+
*/
|
|
107
|
+
export function agentCoreBrowser(options = {}) {
|
|
108
|
+
const browserIdentifier = options.browserIdentifier ?? AWS_SYSTEM_BROWSER;
|
|
109
|
+
let client;
|
|
110
|
+
const getClient = () => {
|
|
111
|
+
client ??= options._client ?? createBrowserClient(options);
|
|
112
|
+
return client;
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
id: options.id ?? 'agentcore-browser',
|
|
116
|
+
async start(req) {
|
|
117
|
+
const c = getClient();
|
|
118
|
+
const started = await c.startBrowserSession({
|
|
119
|
+
browserIdentifier,
|
|
120
|
+
name: req.key,
|
|
121
|
+
...(options.sessionTimeoutSeconds !== undefined && {
|
|
122
|
+
sessionTimeoutSeconds: options.sessionTimeoutSeconds,
|
|
123
|
+
}),
|
|
124
|
+
...(options.viewport !== undefined && { viewPort: options.viewport }),
|
|
125
|
+
});
|
|
126
|
+
const sessionId = started.sessionId;
|
|
127
|
+
if (!sessionId) {
|
|
128
|
+
throw new Error('agentCoreBrowser: StartBrowserSession returned no sessionId, so there is no session ' +
|
|
129
|
+
'to drive. Check the browser identifier and the execution role.');
|
|
130
|
+
}
|
|
131
|
+
const act = async (action) => {
|
|
132
|
+
const answer = await c.invokeBrowser({ browserIdentifier, sessionId, action });
|
|
133
|
+
return answer.result;
|
|
134
|
+
};
|
|
135
|
+
const automationEndpoint = started.streams?.automationStream?.streamEndpoint;
|
|
136
|
+
const liveViewEndpoint = started.streams?.liveViewStream?.streamEndpoint;
|
|
137
|
+
const session = {
|
|
138
|
+
id: sessionId,
|
|
139
|
+
...(automationEndpoint !== undefined && { automationEndpoint }),
|
|
140
|
+
...(liveViewEndpoint !== undefined && { liveViewEndpoint }),
|
|
141
|
+
async click({ x, y, button, clicks }) {
|
|
142
|
+
await act({
|
|
143
|
+
mouseClick: {
|
|
144
|
+
x,
|
|
145
|
+
y,
|
|
146
|
+
...(button !== undefined && { button: BUTTONS[button] }),
|
|
147
|
+
...(clicks !== undefined && { clickCount: clicks }),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
async type(text) {
|
|
152
|
+
await act({ keyType: { text } });
|
|
153
|
+
},
|
|
154
|
+
async press({ key, times }) {
|
|
155
|
+
await act({ keyPress: { key, ...(times !== undefined && { presses: times }) } });
|
|
156
|
+
},
|
|
157
|
+
async screenshot() {
|
|
158
|
+
const result = await act({ screenshot: { format: 'PNG' } });
|
|
159
|
+
const shot = result?.screenshot;
|
|
160
|
+
if (!shot?.data) {
|
|
161
|
+
// The result member carries its own status and error, so a failed
|
|
162
|
+
// screenshot says what the service said rather than answering with
|
|
163
|
+
// an empty image that reads as a blank page.
|
|
164
|
+
throw new Error(`agentCoreBrowser: the screenshot did not produce image data` +
|
|
165
|
+
`${shot?.status ? ` (status ${shot.status})` : ''}` +
|
|
166
|
+
`${shot?.error ? `: ${shot.error}` : '.'}`);
|
|
167
|
+
}
|
|
168
|
+
return { data: shot.data, format: 'png' };
|
|
169
|
+
},
|
|
170
|
+
async handControlTo(driver) {
|
|
171
|
+
// The person takes over by DISABLING automation: the live-view user
|
|
172
|
+
// is already connected, and stopping the automation stream is what
|
|
173
|
+
// lets their input through.
|
|
174
|
+
await c.updateBrowserStream({
|
|
175
|
+
browserIdentifier,
|
|
176
|
+
sessionId,
|
|
177
|
+
streamUpdate: {
|
|
178
|
+
automationStreamUpdate: {
|
|
179
|
+
streamStatus: driver === 'person' ? 'DISABLED' : 'ENABLED',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
async stop() {
|
|
185
|
+
try {
|
|
186
|
+
await c.stopBrowserSession({ browserIdentifier, sessionId });
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// A managed session reaped by its own idle timeout is the ordinary
|
|
190
|
+
// case, and stopping one that is already gone is a no-op — the port
|
|
191
|
+
// says so, and a throw here would fail a teardown that succeeded.
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
return session;
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/browser/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAkEnD,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAE5E,SAAS,mBAAmB,CAAC,OAAgC;IAC3D,IAAI,GAAqC,CAAC;IAC1C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IACrB,CAA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ACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -811,6 +811,88 @@ export interface PricingTable {
|
|
|
811
811
|
*
|
|
812
812
|
* Implement it for your own backend; ship it to `codeRunnerTool({ runner })`.
|
|
813
813
|
*/
|
|
814
|
+
/** One screenshot a browser session took. */
|
|
815
|
+
export interface BrowserShot {
|
|
816
|
+
/** Image bytes. */
|
|
817
|
+
readonly data: Uint8Array;
|
|
818
|
+
/** Image format, lower-case (`'png'`). */
|
|
819
|
+
readonly format: string;
|
|
820
|
+
}
|
|
821
|
+
/** Who is driving a browser session right now. */
|
|
822
|
+
export type BrowserDriver = 'agent' | 'person';
|
|
823
|
+
/**
|
|
824
|
+
* A browser an agent can drive — the PORT (9.68.0).
|
|
825
|
+
*
|
|
826
|
+
* Deliberately small, and deliberately not a browser automation API. Page-level
|
|
827
|
+
* work (navigate, find an element, fill a form) is what CDP and Playwright
|
|
828
|
+
* already do far better than any interface here would; a session exposes
|
|
829
|
+
* {@link BrowserSession.automationEndpoint} so those attach directly. What this
|
|
830
|
+
* port carries is what an automation library CANNOT do on its own: open and
|
|
831
|
+
* release a managed session, reach the operating system above the page, and —
|
|
832
|
+
* the one that matters — hand the controls to a person and take them back.
|
|
833
|
+
*/
|
|
834
|
+
export interface BrowserRunner {
|
|
835
|
+
/** Stable id — reported on every tool-session event, so a row names its backend. */
|
|
836
|
+
readonly id: string;
|
|
837
|
+
/**
|
|
838
|
+
* Open a session.
|
|
839
|
+
*
|
|
840
|
+
* `key` is the ISOLATION key the caller derived. An adapter may use it to
|
|
841
|
+
* name the remote session; it must never widen it.
|
|
842
|
+
*/
|
|
843
|
+
start(req: {
|
|
844
|
+
readonly key: string;
|
|
845
|
+
readonly signal?: AbortSignal;
|
|
846
|
+
}): Promise<BrowserSession>;
|
|
847
|
+
}
|
|
848
|
+
/** One open browser session. */
|
|
849
|
+
export interface BrowserSession {
|
|
850
|
+
/** The backend's own id for this session. */
|
|
851
|
+
readonly id: string;
|
|
852
|
+
/**
|
|
853
|
+
* Where an automation client attaches — a CDP WebSocket, for Playwright and
|
|
854
|
+
* friends. Absent on a backend that offers no such channel.
|
|
855
|
+
*
|
|
856
|
+
* This library does not drive the page for you and does not depend on
|
|
857
|
+
* Playwright; it hands you the endpoint and stays out of the way.
|
|
858
|
+
*/
|
|
859
|
+
readonly automationEndpoint?: string;
|
|
860
|
+
/** Where a PERSON can watch this session, when the backend offers a view. */
|
|
861
|
+
readonly liveViewEndpoint?: string;
|
|
862
|
+
/** Click at a point, in the operating system rather than in the page. */
|
|
863
|
+
click(req: {
|
|
864
|
+
readonly x: number;
|
|
865
|
+
readonly y: number;
|
|
866
|
+
readonly button?: 'left' | 'middle' | 'right';
|
|
867
|
+
readonly clicks?: number;
|
|
868
|
+
}): Promise<void>;
|
|
869
|
+
/** Type text, as a keyboard would. */
|
|
870
|
+
type(text: string): Promise<void>;
|
|
871
|
+
/** Press a named key, optionally more than once. */
|
|
872
|
+
press(req: {
|
|
873
|
+
readonly key: string;
|
|
874
|
+
readonly times?: number;
|
|
875
|
+
}): Promise<void>;
|
|
876
|
+
/** Take a screenshot of the session as it is now. */
|
|
877
|
+
screenshot(): Promise<BrowserShot>;
|
|
878
|
+
/**
|
|
879
|
+
* Hand the controls to a person, or take them back (optional).
|
|
880
|
+
*
|
|
881
|
+
* This is the seam a human-in-the-loop browsing flow is built on: the agent
|
|
882
|
+
* stops driving, a person finishes the step that needed them — a login, a
|
|
883
|
+
* consent screen, a CAPTCHA — and the agent resumes on the page they left.
|
|
884
|
+
* Absent on a backend with no such notion; feature-detect before offering it.
|
|
885
|
+
*/
|
|
886
|
+
handControlTo?(driver: BrowserDriver): Promise<void>;
|
|
887
|
+
/**
|
|
888
|
+
* Release the session.
|
|
889
|
+
*
|
|
890
|
+
* Must tolerate a session the far side already reaped — an idle timeout is
|
|
891
|
+
* the reality on every managed backend, and a stop on a dead session is a
|
|
892
|
+
* no-op, not an error.
|
|
893
|
+
*/
|
|
894
|
+
stop(): Promise<void>;
|
|
895
|
+
}
|
|
814
896
|
export interface CodeRunner {
|
|
815
897
|
/** Stable id — reported on every `agentfootprint.tools.session_*` event so a
|
|
816
898
|
* row names its backend, not just its tool. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsHH;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB,MAAM,CAAC,MAAM,CAAC;IAC5E,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AAqsBH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAsC,EACtC,UAAgC;IAEhC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AACxD,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsHH;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB,MAAM,CAAC,MAAM,CAAC;IAC5E,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AAqsBH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAsC,EACtC,UAAgC;IAEhC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AACxD,CAAC;AAqID;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAgGpD;uDACuD;AACvD,MAAM,UAAU,kBAAkB,CAChC,OAAoB;IAEpB,OAAO,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,CAAC;AACnD,CAAC"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* An OPTIONAL operator dial on the agent's artifacts wiring:
|
|
5
5
|
* `Agent.create({ artifacts: { store, placement: { maxInlineChars: N } } })`.
|
|
6
6
|
* A tool result whose finalized text exceeds the threshold is checked into
|
|
7
|
-
* the store (kind `tool-result/<toolName
|
|
7
|
+
* the store (kind `tool-result/<toolName>`, or the tool's declared
|
|
8
|
+
* `resultKind` — see `placedResultKind`) and the model receives the claim
|
|
8
9
|
* ticket instead — a SHORT substitute naming ref + meta + how to consume it.
|
|
9
10
|
* The whole 879,073-token failure class, retired by configuration.
|
|
10
11
|
*
|
|
@@ -55,11 +56,24 @@ export interface ArtifactPlacement {
|
|
|
55
56
|
* — never at the first oversized result of the first run.
|
|
56
57
|
*/
|
|
57
58
|
export declare function assertArtifactPlacement(site: string, placement: ArtifactPlacement | undefined): void;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The kind vocabulary a placement mint declares — THE one decision, and the
|
|
61
|
+
* only place it is made.
|
|
62
|
+
*
|
|
63
|
+
* Default: `tool-result/<toolName>`. Honest — it says exactly what the payload
|
|
64
|
+
* is and which tool produced it — and it is what a `wants` declaration or a
|
|
65
|
+
* `present` call names to consume the placed result.
|
|
66
|
+
*
|
|
67
|
+
* `declared` is the tool's own `Tool.resultKind` (9.70.0), and when a tool
|
|
68
|
+
* declares one it WINS. The reason is the exact-match law on the consuming
|
|
69
|
+
* end: `wants` matches kinds by exact string equality — no wildcards, no
|
|
70
|
+
* hierarchy — so the framework's default vocabulary is a ticket a
|
|
71
|
+
* `wants: { dataset: 'dataset/rows' }` argument must refuse. Rather than
|
|
72
|
+
* loosen the matcher (a ticket would stop being a promise) or make consumers
|
|
73
|
+
* re-mint at the seam (the framework declining to carry its own ref), the
|
|
74
|
+
* MINT speaks the author's vocabulary. Absent → today's bytes exactly.
|
|
75
|
+
*/
|
|
76
|
+
export declare function placedResultKind(toolName: string, declared?: string): string;
|
|
63
77
|
/**
|
|
64
78
|
* The substitute the model reads in place of the payload — ONE shape, always
|
|
65
79
|
* the object (the `TruncatedToolResult` law: a consumer branches on
|
|
@@ -70,7 +84,8 @@ export interface PlacedToolResult {
|
|
|
70
84
|
/** Always `true`. The field a consumer branches on. */
|
|
71
85
|
readonly placed: true;
|
|
72
86
|
readonly ref: string;
|
|
73
|
-
/**
|
|
87
|
+
/** The minted kind — what a consumer names to want it. The tool's declared
|
|
88
|
+
* `Tool.resultKind` when it has one, `tool-result/<toolName>` otherwise. */
|
|
74
89
|
readonly kind: string;
|
|
75
90
|
readonly mediaType: string;
|
|
76
91
|
/** The stored payload's true size — the chars the window did NOT pay. */
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* An OPTIONAL operator dial on the agent's artifacts wiring:
|
|
5
5
|
* `Agent.create({ artifacts: { store, placement: { maxInlineChars: N } } })`.
|
|
6
6
|
* A tool result whose finalized text exceeds the threshold is checked into
|
|
7
|
-
* the store (kind `tool-result/<toolName
|
|
7
|
+
* the store (kind `tool-result/<toolName>`, or the tool's declared
|
|
8
|
+
* `resultKind` — see `placedResultKind`) and the model receives the claim
|
|
8
9
|
* ticket instead — a SHORT substitute naming ref + meta + how to consume it.
|
|
9
10
|
* The whole 879,073-token failure class, retired by configuration.
|
|
10
11
|
*
|
|
@@ -45,12 +46,25 @@ export function assertArtifactPlacement(site, placement) {
|
|
|
45
46
|
`measured and never placed, exactly as before.`);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
/**
|
|
50
|
+
* The kind vocabulary a placement mint declares — THE one decision, and the
|
|
51
|
+
* only place it is made.
|
|
52
|
+
*
|
|
53
|
+
* Default: `tool-result/<toolName>`. Honest — it says exactly what the payload
|
|
54
|
+
* is and which tool produced it — and it is what a `wants` declaration or a
|
|
55
|
+
* `present` call names to consume the placed result.
|
|
56
|
+
*
|
|
57
|
+
* `declared` is the tool's own `Tool.resultKind` (9.70.0), and when a tool
|
|
58
|
+
* declares one it WINS. The reason is the exact-match law on the consuming
|
|
59
|
+
* end: `wants` matches kinds by exact string equality — no wildcards, no
|
|
60
|
+
* hierarchy — so the framework's default vocabulary is a ticket a
|
|
61
|
+
* `wants: { dataset: 'dataset/rows' }` argument must refuse. Rather than
|
|
62
|
+
* loosen the matcher (a ticket would stop being a promise) or make consumers
|
|
63
|
+
* re-mint at the seam (the framework declining to carry its own ref), the
|
|
64
|
+
* MINT speaks the author's vocabulary. Absent → today's bytes exactly.
|
|
65
|
+
*/
|
|
66
|
+
export function placedResultKind(toolName, declared) {
|
|
67
|
+
return declared ?? `tool-result/${toolName}`;
|
|
54
68
|
}
|
|
55
69
|
/** Type guard for consumers reading `tool_end.result` or a tool message. */
|
|
56
70
|
export function isPlacedToolResult(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../../src/artifacts/placement.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../../src/artifacts/placement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAyBH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAY,EACZ,SAAwC;IAExC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,K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When set
|
|
104
104
|
* (only ever beside `artifactStore`; the Agent option's shape enforces it),
|
|
105
105
|
* every finalized tool result on every dispatch path is measured, and one
|
|
106
|
-
* whose text exceeds `maxInlineChars` is checked into the store (
|
|
107
|
-
* `tool-result/<toolName>`
|
|
106
|
+
* whose text exceeds `maxInlineChars` is checked into the store (under the
|
|
107
|
+
* tool's declared `resultKind`, or `tool-result/<toolName>` when it
|
|
108
|
+
* declares none) with the model reading the claim ticket
|
|
108
109
|
* instead. Judged AFTER the tool's own `resultCeiling` and the after-tool
|
|
109
110
|
* chain, BEFORE the `maxToolResultChars` truncation net. Undefined — the
|
|
110
111
|
* default — and results are never measured against it (zero-cost).
|
|
@@ -1155,7 +1155,13 @@ export function buildToolCallsHandler(deps) {
|
|
|
1155
1155
|
// `mediaType` states what that text is: a JSON serialization when the
|
|
1156
1156
|
// tool returned a value, plain text when it returned a string.
|
|
1157
1157
|
meta = await bound.artifacts.put({
|
|
1158
|
-
|
|
1158
|
+
// The tool's own `resultKind` when it declared one (9.70.0), the
|
|
1159
|
+
// framework's `tool-result/<name>` when it did not. Resolved HERE
|
|
1160
|
+
// rather than threaded through the five dispatch doors: `lookupTool`
|
|
1161
|
+
// is the closure's one resolver (registry + this iteration's cached
|
|
1162
|
+
// provider list), so a sixth door added later cannot forget to carry
|
|
1163
|
+
// the declaration — the `capResults` landmine, avoided by shape.
|
|
1164
|
+
kind: placedResultKind(call.toolName, lookupTool(call.toolName)?.resultKind),
|
|
1159
1165
|
mediaType: typeof values.modelResult === 'string' ? 'text/plain' : 'application/json',
|
|
1160
1166
|
data: text,
|
|
1161
1167
|
label: `${call.toolName} result`,
|