macp-sdk-typescript 0.4.0 → 0.5.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/CHANGELOG.md +77 -0
- package/README.md +4 -3
- package/dist/agent/participant.d.ts +2 -0
- package/dist/agent/participant.js +1 -0
- package/dist/agent/runner.d.ts +1 -0
- package/dist/agent/runner.js +1 -0
- package/dist/agent/transports.d.ts +10 -0
- package/dist/agent/transports.js +13 -0
- package/dist/auth.d.ts +10 -5
- package/dist/auth.js +15 -15
- package/dist/base-session.d.ts +1 -0
- package/dist/base-session.js +3 -0
- package/dist/client.d.ts +60 -14
- package/dist/client.js +88 -30
- package/dist/decision.d.ts +1 -0
- package/dist/decision.js +2 -0
- package/dist/envelope.d.ts +20 -0
- package/dist/envelope.js +15 -0
- package/dist/errors.d.ts +10 -1
- package/dist/errors.js +11 -1
- package/dist/handoff.d.ts +1 -0
- package/dist/handoff.js +9 -1
- package/dist/policy.d.ts +35 -0
- package/dist/policy.js +18 -2
- package/dist/projections/handoff.d.ts +12 -0
- package/dist/projections/handoff.js +13 -0
- package/dist/proposal.d.ts +1 -0
- package/dist/proposal.js +2 -0
- package/dist/proto-registry.d.ts +10 -0
- package/dist/proto-registry.js +48 -2
- package/dist/quorum.d.ts +1 -0
- package/dist/quorum.js +2 -0
- package/dist/retry.d.ts +7 -0
- package/dist/task.d.ts +1 -0
- package/dist/task.js +2 -0
- package/dist/types.d.ts +18 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.js +10 -0
- package/dist/watchers.d.ts +17 -13
- package/dist/watchers.js +26 -26
- package/package.json +4 -4
package/dist/watchers.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SessionLifecycleWatcher = exports.PolicyWatcher = exports.SignalWatcher = exports.RootsWatcher = exports.ModeRegistryWatcher = exports.isTerminalSessionLifecycleEvent = exports.isSessionResumed = exports.isSessionSuspended = exports.isSessionCancelled = exports.isSessionExpired = exports.isSessionResolved = exports.isSessionCreated = exports.TERMINAL_SESSION_LIFECYCLE_EVENT_TYPES = void 0;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
5
6
|
/**
|
|
6
7
|
* The lifecycle event types after which a session emits no further events.
|
|
7
8
|
* `EVENT_TYPE_CANCELLED` (proto 0.1.3) is terminal alongside `RESOLVED` and
|
|
@@ -48,7 +49,14 @@ function serverStreamToAsyncGenerator(stream) {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
stream.on('error', (error) => {
|
|
51
|
-
|
|
52
|
+
// Wrap the raw gRPC ServiceError into a coded MacpTransportError so
|
|
53
|
+
// consumers can branch on `.code`: consumer lag terminates a watch stream
|
|
54
|
+
// with RESOURCE_EXHAUSTED (reconnect + re-sync), an unauthenticated
|
|
55
|
+
// WatchSignals with UNAUTHENTICATED (fix auth, do NOT reconnect).
|
|
56
|
+
const code = (0, client_1.grpcStatusName)(error.code);
|
|
57
|
+
const serviceErr = error;
|
|
58
|
+
const wrapped = new errors_1.MacpTransportError(serviceErr.details || error.message, code);
|
|
59
|
+
queue.push({ error: wrapped });
|
|
52
60
|
if (resolve) {
|
|
53
61
|
resolve();
|
|
54
62
|
resolve = null;
|
|
@@ -148,6 +156,16 @@ class RootsWatcher {
|
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
exports.RootsWatcher = RootsWatcher;
|
|
159
|
+
/**
|
|
160
|
+
* Watches the ambient signal plane. **Requires auth** as of runtime 0.5.0: if
|
|
161
|
+
* no credential is configured on the watcher or the client, iterating
|
|
162
|
+
* {@link SignalWatcher.signals} throws immediately (via `client.watchSignals`).
|
|
163
|
+
*
|
|
164
|
+
* Consumer lag terminates the stream with a coded `MacpTransportError`
|
|
165
|
+
* (`code === 'RESOURCE_EXHAUSTED'`); the correct response is to reconnect.
|
|
166
|
+
* A missing/invalid credential surfaces as `code === 'UNAUTHENTICATED'` — fix
|
|
167
|
+
* auth, do not reconnect.
|
|
168
|
+
*/
|
|
151
169
|
class SignalWatcher {
|
|
152
170
|
client;
|
|
153
171
|
auth;
|
|
@@ -210,11 +228,15 @@ class PolicyWatcher {
|
|
|
210
228
|
}
|
|
211
229
|
}
|
|
212
230
|
exports.PolicyWatcher = PolicyWatcher;
|
|
231
|
+
/**
|
|
232
|
+
* Watches session lifecycle events (`WatchSessions`). Consumer lag terminates
|
|
233
|
+
* the stream with a coded `MacpTransportError` (`code === 'RESOURCE_EXHAUSTED'`);
|
|
234
|
+
* the correct response is to reconnect and re-sync current state via
|
|
235
|
+
* {@link MacpClient.listSessions}, since events emitted during the gap are lost.
|
|
236
|
+
*/
|
|
213
237
|
class SessionLifecycleWatcher {
|
|
214
238
|
client;
|
|
215
239
|
auth;
|
|
216
|
-
deprecatedEventsWarned = false;
|
|
217
|
-
deprecatedNextEventWarned = false;
|
|
218
240
|
constructor(client, options) {
|
|
219
241
|
this.client = client;
|
|
220
242
|
this.auth = options?.auth;
|
|
@@ -243,27 +265,5 @@ class SessionLifecycleWatcher {
|
|
|
243
265
|
throw new Error('stream ended before receiving a session lifecycle event');
|
|
244
266
|
return result.value;
|
|
245
267
|
}
|
|
246
|
-
/**
|
|
247
|
-
* @deprecated Use {@link changes} — renamed for parity with python-sdk's
|
|
248
|
-
* `SessionLifecycleWatcher.changes()` and the uniform `changes()` name
|
|
249
|
-
* used by all other watchers in both SDKs. Will be removed in 0.5.0.
|
|
250
|
-
*/
|
|
251
|
-
async *events(signal) {
|
|
252
|
-
if (!this.deprecatedEventsWarned) {
|
|
253
|
-
this.deprecatedEventsWarned = true;
|
|
254
|
-
logging_1.logger.warn('[deprecated] SessionLifecycleWatcher.events() — use changes() instead');
|
|
255
|
-
}
|
|
256
|
-
yield* this.changes(signal);
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* @deprecated Use {@link nextChange}. Will be removed in 0.5.0.
|
|
260
|
-
*/
|
|
261
|
-
async nextEvent() {
|
|
262
|
-
if (!this.deprecatedNextEventWarned) {
|
|
263
|
-
this.deprecatedNextEventWarned = true;
|
|
264
|
-
logging_1.logger.warn('[deprecated] SessionLifecycleWatcher.nextEvent() — use nextChange() instead');
|
|
265
|
-
}
|
|
266
|
-
return this.nextChange();
|
|
267
|
-
}
|
|
268
268
|
}
|
|
269
269
|
exports.SessionLifecycleWatcher = SessionLifecycleWatcher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "macp-sdk-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "TypeScript SDK for the MACP Rust runtime",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
],
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
53
|
-
"url": "https://github.com/multiagentcoordinationprotocol/
|
|
53
|
+
"url": "https://github.com/multiagentcoordinationprotocol/macp-sdk-typescript.git"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@grpc/grpc-js": "^1.14.3",
|
|
57
57
|
"@grpc/proto-loader": "^0.8.0",
|
|
58
|
-
"@multiagentcoordinationprotocol/proto": "^0.1.
|
|
59
|
-
"protobufjs": "^8.
|
|
58
|
+
"@multiagentcoordinationprotocol/proto": "^0.1.6",
|
|
59
|
+
"protobufjs": "^8.6.5"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^22.14.0",
|