macp-sdk-typescript 0.14.0 → 0.15.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 +50 -20
- package/dist/client.d.ts +18 -5
- package/dist/client.js +24 -10
- package/dist/commitment-hash.d.ts +26 -0
- package/dist/commitment-hash.js +180 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +50 -1
- package/dist/decision.js +4 -1
- package/dist/errors.d.ts +67 -6
- package/dist/errors.js +90 -47
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/policy.js +7 -3
- package/dist/projections/base.d.ts +14 -0
- package/dist/projections/base.js +18 -0
- package/dist/projections/decision.js +22 -15
- package/dist/projections/handoff.js +4 -4
- package/dist/projections/proposal.d.ts +13 -0
- package/dist/projections/proposal.js +19 -2
- package/dist/projections/quorum.js +1 -1
- package/dist/projections/task.d.ts +7 -0
- package/dist/projections/task.js +15 -4
- package/dist/types.d.ts +1 -0
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +6 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/watchers.js +8 -6
- package/package.json +2 -2
package/dist/projections/task.js
CHANGED
|
@@ -9,6 +9,7 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
9
9
|
updates = [];
|
|
10
10
|
completions = [];
|
|
11
11
|
failures = [];
|
|
12
|
+
rejections = [];
|
|
12
13
|
phase = 'Pending';
|
|
13
14
|
/**
|
|
14
15
|
* The **session-level** active assignment: who currently holds the session's
|
|
@@ -46,7 +47,7 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
46
47
|
progress: 0,
|
|
47
48
|
sender: envelope.sender,
|
|
48
49
|
});
|
|
49
|
-
this.
|
|
50
|
+
this.setPhase('Requested');
|
|
50
51
|
break;
|
|
51
52
|
}
|
|
52
53
|
case 'TaskAccept': {
|
|
@@ -90,7 +91,7 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
90
91
|
task.assignee = record.assignee;
|
|
91
92
|
task.status = 'accepted';
|
|
92
93
|
this.activeAssignment = { sender: envelope.sender, taskId: record.taskId };
|
|
93
|
-
this.
|
|
94
|
+
this.setPhase('InProgress');
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
97
|
this.recordAnomaly({
|
|
@@ -109,6 +110,16 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
109
110
|
}
|
|
110
111
|
case 'TaskReject': {
|
|
111
112
|
const record = payload;
|
|
113
|
+
// Issue #151: unconditional audit record, matching this file's own
|
|
114
|
+
// TaskUpdate/TaskComplete/TaskFail convention (and Python's
|
|
115
|
+
// identical unconditional `self.rejections.append(...)`,
|
|
116
|
+
// task.py:186-196) — `sender` comes from the envelope, never the
|
|
117
|
+
// payload, matching the three sibling records. Deliberately does
|
|
118
|
+
// NOT fall back `assignee` to `envelope.sender` the way Python's
|
|
119
|
+
// `p.assignee or envelope.sender` does: TaskComplete/TaskFail below
|
|
120
|
+
// spread the payload's `assignee` as-is with no such fallback, and
|
|
121
|
+
// intra-SDK consistency wins over replicating Python's nuance here.
|
|
122
|
+
this.rejections.push({ ...record, sender: envelope.sender });
|
|
112
123
|
const task = this.tasks.get(record.taskId);
|
|
113
124
|
if (task)
|
|
114
125
|
task.status = 'rejected';
|
|
@@ -158,7 +169,7 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
158
169
|
if (task) {
|
|
159
170
|
task.status = 'completed';
|
|
160
171
|
task.progress = 1;
|
|
161
|
-
this.
|
|
172
|
+
this.setPhase('Completed');
|
|
162
173
|
}
|
|
163
174
|
break;
|
|
164
175
|
}
|
|
@@ -168,7 +179,7 @@ class TaskProjection extends base_1.BaseProjection {
|
|
|
168
179
|
const task = this.tasks.get(record.taskId);
|
|
169
180
|
if (task) {
|
|
170
181
|
task.status = 'failed';
|
|
171
|
-
this.
|
|
182
|
+
this.setPhase('Failed');
|
|
172
183
|
}
|
|
173
184
|
break;
|
|
174
185
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -173,6 +173,7 @@ export interface DecisionEvaluationPayload {
|
|
|
173
173
|
export interface DecisionObjectionPayload {
|
|
174
174
|
proposalId: string;
|
|
175
175
|
reason: string;
|
|
176
|
+
/** `critical` | `high` | `medium` | `low` (case-insensitive; sent lowercase). Defaults to `medium`. */
|
|
176
177
|
severity?: string;
|
|
177
178
|
}
|
|
178
179
|
export interface DecisionVotePayload {
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validate that `sid` is a lowercase UUID v4/v7 or base64url (22
|
|
2
|
+
* Validate that `sid` is a lowercase UUID v4/v7 or base64url (22–128 chars).
|
|
3
3
|
*
|
|
4
4
|
* Mirrors the runtime's **no-fall-through** rule (issue #108.1, and
|
|
5
5
|
* `macp-sdk-python`'s `validate_session_id`, `validation.py:33-58`, which
|
package/dist/validation.js
CHANGED
|
@@ -20,9 +20,12 @@ const errors_1 = require("./errors");
|
|
|
20
20
|
const UUID_SHAPE_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
21
21
|
// Strict lowercase UUID v4/v7 (version nibble 4 or 7, RFC 9562 variant 8/9/a/b).
|
|
22
22
|
const UUID_V4V7_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[47][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
23
|
-
|
|
23
|
+
// 22–128 chars: the 128 cap is RFC-MACP-0004 §11.2's portability floor, which
|
|
24
|
+
// runtime ≥ 0.9.0 enforces at SessionStart (INVALID_SESSION_ID). The charset is
|
|
25
|
+
// ASCII, so 128 chars == 128 bytes.
|
|
26
|
+
const BASE64URL_RE = /^[A-Za-z0-9_-]{22,128}$/;
|
|
24
27
|
/**
|
|
25
|
-
* Validate that `sid` is a lowercase UUID v4/v7 or base64url (22
|
|
28
|
+
* Validate that `sid` is a lowercase UUID v4/v7 or base64url (22–128 chars).
|
|
26
29
|
*
|
|
27
30
|
* Mirrors the runtime's **no-fall-through** rule (issue #108.1, and
|
|
28
31
|
* `macp-sdk-python`'s `validate_session_id`, `validation.py:33-58`, which
|
|
@@ -44,7 +47,7 @@ function validateSessionId(sid) {
|
|
|
44
47
|
}
|
|
45
48
|
if (BASE64URL_RE.test(sid))
|
|
46
49
|
return;
|
|
47
|
-
throw new errors_1.MacpSessionError(`session_id must be a lowercase UUID v4/v7 or base64url (22
|
|
50
|
+
throw new errors_1.MacpSessionError(`session_id must be a lowercase UUID v4/v7 or base64url (22–128 chars), got: ${sid}`);
|
|
48
51
|
}
|
|
49
52
|
const VALID_VOTES = new Set(['APPROVE', 'REJECT', 'ABSTAIN']);
|
|
50
53
|
function validateVote(value) {
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/watchers.js
CHANGED
|
@@ -55,7 +55,9 @@ function serverStreamToAsyncGenerator(stream) {
|
|
|
55
55
|
// WatchSignals with UNAUTHENTICATED (fix auth, do NOT reconnect).
|
|
56
56
|
const code = (0, client_1.grpcStatusName)(error.code);
|
|
57
57
|
const serviceErr = error;
|
|
58
|
-
const wrapped = new errors_1.MacpTransportError(serviceErr.details || error.message, code)
|
|
58
|
+
const wrapped = new errors_1.MacpTransportError(serviceErr.details || error.message, code, (0, errors_1.macpErrorCodeFromMetadata)(serviceErr.metadata
|
|
59
|
+
? serviceErr.metadata.get('macp-error-code').map((value) => ({ key: 'macp-error-code', value }))
|
|
60
|
+
: undefined));
|
|
59
61
|
queue.push({ error: wrapped });
|
|
60
62
|
if (resolve) {
|
|
61
63
|
resolve();
|
|
@@ -130,7 +132,7 @@ class ModeRegistryWatcher {
|
|
|
130
132
|
const result = await gen.next();
|
|
131
133
|
await gen.return(undefined);
|
|
132
134
|
if (result.done)
|
|
133
|
-
throw new
|
|
135
|
+
throw new errors_1.MacpTransportError('stream ended before receiving a change');
|
|
134
136
|
return result.value;
|
|
135
137
|
}
|
|
136
138
|
}
|
|
@@ -159,7 +161,7 @@ class RootsWatcher {
|
|
|
159
161
|
const result = await gen.next();
|
|
160
162
|
await gen.return(undefined);
|
|
161
163
|
if (result.done)
|
|
162
|
-
throw new
|
|
164
|
+
throw new errors_1.MacpTransportError('stream ended before receiving a change');
|
|
163
165
|
return result.value;
|
|
164
166
|
}
|
|
165
167
|
}
|
|
@@ -202,7 +204,7 @@ class SignalWatcher {
|
|
|
202
204
|
const result = await gen.next();
|
|
203
205
|
await gen.return(undefined);
|
|
204
206
|
if (result.done)
|
|
205
|
-
throw new
|
|
207
|
+
throw new errors_1.MacpTransportError('stream ended before receiving a signal');
|
|
206
208
|
return result.value;
|
|
207
209
|
}
|
|
208
210
|
}
|
|
@@ -231,7 +233,7 @@ class PolicyWatcher {
|
|
|
231
233
|
const result = await gen.next();
|
|
232
234
|
await gen.return(undefined);
|
|
233
235
|
if (result.done)
|
|
234
|
-
throw new
|
|
236
|
+
throw new errors_1.MacpTransportError('stream ended before receiving a policy change');
|
|
235
237
|
return result.value;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
@@ -270,7 +272,7 @@ class SessionLifecycleWatcher {
|
|
|
270
272
|
const result = await gen.next();
|
|
271
273
|
await gen.return(undefined);
|
|
272
274
|
if (result.done)
|
|
273
|
-
throw new
|
|
275
|
+
throw new errors_1.MacpTransportError('stream ended before receiving a session lifecycle event');
|
|
274
276
|
return result.value;
|
|
275
277
|
}
|
|
276
278
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "macp-sdk-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "TypeScript SDK for the MACP Rust runtime",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@grpc/grpc-js": "^1.14.3",
|
|
58
58
|
"@grpc/proto-loader": "^0.8.0",
|
|
59
|
-
"@multiagentcoordinationprotocol/proto": "^0.1.
|
|
59
|
+
"@multiagentcoordinationprotocol/proto": "^0.1.11",
|
|
60
60
|
"protobufjs": "^8.6.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|