@realtimex/sdk 1.3.5-rc.1 → 1.3.5-rc.2
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/index.d.mts +512 -1
- package/dist/index.d.ts +512 -1
- package/dist/index.js +1536 -2
- package/dist/index.mjs +1511 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1177,6 +1177,516 @@ declare class ContractModule {
|
|
|
1177
1177
|
clearCache(): void;
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
|
+
type ProviderKind = 'gemini' | 'claude' | 'codex';
|
|
1181
|
+
type ContractStrictness = 'compatible' | 'strict';
|
|
1182
|
+
interface ContractCallbackRules {
|
|
1183
|
+
event_id_header?: string;
|
|
1184
|
+
signature_header?: string;
|
|
1185
|
+
signature_algorithm?: string;
|
|
1186
|
+
signature_message?: string;
|
|
1187
|
+
attempt_id_format?: string;
|
|
1188
|
+
idempotency?: string;
|
|
1189
|
+
}
|
|
1190
|
+
interface ContractCapabilityTrigger {
|
|
1191
|
+
event: 'task.trigger';
|
|
1192
|
+
route?: string;
|
|
1193
|
+
payload_template?: Record<string, unknown>;
|
|
1194
|
+
}
|
|
1195
|
+
interface ContractCapability {
|
|
1196
|
+
capability_id: string;
|
|
1197
|
+
name: string;
|
|
1198
|
+
description: string;
|
|
1199
|
+
input_schema: Record<string, unknown>;
|
|
1200
|
+
output_schema?: Record<string, unknown>;
|
|
1201
|
+
permission: string;
|
|
1202
|
+
trigger: ContractCapabilityTrigger;
|
|
1203
|
+
}
|
|
1204
|
+
interface LocalAppContractV1 {
|
|
1205
|
+
contract_version: 'local-app-contract/v1';
|
|
1206
|
+
strictness: ContractStrictness;
|
|
1207
|
+
supported_contract_events: string[];
|
|
1208
|
+
supported_legacy_events?: string[];
|
|
1209
|
+
aliases?: Record<string, string>;
|
|
1210
|
+
status_map?: Record<string, string>;
|
|
1211
|
+
legacy_action_map?: Record<string, string>;
|
|
1212
|
+
callback?: ContractCallbackRules;
|
|
1213
|
+
capabilities?: ContractCapability[];
|
|
1214
|
+
}
|
|
1215
|
+
interface LegacyLocalAppContractShape {
|
|
1216
|
+
id?: string;
|
|
1217
|
+
version?: string;
|
|
1218
|
+
strictness?: ContractStrictness;
|
|
1219
|
+
supported_events?: string[];
|
|
1220
|
+
supported_contract_events?: string[];
|
|
1221
|
+
supported_legacy_events?: string[];
|
|
1222
|
+
aliases?: Record<string, string>;
|
|
1223
|
+
status_map?: Record<string, string>;
|
|
1224
|
+
legacy_action_map?: Record<string, string>;
|
|
1225
|
+
callback?: ContractCallbackRules;
|
|
1226
|
+
capabilities?: ContractCapability[];
|
|
1227
|
+
}
|
|
1228
|
+
interface ContractDiscoveryResponse {
|
|
1229
|
+
success: boolean;
|
|
1230
|
+
contract: LocalAppContractV1 | LegacyLocalAppContractShape;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
interface ProjectToolsInput {
|
|
1234
|
+
contract: LocalAppContractV1;
|
|
1235
|
+
provider: ProviderKind;
|
|
1236
|
+
appId: string;
|
|
1237
|
+
namespace?: string;
|
|
1238
|
+
}
|
|
1239
|
+
interface CanonicalToolDefinition {
|
|
1240
|
+
tool_name: string;
|
|
1241
|
+
title: string;
|
|
1242
|
+
description: string;
|
|
1243
|
+
input_schema: Record<string, unknown>;
|
|
1244
|
+
output_schema?: Record<string, unknown>;
|
|
1245
|
+
permission: string;
|
|
1246
|
+
capability_id: string;
|
|
1247
|
+
trigger: ContractCapability['trigger'];
|
|
1248
|
+
}
|
|
1249
|
+
interface HostToolAdapter<TProviderTool, TProviderToolCall, TProviderResult> {
|
|
1250
|
+
toProviderTools(tools: CanonicalToolDefinition[]): TProviderTool[];
|
|
1251
|
+
fromProviderToolCall(call: TProviderToolCall): {
|
|
1252
|
+
tool_call_id: string;
|
|
1253
|
+
tool_name: string;
|
|
1254
|
+
args: Record<string, unknown>;
|
|
1255
|
+
};
|
|
1256
|
+
toProviderResult(result: {
|
|
1257
|
+
status: 'completed' | 'failed' | 'queued';
|
|
1258
|
+
tool_call_id?: string;
|
|
1259
|
+
task_id?: string;
|
|
1260
|
+
attempt_id?: string;
|
|
1261
|
+
output?: Record<string, unknown>;
|
|
1262
|
+
error?: {
|
|
1263
|
+
code: string;
|
|
1264
|
+
message: string;
|
|
1265
|
+
retryable: boolean;
|
|
1266
|
+
};
|
|
1267
|
+
}): TProviderResult;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
interface ToolCall {
|
|
1271
|
+
tool_call_id: string;
|
|
1272
|
+
tool_name: string;
|
|
1273
|
+
args: Record<string, unknown>;
|
|
1274
|
+
}
|
|
1275
|
+
interface ExecutionContext {
|
|
1276
|
+
appId: string;
|
|
1277
|
+
userId: string;
|
|
1278
|
+
workspaceId?: string;
|
|
1279
|
+
requestId?: string;
|
|
1280
|
+
idempotencyKey?: string;
|
|
1281
|
+
provider?: ProviderKind;
|
|
1282
|
+
namespace?: string;
|
|
1283
|
+
metadata?: Record<string, unknown>;
|
|
1284
|
+
}
|
|
1285
|
+
interface ExecutionResult {
|
|
1286
|
+
status: 'completed' | 'failed' | 'queued';
|
|
1287
|
+
tool_call_id?: string;
|
|
1288
|
+
task_id?: string;
|
|
1289
|
+
attempt_id?: string;
|
|
1290
|
+
output?: Record<string, unknown>;
|
|
1291
|
+
error?: {
|
|
1292
|
+
code: string;
|
|
1293
|
+
message: string;
|
|
1294
|
+
retryable: boolean;
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
type LifecycleEventType = 'task.claimed' | 'task.started' | 'task.progress' | 'task.completed' | 'task.failed' | 'task.canceled';
|
|
1298
|
+
interface RuntimeExecutionEvent {
|
|
1299
|
+
tool_call_id: string;
|
|
1300
|
+
task_id: string;
|
|
1301
|
+
attempt_id?: string;
|
|
1302
|
+
event_type: LifecycleEventType;
|
|
1303
|
+
event_id: string;
|
|
1304
|
+
timestamp: string;
|
|
1305
|
+
payload?: Record<string, unknown>;
|
|
1306
|
+
}
|
|
1307
|
+
interface GetToolsInput {
|
|
1308
|
+
appId: string;
|
|
1309
|
+
provider: ProviderKind;
|
|
1310
|
+
namespace?: string;
|
|
1311
|
+
}
|
|
1312
|
+
interface IngestExecutionEventInput {
|
|
1313
|
+
event?: string;
|
|
1314
|
+
event_type?: string;
|
|
1315
|
+
event_id?: string;
|
|
1316
|
+
task_id?: string;
|
|
1317
|
+
task_uuid?: string;
|
|
1318
|
+
attempt_id?: string | number | null;
|
|
1319
|
+
tool_call_id?: string;
|
|
1320
|
+
timestamp?: string;
|
|
1321
|
+
payload?: Record<string, unknown>;
|
|
1322
|
+
data?: Record<string, unknown>;
|
|
1323
|
+
[key: string]: unknown;
|
|
1324
|
+
}
|
|
1325
|
+
interface ContractRuntimeInterface {
|
|
1326
|
+
getContract(appId: string): Promise<LocalAppContractV1>;
|
|
1327
|
+
getTools(input: GetToolsInput): Promise<CanonicalToolDefinition[]>;
|
|
1328
|
+
executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
|
|
1329
|
+
onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
interface RetryPolicyOptions {
|
|
1333
|
+
maxAttempts?: number;
|
|
1334
|
+
baseDelayMs?: number;
|
|
1335
|
+
maxDelayMs?: number;
|
|
1336
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
1337
|
+
}
|
|
1338
|
+
declare class RetryPolicy {
|
|
1339
|
+
private readonly maxAttempts;
|
|
1340
|
+
private readonly baseDelayMs;
|
|
1341
|
+
private readonly maxDelayMs;
|
|
1342
|
+
private readonly shouldRetry;
|
|
1343
|
+
constructor(options?: RetryPolicyOptions);
|
|
1344
|
+
execute<T>(operation: (attempt: number) => Promise<T>): Promise<T>;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
interface ContractRuntimeOptions {
|
|
1348
|
+
baseUrl: string;
|
|
1349
|
+
appId?: string;
|
|
1350
|
+
appName?: string;
|
|
1351
|
+
apiKey?: string;
|
|
1352
|
+
permissions?: string[];
|
|
1353
|
+
namespace?: string;
|
|
1354
|
+
fetchImpl?: typeof fetch;
|
|
1355
|
+
cacheTtlMs?: number;
|
|
1356
|
+
retry?: RetryPolicyOptions;
|
|
1357
|
+
}
|
|
1358
|
+
declare class ContractRuntime implements ContractRuntimeInterface {
|
|
1359
|
+
private readonly appId?;
|
|
1360
|
+
private readonly appName?;
|
|
1361
|
+
private readonly defaultNamespace?;
|
|
1362
|
+
private readonly contractClient;
|
|
1363
|
+
private readonly toolProjector;
|
|
1364
|
+
private readonly executionStore;
|
|
1365
|
+
private readonly lifecycleReporter;
|
|
1366
|
+
private readonly scopeGuard;
|
|
1367
|
+
private readonly retryPolicy;
|
|
1368
|
+
private readonly httpClient;
|
|
1369
|
+
constructor(options: ContractRuntimeOptions);
|
|
1370
|
+
getContract(appId: string): Promise<LocalAppContractV1>;
|
|
1371
|
+
getTools(input: GetToolsInput): Promise<CanonicalToolDefinition[]>;
|
|
1372
|
+
executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
|
|
1373
|
+
onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
|
|
1374
|
+
ingestExecutionEvent(input: IngestExecutionEventInput): RuntimeExecutionEvent | null;
|
|
1375
|
+
clearCache(): void;
|
|
1376
|
+
private assertAppContext;
|
|
1377
|
+
private buildRegistryKey;
|
|
1378
|
+
private resolveTaskId;
|
|
1379
|
+
private buildTriggerRequestBody;
|
|
1380
|
+
private validateToolArgs;
|
|
1381
|
+
private matchesType;
|
|
1382
|
+
private tryEmitLifecycleEvent;
|
|
1383
|
+
private toFailedResult;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
interface ContractHttpClientConfig {
|
|
1387
|
+
baseUrl: string;
|
|
1388
|
+
appId?: string;
|
|
1389
|
+
appName?: string;
|
|
1390
|
+
apiKey?: string;
|
|
1391
|
+
fetchImpl?: typeof fetch;
|
|
1392
|
+
}
|
|
1393
|
+
declare class ContractHttpClient {
|
|
1394
|
+
private readonly baseUrl;
|
|
1395
|
+
private readonly appId?;
|
|
1396
|
+
private readonly appName?;
|
|
1397
|
+
private readonly apiKey?;
|
|
1398
|
+
private readonly fetchImpl;
|
|
1399
|
+
constructor(config: ContractHttpClientConfig);
|
|
1400
|
+
get<T>(path: string, headers?: HeadersInit): Promise<T>;
|
|
1401
|
+
post<T>(path: string, body: unknown, headers?: HeadersInit): Promise<T>;
|
|
1402
|
+
request<T>(path: string, options?: RequestInit): Promise<T>;
|
|
1403
|
+
private buildHeaders;
|
|
1404
|
+
private parseResponse;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
declare class ContractCache {
|
|
1408
|
+
private readonly ttlMs;
|
|
1409
|
+
private readonly entries;
|
|
1410
|
+
constructor(ttlMs?: number);
|
|
1411
|
+
get(key: string): LocalAppContractV1 | null;
|
|
1412
|
+
set(key: string, value: LocalAppContractV1): void;
|
|
1413
|
+
clear(key?: string): void;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
interface ContractClientOptions {
|
|
1417
|
+
cache?: ContractCache;
|
|
1418
|
+
cacheKey?: string;
|
|
1419
|
+
}
|
|
1420
|
+
declare class ContractClient {
|
|
1421
|
+
private readonly httpClient;
|
|
1422
|
+
private readonly cache;
|
|
1423
|
+
private readonly cacheKey;
|
|
1424
|
+
constructor(httpClient: ContractHttpClient, options?: ContractClientOptions);
|
|
1425
|
+
getLocalAppV1(forceRefresh?: boolean): Promise<LocalAppContractV1>;
|
|
1426
|
+
clearCache(): void;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
declare function normalizeLocalAppContractV1(payload: unknown): LocalAppContractV1;
|
|
1430
|
+
|
|
1431
|
+
declare class ToolProjector {
|
|
1432
|
+
project(input: ProjectToolsInput): CanonicalToolDefinition[];
|
|
1433
|
+
private ensureUniqueToolName;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
declare function normalizeSchema(schema?: Record<string, unknown>): Record<string, unknown>;
|
|
1437
|
+
|
|
1438
|
+
declare function toStableToolName(capabilityId: string, namespace?: string): string;
|
|
1439
|
+
|
|
1440
|
+
declare class ScopeGuard {
|
|
1441
|
+
private readonly scopes;
|
|
1442
|
+
constructor(scopes?: string[]);
|
|
1443
|
+
can(permission?: string): boolean;
|
|
1444
|
+
assert(permission?: string): void;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
interface AuthProvider {
|
|
1448
|
+
buildHeaders(baseHeaders?: Record<string, string>): Record<string, string>;
|
|
1449
|
+
}
|
|
1450
|
+
interface StaticAuthProviderOptions {
|
|
1451
|
+
appId?: string;
|
|
1452
|
+
appName?: string;
|
|
1453
|
+
apiKey?: string;
|
|
1454
|
+
}
|
|
1455
|
+
declare class StaticAuthProvider implements AuthProvider {
|
|
1456
|
+
private readonly appId?;
|
|
1457
|
+
private readonly appName?;
|
|
1458
|
+
private readonly apiKey?;
|
|
1459
|
+
constructor(options?: StaticAuthProviderOptions);
|
|
1460
|
+
buildHeaders(baseHeaders?: Record<string, string>): Record<string, string>;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
declare class ContractError extends Error {
|
|
1464
|
+
readonly code: string;
|
|
1465
|
+
readonly details?: unknown;
|
|
1466
|
+
constructor(code: string, message: string, details?: unknown);
|
|
1467
|
+
}
|
|
1468
|
+
declare class ContractValidationError extends ContractError {
|
|
1469
|
+
constructor(message: string, details?: unknown);
|
|
1470
|
+
}
|
|
1471
|
+
declare class ToolValidationError extends ContractError {
|
|
1472
|
+
constructor(message: string, details?: unknown);
|
|
1473
|
+
}
|
|
1474
|
+
declare class ToolNotFoundError extends ContractError {
|
|
1475
|
+
constructor(toolName: string, details?: unknown);
|
|
1476
|
+
}
|
|
1477
|
+
declare class ScopeDeniedError extends ContractError {
|
|
1478
|
+
constructor(permission: string, details?: unknown);
|
|
1479
|
+
}
|
|
1480
|
+
declare class RuntimeTransportError extends ContractError {
|
|
1481
|
+
readonly statusCode?: number;
|
|
1482
|
+
constructor(message: string, statusCode?: number, details?: unknown);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
interface GeminiFunctionDeclaration {
|
|
1486
|
+
name: string;
|
|
1487
|
+
description?: string;
|
|
1488
|
+
parameters?: Record<string, unknown>;
|
|
1489
|
+
}
|
|
1490
|
+
interface GeminiToolCall {
|
|
1491
|
+
id: string;
|
|
1492
|
+
name: string;
|
|
1493
|
+
args?: Record<string, unknown> | string;
|
|
1494
|
+
}
|
|
1495
|
+
interface GeminiToolResult {
|
|
1496
|
+
tool_call_id: string;
|
|
1497
|
+
status: ExecutionResult['status'];
|
|
1498
|
+
payload: Record<string, unknown>;
|
|
1499
|
+
}
|
|
1500
|
+
declare class GeminiToolAdapter implements HostToolAdapter<GeminiFunctionDeclaration, GeminiToolCall, GeminiToolResult> {
|
|
1501
|
+
toProviderTools(tools: CanonicalToolDefinition[]): GeminiFunctionDeclaration[];
|
|
1502
|
+
fromProviderToolCall(call: GeminiToolCall): ToolCall;
|
|
1503
|
+
toProviderResult(result: ExecutionResult): GeminiToolResult;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
interface ClaudeToolDefinition {
|
|
1507
|
+
name: string;
|
|
1508
|
+
description: string;
|
|
1509
|
+
input_schema: Record<string, unknown>;
|
|
1510
|
+
}
|
|
1511
|
+
interface ClaudeToolCall {
|
|
1512
|
+
id: string;
|
|
1513
|
+
name: string;
|
|
1514
|
+
input?: Record<string, unknown>;
|
|
1515
|
+
}
|
|
1516
|
+
interface ClaudeToolResult {
|
|
1517
|
+
type: 'tool_result';
|
|
1518
|
+
tool_use_id: string;
|
|
1519
|
+
content: string;
|
|
1520
|
+
is_error?: boolean;
|
|
1521
|
+
}
|
|
1522
|
+
declare class ClaudeToolAdapter implements HostToolAdapter<ClaudeToolDefinition, ClaudeToolCall, ClaudeToolResult> {
|
|
1523
|
+
toProviderTools(tools: CanonicalToolDefinition[]): ClaudeToolDefinition[];
|
|
1524
|
+
fromProviderToolCall(call: ClaudeToolCall): ToolCall;
|
|
1525
|
+
toProviderResult(result: ExecutionResult): ClaudeToolResult;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
interface CodexToolDefinition {
|
|
1529
|
+
type: 'function';
|
|
1530
|
+
function: {
|
|
1531
|
+
name: string;
|
|
1532
|
+
description: string;
|
|
1533
|
+
parameters: Record<string, unknown>;
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
interface CodexToolCall {
|
|
1537
|
+
id: string;
|
|
1538
|
+
function: {
|
|
1539
|
+
name: string;
|
|
1540
|
+
arguments?: string | Record<string, unknown>;
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
interface CodexToolResult {
|
|
1544
|
+
tool_call_id: string;
|
|
1545
|
+
output: string;
|
|
1546
|
+
is_error?: boolean;
|
|
1547
|
+
}
|
|
1548
|
+
declare class CodexToolAdapter implements HostToolAdapter<CodexToolDefinition, CodexToolCall, CodexToolResult> {
|
|
1549
|
+
toProviderTools(tools: CanonicalToolDefinition[]): CodexToolDefinition[];
|
|
1550
|
+
fromProviderToolCall(call: CodexToolCall): ToolCall;
|
|
1551
|
+
toProviderResult(result: ExecutionResult): CodexToolResult;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
type ACPToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'other';
|
|
1555
|
+
type ACPToolStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
1556
|
+
interface ACPTextContent {
|
|
1557
|
+
type: 'text';
|
|
1558
|
+
text: string;
|
|
1559
|
+
}
|
|
1560
|
+
interface ACPSessionToolUpdate {
|
|
1561
|
+
type: 'tool_call' | 'tool_call_update';
|
|
1562
|
+
toolCallId: string;
|
|
1563
|
+
title?: string;
|
|
1564
|
+
kind?: ACPToolKind;
|
|
1565
|
+
status: ACPToolStatus;
|
|
1566
|
+
content?: ACPTextContent[];
|
|
1567
|
+
rawInput?: Record<string, unknown>;
|
|
1568
|
+
rawOutput?: Record<string, unknown>;
|
|
1569
|
+
_meta?: Record<string, unknown>;
|
|
1570
|
+
}
|
|
1571
|
+
interface ACPSessionUpdateParams {
|
|
1572
|
+
sessionId: string;
|
|
1573
|
+
update: ACPSessionToolUpdate;
|
|
1574
|
+
}
|
|
1575
|
+
interface ACPNotifier {
|
|
1576
|
+
notify(method: 'session/update', params: ACPSessionUpdateParams): Promise<void>;
|
|
1577
|
+
request?<T = unknown>(method: string, params: Record<string, unknown>): Promise<T>;
|
|
1578
|
+
}
|
|
1579
|
+
interface ACPAdapterContext {
|
|
1580
|
+
sessionId: string;
|
|
1581
|
+
appId: string;
|
|
1582
|
+
userId: string;
|
|
1583
|
+
workspaceId?: string;
|
|
1584
|
+
provider?: 'gemini' | 'claude' | 'codex';
|
|
1585
|
+
namespace?: string;
|
|
1586
|
+
}
|
|
1587
|
+
interface ACPToolInvocation {
|
|
1588
|
+
toolCallId: string;
|
|
1589
|
+
toolName: string;
|
|
1590
|
+
args: Record<string, unknown>;
|
|
1591
|
+
title?: string;
|
|
1592
|
+
kind?: ACPToolKind;
|
|
1593
|
+
}
|
|
1594
|
+
interface ACPExecutionReference {
|
|
1595
|
+
sessionId: string;
|
|
1596
|
+
toolCallId: string;
|
|
1597
|
+
appId: string;
|
|
1598
|
+
userId: string;
|
|
1599
|
+
workspaceId?: string;
|
|
1600
|
+
provider?: 'gemini' | 'claude' | 'codex';
|
|
1601
|
+
namespace?: string;
|
|
1602
|
+
title?: string;
|
|
1603
|
+
kind?: ACPToolKind;
|
|
1604
|
+
}
|
|
1605
|
+
interface PermissionOption {
|
|
1606
|
+
id: string;
|
|
1607
|
+
label: string;
|
|
1608
|
+
kind?: 'allow_once' | 'allow_always' | 'deny_once' | 'deny_always';
|
|
1609
|
+
}
|
|
1610
|
+
interface ACPContractRuntime {
|
|
1611
|
+
executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
|
|
1612
|
+
onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
|
|
1613
|
+
ingestExecutionEvent(input: IngestExecutionEventInput): RuntimeExecutionEvent | null;
|
|
1614
|
+
}
|
|
1615
|
+
interface ACPContractAdapterOptions {
|
|
1616
|
+
runtime: ACPContractRuntime;
|
|
1617
|
+
notifier: ACPNotifier;
|
|
1618
|
+
requestPermission?: boolean;
|
|
1619
|
+
buildPermissionOptions?: (input: ACPToolInvocation) => PermissionOption[];
|
|
1620
|
+
telemetry?: ACPAdapterTelemetrySink;
|
|
1621
|
+
}
|
|
1622
|
+
interface ACPAdapterTelemetryEvent {
|
|
1623
|
+
phase: 'execute' | 'notify' | 'permission' | 'runtime_event' | 'ingest';
|
|
1624
|
+
result: 'ok' | 'failed' | 'skipped';
|
|
1625
|
+
sessionId?: string;
|
|
1626
|
+
toolCallId?: string;
|
|
1627
|
+
toolName?: string;
|
|
1628
|
+
taskId?: string;
|
|
1629
|
+
attemptId?: string;
|
|
1630
|
+
eventId?: string;
|
|
1631
|
+
eventType?: string;
|
|
1632
|
+
status?: ACPToolStatus;
|
|
1633
|
+
error?: string;
|
|
1634
|
+
metadata?: Record<string, unknown>;
|
|
1635
|
+
}
|
|
1636
|
+
interface ACPAdapterTelemetrySink {
|
|
1637
|
+
emit(event: ACPAdapterTelemetryEvent): void | Promise<void>;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
declare class ACPContractAdapter {
|
|
1641
|
+
private readonly runtime;
|
|
1642
|
+
private readonly notifier;
|
|
1643
|
+
private readonly mapper;
|
|
1644
|
+
private readonly permissionBridge;
|
|
1645
|
+
private readonly telemetry;
|
|
1646
|
+
private readonly taskReferences;
|
|
1647
|
+
private readonly toolCallReferences;
|
|
1648
|
+
private readonly runtimeUnsubscribe;
|
|
1649
|
+
constructor(options: ACPContractAdapterOptions);
|
|
1650
|
+
dispose(): void;
|
|
1651
|
+
executeTool(invocation: ACPToolInvocation, context: ACPAdapterContext): Promise<ExecutionResult>;
|
|
1652
|
+
ingestContractCallback(payload: Record<string, unknown>, context: Pick<ACPAdapterContext, 'sessionId'>): RuntimeExecutionEvent | null;
|
|
1653
|
+
private handleRuntimeEvent;
|
|
1654
|
+
private resolveReferenceForEvent;
|
|
1655
|
+
private rememberReference;
|
|
1656
|
+
private cleanupReference;
|
|
1657
|
+
private notify;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
declare class ACPEventMapper {
|
|
1661
|
+
createReference(invocation: ACPToolInvocation, context: ACPAdapterContext): ACPExecutionReference;
|
|
1662
|
+
buildPendingUpdate(invocation: ACPToolInvocation, reference: ACPExecutionReference): ACPSessionUpdateParams;
|
|
1663
|
+
buildResultUpdate(result: ExecutionResult, reference: ACPExecutionReference): ACPSessionUpdateParams;
|
|
1664
|
+
buildLifecycleUpdate(event: RuntimeExecutionEvent, reference: ACPExecutionReference): ACPSessionUpdateParams | null;
|
|
1665
|
+
buildNotifyFailureUpdate(reference: ACPExecutionReference, error: unknown): ACPSessionUpdateParams;
|
|
1666
|
+
mapContractEventStatus(eventType: string): ACPToolStatus | null;
|
|
1667
|
+
private mapExecutionResultStatus;
|
|
1668
|
+
private resolveEventText;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
interface ACPPermissionBridgeOptions {
|
|
1672
|
+
notifier: ACPNotifier;
|
|
1673
|
+
enabled: boolean;
|
|
1674
|
+
buildPermissionOptions?: (input: ACPToolInvocation) => PermissionOption[];
|
|
1675
|
+
}
|
|
1676
|
+
declare class ACPPermissionBridge {
|
|
1677
|
+
private readonly notifier;
|
|
1678
|
+
private readonly enabled;
|
|
1679
|
+
private readonly buildPermissionOptions?;
|
|
1680
|
+
constructor(options: ACPPermissionBridgeOptions);
|
|
1681
|
+
requestToolPermission(invocation: ACPToolInvocation, context: ACPAdapterContext): Promise<boolean>;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
declare class ACPTelemetry {
|
|
1685
|
+
private readonly sink?;
|
|
1686
|
+
constructor(sink?: ACPAdapterTelemetrySink);
|
|
1687
|
+
emit(event: ACPAdapterTelemetryEvent): void;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1180
1690
|
/**
|
|
1181
1691
|
* RealtimeX Local App SDK
|
|
1182
1692
|
*
|
|
@@ -1196,6 +1706,7 @@ declare class RealtimeXSDK {
|
|
|
1196
1706
|
agent: AgentModule;
|
|
1197
1707
|
mcp: MCPModule;
|
|
1198
1708
|
contract: ContractModule;
|
|
1709
|
+
contractRuntime: ContractRuntime;
|
|
1199
1710
|
readonly appId: string;
|
|
1200
1711
|
readonly appName: string | undefined;
|
|
1201
1712
|
readonly apiKey: string | undefined;
|
|
@@ -1230,4 +1741,4 @@ declare class RealtimeXSDK {
|
|
|
1230
1741
|
getAppDataDir(): Promise<string>;
|
|
1231
1742
|
}
|
|
1232
1743
|
|
|
1233
|
-
export { ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, type ContractCallbackMetadata, type ContractEventType, ContractModule, type ContractSignInput, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LocalAppContractDefinition, type LocalAppContractResponse, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, parseAttemptRunId, signContractEvent };
|
|
1744
|
+
export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, type AuthProvider, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
|