macp-sdk-typescript 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -414,7 +414,7 @@ Run the full SDK against a live MACP runtime:
414
414
 
415
415
  ```bash
416
416
  # Build and start the runtime
417
- docker build -t macp-runtime ../runtime/
417
+ docker build -t macp-runtime ../macp-runtime/
418
418
  docker run -d --name macp-runtime-test -p 50051:50051 \
419
419
  -e MACP_BIND_ADDR=0.0.0.0:50051 -e MACP_ALLOW_INSECURE=1 \
420
420
  -e MACP_ALLOW_DEV_SENDER_HEADER=1 -e MACP_MEMORY_ONLY=1 macp-runtime
package/dist/policy.d.ts CHANGED
@@ -4,6 +4,14 @@ export interface CommitmentRules {
4
4
  designatedRoles?: string[];
5
5
  /** Decision-specific: require quorum before commit. Ignored for other modes. */
6
6
  requireVoteQuorum?: boolean;
7
+ /**
8
+ * RFC-MACP-0012 schema_version 2, Decision mode only: when `true`, a
9
+ * reject-majority resolves the session with a committed *negative* outcome
10
+ * (`outcome_positive = false`) instead of denying commitment. Emitted only by
11
+ * `buildDecisionPolicy`, so the still-v1 quorum/proposal/task/handoff
12
+ * commitment schemas are unaffected. Default `false` preserves v1 behavior.
13
+ */
14
+ allowDeclineOverApproval?: boolean;
7
15
  }
8
16
  export interface VotingRules {
9
17
  algorithm?: 'none' | 'majority' | 'supermajority' | 'unanimous' | 'weighted' | 'plurality';
@@ -17,6 +25,13 @@ export interface VotingRules {
17
25
  export interface ObjectionHandlingRules {
18
26
  criticalSeverityVetoes?: boolean;
19
27
  vetoThreshold?: number;
28
+ /**
29
+ * RFC-MACP-0012 schema_version 2: action taken when a critical objection would
30
+ * block commitment. `deny` rejects the commitment (legacy default),
31
+ * `finalize_decline` resolves the session as a negative outcome, `hold` leaves
32
+ * the session open. Default `deny` preserves v1 behavior.
33
+ */
34
+ criticalObjectionAction?: 'deny' | 'finalize_decline' | 'hold';
20
35
  }
21
36
  export interface EvaluationRules {
22
37
  minimumConfidence?: number;
package/dist/policy.js CHANGED
@@ -16,6 +16,12 @@ function serializeCommitment(commitment) {
16
16
  };
17
17
  }
18
18
  function buildDecisionPolicy(policyId, description, rules) {
19
+ // Decision-only: extend the shared v1 commitment rules with the schema_version 2
20
+ // decline-over-approval switch, appended after the shared keys so it does not
21
+ // leak into the still-v1 quorum/proposal/task/handoff commitment blocks
22
+ // (parity with python-sdk `_commitment_dict` + `build_decision_policy`).
23
+ const commitmentSection = serializeCommitment(rules.commitment);
24
+ commitmentSection.allow_decline_over_approval = rules.commitment?.allowDeclineOverApproval ?? false;
19
25
  const rulesJson = {
20
26
  voting: {
21
27
  algorithm: rules.voting?.algorithm ?? 'none',
@@ -26,19 +32,20 @@ function buildDecisionPolicy(policyId, description, rules) {
26
32
  objection_handling: {
27
33
  critical_severity_vetoes: rules.objectionHandling?.criticalSeverityVetoes ?? false,
28
34
  veto_threshold: rules.objectionHandling?.vetoThreshold ?? 1,
35
+ critical_objection_action: rules.objectionHandling?.criticalObjectionAction ?? 'deny',
29
36
  },
30
37
  evaluation: {
31
38
  minimum_confidence: rules.evaluation?.minimumConfidence ?? 0,
32
39
  required_before_voting: rules.evaluation?.requiredBeforeVoting ?? false,
33
40
  },
34
- commitment: serializeCommitment(rules.commitment),
41
+ commitment: commitmentSection,
35
42
  };
36
43
  return {
37
44
  policyId,
38
45
  mode: 'macp.mode.decision.v1',
39
46
  description,
40
47
  rules: JSON.stringify(rulesJson),
41
- schemaVersion: 1,
48
+ schemaVersion: 2,
42
49
  };
43
50
  }
44
51
  function buildQuorumPolicy(policyId, description, rules) {
@@ -121,12 +121,25 @@ class ProtoRegistry {
121
121
  decodeMessage(typeName, payload) {
122
122
  const type = this.lookupType(typeName);
123
123
  const decoded = type.decode(payload);
124
- return type.toObject(decoded, {
124
+ const obj = type.toObject(decoded, {
125
125
  longs: String,
126
126
  enums: String,
127
127
  bytes: Buffer,
128
128
  defaults: false,
129
129
  });
130
+ // proto3 omits default-valued scalars on the wire; protobufjs (>=8.6) drops
131
+ // them again on decode with `defaults:false`. For a `bool` that means an
132
+ // explicit `false` — e.g. `Commitment.outcome_positive` on a negative
133
+ // (decline) outcome — decodes as *absent*, indistinguishable from unset and
134
+ // silently mis-read as positive. Materialize proto3 bool defaults so the
135
+ // read-model always sees the real boolean, mirroring Python protobuf where a
136
+ // schema bool field is always present.
137
+ for (const field of type.fieldsArray) {
138
+ if (field.type === 'bool' && !field.repeated && obj[field.name] === undefined) {
139
+ obj[field.name] = false;
140
+ }
141
+ }
142
+ return obj;
130
143
  }
131
144
  encodeKnownPayload(mode, messageType, value) {
132
145
  const typeName = this.getKnownTypeName(mode, messageType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macp-sdk-typescript",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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/typescript-sdk.git"
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
58
  "@multiagentcoordinationprotocol/proto": "^0.1.3",
59
- "protobufjs": "^8.0.0"
59
+ "protobufjs": "^8.6.5"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "^22.14.0",