@dcp-ai/create-langchain 2.0.1 → 2.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/template/index.js +14 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcp-ai/create-langchain",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Scaffold a DCP-AI governed LangChain agent project",
5
5
  "type": "module",
6
6
  "bin": {
package/template/index.js CHANGED
@@ -180,9 +180,20 @@ console.log(`📒 Audit entry recorded: ${auditId}`);
180
180
 
181
181
  function canonicalize(obj) {
182
182
  if (obj === null || typeof obj !== "object") return JSON.stringify(obj);
183
- if (Array.isArray(obj)) return "[" + obj.map(canonicalize).join(",") + "]";
184
- const sorted = Object.keys(obj).sort();
185
- return "{" + sorted.map(k => JSON.stringify(k) + ":" + canonicalize(obj[k])).join(",") + "}";
183
+ if (Array.isArray(obj)) {
184
+ // By index: Array#map skips a hole, and join() writes nothing for it or for an undefined.
185
+ // JSON.stringify writes both as null, and so does this.
186
+ const items = [];
187
+ for (let i = 0; i < obj.length; i++) items.push(canonicalize(obj[i]) ?? "null");
188
+ return "[" + items.join(",") + "]";
189
+ }
190
+ // A member with no JSON value (an undefined, a function, a symbol) is left out, as JSON.stringify leaves it out.
191
+ const members = [];
192
+ for (const k of Object.keys(obj).sort()) {
193
+ const v = canonicalize(obj[k]);
194
+ if (v !== undefined) members.push(JSON.stringify(k) + ":" + v);
195
+ }
196
+ return "{" + members.join(",") + "}";
186
197
  }
187
198
 
188
199
  function hashPayload(payload) {