@mondaydotcomorg/atp-server 0.20.1 → 0.20.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/controllers/stream.controller.d.ts.map +1 -1
- package/dist/controllers/stream.controller.js +3 -0
- package/dist/controllers/stream.controller.js.map +1 -1
- package/dist/executor/sandbox-builder.d.ts.map +1 -1
- package/dist/executor/sandbox-builder.js +27 -1
- package/dist/executor/sandbox-builder.js.map +1 -1
- package/dist/handlers/execute.handler.d.ts.map +1 -1
- package/dist/handlers/execute.handler.js +1 -0
- package/dist/handlers/execute.handler.js.map +1 -1
- package/dist/index.cjs +26 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/controllers/stream.controller.ts +4 -1
- package/src/executor/sandbox-builder.ts +50 -1
- package/src/handlers/execute.handler.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/atp-server",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Server implementation for Agent Tool Protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"@babel/parser": "^7.26.0",
|
|
50
50
|
"@babel/traverse": "^7.26.0",
|
|
51
51
|
"@babel/types": "^7.26.0",
|
|
52
|
-
"@mondaydotcomorg/atp-compiler": "0.19.
|
|
53
|
-
"@mondaydotcomorg/atp-protocol": "0.19.
|
|
54
|
-
"@mondaydotcomorg/atp-provenance": "0.19.
|
|
55
|
-
"@mondaydotcomorg/atp-providers": "0.19.
|
|
56
|
-
"@mondaydotcomorg/atp-runtime": "0.19.
|
|
52
|
+
"@mondaydotcomorg/atp-compiler": "0.19.17",
|
|
53
|
+
"@mondaydotcomorg/atp-protocol": "0.19.15",
|
|
54
|
+
"@mondaydotcomorg/atp-provenance": "0.19.14",
|
|
55
|
+
"@mondaydotcomorg/atp-providers": "0.19.15",
|
|
56
|
+
"@mondaydotcomorg/atp-runtime": "0.19.14",
|
|
57
57
|
"@opentelemetry/api": "^1.9.0",
|
|
58
58
|
"@opentelemetry/auto-instrumentations-node": "^0.66.0",
|
|
59
59
|
"@opentelemetry/core": "^2.2.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import type { ExecutionConfig } from '@mondaydotcomorg/atp-protocol';
|
|
2
|
+
import type { ExecutionConfig, ATPEvent } from '@mondaydotcomorg/atp-protocol';
|
|
3
3
|
import {
|
|
4
4
|
ExecutionErrorCode,
|
|
5
5
|
validateExecutionConfig,
|
|
@@ -86,6 +86,9 @@ export async function handleExecuteStream(
|
|
|
86
86
|
progressCallback: (message: string, fraction: number) => {
|
|
87
87
|
sendEvent('progress', { message, fraction });
|
|
88
88
|
},
|
|
89
|
+
eventCallback: (event: ATPEvent) => {
|
|
90
|
+
sendEvent(event.type, event.data);
|
|
91
|
+
},
|
|
89
92
|
clientServices: request.config?.clientServices,
|
|
90
93
|
provenanceMode: request.config?.provenanceMode,
|
|
91
94
|
securityPolicies: request.config?.securityPolicies,
|
|
@@ -3,7 +3,10 @@ import type {
|
|
|
3
3
|
APIGroupConfig,
|
|
4
4
|
ClientToolDefinition,
|
|
5
5
|
ToolCallEvent,
|
|
6
|
+
ATPEvent,
|
|
7
|
+
ATPEventType,
|
|
6
8
|
} from '@mondaydotcomorg/atp-protocol';
|
|
9
|
+
import { createToolStartEvent, createToolEndEvent } from '@mondaydotcomorg/atp-protocol';
|
|
7
10
|
import { filterApiGroups } from '../core/request-scope.js';
|
|
8
11
|
import {
|
|
9
12
|
ToolOperationType,
|
|
@@ -41,6 +44,35 @@ import { ReaderPermissions } from '@mondaydotcomorg/atp-server';
|
|
|
41
44
|
import { getHintMap, reattachProvenanceFromHints } from '../utils/provenance-reattachment.js';
|
|
42
45
|
import { createASTProvenanceChecker } from './ast-provenance-bridge.js';
|
|
43
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Creates a non-blocking event emitter for streaming events to clients.
|
|
49
|
+
* Events are fired asynchronously without blocking execution.
|
|
50
|
+
*/
|
|
51
|
+
function createEventEmitter(
|
|
52
|
+
eventCallback?: (event: ATPEvent) => void
|
|
53
|
+
): (
|
|
54
|
+
eventOrType: ATPEvent | ATPEventType | string,
|
|
55
|
+
data?: unknown,
|
|
56
|
+
runId?: string
|
|
57
|
+
) => void {
|
|
58
|
+
return (eventOrType, data, runId) => {
|
|
59
|
+
if (!eventCallback) return;
|
|
60
|
+
|
|
61
|
+
const event: ATPEvent =
|
|
62
|
+
typeof eventOrType === 'string'
|
|
63
|
+
? { type: eventOrType, data, timestamp: Date.now(), runId }
|
|
64
|
+
: eventOrType;
|
|
65
|
+
|
|
66
|
+
setImmediate(() => {
|
|
67
|
+
try {
|
|
68
|
+
eventCallback(event);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
// Silently ignore errors in event callbacks to avoid breaking execution
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
44
76
|
export class SandboxBuilder {
|
|
45
77
|
private policyEngine: SecurityPolicyEngine | null = null;
|
|
46
78
|
|
|
@@ -467,22 +499,39 @@ export class SandboxBuilder {
|
|
|
467
499
|
});
|
|
468
500
|
}
|
|
469
501
|
|
|
502
|
+
const emit = createEventEmitter(config.eventCallback);
|
|
503
|
+
|
|
470
504
|
const handlerContext = {
|
|
471
505
|
metadata: metadata,
|
|
472
506
|
requestContext: config.requestContext,
|
|
507
|
+
emit,
|
|
473
508
|
};
|
|
474
509
|
const toolCallStartTime = Date.now();
|
|
475
510
|
let result: unknown;
|
|
476
511
|
let toolCallError: Error | undefined;
|
|
477
512
|
|
|
513
|
+
emit(createToolStartEvent(func.name, group.name, input));
|
|
514
|
+
|
|
478
515
|
try {
|
|
479
516
|
result = await handler(input, handlerContext);
|
|
480
517
|
} catch (error) {
|
|
481
518
|
toolCallError = error instanceof Error ? error : new Error(String(error));
|
|
482
519
|
throw error;
|
|
483
520
|
} finally {
|
|
521
|
+
const duration = Date.now() - toolCallStartTime;
|
|
522
|
+
|
|
523
|
+
emit(
|
|
524
|
+
createToolEndEvent(
|
|
525
|
+
func.name,
|
|
526
|
+
group.name,
|
|
527
|
+
toolCallError ? undefined : result,
|
|
528
|
+
duration,
|
|
529
|
+
!toolCallError,
|
|
530
|
+
toolCallError?.message
|
|
531
|
+
)
|
|
532
|
+
);
|
|
533
|
+
|
|
484
534
|
if (config.onToolCall) {
|
|
485
|
-
const duration = Date.now() - toolCallStartTime;
|
|
486
535
|
config.onToolCall({
|
|
487
536
|
toolName: func.name,
|
|
488
537
|
apiGroup: group.name,
|