@mondaydotcomorg/atp-client 0.19.6 → 0.19.7
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 +23 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -5
- package/dist/client.js.map +1 -1
- package/dist/core/api-operations.d.ts +4 -2
- package/dist/core/api-operations.d.ts.map +1 -1
- package/dist/core/api-operations.js +25 -1
- package/dist/core/api-operations.js.map +1 -1
- package/dist/core/execution-operations.d.ts +4 -2
- package/dist/core/execution-operations.d.ts.map +1 -1
- package/dist/core/execution-operations.js +60 -40
- package/dist/core/execution-operations.js.map +1 -1
- package/dist/core/in-process-session.d.ts +96 -0
- package/dist/core/in-process-session.d.ts.map +1 -0
- package/dist/core/in-process-session.js +175 -0
- package/dist/core/in-process-session.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/session.d.ts +24 -1
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +47 -7
- package/src/core/api-operations.ts +35 -3
- package/src/core/execution-operations.ts +69 -45
- package/src/core/in-process-session.ts +294 -0
- package/src/core/index.ts +1 -0
- package/src/core/session.ts +20 -1
- package/src/index.ts +2 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export class InProcessSession {
|
|
2
|
+
server;
|
|
3
|
+
clientId;
|
|
4
|
+
clientToken;
|
|
5
|
+
initialized = false;
|
|
6
|
+
initPromise;
|
|
7
|
+
constructor(server) {
|
|
8
|
+
this.server = server;
|
|
9
|
+
}
|
|
10
|
+
async init(clientInfo, tools, services) {
|
|
11
|
+
if (this.initPromise) {
|
|
12
|
+
await this.initPromise;
|
|
13
|
+
return {
|
|
14
|
+
clientId: this.clientId,
|
|
15
|
+
token: this.clientToken,
|
|
16
|
+
expiresAt: 0,
|
|
17
|
+
tokenRotateAt: 0,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
this.initPromise = (async () => {
|
|
21
|
+
await this.server.start();
|
|
22
|
+
const ctx = this.createContext({
|
|
23
|
+
method: 'POST',
|
|
24
|
+
path: '/api/init',
|
|
25
|
+
body: {
|
|
26
|
+
clientInfo,
|
|
27
|
+
tools: tools || [],
|
|
28
|
+
services,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const result = (await this.server.handleInit(ctx));
|
|
32
|
+
this.clientId = result.clientId;
|
|
33
|
+
this.clientToken = result.token;
|
|
34
|
+
this.initialized = true;
|
|
35
|
+
})();
|
|
36
|
+
await this.initPromise;
|
|
37
|
+
return {
|
|
38
|
+
clientId: this.clientId,
|
|
39
|
+
token: this.clientToken,
|
|
40
|
+
expiresAt: 0,
|
|
41
|
+
tokenRotateAt: 0,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getClientId() {
|
|
45
|
+
if (!this.clientId) {
|
|
46
|
+
throw new Error('Client not initialized. Call init() first.');
|
|
47
|
+
}
|
|
48
|
+
return this.clientId;
|
|
49
|
+
}
|
|
50
|
+
async ensureInitialized() {
|
|
51
|
+
if (!this.initialized) {
|
|
52
|
+
throw new Error('Client not initialized. Call init() first.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getHeaders() {
|
|
56
|
+
const headers = {
|
|
57
|
+
'content-type': 'application/json',
|
|
58
|
+
};
|
|
59
|
+
if (this.clientId) {
|
|
60
|
+
headers['x-client-id'] = this.clientId;
|
|
61
|
+
}
|
|
62
|
+
if (this.clientToken) {
|
|
63
|
+
headers['authorization'] = `Bearer ${this.clientToken}`;
|
|
64
|
+
}
|
|
65
|
+
return headers;
|
|
66
|
+
}
|
|
67
|
+
getBaseUrl() {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
updateToken(_response) {
|
|
71
|
+
// No-op for in-process - tokens are managed directly
|
|
72
|
+
}
|
|
73
|
+
async prepareHeaders(_method, _url, _body) {
|
|
74
|
+
return this.getHeaders();
|
|
75
|
+
}
|
|
76
|
+
async getDefinitions(options) {
|
|
77
|
+
await this.ensureInitialized();
|
|
78
|
+
const ctx = this.createContext({
|
|
79
|
+
method: 'GET',
|
|
80
|
+
path: '/api/definitions',
|
|
81
|
+
query: options?.apiGroups ? { apiGroups: options.apiGroups.join(',') } : {},
|
|
82
|
+
});
|
|
83
|
+
return (await this.server.getDefinitions(ctx));
|
|
84
|
+
}
|
|
85
|
+
async getRuntimeDefinitions(options) {
|
|
86
|
+
await this.ensureInitialized();
|
|
87
|
+
const ctx = this.createContext({
|
|
88
|
+
method: 'GET',
|
|
89
|
+
path: '/api/runtime',
|
|
90
|
+
query: options?.apis?.length ? { apis: options.apis.join(',') } : {},
|
|
91
|
+
});
|
|
92
|
+
return await this.server.getRuntimeDefinitions(ctx);
|
|
93
|
+
}
|
|
94
|
+
async getServerInfo() {
|
|
95
|
+
await this.ensureInitialized();
|
|
96
|
+
return this.server.getInfo();
|
|
97
|
+
}
|
|
98
|
+
async search(query, options) {
|
|
99
|
+
await this.ensureInitialized();
|
|
100
|
+
const ctx = this.createContext({
|
|
101
|
+
method: 'POST',
|
|
102
|
+
path: '/api/search',
|
|
103
|
+
body: { query, ...options },
|
|
104
|
+
});
|
|
105
|
+
return (await this.server.handleSearch(ctx));
|
|
106
|
+
}
|
|
107
|
+
async explore(path) {
|
|
108
|
+
await this.ensureInitialized();
|
|
109
|
+
const ctx = this.createContext({
|
|
110
|
+
method: 'POST',
|
|
111
|
+
path: '/api/explore',
|
|
112
|
+
body: { path },
|
|
113
|
+
});
|
|
114
|
+
return await this.server.handleExplore(ctx);
|
|
115
|
+
}
|
|
116
|
+
async execute(code, config) {
|
|
117
|
+
await this.ensureInitialized();
|
|
118
|
+
const ctx = this.createContext({
|
|
119
|
+
method: 'POST',
|
|
120
|
+
path: '/api/execute',
|
|
121
|
+
body: { code, config },
|
|
122
|
+
});
|
|
123
|
+
return await this.server.handleExecute(ctx);
|
|
124
|
+
}
|
|
125
|
+
async resume(executionId, callbackResult) {
|
|
126
|
+
await this.ensureInitialized();
|
|
127
|
+
const ctx = this.createContext({
|
|
128
|
+
method: 'POST',
|
|
129
|
+
path: `/api/resume/${executionId}`,
|
|
130
|
+
body: { result: callbackResult },
|
|
131
|
+
});
|
|
132
|
+
return await this.server.handleResume(ctx, executionId);
|
|
133
|
+
}
|
|
134
|
+
async resumeWithBatchResults(executionId, batchResults) {
|
|
135
|
+
await this.ensureInitialized();
|
|
136
|
+
const ctx = this.createContext({
|
|
137
|
+
method: 'POST',
|
|
138
|
+
path: `/api/resume/${executionId}`,
|
|
139
|
+
body: { results: batchResults },
|
|
140
|
+
});
|
|
141
|
+
return await this.server.handleResume(ctx, executionId);
|
|
142
|
+
}
|
|
143
|
+
createContext(options) {
|
|
144
|
+
const noopLogger = {
|
|
145
|
+
debug: () => { },
|
|
146
|
+
info: () => { },
|
|
147
|
+
warn: () => { },
|
|
148
|
+
error: () => { },
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
method: options.method,
|
|
152
|
+
path: options.path,
|
|
153
|
+
query: options.query || {},
|
|
154
|
+
headers: this.getHeaders(),
|
|
155
|
+
body: options.body,
|
|
156
|
+
clientId: this.clientId,
|
|
157
|
+
clientToken: this.clientToken,
|
|
158
|
+
logger: noopLogger,
|
|
159
|
+
status: 200,
|
|
160
|
+
responseBody: null,
|
|
161
|
+
throw: (status, message) => {
|
|
162
|
+
const error = new Error(message);
|
|
163
|
+
error.status = status;
|
|
164
|
+
throw error;
|
|
165
|
+
},
|
|
166
|
+
assert: (condition, message) => {
|
|
167
|
+
if (!condition) {
|
|
168
|
+
throw new Error(message);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
set: () => { },
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=in-process-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-process-session.js","sourceRoot":"","sources":["../../src/core/in-process-session.ts"],"names":[],"mappings":"AAsCA,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAkB;IACxB,QAAQ,CAAU;IAClB,WAAW,CAAU;IACrB,WAAW,GAAY,KAAK,CAAC;IAC7B,WAAW,CAAiB;IAEpC,YAAY,MAAuB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CACT,UAAwE,EACxE,KAA8B,EAC9B,QAA8F;QAO9F,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,WAAW,CAAC;YACvB,OAAO;gBACN,QAAQ,EAAE,IAAI,CAAC,QAAS;gBACxB,KAAK,EAAE,IAAI,CAAC,WAAY;gBACxB,SAAS,EAAE,CAAC;gBACZ,aAAa,EAAE,CAAC;aAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAE1B,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;gBAC9B,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE;oBACL,UAAU;oBACV,KAAK,EAAE,KAAK,IAAI,EAAE;oBAClB,QAAQ;iBACR;aACD,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAKhD,CAAC;YAEF,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;YAChC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;YAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC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ED
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,YAAY,EACX,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,YAAY,EACX,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,+BAA+B,CAAC"}
|
package/dist/core/index.js
CHANGED
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import type { ClientHooks } from './types.js';
|
|
2
2
|
import type { ClientToolDefinition } from '@mondaydotcomorg/atp-protocol';
|
|
3
|
-
export
|
|
3
|
+
export interface ISession {
|
|
4
|
+
init(clientInfo?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}, tools?: ClientToolDefinition[], services?: {
|
|
9
|
+
hasLLM: boolean;
|
|
10
|
+
hasApproval: boolean;
|
|
11
|
+
hasEmbedding: boolean;
|
|
12
|
+
hasTools: boolean;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
clientId: string;
|
|
15
|
+
token: string;
|
|
16
|
+
expiresAt: number;
|
|
17
|
+
tokenRotateAt: number;
|
|
18
|
+
}>;
|
|
19
|
+
getClientId(): string;
|
|
20
|
+
ensureInitialized(): Promise<void>;
|
|
21
|
+
getHeaders(): Record<string, string>;
|
|
22
|
+
getBaseUrl(): string;
|
|
23
|
+
updateToken(response: Response): void;
|
|
24
|
+
prepareHeaders(method: string, url: string, body?: unknown): Promise<Record<string, string>>;
|
|
25
|
+
}
|
|
26
|
+
export declare class ClientSession implements ISession {
|
|
4
27
|
private baseUrl;
|
|
5
28
|
private customHeaders;
|
|
6
29
|
private clientId?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,
|
|
1
|
+
{"version":3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"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,aAAa;IACjB,OAAO,CAAS;IAChB,aAAa,CAAyB;IACtC,QAAQ,CAAU;IAClB,WAAW,CAAU;IACrB,WAAW,CAAiB;IAC5B,KAAK,CAAe;IAE5B,YAAY,OAAe,EAAE,OAAgC,EAAE,KAAmB;QACjF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CACT,UAAwE,EACxE,KAA8B,EAC9B,QAA8F;QAO9F,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,WAAW,CAAC;YACvB,OAAO;gBACN,QAAQ,EAAE,IAAI,CAAC,QAAS;gBACxB,KAAK,EAAE,IAAI,CAAC,WAAY;gBACxB,SAAS,EAAE,CAAC;gBACZ,aAAa,EAAE,CAAC;aAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,WAAW,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC3B,UAAU;gBACV,KAAK,EAAE,KAAK,IAAI,EAAE;gBAClB,QAAQ;aACR,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAE7D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBACjC,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI;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F,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export type { RuntimeAPIName } from '@mondaydotcomorg/atp-runtime';
|
|
|
8
8
|
export type { Tool, ToolName } from './tools/types.js';
|
|
9
9
|
export { ToolNames } from './tools/types.js';
|
|
10
10
|
export type { AgentToolProtocolClientOptions } from './client.js';
|
|
11
|
+
export { InProcessSession } from './core/in-process-session.js';
|
|
12
|
+
export type { ISession } from './core/session.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,5 @@ export * from './core/types.js';
|
|
|
5
5
|
export * from './errors.js';
|
|
6
6
|
export { ExecutionStatus } from '@mondaydotcomorg/atp-protocol';
|
|
7
7
|
export { ToolNames } from './tools/types.js';
|
|
8
|
+
export { InProcessSession } from './core/in-process-session.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/atp-client",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"description": "Client SDK for Agent Tool Protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@mondaydotcomorg/atp-protocol": "0.19.
|
|
48
|
-
"@mondaydotcomorg/atp-runtime": "0.19.
|
|
47
|
+
"@mondaydotcomorg/atp-protocol": "0.19.7",
|
|
48
|
+
"@mondaydotcomorg/atp-runtime": "0.19.7",
|
|
49
49
|
"undici": "*",
|
|
50
50
|
"zod-to-json-schema": "^3.24.6"
|
|
51
51
|
},
|
package/src/client.ts
CHANGED
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
type ClientEmbeddingHandler,
|
|
16
16
|
type ClientServiceProviders,
|
|
17
17
|
type ClientHooks,
|
|
18
|
+
type ISession,
|
|
18
19
|
ClientSession,
|
|
20
|
+
InProcessSession,
|
|
19
21
|
APIOperations,
|
|
20
22
|
ExecutionOperations,
|
|
21
23
|
ServiceProviders,
|
|
@@ -28,12 +30,26 @@ import {
|
|
|
28
30
|
createExploreApiTool,
|
|
29
31
|
} from './tools/index.js';
|
|
30
32
|
|
|
33
|
+
interface InProcessServer {
|
|
34
|
+
start(): Promise<void>;
|
|
35
|
+
handleInit(ctx: unknown): Promise<unknown>;
|
|
36
|
+
getDefinitions(ctx?: unknown): Promise<unknown>;
|
|
37
|
+
getRuntimeDefinitions(ctx?: unknown): Promise<string>;
|
|
38
|
+
getInfo(): unknown;
|
|
39
|
+
handleSearch(ctx: unknown): Promise<unknown>;
|
|
40
|
+
handleExplore(ctx: unknown): Promise<unknown>;
|
|
41
|
+
handleExecute(ctx: unknown): Promise<unknown>;
|
|
42
|
+
handleResume(ctx: unknown, executionId: string): Promise<unknown>;
|
|
43
|
+
}
|
|
44
|
+
|
|
31
45
|
/**
|
|
32
46
|
* Options for creating an AgentToolProtocolClient
|
|
33
47
|
*/
|
|
34
48
|
export interface AgentToolProtocolClientOptions {
|
|
35
|
-
/** Base URL of the Agent Tool Protocol server */
|
|
36
|
-
baseUrl
|
|
49
|
+
/** Base URL of the Agent Tool Protocol server (HTTP mode) */
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
/** Server instance for in-process mode (no HTTP, no port binding) */
|
|
52
|
+
server?: InProcessServer;
|
|
37
53
|
/** Optional headers for authentication (e.g., { Authorization: 'Bearer token' }) */
|
|
38
54
|
headers?: Record<string, string>;
|
|
39
55
|
/** Optional client-provided services (LLM, approval, embedding) */
|
|
@@ -47,7 +63,8 @@ export interface AgentToolProtocolClientOptions {
|
|
|
47
63
|
* Agent Tool Protocol servers and executing code.
|
|
48
64
|
*/
|
|
49
65
|
export class AgentToolProtocolClient {
|
|
50
|
-
private session:
|
|
66
|
+
private session: ISession;
|
|
67
|
+
private inProcessSession?: InProcessSession;
|
|
51
68
|
private apiOps: APIOperations;
|
|
52
69
|
private execOps: ExecutionOperations;
|
|
53
70
|
private serviceProviders: ServiceProviders;
|
|
@@ -57,6 +74,7 @@ export class AgentToolProtocolClient {
|
|
|
57
74
|
*
|
|
58
75
|
* @example
|
|
59
76
|
* ```typescript
|
|
77
|
+
* // HTTP mode
|
|
60
78
|
* const client = new AgentToolProtocolClient({
|
|
61
79
|
* baseUrl: 'http://localhost:3333',
|
|
62
80
|
* headers: { Authorization: 'Bearer token' },
|
|
@@ -67,14 +85,36 @@ export class AgentToolProtocolClient {
|
|
|
67
85
|
* }
|
|
68
86
|
* }
|
|
69
87
|
* });
|
|
88
|
+
*
|
|
89
|
+
* // In-process mode (no port binding)
|
|
90
|
+
* const server = createServer();
|
|
91
|
+
* server.use(myApiGroup);
|
|
92
|
+
* const client = new AgentToolProtocolClient({ server });
|
|
70
93
|
* ```
|
|
71
94
|
*/
|
|
72
95
|
constructor(options: AgentToolProtocolClientOptions) {
|
|
73
|
-
const { baseUrl, headers, serviceProviders, hooks } = options;
|
|
74
|
-
|
|
96
|
+
const { baseUrl, server, headers, serviceProviders, hooks } = options;
|
|
97
|
+
|
|
98
|
+
if (!baseUrl && !server) {
|
|
99
|
+
throw new Error('Either baseUrl or server must be provided');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (baseUrl && server) {
|
|
103
|
+
throw new Error('Cannot provide both baseUrl and server');
|
|
104
|
+
}
|
|
105
|
+
|
|
75
106
|
this.serviceProviders = new ServiceProviders(serviceProviders);
|
|
76
|
-
|
|
77
|
-
|
|
107
|
+
|
|
108
|
+
if (server) {
|
|
109
|
+
this.inProcessSession = new InProcessSession(server);
|
|
110
|
+
this.session = this.inProcessSession;
|
|
111
|
+
this.apiOps = new APIOperations(this.session, this.inProcessSession);
|
|
112
|
+
this.execOps = new ExecutionOperations(this.session, this.serviceProviders, this.inProcessSession);
|
|
113
|
+
} else {
|
|
114
|
+
this.session = new ClientSession(baseUrl!, headers, hooks);
|
|
115
|
+
this.apiOps = new APIOperations(this.session);
|
|
116
|
+
this.execOps = new ExecutionOperations(this.session, this.serviceProviders);
|
|
117
|
+
}
|
|
78
118
|
}
|
|
79
119
|
|
|
80
120
|
/**
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { SearchOptions, SearchResult, ExploreResult } from '@mondaydotcomorg/atp-protocol';
|
|
2
2
|
import type { RuntimeAPIName } from '@mondaydotcomorg/atp-runtime';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ISession } from './session.js';
|
|
4
|
+
import type { InProcessSession } from './in-process-session.js';
|
|
4
5
|
|
|
5
6
|
export class APIOperations {
|
|
6
|
-
private session:
|
|
7
|
+
private session: ISession;
|
|
8
|
+
private inProcessSession?: InProcessSession;
|
|
7
9
|
private apiDefinitions?: string;
|
|
8
10
|
|
|
9
|
-
constructor(session:
|
|
11
|
+
constructor(session: ISession, inProcessSession?: InProcessSession) {
|
|
10
12
|
this.session = session;
|
|
13
|
+
this.inProcessSession = inProcessSession;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -20,6 +23,16 @@ export class APIOperations {
|
|
|
20
23
|
}> {
|
|
21
24
|
await this.session.ensureInitialized();
|
|
22
25
|
|
|
26
|
+
if (this.inProcessSession) {
|
|
27
|
+
const data = await this.inProcessSession.getDefinitions(options);
|
|
28
|
+
this.apiDefinitions = data.typescript;
|
|
29
|
+
return {
|
|
30
|
+
serverVersion: data.version,
|
|
31
|
+
capabilities: {},
|
|
32
|
+
apiGroups: data.apiGroups,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
const params = new URLSearchParams();
|
|
24
37
|
if (options?.apiGroups) {
|
|
25
38
|
params.set('apiGroups', options.apiGroups.join(','));
|
|
@@ -64,6 +77,11 @@ export class APIOperations {
|
|
|
64
77
|
async searchAPI(query: string, options?: SearchOptions): Promise<SearchResult[]> {
|
|
65
78
|
await this.session.ensureInitialized();
|
|
66
79
|
|
|
80
|
+
if (this.inProcessSession) {
|
|
81
|
+
const data = await this.inProcessSession.search(query, options as unknown as Record<string, unknown>);
|
|
82
|
+
return data.results as SearchResult[];
|
|
83
|
+
}
|
|
84
|
+
|
|
67
85
|
const url = `${this.session.getBaseUrl()}/api/search`;
|
|
68
86
|
const body = JSON.stringify({ query, ...options });
|
|
69
87
|
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
@@ -88,6 +106,10 @@ export class APIOperations {
|
|
|
88
106
|
async exploreAPI(path: string): Promise<ExploreResult> {
|
|
89
107
|
await this.session.ensureInitialized();
|
|
90
108
|
|
|
109
|
+
if (this.inProcessSession) {
|
|
110
|
+
return (await this.inProcessSession.explore(path)) as ExploreResult;
|
|
111
|
+
}
|
|
112
|
+
|
|
91
113
|
const url = `${this.session.getBaseUrl()}/api/explore`;
|
|
92
114
|
const body = JSON.stringify({ path });
|
|
93
115
|
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
@@ -114,6 +136,10 @@ export class APIOperations {
|
|
|
114
136
|
}> {
|
|
115
137
|
await this.session.ensureInitialized();
|
|
116
138
|
|
|
139
|
+
if (this.inProcessSession) {
|
|
140
|
+
return await this.inProcessSession.getServerInfo();
|
|
141
|
+
}
|
|
142
|
+
|
|
117
143
|
const url = `${this.session.getBaseUrl()}/api/info`;
|
|
118
144
|
const headers = await this.session.prepareHeaders('GET', url);
|
|
119
145
|
|
|
@@ -145,6 +171,12 @@ export class APIOperations {
|
|
|
145
171
|
async getRuntimeDefinitions(options?: { apis?: RuntimeAPIName[] }): Promise<string> {
|
|
146
172
|
await this.session.ensureInitialized();
|
|
147
173
|
|
|
174
|
+
if (this.inProcessSession) {
|
|
175
|
+
return await this.inProcessSession.getRuntimeDefinitions(
|
|
176
|
+
options?.apis ? { apis: options.apis } : undefined
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
148
180
|
const params = new URLSearchParams();
|
|
149
181
|
if (options?.apis && options.apis.length > 0) {
|
|
150
182
|
params.set('apis', options.apis.join(','));
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import type { ExecutionResult, ExecutionConfig } from '@mondaydotcomorg/atp-protocol';
|
|
2
2
|
import { ExecutionStatus, CallbackType } from '@mondaydotcomorg/atp-protocol';
|
|
3
3
|
import { log } from '@mondaydotcomorg/atp-runtime';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ISession } from './session.js';
|
|
5
|
+
import type { InProcessSession } from './in-process-session.js';
|
|
5
6
|
import type { ServiceProviders } from './service-providers';
|
|
6
7
|
import { ClientCallbackError } from '../errors.js';
|
|
7
8
|
import { ProvenanceTokenRegistry } from './provenance-registry.js';
|
|
8
9
|
|
|
9
10
|
export class ExecutionOperations {
|
|
10
|
-
private session:
|
|
11
|
+
private session: ISession;
|
|
12
|
+
private inProcessSession?: InProcessSession;
|
|
11
13
|
private serviceProviders: ServiceProviders;
|
|
12
14
|
private tokenRegistry: ProvenanceTokenRegistry;
|
|
13
15
|
private lastExecutionConfig: Partial<ExecutionConfig> | null = null;
|
|
14
16
|
|
|
15
|
-
constructor(session:
|
|
17
|
+
constructor(session: ISession, serviceProviders: ServiceProviders, inProcessSession?: InProcessSession) {
|
|
16
18
|
this.session = session;
|
|
19
|
+
this.inProcessSession = inProcessSession;
|
|
17
20
|
this.serviceProviders = serviceProviders;
|
|
18
21
|
this.tokenRegistry = new ProvenanceTokenRegistry();
|
|
19
22
|
}
|
|
@@ -132,24 +135,30 @@ export class ExecutionOperations {
|
|
|
132
135
|
|
|
133
136
|
this.lastExecutionConfig = executionConfig;
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
const body = JSON.stringify({ code, config: executionConfig });
|
|
137
|
-
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
138
|
+
let result: ExecutionResult;
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
if (this.inProcessSession) {
|
|
141
|
+
result = (await this.inProcessSession.execute(code, executionConfig)) as ExecutionResult;
|
|
142
|
+
} else {
|
|
143
|
+
const url = `${this.session.getBaseUrl()}/api/execute`;
|
|
144
|
+
const body = JSON.stringify({ code, config: executionConfig });
|
|
145
|
+
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
const response = await fetch(url, {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
headers,
|
|
150
|
+
body,
|
|
151
|
+
});
|
|
146
152
|
|
|
147
|
-
|
|
148
|
-
const error = (await response.json()) as { error: string };
|
|
149
|
-
throw new Error(`Execution failed: ${error.error || response.statusText}`);
|
|
150
|
-
}
|
|
153
|
+
this.session.updateToken(response);
|
|
151
154
|
|
|
152
|
-
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
const error = (await response.json()) as { error: string };
|
|
157
|
+
throw new Error(`Execution failed: ${error.error || response.statusText}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
result = (await response.json()) as ExecutionResult;
|
|
161
|
+
}
|
|
153
162
|
|
|
154
163
|
if (result.provenanceTokens && result.provenanceTokens.length > 0) {
|
|
155
164
|
for (const { token } of result.provenanceTokens) {
|
|
@@ -383,24 +392,30 @@ export class ExecutionOperations {
|
|
|
383
392
|
async resume(executionId: string, callbackResult: unknown): Promise<ExecutionResult> {
|
|
384
393
|
await this.session.ensureInitialized();
|
|
385
394
|
|
|
386
|
-
|
|
387
|
-
const body = JSON.stringify({ result: callbackResult });
|
|
388
|
-
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
395
|
+
let result: ExecutionResult;
|
|
389
396
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
if (this.inProcessSession) {
|
|
398
|
+
result = (await this.inProcessSession.resume(executionId, callbackResult)) as ExecutionResult;
|
|
399
|
+
} else {
|
|
400
|
+
const url = `${this.session.getBaseUrl()}/api/resume/${executionId}`;
|
|
401
|
+
const body = JSON.stringify({ result: callbackResult });
|
|
402
|
+
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
403
|
+
|
|
404
|
+
const response = await fetch(url, {
|
|
405
|
+
method: 'POST',
|
|
406
|
+
headers,
|
|
407
|
+
body,
|
|
408
|
+
});
|
|
395
409
|
|
|
396
|
-
|
|
410
|
+
this.session.updateToken(response);
|
|
397
411
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
412
|
+
if (!response.ok) {
|
|
413
|
+
const error = (await response.json()) as { error: string };
|
|
414
|
+
throw new Error(`Resume failed: ${error.error || response.statusText}`);
|
|
415
|
+
}
|
|
402
416
|
|
|
403
|
-
|
|
417
|
+
result = (await response.json()) as ExecutionResult;
|
|
418
|
+
}
|
|
404
419
|
|
|
405
420
|
if (result.provenanceTokens && result.provenanceTokens.length > 0) {
|
|
406
421
|
for (const { token } of result.provenanceTokens) {
|
|
@@ -428,24 +443,33 @@ export class ExecutionOperations {
|
|
|
428
443
|
): Promise<ExecutionResult> {
|
|
429
444
|
await this.session.ensureInitialized();
|
|
430
445
|
|
|
431
|
-
|
|
432
|
-
const body = JSON.stringify({ results: batchResults });
|
|
433
|
-
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
446
|
+
let result: ExecutionResult;
|
|
434
447
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
448
|
+
if (this.inProcessSession) {
|
|
449
|
+
result = (await this.inProcessSession.resumeWithBatchResults(
|
|
450
|
+
executionId,
|
|
451
|
+
batchResults
|
|
452
|
+
)) as ExecutionResult;
|
|
453
|
+
} else {
|
|
454
|
+
const url = `${this.session.getBaseUrl()}/api/resume/${executionId}`;
|
|
455
|
+
const body = JSON.stringify({ results: batchResults });
|
|
456
|
+
const headers = await this.session.prepareHeaders('POST', url, body);
|
|
440
457
|
|
|
441
|
-
|
|
458
|
+
const response = await fetch(url, {
|
|
459
|
+
method: 'POST',
|
|
460
|
+
headers,
|
|
461
|
+
body,
|
|
462
|
+
});
|
|
442
463
|
|
|
443
|
-
|
|
444
|
-
const error = (await response.json()) as { error: string };
|
|
445
|
-
throw new Error(`Batch resume failed: ${error.error || response.statusText}`);
|
|
446
|
-
}
|
|
464
|
+
this.session.updateToken(response);
|
|
447
465
|
|
|
448
|
-
|
|
466
|
+
if (!response.ok) {
|
|
467
|
+
const error = (await response.json()) as { error: string };
|
|
468
|
+
throw new Error(`Batch resume failed: ${error.error || response.statusText}`);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
result = (await response.json()) as ExecutionResult;
|
|
472
|
+
}
|
|
449
473
|
|
|
450
474
|
if (result.provenanceTokens && result.provenanceTokens.length > 0) {
|
|
451
475
|
for (const { token } of result.provenanceTokens) {
|