@autopilot-agent/core 0.3.0 → 0.4.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/README.md +6 -2
- package/dist/experimental/index.js +147 -52
- package/dist/experimental/index.mjs +147 -52
- package/dist/index.d.ts +7 -2
- package/dist/index.js +278 -173
- package/dist/index.mjs +279 -174
- package/dist/internal/agent-runtime.d.ts +8 -0
- package/dist/internal/kernel/run-context.d.ts +2 -0
- package/dist/internal/kernel/turn-usage.d.ts +1 -0
- package/dist/internal/lib/llm.d.ts +1 -0
- package/dist/internal/lib/llm.js +1 -1
- package/dist/internal/tools/builtins/browser-tool.d.ts +13 -0
- package/dist/internal/tools/builtins/static-preview.d.ts +1 -1
- package/dist/internal/tools/builtins/thread-tools.d.ts +1 -1
- package/dist/internal/tools/permissions/command-policy.d.ts +2 -0
- package/dist/internal/tools/policy-engine.d.ts +1 -0
- package/dist/internal/tools/types.d.ts +3 -0
- package/dist/internal/types/agent-message.d.ts +1 -1
- package/dist/internal/types/index.d.ts +1 -1
- package/dist/runtime/application/runtime-facts.d.ts +54 -0
- package/dist/runtime/application/session-service.d.ts +1 -0
- package/dist/runtime/application/turn/turn-capability-ceiling.d.ts +2 -0
- package/dist/runtime/application/turn/turn-recovery-service.d.ts +2 -0
- package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -0
- package/dist/runtime/domain/frozen-run-config.d.ts +1 -0
- package/dist/runtime/domain/index.d.ts +9 -0
- package/dist/runtime/domain/model-ref.d.ts +1 -1
- package/dist/runtime/domain/turn.d.ts +8 -0
- package/dist/runtime/protocol/browser-capability.d.ts +81 -0
- package/dist/runtime/protocol/browser-operation.d.ts +89 -0
- package/dist/runtime/protocol/frozen-run-config-view.d.ts +2 -1
- package/dist/runtime/protocol/index.d.ts +2 -1
- package/dist/runtime/protocol/run-config.d.ts +12 -0
- package/dist/runtime/protocol/web-capability.d.ts +5 -1
- package/dist/runtime/provider/api-protocol.d.ts +16 -2
- package/dist/runtime/provider/compatibility-presets.d.ts +19 -0
- package/dist/runtime/provider/frozen-provider-config.d.ts +3 -1
- package/dist/runtime/provider/index.d.ts +3 -1
- package/dist/runtime/provider/model-capability-catalog.d.ts +5 -0
- package/dist/runtime/provider/model-sample-resolver.d.ts +3 -2
- package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +3 -0
- package/dist/runtime/provider/openai-responses-adapter.d.ts +22 -0
- package/dist/runtime/public/agent-runtime.d.ts +1 -0
- package/package.json +1 -3
|
@@ -22,6 +22,7 @@ import type { CompletionPolicy } from "./kernel/completion-policy";
|
|
|
22
22
|
import { type ModelBehaviorProfile } from "../runtime/provider/model-behavior-profile";
|
|
23
23
|
import type { McpCapability } from "../runtime/protocol";
|
|
24
24
|
import type { CredentialStore, FileMutationStore } from "../runtime/ports";
|
|
25
|
+
import type { BrowserBinding, BrowserCapability } from "../runtime/protocol/browser-capability";
|
|
25
26
|
import type { WorkPreviewCapability } from "../runtime/protocol/work-preview-capability";
|
|
26
27
|
import type { AgentThreadsCapability } from "../runtime/application/thread-tool-binding";
|
|
27
28
|
import type { JobService } from "../runtime/application/job-service";
|
|
@@ -39,6 +40,8 @@ export interface RagCapability {
|
|
|
39
40
|
}
|
|
40
41
|
export interface AgentOptions {
|
|
41
42
|
capabilityCeiling?: CapabilityCeiling;
|
|
43
|
+
hostToolAdmission?: (toolName: string) => Promise<void>;
|
|
44
|
+
hostTools?: import("./tools/types").AgentToolDefinition<any, any>[];
|
|
42
45
|
chatCapability?: ChatCapability;
|
|
43
46
|
chatAttachmentGrants?: readonly ChatAttachmentGrant[];
|
|
44
47
|
sessionImageStore?: import("../runtime/ports/session-image-store").SessionImageStore;
|
|
@@ -50,6 +53,8 @@ export interface AgentOptions {
|
|
|
50
53
|
rag?: RagCapability;
|
|
51
54
|
web?: WebCapability;
|
|
52
55
|
workPreview?: WorkPreviewCapability;
|
|
56
|
+
browser?: BrowserCapability;
|
|
57
|
+
browserBinding?: BrowserBinding;
|
|
53
58
|
threads?: AgentThreadsCapability;
|
|
54
59
|
databaseSearch?: DatabaseSearchCapability;
|
|
55
60
|
focusedPdfFileName?: string;
|
|
@@ -213,6 +218,8 @@ export interface AgentCheckpoint {
|
|
|
213
218
|
totalTokens: number;
|
|
214
219
|
inputTokens?: number;
|
|
215
220
|
outputTokens?: number;
|
|
221
|
+
reasoningTokens?: number;
|
|
222
|
+
reasoningReportedOutputTokens?: number;
|
|
216
223
|
updatedAt?: number;
|
|
217
224
|
executionSegmentVersion?: 1;
|
|
218
225
|
};
|
|
@@ -243,6 +250,7 @@ interface InternalAgentRunInput {
|
|
|
243
250
|
decision: ToolApprovalDecision;
|
|
244
251
|
};
|
|
245
252
|
reissueApproval?: boolean;
|
|
253
|
+
revalidateApproval?: boolean;
|
|
246
254
|
userQuestion?: {
|
|
247
255
|
requestId: string;
|
|
248
256
|
answer: import("../runtime/domain").UserQuestionAnswer;
|
|
@@ -58,6 +58,7 @@ export interface PermissionContext {
|
|
|
58
58
|
export interface RunContext {
|
|
59
59
|
sessionImageStore?: import("../../runtime/ports/session-image-store").SessionImageStore;
|
|
60
60
|
supportsImageInput?: boolean;
|
|
61
|
+
hostToolAdmission?: (tool: import("../tools/types").AgentToolDefinition<any, any>) => Promise<void>;
|
|
61
62
|
hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
|
|
62
63
|
capabilityCeiling?: import("../../runtime/domain/product-mode").CapabilityCeiling;
|
|
63
64
|
chat?: import("../tools/chat-tool-runtime").ChatToolRuntime;
|
|
@@ -97,6 +98,7 @@ export interface RunContext {
|
|
|
97
98
|
decision: ToolApprovalDecision;
|
|
98
99
|
};
|
|
99
100
|
reissueApproval?: boolean;
|
|
101
|
+
revalidateApproval?: boolean;
|
|
100
102
|
userQuestion?: {
|
|
101
103
|
requestId: string;
|
|
102
104
|
answer: import("../../runtime/domain").UserQuestionAnswer;
|
package/dist/internal/lib/llm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var V=(n,e)=>{for(var o in e)w(n,o,{get:e[o],enumerable:!0})},$=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!D.call(n,t)&&t!==o&&w(n,t,{get:()=>e[t],enumerable:!(s=v(e,t))||s.enumerable});return n};var j=n=>$(w({},"__esModule",{value:!0}),n);var F={};V(F,{AgentSampleError:()=>T,askLLM:()=>K,askLLMStream:()=>Y,askLLMStreamWithImages:()=>J,askLLMWithImages:()=>U,askLoopLLM:()=>B,chatCompletion:()=>
|
|
1
|
+
"use strict";var w=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var V=(n,e)=>{for(var o in e)w(n,o,{get:e[o],enumerable:!0})},$=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!D.call(n,t)&&t!==o&&w(n,t,{get:()=>e[t],enumerable:!(s=v(e,t))||s.enumerable});return n};var j=n=>$(w({},"__esModule",{value:!0}),n);var F={};V(F,{AgentSampleError:()=>T,askLLM:()=>K,askLLMStream:()=>Y,askLLMStreamWithImages:()=>J,askLLMWithImages:()=>U,askLoopLLM:()=>B,chatCompletion:()=>C});module.exports=j(F);var y=process.env.LLM_BASE_URL||"https://api.deepseek.com",u=process.env.LLM_API_KEY||"",M=process.env.LLM_MODEL||"deepseek-v4-flash",I=process.env.LOOP_LLM_BASE_URL||"",S=process.env.LOOP_LLM_API_KEY||"",b=process.env.LOOP_LLM_MODEL||"",W=Number(process.env.LOOP_LLM_MAX_TOKENS)||8192;var T=class extends Error{constructor(o,s,t,p,L,c,i){super(o);this.code=s;this.argBytes=t;this.providerHttpStatus=p;this.providerFailureReason=L;this.providerFailureDetail=c;this.retryAfterMs=i;this.name="AgentSampleError"}};async function C(n,e={}){if(!u)throw new Error("LLM_API_KEY \u672A\u914D\u7F6E\u3002\u8BF7\u5728\u9879\u76EE\u6839 .env \u6587\u4EF6\u4E2D\u8BBE\u7F6E LLM_API_KEY=\u4F60\u7684key");let{temperature:o=.3,maxTokens:s=1024,thinking:t,reasoningEffort:p,signal:L}=e,c={model:M,messages:n,temperature:o,max_tokens:s};t&&(c.thinking={type:t}),p&&(c.reasoning_effort=p);let i=await fetch(`${y}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(c),signal:L});if(!i.ok){let a=await i.text().catch(()=>"");throw new Error(`LLM API \u8C03\u7528\u5931\u8D25 (${i.status}): ${a.slice(0,300)}`)}let r=await i.json(),g=r.choices?.[0]?.message?.content;if(!g)throw new Error("LLM API \u8FD4\u56DE\u7A7A\u5185\u5BB9");return{answer:g,model:r.model||M,usage:r.usage?{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens}:void 0}}async function K(n,e,o={},s){let t=[{role:"system",content:n}];s&&s.length>0&&t.push(...s),t.push({role:"user",content:e});let{answer:p}=await C(t,o);return p}async function B(n,e,o={}){if(!I||!S||!b)throw new Error("LOOP_LLM_BASE_URL\u3001LOOP_LLM_API_KEY \u6216 LOOP_LLM_MODEL \u672A\u914D\u7F6E");let{temperature:s=0,maxTokens:t=512,thinking:p,reasoningEffort:L,signal:c}=o,i={model:b,messages:[{role:"system",content:n},{role:"user",content:e}],temperature:s,max_tokens:t};p&&(i.thinking={type:p}),L&&(i.reasoning_effort=L);let r=await fetch(`${I}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify(i),signal:c});if(!r.ok){let l=await r.text().catch(()=>"");throw new Error(`LOOP_LLM API \u8C03\u7528\u5931\u8D25 (${r.status}): ${l.slice(0,300)}`)}let a=(await r.json()).choices?.[0]?.message?.content;if(!a)throw new Error("LOOP_LLM API \u8FD4\u56DE\u7A7A\u5185\u5BB9");return a}function x(n,e){return e.length===0?{role:"user",content:n}:{role:"user",content:[{type:"text",text:n},...e.map(o=>({type:"image_url",image_url:{url:o}}))]}}async function U(n,e,o,s={},t){if(!u)throw new Error("LLM_API_KEY \u672A\u914D\u7F6E\u3002\u8BF7\u5728\u9879\u76EE\u6839 .env \u6587\u4EF6\u4E2D\u8BBE\u7F6E LLM_API_KEY=\u4F60\u7684key");let{temperature:p=.3,maxTokens:L=1024,thinking:c,reasoningEffort:i,signal:r}=s,g=[{role:"system",content:n}];t&&t.length>0&&g.push(...t),g.push(x(e,o));let a={model:M,messages:g,temperature:p,max_tokens:L};c&&(a.thinking={type:c}),i&&(a.reasoning_effort=i);let l=await fetch(`${y}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(a),signal:r});if(!l.ok)throw new Error(`\u89C6\u89C9 LLM API \u8C03\u7528\u5931\u8D25 (${l.status})`);let m=(await l.json()).choices?.[0]?.message?.content;if(!m)throw new Error("\u89C6\u89C9 LLM API \u8FD4\u56DE\u7A7A\u5185\u5BB9");return m}async function*Y(n,e,o={},s){if(!u)throw new Error("LLM_API_KEY \u672A\u914D\u7F6E\u3002\u8BF7\u5728\u9879\u76EE\u6839 .env \u6587\u4EF6\u4E2D\u8BBE\u7F6E LLM_API_KEY=\u4F60\u7684key");let{temperature:t=.3,maxTokens:p=1024,thinking:L,reasoningEffort:c,signal:i}=o,r=[{role:"system",content:n}];s&&s.length>0&&r.push(...s),r.push({role:"user",content:e});let g={model:M,messages:r,temperature:t,max_tokens:p,stream:!0};L&&(g.thinking={type:L}),c&&(g.reasoning_effort=c);let a=await fetch(`${y}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(g),signal:i});if(!a.ok){let d=await a.text().catch(()=>"");throw new Error(`LLM API \u6D41\u5F0F\u8C03\u7528\u5931\u8D25 (${a.status}): ${d.slice(0,300)}`)}let l=a.body?.getReader();if(!l)throw new Error("LLM API \u6D41\u5F0F\u54CD\u5E94 body \u4E0D\u53EF\u8BFB");let f=new TextDecoder,m="";for(;;){let{done:d,value:k}=await l.read();if(d)break;m+=f.decode(k,{stream:!0});let E=m.split(`
|
|
2
2
|
`);m=E.pop()||"";for(let O of E){let h=O.trim();if(!h||!h.startsWith("data:"))continue;let _=h.slice(5).trim();if(_==="[DONE]")return;try{let P=JSON.parse(_).choices?.[0]?.delta?.content;P&&(yield P)}catch{}}}}async function*J(n,e,o,s={},t){if(!u)throw new Error("LLM_API_KEY \u672A\u914D\u7F6E\u3002\u8BF7\u5728\u9879\u76EE\u6839 .env \u6587\u4EF6\u4E2D\u8BBE\u7F6E LLM_API_KEY=\u4F60\u7684key");let{temperature:p=.3,maxTokens:L=1024,thinking:c,reasoningEffort:i,signal:r}=s,g=[{role:"system",content:n}];t&&t.length>0&&g.push(...t),g.push(x(e,o));let a={model:M,messages:g,temperature:p,max_tokens:L,stream:!0};c&&(a.thinking={type:c}),i&&(a.reasoning_effort=i);let l=await fetch(`${y}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(a),signal:r});if(!l.ok)throw new Error(`\u89C6\u89C9 LLM API \u6D41\u5F0F\u8C03\u7528\u5931\u8D25 (${l.status})`);let f=l.body?.getReader();if(!f)throw new Error("\u89C6\u89C9 LLM API \u6D41\u5F0F\u54CD\u5E94 body \u4E0D\u53EF\u8BFB");let m=new TextDecoder,d="";for(;;){let{done:k,value:E}=await f.read();if(k)break;d+=m.decode(E,{stream:!0});let O=d.split(`
|
|
3
3
|
`);d=O.pop()||"";for(let h of O){let _=h.trim();if(!_||!_.startsWith("data:"))continue;let A=_.slice(5).trim();if(A==="[DONE]")return;try{let R=JSON.parse(A).choices?.[0]?.delta?.content;R&&(yield R)}catch{}}}}0&&(module.exports={AgentSampleError,askLLM,askLLMStream,askLLMStreamWithImages,askLLMWithImages,askLoopLLM,chatCompletion});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JobService } from "../../../runtime/application/job-service";
|
|
2
|
+
export { browserOperationSchema } from "../../../runtime/protocol/browser-operation";
|
|
3
|
+
import type { AgentToolDefinition } from "../types";
|
|
4
|
+
import type { BrowserBinding, BrowserCapability, BrowserOperation } from "../../../runtime/protocol/browser-capability";
|
|
5
|
+
import type { SessionImageStore } from "../../../runtime/ports/session-image-store";
|
|
6
|
+
export declare function createBrowserTool(capability: BrowserCapability, binding: BrowserBinding, store?: SessionImageStore, preview?: {
|
|
7
|
+
jobs: JobService;
|
|
8
|
+
workspaceRoot: string;
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
}): AgentToolDefinition<BrowserOperation | {
|
|
11
|
+
type: "open";
|
|
12
|
+
staticPath: string;
|
|
13
|
+
}, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JobService } from "../../../runtime/application/job-service";
|
|
2
2
|
import type { ToolExecutionContext } from "../types";
|
|
3
|
-
export declare const STATIC_PREVIEW_SCRIPT
|
|
3
|
+
export declare const STATIC_PREVIEW_SCRIPT: string;
|
|
4
4
|
export declare function resolveStaticPreviewFile(workspaceRoot: string | undefined, staticPath: string): Promise<string>;
|
|
5
5
|
export declare function prepareStaticPreview(input: {
|
|
6
6
|
jobs: JobService;
|
|
@@ -18,7 +18,7 @@ export declare function createThreadTools(capability: AgentThreadsCapability): {
|
|
|
18
18
|
provider: string;
|
|
19
19
|
modelId: string;
|
|
20
20
|
} | undefined;
|
|
21
|
-
reasoningEffort?: "low" | "medium" | "high" | "max" | "none" | undefined;
|
|
21
|
+
reasoningEffort?: "low" | "medium" | "high" | "max" | "none" | "xhigh" | undefined;
|
|
22
22
|
}, {
|
|
23
23
|
threadId: string;
|
|
24
24
|
groupId: string;
|
|
@@ -4,11 +4,13 @@ export interface CommandRule {
|
|
|
4
4
|
decision: ToolPermissionDecision;
|
|
5
5
|
risk: CommandRisk;
|
|
6
6
|
reason: string;
|
|
7
|
+
requireSingleApproval?: true;
|
|
7
8
|
}
|
|
8
9
|
export interface CommandPolicyResult {
|
|
9
10
|
decision: ToolPermissionDecision;
|
|
10
11
|
risk: CommandRisk;
|
|
11
12
|
reason: string;
|
|
13
|
+
requireSingleApproval?: true;
|
|
12
14
|
}
|
|
13
15
|
export declare const defaultCommandRules: CommandRule[];
|
|
14
16
|
export declare function normalizeProgramName(program: string): string;
|
|
@@ -11,6 +11,7 @@ export interface PolicyEvaluationInput {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class PolicyEngine {
|
|
13
13
|
canUsePersistentGrant(context: ToolExecutionContext, facts: ToolActionFacts): boolean;
|
|
14
|
+
requiresSingleApproval(context: ToolExecutionContext, facts: ToolActionFacts): boolean;
|
|
14
15
|
evaluate(input: PolicyEvaluationInput): ToolPolicyResult;
|
|
15
16
|
private allowsAutoApprove;
|
|
16
17
|
}
|
|
@@ -250,6 +250,7 @@ export interface ToolActionFacts {
|
|
|
250
250
|
stableConstraint?: string;
|
|
251
251
|
hardDenyReason?: string;
|
|
252
252
|
requiresApproval?: boolean;
|
|
253
|
+
requireSingleApproval?: true;
|
|
253
254
|
externalMutation?: boolean;
|
|
254
255
|
externalTarget?: {
|
|
255
256
|
canonicalTarget: string;
|
|
@@ -291,6 +292,7 @@ export interface ToolExecutionContext {
|
|
|
291
292
|
taskId: string;
|
|
292
293
|
explicit: boolean;
|
|
293
294
|
};
|
|
295
|
+
hostToolAdmission?: (tool: AgentToolDefinition<any, any>) => Promise<void>;
|
|
294
296
|
hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
|
|
295
297
|
executionSessionId?: string;
|
|
296
298
|
externalExecutionAuthority?: ExternalExecutionAuthority;
|
|
@@ -301,6 +303,7 @@ export interface ToolExecutionContext {
|
|
|
301
303
|
workspaceTrusted?: boolean;
|
|
302
304
|
signal?: AbortSignal;
|
|
303
305
|
toolCallId?: string;
|
|
306
|
+
browserApprovalConsumed?: true;
|
|
304
307
|
webFetchRedirectsRemaining?: number;
|
|
305
308
|
fileMutations?: {
|
|
306
309
|
store: FileMutationStore;
|
|
@@ -32,7 +32,7 @@ export interface AgentMessage {
|
|
|
32
32
|
role: AgentMessageRole;
|
|
33
33
|
content: AgentContentBlock[];
|
|
34
34
|
adapterReplayState?: {
|
|
35
|
-
apiProtocol: "anthropic-messages" | "openai-chat-completions";
|
|
35
|
+
apiProtocol: "anthropic-messages" | "openai-chat-completions" | "openai-responses";
|
|
36
36
|
value: unknown;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -28,7 +28,7 @@ export interface ModelSampleOptions {
|
|
|
28
28
|
};
|
|
29
29
|
model?: string;
|
|
30
30
|
thinking?: "enabled" | "disabled" | "auto";
|
|
31
|
-
reasoningEffort?: "low" | "medium" | "high" | "max";
|
|
31
|
+
reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
32
32
|
temperature?: number;
|
|
33
33
|
topP?: number;
|
|
34
34
|
maxTokens?: number;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RuntimePorts } from "../ports";
|
|
2
|
+
import type { AgentEventEnvelope } from "../protocol";
|
|
3
|
+
export interface RuntimeFact {
|
|
4
|
+
protocol: 1;
|
|
5
|
+
source: "core";
|
|
6
|
+
eventId: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
turnId: string;
|
|
9
|
+
sequence: number;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
eventType: string;
|
|
12
|
+
payload: {
|
|
13
|
+
callId?: string;
|
|
14
|
+
requestId?: string;
|
|
15
|
+
approvalId?: string;
|
|
16
|
+
inputId?: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface RuntimeFactSnapshot {
|
|
21
|
+
protocol: 1;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
cursor?: string;
|
|
24
|
+
consistency: "overlap";
|
|
25
|
+
execution: null | {
|
|
26
|
+
turnId: string;
|
|
27
|
+
status: string;
|
|
28
|
+
execution: "active" | "inactive" | "unconfirmed" | "lost";
|
|
29
|
+
lastSeq: number;
|
|
30
|
+
result?: string;
|
|
31
|
+
waiting?: string;
|
|
32
|
+
interaction?: {
|
|
33
|
+
state: string;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
approvalId?: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare function projectRuntimeFact(envelope: AgentEventEnvelope): RuntimeFact | null;
|
|
40
|
+
export declare function createRuntimeFacts(ports: RuntimePorts): {
|
|
41
|
+
read: (input: {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
cursor?: string;
|
|
44
|
+
limit: number;
|
|
45
|
+
}) => Promise<{
|
|
46
|
+
items: RuntimeFact[];
|
|
47
|
+
cursor: string | undefined;
|
|
48
|
+
nextCursor: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
snapshot: (input: {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
}) => Promise<RuntimeFactSnapshot>;
|
|
53
|
+
};
|
|
54
|
+
export type RuntimeFacts = ReturnType<typeof createRuntimeFacts>;
|
|
@@ -2,6 +2,8 @@ import type { Session, FrozenRunConfig } from "../../domain";
|
|
|
2
2
|
import type { ChatCapability } from "../../protocol/chat-capability";
|
|
3
3
|
import type { RunConfig } from "../../protocol/run-config";
|
|
4
4
|
export interface TurnCapabilities extends RunConfig {
|
|
5
|
+
hostToolAdmission?: (toolName: string) => Promise<void>;
|
|
6
|
+
hostTools?: import("../../../internal/tools/types").AgentToolDefinition<any, any>[];
|
|
5
7
|
chatCapability?: ChatCapability;
|
|
6
8
|
}
|
|
7
9
|
export declare function resolveTurnCapabilities(input: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ContextUsageView } from "../../../internal/kernel/context-budget";
|
|
2
2
|
import { type TurnUsageSummaryView } from "../../../internal/kernel/turn-usage";
|
|
3
3
|
import type { AgentCheckpoint, AgentEventEnvelope, FrozenRunConfigView, PublicCheckpointView, RecoverableTurnView } from "../../protocol";
|
|
4
|
+
import { getAgentToolCalls, type AgentMessage } from "../../../internal/types/agent-message";
|
|
4
5
|
import type { Turn } from "../../domain";
|
|
5
6
|
import type { RuntimePorts } from "../../ports";
|
|
6
7
|
import type { TurnLeaseCoordinator } from "./turn-lease-coordinator";
|
|
@@ -44,4 +45,5 @@ export interface TurnRecoveryService {
|
|
|
44
45
|
}>;
|
|
45
46
|
getContinuation(sessionId: string, turnId: string | undefined): Promise<RecoverableContinuation>;
|
|
46
47
|
}
|
|
48
|
+
export declare function closeInterruptedToolCalls(messages: AgentMessage[], pendingCalls: ReturnType<typeof getAgentToolCalls>): AgentMessage[];
|
|
47
49
|
export declare function createTurnRecoveryService(ports: RuntimePorts, leaseCoordinator: TurnLeaseCoordinator): TurnRecoveryService;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentRuntime } from "../public";
|
|
2
2
|
import type { RuntimePorts } from "../ports";
|
|
3
3
|
import type { WorkspaceAdapter } from "../ports/workspace-adapter";
|
|
4
|
+
import type { BrowserCapability } from "../protocol/browser-capability";
|
|
4
5
|
import type { RunConfig, McpCapability, WebCapability, WorkPreviewCapability } from "../protocol";
|
|
5
6
|
import type { AgentContextSnapshot } from "../../internal/agent-context";
|
|
6
7
|
import type { AgentSkillsCapability } from "../../internal/tools/builtins/skill-tool";
|
|
@@ -10,6 +11,7 @@ import type { DatabaseSearchCapability } from "../../internal/database-search";
|
|
|
10
11
|
import type { SafeBootstrapConfig } from "./safe-bootstrap-config";
|
|
11
12
|
import type { WorkspaceTrustPolicy, WorkspaceTrustEntry } from "./workspace-trust-policy";
|
|
12
13
|
export interface CapabilityLoader {
|
|
14
|
+
loadBrowser?(workspaceRoot: string): Promise<BrowserCapability | undefined> | BrowserCapability | undefined;
|
|
13
15
|
loadProvider?(workspaceRoot: string): Promise<ModelSamplerFactory> | ModelSamplerFactory;
|
|
14
16
|
loadMcp?(workspaceRoot: string): Promise<McpCapability | undefined> | McpCapability | undefined;
|
|
15
17
|
loadWeb?(workspaceRoot: string): Promise<WebCapability | undefined> | WebCapability | undefined;
|
|
@@ -12,6 +12,7 @@ export interface FrozenRunConfig {
|
|
|
12
12
|
capabilityCeiling?: import("./product-mode").CapabilityCeiling;
|
|
13
13
|
chatAttachmentGrants?: readonly import("../protocol/chat-capability").ChatAttachmentGrant[];
|
|
14
14
|
workPreviewEnabled?: boolean;
|
|
15
|
+
browserEnabled?: boolean;
|
|
15
16
|
modelRef?: ModelRef;
|
|
16
17
|
reasoningProfile?: ReasoningProfile;
|
|
17
18
|
credentialRef?: CredentialRef;
|
|
@@ -22,6 +22,11 @@ export type SessionPersistenceMode = "durable" | "ephemeral";
|
|
|
22
22
|
export type { SessionPresentation, SessionPresentationCompaction, SessionPresentationMessage, SessionPresentationPinnedSkill, } from "./session-presentation";
|
|
23
23
|
export type SessionStatus = "idle" | "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "failed" | "completed";
|
|
24
24
|
export interface Session {
|
|
25
|
+
readonly managedExecution?: {
|
|
26
|
+
hostId: string;
|
|
27
|
+
requestId: string;
|
|
28
|
+
threadPolicy: "disabled";
|
|
29
|
+
};
|
|
25
30
|
readonly workContextVersion?: 1;
|
|
26
31
|
id: string;
|
|
27
32
|
readonly collaborationCreationId?: string;
|
|
@@ -38,6 +43,10 @@ export interface Session {
|
|
|
38
43
|
activeTurnId?: string;
|
|
39
44
|
title?: string;
|
|
40
45
|
defaultRunConfig?: import("./session-run-config").SessionRunConfig;
|
|
46
|
+
permissionSelection?: {
|
|
47
|
+
mode: import("../../internal/tools/types").ToolPermissionMode;
|
|
48
|
+
revision: string;
|
|
49
|
+
};
|
|
41
50
|
presentation?: import("./session-presentation").SessionPresentation;
|
|
42
51
|
createdAt: number;
|
|
43
52
|
updatedAt: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ReasoningEffort = "none" | "low" | "medium" | "high" | "max";
|
|
1
|
+
export type ReasoningEffort = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
2
2
|
export declare function parseReasoningEffort(value: unknown): ReasoningEffort | undefined;
|
|
3
3
|
export interface ModelRef {
|
|
4
4
|
provider: string;
|
|
@@ -6,6 +6,14 @@ export interface Turn {
|
|
|
6
6
|
sessionId: string;
|
|
7
7
|
status: TurnStatus;
|
|
8
8
|
frozenRunConfig: FrozenRunConfig;
|
|
9
|
+
permissionSelectionRevision?: string;
|
|
10
|
+
permissionRevisions?: Array<{
|
|
11
|
+
permissionMode: NonNullable<FrozenRunConfig["permissionMode"]>;
|
|
12
|
+
selectionRevision: string;
|
|
13
|
+
changedAt: number;
|
|
14
|
+
leaseId: string;
|
|
15
|
+
approvalCutoffSeq: number;
|
|
16
|
+
}>;
|
|
9
17
|
frozenProviderConfig?: FrozenProviderConfig;
|
|
10
18
|
todoChainId?: string;
|
|
11
19
|
startedAt: number;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type BrowserOperation = {
|
|
2
|
+
type: "list";
|
|
3
|
+
} | {
|
|
4
|
+
type: "downloads";
|
|
5
|
+
pageId: string;
|
|
6
|
+
revision: number;
|
|
7
|
+
} | {
|
|
8
|
+
type: "cancel-download";
|
|
9
|
+
pageId: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
id: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "wait";
|
|
14
|
+
pageId: string;
|
|
15
|
+
revision: number;
|
|
16
|
+
condition: "load";
|
|
17
|
+
timeout: number;
|
|
18
|
+
} | {
|
|
19
|
+
type: "open";
|
|
20
|
+
url: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "document";
|
|
23
|
+
path: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "navigate";
|
|
26
|
+
pageId: string;
|
|
27
|
+
url: string;
|
|
28
|
+
revision: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: "select" | "close" | "release" | "back" | "forward" | "reload" | "snapshot" | "screenshot";
|
|
31
|
+
pageId: string;
|
|
32
|
+
revision: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: "click";
|
|
35
|
+
pageId: string;
|
|
36
|
+
revision: number;
|
|
37
|
+
ref: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "fill" | "select-option";
|
|
40
|
+
pageId: string;
|
|
41
|
+
revision: number;
|
|
42
|
+
ref: string;
|
|
43
|
+
value: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "press";
|
|
46
|
+
pageId: string;
|
|
47
|
+
revision: number;
|
|
48
|
+
key: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "scroll";
|
|
51
|
+
pageId: string;
|
|
52
|
+
revision: number;
|
|
53
|
+
direction: "up" | "down" | "left" | "right";
|
|
54
|
+
amount: number;
|
|
55
|
+
} | {
|
|
56
|
+
type: "check";
|
|
57
|
+
pageId: string;
|
|
58
|
+
revision: number;
|
|
59
|
+
ref: string;
|
|
60
|
+
checked: boolean;
|
|
61
|
+
} | {
|
|
62
|
+
type: "dialog";
|
|
63
|
+
pageId: string;
|
|
64
|
+
revision: number;
|
|
65
|
+
accept: boolean;
|
|
66
|
+
text: string;
|
|
67
|
+
};
|
|
68
|
+
export interface BrowserBinding {
|
|
69
|
+
sessionId: string;
|
|
70
|
+
turnId: string;
|
|
71
|
+
}
|
|
72
|
+
export interface BrowserRequestAuthorization {
|
|
73
|
+
mode: "ask" | "auto_approve" | "full_access";
|
|
74
|
+
approvedOnce?: true;
|
|
75
|
+
}
|
|
76
|
+
export interface BrowserCapability {
|
|
77
|
+
confirmsDocument?: true;
|
|
78
|
+
managesApprovals?: true;
|
|
79
|
+
request(binding: BrowserBinding, callId: string, operation: BrowserOperation, signal?: AbortSignal, authorization?: BrowserRequestAuthorization): Promise<unknown>;
|
|
80
|
+
endTurn(binding: BrowserBinding): Promise<void>;
|
|
81
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BrowserOperation } from "./browser-capability";
|
|
3
|
+
export declare const browserOperationSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"list">;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
type: z.ZodLiteral<"open">;
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"document">;
|
|
10
|
+
path: z.ZodString;
|
|
11
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
12
|
+
pageId: z.ZodString;
|
|
13
|
+
revision: z.ZodNumber;
|
|
14
|
+
type: z.ZodLiteral<"downloads">;
|
|
15
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
pageId: z.ZodString;
|
|
18
|
+
revision: z.ZodNumber;
|
|
19
|
+
type: z.ZodLiteral<"cancel-download">;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
condition: z.ZodLiteral<"load">;
|
|
22
|
+
timeout: z.ZodNumber;
|
|
23
|
+
pageId: z.ZodString;
|
|
24
|
+
revision: z.ZodNumber;
|
|
25
|
+
type: z.ZodLiteral<"wait">;
|
|
26
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
pageId: z.ZodString;
|
|
29
|
+
revision: z.ZodNumber;
|
|
30
|
+
type: z.ZodLiteral<"navigate">;
|
|
31
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
32
|
+
pageId: z.ZodString;
|
|
33
|
+
revision: z.ZodNumber;
|
|
34
|
+
type: z.ZodEnum<{
|
|
35
|
+
select: "select";
|
|
36
|
+
close: "close";
|
|
37
|
+
release: "release";
|
|
38
|
+
back: "back";
|
|
39
|
+
forward: "forward";
|
|
40
|
+
reload: "reload";
|
|
41
|
+
snapshot: "snapshot";
|
|
42
|
+
screenshot: "screenshot";
|
|
43
|
+
}>;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
ref: z.ZodString;
|
|
46
|
+
pageId: z.ZodString;
|
|
47
|
+
revision: z.ZodNumber;
|
|
48
|
+
type: z.ZodLiteral<"click">;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
ref: z.ZodString;
|
|
51
|
+
value: z.ZodString;
|
|
52
|
+
pageId: z.ZodString;
|
|
53
|
+
revision: z.ZodNumber;
|
|
54
|
+
type: z.ZodEnum<{
|
|
55
|
+
fill: "fill";
|
|
56
|
+
"select-option": "select-option";
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
key: z.ZodString;
|
|
60
|
+
pageId: z.ZodString;
|
|
61
|
+
revision: z.ZodNumber;
|
|
62
|
+
type: z.ZodLiteral<"press">;
|
|
63
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
64
|
+
direction: z.ZodEnum<{
|
|
65
|
+
left: "left";
|
|
66
|
+
right: "right";
|
|
67
|
+
up: "up";
|
|
68
|
+
down: "down";
|
|
69
|
+
}>;
|
|
70
|
+
amount: z.ZodNumber;
|
|
71
|
+
pageId: z.ZodString;
|
|
72
|
+
revision: z.ZodNumber;
|
|
73
|
+
type: z.ZodLiteral<"scroll">;
|
|
74
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
75
|
+
ref: z.ZodString;
|
|
76
|
+
checked: z.ZodBoolean;
|
|
77
|
+
pageId: z.ZodString;
|
|
78
|
+
revision: z.ZodNumber;
|
|
79
|
+
type: z.ZodLiteral<"check">;
|
|
80
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
81
|
+
accept: z.ZodBoolean;
|
|
82
|
+
text: z.ZodString;
|
|
83
|
+
pageId: z.ZodString;
|
|
84
|
+
revision: z.ZodNumber;
|
|
85
|
+
type: z.ZodLiteral<"dialog">;
|
|
86
|
+
}, z.core.$strict>]>;
|
|
87
|
+
export declare function parseBrowserOperation(value: unknown): BrowserOperation;
|
|
88
|
+
export declare function isPublicBrowserUrl(value: string): boolean;
|
|
89
|
+
export declare function isPublicBrowserRead(operation: BrowserOperation, pageUrl?: string): boolean;
|
|
@@ -7,8 +7,9 @@ export interface FrozenRunConfigView {
|
|
|
7
7
|
reasoningProfile?: ReasoningProfile;
|
|
8
8
|
effectiveReasoning?: {
|
|
9
9
|
effort: ReasoningEffort;
|
|
10
|
-
source: "requested";
|
|
10
|
+
source: "requested" | "default";
|
|
11
11
|
};
|
|
12
12
|
permissionMode?: ToolPermissionMode;
|
|
13
|
+
executionPermissionMode?: ToolPermissionMode;
|
|
13
14
|
capabilityCeiling?: import("../domain/product-mode").CapabilityCeiling;
|
|
14
15
|
}
|
|
@@ -12,7 +12,7 @@ export { createEventEnvelope } from "./event-envelope";
|
|
|
12
12
|
export type { McpCapability, McpServerConfig } from "./mcp-capability";
|
|
13
13
|
export { parseMcpConfig, getMcpServerConfigHash, getMcpServerGrantConstraint } from "./mcp-capability";
|
|
14
14
|
export { WebFetchCapabilityError, WebSearchCapabilityError } from "./web-capability";
|
|
15
|
-
export type { WebCapability, WebFetchCapability, WebFetchCapabilityErrorCode, WebFetchResult, WebSearchCapability, WebSearchCapabilityErrorCode, WebSearchResult, WebSearchSource } from "./web-capability";
|
|
15
|
+
export type { WebCapability, WebFetchBlockReason, WebFetchCapability, WebFetchCapabilityErrorCode, WebFetchResult, WebSearchCapability, WebSearchCapabilityErrorCode, WebSearchResult, WebSearchSource } from "./web-capability";
|
|
16
16
|
export type { WorkPreviewCapability, WorkPreviewPrepareRequest, WorkPreviewPrepareResult, WorkPreviewOpenWhen } from "./work-preview-capability";
|
|
17
17
|
export type { CompactTurnInput, CompactTurnResult } from "./compact-turn-input";
|
|
18
18
|
export type { AgentTerminationBudget, AgentTerminationReason, AgentTerminationView, RecoverableTurnStatus, RecoverableApprovalView, RecoverableTurnView } from "./recoverable-turn-view";
|
|
@@ -68,3 +68,4 @@ export interface SteerTurnInput {
|
|
|
68
68
|
selectedSkills?: import("../domain/input-inbox").InboxSkillRef[];
|
|
69
69
|
}
|
|
70
70
|
export type { AgentCheckpoint };
|
|
71
|
+
export type { BrowserCapability, BrowserBinding, BrowserOperation, BrowserRequestAuthorization } from "./browser-capability";
|
|
@@ -7,6 +7,7 @@ import type { ModelSampler } from "../../internal/kernel/model-sampler";
|
|
|
7
7
|
import type { ModelSamplerFactory } from "../provider/model-sampler-factory";
|
|
8
8
|
import type { McpCapability } from "./mcp-capability";
|
|
9
9
|
import type { WebCapability } from "./web-capability";
|
|
10
|
+
import type { BrowserCapability } from "./browser-capability";
|
|
10
11
|
import type { WorkPreviewCapability } from "./work-preview-capability";
|
|
11
12
|
import type { SessionRunConfig } from "../domain/session-run-config";
|
|
12
13
|
import type { FrozenRunConfig } from "../domain/frozen-run-config";
|
|
@@ -38,6 +39,15 @@ export interface CompactPolicy {
|
|
|
38
39
|
targetTokens: number;
|
|
39
40
|
}
|
|
40
41
|
export interface RunConfig {
|
|
42
|
+
hostToolsLoader?: (binding: {
|
|
43
|
+
sessionId: string;
|
|
44
|
+
turnId: string;
|
|
45
|
+
}) => Promise<{
|
|
46
|
+
tools: import("../../internal/tools/types").AgentToolDefinition<any, any>[];
|
|
47
|
+
allowedTools?: string[];
|
|
48
|
+
beforeExecute?: (toolName: string) => Promise<void>;
|
|
49
|
+
browser?: BrowserCapability;
|
|
50
|
+
} | undefined>;
|
|
41
51
|
toolAllowlist?: readonly string[];
|
|
42
52
|
chatLoader?: (binding: import("./chat-capability").ChatCapabilityBinding) => Promise<import("./chat-capability").ChatCapability | undefined>;
|
|
43
53
|
workspaceRoot?: string;
|
|
@@ -50,6 +60,8 @@ export interface RunConfig {
|
|
|
50
60
|
web?: WebCapability;
|
|
51
61
|
webLoader?: () => Promise<WebCapability | undefined>;
|
|
52
62
|
workPreview?: WorkPreviewCapability;
|
|
63
|
+
browser?: BrowserCapability;
|
|
64
|
+
browserLoader?: () => Promise<BrowserCapability | undefined>;
|
|
53
65
|
workPreviewLoader?: () => Promise<WorkPreviewCapability | undefined>;
|
|
54
66
|
threads?: import("./threads-capability").ThreadsCapability;
|
|
55
67
|
databaseSearch?: DatabaseSearchCapability;
|
|
@@ -29,16 +29,20 @@ export interface WebFetchResult {
|
|
|
29
29
|
truncated: boolean;
|
|
30
30
|
}
|
|
31
31
|
export type WebFetchCapabilityErrorCode = "WEB_URL_BLOCKED" | "WEB_REDIRECT_REQUIRES_APPROVAL" | "WEB_RESPONSE_TOO_LARGE" | "WEB_CONTENT_TYPE_UNSUPPORTED";
|
|
32
|
+
export type WebFetchBlockReason = "url_not_allowed" | "dns_failed" | "non_public_address" | "redirect_rejected";
|
|
33
|
+
export declare const WEB_FETCH_BLOCK_MESSAGES: Readonly<Record<WebFetchBlockReason, string>>;
|
|
34
|
+
export declare const WEB_FETCH_BLOCK_FALLBACK = "\u7F51\u9875\u5730\u5740\u88AB\u5B89\u5168\u7B56\u7565\u963B\u6B62";
|
|
32
35
|
export declare class WebFetchCapabilityError extends Error {
|
|
33
36
|
readonly code: WebFetchCapabilityErrorCode;
|
|
34
37
|
readonly redirect?: {
|
|
35
38
|
url: string;
|
|
36
39
|
remainingRedirects: number;
|
|
37
40
|
} | undefined;
|
|
41
|
+
readonly blockReason?: WebFetchBlockReason | undefined;
|
|
38
42
|
constructor(code: WebFetchCapabilityErrorCode, message: string, redirect?: {
|
|
39
43
|
url: string;
|
|
40
44
|
remainingRedirects: number;
|
|
41
|
-
} | undefined);
|
|
45
|
+
} | undefined, blockReason?: WebFetchBlockReason | undefined);
|
|
42
46
|
}
|
|
43
47
|
export declare function isWebFetchCapabilityError(value: unknown): value is WebFetchCapabilityError;
|
|
44
48
|
export interface WebFetchCapability {
|