@devicerail/tool-adapter 0.1.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.
@@ -0,0 +1,79 @@
1
+ import type { DeviceRailClient } from "@devicerail/client";
2
+ import type { ActionResult, Observation, RequestCancelResult, RpcId } from "@devicerail/protocol";
3
+ export type DeviceRailToolClient = Pick<DeviceRailClient, "beginCall" | "call"> & {
4
+ readonly enabledFeatures?: ReadonlySet<string>;
5
+ };
6
+ export type ToolInputSchema = Readonly<Record<string, unknown>>;
7
+ export interface ObservationToolDefinition {
8
+ readonly description: string;
9
+ readonly inputSchema: ToolInputSchema;
10
+ readonly kind: "observation";
11
+ readonly name: string;
12
+ }
13
+ export interface ActionToolDefinition {
14
+ readonly actionName: string;
15
+ readonly description: string;
16
+ readonly inputSchema: ToolInputSchema;
17
+ readonly kind: "action";
18
+ readonly name: string;
19
+ readonly protection?: "protected";
20
+ }
21
+ export type DeviceRailToolDefinition = ObservationToolDefinition | ActionToolDefinition;
22
+ export interface ToolInvocation {
23
+ readonly arguments?: unknown;
24
+ readonly invocationId?: string;
25
+ readonly name: string;
26
+ }
27
+ export interface ToolInvocationOptions {
28
+ readonly actionTimeoutMs?: number;
29
+ readonly requestTimeoutMs?: number;
30
+ readonly signal?: AbortSignal;
31
+ }
32
+ export interface ObservationToolResult {
33
+ readonly invocationId?: string;
34
+ readonly kind: "observation";
35
+ readonly observation: Observation;
36
+ readonly requestId: RpcId;
37
+ readonly toolName: string;
38
+ }
39
+ export interface ActionToolResult {
40
+ readonly action: ActionResult;
41
+ readonly actionCallId: string;
42
+ readonly actionName: string;
43
+ readonly invocationId?: string;
44
+ readonly kind: "action";
45
+ readonly requestId: RpcId;
46
+ readonly toolName: string;
47
+ }
48
+ export type ToolInvocationResult = ObservationToolResult | ActionToolResult;
49
+ interface BaseToolInvocationHandle<Result extends ToolInvocationResult> {
50
+ readonly requestId: RpcId;
51
+ readonly result: Promise<Result>;
52
+ cancel(): Promise<RequestCancelResult>;
53
+ }
54
+ export interface ObservationToolInvocationHandle extends BaseToolInvocationHandle<ObservationToolResult> {
55
+ readonly kind: "observation";
56
+ }
57
+ export interface ActionToolInvocationHandle extends BaseToolInvocationHandle<ActionToolResult> {
58
+ readonly actionCallId: string;
59
+ readonly actionName: string;
60
+ readonly kind: "action";
61
+ }
62
+ export type ToolInvocationHandle = ObservationToolInvocationHandle | ActionToolInvocationHandle;
63
+ export interface DeviceRailToolCatalog {
64
+ readonly id: string;
65
+ readonly revision: number;
66
+ readonly tools: readonly DeviceRailToolDefinition[];
67
+ beginInvoke(invocation: ToolInvocation, options?: ToolInvocationOptions): ToolInvocationHandle;
68
+ invoke(invocation: ToolInvocation, options?: ToolInvocationOptions): Promise<ToolInvocationResult>;
69
+ }
70
+ export interface ToolDiscoveryOptions {
71
+ readonly requestTimeoutMs?: number;
72
+ readonly signal?: AbortSignal;
73
+ }
74
+ export interface DeviceRailToolAdapterOptions {
75
+ readonly includeObservation?: boolean;
76
+ readonly includeProtectedActions?: boolean;
77
+ readonly maxActions?: number;
78
+ }
79
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@devicerail/tool-adapter",
3
+ "version": "0.1.0",
4
+ "description": "Provider-neutral AI tool adapter for DeviceRail device capabilities",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "ai-agent",
8
+ "ai-tools",
9
+ "device-automation",
10
+ "test-automation"
11
+ ],
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "dependencies": {
32
+ "@types/node": "26.1.1",
33
+ "@devicerail/client": "0.1.0",
34
+ "@devicerail/protocol": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "typescript": "7.0.2"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/wangweiwei/device-rail.git",
42
+ "directory": "packages/tool-adapter"
43
+ },
44
+ "homepage": "https://github.com/wangweiwei/device-rail#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/wangweiwei/device-rail/issues"
47
+ },
48
+ "scripts": {
49
+ "typecheck": "tsc -p tsconfig.json --noEmit",
50
+ "build": "node scripts/clean.mjs dist && tsc -p tsconfig.build.json && tsc -p tsconfig.package-exports.json && node scripts/check-package-exports.mjs",
51
+ "test": "node scripts/clean.mjs .test-dist && tsc -p tsconfig.test.json && node scripts/run-tests.mjs"
52
+ }
53
+ }