@aumos/agent-sim-bridge 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.
- package/dist/client.d.ts +118 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +142 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +230 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -0
- package/src/client.ts +358 -0
- package/src/index.ts +33 -0
- package/src/types.ts +274 -0
- package/tsconfig.json +25 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-sim-bridge sim-to-real transfer API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSimBridgeClient } from "@aumos/agent-sim-bridge";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSimBridgeClient({ baseUrl: "http://localhost:8094" });
|
|
12
|
+
*
|
|
13
|
+
* const sim = await client.createSimulation({
|
|
14
|
+
* backend: "pybullet",
|
|
15
|
+
* name: "manipulation-v1",
|
|
16
|
+
* max_episode_steps: 500,
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (sim.ok) {
|
|
20
|
+
* console.log("Simulation created:", sim.data.environment_id);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { ApiResult, DomainRandomization, GapEstimationRequest, GapEstimationResult, RandomizationRequest, RandomizationResult, SimResult, SimulationConfig, SimulationEnvironment, TransferConfig, TransferResult } from "./types.js";
|
|
25
|
+
/** Configuration options for the AgentSimBridgeClient. */
|
|
26
|
+
export interface AgentSimBridgeClientConfig {
|
|
27
|
+
/** Base URL of the agent-sim-bridge server (e.g. "http://localhost:8094"). */
|
|
28
|
+
readonly baseUrl: string;
|
|
29
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
30
|
+
readonly timeoutMs?: number;
|
|
31
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
32
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
33
|
+
}
|
|
34
|
+
/** Typed HTTP client for the agent-sim-bridge server. */
|
|
35
|
+
export interface AgentSimBridgeClient {
|
|
36
|
+
/**
|
|
37
|
+
* Create and register a new simulation environment.
|
|
38
|
+
*
|
|
39
|
+
* @param config - Simulation configuration including backend and episode settings.
|
|
40
|
+
* @returns The created SimulationEnvironment descriptor.
|
|
41
|
+
*/
|
|
42
|
+
createSimulation(config: SimulationConfig): Promise<ApiResult<SimulationEnvironment>>;
|
|
43
|
+
/**
|
|
44
|
+
* Transfer simulation values to real-world units using a calibration profile.
|
|
45
|
+
*
|
|
46
|
+
* @param options - Transfer configuration and simulation values to transform.
|
|
47
|
+
* @returns A TransferResult with transformed real-world values.
|
|
48
|
+
*/
|
|
49
|
+
transferToReality(options: {
|
|
50
|
+
config: TransferConfig;
|
|
51
|
+
sim_values: readonly number[];
|
|
52
|
+
}): Promise<ApiResult<TransferResult>>;
|
|
53
|
+
/**
|
|
54
|
+
* Estimate the sim-to-real distribution gap across multiple dimensions.
|
|
55
|
+
*
|
|
56
|
+
* @param request - Gap estimation request with dimensions and metric selection.
|
|
57
|
+
* @returns A GapEstimationResult with per-dimension gaps and overall score.
|
|
58
|
+
*/
|
|
59
|
+
estimateGap(request: GapEstimationRequest): Promise<ApiResult<GapEstimationResult>>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the results for a completed simulation episode.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Environment ID and optional run ID filter.
|
|
64
|
+
* @returns Array of SimResult records ordered by completion time descending.
|
|
65
|
+
*/
|
|
66
|
+
getSimResults(options: {
|
|
67
|
+
environment_id: string;
|
|
68
|
+
run_id?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
}): Promise<ApiResult<readonly SimResult[]>>;
|
|
71
|
+
/**
|
|
72
|
+
* Configure and apply domain randomization to a simulation environment.
|
|
73
|
+
*
|
|
74
|
+
* @param request - Randomization request with environment ID and parameter specs.
|
|
75
|
+
* @returns A RandomizationResult with the sampled parameter values.
|
|
76
|
+
*/
|
|
77
|
+
configureRandomization(request: RandomizationRequest): Promise<ApiResult<RandomizationResult>>;
|
|
78
|
+
/**
|
|
79
|
+
* List all registered simulation environments.
|
|
80
|
+
*
|
|
81
|
+
* @param options - Optional filter parameters.
|
|
82
|
+
* @returns Array of SimulationEnvironment descriptors.
|
|
83
|
+
*/
|
|
84
|
+
listSimulations(options?: {
|
|
85
|
+
backend?: string;
|
|
86
|
+
limit?: number;
|
|
87
|
+
}): Promise<ApiResult<readonly SimulationEnvironment[]>>;
|
|
88
|
+
/**
|
|
89
|
+
* Get the transfer configuration (calibration profile) for an environment.
|
|
90
|
+
*
|
|
91
|
+
* @param environmentId - The simulation environment identifier.
|
|
92
|
+
* @returns The TransferConfig describing the linear sim-to-real transform.
|
|
93
|
+
*/
|
|
94
|
+
getTransferConfig(environmentId: string): Promise<ApiResult<TransferConfig>>;
|
|
95
|
+
/**
|
|
96
|
+
* Update the transfer configuration for a simulation environment.
|
|
97
|
+
*
|
|
98
|
+
* @param environmentId - The simulation environment identifier.
|
|
99
|
+
* @param config - The new TransferConfig to apply.
|
|
100
|
+
* @returns The updated TransferConfig.
|
|
101
|
+
*/
|
|
102
|
+
updateTransferConfig(environmentId: string, config: TransferConfig): Promise<ApiResult<TransferConfig>>;
|
|
103
|
+
/**
|
|
104
|
+
* List the randomization configurations for a simulation environment.
|
|
105
|
+
*
|
|
106
|
+
* @param environmentId - The simulation environment identifier.
|
|
107
|
+
* @returns Array of DomainRandomization specifications.
|
|
108
|
+
*/
|
|
109
|
+
listRandomizations(environmentId: string): Promise<ApiResult<readonly DomainRandomization[]>>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a typed HTTP client for the agent-sim-bridge server.
|
|
113
|
+
*
|
|
114
|
+
* @param config - Client configuration including base URL.
|
|
115
|
+
* @returns An AgentSimBridgeClient instance.
|
|
116
|
+
*/
|
|
117
|
+
export declare function createAgentSimBridgeClient(config: AgentSimBridgeClientConfig): AgentSimBridgeClient;
|
|
118
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAEV,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB,0DAA0D;AAC1D,MAAM,WAAW,0BAA0B;IACzC,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AA0DD,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,gBAAgB,CACd,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAE7C;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE;QACzB,MAAM,EAAE,cAAc,CAAC;QACvB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;KAC/B,GAAG,OA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P client for the agent-sim-bridge sim-to-real transfer API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSimBridgeClient } from "@aumos/agent-sim-bridge";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSimBridgeClient({ baseUrl: "http://localhost:8094" });
|
|
12
|
+
*
|
|
13
|
+
* const sim = await client.createSimulation({
|
|
14
|
+
* backend: "pybullet",
|
|
15
|
+
* name: "manipulation-v1",
|
|
16
|
+
* max_episode_steps: 500,
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (sim.ok) {
|
|
20
|
+
* console.log("Simulation created:", sim.data.environment_id);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Internal helpers
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
async function fetchJson(url, init, timeoutMs) {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
32
|
+
clearTimeout(timeoutId);
|
|
33
|
+
const body = await response.json();
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const errorBody = body;
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: {
|
|
39
|
+
error: errorBody.error ?? "Unknown error",
|
|
40
|
+
detail: errorBody.detail ?? "",
|
|
41
|
+
},
|
|
42
|
+
status: response.status,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { ok: true, data: body };
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
clearTimeout(timeoutId);
|
|
49
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
error: { error: "Network error", detail: message },
|
|
53
|
+
status: 0,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function buildHeaders(extraHeaders) {
|
|
58
|
+
return {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
Accept: "application/json",
|
|
61
|
+
...extraHeaders,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Client factory
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Create a typed HTTP client for the agent-sim-bridge server.
|
|
69
|
+
*
|
|
70
|
+
* @param config - Client configuration including base URL.
|
|
71
|
+
* @returns An AgentSimBridgeClient instance.
|
|
72
|
+
*/
|
|
73
|
+
export function createAgentSimBridgeClient(config) {
|
|
74
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
75
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
76
|
+
return {
|
|
77
|
+
async createSimulation(simConfig) {
|
|
78
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: baseHeaders,
|
|
81
|
+
body: JSON.stringify(simConfig),
|
|
82
|
+
}, timeoutMs);
|
|
83
|
+
},
|
|
84
|
+
async transferToReality(options) {
|
|
85
|
+
return fetchJson(`${baseUrl}/sim-bridge/transfer/sim-to-real`, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: baseHeaders,
|
|
88
|
+
body: JSON.stringify(options),
|
|
89
|
+
}, timeoutMs);
|
|
90
|
+
},
|
|
91
|
+
async estimateGap(request) {
|
|
92
|
+
return fetchJson(`${baseUrl}/sim-bridge/gap/estimate`, {
|
|
93
|
+
method: "POST",
|
|
94
|
+
headers: baseHeaders,
|
|
95
|
+
body: JSON.stringify(request),
|
|
96
|
+
}, timeoutMs);
|
|
97
|
+
},
|
|
98
|
+
async getSimResults(options) {
|
|
99
|
+
const params = new URLSearchParams();
|
|
100
|
+
params.set("environment_id", options.environment_id);
|
|
101
|
+
if (options.run_id !== undefined) {
|
|
102
|
+
params.set("run_id", options.run_id);
|
|
103
|
+
}
|
|
104
|
+
if (options.limit !== undefined) {
|
|
105
|
+
params.set("limit", String(options.limit));
|
|
106
|
+
}
|
|
107
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations/results?${params.toString()}`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
108
|
+
},
|
|
109
|
+
async configureRandomization(request) {
|
|
110
|
+
return fetchJson(`${baseUrl}/sim-bridge/randomization/apply`, {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: baseHeaders,
|
|
113
|
+
body: JSON.stringify(request),
|
|
114
|
+
}, timeoutMs);
|
|
115
|
+
},
|
|
116
|
+
async listSimulations(options) {
|
|
117
|
+
const params = new URLSearchParams();
|
|
118
|
+
if (options?.backend !== undefined) {
|
|
119
|
+
params.set("backend", options.backend);
|
|
120
|
+
}
|
|
121
|
+
if (options?.limit !== undefined) {
|
|
122
|
+
params.set("limit", String(options.limit));
|
|
123
|
+
}
|
|
124
|
+
const query = params.toString();
|
|
125
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations${query ? `?${query}` : ""}`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
126
|
+
},
|
|
127
|
+
async getTransferConfig(environmentId) {
|
|
128
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/transfer-config`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
129
|
+
},
|
|
130
|
+
async updateTransferConfig(environmentId, transferConfig) {
|
|
131
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/transfer-config`, {
|
|
132
|
+
method: "PUT",
|
|
133
|
+
headers: baseHeaders,
|
|
134
|
+
body: JSON.stringify(transferConfig),
|
|
135
|
+
}, timeoutMs);
|
|
136
|
+
},
|
|
137
|
+
async listRandomizations(environmentId) {
|
|
138
|
+
return fetchJson(`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/randomizations`, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA+BH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,KAAK,UAAU,SAAS,CACtB,GAAW,EACX,IAAiB,EACjB,SAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAElE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,YAAY,CAAC,SAAS,CAAC,CAAC;QAExB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAa,CAAC;QAE9C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,IAAyB,CAAC;YAC5C,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE;oBACL,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,eAAe;oBACzC,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,EAAE;iBAC/B;gBACD,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAS,EAAE,CAAC;IACvC,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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sim-bridge
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sim-bridge sim-to-real transfer layer.
|
|
5
|
+
* Provides HTTP client, simulation environment management, domain randomization,
|
|
6
|
+
* gap estimation, and reality adapter type definitions.
|
|
7
|
+
*/
|
|
8
|
+
export type { AgentSimBridgeClient, AgentSimBridgeClientConfig } from "./client.js";
|
|
9
|
+
export { createAgentSimBridgeClient } from "./client.js";
|
|
10
|
+
export type { ApiError, ApiResult, DistributionType, DomainRandomization, EnvironmentInfo, GapDimension, GapEstimation, GapEstimationRequest, GapEstimationResult, GapMetric, RandomizationRequest, RandomizationResult, SimResult, SimulationConfig, SimulationEnvironment, SpaceSpec, TransferConfig, TransferResult, } from "./types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EACV,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sim-bridge
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sim-bridge sim-to-real transfer layer.
|
|
5
|
+
* Provides HTTP client, simulation environment management, domain randomization,
|
|
6
|
+
* gap estimation, and reality adapter type definitions.
|
|
7
|
+
*/
|
|
8
|
+
export { createAgentSimBridgeClient } from "./client.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sim-bridge sim-to-real transfer layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sim_bridge.environment.base (SpaceSpec, EnvironmentInfo)
|
|
6
|
+
* agent_sim_bridge.environment.sim_env (SimulationEnvironment)
|
|
7
|
+
* agent_sim_bridge.transfer.bridge (CalibrationProfile)
|
|
8
|
+
* agent_sim_bridge.transfer.domain_randomization (DistributionType, RandomizationConfig)
|
|
9
|
+
* agent_sim_bridge.gap.estimator (GapMetric, GapDimension, DimensionGap)
|
|
10
|
+
* agent_sim_bridge.staging.results (SimResult)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Describes a continuous box space (observation or action).
|
|
16
|
+
* Maps to SpaceSpec Pydantic model in Python.
|
|
17
|
+
*/
|
|
18
|
+
export interface SpaceSpec {
|
|
19
|
+
/**
|
|
20
|
+
* Dimensionality tuple (e.g. [3] for a 3-vector, [84, 84, 3] for an image).
|
|
21
|
+
* Represented as an array in TypeScript.
|
|
22
|
+
*/
|
|
23
|
+
readonly shape: readonly number[];
|
|
24
|
+
/** Per-dimension lower bounds. null means negative infinity. */
|
|
25
|
+
readonly low: readonly number[] | null;
|
|
26
|
+
/** Per-dimension upper bounds. null means positive infinity. */
|
|
27
|
+
readonly high: readonly number[] | null;
|
|
28
|
+
/** Numpy dtype string, e.g. "float32". */
|
|
29
|
+
readonly dtype: string;
|
|
30
|
+
}
|
|
31
|
+
/** Metadata describing an environment instance. */
|
|
32
|
+
export interface EnvironmentInfo {
|
|
33
|
+
/** Human-readable identifier. */
|
|
34
|
+
readonly name: string;
|
|
35
|
+
/** Semantic version string. */
|
|
36
|
+
readonly version: string;
|
|
37
|
+
/** True for simulation environments, false for real-world. */
|
|
38
|
+
readonly is_simulation: boolean;
|
|
39
|
+
/** Maximum allowed steps per episode before truncation. */
|
|
40
|
+
readonly max_episode_steps: number;
|
|
41
|
+
/** Arbitrary key/value metadata. */
|
|
42
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Describes a simulation environment configuration.
|
|
46
|
+
* Corresponds to the SimulationEnvironment class in Python.
|
|
47
|
+
*/
|
|
48
|
+
export interface SimulationEnvironment {
|
|
49
|
+
/** Unique identifier for this simulation environment. */
|
|
50
|
+
readonly environment_id: string;
|
|
51
|
+
/** Metadata about this environment instance. */
|
|
52
|
+
readonly info: EnvironmentInfo;
|
|
53
|
+
/** Description of the observation (state) space. */
|
|
54
|
+
readonly state_space: SpaceSpec;
|
|
55
|
+
/** Description of the action space. */
|
|
56
|
+
readonly action_space: SpaceSpec;
|
|
57
|
+
/** Whether trajectory recording is enabled. */
|
|
58
|
+
readonly record_trajectories: boolean;
|
|
59
|
+
/** ISO-8601 UTC timestamp when this environment was created. */
|
|
60
|
+
readonly created_at: string;
|
|
61
|
+
}
|
|
62
|
+
/** Configuration for creating a simulation environment. */
|
|
63
|
+
export interface SimulationConfig {
|
|
64
|
+
/** The backend to use (e.g. "pybullet", "gazebo", "generic"). */
|
|
65
|
+
readonly backend: string;
|
|
66
|
+
/** Human-readable name for this environment instance. */
|
|
67
|
+
readonly name?: string;
|
|
68
|
+
/** Episode truncation limit. */
|
|
69
|
+
readonly max_episode_steps?: number;
|
|
70
|
+
/** Whether to enable trajectory recording. */
|
|
71
|
+
readonly record_trajectories?: boolean;
|
|
72
|
+
/** Backend-specific configuration parameters. */
|
|
73
|
+
readonly backend_config?: Readonly<Record<string, unknown>>;
|
|
74
|
+
}
|
|
75
|
+
/** The result of a simulation episode or step. */
|
|
76
|
+
export interface SimResult {
|
|
77
|
+
/** Unique identifier for this simulation run. */
|
|
78
|
+
readonly run_id: string;
|
|
79
|
+
/** The environment that produced this result. */
|
|
80
|
+
readonly environment_id: string;
|
|
81
|
+
/** Total number of steps completed in this episode. */
|
|
82
|
+
readonly total_steps: number;
|
|
83
|
+
/** Cumulative reward over the episode. */
|
|
84
|
+
readonly total_reward: number;
|
|
85
|
+
/** Whether the episode ended due to a terminal state. */
|
|
86
|
+
readonly terminated: boolean;
|
|
87
|
+
/** Whether the episode ended due to truncation. */
|
|
88
|
+
readonly truncated: boolean;
|
|
89
|
+
/** ISO-8601 UTC timestamp when the episode ended. */
|
|
90
|
+
readonly completed_at: string;
|
|
91
|
+
/** Arbitrary diagnostic information. */
|
|
92
|
+
readonly info: Readonly<Record<string, unknown>>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Encodes a linear sim-to-real calibration transform.
|
|
96
|
+
* Maps to CalibrationProfile dataclass in Python.
|
|
97
|
+
*
|
|
98
|
+
* Each dimension i transforms as: real[i] = sim[i] * scale_factors[i] + offsets[i]
|
|
99
|
+
*/
|
|
100
|
+
export interface TransferConfig {
|
|
101
|
+
/** Per-dimension multiplicative scale factors. */
|
|
102
|
+
readonly scale_factors: readonly number[];
|
|
103
|
+
/** Per-dimension additive offsets (applied after scaling). */
|
|
104
|
+
readonly offsets: readonly number[];
|
|
105
|
+
/** Optional name of the noise model to apply after transformation. */
|
|
106
|
+
readonly noise_model: string | null;
|
|
107
|
+
/** Optional human-readable labels for each dimension. */
|
|
108
|
+
readonly dimension_names: readonly string[];
|
|
109
|
+
/** Arbitrary annotations (e.g. calibration date, sensor serial numbers). */
|
|
110
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
111
|
+
}
|
|
112
|
+
/** Result of a sim-to-real transfer operation. */
|
|
113
|
+
export interface TransferResult {
|
|
114
|
+
/** The configuration used for the transfer. */
|
|
115
|
+
readonly config: TransferConfig;
|
|
116
|
+
/** Input values (simulation units). */
|
|
117
|
+
readonly sim_values: readonly number[];
|
|
118
|
+
/** Output values (real-world units). */
|
|
119
|
+
readonly real_values: readonly number[];
|
|
120
|
+
/** ISO-8601 UTC timestamp of the transfer. */
|
|
121
|
+
readonly transferred_at: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Supported sampling distributions for domain randomization.
|
|
125
|
+
* Maps to DistributionType enum in Python.
|
|
126
|
+
*/
|
|
127
|
+
export type DistributionType = "uniform" | "gaussian" | "log_uniform" | "constant";
|
|
128
|
+
/**
|
|
129
|
+
* Specification for randomizing one environment parameter.
|
|
130
|
+
* Maps to RandomizationConfig dataclass in Python.
|
|
131
|
+
*/
|
|
132
|
+
export interface DomainRandomization {
|
|
133
|
+
/**
|
|
134
|
+
* Dot-path name of the parameter to randomize.
|
|
135
|
+
* e.g. "physics.gravity" or "sensor.noise_std".
|
|
136
|
+
*/
|
|
137
|
+
readonly parameter_name: string;
|
|
138
|
+
/** Sampling distribution to use. */
|
|
139
|
+
readonly distribution: DistributionType;
|
|
140
|
+
/** Lower bound (or mean for GAUSSIAN, or constant value for CONSTANT). */
|
|
141
|
+
readonly low: number;
|
|
142
|
+
/** Upper bound (or std dev for GAUSSIAN). */
|
|
143
|
+
readonly high: number;
|
|
144
|
+
/** Optional hard minimum applied after sampling. */
|
|
145
|
+
readonly clip_low: number | null;
|
|
146
|
+
/** Optional hard maximum applied after sampling. */
|
|
147
|
+
readonly clip_high: number | null;
|
|
148
|
+
/** Arbitrary annotations. */
|
|
149
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
150
|
+
}
|
|
151
|
+
/** Configuration for applying a set of domain randomizations. */
|
|
152
|
+
export interface RandomizationRequest {
|
|
153
|
+
/** The environment identifier to apply randomizations to. */
|
|
154
|
+
readonly environment_id: string;
|
|
155
|
+
/** The randomization specifications to apply. */
|
|
156
|
+
readonly randomizations: readonly DomainRandomization[];
|
|
157
|
+
/** Optional RNG seed for reproducibility. */
|
|
158
|
+
readonly seed?: number;
|
|
159
|
+
}
|
|
160
|
+
/** Result of applying domain randomizations to an environment. */
|
|
161
|
+
export interface RandomizationResult {
|
|
162
|
+
/** The environment that was randomized. */
|
|
163
|
+
readonly environment_id: string;
|
|
164
|
+
/** The sampled parameter values (parameter_name -> sampled_value). */
|
|
165
|
+
readonly sampled_parameters: Readonly<Record<string, number>>;
|
|
166
|
+
/** ISO-8601 UTC timestamp of when randomization was applied. */
|
|
167
|
+
readonly applied_at: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Statistical distance metric for comparing distributions.
|
|
171
|
+
* Maps to GapMetric enum in Python.
|
|
172
|
+
*/
|
|
173
|
+
export type GapMetric = "KL_DIVERGENCE" | "WASSERSTEIN" | "MMD" | "JENSEN_SHANNON";
|
|
174
|
+
/**
|
|
175
|
+
* A named pair of sim and real distributions for one observable dimension.
|
|
176
|
+
* Maps to GapDimension frozen dataclass in Python.
|
|
177
|
+
*/
|
|
178
|
+
export interface GapDimension {
|
|
179
|
+
/** Human-readable label (e.g. "joint_velocity_0"). */
|
|
180
|
+
readonly name: string;
|
|
181
|
+
/** Empirical distribution collected in simulation. */
|
|
182
|
+
readonly sim_distribution: readonly number[];
|
|
183
|
+
/** Empirical distribution collected on the real system. */
|
|
184
|
+
readonly real_distribution: readonly number[];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The gap value for one metric applied to one dimension.
|
|
188
|
+
* Maps to DimensionGap frozen dataclass in Python.
|
|
189
|
+
*/
|
|
190
|
+
export interface GapEstimation {
|
|
191
|
+
/** The name of the GapDimension this result belongs to. */
|
|
192
|
+
readonly dimension_name: string;
|
|
193
|
+
/** The GapMetric used to compute the value. */
|
|
194
|
+
readonly metric: GapMetric;
|
|
195
|
+
/** The computed distance value. */
|
|
196
|
+
readonly value: number;
|
|
197
|
+
/** Qualitative severity: "low", "medium", or "high". */
|
|
198
|
+
readonly interpretation: string;
|
|
199
|
+
}
|
|
200
|
+
/** Request for estimating the sim-to-real gap across dimensions. */
|
|
201
|
+
export interface GapEstimationRequest {
|
|
202
|
+
/** Dimensions to analyse. */
|
|
203
|
+
readonly dimensions: readonly GapDimension[];
|
|
204
|
+
/** Metrics to compute (defaults to all four if omitted). */
|
|
205
|
+
readonly metrics?: readonly GapMetric[];
|
|
206
|
+
}
|
|
207
|
+
/** Full result of a sim-to-real gap estimation run. */
|
|
208
|
+
export interface GapEstimationResult {
|
|
209
|
+
/** Per-dimension gap results, indexed by dimension name. */
|
|
210
|
+
readonly dimension_gaps: Readonly<Record<string, readonly GapEstimation[]>>;
|
|
211
|
+
/** Weighted average gap score in [0, 1]. */
|
|
212
|
+
readonly overall_gap_score: number;
|
|
213
|
+
/** ISO-8601 UTC timestamp when the estimation was computed. */
|
|
214
|
+
readonly estimated_at: string;
|
|
215
|
+
}
|
|
216
|
+
/** Standard error payload returned by the agent-sim-bridge API. */
|
|
217
|
+
export interface ApiError {
|
|
218
|
+
readonly error: string;
|
|
219
|
+
readonly detail: string;
|
|
220
|
+
}
|
|
221
|
+
/** Result type for all client operations. */
|
|
222
|
+
export type ApiResult<T> = {
|
|
223
|
+
readonly ok: true;
|
|
224
|
+
readonly data: T;
|
|
225
|
+
} | {
|
|
226
|
+
readonly ok: false;
|
|
227
|
+
readonly error: ApiError;
|
|
228
|
+
readonly status: number;
|
|
229
|
+
};
|
|
230
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;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EAAE,CAAC,CAAC,CAAC;IAC5E,4CAA4C;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAMD,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACvC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sim-bridge sim-to-real transfer layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sim_bridge.environment.base (SpaceSpec, EnvironmentInfo)
|
|
6
|
+
* agent_sim_bridge.environment.sim_env (SimulationEnvironment)
|
|
7
|
+
* agent_sim_bridge.transfer.bridge (CalibrationProfile)
|
|
8
|
+
* agent_sim_bridge.transfer.domain_randomization (DistributionType, RandomizationConfig)
|
|
9
|
+
* agent_sim_bridge.gap.estimator (GapMetric, GapDimension, DimensionGap)
|
|
10
|
+
* agent_sim_bridge.staging.results (SimResult)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aumos/agent-sim-bridge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for the AumOS agent-sim-bridge sim-to-real transfer layer — simulation environments, domain randomization, gap estimation, and reality adapters",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.3.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"aumos",
|
|
24
|
+
"agent-sim-bridge",
|
|
25
|
+
"simulation",
|
|
26
|
+
"sim-to-real",
|
|
27
|
+
"domain-randomization",
|
|
28
|
+
"gap-estimation",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/aumos-ai/agent-sim-bridge"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-sim-bridge sim-to-real transfer API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentSimBridgeClient } from "@aumos/agent-sim-bridge";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentSimBridgeClient({ baseUrl: "http://localhost:8094" });
|
|
12
|
+
*
|
|
13
|
+
* const sim = await client.createSimulation({
|
|
14
|
+
* backend: "pybullet",
|
|
15
|
+
* name: "manipulation-v1",
|
|
16
|
+
* max_episode_steps: 500,
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (sim.ok) {
|
|
20
|
+
* console.log("Simulation created:", sim.data.environment_id);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
ApiError,
|
|
27
|
+
ApiResult,
|
|
28
|
+
DomainRandomization,
|
|
29
|
+
GapEstimationRequest,
|
|
30
|
+
GapEstimationResult,
|
|
31
|
+
RandomizationRequest,
|
|
32
|
+
RandomizationResult,
|
|
33
|
+
SimResult,
|
|
34
|
+
SimulationConfig,
|
|
35
|
+
SimulationEnvironment,
|
|
36
|
+
TransferConfig,
|
|
37
|
+
TransferResult,
|
|
38
|
+
} from "./types.js";
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Client configuration
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/** Configuration options for the AgentSimBridgeClient. */
|
|
45
|
+
export interface AgentSimBridgeClientConfig {
|
|
46
|
+
/** Base URL of the agent-sim-bridge server (e.g. "http://localhost:8094"). */
|
|
47
|
+
readonly baseUrl: string;
|
|
48
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
49
|
+
readonly timeoutMs?: number;
|
|
50
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
51
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Internal helpers
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
async function fetchJson<T>(
|
|
59
|
+
url: string,
|
|
60
|
+
init: RequestInit,
|
|
61
|
+
timeoutMs: number,
|
|
62
|
+
): Promise<ApiResult<T>> {
|
|
63
|
+
const controller = new AbortController();
|
|
64
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
68
|
+
clearTimeout(timeoutId);
|
|
69
|
+
|
|
70
|
+
const body = await response.json() as unknown;
|
|
71
|
+
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
const errorBody = body as Partial<ApiError>;
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
error: {
|
|
77
|
+
error: errorBody.error ?? "Unknown error",
|
|
78
|
+
detail: errorBody.detail ?? "",
|
|
79
|
+
},
|
|
80
|
+
status: response.status,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return { ok: true, data: body as T };
|
|
85
|
+
} catch (err: unknown) {
|
|
86
|
+
clearTimeout(timeoutId);
|
|
87
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
error: { error: "Network error", detail: message },
|
|
91
|
+
status: 0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function buildHeaders(
|
|
97
|
+
extraHeaders: Readonly<Record<string, string>> | undefined,
|
|
98
|
+
): Record<string, string> {
|
|
99
|
+
return {
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
Accept: "application/json",
|
|
102
|
+
...extraHeaders,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// Client interface
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
/** Typed HTTP client for the agent-sim-bridge server. */
|
|
111
|
+
export interface AgentSimBridgeClient {
|
|
112
|
+
/**
|
|
113
|
+
* Create and register a new simulation environment.
|
|
114
|
+
*
|
|
115
|
+
* @param config - Simulation configuration including backend and episode settings.
|
|
116
|
+
* @returns The created SimulationEnvironment descriptor.
|
|
117
|
+
*/
|
|
118
|
+
createSimulation(
|
|
119
|
+
config: SimulationConfig,
|
|
120
|
+
): Promise<ApiResult<SimulationEnvironment>>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Transfer simulation values to real-world units using a calibration profile.
|
|
124
|
+
*
|
|
125
|
+
* @param options - Transfer configuration and simulation values to transform.
|
|
126
|
+
* @returns A TransferResult with transformed real-world values.
|
|
127
|
+
*/
|
|
128
|
+
transferToReality(options: {
|
|
129
|
+
config: TransferConfig;
|
|
130
|
+
sim_values: readonly number[];
|
|
131
|
+
}): Promise<ApiResult<TransferResult>>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Estimate the sim-to-real distribution gap across multiple dimensions.
|
|
135
|
+
*
|
|
136
|
+
* @param request - Gap estimation request with dimensions and metric selection.
|
|
137
|
+
* @returns A GapEstimationResult with per-dimension gaps and overall score.
|
|
138
|
+
*/
|
|
139
|
+
estimateGap(
|
|
140
|
+
request: GapEstimationRequest,
|
|
141
|
+
): Promise<ApiResult<GapEstimationResult>>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get the results for a completed simulation episode.
|
|
145
|
+
*
|
|
146
|
+
* @param options - Environment ID and optional run ID filter.
|
|
147
|
+
* @returns Array of SimResult records ordered by completion time descending.
|
|
148
|
+
*/
|
|
149
|
+
getSimResults(options: {
|
|
150
|
+
environment_id: string;
|
|
151
|
+
run_id?: string;
|
|
152
|
+
limit?: number;
|
|
153
|
+
}): Promise<ApiResult<readonly SimResult[]>>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Configure and apply domain randomization to a simulation environment.
|
|
157
|
+
*
|
|
158
|
+
* @param request - Randomization request with environment ID and parameter specs.
|
|
159
|
+
* @returns A RandomizationResult with the sampled parameter values.
|
|
160
|
+
*/
|
|
161
|
+
configureRandomization(
|
|
162
|
+
request: RandomizationRequest,
|
|
163
|
+
): Promise<ApiResult<RandomizationResult>>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* List all registered simulation environments.
|
|
167
|
+
*
|
|
168
|
+
* @param options - Optional filter parameters.
|
|
169
|
+
* @returns Array of SimulationEnvironment descriptors.
|
|
170
|
+
*/
|
|
171
|
+
listSimulations(options?: {
|
|
172
|
+
backend?: string;
|
|
173
|
+
limit?: number;
|
|
174
|
+
}): Promise<ApiResult<readonly SimulationEnvironment[]>>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Get the transfer configuration (calibration profile) for an environment.
|
|
178
|
+
*
|
|
179
|
+
* @param environmentId - The simulation environment identifier.
|
|
180
|
+
* @returns The TransferConfig describing the linear sim-to-real transform.
|
|
181
|
+
*/
|
|
182
|
+
getTransferConfig(
|
|
183
|
+
environmentId: string,
|
|
184
|
+
): Promise<ApiResult<TransferConfig>>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Update the transfer configuration for a simulation environment.
|
|
188
|
+
*
|
|
189
|
+
* @param environmentId - The simulation environment identifier.
|
|
190
|
+
* @param config - The new TransferConfig to apply.
|
|
191
|
+
* @returns The updated TransferConfig.
|
|
192
|
+
*/
|
|
193
|
+
updateTransferConfig(
|
|
194
|
+
environmentId: string,
|
|
195
|
+
config: TransferConfig,
|
|
196
|
+
): Promise<ApiResult<TransferConfig>>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* List the randomization configurations for a simulation environment.
|
|
200
|
+
*
|
|
201
|
+
* @param environmentId - The simulation environment identifier.
|
|
202
|
+
* @returns Array of DomainRandomization specifications.
|
|
203
|
+
*/
|
|
204
|
+
listRandomizations(
|
|
205
|
+
environmentId: string,
|
|
206
|
+
): Promise<ApiResult<readonly DomainRandomization[]>>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
// Client factory
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Create a typed HTTP client for the agent-sim-bridge server.
|
|
215
|
+
*
|
|
216
|
+
* @param config - Client configuration including base URL.
|
|
217
|
+
* @returns An AgentSimBridgeClient instance.
|
|
218
|
+
*/
|
|
219
|
+
export function createAgentSimBridgeClient(
|
|
220
|
+
config: AgentSimBridgeClientConfig,
|
|
221
|
+
): AgentSimBridgeClient {
|
|
222
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
223
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
async createSimulation(
|
|
227
|
+
simConfig: SimulationConfig,
|
|
228
|
+
): Promise<ApiResult<SimulationEnvironment>> {
|
|
229
|
+
return fetchJson<SimulationEnvironment>(
|
|
230
|
+
`${baseUrl}/sim-bridge/simulations`,
|
|
231
|
+
{
|
|
232
|
+
method: "POST",
|
|
233
|
+
headers: baseHeaders,
|
|
234
|
+
body: JSON.stringify(simConfig),
|
|
235
|
+
},
|
|
236
|
+
timeoutMs,
|
|
237
|
+
);
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
async transferToReality(options: {
|
|
241
|
+
config: TransferConfig;
|
|
242
|
+
sim_values: readonly number[];
|
|
243
|
+
}): Promise<ApiResult<TransferResult>> {
|
|
244
|
+
return fetchJson<TransferResult>(
|
|
245
|
+
`${baseUrl}/sim-bridge/transfer/sim-to-real`,
|
|
246
|
+
{
|
|
247
|
+
method: "POST",
|
|
248
|
+
headers: baseHeaders,
|
|
249
|
+
body: JSON.stringify(options),
|
|
250
|
+
},
|
|
251
|
+
timeoutMs,
|
|
252
|
+
);
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
async estimateGap(
|
|
256
|
+
request: GapEstimationRequest,
|
|
257
|
+
): Promise<ApiResult<GapEstimationResult>> {
|
|
258
|
+
return fetchJson<GapEstimationResult>(
|
|
259
|
+
`${baseUrl}/sim-bridge/gap/estimate`,
|
|
260
|
+
{
|
|
261
|
+
method: "POST",
|
|
262
|
+
headers: baseHeaders,
|
|
263
|
+
body: JSON.stringify(request),
|
|
264
|
+
},
|
|
265
|
+
timeoutMs,
|
|
266
|
+
);
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
async getSimResults(options: {
|
|
270
|
+
environment_id: string;
|
|
271
|
+
run_id?: string;
|
|
272
|
+
limit?: number;
|
|
273
|
+
}): Promise<ApiResult<readonly SimResult[]>> {
|
|
274
|
+
const params = new URLSearchParams();
|
|
275
|
+
params.set("environment_id", options.environment_id);
|
|
276
|
+
if (options.run_id !== undefined) {
|
|
277
|
+
params.set("run_id", options.run_id);
|
|
278
|
+
}
|
|
279
|
+
if (options.limit !== undefined) {
|
|
280
|
+
params.set("limit", String(options.limit));
|
|
281
|
+
}
|
|
282
|
+
return fetchJson<readonly SimResult[]>(
|
|
283
|
+
`${baseUrl}/sim-bridge/simulations/results?${params.toString()}`,
|
|
284
|
+
{ method: "GET", headers: baseHeaders },
|
|
285
|
+
timeoutMs,
|
|
286
|
+
);
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
async configureRandomization(
|
|
290
|
+
request: RandomizationRequest,
|
|
291
|
+
): Promise<ApiResult<RandomizationResult>> {
|
|
292
|
+
return fetchJson<RandomizationResult>(
|
|
293
|
+
`${baseUrl}/sim-bridge/randomization/apply`,
|
|
294
|
+
{
|
|
295
|
+
method: "POST",
|
|
296
|
+
headers: baseHeaders,
|
|
297
|
+
body: JSON.stringify(request),
|
|
298
|
+
},
|
|
299
|
+
timeoutMs,
|
|
300
|
+
);
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
async listSimulations(options?: {
|
|
304
|
+
backend?: string;
|
|
305
|
+
limit?: number;
|
|
306
|
+
}): Promise<ApiResult<readonly SimulationEnvironment[]>> {
|
|
307
|
+
const params = new URLSearchParams();
|
|
308
|
+
if (options?.backend !== undefined) {
|
|
309
|
+
params.set("backend", options.backend);
|
|
310
|
+
}
|
|
311
|
+
if (options?.limit !== undefined) {
|
|
312
|
+
params.set("limit", String(options.limit));
|
|
313
|
+
}
|
|
314
|
+
const query = params.toString();
|
|
315
|
+
return fetchJson<readonly SimulationEnvironment[]>(
|
|
316
|
+
`${baseUrl}/sim-bridge/simulations${query ? `?${query}` : ""}`,
|
|
317
|
+
{ method: "GET", headers: baseHeaders },
|
|
318
|
+
timeoutMs,
|
|
319
|
+
);
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
async getTransferConfig(
|
|
323
|
+
environmentId: string,
|
|
324
|
+
): Promise<ApiResult<TransferConfig>> {
|
|
325
|
+
return fetchJson<TransferConfig>(
|
|
326
|
+
`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/transfer-config`,
|
|
327
|
+
{ method: "GET", headers: baseHeaders },
|
|
328
|
+
timeoutMs,
|
|
329
|
+
);
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
async updateTransferConfig(
|
|
333
|
+
environmentId: string,
|
|
334
|
+
transferConfig: TransferConfig,
|
|
335
|
+
): Promise<ApiResult<TransferConfig>> {
|
|
336
|
+
return fetchJson<TransferConfig>(
|
|
337
|
+
`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/transfer-config`,
|
|
338
|
+
{
|
|
339
|
+
method: "PUT",
|
|
340
|
+
headers: baseHeaders,
|
|
341
|
+
body: JSON.stringify(transferConfig),
|
|
342
|
+
},
|
|
343
|
+
timeoutMs,
|
|
344
|
+
);
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
async listRandomizations(
|
|
348
|
+
environmentId: string,
|
|
349
|
+
): Promise<ApiResult<readonly DomainRandomization[]>> {
|
|
350
|
+
return fetchJson<readonly DomainRandomization[]>(
|
|
351
|
+
`${baseUrl}/sim-bridge/simulations/${encodeURIComponent(environmentId)}/randomizations`,
|
|
352
|
+
{ method: "GET", headers: baseHeaders },
|
|
353
|
+
timeoutMs,
|
|
354
|
+
);
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-sim-bridge
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-sim-bridge sim-to-real transfer layer.
|
|
5
|
+
* Provides HTTP client, simulation environment management, domain randomization,
|
|
6
|
+
* gap estimation, and reality adapter type definitions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Client and configuration
|
|
10
|
+
export type { AgentSimBridgeClient, AgentSimBridgeClientConfig } from "./client.js";
|
|
11
|
+
export { createAgentSimBridgeClient } from "./client.js";
|
|
12
|
+
|
|
13
|
+
// Core types
|
|
14
|
+
export type {
|
|
15
|
+
ApiError,
|
|
16
|
+
ApiResult,
|
|
17
|
+
DistributionType,
|
|
18
|
+
DomainRandomization,
|
|
19
|
+
EnvironmentInfo,
|
|
20
|
+
GapDimension,
|
|
21
|
+
GapEstimation,
|
|
22
|
+
GapEstimationRequest,
|
|
23
|
+
GapEstimationResult,
|
|
24
|
+
GapMetric,
|
|
25
|
+
RandomizationRequest,
|
|
26
|
+
RandomizationResult,
|
|
27
|
+
SimResult,
|
|
28
|
+
SimulationConfig,
|
|
29
|
+
SimulationEnvironment,
|
|
30
|
+
SpaceSpec,
|
|
31
|
+
TransferConfig,
|
|
32
|
+
TransferResult,
|
|
33
|
+
} from "./types.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-sim-bridge sim-to-real transfer layer.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python dataclasses and Pydantic models defined in:
|
|
5
|
+
* agent_sim_bridge.environment.base (SpaceSpec, EnvironmentInfo)
|
|
6
|
+
* agent_sim_bridge.environment.sim_env (SimulationEnvironment)
|
|
7
|
+
* agent_sim_bridge.transfer.bridge (CalibrationProfile)
|
|
8
|
+
* agent_sim_bridge.transfer.domain_randomization (DistributionType, RandomizationConfig)
|
|
9
|
+
* agent_sim_bridge.gap.estimator (GapMetric, GapDimension, DimensionGap)
|
|
10
|
+
* agent_sim_bridge.staging.results (SimResult)
|
|
11
|
+
*
|
|
12
|
+
* All interfaces use readonly fields to match Python frozen dataclasses.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Space and environment types
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Describes a continuous box space (observation or action).
|
|
21
|
+
* Maps to SpaceSpec Pydantic model in Python.
|
|
22
|
+
*/
|
|
23
|
+
export interface SpaceSpec {
|
|
24
|
+
/**
|
|
25
|
+
* Dimensionality tuple (e.g. [3] for a 3-vector, [84, 84, 3] for an image).
|
|
26
|
+
* Represented as an array in TypeScript.
|
|
27
|
+
*/
|
|
28
|
+
readonly shape: readonly number[];
|
|
29
|
+
/** Per-dimension lower bounds. null means negative infinity. */
|
|
30
|
+
readonly low: readonly number[] | null;
|
|
31
|
+
/** Per-dimension upper bounds. null means positive infinity. */
|
|
32
|
+
readonly high: readonly number[] | null;
|
|
33
|
+
/** Numpy dtype string, e.g. "float32". */
|
|
34
|
+
readonly dtype: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Metadata describing an environment instance. */
|
|
38
|
+
export interface EnvironmentInfo {
|
|
39
|
+
/** Human-readable identifier. */
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** Semantic version string. */
|
|
42
|
+
readonly version: string;
|
|
43
|
+
/** True for simulation environments, false for real-world. */
|
|
44
|
+
readonly is_simulation: boolean;
|
|
45
|
+
/** Maximum allowed steps per episode before truncation. */
|
|
46
|
+
readonly max_episode_steps: number;
|
|
47
|
+
/** Arbitrary key/value metadata. */
|
|
48
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Simulation environment
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Describes a simulation environment configuration.
|
|
57
|
+
* Corresponds to the SimulationEnvironment class in Python.
|
|
58
|
+
*/
|
|
59
|
+
export interface SimulationEnvironment {
|
|
60
|
+
/** Unique identifier for this simulation environment. */
|
|
61
|
+
readonly environment_id: string;
|
|
62
|
+
/** Metadata about this environment instance. */
|
|
63
|
+
readonly info: EnvironmentInfo;
|
|
64
|
+
/** Description of the observation (state) space. */
|
|
65
|
+
readonly state_space: SpaceSpec;
|
|
66
|
+
/** Description of the action space. */
|
|
67
|
+
readonly action_space: SpaceSpec;
|
|
68
|
+
/** Whether trajectory recording is enabled. */
|
|
69
|
+
readonly record_trajectories: boolean;
|
|
70
|
+
/** ISO-8601 UTC timestamp when this environment was created. */
|
|
71
|
+
readonly created_at: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Configuration for creating a simulation environment. */
|
|
75
|
+
export interface SimulationConfig {
|
|
76
|
+
/** The backend to use (e.g. "pybullet", "gazebo", "generic"). */
|
|
77
|
+
readonly backend: string;
|
|
78
|
+
/** Human-readable name for this environment instance. */
|
|
79
|
+
readonly name?: string;
|
|
80
|
+
/** Episode truncation limit. */
|
|
81
|
+
readonly max_episode_steps?: number;
|
|
82
|
+
/** Whether to enable trajectory recording. */
|
|
83
|
+
readonly record_trajectories?: boolean;
|
|
84
|
+
/** Backend-specific configuration parameters. */
|
|
85
|
+
readonly backend_config?: Readonly<Record<string, unknown>>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Sim result
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
/** The result of a simulation episode or step. */
|
|
93
|
+
export interface SimResult {
|
|
94
|
+
/** Unique identifier for this simulation run. */
|
|
95
|
+
readonly run_id: string;
|
|
96
|
+
/** The environment that produced this result. */
|
|
97
|
+
readonly environment_id: string;
|
|
98
|
+
/** Total number of steps completed in this episode. */
|
|
99
|
+
readonly total_steps: number;
|
|
100
|
+
/** Cumulative reward over the episode. */
|
|
101
|
+
readonly total_reward: number;
|
|
102
|
+
/** Whether the episode ended due to a terminal state. */
|
|
103
|
+
readonly terminated: boolean;
|
|
104
|
+
/** Whether the episode ended due to truncation. */
|
|
105
|
+
readonly truncated: boolean;
|
|
106
|
+
/** ISO-8601 UTC timestamp when the episode ended. */
|
|
107
|
+
readonly completed_at: string;
|
|
108
|
+
/** Arbitrary diagnostic information. */
|
|
109
|
+
readonly info: Readonly<Record<string, unknown>>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Transfer / calibration types
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Encodes a linear sim-to-real calibration transform.
|
|
118
|
+
* Maps to CalibrationProfile dataclass in Python.
|
|
119
|
+
*
|
|
120
|
+
* Each dimension i transforms as: real[i] = sim[i] * scale_factors[i] + offsets[i]
|
|
121
|
+
*/
|
|
122
|
+
export interface TransferConfig {
|
|
123
|
+
/** Per-dimension multiplicative scale factors. */
|
|
124
|
+
readonly scale_factors: readonly number[];
|
|
125
|
+
/** Per-dimension additive offsets (applied after scaling). */
|
|
126
|
+
readonly offsets: readonly number[];
|
|
127
|
+
/** Optional name of the noise model to apply after transformation. */
|
|
128
|
+
readonly noise_model: string | null;
|
|
129
|
+
/** Optional human-readable labels for each dimension. */
|
|
130
|
+
readonly dimension_names: readonly string[];
|
|
131
|
+
/** Arbitrary annotations (e.g. calibration date, sensor serial numbers). */
|
|
132
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Result of a sim-to-real transfer operation. */
|
|
136
|
+
export interface TransferResult {
|
|
137
|
+
/** The configuration used for the transfer. */
|
|
138
|
+
readonly config: TransferConfig;
|
|
139
|
+
/** Input values (simulation units). */
|
|
140
|
+
readonly sim_values: readonly number[];
|
|
141
|
+
/** Output values (real-world units). */
|
|
142
|
+
readonly real_values: readonly number[];
|
|
143
|
+
/** ISO-8601 UTC timestamp of the transfer. */
|
|
144
|
+
readonly transferred_at: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// Domain randomization types
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Supported sampling distributions for domain randomization.
|
|
153
|
+
* Maps to DistributionType enum in Python.
|
|
154
|
+
*/
|
|
155
|
+
export type DistributionType = "uniform" | "gaussian" | "log_uniform" | "constant";
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Specification for randomizing one environment parameter.
|
|
159
|
+
* Maps to RandomizationConfig dataclass in Python.
|
|
160
|
+
*/
|
|
161
|
+
export interface DomainRandomization {
|
|
162
|
+
/**
|
|
163
|
+
* Dot-path name of the parameter to randomize.
|
|
164
|
+
* e.g. "physics.gravity" or "sensor.noise_std".
|
|
165
|
+
*/
|
|
166
|
+
readonly parameter_name: string;
|
|
167
|
+
/** Sampling distribution to use. */
|
|
168
|
+
readonly distribution: DistributionType;
|
|
169
|
+
/** Lower bound (or mean for GAUSSIAN, or constant value for CONSTANT). */
|
|
170
|
+
readonly low: number;
|
|
171
|
+
/** Upper bound (or std dev for GAUSSIAN). */
|
|
172
|
+
readonly high: number;
|
|
173
|
+
/** Optional hard minimum applied after sampling. */
|
|
174
|
+
readonly clip_low: number | null;
|
|
175
|
+
/** Optional hard maximum applied after sampling. */
|
|
176
|
+
readonly clip_high: number | null;
|
|
177
|
+
/** Arbitrary annotations. */
|
|
178
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Configuration for applying a set of domain randomizations. */
|
|
182
|
+
export interface RandomizationRequest {
|
|
183
|
+
/** The environment identifier to apply randomizations to. */
|
|
184
|
+
readonly environment_id: string;
|
|
185
|
+
/** The randomization specifications to apply. */
|
|
186
|
+
readonly randomizations: readonly DomainRandomization[];
|
|
187
|
+
/** Optional RNG seed for reproducibility. */
|
|
188
|
+
readonly seed?: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Result of applying domain randomizations to an environment. */
|
|
192
|
+
export interface RandomizationResult {
|
|
193
|
+
/** The environment that was randomized. */
|
|
194
|
+
readonly environment_id: string;
|
|
195
|
+
/** The sampled parameter values (parameter_name -> sampled_value). */
|
|
196
|
+
readonly sampled_parameters: Readonly<Record<string, number>>;
|
|
197
|
+
/** ISO-8601 UTC timestamp of when randomization was applied. */
|
|
198
|
+
readonly applied_at: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
// Gap estimation types
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Statistical distance metric for comparing distributions.
|
|
207
|
+
* Maps to GapMetric enum in Python.
|
|
208
|
+
*/
|
|
209
|
+
export type GapMetric =
|
|
210
|
+
| "KL_DIVERGENCE"
|
|
211
|
+
| "WASSERSTEIN"
|
|
212
|
+
| "MMD"
|
|
213
|
+
| "JENSEN_SHANNON";
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A named pair of sim and real distributions for one observable dimension.
|
|
217
|
+
* Maps to GapDimension frozen dataclass in Python.
|
|
218
|
+
*/
|
|
219
|
+
export interface GapDimension {
|
|
220
|
+
/** Human-readable label (e.g. "joint_velocity_0"). */
|
|
221
|
+
readonly name: string;
|
|
222
|
+
/** Empirical distribution collected in simulation. */
|
|
223
|
+
readonly sim_distribution: readonly number[];
|
|
224
|
+
/** Empirical distribution collected on the real system. */
|
|
225
|
+
readonly real_distribution: readonly number[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The gap value for one metric applied to one dimension.
|
|
230
|
+
* Maps to DimensionGap frozen dataclass in Python.
|
|
231
|
+
*/
|
|
232
|
+
export interface GapEstimation {
|
|
233
|
+
/** The name of the GapDimension this result belongs to. */
|
|
234
|
+
readonly dimension_name: string;
|
|
235
|
+
/** The GapMetric used to compute the value. */
|
|
236
|
+
readonly metric: GapMetric;
|
|
237
|
+
/** The computed distance value. */
|
|
238
|
+
readonly value: number;
|
|
239
|
+
/** Qualitative severity: "low", "medium", or "high". */
|
|
240
|
+
readonly interpretation: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Request for estimating the sim-to-real gap across dimensions. */
|
|
244
|
+
export interface GapEstimationRequest {
|
|
245
|
+
/** Dimensions to analyse. */
|
|
246
|
+
readonly dimensions: readonly GapDimension[];
|
|
247
|
+
/** Metrics to compute (defaults to all four if omitted). */
|
|
248
|
+
readonly metrics?: readonly GapMetric[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Full result of a sim-to-real gap estimation run. */
|
|
252
|
+
export interface GapEstimationResult {
|
|
253
|
+
/** Per-dimension gap results, indexed by dimension name. */
|
|
254
|
+
readonly dimension_gaps: Readonly<Record<string, readonly GapEstimation[]>>;
|
|
255
|
+
/** Weighted average gap score in [0, 1]. */
|
|
256
|
+
readonly overall_gap_score: number;
|
|
257
|
+
/** ISO-8601 UTC timestamp when the estimation was computed. */
|
|
258
|
+
readonly estimated_at: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
// API result wrapper (shared pattern)
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
|
|
265
|
+
/** Standard error payload returned by the agent-sim-bridge API. */
|
|
266
|
+
export interface ApiError {
|
|
267
|
+
readonly error: string;
|
|
268
|
+
readonly detail: string;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Result type for all client operations. */
|
|
272
|
+
export type ApiResult<T> =
|
|
273
|
+
| { readonly ok: true; readonly data: T }
|
|
274
|
+
| { readonly ok: false; readonly error: ApiError; readonly status: number };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"exactOptionalPropertyTypes": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|