@roll-agent/runtime 0.27.0 → 1.0.1
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/dist/engine/agent-session.d.ts +8 -5
- package/dist/engine/agent-session.js +1 -1
- package/dist/engine/cancelled-turn-recovery.d.ts +1 -11
- package/dist/engine/capability-manifest.d.ts +3 -3
- package/dist/engine/compaction-checkpoint.d.ts +486 -3903
- package/dist/engine/compaction-checkpoint.js +1 -1
- package/dist/engine/compaction-semantic-state.d.ts +210 -1804
- package/dist/engine/compactor.d.ts +5 -0
- package/dist/engine/compactor.js +1 -1
- package/dist/engine/conversation-engine.d.ts +24 -42
- package/dist/engine/conversation-engine.js +1 -1
- package/dist/engine/explicit-skill-context.d.ts +6 -62
- package/dist/engine/explicit-skill-context.js +1 -1
- package/dist/engine/model-catalog.d.ts +3 -27
- package/dist/engine/request-budget.d.ts +9 -50
- package/dist/host-contracts/agent-host.d.ts +39 -0
- package/dist/host-contracts/agent-host.js +1 -0
- package/dist/host-contracts/index.d.ts +7 -0
- package/dist/host-contracts/index.js +1 -0
- package/dist/host-contracts/runtime-settings.d.ts +68 -0
- package/dist/host-contracts/runtime-settings.js +1 -0
- package/dist/host-contracts/schedule-tools.d.ts +138 -0
- package/dist/host-contracts/schedule-tools.js +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/interaction/user-input-interaction-manager.d.ts +1 -1
- package/dist/scheduler/calendar.d.ts +13 -51
- package/dist/scheduler/trigger.d.ts +20 -156
- package/dist/server/protocol.d.ts +11 -73
- package/dist/server/runtime-client-interaction-lifecycle.d.ts +2 -2
- package/dist/skills/contracts.d.ts +24 -0
- package/dist/skills/contracts.js +1 -0
- package/dist/skills/index.d.ts +2 -0
- package/dist/skills/index.js +1 -0
- package/dist/skills/invocation.d.ts +29 -0
- package/dist/skills/invocation.js +1 -0
- package/dist/store/semantic-ledger.d.ts +27 -72
- package/dist/store/thread-origin.d.ts +8 -100
- package/dist/store/thread-store.d.ts +3 -3
- package/dist/store/turn-input.d.ts +11 -135
- package/dist/store/turn-input.js +1 -1
- package/dist/tool-bridge/bash-tool.d.ts +1 -13
- package/dist/tool-bridge/build-tools.d.ts +5 -5
- package/dist/tool-bridge/build-tools.js +1 -1
- package/dist/tool-bridge/file-tools/edit-file-tool.d.ts +2 -24
- package/dist/tool-bridge/file-tools/glob-tool.d.ts +1 -7
- package/dist/tool-bridge/file-tools/grep-tool.d.ts +1 -15
- package/dist/tool-bridge/file-tools/list-dir-tool.d.ts +1 -5
- package/dist/tool-bridge/file-tools/read-file-tool.d.ts +1 -9
- package/dist/tool-bridge/file-tools/verify-file-tool.d.ts +5 -8
- package/dist/tool-bridge/file-tools/write-file-tool.d.ts +1 -7
- package/dist/tool-bridge/model-input-schema.d.ts +3 -0
- package/dist/tool-bridge/model-input-schema.js +1 -0
- package/dist/tool-bridge/naming.d.ts +2 -2
- package/dist/tool-bridge/normalize-result.js +1 -1
- package/dist/tool-bridge/observation-recall-tool.d.ts +1 -9
- package/dist/tool-bridge/schedule-create-input.d.ts +9 -75
- package/dist/tool-bridge/schedule-tool.d.ts +1 -1
- package/dist/tool-bridge/schedule-tool.js +1 -1
- package/dist/tool-bridge/session-exec-tool.d.ts +3 -23
- package/dist/tool-bridge/skill-tool.d.ts +2 -8
- package/dist/tool-bridge/skill-tool.js +1 -1
- package/dist/tool-bridge/tool-approval-continuation.d.ts +1 -1
- package/dist/tool-bridge/tool-approval-continuation.js +1 -1
- package/dist/tool-bridge/tool-execution-coordinator.d.ts +3 -26
- package/dist/tool-bridge/tool-execution-coordinator.js +1 -1
- package/dist/tool-bridge/transcript-tool.d.ts +7 -35
- package/dist/tool-bridge/user-input-tool.js +1 -1
- package/dist/tool-contracts/agent-types.d.ts +32 -0
- package/dist/tool-contracts/agent-types.js +1 -0
- package/dist/tool-contracts/execution-timeout.d.ts +2 -0
- package/dist/tool-contracts/execution-timeout.js +1 -0
- package/dist/tool-contracts/index.d.ts +8 -0
- package/dist/tool-contracts/index.js +1 -0
- package/dist/tool-contracts/issues.d.ts +22 -0
- package/dist/tool-contracts/issues.js +1 -0
- package/dist/tool-contracts/json-schema-refs.d.ts +19 -0
- package/dist/tool-contracts/json-schema-refs.js +1 -0
- package/dist/tool-contracts/preflight.d.ts +16 -0
- package/dist/tool-contracts/preflight.js +1 -0
- package/dist/tool-contracts/resource-hints.d.ts +26 -0
- package/dist/tool-contracts/resource-hints.js +1 -0
- package/dist/tool-contracts/results.d.ts +7 -0
- package/dist/tool-contracts/results.js +1 -0
- package/dist/tool-contracts/schema.d.ts +13 -0
- package/dist/tool-contracts/schema.js +1 -0
- package/dist/types/cancellation.d.ts +6 -10
- package/dist/types/events.d.ts +12 -0
- package/dist/types/events.js +1 -1
- package/package.json +17 -6
|
@@ -7,47 +7,19 @@ import { type ToolExecutionCoordinator } from "./tool-execution-coordinator.ts";
|
|
|
7
7
|
export declare const TRANSCRIPT_TOOL_AGENT_NAME = "roll";
|
|
8
8
|
export declare const TRANSCRIPT_TOOL_NAME = "transcript";
|
|
9
9
|
export declare const TRANSCRIPT_TOOL_ID = "roll__transcript";
|
|
10
|
-
declare const transcriptToolInputSchema: z.
|
|
10
|
+
declare const transcriptToolInputSchema: z.ZodObject<{
|
|
11
11
|
checkpointId: z.ZodString;
|
|
12
|
-
kind: z.ZodOptional<z.ZodEnum<
|
|
12
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
message: "message";
|
|
14
|
+
tool_execution: "tool_execution";
|
|
15
|
+
legacy_context: "legacy_context";
|
|
16
|
+
}>>;
|
|
13
17
|
afterSequence: z.ZodOptional<z.ZodNumber>;
|
|
14
18
|
sequence: z.ZodOptional<z.ZodNumber>;
|
|
15
19
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
16
20
|
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
17
21
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
},
|
|
19
|
-
checkpointId: string;
|
|
20
|
-
kind?: "message" | "tool_execution" | "legacy_context" | undefined;
|
|
21
|
-
limit?: number | undefined;
|
|
22
|
-
offset?: number | undefined;
|
|
23
|
-
sequence?: number | undefined;
|
|
24
|
-
maxChars?: number | undefined;
|
|
25
|
-
afterSequence?: number | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
checkpointId: string;
|
|
28
|
-
kind?: "message" | "tool_execution" | "legacy_context" | undefined;
|
|
29
|
-
limit?: number | undefined;
|
|
30
|
-
offset?: number | undefined;
|
|
31
|
-
sequence?: number | undefined;
|
|
32
|
-
maxChars?: number | undefined;
|
|
33
|
-
afterSequence?: number | undefined;
|
|
34
|
-
}>, {
|
|
35
|
-
checkpointId: string;
|
|
36
|
-
kind?: "message" | "tool_execution" | "legacy_context" | undefined;
|
|
37
|
-
limit?: number | undefined;
|
|
38
|
-
offset?: number | undefined;
|
|
39
|
-
sequence?: number | undefined;
|
|
40
|
-
maxChars?: number | undefined;
|
|
41
|
-
afterSequence?: number | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
checkpointId: string;
|
|
44
|
-
kind?: "message" | "tool_execution" | "legacy_context" | undefined;
|
|
45
|
-
limit?: number | undefined;
|
|
46
|
-
offset?: number | undefined;
|
|
47
|
-
sequence?: number | undefined;
|
|
48
|
-
maxChars?: number | undefined;
|
|
49
|
-
afterSequence?: number | undefined;
|
|
50
|
-
}>;
|
|
22
|
+
}, z.core.$strict>;
|
|
51
23
|
export type TranscriptToolInput = z.infer<typeof transcriptToolInputSchema>;
|
|
52
24
|
export type TranscriptReader = (options: ReadCheckpointTranscriptOptions) => CheckpointTranscriptPage;
|
|
53
25
|
export declare function executeTranscriptTool(reader: TranscriptReader, input: TranscriptToolInput): NormalizedToolResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{tool as t}from"ai";import{userInputFormSchema as o}from"@roll-agent/protocol";import{successfulToolResult as
|
|
1
|
+
import{tool as t}from"ai";import{userInputFormSchema as o}from"@roll-agent/protocol";import{modelToolInputSchema as e}from"./model-input-schema.js";import{successfulToolResult as s,toolResultToModelOutput as r}from"./normalize-result.js";import{TOOL_RESOURCE_ACCESS_MODES as i,executeCoordinatedTool as n}from"./tool-execution-coordinator.js";export const USER_INPUT_TOOL_AGENT_NAME="roll";export const USER_INPUT_TOOL_NAME="user_input";function a(t){const o="submitted"===t.status?{status:t.status,submittedControlIds:t.values.map(t=>t.id)}:{status:t.status};return s(o,{raw:t,model:{type:"json",value:t}})}function u(){return a({status:"cancelled",reason:"当前客户端不再支持用户输入请求"})}export function buildUserInputTool(s,l,p){const c=l.register("roll","user_input",{annotations:{readOnlyHint:!0}}),d={prepare:()=>s.isAvailable()?void 0:u(),resources:()=>[{key:`session:${s.sessionId}:user-input`,mode:i.write}],revalidateExecution:()=>s.isAvailable()?void 0:u()};return p.register(c,d),{id:c,tools:{[c]:t({description:"向用户展示一个结构化表单,仅用于补充完成当前任务所必需且无法从上下文推断的信息。不得请求密码、令牌、密钥或其他敏感凭证。",inputSchema:e(o),toModelOutput:({output:t})=>r(t),execute:async(t,o)=>n(p,d,c,o.toolCallId,t,o.abortSignal,async()=>s.isAvailable()?a(await s.request(t,o.abortSignal)):u())})}}}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AppOutputContract } from "@roll-agent/protocol/app-output";
|
|
2
|
+
import type { JsonSchemaRefIssue } from "./json-schema-refs.ts";
|
|
3
|
+
/** Agent 来源类型 */
|
|
4
|
+
export declare const AGENT_SOURCE_TYPES: readonly ["git", "local-path", "installed-package", "remote-manifest"];
|
|
5
|
+
export type AgentSourceType = (typeof AGENT_SOURCE_TYPES)[number];
|
|
6
|
+
/** Agent 运行时 ownership */
|
|
7
|
+
export declare const AGENT_RUNTIME_OWNERSHIPS: readonly ["on-demand", "core-managed", "external-managed"];
|
|
8
|
+
export type AgentRuntimeOwnership = (typeof AGENT_RUNTIME_OWNERSHIPS)[number];
|
|
9
|
+
/** JSON Schema 子集,对应 MCP tool 的 inputSchema */
|
|
10
|
+
export interface JsonSchemaObject {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly properties?: Readonly<Record<string, object>> | undefined;
|
|
13
|
+
readonly required?: readonly string[] | undefined;
|
|
14
|
+
readonly additionalProperties?: boolean | undefined;
|
|
15
|
+
readonly [key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** MCP Tool Schema */
|
|
18
|
+
export interface AgentTool {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description?: string | undefined;
|
|
21
|
+
readonly inputSchema: JsonSchemaObject;
|
|
22
|
+
readonly schemaIssues?: readonly JsonSchemaRefIssue[];
|
|
23
|
+
readonly appOutput?: AppOutputContract;
|
|
24
|
+
readonly appOutputIssue?: "invalid_contract";
|
|
25
|
+
/** Validated MCP request deadline advertised by this tool. */
|
|
26
|
+
readonly executionTimeoutMs?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const AGENT_TRANSPORT_KINDS: {
|
|
29
|
+
readonly stdio: "stdio";
|
|
30
|
+
readonly streamableHttp: "streamable-http";
|
|
31
|
+
};
|
|
32
|
+
export type AgentTransportKind = (typeof AGENT_TRANSPORT_KINDS)[keyof typeof AGENT_TRANSPORT_KINDS];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AGENT_SOURCE_TYPES=["git","local-path","installed-package","remote-manifest"];export const AGENT_RUNTIME_OWNERSHIPS=["on-demand","core-managed","external-managed"];export const AGENT_TRANSPORT_KINDS={stdio:"stdio",streamableHttp:"streamable-http"};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ROLL_EXECUTION_TIMEOUT_META_KEY="roll/executionTimeoutMs";export function readExecutionTimeoutMs(e){const o="object"!=typeof e||null===e||Array.isArray(e)?void 0:Reflect.get(e,"roll/executionTimeoutMs");return"number"==typeof o&&Number.isSafeInteger(o)&&o>=1e3&&o<=18e5?o:void 0}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./agent-types.ts";
|
|
2
|
+
export * from "./issues.ts";
|
|
3
|
+
export * from "./json-schema-refs.ts";
|
|
4
|
+
export * from "./schema.ts";
|
|
5
|
+
export * from "./preflight.ts";
|
|
6
|
+
export * from "./execution-timeout.ts";
|
|
7
|
+
export * from "./results.ts";
|
|
8
|
+
export * from "./resource-hints.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./agent-types.js";export*from"./issues.js";export*from"./json-schema-refs.js";export*from"./schema.js";export*from"./preflight.js";export*from"./execution-timeout.js";export*from"./results.js";export*from"./resource-hints.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const ASK_VALIDATION_ISSUE_CODES: readonly ["missing_required", "requires_explicit_input", "invalid_type", "invalid_enum", "too_small", "unexpected_property"];
|
|
2
|
+
export type AskValidationIssueCode = (typeof ASK_VALIDATION_ISSUE_CODES)[number];
|
|
3
|
+
export declare const ASK_RUNTIME_ISSUE_CATEGORIES: readonly ["env"];
|
|
4
|
+
export type AskRuntimeIssueCategory = (typeof ASK_RUNTIME_ISSUE_CATEGORIES)[number];
|
|
5
|
+
export declare const ASK_RUNTIME_ISSUE_CODES: readonly ["missing_required_env"];
|
|
6
|
+
export type AskRuntimeIssueCode = (typeof ASK_RUNTIME_ISSUE_CODES)[number];
|
|
7
|
+
export interface AskValidationIssue {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly code: AskValidationIssueCode;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
readonly expected?: string;
|
|
13
|
+
readonly actual?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AskRuntimeIssue {
|
|
16
|
+
readonly category: AskRuntimeIssueCategory;
|
|
17
|
+
readonly code: AskRuntimeIssueCode;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly purpose?: string;
|
|
21
|
+
readonly example?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ASK_VALIDATION_ISSUE_CODES=["missing_required","requires_explicit_input","invalid_type","invalid_enum","too_small","unexpected_property"];export const ASK_RUNTIME_ISSUE_CATEGORIES=["env"];export const ASK_RUNTIME_ISSUE_CODES=["missing_required_env"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const JSON_SCHEMA_REF_ISSUE_REASONS: {
|
|
2
|
+
readonly recursive: "recursive";
|
|
3
|
+
readonly external: "external";
|
|
4
|
+
readonly unresolvable: "unresolvable";
|
|
5
|
+
readonly siblingKeywords: "sibling-keywords";
|
|
6
|
+
readonly limit: "limit";
|
|
7
|
+
};
|
|
8
|
+
export type JsonSchemaRefIssueReason = (typeof JSON_SCHEMA_REF_ISSUE_REASONS)[keyof typeof JSON_SCHEMA_REF_ISSUE_REASONS];
|
|
9
|
+
export interface JsonSchemaRefIssue {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly ref: string;
|
|
12
|
+
readonly reason: JsonSchemaRefIssueReason;
|
|
13
|
+
}
|
|
14
|
+
export interface InlineJsonSchemaRefsResult<T> {
|
|
15
|
+
readonly schema: T;
|
|
16
|
+
readonly unresolved: readonly JsonSchemaRefIssue[];
|
|
17
|
+
}
|
|
18
|
+
export declare function isRootDefinitionReference(ref: string): boolean;
|
|
19
|
+
export declare function inlineAcyclicLocalJsonSchemaReferences<T extends object>(schema: T): InlineJsonSchemaRefsResult<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const JSON_SCHEMA_REF_ISSUE_REASONS={recursive:"recursive",external:"external",unresolvable:"unresolvable",siblingKeywords:"sibling-keywords",limit:"limit"};const e=32,t=1e4,n=262144,r=new Set(["description","title","default","examples","deprecated","readOnly","writeOnly","$comment"]),i=new Set(["$defs","definitions"]),s=["#/$defs/","#/definitions/"],o=new Set(["additionalItems","additionalProperties","allOf","anyOf","contains","contentSchema","else","if","items","not","oneOf","prefixItems","propertyNames","then","unevaluatedItems","unevaluatedProperties"]),u=new Set(["dependencies","dependentSchemas","patternProperties","properties"]),c=/^(?:0|[1-9]\d*)$/u;class InlineLimitExceeded extends Error{}function a(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function d(e){return"boolean"==typeof e||a(e)}export function isRootDefinitionReference(e){const t=s.find(t=>e.startsWith(t)),n=void 0===t?void 0:e.slice(t.length);if(void 0===n||0===n.length||n.includes("/"))return!1;let r;try{r=decodeURIComponent(n)}catch{return!1}return!r.includes("/")&&!/~(?![01])/u.test(r)}function l(e){if(!/~(?![01])/u.test(e))return e.replace(/~1/gu,"/").replace(/~0/gu,"~")}function f(e){return e.replace(/~/gu,"~0").replace(/\//gu,"~1")}function S(e,t){let n;try{n=decodeURIComponent(t.slice(1))}catch{return}if(0===n.length)return e;if(!n.startsWith("/"))return;let r=e;for(const e of n.slice(1).split("/")){const t=l(e);if(void 0===t)return;if(Array.isArray(r))r=c.test(t)?r[Number(t)]:void 0;else{if(!a(r))return;r=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0}if(void 0===r)return}return r}function p(e,t,n){return e.startsWith("#")?t.activeRefs.includes(e)?JSON_SCHEMA_REF_ISSUE_REASONS.recursive:d(S(n,e))?void 0:JSON_SCHEMA_REF_ISSUE_REASONS.unresolvable:JSON_SCHEMA_REF_ISSUE_REASONS.external}function h(e,t){return!0===e?{...t}:!1===e?{not:{},...t}:{...e,...t}}function E(e,t,n,r){return Object.fromEntries(Object.entries(e).map(([e,i])=>{const s=`${t}/${f(e)}`;return o.has(e)?[e,v(i,s,n,r)]:u.has(e)&&a(i)?[e,Object.fromEntries(Object.entries(i).map(([e,t])=>[e,v(t,`${s}/${f(e)}`,n,r)]))]:[e,i]}))}function v(n,s,o,u){if(o.activeRefs.length>0&&(u.expandedNodes+=1,u.expandedNodes>t||o.expansionDepth>e))throw new InlineLimitExceeded;if(Array.isArray(n))return n.map((e,t)=>v(e,`${s}/${String(t)}`,o,u));if(!a(n))return n;const{$ref:c,...l}=n;if("string"!=typeof c)return E(n,s,o,u);if(Object.keys(l).some(e=>!r.has(e)&&!i.has(e)))return u.unresolved.push({path:s,ref:c,reason:JSON_SCHEMA_REF_ISSUE_REASONS.siblingKeywords}),n;const f=p(c,o,u.root);if(void 0!==f)return u.unresolved.push({path:s,ref:c,reason:f}),n;const _={root:u.root,unresolved:[],expandedNodes:u.expandedNodes},m=v(S(u.root,c),s,{activeRefs:[...o.activeRefs,c],expansionDepth:o.expansionDepth+1},_);u.expandedNodes=_.expandedNodes;return _.unresolved.some(e=>e.reason===JSON_SCHEMA_REF_ISSUE_REASONS.recursive&&e.ref===c)?(u.unresolved.push({path:s,ref:c,reason:JSON_SCHEMA_REF_ISSUE_REASONS.recursive}),n):(u.unresolved.push(..._.unresolved),d(m)?h(m,l):n)}function _(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}export function inlineAcyclicLocalJsonSchemaReferences(e){const t=JSON.stringify(e);if(!t.includes('"$ref"'))return{schema:e,unresolved:[]};const r={root:e,unresolved:[],expandedNodes:0};try{const i=v(e,"",{activeRefs:[],expansionDepth:0},r),s=_(i);if(s>n&&s>Buffer.byteLength(t,"utf8"))throw new InlineLimitExceeded;return{schema:i,unresolved:r.unresolved}}catch(t){if(t instanceof InlineLimitExceeded)return{schema:e,unresolved:[{path:"",ref:"#",reason:JSON_SCHEMA_REF_ISSUE_REASONS.limit}]};throw t}}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentTool } from "./agent-types.ts";
|
|
2
|
+
import type { AskRuntimeIssue, AskValidationIssue } from "./issues.ts";
|
|
3
|
+
export interface ToolCallPreflightSuccess {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
}
|
|
6
|
+
export interface ToolCallPreflightFailure {
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly issues: ReadonlyArray<AskValidationIssue>;
|
|
9
|
+
readonly runtimeIssues: ReadonlyArray<AskRuntimeIssue>;
|
|
10
|
+
}
|
|
11
|
+
export type ToolCallPreflightResult = ToolCallPreflightSuccess | ToolCallPreflightFailure;
|
|
12
|
+
export interface ToolCallPreflightOptions {
|
|
13
|
+
readonly runtimeIssues?: ReadonlyArray<AskRuntimeIssue>;
|
|
14
|
+
}
|
|
15
|
+
export declare function getInputValidationIssues(tool: Pick<AgentTool, "inputSchema">, input: Readonly<Record<string, unknown>>): ReadonlyArray<AskValidationIssue>;
|
|
16
|
+
export declare function preflightToolCall(tool: Pick<AgentTool, "inputSchema">, input: Readonly<Record<string, unknown>>, options?: ToolCallPreflightOptions): ToolCallPreflightResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describeValueType as e,getAdditionalPropertiesSetting as t,getSchemaDescription as n,getSchemaEnum as r,getSchemaItems as s,getSchemaMinItems as i,getSchemaProperties as u,getSchemaRequired as o,getSchemaType as c,isNaturallyExtractableSchema as a,isJsonSchemaObject as p,isPlainObject as l}from"./schema.js";function g(e,t){const r=n(t),s=t&&!a(t);return{path:e,code:s?"requires_explicit_input":"missing_required",message:s?`${e} 无法从自然语言可靠提取,需要显式提供`:`${e} 为必填字段`,...r?{description:r}:{}}}function f(e,t){if(t&&p(t)){const n=h({inputSchema:t},{},e);if(n.length>0)return n}return[g(e,t)]}function m(t,u,o){const a=[],g=n(t),f=r(t),d=c(t);if(f&&!f.some(e=>Object.is(e,u)))return a.push({path:o,code:"invalid_enum",message:`${o} 必须是以下值之一:${f.map(e=>JSON.stringify(e)).join("、")}`,...g?{description:g}:{},expected:f.map(e=>JSON.stringify(e)).join(" | "),actual:JSON.stringify(u)}),a;if(!d)return a;const $=e(u),y=()=>{a.push({path:o,code:"invalid_type",message:`${o} 应为 ${d},当前是 ${$}`,...g?{description:g}:{},expected:d,actual:$})};switch(d){case"string":return"string"!=typeof u&&y(),a;case"number":return("number"!=typeof u||Number.isNaN(u))&&y(),a;case"integer":return"number"==typeof u&&Number.isInteger(u)||y(),a;case"boolean":return"boolean"!=typeof u&&y(),a;case"null":return null!==u&&y(),a;case"array":if(!Array.isArray(u))return y(),a;{const e=i(t);void 0!==e&&u.length<e&&a.push({path:o,code:"too_small",message:`${o} 至少需要 ${String(e)} 个元素,当前是 ${String(u.length)} 个`,...g?{description:g}:{},expected:`minItems: ${String(e)}`,actual:`length: ${String(u.length)}`});const n=s(t);return n?(a.push(...u.flatMap((e,t)=>m(n,e,`${o}[${String(t)}]`))),a):a}case"object":return l(u)?p(t)?h({inputSchema:t},u,o):a:(y(),a);default:return a}}function h(e,n,r=""){const s=o(e),i=u(e.inputSchema),c=[];for(const e of s){const t=n[e];if(null!=t)continue;const s=i[e],u=r?`${r}.${e}`:e;c.push(...f(u,s))}for(const[s,u]of Object.entries(n)){const n=r?`${r}.${s}`:s,o=i[s];o?c.push(...m(o,u,n)):!1===t(e.inputSchema)&&c.push({path:n,code:"unexpected_property",message:`${n} 不是允许的参数`})}return c}export function getInputValidationIssues(e,t){return h(e,t)}export function preflightToolCall(e,t,n={}){const r=getInputValidationIssues(e,t),s=n.runtimeIssues??[];return 0===r.length&&0===s.length?{ok:!0}:{ok:!1,issues:r,runtimeIssues:s}}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const ROLL_RESOURCE_HINTS_META_KEY = "roll/resourceHints";
|
|
2
|
+
export declare const TOOL_RESOURCE_ACCESS_MODES: {
|
|
3
|
+
readonly read: "read";
|
|
4
|
+
readonly write: "write";
|
|
5
|
+
};
|
|
6
|
+
export declare const OPAQUE_SIDE_EFFECT_RESOURCE = "shell:opaque-side-effects";
|
|
7
|
+
export type ToolResourceAccessMode = (typeof TOOL_RESOURCE_ACCESS_MODES)[keyof typeof TOOL_RESOURCE_ACCESS_MODES];
|
|
8
|
+
export interface ToolResourceAccess {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly mode: ToolResourceAccessMode;
|
|
11
|
+
}
|
|
12
|
+
export declare const TOOL_RESOURCE_HINT_KINDS: {
|
|
13
|
+
readonly file: "file";
|
|
14
|
+
readonly browserSession: "browser-session";
|
|
15
|
+
readonly conversation: "conversation";
|
|
16
|
+
readonly custom: "custom";
|
|
17
|
+
};
|
|
18
|
+
export type ToolResourceHintKind = (typeof TOOL_RESOURCE_HINT_KINDS)[keyof typeof TOOL_RESOURCE_HINT_KINDS];
|
|
19
|
+
export interface ToolResourceHint {
|
|
20
|
+
/** Top-level tool input field containing one resource id or an array of ids. */
|
|
21
|
+
readonly field: string;
|
|
22
|
+
readonly kind: ToolResourceHintKind;
|
|
23
|
+
readonly mode?: ToolResourceAccessMode;
|
|
24
|
+
/** Required for `custom`; ignored for built-in kinds. */
|
|
25
|
+
readonly namespace?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ROLL_RESOURCE_HINTS_META_KEY="roll/resourceHints";export const TOOL_RESOURCE_ACCESS_MODES={read:"read",write:"write"};export const OPAQUE_SIDE_EFFECT_RESOURCE="shell:opaque-side-effects";export const TOOL_RESOURCE_HINT_KINDS={file:"file",browserSession:"browser-session",conversation:"conversation",custom:"custom"};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AppOutputContract } from "@roll-agent/protocol/app-output";
|
|
2
|
+
export { getCompletedAppOutputStatus } from "@roll-agent/protocol/app-output";
|
|
3
|
+
export declare function extractTextContent(content: unknown): string[];
|
|
4
|
+
export declare function isToolErrorResult(result: unknown, appOutput?: AppOutputContract): result is {
|
|
5
|
+
readonly isError: true;
|
|
6
|
+
readonly content?: unknown;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCompletedAppOutputStatus as t}from"@roll-agent/protocol/app-output";export{getCompletedAppOutputStatus}from"@roll-agent/protocol/app-output";export function extractTextContent(t){if(!Array.isArray(t))return[];const o=[];for(const r of t)"object"==typeof r&&null!==r&&"type"in r&&"text"===r.type&&"text"in r&&"string"==typeof r.text&&o.push(r.text);return o}export function isToolErrorResult(o,r){return(void 0===r||void 0===t(o))&&("object"==typeof o&&null!==o&&"isError"in o&&!0===o.isError)}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentTool } from "./agent-types.ts";
|
|
2
|
+
export declare function isPlainObject(value: unknown): value is Readonly<Record<string, unknown>>;
|
|
3
|
+
export declare function isJsonSchemaObject(value: object): value is AgentTool["inputSchema"];
|
|
4
|
+
export declare function getSchemaDescription(schema: object | undefined): string | undefined;
|
|
5
|
+
export declare function getSchemaType(schema: object | undefined): string | undefined;
|
|
6
|
+
export declare function getSchemaEnum(schema: object | undefined): ReadonlyArray<unknown> | undefined;
|
|
7
|
+
export declare function getSchemaItems(schema: object | undefined): object | undefined;
|
|
8
|
+
export declare function getSchemaMinItems(schema: object | undefined): number | undefined;
|
|
9
|
+
export declare function getSchemaProperties(schema: Pick<AgentTool, "inputSchema">["inputSchema"] | object | undefined): Readonly<Record<string, object>>;
|
|
10
|
+
export declare function isNaturallyExtractableSchema(schema: object | undefined): boolean;
|
|
11
|
+
export declare function getSchemaRequired(tool: Pick<AgentTool, "inputSchema">): ReadonlyArray<string>;
|
|
12
|
+
export declare function getAdditionalPropertiesSetting(schema: Pick<AgentTool, "inputSchema">["inputSchema"] | object | undefined): boolean | undefined;
|
|
13
|
+
export declare function describeValueType(value: unknown): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isPlainObject(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}export function isJsonSchemaObject(e){return"type"in e&&"object"===e.type}export function getSchemaDescription(e){return e&&"description"in e&&"string"==typeof e.description?e.description:void 0}export function getSchemaType(e){return e&&"type"in e&&"string"==typeof e.type?e.type:void 0}export function getSchemaEnum(e){return e&&"enum"in e&&Array.isArray(e.enum)?e.enum:void 0}export function getSchemaItems(e){return e&&"items"in e&&"object"==typeof e.items&&null!==e.items?e.items:void 0}export function getSchemaMinItems(e){return e&&"minItems"in e&&"number"==typeof e.minItems?e.minItems:void 0}export function getSchemaProperties(e){if(!(e&&"properties"in e&&e.properties&&isPlainObject(e.properties)))return{};const t=Object.entries(e.properties).filter(e=>{const[,t]=e;return"object"==typeof t&&null!==t});return Object.fromEntries(t)}export function isNaturallyExtractableSchema(e){return!!e&&("object"!==getSchemaType(e)||Object.keys(getSchemaProperties(e)).length>0)}export function getSchemaRequired(e){return e.inputSchema.required??[]}export function getAdditionalPropertiesSetting(e){return e&&"additionalProperties"in e&&"boolean"==typeof e.additionalProperties?e.additionalProperties:void 0}export function describeValueType(e){return null===e?"null":Array.isArray(e)?"array":typeof e}
|
|
@@ -9,16 +9,12 @@ export type SessionCancellationReason = (typeof SESSION_CANCELLATION_REASONS)[ke
|
|
|
9
9
|
export declare const turnCancellationMetadataV1Schema: z.ZodReadonly<z.ZodObject<{
|
|
10
10
|
version: z.ZodLiteral<1>;
|
|
11
11
|
kind: z.ZodLiteral<"turn-cancellation">;
|
|
12
|
-
reason: z.ZodEnum<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
kind: "turn-cancellation";
|
|
19
|
-
version: 1;
|
|
20
|
-
reason: "runtime" | "user" | "timeout";
|
|
21
|
-
}>>;
|
|
12
|
+
reason: z.ZodEnum<{
|
|
13
|
+
user: "user";
|
|
14
|
+
timeout: "timeout";
|
|
15
|
+
runtime: "runtime";
|
|
16
|
+
}>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
22
18
|
export declare function createTurnCancellationMessage(content: string, reason: SessionCancellationReason): AssistantModelMessage;
|
|
23
19
|
export declare function readTurnCancellationReason(message: ModelMessage): SessionCancellationReason | undefined;
|
|
24
20
|
export declare function stripTurnCancellationMetadata(messages: readonly ModelMessage[]): ModelMessage[];
|
package/dist/types/events.d.ts
CHANGED
|
@@ -13,6 +13,16 @@ export interface SessionTokenUsage {
|
|
|
13
13
|
export type SessionEventStage = "bootstrap" | "plan" | "execute";
|
|
14
14
|
export type SessionDebugStage = "turn" | "compaction" | "model" | "persist";
|
|
15
15
|
export type SessionDebugData = Readonly<Record<string, string | number | boolean>>;
|
|
16
|
+
export declare const COMPACTION_FAILURE_REASONS: {
|
|
17
|
+
readonly timeout: "timeout";
|
|
18
|
+
readonly error: "error";
|
|
19
|
+
};
|
|
20
|
+
export type ContextCompactionFailure = {
|
|
21
|
+
readonly reason: typeof COMPACTION_FAILURE_REASONS.timeout;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly reason: typeof COMPACTION_FAILURE_REASONS.error;
|
|
25
|
+
};
|
|
16
26
|
export type SessionEvent = {
|
|
17
27
|
readonly type: "context-recovery";
|
|
18
28
|
readonly state: ContextRecoveryView | null;
|
|
@@ -129,6 +139,8 @@ export type SessionEvent = {
|
|
|
129
139
|
readonly truncatedTools?: number;
|
|
130
140
|
readonly beforeInputTokens?: number;
|
|
131
141
|
readonly recoveryNotice?: string;
|
|
142
|
+
/** Diagnostic only: a failed attempt leaves the original context intact. */
|
|
143
|
+
readonly failure?: ContextCompactionFailure;
|
|
132
144
|
readonly checkpointId?: string;
|
|
133
145
|
readonly checkpointGeneration?: number;
|
|
134
146
|
readonly checkpointSummaryStatus?: "valid" | "fallback" | "skipped";
|
package/dist/types/events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export const COMPACTION_FAILURE_REASONS={timeout:"timeout",error:"error"};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roll-agent/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./skills": {
|
|
19
|
+
"types": "./dist/skills/index.d.ts",
|
|
20
|
+
"default": "./dist/skills/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./tool-contracts": {
|
|
23
|
+
"types": "./dist/tool-contracts/index.d.ts",
|
|
24
|
+
"default": "./dist/tool-contracts/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./host-contracts": {
|
|
27
|
+
"types": "./dist/host-contracts/index.d.ts",
|
|
28
|
+
"default": "./dist/host-contracts/index.js"
|
|
17
29
|
}
|
|
18
30
|
},
|
|
19
31
|
"publishConfig": {
|
|
@@ -26,17 +38,16 @@
|
|
|
26
38
|
"node": ">=22.6.0"
|
|
27
39
|
},
|
|
28
40
|
"dependencies": {
|
|
29
|
-
"@ai-sdk/provider": "
|
|
41
|
+
"@ai-sdk/provider": "4.0.31",
|
|
30
42
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
31
|
-
"@roll-agent/protocol": "0.
|
|
43
|
+
"@roll-agent/protocol": "0.10.0",
|
|
32
44
|
"@vscode/ripgrep": "1.18.0",
|
|
33
|
-
"ai": "
|
|
45
|
+
"ai": "7.0.146",
|
|
34
46
|
"diff": "9.0.0",
|
|
35
47
|
"yaml": "2.8.3",
|
|
36
|
-
"zod": "
|
|
48
|
+
"zod": "4.6.6"
|
|
37
49
|
},
|
|
38
50
|
"devDependencies": {
|
|
39
|
-
"@roll-agent/core": "0.44.0",
|
|
40
51
|
"@types/node": "^22.0.0"
|
|
41
52
|
},
|
|
42
53
|
"scripts": {
|