asqend-mcp-contracts 0.3.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/batch-execute.d.ts +29 -0
- package/dist/batch-execute.js +109 -0
- package/dist/definitions.d.ts +1 -0
- package/dist/definitions.js +1 -0
- package/dist/dispatch.d.ts +1 -0
- package/dist/dispatch.js +1 -0
- package/dist/fallback-set.d.ts +1 -0
- package/dist/fallback-set.js +1 -0
- package/dist/generated/hosted.bridge.json +12061 -0
- package/dist/generated/tools.definitions.d.ts +2 -0
- package/dist/generated/tools.definitions.js +6997 -0
- package/dist/generated/tools.dispatch.d.ts +6 -0
- package/dist/generated/tools.dispatch.js +587 -0
- package/dist/generated/tools.fallback-set.d.ts +1 -0
- package/dist/generated/tools.fallback-set.js +9 -0
- package/dist/generated/tools.manifest.json +9957 -0
- package/dist/generated/tools.visibility.d.ts +1 -0
- package/dist/generated/tools.visibility.js +120 -0
- package/dist/generated/tools.write-set.d.ts +1 -0
- package/dist/generated/tools.write-set.js +93 -0
- package/dist/hosted-bridge.d.ts +2 -0
- package/dist/hosted-bridge.js +2 -0
- package/dist/hosted-rollout.d.ts +7 -0
- package/dist/hosted-rollout.js +12 -0
- package/dist/hosted-tools.d.ts +10 -0
- package/dist/hosted-tools.js +180 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +11 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +2 -0
- package/dist/transport-support.d.ts +7 -0
- package/dist/transport-support.js +139 -0
- package/dist/types.d.ts +77 -0
- package/dist/types.js +1 -0
- package/dist/visibility.d.ts +1 -0
- package/dist/visibility.js +1 -0
- package/dist/write-set.d.ts +1 -0
- package/dist/write-set.js +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type BatchOperation = {
|
|
2
|
+
tool: string;
|
|
3
|
+
args: Record<string, unknown>;
|
|
4
|
+
};
|
|
5
|
+
export type BatchOperationResult = {
|
|
6
|
+
index: number;
|
|
7
|
+
tool: string;
|
|
8
|
+
status: 'ok';
|
|
9
|
+
durationMs: number;
|
|
10
|
+
data: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
index: number;
|
|
13
|
+
tool: string;
|
|
14
|
+
status: 'error';
|
|
15
|
+
durationMs: number;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
export interface BatchExecuteResult {
|
|
19
|
+
results: BatchOperationResult[];
|
|
20
|
+
totalMs: number;
|
|
21
|
+
operationCount: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function parseBatchExecuteOperations(input: Record<string, unknown>): BatchOperation[];
|
|
24
|
+
export declare function resolveBatchExecuteConcurrency(input: Record<string, unknown>): number;
|
|
25
|
+
export declare function executeBatchExecuteOperations(args: {
|
|
26
|
+
operations: BatchOperation[];
|
|
27
|
+
concurrency: number;
|
|
28
|
+
executeOperation: (operation: BatchOperation, index: number) => Promise<unknown>;
|
|
29
|
+
}): Promise<BatchExecuteResult>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { generatedWriteTools } from './write-set.js';
|
|
2
|
+
const MAX_BATCH_OPERATIONS = 20;
|
|
3
|
+
const DEFAULT_BATCH_CONCURRENCY = 5;
|
|
4
|
+
const MAX_BATCH_CONCURRENCY = 10;
|
|
5
|
+
export function parseBatchExecuteOperations(input) {
|
|
6
|
+
const operations = input.operations;
|
|
7
|
+
if (!Array.isArray(operations)) {
|
|
8
|
+
throw new Error('batch_execute requires operations[]');
|
|
9
|
+
}
|
|
10
|
+
if (operations.length === 0) {
|
|
11
|
+
throw new Error('batch_execute requires at least one operation');
|
|
12
|
+
}
|
|
13
|
+
if (operations.length > MAX_BATCH_OPERATIONS) {
|
|
14
|
+
throw new Error(`batch_execute supports at most ${MAX_BATCH_OPERATIONS} operations`);
|
|
15
|
+
}
|
|
16
|
+
return operations.map((operation, index) => {
|
|
17
|
+
if (!operation || typeof operation !== 'object' || Array.isArray(operation)) {
|
|
18
|
+
throw new Error(`batch_execute operation ${index} must be an object`);
|
|
19
|
+
}
|
|
20
|
+
const candidate = operation;
|
|
21
|
+
const tool = candidate.tool;
|
|
22
|
+
const args = candidate.args;
|
|
23
|
+
if (typeof tool !== 'string' || tool.trim().length === 0) {
|
|
24
|
+
throw new Error(`batch_execute operation ${index} requires tool`);
|
|
25
|
+
}
|
|
26
|
+
if (args !== undefined &&
|
|
27
|
+
(!args || typeof args !== 'object' || Array.isArray(args))) {
|
|
28
|
+
throw new Error(`batch_execute operation ${index} args must be an object`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
tool: tool.trim(),
|
|
32
|
+
args: args ?? {},
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function resolveBatchExecuteConcurrency(input) {
|
|
37
|
+
const rawConcurrency = input.concurrency;
|
|
38
|
+
if (rawConcurrency === undefined) {
|
|
39
|
+
return DEFAULT_BATCH_CONCURRENCY;
|
|
40
|
+
}
|
|
41
|
+
if (typeof rawConcurrency !== 'number' || !Number.isFinite(rawConcurrency)) {
|
|
42
|
+
throw new Error('batch_execute concurrency must be a finite number');
|
|
43
|
+
}
|
|
44
|
+
return Math.min(Math.max(1, Math.trunc(rawConcurrency)), MAX_BATCH_CONCURRENCY);
|
|
45
|
+
}
|
|
46
|
+
async function mapWithConcurrency(items, concurrency, worker) {
|
|
47
|
+
const results = new Array(items.length);
|
|
48
|
+
let nextIndex = 0;
|
|
49
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
50
|
+
while (true) {
|
|
51
|
+
const currentIndex = nextIndex;
|
|
52
|
+
nextIndex += 1;
|
|
53
|
+
if (currentIndex >= items.length) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
results[currentIndex] = await worker(items[currentIndex], currentIndex);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
await Promise.all(workers);
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
export async function executeBatchExecuteOperations(args) {
|
|
63
|
+
const startedAt = Date.now();
|
|
64
|
+
const results = await mapWithConcurrency(args.operations, args.concurrency, async (operation, index) => {
|
|
65
|
+
if (operation.tool === 'batch_execute') {
|
|
66
|
+
return {
|
|
67
|
+
index,
|
|
68
|
+
tool: operation.tool,
|
|
69
|
+
status: 'error',
|
|
70
|
+
durationMs: 0,
|
|
71
|
+
error: 'batch_execute does not support nested batch_execute operations',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (generatedWriteTools.has(operation.tool)) {
|
|
75
|
+
return {
|
|
76
|
+
index,
|
|
77
|
+
tool: operation.tool,
|
|
78
|
+
status: 'error',
|
|
79
|
+
durationMs: 0,
|
|
80
|
+
error: `batch_execute only supports read tools; ${operation.tool} is a write tool`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const operationStartedAt = Date.now();
|
|
84
|
+
try {
|
|
85
|
+
const data = await args.executeOperation(operation, index);
|
|
86
|
+
return {
|
|
87
|
+
index,
|
|
88
|
+
tool: operation.tool,
|
|
89
|
+
status: 'ok',
|
|
90
|
+
durationMs: Date.now() - operationStartedAt,
|
|
91
|
+
data,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
index,
|
|
97
|
+
tool: operation.tool,
|
|
98
|
+
status: 'error',
|
|
99
|
+
durationMs: Date.now() - operationStartedAt,
|
|
100
|
+
error: error instanceof Error ? error.message : 'Tool call failed',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
results,
|
|
106
|
+
totalMs: Date.now() - startedAt,
|
|
107
|
+
operationCount: args.operations.length,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedToolDefinitions } from './generated/tools.definitions.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedToolDefinitions } from './generated/tools.definitions.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedDispatch } from './generated/tools.dispatch.js';
|
package/dist/dispatch.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedDispatch } from './generated/tools.dispatch.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedFallbackTools } from './generated/tools.fallback-set.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generatedFallbackTools } from './generated/tools.fallback-set.js';
|