@divergeai/cli 0.1.22 → 0.1.24
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 +62 -6
- package/dist/diverge.mjs +1255 -806
- package/package.json +6 -6
package/dist/diverge.mjs
CHANGED
|
@@ -37,9 +37,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
mod
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
-
// node_modules/yaml/dist/nodes/identity.js
|
|
40
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/identity.js
|
|
41
41
|
var require_identity = __commonJS({
|
|
42
|
-
"node_modules/yaml/dist/nodes/identity.js"(exports) {
|
|
42
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/identity.js"(exports) {
|
|
43
43
|
"use strict";
|
|
44
44
|
var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias");
|
|
45
45
|
var DOC = /* @__PURE__ */ Symbol.for("yaml.document");
|
|
@@ -94,9 +94,9 @@ var require_identity = __commonJS({
|
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
// node_modules/yaml/dist/visit.js
|
|
97
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/visit.js
|
|
98
98
|
var require_visit = __commonJS({
|
|
99
|
-
"node_modules/yaml/dist/visit.js"(exports) {
|
|
99
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/visit.js"(exports) {
|
|
100
100
|
"use strict";
|
|
101
101
|
var identity = require_identity();
|
|
102
102
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
@@ -114,17 +114,17 @@ var require_visit = __commonJS({
|
|
|
114
114
|
visit.BREAK = BREAK;
|
|
115
115
|
visit.SKIP = SKIP;
|
|
116
116
|
visit.REMOVE = REMOVE;
|
|
117
|
-
function visit_(key, node, visitor,
|
|
118
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
117
|
+
function visit_(key, node, visitor, path17) {
|
|
118
|
+
const ctrl = callVisitor(key, node, visitor, path17);
|
|
119
119
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
120
|
-
replaceNode(key,
|
|
121
|
-
return visit_(key, ctrl, visitor,
|
|
120
|
+
replaceNode(key, path17, ctrl);
|
|
121
|
+
return visit_(key, ctrl, visitor, path17);
|
|
122
122
|
}
|
|
123
123
|
if (typeof ctrl !== "symbol") {
|
|
124
124
|
if (identity.isCollection(node)) {
|
|
125
|
-
|
|
125
|
+
path17 = Object.freeze(path17.concat(node));
|
|
126
126
|
for (let i = 0; i < node.items.length; ++i) {
|
|
127
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
127
|
+
const ci = visit_(i, node.items[i], visitor, path17);
|
|
128
128
|
if (typeof ci === "number")
|
|
129
129
|
i = ci - 1;
|
|
130
130
|
else if (ci === BREAK)
|
|
@@ -135,13 +135,13 @@ var require_visit = __commonJS({
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
} else if (identity.isPair(node)) {
|
|
138
|
-
|
|
139
|
-
const ck = visit_("key", node.key, visitor,
|
|
138
|
+
path17 = Object.freeze(path17.concat(node));
|
|
139
|
+
const ck = visit_("key", node.key, visitor, path17);
|
|
140
140
|
if (ck === BREAK)
|
|
141
141
|
return BREAK;
|
|
142
142
|
else if (ck === REMOVE)
|
|
143
143
|
node.key = null;
|
|
144
|
-
const cv = visit_("value", node.value, visitor,
|
|
144
|
+
const cv = visit_("value", node.value, visitor, path17);
|
|
145
145
|
if (cv === BREAK)
|
|
146
146
|
return BREAK;
|
|
147
147
|
else if (cv === REMOVE)
|
|
@@ -162,17 +162,17 @@ var require_visit = __commonJS({
|
|
|
162
162
|
visitAsync.BREAK = BREAK;
|
|
163
163
|
visitAsync.SKIP = SKIP;
|
|
164
164
|
visitAsync.REMOVE = REMOVE;
|
|
165
|
-
async function visitAsync_(key, node, visitor,
|
|
166
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
165
|
+
async function visitAsync_(key, node, visitor, path17) {
|
|
166
|
+
const ctrl = await callVisitor(key, node, visitor, path17);
|
|
167
167
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
168
|
-
replaceNode(key,
|
|
169
|
-
return visitAsync_(key, ctrl, visitor,
|
|
168
|
+
replaceNode(key, path17, ctrl);
|
|
169
|
+
return visitAsync_(key, ctrl, visitor, path17);
|
|
170
170
|
}
|
|
171
171
|
if (typeof ctrl !== "symbol") {
|
|
172
172
|
if (identity.isCollection(node)) {
|
|
173
|
-
|
|
173
|
+
path17 = Object.freeze(path17.concat(node));
|
|
174
174
|
for (let i = 0; i < node.items.length; ++i) {
|
|
175
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
175
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path17);
|
|
176
176
|
if (typeof ci === "number")
|
|
177
177
|
i = ci - 1;
|
|
178
178
|
else if (ci === BREAK)
|
|
@@ -183,13 +183,13 @@ var require_visit = __commonJS({
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
} else if (identity.isPair(node)) {
|
|
186
|
-
|
|
187
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
186
|
+
path17 = Object.freeze(path17.concat(node));
|
|
187
|
+
const ck = await visitAsync_("key", node.key, visitor, path17);
|
|
188
188
|
if (ck === BREAK)
|
|
189
189
|
return BREAK;
|
|
190
190
|
else if (ck === REMOVE)
|
|
191
191
|
node.key = null;
|
|
192
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
192
|
+
const cv = await visitAsync_("value", node.value, visitor, path17);
|
|
193
193
|
if (cv === BREAK)
|
|
194
194
|
return BREAK;
|
|
195
195
|
else if (cv === REMOVE)
|
|
@@ -216,23 +216,23 @@ var require_visit = __commonJS({
|
|
|
216
216
|
}
|
|
217
217
|
return visitor;
|
|
218
218
|
}
|
|
219
|
-
function callVisitor(key, node, visitor,
|
|
219
|
+
function callVisitor(key, node, visitor, path17) {
|
|
220
220
|
if (typeof visitor === "function")
|
|
221
|
-
return visitor(key, node,
|
|
221
|
+
return visitor(key, node, path17);
|
|
222
222
|
if (identity.isMap(node))
|
|
223
|
-
return visitor.Map?.(key, node,
|
|
223
|
+
return visitor.Map?.(key, node, path17);
|
|
224
224
|
if (identity.isSeq(node))
|
|
225
|
-
return visitor.Seq?.(key, node,
|
|
225
|
+
return visitor.Seq?.(key, node, path17);
|
|
226
226
|
if (identity.isPair(node))
|
|
227
|
-
return visitor.Pair?.(key, node,
|
|
227
|
+
return visitor.Pair?.(key, node, path17);
|
|
228
228
|
if (identity.isScalar(node))
|
|
229
|
-
return visitor.Scalar?.(key, node,
|
|
229
|
+
return visitor.Scalar?.(key, node, path17);
|
|
230
230
|
if (identity.isAlias(node))
|
|
231
|
-
return visitor.Alias?.(key, node,
|
|
231
|
+
return visitor.Alias?.(key, node, path17);
|
|
232
232
|
return void 0;
|
|
233
233
|
}
|
|
234
|
-
function replaceNode(key,
|
|
235
|
-
const parent =
|
|
234
|
+
function replaceNode(key, path17, node) {
|
|
235
|
+
const parent = path17[path17.length - 1];
|
|
236
236
|
if (identity.isCollection(parent)) {
|
|
237
237
|
parent.items[key] = node;
|
|
238
238
|
} else if (identity.isPair(parent)) {
|
|
@@ -252,9 +252,9 @@ var require_visit = __commonJS({
|
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
// node_modules/yaml/dist/doc/directives.js
|
|
255
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/directives.js
|
|
256
256
|
var require_directives = __commonJS({
|
|
257
|
-
"node_modules/yaml/dist/doc/directives.js"(exports) {
|
|
257
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/directives.js"(exports) {
|
|
258
258
|
"use strict";
|
|
259
259
|
var identity = require_identity();
|
|
260
260
|
var visit = require_visit();
|
|
@@ -423,9 +423,9 @@ var require_directives = __commonJS({
|
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
425
|
|
|
426
|
-
// node_modules/yaml/dist/doc/anchors.js
|
|
426
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/anchors.js
|
|
427
427
|
var require_anchors = __commonJS({
|
|
428
|
-
"node_modules/yaml/dist/doc/anchors.js"(exports) {
|
|
428
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/anchors.js"(exports) {
|
|
429
429
|
"use strict";
|
|
430
430
|
var identity = require_identity();
|
|
431
431
|
var visit = require_visit();
|
|
@@ -493,9 +493,9 @@ var require_anchors = __commonJS({
|
|
|
493
493
|
}
|
|
494
494
|
});
|
|
495
495
|
|
|
496
|
-
// node_modules/yaml/dist/doc/applyReviver.js
|
|
496
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/applyReviver.js
|
|
497
497
|
var require_applyReviver = __commonJS({
|
|
498
|
-
"node_modules/yaml/dist/doc/applyReviver.js"(exports) {
|
|
498
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/applyReviver.js"(exports) {
|
|
499
499
|
"use strict";
|
|
500
500
|
function applyReviver(reviver, obj, key, val) {
|
|
501
501
|
if (val && typeof val === "object") {
|
|
@@ -543,9 +543,9 @@ var require_applyReviver = __commonJS({
|
|
|
543
543
|
}
|
|
544
544
|
});
|
|
545
545
|
|
|
546
|
-
// node_modules/yaml/dist/nodes/toJS.js
|
|
546
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/toJS.js
|
|
547
547
|
var require_toJS = __commonJS({
|
|
548
|
-
"node_modules/yaml/dist/nodes/toJS.js"(exports) {
|
|
548
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/toJS.js"(exports) {
|
|
549
549
|
"use strict";
|
|
550
550
|
var identity = require_identity();
|
|
551
551
|
function toJS(value, arg, ctx) {
|
|
@@ -573,9 +573,9 @@ var require_toJS = __commonJS({
|
|
|
573
573
|
}
|
|
574
574
|
});
|
|
575
575
|
|
|
576
|
-
// node_modules/yaml/dist/nodes/Node.js
|
|
576
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Node.js
|
|
577
577
|
var require_Node = __commonJS({
|
|
578
|
-
"node_modules/yaml/dist/nodes/Node.js"(exports) {
|
|
578
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Node.js"(exports) {
|
|
579
579
|
"use strict";
|
|
580
580
|
var applyReviver = require_applyReviver();
|
|
581
581
|
var identity = require_identity();
|
|
@@ -614,9 +614,9 @@ var require_Node = __commonJS({
|
|
|
614
614
|
}
|
|
615
615
|
});
|
|
616
616
|
|
|
617
|
-
// node_modules/yaml/dist/nodes/Alias.js
|
|
617
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Alias.js
|
|
618
618
|
var require_Alias = __commonJS({
|
|
619
|
-
"node_modules/yaml/dist/nodes/Alias.js"(exports) {
|
|
619
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Alias.js"(exports) {
|
|
620
620
|
"use strict";
|
|
621
621
|
var anchors = require_anchors();
|
|
622
622
|
var visit = require_visit();
|
|
@@ -661,36 +661,38 @@ var require_Alias = __commonJS({
|
|
|
661
661
|
if (node.anchor === this.source)
|
|
662
662
|
found = node;
|
|
663
663
|
}
|
|
664
|
+
if (found && ctx) {
|
|
665
|
+
const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
|
|
666
|
+
let data = anchors2.get(found);
|
|
667
|
+
if (!data) {
|
|
668
|
+
toJS.toJS(found, null, ctx);
|
|
669
|
+
data = anchors2.get(found);
|
|
670
|
+
}
|
|
671
|
+
if (data?.res === void 0) {
|
|
672
|
+
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
673
|
+
throw new ReferenceError(msg);
|
|
674
|
+
}
|
|
675
|
+
if (maxAliasCount >= 0) {
|
|
676
|
+
data.count += 1;
|
|
677
|
+
if (data.aliasCount === 0)
|
|
678
|
+
data.aliasCount = getAliasCount(doc2, found, anchors2);
|
|
679
|
+
if (data.count * data.aliasCount > maxAliasCount) {
|
|
680
|
+
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
681
|
+
throw new ReferenceError(msg);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
664
685
|
return found;
|
|
665
686
|
}
|
|
666
687
|
toJSON(_arg, ctx) {
|
|
667
688
|
if (!ctx)
|
|
668
689
|
return { source: this.source };
|
|
669
|
-
const
|
|
670
|
-
const source = this.resolve(doc, ctx);
|
|
690
|
+
const source = this.resolve(ctx.doc, ctx);
|
|
671
691
|
if (!source) {
|
|
672
692
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
673
693
|
throw new ReferenceError(msg);
|
|
674
694
|
}
|
|
675
|
-
|
|
676
|
-
if (!data) {
|
|
677
|
-
toJS.toJS(source, null, ctx);
|
|
678
|
-
data = anchors2.get(source);
|
|
679
|
-
}
|
|
680
|
-
if (data?.res === void 0) {
|
|
681
|
-
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
682
|
-
throw new ReferenceError(msg);
|
|
683
|
-
}
|
|
684
|
-
if (maxAliasCount >= 0) {
|
|
685
|
-
data.count += 1;
|
|
686
|
-
if (data.aliasCount === 0)
|
|
687
|
-
data.aliasCount = getAliasCount(doc, source, anchors2);
|
|
688
|
-
if (data.count * data.aliasCount > maxAliasCount) {
|
|
689
|
-
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
690
|
-
throw new ReferenceError(msg);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
return data.res;
|
|
695
|
+
return ctx.anchors.get(source).res;
|
|
694
696
|
}
|
|
695
697
|
toString(ctx, _onComment, _onChompKeep) {
|
|
696
698
|
const src = `*${this.source}`;
|
|
@@ -730,9 +732,9 @@ var require_Alias = __commonJS({
|
|
|
730
732
|
}
|
|
731
733
|
});
|
|
732
734
|
|
|
733
|
-
// node_modules/yaml/dist/nodes/Scalar.js
|
|
735
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Scalar.js
|
|
734
736
|
var require_Scalar = __commonJS({
|
|
735
|
-
"node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
737
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
736
738
|
"use strict";
|
|
737
739
|
var identity = require_identity();
|
|
738
740
|
var Node = require_Node();
|
|
@@ -760,9 +762,9 @@ var require_Scalar = __commonJS({
|
|
|
760
762
|
}
|
|
761
763
|
});
|
|
762
764
|
|
|
763
|
-
// node_modules/yaml/dist/doc/createNode.js
|
|
765
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/createNode.js
|
|
764
766
|
var require_createNode = __commonJS({
|
|
765
|
-
"node_modules/yaml/dist/doc/createNode.js"(exports) {
|
|
767
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/createNode.js"(exports) {
|
|
766
768
|
"use strict";
|
|
767
769
|
var Alias = require_Alias();
|
|
768
770
|
var identity = require_identity();
|
|
@@ -835,17 +837,17 @@ var require_createNode = __commonJS({
|
|
|
835
837
|
}
|
|
836
838
|
});
|
|
837
839
|
|
|
838
|
-
// node_modules/yaml/dist/nodes/Collection.js
|
|
840
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Collection.js
|
|
839
841
|
var require_Collection = __commonJS({
|
|
840
|
-
"node_modules/yaml/dist/nodes/Collection.js"(exports) {
|
|
842
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Collection.js"(exports) {
|
|
841
843
|
"use strict";
|
|
842
844
|
var createNode = require_createNode();
|
|
843
845
|
var identity = require_identity();
|
|
844
846
|
var Node = require_Node();
|
|
845
|
-
function collectionFromPath(schema,
|
|
847
|
+
function collectionFromPath(schema, path17, value) {
|
|
846
848
|
let v = value;
|
|
847
|
-
for (let i =
|
|
848
|
-
const k =
|
|
849
|
+
for (let i = path17.length - 1; i >= 0; --i) {
|
|
850
|
+
const k = path17[i];
|
|
849
851
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
850
852
|
const a = [];
|
|
851
853
|
a[k] = v;
|
|
@@ -864,7 +866,7 @@ var require_Collection = __commonJS({
|
|
|
864
866
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
865
867
|
});
|
|
866
868
|
}
|
|
867
|
-
var isEmptyPath = (
|
|
869
|
+
var isEmptyPath = (path17) => path17 == null || typeof path17 === "object" && !!path17[Symbol.iterator]().next().done;
|
|
868
870
|
var Collection = class extends Node.NodeBase {
|
|
869
871
|
constructor(type, schema) {
|
|
870
872
|
super(type);
|
|
@@ -894,11 +896,11 @@ var require_Collection = __commonJS({
|
|
|
894
896
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
895
897
|
* that already exists in the map.
|
|
896
898
|
*/
|
|
897
|
-
addIn(
|
|
898
|
-
if (isEmptyPath(
|
|
899
|
+
addIn(path17, value) {
|
|
900
|
+
if (isEmptyPath(path17))
|
|
899
901
|
this.add(value);
|
|
900
902
|
else {
|
|
901
|
-
const [key, ...rest] =
|
|
903
|
+
const [key, ...rest] = path17;
|
|
902
904
|
const node = this.get(key, true);
|
|
903
905
|
if (identity.isCollection(node))
|
|
904
906
|
node.addIn(rest, value);
|
|
@@ -912,8 +914,8 @@ var require_Collection = __commonJS({
|
|
|
912
914
|
* Removes a value from the collection.
|
|
913
915
|
* @returns `true` if the item was found and removed.
|
|
914
916
|
*/
|
|
915
|
-
deleteIn(
|
|
916
|
-
const [key, ...rest] =
|
|
917
|
+
deleteIn(path17) {
|
|
918
|
+
const [key, ...rest] = path17;
|
|
917
919
|
if (rest.length === 0)
|
|
918
920
|
return this.delete(key);
|
|
919
921
|
const node = this.get(key, true);
|
|
@@ -927,8 +929,8 @@ var require_Collection = __commonJS({
|
|
|
927
929
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
928
930
|
* `true` (collections are always returned intact).
|
|
929
931
|
*/
|
|
930
|
-
getIn(
|
|
931
|
-
const [key, ...rest] =
|
|
932
|
+
getIn(path17, keepScalar) {
|
|
933
|
+
const [key, ...rest] = path17;
|
|
932
934
|
const node = this.get(key, true);
|
|
933
935
|
if (rest.length === 0)
|
|
934
936
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -946,8 +948,8 @@ var require_Collection = __commonJS({
|
|
|
946
948
|
/**
|
|
947
949
|
* Checks if the collection includes a value with the key `key`.
|
|
948
950
|
*/
|
|
949
|
-
hasIn(
|
|
950
|
-
const [key, ...rest] =
|
|
951
|
+
hasIn(path17) {
|
|
952
|
+
const [key, ...rest] = path17;
|
|
951
953
|
if (rest.length === 0)
|
|
952
954
|
return this.has(key);
|
|
953
955
|
const node = this.get(key, true);
|
|
@@ -957,8 +959,8 @@ var require_Collection = __commonJS({
|
|
|
957
959
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
958
960
|
* boolean to add/remove the item from the set.
|
|
959
961
|
*/
|
|
960
|
-
setIn(
|
|
961
|
-
const [key, ...rest] =
|
|
962
|
+
setIn(path17, value) {
|
|
963
|
+
const [key, ...rest] = path17;
|
|
962
964
|
if (rest.length === 0) {
|
|
963
965
|
this.set(key, value);
|
|
964
966
|
} else {
|
|
@@ -978,9 +980,9 @@ var require_Collection = __commonJS({
|
|
|
978
980
|
}
|
|
979
981
|
});
|
|
980
982
|
|
|
981
|
-
// node_modules/yaml/dist/stringify/stringifyComment.js
|
|
983
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyComment.js
|
|
982
984
|
var require_stringifyComment = __commonJS({
|
|
983
|
-
"node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
|
|
985
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
|
|
984
986
|
"use strict";
|
|
985
987
|
var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
|
|
986
988
|
function indentComment(comment, indent) {
|
|
@@ -995,9 +997,9 @@ var require_stringifyComment = __commonJS({
|
|
|
995
997
|
}
|
|
996
998
|
});
|
|
997
999
|
|
|
998
|
-
// node_modules/yaml/dist/stringify/foldFlowLines.js
|
|
1000
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/foldFlowLines.js
|
|
999
1001
|
var require_foldFlowLines = __commonJS({
|
|
1000
|
-
"node_modules/yaml/dist/stringify/foldFlowLines.js"(exports) {
|
|
1002
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/foldFlowLines.js"(exports) {
|
|
1001
1003
|
"use strict";
|
|
1002
1004
|
var FOLD_FLOW = "flow";
|
|
1003
1005
|
var FOLD_BLOCK = "block";
|
|
@@ -1131,9 +1133,9 @@ ${indent}${text.slice(fold + 1, end2)}`;
|
|
|
1131
1133
|
}
|
|
1132
1134
|
});
|
|
1133
1135
|
|
|
1134
|
-
// node_modules/yaml/dist/stringify/stringifyString.js
|
|
1136
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyString.js
|
|
1135
1137
|
var require_stringifyString = __commonJS({
|
|
1136
|
-
"node_modules/yaml/dist/stringify/stringifyString.js"(exports) {
|
|
1138
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyString.js"(exports) {
|
|
1137
1139
|
"use strict";
|
|
1138
1140
|
var Scalar = require_Scalar();
|
|
1139
1141
|
var foldFlowLines = require_foldFlowLines();
|
|
@@ -1414,9 +1416,9 @@ ${indent}`);
|
|
|
1414
1416
|
}
|
|
1415
1417
|
});
|
|
1416
1418
|
|
|
1417
|
-
// node_modules/yaml/dist/stringify/stringify.js
|
|
1419
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringify.js
|
|
1418
1420
|
var require_stringify = __commonJS({
|
|
1419
|
-
"node_modules/yaml/dist/stringify/stringify.js"(exports) {
|
|
1421
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringify.js"(exports) {
|
|
1420
1422
|
"use strict";
|
|
1421
1423
|
var anchors = require_anchors();
|
|
1422
1424
|
var identity = require_identity();
|
|
@@ -1538,9 +1540,9 @@ ${ctx.indent}${str}`;
|
|
|
1538
1540
|
}
|
|
1539
1541
|
});
|
|
1540
1542
|
|
|
1541
|
-
// node_modules/yaml/dist/stringify/stringifyPair.js
|
|
1543
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyPair.js
|
|
1542
1544
|
var require_stringifyPair = __commonJS({
|
|
1543
|
-
"node_modules/yaml/dist/stringify/stringifyPair.js"(exports) {
|
|
1545
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyPair.js"(exports) {
|
|
1544
1546
|
"use strict";
|
|
1545
1547
|
var identity = require_identity();
|
|
1546
1548
|
var Scalar = require_Scalar();
|
|
@@ -1671,9 +1673,9 @@ ${ctx.indent}`;
|
|
|
1671
1673
|
}
|
|
1672
1674
|
});
|
|
1673
1675
|
|
|
1674
|
-
// node_modules/yaml/dist/log.js
|
|
1676
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/log.js
|
|
1675
1677
|
var require_log = __commonJS({
|
|
1676
|
-
"node_modules/yaml/dist/log.js"(exports) {
|
|
1678
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/log.js"(exports) {
|
|
1677
1679
|
"use strict";
|
|
1678
1680
|
var node_process = __require("process");
|
|
1679
1681
|
function debug(logLevel, ...messages) {
|
|
@@ -1693,9 +1695,9 @@ var require_log = __commonJS({
|
|
|
1693
1695
|
}
|
|
1694
1696
|
});
|
|
1695
1697
|
|
|
1696
|
-
// node_modules/yaml/dist/schema/yaml-1.1/merge.js
|
|
1698
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/merge.js
|
|
1697
1699
|
var require_merge = __commonJS({
|
|
1698
|
-
"node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports) {
|
|
1700
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports) {
|
|
1699
1701
|
"use strict";
|
|
1700
1702
|
var identity = require_identity();
|
|
1701
1703
|
var Scalar = require_Scalar();
|
|
@@ -1753,9 +1755,9 @@ var require_merge = __commonJS({
|
|
|
1753
1755
|
}
|
|
1754
1756
|
});
|
|
1755
1757
|
|
|
1756
|
-
// node_modules/yaml/dist/nodes/addPairToJSMap.js
|
|
1758
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/addPairToJSMap.js
|
|
1757
1759
|
var require_addPairToJSMap = __commonJS({
|
|
1758
|
-
"node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
|
|
1760
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
|
|
1759
1761
|
"use strict";
|
|
1760
1762
|
var log = require_log();
|
|
1761
1763
|
var merge = require_merge();
|
|
@@ -1817,9 +1819,9 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1817
1819
|
}
|
|
1818
1820
|
});
|
|
1819
1821
|
|
|
1820
|
-
// node_modules/yaml/dist/nodes/Pair.js
|
|
1822
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Pair.js
|
|
1821
1823
|
var require_Pair = __commonJS({
|
|
1822
|
-
"node_modules/yaml/dist/nodes/Pair.js"(exports) {
|
|
1824
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Pair.js"(exports) {
|
|
1823
1825
|
"use strict";
|
|
1824
1826
|
var createNode = require_createNode();
|
|
1825
1827
|
var stringifyPair = require_stringifyPair();
|
|
@@ -1857,9 +1859,9 @@ var require_Pair = __commonJS({
|
|
|
1857
1859
|
}
|
|
1858
1860
|
});
|
|
1859
1861
|
|
|
1860
|
-
// node_modules/yaml/dist/stringify/stringifyCollection.js
|
|
1862
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyCollection.js
|
|
1861
1863
|
var require_stringifyCollection = __commonJS({
|
|
1862
|
-
"node_modules/yaml/dist/stringify/stringifyCollection.js"(exports) {
|
|
1864
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports) {
|
|
1863
1865
|
"use strict";
|
|
1864
1866
|
var identity = require_identity();
|
|
1865
1867
|
var stringify = require_stringify();
|
|
@@ -2008,9 +2010,9 @@ ${indent}${end}`;
|
|
|
2008
2010
|
}
|
|
2009
2011
|
});
|
|
2010
2012
|
|
|
2011
|
-
// node_modules/yaml/dist/nodes/YAMLMap.js
|
|
2013
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/YAMLMap.js
|
|
2012
2014
|
var require_YAMLMap = __commonJS({
|
|
2013
|
-
"node_modules/yaml/dist/nodes/YAMLMap.js"(exports) {
|
|
2015
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/YAMLMap.js"(exports) {
|
|
2014
2016
|
"use strict";
|
|
2015
2017
|
var stringifyCollection = require_stringifyCollection();
|
|
2016
2018
|
var addPairToJSMap = require_addPairToJSMap();
|
|
@@ -2152,9 +2154,9 @@ var require_YAMLMap = __commonJS({
|
|
|
2152
2154
|
}
|
|
2153
2155
|
});
|
|
2154
2156
|
|
|
2155
|
-
// node_modules/yaml/dist/schema/common/map.js
|
|
2157
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/map.js
|
|
2156
2158
|
var require_map = __commonJS({
|
|
2157
|
-
"node_modules/yaml/dist/schema/common/map.js"(exports) {
|
|
2159
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/map.js"(exports) {
|
|
2158
2160
|
"use strict";
|
|
2159
2161
|
var identity = require_identity();
|
|
2160
2162
|
var YAMLMap = require_YAMLMap();
|
|
@@ -2174,9 +2176,9 @@ var require_map = __commonJS({
|
|
|
2174
2176
|
}
|
|
2175
2177
|
});
|
|
2176
2178
|
|
|
2177
|
-
// node_modules/yaml/dist/nodes/YAMLSeq.js
|
|
2179
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/YAMLSeq.js
|
|
2178
2180
|
var require_YAMLSeq = __commonJS({
|
|
2179
|
-
"node_modules/yaml/dist/nodes/YAMLSeq.js"(exports) {
|
|
2181
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/YAMLSeq.js"(exports) {
|
|
2180
2182
|
"use strict";
|
|
2181
2183
|
var createNode = require_createNode();
|
|
2182
2184
|
var stringifyCollection = require_stringifyCollection();
|
|
@@ -2290,9 +2292,9 @@ var require_YAMLSeq = __commonJS({
|
|
|
2290
2292
|
}
|
|
2291
2293
|
});
|
|
2292
2294
|
|
|
2293
|
-
// node_modules/yaml/dist/schema/common/seq.js
|
|
2295
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/seq.js
|
|
2294
2296
|
var require_seq = __commonJS({
|
|
2295
|
-
"node_modules/yaml/dist/schema/common/seq.js"(exports) {
|
|
2297
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/seq.js"(exports) {
|
|
2296
2298
|
"use strict";
|
|
2297
2299
|
var identity = require_identity();
|
|
2298
2300
|
var YAMLSeq = require_YAMLSeq();
|
|
@@ -2312,9 +2314,9 @@ var require_seq = __commonJS({
|
|
|
2312
2314
|
}
|
|
2313
2315
|
});
|
|
2314
2316
|
|
|
2315
|
-
// node_modules/yaml/dist/schema/common/string.js
|
|
2317
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/string.js
|
|
2316
2318
|
var require_string = __commonJS({
|
|
2317
|
-
"node_modules/yaml/dist/schema/common/string.js"(exports) {
|
|
2319
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/string.js"(exports) {
|
|
2318
2320
|
"use strict";
|
|
2319
2321
|
var stringifyString = require_stringifyString();
|
|
2320
2322
|
var string = {
|
|
@@ -2331,9 +2333,9 @@ var require_string = __commonJS({
|
|
|
2331
2333
|
}
|
|
2332
2334
|
});
|
|
2333
2335
|
|
|
2334
|
-
// node_modules/yaml/dist/schema/common/null.js
|
|
2336
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/null.js
|
|
2335
2337
|
var require_null = __commonJS({
|
|
2336
|
-
"node_modules/yaml/dist/schema/common/null.js"(exports) {
|
|
2338
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/common/null.js"(exports) {
|
|
2337
2339
|
"use strict";
|
|
2338
2340
|
var Scalar = require_Scalar();
|
|
2339
2341
|
var nullTag = {
|
|
@@ -2349,9 +2351,9 @@ var require_null = __commonJS({
|
|
|
2349
2351
|
}
|
|
2350
2352
|
});
|
|
2351
2353
|
|
|
2352
|
-
// node_modules/yaml/dist/schema/core/bool.js
|
|
2354
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/bool.js
|
|
2353
2355
|
var require_bool = __commonJS({
|
|
2354
|
-
"node_modules/yaml/dist/schema/core/bool.js"(exports) {
|
|
2356
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/bool.js"(exports) {
|
|
2355
2357
|
"use strict";
|
|
2356
2358
|
var Scalar = require_Scalar();
|
|
2357
2359
|
var boolTag = {
|
|
@@ -2373,9 +2375,9 @@ var require_bool = __commonJS({
|
|
|
2373
2375
|
}
|
|
2374
2376
|
});
|
|
2375
2377
|
|
|
2376
|
-
// node_modules/yaml/dist/stringify/stringifyNumber.js
|
|
2378
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyNumber.js
|
|
2377
2379
|
var require_stringifyNumber = __commonJS({
|
|
2378
|
-
"node_modules/yaml/dist/stringify/stringifyNumber.js"(exports) {
|
|
2380
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyNumber.js"(exports) {
|
|
2379
2381
|
"use strict";
|
|
2380
2382
|
function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
|
2381
2383
|
if (typeof value === "bigint")
|
|
@@ -2400,9 +2402,9 @@ var require_stringifyNumber = __commonJS({
|
|
|
2400
2402
|
}
|
|
2401
2403
|
});
|
|
2402
2404
|
|
|
2403
|
-
// node_modules/yaml/dist/schema/core/float.js
|
|
2405
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/float.js
|
|
2404
2406
|
var require_float = __commonJS({
|
|
2405
|
-
"node_modules/yaml/dist/schema/core/float.js"(exports) {
|
|
2407
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/float.js"(exports) {
|
|
2406
2408
|
"use strict";
|
|
2407
2409
|
var Scalar = require_Scalar();
|
|
2408
2410
|
var stringifyNumber = require_stringifyNumber();
|
|
@@ -2446,9 +2448,9 @@ var require_float = __commonJS({
|
|
|
2446
2448
|
}
|
|
2447
2449
|
});
|
|
2448
2450
|
|
|
2449
|
-
// node_modules/yaml/dist/schema/core/int.js
|
|
2451
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/int.js
|
|
2450
2452
|
var require_int = __commonJS({
|
|
2451
|
-
"node_modules/yaml/dist/schema/core/int.js"(exports) {
|
|
2453
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/int.js"(exports) {
|
|
2452
2454
|
"use strict";
|
|
2453
2455
|
var stringifyNumber = require_stringifyNumber();
|
|
2454
2456
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
@@ -2491,9 +2493,9 @@ var require_int = __commonJS({
|
|
|
2491
2493
|
}
|
|
2492
2494
|
});
|
|
2493
2495
|
|
|
2494
|
-
// node_modules/yaml/dist/schema/core/schema.js
|
|
2496
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/schema.js
|
|
2495
2497
|
var require_schema = __commonJS({
|
|
2496
|
-
"node_modules/yaml/dist/schema/core/schema.js"(exports) {
|
|
2498
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/core/schema.js"(exports) {
|
|
2497
2499
|
"use strict";
|
|
2498
2500
|
var map = require_map();
|
|
2499
2501
|
var _null = require_null();
|
|
@@ -2519,9 +2521,9 @@ var require_schema = __commonJS({
|
|
|
2519
2521
|
}
|
|
2520
2522
|
});
|
|
2521
2523
|
|
|
2522
|
-
// node_modules/yaml/dist/schema/json/schema.js
|
|
2524
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/json/schema.js
|
|
2523
2525
|
var require_schema2 = __commonJS({
|
|
2524
|
-
"node_modules/yaml/dist/schema/json/schema.js"(exports) {
|
|
2526
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/json/schema.js"(exports) {
|
|
2525
2527
|
"use strict";
|
|
2526
2528
|
var Scalar = require_Scalar();
|
|
2527
2529
|
var map = require_map();
|
|
@@ -2586,9 +2588,9 @@ var require_schema2 = __commonJS({
|
|
|
2586
2588
|
}
|
|
2587
2589
|
});
|
|
2588
2590
|
|
|
2589
|
-
// node_modules/yaml/dist/schema/yaml-1.1/binary.js
|
|
2591
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/binary.js
|
|
2590
2592
|
var require_binary = __commonJS({
|
|
2591
|
-
"node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports) {
|
|
2593
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports) {
|
|
2592
2594
|
"use strict";
|
|
2593
2595
|
var node_buffer = __require("buffer");
|
|
2594
2596
|
var Scalar = require_Scalar();
|
|
@@ -2652,9 +2654,9 @@ var require_binary = __commonJS({
|
|
|
2652
2654
|
}
|
|
2653
2655
|
});
|
|
2654
2656
|
|
|
2655
|
-
// node_modules/yaml/dist/schema/yaml-1.1/pairs.js
|
|
2657
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/pairs.js
|
|
2656
2658
|
var require_pairs = __commonJS({
|
|
2657
|
-
"node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports) {
|
|
2659
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports) {
|
|
2658
2660
|
"use strict";
|
|
2659
2661
|
var identity = require_identity();
|
|
2660
2662
|
var Pair = require_Pair();
|
|
@@ -2730,9 +2732,9 @@ ${cn.comment}` : item.comment;
|
|
|
2730
2732
|
}
|
|
2731
2733
|
});
|
|
2732
2734
|
|
|
2733
|
-
// node_modules/yaml/dist/schema/yaml-1.1/omap.js
|
|
2735
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/omap.js
|
|
2734
2736
|
var require_omap = __commonJS({
|
|
2735
|
-
"node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports) {
|
|
2737
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports) {
|
|
2736
2738
|
"use strict";
|
|
2737
2739
|
var identity = require_identity();
|
|
2738
2740
|
var toJS = require_toJS();
|
|
@@ -2808,9 +2810,9 @@ var require_omap = __commonJS({
|
|
|
2808
2810
|
}
|
|
2809
2811
|
});
|
|
2810
2812
|
|
|
2811
|
-
// node_modules/yaml/dist/schema/yaml-1.1/bool.js
|
|
2813
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/bool.js
|
|
2812
2814
|
var require_bool2 = __commonJS({
|
|
2813
|
-
"node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) {
|
|
2815
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) {
|
|
2814
2816
|
"use strict";
|
|
2815
2817
|
var Scalar = require_Scalar();
|
|
2816
2818
|
function boolStringify({ value, source }, ctx) {
|
|
@@ -2840,9 +2842,9 @@ var require_bool2 = __commonJS({
|
|
|
2840
2842
|
}
|
|
2841
2843
|
});
|
|
2842
2844
|
|
|
2843
|
-
// node_modules/yaml/dist/schema/yaml-1.1/float.js
|
|
2845
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/float.js
|
|
2844
2846
|
var require_float2 = __commonJS({
|
|
2845
|
-
"node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports) {
|
|
2847
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports) {
|
|
2846
2848
|
"use strict";
|
|
2847
2849
|
var Scalar = require_Scalar();
|
|
2848
2850
|
var stringifyNumber = require_stringifyNumber();
|
|
@@ -2889,9 +2891,9 @@ var require_float2 = __commonJS({
|
|
|
2889
2891
|
}
|
|
2890
2892
|
});
|
|
2891
2893
|
|
|
2892
|
-
// node_modules/yaml/dist/schema/yaml-1.1/int.js
|
|
2894
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/int.js
|
|
2893
2895
|
var require_int2 = __commonJS({
|
|
2894
|
-
"node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports) {
|
|
2896
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports) {
|
|
2895
2897
|
"use strict";
|
|
2896
2898
|
var stringifyNumber = require_stringifyNumber();
|
|
2897
2899
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
@@ -2968,9 +2970,9 @@ var require_int2 = __commonJS({
|
|
|
2968
2970
|
}
|
|
2969
2971
|
});
|
|
2970
2972
|
|
|
2971
|
-
// node_modules/yaml/dist/schema/yaml-1.1/set.js
|
|
2973
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/set.js
|
|
2972
2974
|
var require_set = __commonJS({
|
|
2973
|
-
"node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports) {
|
|
2975
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports) {
|
|
2974
2976
|
"use strict";
|
|
2975
2977
|
var identity = require_identity();
|
|
2976
2978
|
var Pair = require_Pair();
|
|
@@ -3023,18 +3025,18 @@ var require_set = __commonJS({
|
|
|
3023
3025
|
}
|
|
3024
3026
|
static from(schema, iterable, ctx) {
|
|
3025
3027
|
const { replacer } = ctx;
|
|
3026
|
-
const
|
|
3028
|
+
const set3 = new this(schema);
|
|
3027
3029
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
3028
3030
|
for (let value of iterable) {
|
|
3029
3031
|
if (typeof replacer === "function")
|
|
3030
3032
|
value = replacer.call(iterable, value, value);
|
|
3031
|
-
|
|
3033
|
+
set3.items.push(Pair.createPair(value, null, ctx));
|
|
3032
3034
|
}
|
|
3033
|
-
return
|
|
3035
|
+
return set3;
|
|
3034
3036
|
}
|
|
3035
3037
|
};
|
|
3036
3038
|
YAMLSet.tag = "tag:yaml.org,2002:set";
|
|
3037
|
-
var
|
|
3039
|
+
var set2 = {
|
|
3038
3040
|
collection: "map",
|
|
3039
3041
|
identify: (value) => value instanceof Set,
|
|
3040
3042
|
nodeClass: YAMLSet,
|
|
@@ -3053,13 +3055,13 @@ var require_set = __commonJS({
|
|
|
3053
3055
|
}
|
|
3054
3056
|
};
|
|
3055
3057
|
exports.YAMLSet = YAMLSet;
|
|
3056
|
-
exports.set =
|
|
3058
|
+
exports.set = set2;
|
|
3057
3059
|
}
|
|
3058
3060
|
});
|
|
3059
3061
|
|
|
3060
|
-
// node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
|
|
3062
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
|
|
3061
3063
|
var require_timestamp = __commonJS({
|
|
3062
|
-
"node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
3064
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
3063
3065
|
"use strict";
|
|
3064
3066
|
var stringifyNumber = require_stringifyNumber();
|
|
3065
3067
|
function parseSexagesimal(str, asBigInt) {
|
|
@@ -3145,9 +3147,9 @@ var require_timestamp = __commonJS({
|
|
|
3145
3147
|
}
|
|
3146
3148
|
});
|
|
3147
3149
|
|
|
3148
|
-
// node_modules/yaml/dist/schema/yaml-1.1/schema.js
|
|
3150
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/schema.js
|
|
3149
3151
|
var require_schema3 = __commonJS({
|
|
3150
|
-
"node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports) {
|
|
3152
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports) {
|
|
3151
3153
|
"use strict";
|
|
3152
3154
|
var map = require_map();
|
|
3153
3155
|
var _null = require_null();
|
|
@@ -3160,7 +3162,7 @@ var require_schema3 = __commonJS({
|
|
|
3160
3162
|
var merge = require_merge();
|
|
3161
3163
|
var omap = require_omap();
|
|
3162
3164
|
var pairs = require_pairs();
|
|
3163
|
-
var
|
|
3165
|
+
var set2 = require_set();
|
|
3164
3166
|
var timestamp = require_timestamp();
|
|
3165
3167
|
var schema = [
|
|
3166
3168
|
map.map,
|
|
@@ -3180,7 +3182,7 @@ var require_schema3 = __commonJS({
|
|
|
3180
3182
|
merge.merge,
|
|
3181
3183
|
omap.omap,
|
|
3182
3184
|
pairs.pairs,
|
|
3183
|
-
|
|
3185
|
+
set2.set,
|
|
3184
3186
|
timestamp.intTime,
|
|
3185
3187
|
timestamp.floatTime,
|
|
3186
3188
|
timestamp.timestamp
|
|
@@ -3189,9 +3191,9 @@ var require_schema3 = __commonJS({
|
|
|
3189
3191
|
}
|
|
3190
3192
|
});
|
|
3191
3193
|
|
|
3192
|
-
// node_modules/yaml/dist/schema/tags.js
|
|
3194
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/tags.js
|
|
3193
3195
|
var require_tags = __commonJS({
|
|
3194
|
-
"node_modules/yaml/dist/schema/tags.js"(exports) {
|
|
3196
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/tags.js"(exports) {
|
|
3195
3197
|
"use strict";
|
|
3196
3198
|
var map = require_map();
|
|
3197
3199
|
var _null = require_null();
|
|
@@ -3207,7 +3209,7 @@ var require_tags = __commonJS({
|
|
|
3207
3209
|
var omap = require_omap();
|
|
3208
3210
|
var pairs = require_pairs();
|
|
3209
3211
|
var schema$2 = require_schema3();
|
|
3210
|
-
var
|
|
3212
|
+
var set2 = require_set();
|
|
3211
3213
|
var timestamp = require_timestamp();
|
|
3212
3214
|
var schemas = /* @__PURE__ */ new Map([
|
|
3213
3215
|
["core", schema.schema],
|
|
@@ -3233,7 +3235,7 @@ var require_tags = __commonJS({
|
|
|
3233
3235
|
omap: omap.omap,
|
|
3234
3236
|
pairs: pairs.pairs,
|
|
3235
3237
|
seq: seq.seq,
|
|
3236
|
-
set:
|
|
3238
|
+
set: set2.set,
|
|
3237
3239
|
timestamp: timestamp.timestamp
|
|
3238
3240
|
};
|
|
3239
3241
|
var coreKnownTags = {
|
|
@@ -3241,7 +3243,7 @@ var require_tags = __commonJS({
|
|
|
3241
3243
|
"tag:yaml.org,2002:merge": merge.merge,
|
|
3242
3244
|
"tag:yaml.org,2002:omap": omap.omap,
|
|
3243
3245
|
"tag:yaml.org,2002:pairs": pairs.pairs,
|
|
3244
|
-
"tag:yaml.org,2002:set":
|
|
3246
|
+
"tag:yaml.org,2002:set": set2.set,
|
|
3245
3247
|
"tag:yaml.org,2002:timestamp": timestamp.timestamp
|
|
3246
3248
|
};
|
|
3247
3249
|
function getTags(customTags, schemaName, addMergeTag) {
|
|
@@ -3283,9 +3285,9 @@ var require_tags = __commonJS({
|
|
|
3283
3285
|
}
|
|
3284
3286
|
});
|
|
3285
3287
|
|
|
3286
|
-
// node_modules/yaml/dist/schema/Schema.js
|
|
3288
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/Schema.js
|
|
3287
3289
|
var require_Schema = __commonJS({
|
|
3288
|
-
"node_modules/yaml/dist/schema/Schema.js"(exports) {
|
|
3290
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/schema/Schema.js"(exports) {
|
|
3289
3291
|
"use strict";
|
|
3290
3292
|
var identity = require_identity();
|
|
3291
3293
|
var map = require_map();
|
|
@@ -3315,9 +3317,9 @@ var require_Schema = __commonJS({
|
|
|
3315
3317
|
}
|
|
3316
3318
|
});
|
|
3317
3319
|
|
|
3318
|
-
// node_modules/yaml/dist/stringify/stringifyDocument.js
|
|
3320
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyDocument.js
|
|
3319
3321
|
var require_stringifyDocument = __commonJS({
|
|
3320
|
-
"node_modules/yaml/dist/stringify/stringifyDocument.js"(exports) {
|
|
3322
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports) {
|
|
3321
3323
|
"use strict";
|
|
3322
3324
|
var identity = require_identity();
|
|
3323
3325
|
var stringify = require_stringify();
|
|
@@ -3395,9 +3397,9 @@ var require_stringifyDocument = __commonJS({
|
|
|
3395
3397
|
}
|
|
3396
3398
|
});
|
|
3397
3399
|
|
|
3398
|
-
// node_modules/yaml/dist/doc/Document.js
|
|
3400
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/Document.js
|
|
3399
3401
|
var require_Document = __commonJS({
|
|
3400
|
-
"node_modules/yaml/dist/doc/Document.js"(exports) {
|
|
3402
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/Document.js"(exports) {
|
|
3401
3403
|
"use strict";
|
|
3402
3404
|
var Alias = require_Alias();
|
|
3403
3405
|
var Collection = require_Collection();
|
|
@@ -3473,9 +3475,9 @@ var require_Document = __commonJS({
|
|
|
3473
3475
|
this.contents.add(value);
|
|
3474
3476
|
}
|
|
3475
3477
|
/** Adds a value to the document. */
|
|
3476
|
-
addIn(
|
|
3478
|
+
addIn(path17, value) {
|
|
3477
3479
|
if (assertCollection(this.contents))
|
|
3478
|
-
this.contents.addIn(
|
|
3480
|
+
this.contents.addIn(path17, value);
|
|
3479
3481
|
}
|
|
3480
3482
|
/**
|
|
3481
3483
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3550,14 +3552,14 @@ var require_Document = __commonJS({
|
|
|
3550
3552
|
* Removes a value from the document.
|
|
3551
3553
|
* @returns `true` if the item was found and removed.
|
|
3552
3554
|
*/
|
|
3553
|
-
deleteIn(
|
|
3554
|
-
if (Collection.isEmptyPath(
|
|
3555
|
+
deleteIn(path17) {
|
|
3556
|
+
if (Collection.isEmptyPath(path17)) {
|
|
3555
3557
|
if (this.contents == null)
|
|
3556
3558
|
return false;
|
|
3557
3559
|
this.contents = null;
|
|
3558
3560
|
return true;
|
|
3559
3561
|
}
|
|
3560
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3562
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path17) : false;
|
|
3561
3563
|
}
|
|
3562
3564
|
/**
|
|
3563
3565
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3572,10 +3574,10 @@ var require_Document = __commonJS({
|
|
|
3572
3574
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3573
3575
|
* `true` (collections are always returned intact).
|
|
3574
3576
|
*/
|
|
3575
|
-
getIn(
|
|
3576
|
-
if (Collection.isEmptyPath(
|
|
3577
|
+
getIn(path17, keepScalar) {
|
|
3578
|
+
if (Collection.isEmptyPath(path17))
|
|
3577
3579
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3578
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3580
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path17, keepScalar) : void 0;
|
|
3579
3581
|
}
|
|
3580
3582
|
/**
|
|
3581
3583
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3586,10 +3588,10 @@ var require_Document = __commonJS({
|
|
|
3586
3588
|
/**
|
|
3587
3589
|
* Checks if the document includes a value at `path`.
|
|
3588
3590
|
*/
|
|
3589
|
-
hasIn(
|
|
3590
|
-
if (Collection.isEmptyPath(
|
|
3591
|
+
hasIn(path17) {
|
|
3592
|
+
if (Collection.isEmptyPath(path17))
|
|
3591
3593
|
return this.contents !== void 0;
|
|
3592
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3594
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path17) : false;
|
|
3593
3595
|
}
|
|
3594
3596
|
/**
|
|
3595
3597
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3606,13 +3608,13 @@ var require_Document = __commonJS({
|
|
|
3606
3608
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3607
3609
|
* boolean to add/remove the item from the set.
|
|
3608
3610
|
*/
|
|
3609
|
-
setIn(
|
|
3610
|
-
if (Collection.isEmptyPath(
|
|
3611
|
+
setIn(path17, value) {
|
|
3612
|
+
if (Collection.isEmptyPath(path17)) {
|
|
3611
3613
|
this.contents = value;
|
|
3612
3614
|
} else if (this.contents == null) {
|
|
3613
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3615
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path17), value);
|
|
3614
3616
|
} else if (assertCollection(this.contents)) {
|
|
3615
|
-
this.contents.setIn(
|
|
3617
|
+
this.contents.setIn(path17, value);
|
|
3616
3618
|
}
|
|
3617
3619
|
}
|
|
3618
3620
|
/**
|
|
@@ -3704,9 +3706,9 @@ var require_Document = __commonJS({
|
|
|
3704
3706
|
}
|
|
3705
3707
|
});
|
|
3706
3708
|
|
|
3707
|
-
// node_modules/yaml/dist/errors.js
|
|
3709
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/errors.js
|
|
3708
3710
|
var require_errors = __commonJS({
|
|
3709
|
-
"node_modules/yaml/dist/errors.js"(exports) {
|
|
3711
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/errors.js"(exports) {
|
|
3710
3712
|
"use strict";
|
|
3711
3713
|
var YAMLError = class extends Error {
|
|
3712
3714
|
constructor(name, pos, code2, message) {
|
|
@@ -3769,9 +3771,9 @@ ${pointer}
|
|
|
3769
3771
|
}
|
|
3770
3772
|
});
|
|
3771
3773
|
|
|
3772
|
-
// node_modules/yaml/dist/compose/resolve-props.js
|
|
3774
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-props.js
|
|
3773
3775
|
var require_resolve_props = __commonJS({
|
|
3774
|
-
"node_modules/yaml/dist/compose/resolve-props.js"(exports) {
|
|
3776
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-props.js"(exports) {
|
|
3775
3777
|
"use strict";
|
|
3776
3778
|
function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
|
|
3777
3779
|
let spaceBefore = false;
|
|
@@ -3903,9 +3905,9 @@ var require_resolve_props = __commonJS({
|
|
|
3903
3905
|
}
|
|
3904
3906
|
});
|
|
3905
3907
|
|
|
3906
|
-
// node_modules/yaml/dist/compose/util-contains-newline.js
|
|
3908
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-contains-newline.js
|
|
3907
3909
|
var require_util_contains_newline = __commonJS({
|
|
3908
|
-
"node_modules/yaml/dist/compose/util-contains-newline.js"(exports) {
|
|
3910
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-contains-newline.js"(exports) {
|
|
3909
3911
|
"use strict";
|
|
3910
3912
|
function containsNewline(key) {
|
|
3911
3913
|
if (!key)
|
|
@@ -3945,9 +3947,9 @@ var require_util_contains_newline = __commonJS({
|
|
|
3945
3947
|
}
|
|
3946
3948
|
});
|
|
3947
3949
|
|
|
3948
|
-
// node_modules/yaml/dist/compose/util-flow-indent-check.js
|
|
3950
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-flow-indent-check.js
|
|
3949
3951
|
var require_util_flow_indent_check = __commonJS({
|
|
3950
|
-
"node_modules/yaml/dist/compose/util-flow-indent-check.js"(exports) {
|
|
3952
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-flow-indent-check.js"(exports) {
|
|
3951
3953
|
"use strict";
|
|
3952
3954
|
var utilContainsNewline = require_util_contains_newline();
|
|
3953
3955
|
function flowIndentCheck(indent, fc, onError) {
|
|
@@ -3963,9 +3965,9 @@ var require_util_flow_indent_check = __commonJS({
|
|
|
3963
3965
|
}
|
|
3964
3966
|
});
|
|
3965
3967
|
|
|
3966
|
-
// node_modules/yaml/dist/compose/util-map-includes.js
|
|
3968
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-map-includes.js
|
|
3967
3969
|
var require_util_map_includes = __commonJS({
|
|
3968
|
-
"node_modules/yaml/dist/compose/util-map-includes.js"(exports) {
|
|
3970
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-map-includes.js"(exports) {
|
|
3969
3971
|
"use strict";
|
|
3970
3972
|
var identity = require_identity();
|
|
3971
3973
|
function mapIncludes(ctx, items, search) {
|
|
@@ -3979,9 +3981,9 @@ var require_util_map_includes = __commonJS({
|
|
|
3979
3981
|
}
|
|
3980
3982
|
});
|
|
3981
3983
|
|
|
3982
|
-
// node_modules/yaml/dist/compose/resolve-block-map.js
|
|
3984
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-map.js
|
|
3983
3985
|
var require_resolve_block_map = __commonJS({
|
|
3984
|
-
"node_modules/yaml/dist/compose/resolve-block-map.js"(exports) {
|
|
3986
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-map.js"(exports) {
|
|
3985
3987
|
"use strict";
|
|
3986
3988
|
var Pair = require_Pair();
|
|
3987
3989
|
var YAMLMap = require_YAMLMap();
|
|
@@ -4087,9 +4089,9 @@ var require_resolve_block_map = __commonJS({
|
|
|
4087
4089
|
}
|
|
4088
4090
|
});
|
|
4089
4091
|
|
|
4090
|
-
// node_modules/yaml/dist/compose/resolve-block-seq.js
|
|
4092
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-seq.js
|
|
4091
4093
|
var require_resolve_block_seq = __commonJS({
|
|
4092
|
-
"node_modules/yaml/dist/compose/resolve-block-seq.js"(exports) {
|
|
4094
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-seq.js"(exports) {
|
|
4093
4095
|
"use strict";
|
|
4094
4096
|
var YAMLSeq = require_YAMLSeq();
|
|
4095
4097
|
var resolveProps = require_resolve_props();
|
|
@@ -4138,9 +4140,9 @@ var require_resolve_block_seq = __commonJS({
|
|
|
4138
4140
|
}
|
|
4139
4141
|
});
|
|
4140
4142
|
|
|
4141
|
-
// node_modules/yaml/dist/compose/resolve-end.js
|
|
4143
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-end.js
|
|
4142
4144
|
var require_resolve_end = __commonJS({
|
|
4143
|
-
"node_modules/yaml/dist/compose/resolve-end.js"(exports) {
|
|
4145
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-end.js"(exports) {
|
|
4144
4146
|
"use strict";
|
|
4145
4147
|
function resolveEnd(end, offset, reqSpace, onError) {
|
|
4146
4148
|
let comment = "";
|
|
@@ -4181,9 +4183,9 @@ var require_resolve_end = __commonJS({
|
|
|
4181
4183
|
}
|
|
4182
4184
|
});
|
|
4183
4185
|
|
|
4184
|
-
// node_modules/yaml/dist/compose/resolve-flow-collection.js
|
|
4186
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-flow-collection.js
|
|
4185
4187
|
var require_resolve_flow_collection = __commonJS({
|
|
4186
|
-
"node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports) {
|
|
4188
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports) {
|
|
4187
4189
|
"use strict";
|
|
4188
4190
|
var identity = require_identity();
|
|
4189
4191
|
var Pair = require_Pair();
|
|
@@ -4375,9 +4377,9 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4375
4377
|
}
|
|
4376
4378
|
});
|
|
4377
4379
|
|
|
4378
|
-
// node_modules/yaml/dist/compose/compose-collection.js
|
|
4380
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-collection.js
|
|
4379
4381
|
var require_compose_collection = __commonJS({
|
|
4380
|
-
"node_modules/yaml/dist/compose/compose-collection.js"(exports) {
|
|
4382
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-collection.js"(exports) {
|
|
4381
4383
|
"use strict";
|
|
4382
4384
|
var identity = require_identity();
|
|
4383
4385
|
var Scalar = require_Scalar();
|
|
@@ -4440,9 +4442,9 @@ var require_compose_collection = __commonJS({
|
|
|
4440
4442
|
}
|
|
4441
4443
|
});
|
|
4442
4444
|
|
|
4443
|
-
// node_modules/yaml/dist/compose/resolve-block-scalar.js
|
|
4445
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-scalar.js
|
|
4444
4446
|
var require_resolve_block_scalar = __commonJS({
|
|
4445
|
-
"node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports) {
|
|
4447
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports) {
|
|
4446
4448
|
"use strict";
|
|
4447
4449
|
var Scalar = require_Scalar();
|
|
4448
4450
|
function resolveBlockScalar(ctx, scalar, onError) {
|
|
@@ -4623,9 +4625,9 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4623
4625
|
}
|
|
4624
4626
|
});
|
|
4625
4627
|
|
|
4626
|
-
// node_modules/yaml/dist/compose/resolve-flow-scalar.js
|
|
4628
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-flow-scalar.js
|
|
4627
4629
|
var require_resolve_flow_scalar = __commonJS({
|
|
4628
|
-
"node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports) {
|
|
4630
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports) {
|
|
4629
4631
|
"use strict";
|
|
4630
4632
|
var Scalar = require_Scalar();
|
|
4631
4633
|
var resolveEnd = require_resolve_end();
|
|
@@ -4692,37 +4694,38 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4692
4694
|
}
|
|
4693
4695
|
if (badChar)
|
|
4694
4696
|
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
|
|
4695
|
-
return
|
|
4697
|
+
return unfoldLines(source);
|
|
4696
4698
|
}
|
|
4697
4699
|
function singleQuotedValue(source, onError) {
|
|
4698
4700
|
if (source[source.length - 1] !== "'" || source.length === 1)
|
|
4699
4701
|
onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
4700
|
-
return
|
|
4702
|
+
return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
4701
4703
|
}
|
|
4702
|
-
function
|
|
4703
|
-
|
|
4704
|
+
function unfoldLines(source) {
|
|
4705
|
+
const line = /(.*?)\r?\n/sy;
|
|
4706
|
+
let match = line.exec(source);
|
|
4707
|
+
if (!match)
|
|
4708
|
+
return source;
|
|
4709
|
+
let trimEnd, trimBoth;
|
|
4704
4710
|
try {
|
|
4705
|
-
|
|
4706
|
-
|
|
4711
|
+
trimEnd = new RegExp("(?<![ ])[ ]+$");
|
|
4712
|
+
trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
|
|
4707
4713
|
} catch {
|
|
4708
|
-
|
|
4709
|
-
|
|
4714
|
+
trimEnd = /[ \t]+$/;
|
|
4715
|
+
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
4710
4716
|
}
|
|
4711
|
-
let
|
|
4712
|
-
if (!match)
|
|
4713
|
-
return source;
|
|
4714
|
-
let res = match[1];
|
|
4717
|
+
let res = match[1].replace(trimEnd, "");
|
|
4715
4718
|
let sep = " ";
|
|
4716
|
-
let pos =
|
|
4717
|
-
line.lastIndex = pos;
|
|
4719
|
+
let pos = line.lastIndex;
|
|
4718
4720
|
while (match = line.exec(source)) {
|
|
4719
|
-
|
|
4721
|
+
const lm = match[1].replace(trimBoth, "");
|
|
4722
|
+
if (lm === "") {
|
|
4720
4723
|
if (sep === "\n")
|
|
4721
4724
|
res += sep;
|
|
4722
4725
|
else
|
|
4723
4726
|
sep = "\n";
|
|
4724
4727
|
} else {
|
|
4725
|
-
res += sep +
|
|
4728
|
+
res += sep + lm;
|
|
4726
4729
|
sep = " ";
|
|
4727
4730
|
}
|
|
4728
4731
|
pos = line.lastIndex;
|
|
@@ -4843,9 +4846,9 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4843
4846
|
}
|
|
4844
4847
|
});
|
|
4845
4848
|
|
|
4846
|
-
// node_modules/yaml/dist/compose/compose-scalar.js
|
|
4849
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-scalar.js
|
|
4847
4850
|
var require_compose_scalar = __commonJS({
|
|
4848
|
-
"node_modules/yaml/dist/compose/compose-scalar.js"(exports) {
|
|
4851
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-scalar.js"(exports) {
|
|
4849
4852
|
"use strict";
|
|
4850
4853
|
var identity = require_identity();
|
|
4851
4854
|
var Scalar = require_Scalar();
|
|
@@ -4924,9 +4927,9 @@ var require_compose_scalar = __commonJS({
|
|
|
4924
4927
|
}
|
|
4925
4928
|
});
|
|
4926
4929
|
|
|
4927
|
-
// node_modules/yaml/dist/compose/util-empty-scalar-position.js
|
|
4930
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-empty-scalar-position.js
|
|
4928
4931
|
var require_util_empty_scalar_position = __commonJS({
|
|
4929
|
-
"node_modules/yaml/dist/compose/util-empty-scalar-position.js"(exports) {
|
|
4932
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/util-empty-scalar-position.js"(exports) {
|
|
4930
4933
|
"use strict";
|
|
4931
4934
|
function emptyScalarPosition(offset, before, pos) {
|
|
4932
4935
|
if (before) {
|
|
@@ -4954,9 +4957,9 @@ var require_util_empty_scalar_position = __commonJS({
|
|
|
4954
4957
|
}
|
|
4955
4958
|
});
|
|
4956
4959
|
|
|
4957
|
-
// node_modules/yaml/dist/compose/compose-node.js
|
|
4960
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-node.js
|
|
4958
4961
|
var require_compose_node = __commonJS({
|
|
4959
|
-
"node_modules/yaml/dist/compose/compose-node.js"(exports) {
|
|
4962
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-node.js"(exports) {
|
|
4960
4963
|
"use strict";
|
|
4961
4964
|
var Alias = require_Alias();
|
|
4962
4965
|
var identity = require_identity();
|
|
@@ -5060,9 +5063,9 @@ var require_compose_node = __commonJS({
|
|
|
5060
5063
|
}
|
|
5061
5064
|
});
|
|
5062
5065
|
|
|
5063
|
-
// node_modules/yaml/dist/compose/compose-doc.js
|
|
5066
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-doc.js
|
|
5064
5067
|
var require_compose_doc = __commonJS({
|
|
5065
|
-
"node_modules/yaml/dist/compose/compose-doc.js"(exports) {
|
|
5068
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/compose-doc.js"(exports) {
|
|
5066
5069
|
"use strict";
|
|
5067
5070
|
var Document = require_Document();
|
|
5068
5071
|
var composeNode = require_compose_node();
|
|
@@ -5103,9 +5106,9 @@ var require_compose_doc = __commonJS({
|
|
|
5103
5106
|
}
|
|
5104
5107
|
});
|
|
5105
5108
|
|
|
5106
|
-
// node_modules/yaml/dist/compose/composer.js
|
|
5109
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/composer.js
|
|
5107
5110
|
var require_composer = __commonJS({
|
|
5108
|
-
"node_modules/yaml/dist/compose/composer.js"(exports) {
|
|
5111
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/composer.js"(exports) {
|
|
5109
5112
|
"use strict";
|
|
5110
5113
|
var node_process = __require("process");
|
|
5111
5114
|
var directives = require_directives();
|
|
@@ -5311,9 +5314,9 @@ ${end.comment}` : end.comment;
|
|
|
5311
5314
|
}
|
|
5312
5315
|
});
|
|
5313
5316
|
|
|
5314
|
-
// node_modules/yaml/dist/parse/cst-scalar.js
|
|
5317
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-scalar.js
|
|
5315
5318
|
var require_cst_scalar = __commonJS({
|
|
5316
|
-
"node_modules/yaml/dist/parse/cst-scalar.js"(exports) {
|
|
5319
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-scalar.js"(exports) {
|
|
5317
5320
|
"use strict";
|
|
5318
5321
|
var resolveBlockScalar = require_resolve_block_scalar();
|
|
5319
5322
|
var resolveFlowScalar = require_resolve_flow_scalar();
|
|
@@ -5496,9 +5499,9 @@ var require_cst_scalar = __commonJS({
|
|
|
5496
5499
|
}
|
|
5497
5500
|
});
|
|
5498
5501
|
|
|
5499
|
-
// node_modules/yaml/dist/parse/cst-stringify.js
|
|
5502
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-stringify.js
|
|
5500
5503
|
var require_cst_stringify = __commonJS({
|
|
5501
|
-
"node_modules/yaml/dist/parse/cst-stringify.js"(exports) {
|
|
5504
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-stringify.js"(exports) {
|
|
5502
5505
|
"use strict";
|
|
5503
5506
|
var stringify = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst);
|
|
5504
5507
|
function stringifyToken(token) {
|
|
@@ -5557,9 +5560,9 @@ var require_cst_stringify = __commonJS({
|
|
|
5557
5560
|
}
|
|
5558
5561
|
});
|
|
5559
5562
|
|
|
5560
|
-
// node_modules/yaml/dist/parse/cst-visit.js
|
|
5563
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-visit.js
|
|
5561
5564
|
var require_cst_visit = __commonJS({
|
|
5562
|
-
"node_modules/yaml/dist/parse/cst-visit.js"(exports) {
|
|
5565
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-visit.js"(exports) {
|
|
5563
5566
|
"use strict";
|
|
5564
5567
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
5565
5568
|
var SKIP = /* @__PURE__ */ Symbol("skip children");
|
|
@@ -5572,9 +5575,9 @@ var require_cst_visit = __commonJS({
|
|
|
5572
5575
|
visit.BREAK = BREAK;
|
|
5573
5576
|
visit.SKIP = SKIP;
|
|
5574
5577
|
visit.REMOVE = REMOVE;
|
|
5575
|
-
visit.itemAtPath = (cst,
|
|
5578
|
+
visit.itemAtPath = (cst, path17) => {
|
|
5576
5579
|
let item = cst;
|
|
5577
|
-
for (const [field, index] of
|
|
5580
|
+
for (const [field, index] of path17) {
|
|
5578
5581
|
const tok = item?.[field];
|
|
5579
5582
|
if (tok && "items" in tok) {
|
|
5580
5583
|
item = tok.items[index];
|
|
@@ -5583,23 +5586,23 @@ var require_cst_visit = __commonJS({
|
|
|
5583
5586
|
}
|
|
5584
5587
|
return item;
|
|
5585
5588
|
};
|
|
5586
|
-
visit.parentCollection = (cst,
|
|
5587
|
-
const parent = visit.itemAtPath(cst,
|
|
5588
|
-
const field =
|
|
5589
|
+
visit.parentCollection = (cst, path17) => {
|
|
5590
|
+
const parent = visit.itemAtPath(cst, path17.slice(0, -1));
|
|
5591
|
+
const field = path17[path17.length - 1][0];
|
|
5589
5592
|
const coll = parent?.[field];
|
|
5590
5593
|
if (coll && "items" in coll)
|
|
5591
5594
|
return coll;
|
|
5592
5595
|
throw new Error("Parent collection not found");
|
|
5593
5596
|
};
|
|
5594
|
-
function _visit(
|
|
5595
|
-
let ctrl = visitor(item,
|
|
5597
|
+
function _visit(path17, item, visitor) {
|
|
5598
|
+
let ctrl = visitor(item, path17);
|
|
5596
5599
|
if (typeof ctrl === "symbol")
|
|
5597
5600
|
return ctrl;
|
|
5598
5601
|
for (const field of ["key", "value"]) {
|
|
5599
5602
|
const token = item[field];
|
|
5600
5603
|
if (token && "items" in token) {
|
|
5601
5604
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5602
|
-
const ci = _visit(Object.freeze(
|
|
5605
|
+
const ci = _visit(Object.freeze(path17.concat([[field, i]])), token.items[i], visitor);
|
|
5603
5606
|
if (typeof ci === "number")
|
|
5604
5607
|
i = ci - 1;
|
|
5605
5608
|
else if (ci === BREAK)
|
|
@@ -5610,18 +5613,18 @@ var require_cst_visit = __commonJS({
|
|
|
5610
5613
|
}
|
|
5611
5614
|
}
|
|
5612
5615
|
if (typeof ctrl === "function" && field === "key")
|
|
5613
|
-
ctrl = ctrl(item,
|
|
5616
|
+
ctrl = ctrl(item, path17);
|
|
5614
5617
|
}
|
|
5615
5618
|
}
|
|
5616
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5619
|
+
return typeof ctrl === "function" ? ctrl(item, path17) : ctrl;
|
|
5617
5620
|
}
|
|
5618
5621
|
exports.visit = visit;
|
|
5619
5622
|
}
|
|
5620
5623
|
});
|
|
5621
5624
|
|
|
5622
|
-
// node_modules/yaml/dist/parse/cst.js
|
|
5625
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst.js
|
|
5623
5626
|
var require_cst = __commonJS({
|
|
5624
|
-
"node_modules/yaml/dist/parse/cst.js"(exports) {
|
|
5627
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst.js"(exports) {
|
|
5625
5628
|
"use strict";
|
|
5626
5629
|
var cstScalar = require_cst_scalar();
|
|
5627
5630
|
var cstStringify = require_cst_stringify();
|
|
@@ -5721,9 +5724,9 @@ var require_cst = __commonJS({
|
|
|
5721
5724
|
}
|
|
5722
5725
|
});
|
|
5723
5726
|
|
|
5724
|
-
// node_modules/yaml/dist/parse/lexer.js
|
|
5727
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/lexer.js
|
|
5725
5728
|
var require_lexer = __commonJS({
|
|
5726
|
-
"node_modules/yaml/dist/parse/lexer.js"(exports) {
|
|
5729
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/lexer.js"(exports) {
|
|
5727
5730
|
"use strict";
|
|
5728
5731
|
var cst = require_cst();
|
|
5729
5732
|
function isEmpty(ch) {
|
|
@@ -6310,9 +6313,9 @@ var require_lexer = __commonJS({
|
|
|
6310
6313
|
}
|
|
6311
6314
|
});
|
|
6312
6315
|
|
|
6313
|
-
// node_modules/yaml/dist/parse/line-counter.js
|
|
6316
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/line-counter.js
|
|
6314
6317
|
var require_line_counter = __commonJS({
|
|
6315
|
-
"node_modules/yaml/dist/parse/line-counter.js"(exports) {
|
|
6318
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/line-counter.js"(exports) {
|
|
6316
6319
|
"use strict";
|
|
6317
6320
|
var LineCounter = class {
|
|
6318
6321
|
constructor() {
|
|
@@ -6341,9 +6344,9 @@ var require_line_counter = __commonJS({
|
|
|
6341
6344
|
}
|
|
6342
6345
|
});
|
|
6343
6346
|
|
|
6344
|
-
// node_modules/yaml/dist/parse/parser.js
|
|
6347
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/parser.js
|
|
6345
6348
|
var require_parser = __commonJS({
|
|
6346
|
-
"node_modules/yaml/dist/parse/parser.js"(exports) {
|
|
6349
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/parser.js"(exports) {
|
|
6347
6350
|
"use strict";
|
|
6348
6351
|
var node_process = __require("process");
|
|
6349
6352
|
var cst = require_cst();
|
|
@@ -6915,14 +6918,14 @@ var require_parser = __commonJS({
|
|
|
6915
6918
|
case "scalar":
|
|
6916
6919
|
case "single-quoted-scalar":
|
|
6917
6920
|
case "double-quoted-scalar": {
|
|
6918
|
-
const
|
|
6921
|
+
const fs15 = this.flowScalar(this.type);
|
|
6919
6922
|
if (atNextItem || it.value) {
|
|
6920
|
-
map.items.push({ start, key:
|
|
6923
|
+
map.items.push({ start, key: fs15, sep: [] });
|
|
6921
6924
|
this.onKeyLine = true;
|
|
6922
6925
|
} else if (it.sep) {
|
|
6923
|
-
this.stack.push(
|
|
6926
|
+
this.stack.push(fs15);
|
|
6924
6927
|
} else {
|
|
6925
|
-
Object.assign(it, { key:
|
|
6928
|
+
Object.assign(it, { key: fs15, sep: [] });
|
|
6926
6929
|
this.onKeyLine = true;
|
|
6927
6930
|
}
|
|
6928
6931
|
return;
|
|
@@ -7050,13 +7053,13 @@ var require_parser = __commonJS({
|
|
|
7050
7053
|
case "scalar":
|
|
7051
7054
|
case "single-quoted-scalar":
|
|
7052
7055
|
case "double-quoted-scalar": {
|
|
7053
|
-
const
|
|
7056
|
+
const fs15 = this.flowScalar(this.type);
|
|
7054
7057
|
if (!it || it.value)
|
|
7055
|
-
fc.items.push({ start: [], key:
|
|
7058
|
+
fc.items.push({ start: [], key: fs15, sep: [] });
|
|
7056
7059
|
else if (it.sep)
|
|
7057
|
-
this.stack.push(
|
|
7060
|
+
this.stack.push(fs15);
|
|
7058
7061
|
else
|
|
7059
|
-
Object.assign(it, { key:
|
|
7062
|
+
Object.assign(it, { key: fs15, sep: [] });
|
|
7060
7063
|
return;
|
|
7061
7064
|
}
|
|
7062
7065
|
case "flow-map-end":
|
|
@@ -7215,9 +7218,9 @@ var require_parser = __commonJS({
|
|
|
7215
7218
|
}
|
|
7216
7219
|
});
|
|
7217
7220
|
|
|
7218
|
-
// node_modules/yaml/dist/public-api.js
|
|
7221
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/public-api.js
|
|
7219
7222
|
var require_public_api = __commonJS({
|
|
7220
|
-
"node_modules/yaml/dist/public-api.js"(exports) {
|
|
7223
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/public-api.js"(exports) {
|
|
7221
7224
|
"use strict";
|
|
7222
7225
|
var composer = require_composer();
|
|
7223
7226
|
var Document = require_Document();
|
|
@@ -7312,9 +7315,9 @@ var require_public_api = __commonJS({
|
|
|
7312
7315
|
}
|
|
7313
7316
|
});
|
|
7314
7317
|
|
|
7315
|
-
// node_modules/yaml/dist/index.js
|
|
7318
|
+
// ../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/index.js
|
|
7316
7319
|
var require_dist = __commonJS({
|
|
7317
|
-
"node_modules/yaml/dist/index.js"(exports) {
|
|
7320
|
+
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/index.js"(exports) {
|
|
7318
7321
|
"use strict";
|
|
7319
7322
|
var composer = require_composer();
|
|
7320
7323
|
var Document = require_Document();
|
|
@@ -7383,21 +7386,142 @@ var CliError = class extends Error {
|
|
|
7383
7386
|
};
|
|
7384
7387
|
|
|
7385
7388
|
// src/commands/agents.ts
|
|
7386
|
-
import
|
|
7387
|
-
import
|
|
7389
|
+
import fs10 from "node:fs";
|
|
7390
|
+
import path13 from "node:path";
|
|
7388
7391
|
import { parseArgs as parseArgs3 } from "node:util";
|
|
7389
7392
|
|
|
7390
7393
|
// src/auth/oauth-client.ts
|
|
7391
|
-
import
|
|
7394
|
+
import fs4 from "node:fs";
|
|
7392
7395
|
import path3 from "node:path";
|
|
7393
7396
|
|
|
7394
7397
|
// src/config.ts
|
|
7395
7398
|
import os from "node:os";
|
|
7399
|
+
import path2 from "node:path";
|
|
7400
|
+
|
|
7401
|
+
// src/auth/session-token.ts
|
|
7402
|
+
import fs3 from "node:fs";
|
|
7403
|
+
|
|
7404
|
+
// src/auth/token-cache.ts
|
|
7405
|
+
import fs2 from "node:fs";
|
|
7406
|
+
|
|
7407
|
+
// src/fs/atomic.ts
|
|
7408
|
+
import fs from "node:fs";
|
|
7396
7409
|
import path from "node:path";
|
|
7410
|
+
function writeTextAtomic(filePath, text, mode = 384) {
|
|
7411
|
+
const dir = path.dirname(filePath);
|
|
7412
|
+
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
7413
|
+
const tmp = path.join(dir, `.${path.basename(filePath)}.${process.pid}.${Date.now()}.tmp`);
|
|
7414
|
+
const fd = fs.openSync(tmp, "wx", mode);
|
|
7415
|
+
try {
|
|
7416
|
+
fs.writeFileSync(fd, text);
|
|
7417
|
+
fs.closeSync(fd);
|
|
7418
|
+
fs.renameSync(tmp, filePath);
|
|
7419
|
+
} catch (error) {
|
|
7420
|
+
try {
|
|
7421
|
+
fs.closeSync(fd);
|
|
7422
|
+
} catch {
|
|
7423
|
+
}
|
|
7424
|
+
fs.rmSync(tmp, { force: true });
|
|
7425
|
+
throw error;
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7428
|
+
function writeJsonAtomic(filePath, value, mode = 384) {
|
|
7429
|
+
writeTextAtomic(filePath, `${JSON.stringify(value, null, 2)}
|
|
7430
|
+
`, mode);
|
|
7431
|
+
}
|
|
7432
|
+
|
|
7433
|
+
// src/auth/token-cache.ts
|
|
7434
|
+
function loadLoginRecord(file) {
|
|
7435
|
+
try {
|
|
7436
|
+
const parsed = JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
7437
|
+
if (typeof parsed.base_url !== "string" || typeof parsed.refresh_token !== "string") return null;
|
|
7438
|
+
return {
|
|
7439
|
+
base_url: parsed.base_url,
|
|
7440
|
+
refresh_token: parsed.refresh_token,
|
|
7441
|
+
...typeof parsed.account === "string" && parsed.account ? { account: parsed.account } : {},
|
|
7442
|
+
...typeof parsed.organization === "string" && parsed.organization ? { organization: parsed.organization } : {}
|
|
7443
|
+
};
|
|
7444
|
+
} catch {
|
|
7445
|
+
return null;
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
7448
|
+
function saveLoginRecord(file, record) {
|
|
7449
|
+
writeJsonAtomic(file, record, 384);
|
|
7450
|
+
}
|
|
7451
|
+
function loadUserToken(file) {
|
|
7452
|
+
let text;
|
|
7453
|
+
try {
|
|
7454
|
+
text = fs2.readFileSync(file, "utf8");
|
|
7455
|
+
} catch {
|
|
7456
|
+
return null;
|
|
7457
|
+
}
|
|
7458
|
+
try {
|
|
7459
|
+
const parsed = JSON.parse(text);
|
|
7460
|
+
if (typeof parsed.access_token !== "string" || typeof parsed.base_url !== "string" || typeof parsed.expires_at !== "number") {
|
|
7461
|
+
return null;
|
|
7462
|
+
}
|
|
7463
|
+
return { access_token: parsed.access_token, expires_at: parsed.expires_at, base_url: parsed.base_url };
|
|
7464
|
+
} catch {
|
|
7465
|
+
return null;
|
|
7466
|
+
}
|
|
7467
|
+
}
|
|
7468
|
+
function saveUserToken(file, token) {
|
|
7469
|
+
writeJsonAtomic(file, token, 384);
|
|
7470
|
+
}
|
|
7471
|
+
function isFresh(token, freshForSeconds, nowMs = Date.now()) {
|
|
7472
|
+
return token.expires_at - nowMs / 1e3 > freshForSeconds;
|
|
7473
|
+
}
|
|
7474
|
+
function tokenClaims(accessToken) {
|
|
7475
|
+
const payload = accessToken.split(".")[1];
|
|
7476
|
+
if (!payload) return {};
|
|
7477
|
+
try {
|
|
7478
|
+
const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
7479
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
7480
|
+
} catch {
|
|
7481
|
+
return {};
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
|
|
7485
|
+
// src/auth/session-token.ts
|
|
7486
|
+
var SESSION_TOKEN_VARIABLE = "DIVERGENT_TOKEN_FILE";
|
|
7487
|
+
function sessionTokenFile(env) {
|
|
7488
|
+
return env[SESSION_TOKEN_VARIABLE]?.trim() || void 0;
|
|
7489
|
+
}
|
|
7490
|
+
function readSessionToken(file) {
|
|
7491
|
+
let text;
|
|
7492
|
+
try {
|
|
7493
|
+
text = fs3.readFileSync(file, "utf8");
|
|
7494
|
+
} catch (error) {
|
|
7495
|
+
const reason = error.code ?? (error instanceof Error ? error.message : String(error));
|
|
7496
|
+
throw new CliError(`Cannot read the session token file ${file} named by ${SESSION_TOKEN_VARIABLE} (${reason}).`);
|
|
7497
|
+
}
|
|
7498
|
+
const token = text.trim();
|
|
7499
|
+
if (!token) throw new CliError(`The session token file ${file} named by ${SESSION_TOKEN_VARIABLE} is empty.`);
|
|
7500
|
+
return token;
|
|
7501
|
+
}
|
|
7502
|
+
function sessionOrganization(file, token, requested) {
|
|
7503
|
+
const organizationId = tokenClaims(token).organizationId;
|
|
7504
|
+
if (!organizationId) throw new CliError(`The session token in ${file} names no organization, so this session cannot act in one.`);
|
|
7505
|
+
if (requested && requested !== organizationId) {
|
|
7506
|
+
throw new CliError(`This session runs on a session token for organization ${organizationId} (${SESSION_TOKEN_VARIABLE}); it cannot act in organization ${requested}.`);
|
|
7507
|
+
}
|
|
7508
|
+
return organizationId;
|
|
7509
|
+
}
|
|
7510
|
+
function sessionToken(file, baseUrl, organizationId) {
|
|
7511
|
+
const token = readSessionToken(file);
|
|
7512
|
+
if (organizationId) sessionOrganization(file, token, organizationId);
|
|
7513
|
+
return { access_token: token, expires_at: tokenClaims(token).exp ?? 0, base_url: baseUrl };
|
|
7514
|
+
}
|
|
7515
|
+
function refuseInSession(env, command) {
|
|
7516
|
+
const file = sessionTokenFile(env);
|
|
7517
|
+
if (file) throw new CliError(`This session runs on a session token (${SESSION_TOKEN_VARIABLE}=${file}) and holds no login: diverge ${command} does not apply to it.`);
|
|
7518
|
+
}
|
|
7519
|
+
|
|
7520
|
+
// src/config.ts
|
|
7397
7521
|
var DEFAULT_API_URL = "https://divergeai.net";
|
|
7398
7522
|
var DEFAULT_CLIENT_ID = "diverge";
|
|
7399
7523
|
function configDir(env = process.env) {
|
|
7400
|
-
return env.DIVERGE_HOME?.trim() ||
|
|
7524
|
+
return env.DIVERGE_HOME?.trim() || path2.join(os.homedir(), ".diverge");
|
|
7401
7525
|
}
|
|
7402
7526
|
function resolveApiUrl(flag, env = process.env) {
|
|
7403
7527
|
const chosen = flag?.trim() || env.DIVERGENT_API_URL?.trim() || DEFAULT_API_URL;
|
|
@@ -7413,17 +7537,18 @@ function deploymentKey(baseUrl) {
|
|
|
7413
7537
|
}
|
|
7414
7538
|
function tokenSource(env, baseUrl) {
|
|
7415
7539
|
const normalized = baseUrl.replace(/\/+$/, "");
|
|
7416
|
-
const dir =
|
|
7540
|
+
const dir = path2.join(configDir(env), "logins", deploymentKey(normalized));
|
|
7417
7541
|
return {
|
|
7418
|
-
loginFile:
|
|
7419
|
-
tokensDir:
|
|
7542
|
+
loginFile: path2.join(dir, "login.json"),
|
|
7543
|
+
tokensDir: path2.join(dir, "tokens"),
|
|
7420
7544
|
baseUrl: normalized,
|
|
7421
|
-
clientId: clientId(env)
|
|
7545
|
+
clientId: clientId(env),
|
|
7546
|
+
sessionTokenFile: sessionTokenFile(env)
|
|
7422
7547
|
};
|
|
7423
7548
|
}
|
|
7424
7549
|
|
|
7425
7550
|
// src/version.ts
|
|
7426
|
-
var VERSION = true ? "0.1.
|
|
7551
|
+
var VERSION = true ? "0.1.24" : "dev";
|
|
7427
7552
|
var USER_AGENT = `diverge/${VERSION}`;
|
|
7428
7553
|
|
|
7429
7554
|
// src/http.ts
|
|
@@ -7617,87 +7742,6 @@ function buildAuthorizeUrl(params) {
|
|
|
7617
7742
|
return url.toString();
|
|
7618
7743
|
}
|
|
7619
7744
|
|
|
7620
|
-
// src/auth/token-cache.ts
|
|
7621
|
-
import fs2 from "node:fs";
|
|
7622
|
-
|
|
7623
|
-
// src/fs/atomic.ts
|
|
7624
|
-
import fs from "node:fs";
|
|
7625
|
-
import path2 from "node:path";
|
|
7626
|
-
function writeTextAtomic(filePath, text, mode = 384) {
|
|
7627
|
-
const dir = path2.dirname(filePath);
|
|
7628
|
-
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
7629
|
-
const tmp = path2.join(dir, `.${path2.basename(filePath)}.${process.pid}.${Date.now()}.tmp`);
|
|
7630
|
-
const fd = fs.openSync(tmp, "wx", mode);
|
|
7631
|
-
try {
|
|
7632
|
-
fs.writeFileSync(fd, text);
|
|
7633
|
-
fs.closeSync(fd);
|
|
7634
|
-
fs.renameSync(tmp, filePath);
|
|
7635
|
-
} catch (error) {
|
|
7636
|
-
try {
|
|
7637
|
-
fs.closeSync(fd);
|
|
7638
|
-
} catch {
|
|
7639
|
-
}
|
|
7640
|
-
fs.rmSync(tmp, { force: true });
|
|
7641
|
-
throw error;
|
|
7642
|
-
}
|
|
7643
|
-
}
|
|
7644
|
-
function writeJsonAtomic(filePath, value, mode = 384) {
|
|
7645
|
-
writeTextAtomic(filePath, `${JSON.stringify(value, null, 2)}
|
|
7646
|
-
`, mode);
|
|
7647
|
-
}
|
|
7648
|
-
|
|
7649
|
-
// src/auth/token-cache.ts
|
|
7650
|
-
function loadLoginRecord(file) {
|
|
7651
|
-
try {
|
|
7652
|
-
const parsed = JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
7653
|
-
if (typeof parsed.base_url !== "string" || typeof parsed.refresh_token !== "string") return null;
|
|
7654
|
-
return {
|
|
7655
|
-
base_url: parsed.base_url,
|
|
7656
|
-
refresh_token: parsed.refresh_token,
|
|
7657
|
-
...typeof parsed.account === "string" && parsed.account ? { account: parsed.account } : {},
|
|
7658
|
-
...typeof parsed.organization === "string" && parsed.organization ? { organization: parsed.organization } : {}
|
|
7659
|
-
};
|
|
7660
|
-
} catch {
|
|
7661
|
-
return null;
|
|
7662
|
-
}
|
|
7663
|
-
}
|
|
7664
|
-
function saveLoginRecord(file, record) {
|
|
7665
|
-
writeJsonAtomic(file, record, 384);
|
|
7666
|
-
}
|
|
7667
|
-
function loadUserToken(file) {
|
|
7668
|
-
let text;
|
|
7669
|
-
try {
|
|
7670
|
-
text = fs2.readFileSync(file, "utf8");
|
|
7671
|
-
} catch {
|
|
7672
|
-
return null;
|
|
7673
|
-
}
|
|
7674
|
-
try {
|
|
7675
|
-
const parsed = JSON.parse(text);
|
|
7676
|
-
if (typeof parsed.access_token !== "string" || typeof parsed.base_url !== "string" || typeof parsed.expires_at !== "number") {
|
|
7677
|
-
return null;
|
|
7678
|
-
}
|
|
7679
|
-
return { access_token: parsed.access_token, expires_at: parsed.expires_at, base_url: parsed.base_url };
|
|
7680
|
-
} catch {
|
|
7681
|
-
return null;
|
|
7682
|
-
}
|
|
7683
|
-
}
|
|
7684
|
-
function saveUserToken(file, token) {
|
|
7685
|
-
writeJsonAtomic(file, token, 384);
|
|
7686
|
-
}
|
|
7687
|
-
function isFresh(token, freshForSeconds, nowMs = Date.now()) {
|
|
7688
|
-
return token.expires_at - nowMs / 1e3 > freshForSeconds;
|
|
7689
|
-
}
|
|
7690
|
-
function tokenClaims(accessToken) {
|
|
7691
|
-
const payload = accessToken.split(".")[1];
|
|
7692
|
-
if (!payload) return {};
|
|
7693
|
-
try {
|
|
7694
|
-
const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
7695
|
-
return parsed && typeof parsed === "object" ? parsed : {};
|
|
7696
|
-
} catch {
|
|
7697
|
-
return {};
|
|
7698
|
-
}
|
|
7699
|
-
}
|
|
7700
|
-
|
|
7701
7745
|
// src/auth/oauth-client.ts
|
|
7702
7746
|
var DEFAULT_EXPIRES_IN_SECONDS = 3600;
|
|
7703
7747
|
function loginRequired(message) {
|
|
@@ -7798,7 +7842,7 @@ function saveRotated(source, presentedRefresh, next) {
|
|
|
7798
7842
|
saveLogin(source, next);
|
|
7799
7843
|
}
|
|
7800
7844
|
function forgetLogin(source) {
|
|
7801
|
-
|
|
7845
|
+
fs4.rmSync(path3.dirname(source.loginFile), { recursive: true, force: true });
|
|
7802
7846
|
}
|
|
7803
7847
|
function noLogin(baseUrl, alternative) {
|
|
7804
7848
|
const command = `diverge login${baseUrl === DEFAULT_API_URL ? "" : ` --api-url ${baseUrl}`}`;
|
|
@@ -7817,6 +7861,7 @@ async function useOrganization(source, organizationId, nowMs = Date.now()) {
|
|
|
7817
7861
|
return token;
|
|
7818
7862
|
}
|
|
7819
7863
|
async function getUserToken(source, options = {}) {
|
|
7864
|
+
if (source.sessionTokenFile) return sessionToken(source.sessionTokenFile, source.baseUrl, options.organizationId);
|
|
7820
7865
|
const nowMs = options.nowMs ?? Date.now();
|
|
7821
7866
|
const record = requireLogin(source);
|
|
7822
7867
|
const organizationId = options.organizationId?.trim() || record.organization;
|
|
@@ -7849,6 +7894,146 @@ async function revokeRefreshToken(baseUrl, clientId2, refreshToken) {
|
|
|
7849
7894
|
if (!response.ok) throw new CliError(`Revoke endpoint returned HTTP ${response.status}`);
|
|
7850
7895
|
}
|
|
7851
7896
|
|
|
7897
|
+
// src/usage.ts
|
|
7898
|
+
function usageEntries(usage2) {
|
|
7899
|
+
const entries = [];
|
|
7900
|
+
let current = null;
|
|
7901
|
+
for (const line of usage2.split("\n")) {
|
|
7902
|
+
if (/^ {2}\S/.test(line)) {
|
|
7903
|
+
const label = line.trim().split(/ {2,}/)[0];
|
|
7904
|
+
const verbs = [];
|
|
7905
|
+
for (const word of label.split(" ")) {
|
|
7906
|
+
if (!/^[a-z][a-z-]*$/.test(word)) break;
|
|
7907
|
+
verbs.push(word);
|
|
7908
|
+
}
|
|
7909
|
+
current = { verbs, summary: line.trim().slice(label.length).trim(), lines: [line] };
|
|
7910
|
+
entries.push(current);
|
|
7911
|
+
} else if (current && /^ {3,}\S/.test(line)) {
|
|
7912
|
+
current.lines.push(line);
|
|
7913
|
+
} else {
|
|
7914
|
+
current = null;
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
return entries;
|
|
7918
|
+
}
|
|
7919
|
+
function startsWith(words, prefix) {
|
|
7920
|
+
return prefix.every((word, index) => words[index] === word);
|
|
7921
|
+
}
|
|
7922
|
+
function verbPath(usage2, args) {
|
|
7923
|
+
let best = [];
|
|
7924
|
+
for (const entry of usageEntries(usage2)) {
|
|
7925
|
+
let shared = 0;
|
|
7926
|
+
while (shared < entry.verbs.length && args[shared] === entry.verbs[shared]) shared++;
|
|
7927
|
+
if (shared > best.length) best = entry.verbs.slice(0, shared);
|
|
7928
|
+
}
|
|
7929
|
+
return best;
|
|
7930
|
+
}
|
|
7931
|
+
function groupOptions(usage2) {
|
|
7932
|
+
return usage2.split("\n", 1)[0].match(/\[--[^\]]+\]/g) ?? [];
|
|
7933
|
+
}
|
|
7934
|
+
function verbUsage(command, usage2, path17) {
|
|
7935
|
+
const lines = usageEntries(usage2).filter((entry) => startsWith(entry.verbs, path17)).flatMap((entry) => entry.lines);
|
|
7936
|
+
if (path17.length === 0 || lines.length === 0) return usage2;
|
|
7937
|
+
const shared = groupOptions(usage2);
|
|
7938
|
+
return [`diverge ${command} ${path17.join(" ")} ...`, "", ...lines, ...shared.length ? ["", `Every ${command} command also takes ${shared.join(" ")}.`] : []].join("\n");
|
|
7939
|
+
}
|
|
7940
|
+
var COMMON_WORDS = /* @__PURE__ */ new Set(["the", "and", "you", "for", "its", "with", "not", "one", "are", "all", "any", "from", "that", "this", "own", "per", "into", "out", "else", "each", "what", "when", "your"]);
|
|
7941
|
+
function distance(a, b) {
|
|
7942
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_2, j) => i === 0 ? j : j === 0 ? i : 0));
|
|
7943
|
+
for (let i = 1; i <= a.length; i++) {
|
|
7944
|
+
for (let j = 1; j <= b.length; j++) {
|
|
7945
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
7946
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
7947
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
7948
|
+
}
|
|
7949
|
+
}
|
|
7950
|
+
return d[a.length][b.length];
|
|
7951
|
+
}
|
|
7952
|
+
function namesIt(word, guess) {
|
|
7953
|
+
if (word.length < 3 || COMMON_WORDS.has(word)) return false;
|
|
7954
|
+
return word === guess || guess.length >= 3 && word.startsWith(guess) || guess.startsWith(word) || guess.endsWith(word);
|
|
7955
|
+
}
|
|
7956
|
+
function prose(line) {
|
|
7957
|
+
return line.toLowerCase().replace(/\[[^\]]*\]|--?[a-z][a-z-]*/g, " ");
|
|
7958
|
+
}
|
|
7959
|
+
function closest(guess, candidates, rest = [], limit = 3) {
|
|
7960
|
+
const target = guess.toLowerCase().replace(/^-+/, "");
|
|
7961
|
+
const threshold = Math.max(1, Math.floor(target.length / 3));
|
|
7962
|
+
const matches = [];
|
|
7963
|
+
for (const candidate of candidates) {
|
|
7964
|
+
const first = candidate.summary ?? "";
|
|
7965
|
+
const name = candidate.name.toLowerCase();
|
|
7966
|
+
if (name && rest.includes(candidate.name)) {
|
|
7967
|
+
matches.push({ candidate, score: 0, hint: first });
|
|
7968
|
+
continue;
|
|
7969
|
+
}
|
|
7970
|
+
const edits = name ? distance(target, name) : Infinity;
|
|
7971
|
+
if (edits <= threshold || name && target.length >= 2 && name.startsWith(target)) {
|
|
7972
|
+
matches.push({ candidate, score: Math.min(edits, threshold), hint: first });
|
|
7973
|
+
continue;
|
|
7974
|
+
}
|
|
7975
|
+
const line = candidate.lines.find((text) => (prose(text).match(/[a-z]+/g) ?? []).some((word) => namesIt(word, target)));
|
|
7976
|
+
if (line) matches.push({ candidate, score: threshold + 1, hint: line });
|
|
7977
|
+
}
|
|
7978
|
+
return matches.sort((a, b) => a.score - b.score).slice(0, limit);
|
|
7979
|
+
}
|
|
7980
|
+
function didYouMean(matches) {
|
|
7981
|
+
if (matches.length === 0) return "";
|
|
7982
|
+
const shown = (match) => {
|
|
7983
|
+
const hint = match.hint.trim();
|
|
7984
|
+
return hint && hint !== match.candidate.invocation ? `${match.candidate.invocation} (${hint})` : match.candidate.invocation;
|
|
7985
|
+
};
|
|
7986
|
+
if (matches.length === 1) return ` Did you mean: ${shown(matches[0])}?`;
|
|
7987
|
+
return ` Did you mean one of:
|
|
7988
|
+
${matches.map((match) => ` ${shown(match)}`).join("\n")}`;
|
|
7989
|
+
}
|
|
7990
|
+
function verbCandidates(command, usage2, path17) {
|
|
7991
|
+
const byName = /* @__PURE__ */ new Map();
|
|
7992
|
+
for (const entry of usageEntries(usage2)) {
|
|
7993
|
+
if (!startsWith(entry.verbs, path17)) continue;
|
|
7994
|
+
const name = entry.verbs[path17.length] ?? "";
|
|
7995
|
+
const invocation = ["diverge", command, ...path17, ...name ? [name] : []].join(" ");
|
|
7996
|
+
const lines = [entry.summary, ...entry.lines.slice(1).map((line) => line.trim())].filter(Boolean);
|
|
7997
|
+
const known = byName.get(name);
|
|
7998
|
+
if (known) known.lines.push(...lines);
|
|
7999
|
+
else byName.set(name, { invocation, name, summary: entry.summary, lines });
|
|
8000
|
+
}
|
|
8001
|
+
return [...byName.values()];
|
|
8002
|
+
}
|
|
8003
|
+
function unknownVerb(command, usage2, path17, verb, rest = []) {
|
|
8004
|
+
const candidates = verbCandidates(command, usage2, path17);
|
|
8005
|
+
const where = [command, ...path17].join(" ");
|
|
8006
|
+
if (!verb) return new CliError(`${where} needs one of: ${candidates.map((candidate) => candidate.name).filter(Boolean).join(", ")}
|
|
8007
|
+
|
|
8008
|
+
${usage2}`);
|
|
8009
|
+
return new CliError(`Unknown ${where} verb: ${verb}.${didYouMean(closest(verb, candidates, rest))}
|
|
8010
|
+
|
|
8011
|
+
${usage2}`);
|
|
8012
|
+
}
|
|
8013
|
+
function optionCandidates(usage2, path17) {
|
|
8014
|
+
const entries = usageEntries(usage2);
|
|
8015
|
+
const [header = "", ...body] = usage2.split("\n");
|
|
8016
|
+
const described = entries.length === 0 || path17.length === 0 ? body : entries.filter((entry) => startsWith(entry.verbs, path17)).flatMap((entry) => entry.lines);
|
|
8017
|
+
const byName = /* @__PURE__ */ new Map();
|
|
8018
|
+
const add = (line, describes) => {
|
|
8019
|
+
for (const [flag] of line.matchAll(/--[a-z][a-z-]*/g)) {
|
|
8020
|
+
const candidate = byName.get(flag) ?? { invocation: flag, name: flag.slice(2), lines: [] };
|
|
8021
|
+
byName.set(flag, candidate);
|
|
8022
|
+
if (describes && !candidate.lines.includes(line.trim())) candidate.lines.push(line.trim());
|
|
8023
|
+
}
|
|
8024
|
+
};
|
|
8025
|
+
add(header, false);
|
|
8026
|
+
for (const line of described) add(line, true);
|
|
8027
|
+
return [...byName.values()];
|
|
8028
|
+
}
|
|
8029
|
+
function unknownOption(error, usage2, args) {
|
|
8030
|
+
if (!(error instanceof Error) || error.name !== "TypeError") return null;
|
|
8031
|
+
const option = /^Unknown option '([^']+)'/.exec(error.message)?.[1];
|
|
8032
|
+
if (!option) return null;
|
|
8033
|
+
const path17 = verbPath(usage2, args);
|
|
8034
|
+
return `Unknown option: ${option}.${didYouMean(closest(option, optionCandidates(usage2, path17)))}`;
|
|
8035
|
+
}
|
|
8036
|
+
|
|
7852
8037
|
// src/commands/login.ts
|
|
7853
8038
|
import { parseArgs } from "node:util";
|
|
7854
8039
|
|
|
@@ -7936,6 +8121,7 @@ function resolveLoginHint(flag, previous) {
|
|
|
7936
8121
|
return remembered || void 0;
|
|
7937
8122
|
}
|
|
7938
8123
|
async function runLogin(args, io) {
|
|
8124
|
+
refuseInSession(io.env, "login");
|
|
7939
8125
|
const { values } = parseArgs({
|
|
7940
8126
|
args,
|
|
7941
8127
|
options: {
|
|
@@ -8017,6 +8203,14 @@ function surfaceBaseUrl(apiUrl, surface) {
|
|
|
8017
8203
|
}
|
|
8018
8204
|
|
|
8019
8205
|
// src/gateway/models.ts
|
|
8206
|
+
function servedModel(record) {
|
|
8207
|
+
return {
|
|
8208
|
+
id: record.id,
|
|
8209
|
+
input: record.input_modalities?.includes("image") ? ["text", "image"] : ["text"],
|
|
8210
|
+
...record.context_window ? { contextWindow: record.context_window } : {},
|
|
8211
|
+
...record.max_output_tokens ? { maxOutputTokens: record.max_output_tokens } : {}
|
|
8212
|
+
};
|
|
8213
|
+
}
|
|
8020
8214
|
async function listModels(apiUrl, accessToken, surface) {
|
|
8021
8215
|
try {
|
|
8022
8216
|
const body = await fetchJson(`${surfaceBaseUrl(apiUrl, surface)}/v1/models`, {
|
|
@@ -8033,7 +8227,7 @@ async function listModels(apiUrl, accessToken, surface) {
|
|
|
8033
8227
|
}
|
|
8034
8228
|
async function ensureInferenceLogin(io, apiUrl, organizationId) {
|
|
8035
8229
|
const source = tokenSource(io.env, apiUrl);
|
|
8036
|
-
if (!loadLogin(source)) {
|
|
8230
|
+
if (!source.sessionTokenFile && !loadLogin(source)) {
|
|
8037
8231
|
if (!io.interactive) throw new CliError(`Not signed in to ${apiUrl}. Run: diverge login${organizationId ? ` --organization-id ${organizationId}` : ""}`);
|
|
8038
8232
|
await runLogin(organizationId ? ["--organization-id", organizationId] : [], io);
|
|
8039
8233
|
}
|
|
@@ -8114,26 +8308,276 @@ function mergeCodexConfig(existing, block) {
|
|
|
8114
8308
|
|
|
8115
8309
|
// src/agents/dsh.ts
|
|
8116
8310
|
var import_yaml = __toESM(require_dist(), 1);
|
|
8117
|
-
import
|
|
8311
|
+
import fs5 from "node:fs";
|
|
8118
8312
|
import { createRequire } from "node:module";
|
|
8119
8313
|
import os4 from "node:os";
|
|
8120
8314
|
import path6 from "node:path";
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8315
|
+
|
|
8316
|
+
// src/tools/settings.ts
|
|
8317
|
+
var BRIDGE_SCOPES = "mcp:read mcp:execute";
|
|
8318
|
+
var LOGIN_HINT = "diverge login";
|
|
8319
|
+
function loadToolsSettings(options, env = process.env) {
|
|
8320
|
+
const apiUrl = resolveApiUrl(void 0, env);
|
|
8321
|
+
const projectId = options.projectId?.trim() || env.DIVERGENT_PROJECT_ID?.trim() || void 0;
|
|
8322
|
+
let organizationId = options.organizationId?.trim() || env.DIVERGENT_ORG_ID?.trim() || "";
|
|
8323
|
+
const tokenFile = sessionTokenFile(env);
|
|
8324
|
+
if (tokenFile) {
|
|
8325
|
+
organizationId = sessionOrganization(tokenFile, readSessionToken(tokenFile), organizationId || void 0);
|
|
8326
|
+
return { apiUrl, organizationId, projectId, mode: "session", tokenFile };
|
|
8327
|
+
}
|
|
8328
|
+
const cached = loadLogin(tokenSource(env, apiUrl));
|
|
8329
|
+
if (cached) {
|
|
8330
|
+
organizationId ||= cached.organization ?? "";
|
|
8331
|
+
if (!organizationId) throw new CliError(`The login has no default organization. Pass --organization-id or choose one: diverge org use <id|name>`);
|
|
8332
|
+
return { apiUrl, organizationId, projectId, mode: "operator", clientId: clientId(env) };
|
|
8333
|
+
}
|
|
8334
|
+
const serviceClientId = env.DIVERGENT_CLIENT_ID?.trim() ?? "";
|
|
8335
|
+
const serviceClientSecret = env.DIVERGENT_CLIENT_SECRET?.trim() ?? "";
|
|
8336
|
+
const delegatedUserId = env.DIVERGENT_USER_ID?.trim() ?? "";
|
|
8337
|
+
if (!serviceClientId || !serviceClientSecret) {
|
|
8338
|
+
throw noLogin(apiUrl, "Or, unattended, set DIVERGENT_CLIENT_ID, DIVERGENT_CLIENT_SECRET, DIVERGENT_USER_ID and DIVERGENT_ORG_ID.");
|
|
8339
|
+
}
|
|
8340
|
+
if (!organizationId) throw new CliError("Service credentials act in the organization named: pass --organization-id or set DIVERGENT_ORG_ID.");
|
|
8341
|
+
if (!delegatedUserId) {
|
|
8342
|
+
throw new CliError(`DIVERGENT_USER_ID is required for service-credential execution: tools run under that human's RBAC, and without it the service account executes app-only, which governed tools deliberately restrict.
|
|
8343
|
+
Signing in as yourself avoids this entirely: ${LOGIN_HINT}`);
|
|
8344
|
+
}
|
|
8345
|
+
return { apiUrl, organizationId, projectId, mode: "service", serviceClientId, serviceClientSecret, delegatedUserId };
|
|
8124
8346
|
}
|
|
8125
|
-
function
|
|
8126
|
-
|
|
8127
|
-
return models.includes(DSH_SHIPPED_DEFAULT_MODEL) ? DSH_SHIPPED_DEFAULT_MODEL : models[0];
|
|
8347
|
+
function scopeLine(settings) {
|
|
8348
|
+
return `Organization: ${settings.organizationId}${settings.projectId ? ` Project: ${settings.projectId}` : ""}`;
|
|
8128
8349
|
}
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8350
|
+
var actingAs = null;
|
|
8351
|
+
function actingAsLine(settings, env = process.env) {
|
|
8352
|
+
if (settings.mode === "service") {
|
|
8353
|
+
return Promise.resolve(`Acting as: delegated user ${settings.delegatedUserId} via service client`);
|
|
8354
|
+
}
|
|
8355
|
+
actingAs ??= (async () => {
|
|
8356
|
+
let accessToken;
|
|
8357
|
+
try {
|
|
8358
|
+
accessToken = (await getUserToken(tokenSource(env, settings.apiUrl))).access_token;
|
|
8359
|
+
} catch (error) {
|
|
8360
|
+
return `Acting as: unknown user (email unavailable: ${error instanceof Error ? error.message : String(error)})`;
|
|
8361
|
+
}
|
|
8362
|
+
const claims = tokenClaims(accessToken);
|
|
8363
|
+
const account = await describeAccount(settings.apiUrl, accessToken, claims.sub);
|
|
8364
|
+
if (settings.mode !== "session") return `Acting as: ${account}`;
|
|
8365
|
+
return `Acting as: ${account} on a session token (${SESSION_TOKEN_VARIABLE})${claims.act?.sub ? `, for ${claims.act.sub}` : ""}`;
|
|
8366
|
+
})();
|
|
8367
|
+
return actingAs;
|
|
8368
|
+
}
|
|
8369
|
+
function describeToolExecution(env = process.env) {
|
|
8370
|
+
let settings;
|
|
8371
|
+
try {
|
|
8372
|
+
settings = loadToolsSettings({}, env);
|
|
8373
|
+
} catch (error) {
|
|
8374
|
+
return `Tool execution: unavailable \u2014 ${error instanceof CliError ? error.message.split("\n")[0] : String(error)}`;
|
|
8375
|
+
}
|
|
8376
|
+
if (settings.mode === "session") return `Tool execution: on the session token in ${settings.tokenFile}, organization ${settings.organizationId}, on ${settings.apiUrl}`;
|
|
8377
|
+
return settings.mode === "operator" ? `Tool execution: as you, the signed-in operator, on ${settings.apiUrl}` : `Tool execution: NOT as you \u2014 delegated to DIVERGENT_USER_ID=${settings.delegatedUserId} via service credentials on ${settings.apiUrl}`;
|
|
8378
|
+
}
|
|
8379
|
+
|
|
8380
|
+
// src/tools/client.ts
|
|
8381
|
+
var INVOCATION_SET_TOOL = "functions_invocation_set";
|
|
8382
|
+
var PENDING_INVOCATION_STATUSES = ["pending", "approved", "executing"];
|
|
8383
|
+
function isPending(result) {
|
|
8384
|
+
return !!result && typeof result === "object" && result.status === "pending_approval";
|
|
8385
|
+
}
|
|
8386
|
+
var REQUEST_TIMEOUT_MS = 63e4;
|
|
8387
|
+
var TOKEN_REFRESH_MARGIN_SECONDS = 60;
|
|
8388
|
+
var ToolsClient = class {
|
|
8389
|
+
constructor(settings, env = process.env, fetchImpl = fetch) {
|
|
8390
|
+
this.settings = settings;
|
|
8391
|
+
this.env = env;
|
|
8392
|
+
this.fetchImpl = fetchImpl;
|
|
8393
|
+
}
|
|
8394
|
+
settings;
|
|
8395
|
+
env;
|
|
8396
|
+
fetchImpl;
|
|
8397
|
+
serviceToken = null;
|
|
8398
|
+
async token() {
|
|
8399
|
+
if (this.settings.mode !== "service") {
|
|
8400
|
+
return (await getUserToken(tokenSource(this.env, this.settings.apiUrl), { organizationId: this.settings.organizationId })).access_token;
|
|
8401
|
+
}
|
|
8402
|
+
if (this.serviceToken && Date.now() < this.serviceToken.expiresAtMs) return this.serviceToken.value;
|
|
8403
|
+
let response;
|
|
8404
|
+
try {
|
|
8405
|
+
response = await this.fetchImpl(tokenEndpoint(this.settings.apiUrl), {
|
|
8406
|
+
method: "POST",
|
|
8407
|
+
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
8408
|
+
body: JSON.stringify({
|
|
8409
|
+
grant_type: "client_credentials",
|
|
8410
|
+
client_id: this.settings.serviceClientId,
|
|
8411
|
+
client_secret: this.settings.serviceClientSecret,
|
|
8412
|
+
scopes: BRIDGE_SCOPES,
|
|
8413
|
+
organization_id: this.settings.organizationId
|
|
8414
|
+
}),
|
|
8415
|
+
signal: AbortSignal.timeout(3e4)
|
|
8416
|
+
});
|
|
8417
|
+
} catch (error) {
|
|
8418
|
+
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8419
|
+
}
|
|
8420
|
+
if (!response.ok) throw new CliError(`Token acquisition failed (${response.status}): ${(await response.text()).slice(0, 400)}`);
|
|
8421
|
+
const body = await response.json();
|
|
8422
|
+
if (!body.access_token) throw new CliError("Token response contained no access_token");
|
|
8423
|
+
const expiresIn = Number(body.expires_in ?? 3600);
|
|
8424
|
+
this.serviceToken = { value: body.access_token, expiresAtMs: Date.now() + Math.max(expiresIn - TOKEN_REFRESH_MARGIN_SECONDS, 30) * 1e3 };
|
|
8425
|
+
return body.access_token;
|
|
8426
|
+
}
|
|
8427
|
+
async headers() {
|
|
8428
|
+
const headers = { Authorization: `Bearer ${await this.token()}`, "Content-Type": "application/json", "User-Agent": USER_AGENT };
|
|
8429
|
+
if (this.settings.mode === "service") headers["x-divergent-user-id"] = this.settings.delegatedUserId;
|
|
8430
|
+
return headers;
|
|
8431
|
+
}
|
|
8432
|
+
scoped(path17) {
|
|
8433
|
+
const query = new URLSearchParams({ organizationId: this.settings.organizationId });
|
|
8434
|
+
if (this.settings.projectId) query.set("projectId", this.settings.projectId);
|
|
8435
|
+
return `${this.settings.apiUrl}${path17}?${query.toString()}`;
|
|
8436
|
+
}
|
|
8437
|
+
async send(method, url, body) {
|
|
8438
|
+
return this.request(method, url, body, void 0);
|
|
8439
|
+
}
|
|
8440
|
+
/**
|
|
8441
|
+
* One request, re-authenticated once on 401 in service mode. `refused`
|
|
8442
|
+
* turns a chosen status into a value instead of an error, for the
|
|
8443
|
+
* outcomes a caller acts on (a manifest the platform would not accept).
|
|
8444
|
+
*/
|
|
8445
|
+
async request(method, url, body, refused) {
|
|
8446
|
+
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
8447
|
+
const headers = await this.headers();
|
|
8448
|
+
let response;
|
|
8449
|
+
try {
|
|
8450
|
+
response = await this.fetchImpl(url, { method, headers, body: body === void 0 ? void 0 : JSON.stringify(body), signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
8451
|
+
} catch (error) {
|
|
8452
|
+
if (error instanceof Error && error.name === "TimeoutError") {
|
|
8453
|
+
throw new CliError(`${this.settings.apiUrl} did not answer within ${REQUEST_TIMEOUT_MS / 1e3} s`);
|
|
8454
|
+
}
|
|
8455
|
+
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8456
|
+
}
|
|
8457
|
+
if (response.status === 401 && attempt === 1 && this.settings.mode === "service") {
|
|
8458
|
+
this.serviceToken = null;
|
|
8459
|
+
continue;
|
|
8460
|
+
}
|
|
8461
|
+
const text = await response.text();
|
|
8462
|
+
if (!response.ok) {
|
|
8463
|
+
const handled = refused?.(response.status, text);
|
|
8464
|
+
if (handled !== void 0) return handled;
|
|
8465
|
+
let message = text;
|
|
8466
|
+
try {
|
|
8467
|
+
const parsed = JSON.parse(text);
|
|
8468
|
+
if (typeof parsed.error === "string" && parsed.error) message = parsed.error;
|
|
8469
|
+
} catch {
|
|
8470
|
+
}
|
|
8471
|
+
if (response.status === 403 && /scope/i.test(message)) {
|
|
8472
|
+
throw new CliError(`${response.status}: ${message}
|
|
8473
|
+
The signed-in token is missing a required scope. Re-run: ${LOGIN_HINT}`);
|
|
8474
|
+
}
|
|
8475
|
+
throw new CliError(`${response.status}: ${message}`.slice(0, 2e3));
|
|
8476
|
+
}
|
|
8477
|
+
return text ? JSON.parse(text) : {};
|
|
8478
|
+
}
|
|
8479
|
+
throw new CliError("Request failed after re-authentication");
|
|
8480
|
+
}
|
|
8481
|
+
async listTools() {
|
|
8482
|
+
const body = await this.send("GET", this.scoped("/api/plugins/functions/tools"));
|
|
8483
|
+
return body.tools ?? [];
|
|
8484
|
+
}
|
|
8485
|
+
/**
|
|
8486
|
+
* One tool, looked up at its source when the catalog does not list it yet —
|
|
8487
|
+
* a tool deployed after its server's catalog was read. A 404 is an answer.
|
|
8488
|
+
*/
|
|
8489
|
+
describeTool(name) {
|
|
8490
|
+
return this.request("GET", this.scoped(`/api/plugins/functions/tools/${encodeURIComponent(name)}`), void 0, (status2, text) => {
|
|
8491
|
+
if (status2 !== 404) return void 0;
|
|
8492
|
+
try {
|
|
8493
|
+
const parsed = JSON.parse(text);
|
|
8494
|
+
if (typeof parsed.error === "string" && parsed.error) return { notFound: parsed.error };
|
|
8495
|
+
} catch {
|
|
8496
|
+
}
|
|
8497
|
+
return { notFound: `No tool named '${name}' is available.` };
|
|
8498
|
+
});
|
|
8499
|
+
}
|
|
8500
|
+
/**
|
|
8501
|
+
* One call. The platform answers a completed call with its invocation
|
|
8502
|
+
* envelope, `{status: 'succeeded', invocationId?, result}`; the tool's own
|
|
8503
|
+
* payload is `result` inside it. Every caller wants the payload, so it is
|
|
8504
|
+
* unwrapped here, once — a pending approval passes through as it is.
|
|
8505
|
+
*/
|
|
8506
|
+
async callTool(name, args) {
|
|
8507
|
+
const body = await this.send("POST", this.scoped("/api/plugins/functions/tools/execute"), { toolName: name, arguments: args ?? {} });
|
|
8508
|
+
const outcome = body.result;
|
|
8509
|
+
if (outcome?.status !== "succeeded") return body;
|
|
8510
|
+
return { ...body, result: outcome.result };
|
|
8511
|
+
}
|
|
8512
|
+
/**
|
|
8513
|
+
* Several related writes raised as one invocation (ADR 0054, amended
|
|
8514
|
+
* 2026-09-26): one decision for the lot, executed in order, stopping at
|
|
8515
|
+
* the first failure. Answers exactly like `callTool`; a set that ran
|
|
8516
|
+
* carries every call's outcome in `result.calls`.
|
|
8517
|
+
*/
|
|
8518
|
+
async callSet(calls, summary) {
|
|
8519
|
+
const body = await this.send("POST", this.scoped("/api/plugins/functions/tools/sets"), {
|
|
8520
|
+
...summary ? { summary } : {},
|
|
8521
|
+
calls: calls.map((call2) => ({ toolName: call2.tool, arguments: call2.args ?? {} }))
|
|
8522
|
+
});
|
|
8523
|
+
const outcome = body.result;
|
|
8524
|
+
if (outcome?.status !== "succeeded") return body;
|
|
8525
|
+
return { ...body, result: outcome.result };
|
|
8526
|
+
}
|
|
8527
|
+
/** The read half of raise-and-read (ADR 0047); anyone but the raiser sees a 404. */
|
|
8528
|
+
getInvocation(invocationId) {
|
|
8529
|
+
return this.send("GET", this.scoped(`/api/plugins/functions/tools/invocations/${encodeURIComponent(invocationId)}`));
|
|
8530
|
+
}
|
|
8531
|
+
// ── Tenant plugins (RFC: Tenant Plugins) ──────────────────────────────
|
|
8532
|
+
descriptorsUrl(pluginId) {
|
|
8533
|
+
const base = `${this.settings.apiUrl}/api/plugins/forge/plugins/descriptors${pluginId ? `/${encodeURIComponent(pluginId)}` : ""}`;
|
|
8534
|
+
return `${base}?${new URLSearchParams({ targetOrganizationId: this.settings.organizationId }).toString()}`;
|
|
8535
|
+
}
|
|
8536
|
+
/** Validate (dryRun) or publish a manifest for the organization the login is issued to. */
|
|
8537
|
+
publishPlugin(manifest, options) {
|
|
8538
|
+
return this.request(
|
|
8539
|
+
"POST",
|
|
8540
|
+
this.descriptorsUrl(),
|
|
8541
|
+
{ targetOrganizationId: this.settings.organizationId, manifest, dryRun: options.dryRun },
|
|
8542
|
+
(status2, text) => {
|
|
8543
|
+
if (status2 !== 400) return void 0;
|
|
8544
|
+
try {
|
|
8545
|
+
const parsed = JSON.parse(text);
|
|
8546
|
+
if (Array.isArray(parsed.details)) return { ok: false, details: parsed.details.map(String) };
|
|
8547
|
+
return { ok: false, details: [parsed.error ?? text] };
|
|
8548
|
+
} catch {
|
|
8549
|
+
return { ok: false, details: [text] };
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
).then((outcome) => "ok" in outcome ? outcome : { ok: true, result: outcome });
|
|
8553
|
+
}
|
|
8554
|
+
async listPlugins() {
|
|
8555
|
+
const body = await this.send("GET", this.descriptorsUrl());
|
|
8556
|
+
return body.plugins ?? [];
|
|
8557
|
+
}
|
|
8558
|
+
async retirePlugin(pluginId) {
|
|
8559
|
+
const body = await this.send("DELETE", this.descriptorsUrl(pluginId), { targetOrganizationId: this.settings.organizationId });
|
|
8560
|
+
return body.plugin;
|
|
8561
|
+
}
|
|
8562
|
+
};
|
|
8563
|
+
|
|
8564
|
+
// src/agents/dsh.ts
|
|
8565
|
+
var DSH_SHIPPED_DEFAULT_MODEL = "deepseek-flash";
|
|
8566
|
+
function dshHome(env = process.env) {
|
|
8567
|
+
return env.DSH_HOME?.trim() || path6.join(os4.homedir(), ".dsh");
|
|
8568
|
+
}
|
|
8569
|
+
function dshDefaultModel(models, requested) {
|
|
8570
|
+
if (requested) return requested;
|
|
8571
|
+
return models.includes(DSH_SHIPPED_DEFAULT_MODEL) ? DSH_SHIPPED_DEFAULT_MODEL : models[0];
|
|
8572
|
+
}
|
|
8573
|
+
function dshPatchYaml(options) {
|
|
8574
|
+
const tokenEnv = options.tokenEnv ?? "DIVERGENT_TOKEN";
|
|
8575
|
+
const route = `divergent-${options.surface}`;
|
|
8576
|
+
const api = options.surface === "openai" ? "openai-completions" : "anthropic-messages";
|
|
8577
|
+
const endpoint = options.surface === "openai" ? `${options.baseUrl}/v1` : options.baseUrl;
|
|
8578
|
+
return [
|
|
8579
|
+
"# Divergent gateway overlay for dsh; written by `diverge agents setup dsh`.",
|
|
8580
|
+
`# Boot with: ${tokenEnv}="$(diverge token)" dsh --profile <profile> --patch <this file>`,
|
|
8137
8581
|
"- id: llm-pi-ai",
|
|
8138
8582
|
" config:",
|
|
8139
8583
|
" providers:",
|
|
@@ -8143,7 +8587,12 @@ function dshPatchYaml(options) {
|
|
|
8143
8587
|
` baseURL: ${endpoint}`,
|
|
8144
8588
|
` apiKeyEnv: ${tokenEnv}`,
|
|
8145
8589
|
" models:",
|
|
8146
|
-
...options.models.
|
|
8590
|
+
...options.models.flatMap((model) => [
|
|
8591
|
+
` - id: ${JSON.stringify(model.id)}`,
|
|
8592
|
+
` input: [${model.input.join(", ")}]`,
|
|
8593
|
+
...model.contextWindow ? [` contextWindow: ${model.contextWindow}`] : [],
|
|
8594
|
+
...model.maxOutputTokens ? [` maxTokens: ${model.maxOutputTokens}`] : []
|
|
8595
|
+
]),
|
|
8147
8596
|
"- id: agent-default-model",
|
|
8148
8597
|
" config:",
|
|
8149
8598
|
` provider: ${route}`,
|
|
@@ -8159,9 +8608,33 @@ function dshPatchYaml(options) {
|
|
|
8159
8608
|
"- id: session-telemetry-otel",
|
|
8160
8609
|
" disabled: true",
|
|
8161
8610
|
...dshSearchRows(),
|
|
8611
|
+
...dshShellRows(),
|
|
8612
|
+
...dshBrowserRows(),
|
|
8162
8613
|
""
|
|
8163
8614
|
].join("\n");
|
|
8164
8615
|
}
|
|
8616
|
+
function dshShellRows() {
|
|
8617
|
+
return ["bash-sandbox", "pwsh-sandbox"].flatMap((id) => [
|
|
8618
|
+
`- id: ${id}`,
|
|
8619
|
+
" config:",
|
|
8620
|
+
` timeoutMs: ${REQUEST_TIMEOUT_MS}`,
|
|
8621
|
+
` maxTimeoutMs: ${REQUEST_TIMEOUT_MS}`
|
|
8622
|
+
]);
|
|
8623
|
+
}
|
|
8624
|
+
var CHROME_DEVTOOLS_MCP_VERSION = "1.10.1";
|
|
8625
|
+
var CHROME_DEBUG_URL = "http://127.0.0.1:9222";
|
|
8626
|
+
function dshBrowserRows() {
|
|
8627
|
+
return [
|
|
8628
|
+
"- insert:",
|
|
8629
|
+
" - id: mcp-chrome-devtools",
|
|
8630
|
+
" name: '@deepseek-ai/dsh-mcp-client'",
|
|
8631
|
+
" config:",
|
|
8632
|
+
" serverName: chrome-devtools",
|
|
8633
|
+
" transport: stdio",
|
|
8634
|
+
" command: npx",
|
|
8635
|
+
` args: ['-y', 'chrome-devtools-mcp@${CHROME_DEVTOOLS_MCP_VERSION}', '--browser-url=${CHROME_DEBUG_URL}', '--no-usage-statistics', '--no-performance-crux']`
|
|
8636
|
+
];
|
|
8637
|
+
}
|
|
8165
8638
|
function dshSearchRows() {
|
|
8166
8639
|
return [
|
|
8167
8640
|
"- id: web-search-deepseek",
|
|
@@ -8210,17 +8683,17 @@ var DSH_USER_PRESETS_DIR = ".agent-presets";
|
|
|
8210
8683
|
function dshPackageDir(binary) {
|
|
8211
8684
|
if (/\.(cmd|bat)$/i.test(binary)) {
|
|
8212
8685
|
const dir2 = path6.join(path6.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
|
|
8213
|
-
return
|
|
8686
|
+
return fs5.existsSync(path6.join(dir2, "package.json")) ? dir2 : null;
|
|
8214
8687
|
}
|
|
8215
8688
|
let dir;
|
|
8216
8689
|
try {
|
|
8217
|
-
dir = path6.dirname(
|
|
8690
|
+
dir = path6.dirname(fs5.realpathSync(binary));
|
|
8218
8691
|
} catch {
|
|
8219
8692
|
return null;
|
|
8220
8693
|
}
|
|
8221
8694
|
for (; ; ) {
|
|
8222
8695
|
try {
|
|
8223
|
-
if (JSON.parse(
|
|
8696
|
+
if (JSON.parse(fs5.readFileSync(path6.join(dir, "package.json"), "utf8")).name === "@deepseek-ai/dsh") return dir;
|
|
8224
8697
|
} catch {
|
|
8225
8698
|
}
|
|
8226
8699
|
const parent = path6.dirname(dir);
|
|
@@ -8232,7 +8705,7 @@ function shippedPresetDir(packageDir, id = "standard") {
|
|
|
8232
8705
|
try {
|
|
8233
8706
|
const require2 = createRequire(path6.join(packageDir, "package.json"));
|
|
8234
8707
|
const dir = path6.join(path6.dirname(require2.resolve("@deepseek-ai/dsh-agent-presets/package.json")), "presets", id);
|
|
8235
|
-
return
|
|
8708
|
+
return fs5.existsSync(path6.join(dir, "agent.cordis.yml")) ? dir : null;
|
|
8236
8709
|
} catch {
|
|
8237
8710
|
return null;
|
|
8238
8711
|
}
|
|
@@ -8270,7 +8743,7 @@ var DIVERGENT_PRESET_METADATA = [
|
|
|
8270
8743
|
].join("\n");
|
|
8271
8744
|
function writeDivergentPreset(home, shippedDir) {
|
|
8272
8745
|
const dir = path6.join(home, DSH_USER_PRESETS_DIR, DIVERGENT_PRESET_ID);
|
|
8273
|
-
writeTextAtomic(path6.join(dir, "agent.cordis.yml"), divergentPreset(
|
|
8746
|
+
writeTextAtomic(path6.join(dir, "agent.cordis.yml"), divergentPreset(fs5.readFileSync(path6.join(shippedDir, "agent.cordis.yml"), "utf8")), 420);
|
|
8274
8747
|
writeTextAtomic(path6.join(dir, "preset.yml"), DIVERGENT_PRESET_METADATA, 420);
|
|
8275
8748
|
return dir;
|
|
8276
8749
|
}
|
|
@@ -8294,7 +8767,12 @@ function mergeOpencodeConfig(existing, options) {
|
|
|
8294
8767
|
const config = structuredClone(existing ?? {});
|
|
8295
8768
|
config.$schema ??= "https://opencode.ai/config.json";
|
|
8296
8769
|
const providers = { ...config.provider ?? {} };
|
|
8297
|
-
const models = Object.fromEntries(options.models.map((model) => [model, {
|
|
8770
|
+
const models = Object.fromEntries(options.models.map((model) => [model.id, {
|
|
8771
|
+
name: model.id,
|
|
8772
|
+
attachment: model.input.includes("image"),
|
|
8773
|
+
modalities: { input: model.input, output: ["text"] },
|
|
8774
|
+
...model.contextWindow && model.maxOutputTokens ? { limit: { context: model.contextWindow, output: model.maxOutputTokens } } : {}
|
|
8775
|
+
}]));
|
|
8298
8776
|
const options_ = { baseURL: `${options.baseUrl}/v1`, apiKey: `{env:${tokenEnv}}` };
|
|
8299
8777
|
providers[`divergent-${options.surface}`] = options.surface === "openai" ? { npm: "@ai-sdk/openai-compatible", name: "Divergent (OpenAI)", options: options_, models } : { npm: "@ai-sdk/anthropic", name: "Divergent (Anthropic)", options: options_, models };
|
|
8300
8778
|
config.provider = providers;
|
|
@@ -8303,26 +8781,10 @@ function mergeOpencodeConfig(existing, options) {
|
|
|
8303
8781
|
|
|
8304
8782
|
// src/agents/run-dsh.ts
|
|
8305
8783
|
import { spawn as spawn2 } from "node:child_process";
|
|
8306
|
-
import
|
|
8784
|
+
import fs6 from "node:fs";
|
|
8307
8785
|
import path8 from "node:path";
|
|
8308
|
-
function findOnPath(name, env = process.env, platform = process.platform) {
|
|
8309
|
-
const dirs = (env.PATH ?? "").split(path8.delimiter).filter(Boolean);
|
|
8310
|
-
const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
8311
|
-
const candidates = platform === "win32" ? extensions.map((extension) => `${name}${extension.toLowerCase()}`) : [name];
|
|
8312
|
-
for (const dir of dirs) {
|
|
8313
|
-
for (const candidate of candidates) {
|
|
8314
|
-
const full = path8.join(dir, candidate);
|
|
8315
|
-
try {
|
|
8316
|
-
fs5.accessSync(full, fs5.constants.X_OK);
|
|
8317
|
-
if (fs5.statSync(full).isFile()) return full;
|
|
8318
|
-
} catch {
|
|
8319
|
-
}
|
|
8320
|
-
}
|
|
8321
|
-
}
|
|
8322
|
-
return null;
|
|
8323
|
-
}
|
|
8324
8786
|
function writeDshToken(credentialsPath, accessToken) {
|
|
8325
|
-
const existing =
|
|
8787
|
+
const existing = fs6.existsSync(credentialsPath) ? fs6.readFileSync(credentialsPath, "utf8") : null;
|
|
8326
8788
|
let merged;
|
|
8327
8789
|
try {
|
|
8328
8790
|
merged = mergeDshCredentials(existing, accessToken);
|
|
@@ -8331,6 +8793,33 @@ function writeDshToken(credentialsPath, accessToken) {
|
|
|
8331
8793
|
}
|
|
8332
8794
|
writeTextAtomic(credentialsPath, merged, 384);
|
|
8333
8795
|
}
|
|
8796
|
+
function writeDivergeShim(binDir, cli, sessionTokenPath, platform = process.platform) {
|
|
8797
|
+
if (platform === "win32") {
|
|
8798
|
+
const file2 = path8.join(binDir, "diverge.cmd");
|
|
8799
|
+
const run3 = [cli.command, ...cli.args].map((part) => `"${part}"`).join(" ");
|
|
8800
|
+
writeTextAtomic(file2, `@setlocal\r
|
|
8801
|
+
@set "${SESSION_TOKEN_VARIABLE}=${sessionTokenPath}"\r
|
|
8802
|
+
@${run3} %*\r
|
|
8803
|
+
`, 493);
|
|
8804
|
+
return file2;
|
|
8805
|
+
}
|
|
8806
|
+
const quote = (part) => `'${part.replace(/'/g, `'\\''`)}'`;
|
|
8807
|
+
const file = path8.join(binDir, "diverge");
|
|
8808
|
+
writeTextAtomic(file, `#!/bin/sh
|
|
8809
|
+
${SESSION_TOKEN_VARIABLE}=${quote(sessionTokenPath)}
|
|
8810
|
+
export ${SESSION_TOKEN_VARIABLE}
|
|
8811
|
+
exec ${[cli.command, ...cli.args].map(quote).join(" ")} "$@"
|
|
8812
|
+
`, 493);
|
|
8813
|
+
return file;
|
|
8814
|
+
}
|
|
8815
|
+
function dshEnv(env, binDir) {
|
|
8816
|
+
const out = {};
|
|
8817
|
+
for (const [key, value] of Object.entries(env)) {
|
|
8818
|
+
if (value !== void 0 && key !== "DIVERGENT_TOKEN" && key !== "DIVERGENT_ORG_ID") out[key] = value;
|
|
8819
|
+
}
|
|
8820
|
+
out.PATH = env.PATH ? `${binDir}${path8.delimiter}${env.PATH}` : binDir;
|
|
8821
|
+
return out;
|
|
8822
|
+
}
|
|
8334
8823
|
function dshArgs(overlayPath, args) {
|
|
8335
8824
|
const rest = args.includes("--profile") ? args : args.length === 0 ? ["--profile", "web"] : ["--profile", "headless", ...args];
|
|
8336
8825
|
return ["--patch", overlayPath, ...rest];
|
|
@@ -8340,7 +8829,7 @@ function dshLaunch(binary, args, platform = process.platform, execPath = process
|
|
|
8340
8829
|
const packageDir = path8.join(path8.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
|
|
8341
8830
|
let bin;
|
|
8342
8831
|
try {
|
|
8343
|
-
bin = JSON.parse(
|
|
8832
|
+
bin = JSON.parse(fs6.readFileSync(path8.join(packageDir, "package.json"), "utf8")).bin;
|
|
8344
8833
|
} catch {
|
|
8345
8834
|
throw new CliError(`${binary} is not an npm shim for @deepseek-ai/dsh (no ${packageDir}); reinstall: npm install -g @deepseek-ai/dsh`);
|
|
8346
8835
|
}
|
|
@@ -8363,9 +8852,14 @@ async function keepTokenFresh(loop) {
|
|
|
8363
8852
|
}
|
|
8364
8853
|
}
|
|
8365
8854
|
function runDsh(options) {
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8855
|
+
const writeToken = (token) => {
|
|
8856
|
+
writeDshToken(options.credentialsPath, token);
|
|
8857
|
+
writeTextAtomic(options.sessionTokenPath, `${token}
|
|
8858
|
+
`, 384);
|
|
8859
|
+
};
|
|
8860
|
+
writeToken(options.initialToken);
|
|
8861
|
+
writeDivergeShim(options.binDir, options.cli, options.sessionTokenPath);
|
|
8862
|
+
const env = dshEnv(options.env, options.binDir);
|
|
8369
8863
|
const launch = dshLaunch(options.binary, dshArgs(options.overlayPath, options.args));
|
|
8370
8864
|
const child = spawn2(launch.command, launch.args, { env, stdio: "inherit" });
|
|
8371
8865
|
let exited = false;
|
|
@@ -8391,7 +8885,7 @@ function runDsh(options) {
|
|
|
8391
8885
|
process.on("SIGTERM", terminate);
|
|
8392
8886
|
const loop = keepTokenFresh({
|
|
8393
8887
|
freshToken: options.freshToken,
|
|
8394
|
-
write:
|
|
8888
|
+
write: writeToken,
|
|
8395
8889
|
isRunning: () => !exited,
|
|
8396
8890
|
sleep: (ms) => new Promise((resolve) => {
|
|
8397
8891
|
const timer = setTimeout(() => {
|
|
@@ -8412,6 +8906,26 @@ function runDsh(options) {
|
|
|
8412
8906
|
});
|
|
8413
8907
|
}
|
|
8414
8908
|
|
|
8909
|
+
// src/fs/path.ts
|
|
8910
|
+
import fs7 from "node:fs";
|
|
8911
|
+
import path9 from "node:path";
|
|
8912
|
+
function findOnPath(name, env = process.env, platform = process.platform) {
|
|
8913
|
+
const dirs = (env.PATH ?? "").split(path9.delimiter).filter(Boolean);
|
|
8914
|
+
const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
8915
|
+
const candidates = platform === "win32" ? extensions.map((extension) => `${name}${extension.toLowerCase()}`) : [name];
|
|
8916
|
+
for (const dir of dirs) {
|
|
8917
|
+
for (const candidate of candidates) {
|
|
8918
|
+
const full = path9.join(dir, candidate);
|
|
8919
|
+
try {
|
|
8920
|
+
fs7.accessSync(full, fs7.constants.X_OK);
|
|
8921
|
+
if (fs7.statSync(full).isFile()) return full;
|
|
8922
|
+
} catch {
|
|
8923
|
+
}
|
|
8924
|
+
}
|
|
8925
|
+
}
|
|
8926
|
+
return null;
|
|
8927
|
+
}
|
|
8928
|
+
|
|
8415
8929
|
// src/commands/skills.ts
|
|
8416
8930
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
8417
8931
|
|
|
@@ -8443,36 +8957,66 @@ The other skills installed beside this one are the organization's own
|
|
|
8443
8957
|
procedures; each names the tools it is about. Prefer a procedure over
|
|
8444
8958
|
guessing a tool.
|
|
8445
8959
|
|
|
8446
|
-
## Arguments:
|
|
8960
|
+
## Arguments: pipe them through stdin
|
|
8447
8961
|
|
|
8448
8962
|
Shells mangle JSON. Windows PowerShell strips the double quotes inside an
|
|
8449
8963
|
inline argument, so \`--args-json '{"a":"b"}'\` can arrive as \`{a:b}\`.
|
|
8450
|
-
|
|
8451
|
-
|
|
8964
|
+
Pipe the object to \`--args-json -\` from a heredoc (a here-string on
|
|
8965
|
+
PowerShell): exact on every shell, and no file to keep. A worked call:
|
|
8452
8966
|
|
|
8453
8967
|
\`\`\`bash
|
|
8454
|
-
diverge tools describe
|
|
8455
|
-
|
|
8456
|
-
{"query": "
|
|
8968
|
+
diverge tools describe forge_query_issues
|
|
8969
|
+
diverge tools call forge_query_issues --args-json - --json <<'JSON'
|
|
8970
|
+
{"query": "sync failed", "limit": 20}
|
|
8457
8971
|
JSON
|
|
8458
|
-
diverge tools call divix-data-sync_implementation_search_source --args-file /tmp/args.json
|
|
8459
8972
|
\`\`\`
|
|
8460
8973
|
|
|
8974
|
+
\`--args-file <path>\` reads a file you already have. Keep anything a later
|
|
8975
|
+
command needs under the working directory: a sandboxed harness runs each
|
|
8976
|
+
command in a fresh sandbox, and its \`/tmp\` is gone when the command ends.
|
|
8977
|
+
|
|
8461
8978
|
## Read the outcome from stdout with --json
|
|
8462
8979
|
|
|
8463
8980
|
\`call --json\` prints exactly one JSON object on stdout whatever happens,
|
|
8464
8981
|
errors included: \`{"tool", "status", "result"?, "error"?, "invocationId"?,
|
|
8465
8982
|
"decideAt"?}\`, where status is executed, pending, rejected, expired or failed.
|
|
8466
|
-
|
|
8467
|
-
|
|
8983
|
+
\`result\` is the tool's payload exactly as the tool returned it: the CLI
|
|
8984
|
+
unwraps the platform's envelope and nothing inside. Its shape is the tool's
|
|
8985
|
+
own and differs by tool and plugin \u2014 one returns its records under \`data\`,
|
|
8986
|
+
another at the top level \u2014 so read a tool's shape from its own answer, not
|
|
8987
|
+
from the last tool's. Parse stdout alone; stderr only carries the scope and
|
|
8988
|
+
identity lines. Without \`--json\`, errors are text on stderr.
|
|
8989
|
+
|
|
8990
|
+
## Several related writes: one set, one decision
|
|
8991
|
+
|
|
8992
|
+
When two or more writes serve one intent \u2014 assign a role to several groups,
|
|
8993
|
+
deactivate several users, set several notification routes \u2014 raise them as
|
|
8994
|
+
one set, never one call per write: the person approves the set once instead
|
|
8995
|
+
of clicking through one card each.
|
|
8996
|
+
|
|
8997
|
+
\`\`\`bash
|
|
8998
|
+
diverge tools set - --summary "Coordinators get the field role" --json <<'JSON'
|
|
8999
|
+
[{"tool": "rbac_assign_role_to_group", "args": {"roleId": "r1", "groupId": "g1"}},
|
|
9000
|
+
{"tool": "rbac_assign_role_to_group", "args": {"roleId": "r1", "groupId": "g2"}}]
|
|
9001
|
+
JSON
|
|
9002
|
+
\`\`\`
|
|
9003
|
+
|
|
9004
|
+
The set answers like one call (exit 3 while it waits, one invocation id).
|
|
9005
|
+
Once approved its calls run in order and stop at the first failure; read
|
|
9006
|
+
every call's outcome \u2014 succeeded, failed, or not_run \u2014 from \`result.calls\`
|
|
9007
|
+
with \`diverge tools invocation <id>\`. Arguments are frozen when you raise
|
|
9008
|
+
the set, so a call cannot use an id an earlier call creates: raise that one
|
|
9009
|
+
after the first ran. A set carries writes only; reads, and prepared writes
|
|
9010
|
+
that propose a Forge Change, are called on their own.
|
|
8468
9011
|
|
|
8469
|
-
## Several calls at once
|
|
9012
|
+
## Several independent calls at once
|
|
8470
9013
|
|
|
8471
|
-
When a task needs a sequence of calls,
|
|
8472
|
-
once instead of one round trip each
|
|
8473
|
-
array of \`{"tool": "...", "args": {...}}
|
|
8474
|
-
order; each prints one JSON line of outcome, the same shape as
|
|
8475
|
-
the exit code is the worst of them.
|
|
9014
|
+
When a task needs a sequence of reads or unrelated calls, pipe them to
|
|
9015
|
+
\`diverge tools run -\` once instead of one round trip each (or name a file):
|
|
9016
|
+
a JSON array of \`{"tool": "...", "args": {...}}\`, or one per line. Calls run
|
|
9017
|
+
in order; each prints one JSON line of outcome, the same shape as
|
|
9018
|
+
\`call --json\`; the exit code is the worst of them. Each write in a run is
|
|
9019
|
+
its own decision, so related writes belong in a set.
|
|
8476
9020
|
|
|
8477
9021
|
## Exit codes are the contract
|
|
8478
9022
|
|
|
@@ -8500,26 +9044,91 @@ cadence). Never decide your own invocation from any surface you can drive.
|
|
|
8500
9044
|
- \`--json\` on \`list\`, \`describe\` and \`invocation\` gives raw records.
|
|
8501
9045
|
`
|
|
8502
9046
|
};
|
|
9047
|
+
var DRIVE_CHROME_DESCRIPTION = "Control the Chrome the person runs in debug mode (remote debugging on port 9222) through the mcp__chrome-devtools__ tools - list and pick tabs, open and navigate pages, read a page, click, fill forms, run JavaScript, read console and network, take screenshots and performance traces. Use when a task needs to look at or act in a web page, debug a UI, or reproduce a browser problem.";
|
|
9048
|
+
var DRIVE_CHROME_SKILL = {
|
|
9049
|
+
name: "drive-chrome",
|
|
9050
|
+
description: DRIVE_CHROME_DESCRIPTION,
|
|
9051
|
+
tools: [],
|
|
9052
|
+
updatedAt: `diverge/${VERSION}`,
|
|
9053
|
+
content: [
|
|
9054
|
+
"---",
|
|
9055
|
+
"name: drive-chrome",
|
|
9056
|
+
`description: ${DRIVE_CHROME_DESCRIPTION}`,
|
|
9057
|
+
"---",
|
|
9058
|
+
"",
|
|
9059
|
+
"# drive-chrome: the person's Chrome",
|
|
9060
|
+
"",
|
|
9061
|
+
"The `mcp__chrome-devtools__*` tools act in a Chrome the person started with",
|
|
9062
|
+
"remote debugging: their own tabs, signed in as them.",
|
|
9063
|
+
"",
|
|
9064
|
+
"## Find the page",
|
|
9065
|
+
"",
|
|
9066
|
+
"1. `list_pages` names every tab with a page id; the selected one is marked.",
|
|
9067
|
+
"2. `select_page` with that id makes it the page every other tool acts on.",
|
|
9068
|
+
"3. To load something new, `new_page` with the url. Do not `navigate_page` a tab",
|
|
9069
|
+
" the person already had open: that replaces what they were looking at.",
|
|
9070
|
+
"",
|
|
9071
|
+
"## Read before acting",
|
|
9072
|
+
"",
|
|
9073
|
+
"- `take_snapshot` returns the page as text, each element with a `uid`; prefer",
|
|
9074
|
+
" it to a screenshot. `click`, `fill`, `hover` and `fill_form` take those uids.",
|
|
9075
|
+
"- A uid is valid for the snapshot it came from: after an action changes the",
|
|
9076
|
+
" page, take a fresh snapshot before the next one.",
|
|
9077
|
+
"- `evaluate_script` runs a function in the page, for what a snapshot does not",
|
|
9078
|
+
" show: `() => document.title`.",
|
|
9079
|
+
"- `list_console_messages` and `list_network_requests` read what the page logged",
|
|
9080
|
+
" and fetched; `get_network_request` reads one body.",
|
|
9081
|
+
"- `take_screenshot` when the layout itself is the question.",
|
|
9082
|
+
"",
|
|
9083
|
+
"## The person's sessions",
|
|
9084
|
+
"",
|
|
9085
|
+
"Reading is free. Before a click or a script that submits, sends, buys,",
|
|
9086
|
+
"deletes, approves or changes a setting, say what it will do and wait for the",
|
|
9087
|
+
"person. Close the pages you opened with `close_page`; leave theirs.",
|
|
9088
|
+
"",
|
|
9089
|
+
"## When there is no Chrome",
|
|
9090
|
+
"",
|
|
9091
|
+
'"Could not connect to Chrome" means nothing listens on port 9222. Ask the',
|
|
9092
|
+
"person to start Chrome in debug mode. Chrome refuses remote debugging on its",
|
|
9093
|
+
"default profile, so it runs a profile of its own (signed in once, kept after):",
|
|
9094
|
+
"",
|
|
9095
|
+
"```bash",
|
|
9096
|
+
'google-chrome --user-data-dir="$HOME/.config/google-chrome-debug" --remote-debugging-port=9222 # Linux',
|
|
9097
|
+
'open -na "Google Chrome" --args --user-data-dir="$HOME/.chrome-debug" --remote-debugging-port=9222 # macOS',
|
|
9098
|
+
"```",
|
|
9099
|
+
"",
|
|
9100
|
+
"On Windows: `chrome.exe --user-data-dir=%LOCALAPPDATA%\\chrome-debug --remote-debugging-port=9222`.",
|
|
9101
|
+
"`curl -s http://127.0.0.1:9222/json/version` answers once it is up. The next",
|
|
9102
|
+
"tool call connects; there is nothing to restart.",
|
|
9103
|
+
"",
|
|
9104
|
+
"If no `mcp__chrome-devtools__` tool is listed at all, dsh was started without",
|
|
9105
|
+
"the Divergent overlay: `diverge agents run dsh` starts it with one.",
|
|
9106
|
+
""
|
|
9107
|
+
].join("\n")
|
|
9108
|
+
};
|
|
9109
|
+
function bundledSkills(harness) {
|
|
9110
|
+
return harness === "dsh" ? [DIVERGE_SKILL, DRIVE_CHROME_SKILL] : [DIVERGE_SKILL];
|
|
9111
|
+
}
|
|
8503
9112
|
|
|
8504
9113
|
// src/skills/install.ts
|
|
8505
|
-
import
|
|
9114
|
+
import fs8 from "node:fs";
|
|
8506
9115
|
import os6 from "node:os";
|
|
8507
|
-
import
|
|
9116
|
+
import path10 from "node:path";
|
|
8508
9117
|
var HARNESSES = ["claude", "codex", "dsh"];
|
|
8509
9118
|
var SKILLS_MANIFEST = ".diverge-skills.json";
|
|
8510
9119
|
function skillsRoot(harness, env = process.env) {
|
|
8511
9120
|
switch (harness) {
|
|
8512
9121
|
case "claude":
|
|
8513
|
-
return
|
|
9122
|
+
return path10.join(env.CLAUDE_CONFIG_DIR?.trim() || path10.join(os6.homedir(), ".claude"), "skills");
|
|
8514
9123
|
case "codex":
|
|
8515
|
-
return
|
|
9124
|
+
return path10.join(env.CODEX_HOME?.trim() || path10.join(os6.homedir(), ".codex"), "skills");
|
|
8516
9125
|
case "dsh":
|
|
8517
|
-
return
|
|
9126
|
+
return path10.join(dshHome(env), "skills");
|
|
8518
9127
|
}
|
|
8519
9128
|
}
|
|
8520
9129
|
function readSkillsManifest(root) {
|
|
8521
9130
|
try {
|
|
8522
|
-
const parsed = JSON.parse(
|
|
9131
|
+
const parsed = JSON.parse(fs8.readFileSync(path10.join(root, SKILLS_MANIFEST), "utf8"));
|
|
8523
9132
|
if (parsed && typeof parsed === "object" && typeof parsed.skills === "object") return parsed;
|
|
8524
9133
|
} catch {
|
|
8525
9134
|
}
|
|
@@ -8536,7 +9145,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8536
9145
|
const updated = [];
|
|
8537
9146
|
for (const skill of skills) {
|
|
8538
9147
|
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(skill.name)) throw new Error(`skill name ${JSON.stringify(skill.name)} is not a folder name`);
|
|
8539
|
-
writeTextAtomic(
|
|
9148
|
+
writeTextAtomic(path10.join(root, skill.name, "SKILL.md"), skill.content, 420);
|
|
8540
9149
|
written.push(skill.name);
|
|
8541
9150
|
if (!(skill.name in held)) added.push(skill.name);
|
|
8542
9151
|
else if (held[skill.name] !== skill.updatedAt) updated.push(skill.name);
|
|
@@ -8544,7 +9153,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8544
9153
|
const removed = [];
|
|
8545
9154
|
for (const name of Object.keys(previous?.skills ?? {})) {
|
|
8546
9155
|
if (skills.some((skill) => skill.name === name)) continue;
|
|
8547
|
-
|
|
9156
|
+
fs8.rmSync(path10.join(root, name), { recursive: true, force: true });
|
|
8548
9157
|
removed.push(name);
|
|
8549
9158
|
}
|
|
8550
9159
|
const manifest = {
|
|
@@ -8552,7 +9161,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8552
9161
|
source,
|
|
8553
9162
|
skills: Object.fromEntries(skills.map((skill) => [skill.name, skill.updatedAt]))
|
|
8554
9163
|
};
|
|
8555
|
-
writeJsonAtomic(
|
|
9164
|
+
writeJsonAtomic(path10.join(root, SKILLS_MANIFEST), manifest, 420);
|
|
8556
9165
|
return { root, written, added, updated, removed };
|
|
8557
9166
|
}
|
|
8558
9167
|
function skillsStatus(root, skills) {
|
|
@@ -8562,7 +9171,7 @@ function skillsStatus(root, skills) {
|
|
|
8562
9171
|
const behind = [];
|
|
8563
9172
|
const missing = [];
|
|
8564
9173
|
for (const skill of skills) {
|
|
8565
|
-
if (!(skill.name in held) || !
|
|
9174
|
+
if (!(skill.name in held) || !fs8.existsSync(path10.join(root, skill.name, "SKILL.md"))) missing.push(skill.name);
|
|
8566
9175
|
else if (held[skill.name] !== skill.updatedAt) behind.push(skill.name);
|
|
8567
9176
|
else current.push(skill.name);
|
|
8568
9177
|
}
|
|
@@ -8584,7 +9193,7 @@ async function fetchInstallableSkills(baseUrl, accessToken) {
|
|
|
8584
9193
|
var skillsUsage = `diverge skills <list|install|status> [--harness claude,codex,dsh] [--into <dir>]
|
|
8585
9194
|
|
|
8586
9195
|
list the skills the platform serves you: your organization's skills whose tools you can run
|
|
8587
|
-
install write them, and the CLI's own "diverge"
|
|
9196
|
+
install write them, and the CLI's own skills ("diverge"; "drive-chrome" for dsh), into each harness's user skill folder
|
|
8588
9197
|
(~/.claude/skills, ~/.codex/skills, $DSH_HOME/skills); retires the ones the organization retired;
|
|
8589
9198
|
reports what changed \u2014 the full list is \`skills list\`
|
|
8590
9199
|
status what each folder holds against what the platform serves now
|
|
@@ -8596,7 +9205,7 @@ async function installableSkillSet(apiUrl, env) {
|
|
|
8596
9205
|
const organizationId = tokenClaims(token.access_token).organizationId;
|
|
8597
9206
|
if (!organizationId) throw new CliError("The login has no default organization; run: diverge org use <id|name>");
|
|
8598
9207
|
const served = await fetchInstallableSkills(apiUrl, token.access_token);
|
|
8599
|
-
return { skills:
|
|
9208
|
+
return { skills: served.skills, organizationId };
|
|
8600
9209
|
}
|
|
8601
9210
|
function harnessesOf(flag) {
|
|
8602
9211
|
if (!flag) return [...HARNESSES];
|
|
@@ -8606,7 +9215,7 @@ function harnessesOf(flag) {
|
|
|
8606
9215
|
}
|
|
8607
9216
|
function installForHarness(io, harness, skills, apiUrl, into) {
|
|
8608
9217
|
const root = into ?? skillsRoot(harness, io.env);
|
|
8609
|
-
const result = installSkills(root, skills, apiUrl);
|
|
9218
|
+
const result = installSkills(root, [...bundledSkills(harness), ...skills], apiUrl);
|
|
8610
9219
|
const changes = [
|
|
8611
9220
|
...result.added.length ? [`${result.added.length} new: ${few(result.added)}`] : [],
|
|
8612
9221
|
...result.updated.length ? [`${result.updated.length} updated: ${few(result.updated)}`] : [],
|
|
@@ -8621,8 +9230,8 @@ async function runSkills(args, io) {
|
|
|
8621
9230
|
switch (verb) {
|
|
8622
9231
|
case "list": {
|
|
8623
9232
|
const { skills, organizationId } = await installableSkillSet(apiUrl, io.env);
|
|
8624
|
-
io.stdout(`Skills the platform serves you at organization ${organizationId}:`);
|
|
8625
|
-
for (const skill of skills) io.stdout(` ${skill.name.padEnd(36)} ${skill.tools.length ? skill.tools.join(", ") : "(the CLI
|
|
9233
|
+
io.stdout(`Skills the platform serves you at organization ${organizationId}, after the CLI's own:`);
|
|
9234
|
+
for (const skill of [...bundledSkills("dsh"), ...skills]) io.stdout(` ${skill.name.padEnd(36)} ${skill.tools.length ? skill.tools.join(", ") : "(ships with the CLI)"}`);
|
|
8626
9235
|
return ExitCode.Ok;
|
|
8627
9236
|
}
|
|
8628
9237
|
case "install": {
|
|
@@ -8635,7 +9244,7 @@ async function runSkills(args, io) {
|
|
|
8635
9244
|
const { skills } = await installableSkillSet(apiUrl, io.env);
|
|
8636
9245
|
let behind = false;
|
|
8637
9246
|
for (const harness of harnessesOf(values.harness)) {
|
|
8638
|
-
const status2 = skillsStatus(values.into ?? skillsRoot(harness, io.env), skills);
|
|
9247
|
+
const status2 = skillsStatus(values.into ?? skillsRoot(harness, io.env), [...bundledSkills(harness), ...skills]);
|
|
8639
9248
|
const parts = [`${status2.current.length} current`];
|
|
8640
9249
|
if (status2.behind.length) parts.push(`${status2.behind.length} behind (${few(status2.behind)})`);
|
|
8641
9250
|
if (status2.missing.length) parts.push(`${status2.missing.length} missing${status2.current.length || status2.behind.length ? ` (${few(status2.missing)})` : ""}`);
|
|
@@ -8647,17 +9256,15 @@ async function runSkills(args, io) {
|
|
|
8647
9256
|
return ExitCode.Ok;
|
|
8648
9257
|
}
|
|
8649
9258
|
default:
|
|
8650
|
-
throw
|
|
8651
|
-
|
|
8652
|
-
${skillsUsage}`);
|
|
9259
|
+
throw unknownVerb("skills", skillsUsage, [], verb, rest);
|
|
8653
9260
|
}
|
|
8654
9261
|
}
|
|
8655
9262
|
|
|
8656
9263
|
// src/agents/rotate.ts
|
|
8657
9264
|
import os7 from "node:os";
|
|
8658
|
-
import
|
|
9265
|
+
import path11 from "node:path";
|
|
8659
9266
|
function defaultTokenFilePath() {
|
|
8660
|
-
return
|
|
9267
|
+
return path11.join(os7.homedir(), ".divergent", "token");
|
|
8661
9268
|
}
|
|
8662
9269
|
var MIN_ROTATE_INTERVAL_SECONDS = 60;
|
|
8663
9270
|
async function rotateTokenFile(loop) {
|
|
@@ -8672,19 +9279,19 @@ async function rotateTokenFile(loop) {
|
|
|
8672
9279
|
}
|
|
8673
9280
|
|
|
8674
9281
|
// src/agents/self-command.ts
|
|
8675
|
-
import
|
|
8676
|
-
import
|
|
9282
|
+
import fs9 from "node:fs";
|
|
9283
|
+
import path12 from "node:path";
|
|
8677
9284
|
function resolveSelfCommand(argv = process.argv, platform = process.platform, execPath = process.execPath) {
|
|
8678
9285
|
const script = argv[1];
|
|
8679
9286
|
if (!script) return { command: execPath, args: [] };
|
|
8680
9287
|
if (platform !== "win32") {
|
|
8681
9288
|
try {
|
|
8682
|
-
|
|
8683
|
-
return { command:
|
|
9289
|
+
fs9.accessSync(script, fs9.constants.X_OK);
|
|
9290
|
+
return { command: path12.resolve(script), args: [] };
|
|
8684
9291
|
} catch {
|
|
8685
9292
|
}
|
|
8686
9293
|
}
|
|
8687
|
-
return { command: execPath, args: [
|
|
9294
|
+
return { command: execPath, args: [fs9.realpathSync(script)] };
|
|
8688
9295
|
}
|
|
8689
9296
|
function shellCommand(self, ...trailing) {
|
|
8690
9297
|
return [self.command, ...self.args, ...trailing].map((part) => /[\s"]/.test(part) ? `"${part.replace(/"/g, '\\"')}"` : part).join(" ");
|
|
@@ -8711,11 +9318,11 @@ function surfaceOf(value, fallback) {
|
|
|
8711
9318
|
throw new CliError(`--surface must be one of: ${SURFACES.join(", ")}`);
|
|
8712
9319
|
}
|
|
8713
9320
|
function readJson(file) {
|
|
8714
|
-
if (!
|
|
8715
|
-
return JSON.parse(
|
|
9321
|
+
if (!fs10.existsSync(file)) return null;
|
|
9322
|
+
return JSON.parse(fs10.readFileSync(file, "utf8"));
|
|
8716
9323
|
}
|
|
8717
9324
|
async function servedModels(apiUrl, token, surface) {
|
|
8718
|
-
return (await listModels(apiUrl, token.access_token, surface)).map(
|
|
9325
|
+
return (await listModels(apiUrl, token.access_token, surface)).map(servedModel);
|
|
8719
9326
|
}
|
|
8720
9327
|
function syncDivergentPreset(io, binary, home) {
|
|
8721
9328
|
if (!binary) {
|
|
@@ -8729,8 +9336,8 @@ function syncDivergentPreset(io, binary, home) {
|
|
|
8729
9336
|
return;
|
|
8730
9337
|
}
|
|
8731
9338
|
const dir = writeDivergentPreset(home, shipped);
|
|
8732
|
-
const settingsPath =
|
|
8733
|
-
const settings = withDivergentPresetDefault(
|
|
9339
|
+
const settingsPath = path13.join(home, "settings.yaml");
|
|
9340
|
+
const settings = withDivergentPresetDefault(fs10.existsSync(settingsPath) ? fs10.readFileSync(settingsPath, "utf8") : null);
|
|
8734
9341
|
if (settings !== null) writeTextAtomic(settingsPath, settings);
|
|
8735
9342
|
io.stderr(`Agent preset "${DIVERGENT_PRESET_ID}" (${dir}): web sessions search through the platform${settings !== null ? "; set as the default preset in settings.yaml" : ""}.`);
|
|
8736
9343
|
}
|
|
@@ -8743,11 +9350,12 @@ async function skillsFor(io, apiUrl, harness) {
|
|
|
8743
9350
|
}
|
|
8744
9351
|
}
|
|
8745
9352
|
async function overlayAndDefault(apiUrl, token, surface, io, requested) {
|
|
8746
|
-
const
|
|
9353
|
+
const served = await servedModels(apiUrl, token, surface);
|
|
9354
|
+
const models = served.map((model) => model.id);
|
|
8747
9355
|
if (models.length === 0) throw new CliError(`the gateway serves no models on the ${surface} surface for this organization`);
|
|
8748
9356
|
if (requested && !models.includes(requested)) throw new CliError(`${requested} is not served on the ${surface} surface; choose one of: ${models.join(", ")}`);
|
|
8749
9357
|
const defaultModel = dshDefaultModel(models, requested);
|
|
8750
|
-
return { overlay: dshPatchYaml({ baseUrl: surfaceBaseUrl(apiUrl, surface), surface, models, defaultModel }), defaultModel, models };
|
|
9358
|
+
return { overlay: dshPatchYaml({ baseUrl: surfaceBaseUrl(apiUrl, surface), surface, models: served, defaultModel }), defaultModel, models };
|
|
8751
9359
|
}
|
|
8752
9360
|
function organizationArgs(organizationId) {
|
|
8753
9361
|
const trimmed = organizationId?.trim();
|
|
@@ -8801,7 +9409,7 @@ async function setup(args, io) {
|
|
|
8801
9409
|
}
|
|
8802
9410
|
const token = await ensureInferenceLogin(io, apiUrl, values["organization-id"]);
|
|
8803
9411
|
const file = values.config ?? codexConfigPath();
|
|
8804
|
-
const existing =
|
|
9412
|
+
const existing = fs10.existsSync(file) ? fs10.readFileSync(file, "utf8") : null;
|
|
8805
9413
|
writeTextAtomic(file, mergeCodexConfig(existing, block));
|
|
8806
9414
|
io.stdout(`Codex provider divergent \u2192 ${openaiBaseUrl(apiUrl)} as you, organization ${tokenClaims(token.access_token).organizationId}. Wrote ${file}.`);
|
|
8807
9415
|
io.stdout('Select it per run with: codex -c model_provider=divergent (or set model_provider = "divergent" in the config)');
|
|
@@ -8818,7 +9426,7 @@ async function setup(args, io) {
|
|
|
8818
9426
|
io.stdout(overlay.trimEnd());
|
|
8819
9427
|
return ExitCode.Ok;
|
|
8820
9428
|
}
|
|
8821
|
-
const file = values.into ??
|
|
9429
|
+
const file = values.into ?? path13.join(dshHome(io.env), `divergent-${surface}.yml`);
|
|
8822
9430
|
writeTextAtomic(file, overlay);
|
|
8823
9431
|
io.stdout(`dsh route divergent-${surface} \u2192 ${surfaceBaseUrl(apiUrl, surface)} as you, organization ${tokenClaims(token.access_token).organizationId}, default model ${defaultModel}. Wrote ${file}.`);
|
|
8824
9432
|
io.stdout("Platform tools, web search included, are reached from dsh's shell through `diverge tools`; the installed skills say when and how. dsh's DeepSeek search is off.");
|
|
@@ -8829,16 +9437,12 @@ async function setup(args, io) {
|
|
|
8829
9437
|
return ExitCode.Ok;
|
|
8830
9438
|
}
|
|
8831
9439
|
default:
|
|
8832
|
-
throw
|
|
8833
|
-
|
|
8834
|
-
${agentsUsage}`);
|
|
9440
|
+
throw unknownVerb("agents", agentsUsage, ["setup"], agent, rest);
|
|
8835
9441
|
}
|
|
8836
9442
|
}
|
|
8837
9443
|
async function run(args, io) {
|
|
8838
9444
|
const [agent, ...rest] = args;
|
|
8839
|
-
if (agent !== "dsh") throw
|
|
8840
|
-
|
|
8841
|
-
${agentsUsage}`);
|
|
9445
|
+
if (agent !== "dsh") throw unknownVerb("agents", agentsUsage, ["run"], agent, rest);
|
|
8842
9446
|
const terminator = rest.indexOf("--");
|
|
8843
9447
|
const flags = terminator === -1 ? rest : rest.slice(0, terminator);
|
|
8844
9448
|
const passthrough = terminator === -1 ? [] : rest.slice(terminator + 1);
|
|
@@ -8851,16 +9455,16 @@ ${agentsUsage}`);
|
|
|
8851
9455
|
await skillsFor(io, apiUrl, "dsh");
|
|
8852
9456
|
const { overlay, defaultModel } = await overlayAndDefault(apiUrl, token, surface, io, values.model);
|
|
8853
9457
|
const home = dshHome(io.env);
|
|
8854
|
-
const settingsPath =
|
|
9458
|
+
const settingsPath = path13.join(home, "settings.yaml");
|
|
8855
9459
|
let pinned;
|
|
8856
9460
|
try {
|
|
8857
|
-
pinned = dshSettingsDefaultModel(
|
|
9461
|
+
pinned = dshSettingsDefaultModel(fs10.existsSync(settingsPath) ? fs10.readFileSync(settingsPath, "utf8") : null, surface);
|
|
8858
9462
|
} catch (error) {
|
|
8859
9463
|
throw new CliError(`${settingsPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8860
9464
|
}
|
|
8861
9465
|
const served = servedIds(overlay);
|
|
8862
9466
|
if (pinned && !served.includes(pinned)) throw new CliError(stalePinMessage(settingsPath, pinned, surface, served));
|
|
8863
|
-
const overlayPath =
|
|
9467
|
+
const overlayPath = path13.join(home, `divergent-${surface}.yml`);
|
|
8864
9468
|
writeTextAtomic(overlayPath, overlay);
|
|
8865
9469
|
syncDivergentPreset(io, binary, home);
|
|
8866
9470
|
io.stderr(`dsh on divergent-${surface} as you (organization ${tokenClaims(token.access_token).organizationId}), default model ${defaultModel}`);
|
|
@@ -8869,7 +9473,10 @@ ${agentsUsage}`);
|
|
|
8869
9473
|
return runDsh({
|
|
8870
9474
|
binary,
|
|
8871
9475
|
overlayPath,
|
|
8872
|
-
credentialsPath:
|
|
9476
|
+
credentialsPath: path13.join(home, ".credentials.yaml"),
|
|
9477
|
+
sessionTokenPath: path13.join(home, "session-token"),
|
|
9478
|
+
binDir: path13.join(home, "bin"),
|
|
9479
|
+
cli: { command: process.execPath, args: [path13.resolve(process.argv[1])] },
|
|
8873
9480
|
args: passthrough,
|
|
8874
9481
|
env: io.env,
|
|
8875
9482
|
initialToken: token.access_token,
|
|
@@ -8892,7 +9499,7 @@ async function status(args, io) {
|
|
|
8892
9499
|
io.stdout(`Organization: ${claims.organizationId}`);
|
|
8893
9500
|
io.stdout(`Scopes: ${(claims.scopes ?? []).join(" ")}`);
|
|
8894
9501
|
for (const surface of SURFACES) {
|
|
8895
|
-
const models = await servedModels(apiUrl, token, surface);
|
|
9502
|
+
const models = (await servedModels(apiUrl, token, surface)).map((model) => model.id);
|
|
8896
9503
|
io.stdout(`Models (${surface}): ${models.length ? models.join(", ") : "(none served on this surface)"}`);
|
|
8897
9504
|
}
|
|
8898
9505
|
return ExitCode.Ok;
|
|
@@ -8915,18 +9522,8 @@ async function rotate(args, io) {
|
|
|
8915
9522
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
8916
9523
|
});
|
|
8917
9524
|
}
|
|
8918
|
-
function agentsVerbUsage(verb) {
|
|
8919
|
-
const lines = agentsUsage.split("\n").filter((line) => line.trimStart().startsWith(`${verb} `) || line.trimStart().startsWith(`${verb} `));
|
|
8920
|
-
return lines.length ? `diverge agents ${verb} ...
|
|
8921
|
-
|
|
8922
|
-
${lines.join("\n")}` : agentsUsage;
|
|
8923
|
-
}
|
|
8924
9525
|
async function runAgents(args, io) {
|
|
8925
9526
|
const [verb, ...rest] = args;
|
|
8926
|
-
if (verb && (rest.includes("--help") || rest.includes("-h")) && !rest.includes("--")) {
|
|
8927
|
-
io.stdout(agentsVerbUsage(verb));
|
|
8928
|
-
return ExitCode.Ok;
|
|
8929
|
-
}
|
|
8930
9527
|
switch (verb) {
|
|
8931
9528
|
case "setup":
|
|
8932
9529
|
return setup(rest, io);
|
|
@@ -8937,9 +9534,7 @@ async function runAgents(args, io) {
|
|
|
8937
9534
|
case "status":
|
|
8938
9535
|
return status(rest, io);
|
|
8939
9536
|
default:
|
|
8940
|
-
throw
|
|
8941
|
-
|
|
8942
|
-
${agentsUsage}`);
|
|
9537
|
+
throw unknownVerb("agents", agentsUsage, [], verb, rest);
|
|
8943
9538
|
}
|
|
8944
9539
|
}
|
|
8945
9540
|
|
|
@@ -8947,20 +9542,23 @@ ${agentsUsage}`);
|
|
|
8947
9542
|
import { parseArgs as parseArgs4 } from "node:util";
|
|
8948
9543
|
var orgUsage = `diverge org [use <id|name>]
|
|
8949
9544
|
|
|
8950
|
-
|
|
8951
|
-
use <id|name
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
organization
|
|
9545
|
+
(no verb) list the organizations you may act in, the default marked
|
|
9546
|
+
use <id|name> make it the default: where every command that names no organization acts,
|
|
9547
|
+
in every shell on this machine that shares the login
|
|
9548
|
+
|
|
9549
|
+
The default is a local preference: the platform is asked only for a token
|
|
9550
|
+
there, which proves you may act in it. For one command, pass
|
|
9551
|
+
--organization-id <id> (or set DIVERGENT_ORG_ID) instead. A platform actor may
|
|
9552
|
+
act in, and so sees, every organization.`;
|
|
8957
9553
|
async function runOrg(args, io) {
|
|
9554
|
+
refuseInSession(io.env, "org");
|
|
8958
9555
|
const { positionals } = parseArgs4({ args, options: {}, strict: true, allowPositionals: true });
|
|
9556
|
+
const verb = positionals[0];
|
|
9557
|
+
if (verb && verb !== "use") throw unknownVerb("org", orgUsage, [], verb, positionals.slice(1));
|
|
8959
9558
|
const source = tokenSource(io.env, resolveApiUrl(void 0, io.env));
|
|
8960
9559
|
const info = await fetchUserInfo(source.baseUrl, (await getUserToken(source)).access_token);
|
|
8961
9560
|
const organizations = info.organizations ?? [];
|
|
8962
9561
|
const current = requireLogin(source).organization;
|
|
8963
|
-
const verb = positionals[0];
|
|
8964
9562
|
if (!verb) {
|
|
8965
9563
|
if (organizations.length === 0) {
|
|
8966
9564
|
io.stdout("You are not a member of any organization.");
|
|
@@ -8969,105 +9567,55 @@ async function runOrg(args, io) {
|
|
|
8969
9567
|
for (const organization of organizations) io.stdout(`${organization.id === current ? "*" : " "} ${organization.name} (${organization.id})`);
|
|
8970
9568
|
return 0;
|
|
8971
9569
|
}
|
|
8972
|
-
if (verb !== "use") throw new CliError(`Unknown verb: ${verb}
|
|
8973
|
-
|
|
8974
|
-
${orgUsage}`);
|
|
8975
9570
|
const target = positionals[1];
|
|
8976
9571
|
if (!target) throw new CliError("org use needs an organization id or name");
|
|
8977
9572
|
const choice = chooseOrganization({ flag: target, organizations });
|
|
8978
9573
|
if (choice.kind !== "chosen") throw new CliError("org use needs an organization id or name");
|
|
8979
9574
|
const token = await useOrganization(source, choice.organizationId);
|
|
8980
9575
|
io.stdout(`Default organization: ${choice.name ? `${choice.name} (${choice.organizationId})` : choice.organizationId}; scopes ${(tokenClaims(token.access_token).scopes ?? []).join(" ") || "none"}`);
|
|
8981
|
-
return 0;
|
|
8982
|
-
}
|
|
8983
|
-
|
|
8984
|
-
// src/commands/logout.ts
|
|
8985
|
-
var logoutUsage = "diverge logout\n\nRevoke this deployment's login on the platform and forget it locally, with every token issued from it. Logins to other deployments are kept.";
|
|
8986
|
-
async function runLogout(_args, io) {
|
|
8987
|
-
|
|
8988
|
-
const
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
if (token.refresh_token) {
|
|
8994
|
-
try {
|
|
8995
|
-
await revokeRefreshToken(source.baseUrl, source.clientId, token.refresh_token);
|
|
8996
|
-
} catch (error) {
|
|
8997
|
-
io.stderr(`warning: could not revoke the session on ${source.baseUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8998
|
-
}
|
|
8999
|
-
}
|
|
9000
|
-
forgetLogin(source);
|
|
9001
|
-
io.stdout(`Logged out of ${source.baseUrl}.`);
|
|
9002
|
-
return 0;
|
|
9003
|
-
}
|
|
9004
|
-
|
|
9005
|
-
// src/commands/status.ts
|
|
9006
|
-
import path13 from "node:path";
|
|
9007
|
-
|
|
9008
|
-
// src/tools/settings.ts
|
|
9009
|
-
var BRIDGE_SCOPES = "mcp:read mcp:execute";
|
|
9010
|
-
var LOGIN_HINT = "diverge login";
|
|
9011
|
-
function loadToolsSettings(options, env = process.env) {
|
|
9012
|
-
const apiUrl = resolveApiUrl(void 0, env);
|
|
9013
|
-
const projectId = options.projectId?.trim() || env.DIVERGENT_PROJECT_ID?.trim() || void 0;
|
|
9014
|
-
let organizationId = options.organizationId?.trim() || env.DIVERGENT_ORG_ID?.trim() || "";
|
|
9015
|
-
const cached = loadLogin(tokenSource(env, apiUrl));
|
|
9016
|
-
if (cached) {
|
|
9017
|
-
organizationId ||= cached.organization ?? "";
|
|
9018
|
-
if (!organizationId) throw new CliError(`The login has no default organization. Pass --organization-id or choose one: diverge org use <id|name>`);
|
|
9019
|
-
return { apiUrl, organizationId, projectId, mode: "operator", clientId: clientId(env) };
|
|
9020
|
-
}
|
|
9021
|
-
const serviceClientId = env.DIVERGENT_CLIENT_ID?.trim() ?? "";
|
|
9022
|
-
const serviceClientSecret = env.DIVERGENT_CLIENT_SECRET?.trim() ?? "";
|
|
9023
|
-
const delegatedUserId = env.DIVERGENT_USER_ID?.trim() ?? "";
|
|
9024
|
-
if (!serviceClientId || !serviceClientSecret) {
|
|
9025
|
-
throw noLogin(apiUrl, "Or, unattended, set DIVERGENT_CLIENT_ID, DIVERGENT_CLIENT_SECRET, DIVERGENT_USER_ID and DIVERGENT_ORG_ID.");
|
|
9026
|
-
}
|
|
9027
|
-
if (!organizationId) throw new CliError("Service credentials act in the organization named: pass --organization-id or set DIVERGENT_ORG_ID.");
|
|
9028
|
-
if (!delegatedUserId) {
|
|
9029
|
-
throw new CliError(`DIVERGENT_USER_ID is required for service-credential execution: tools run under that human's RBAC, and without it the service account executes app-only, which governed tools deliberately restrict.
|
|
9030
|
-
Signing in as yourself avoids this entirely: ${LOGIN_HINT}`);
|
|
9031
|
-
}
|
|
9032
|
-
return { apiUrl, organizationId, projectId, mode: "service", serviceClientId, serviceClientSecret, delegatedUserId };
|
|
9033
|
-
}
|
|
9034
|
-
function scopeLine(settings) {
|
|
9035
|
-
return `Organization: ${settings.organizationId}${settings.projectId ? ` Project: ${settings.projectId}` : ""}`;
|
|
9036
|
-
}
|
|
9037
|
-
var actingAs = null;
|
|
9038
|
-
function actingAsLine(settings, env = process.env) {
|
|
9039
|
-
if (settings.mode === "service") {
|
|
9040
|
-
return Promise.resolve(`Acting as: delegated user ${settings.delegatedUserId} via service client`);
|
|
9576
|
+
return 0;
|
|
9577
|
+
}
|
|
9578
|
+
|
|
9579
|
+
// src/commands/logout.ts
|
|
9580
|
+
var logoutUsage = "diverge logout\n\nRevoke this deployment's login on the platform and forget it locally, with every token issued from it. Logins to other deployments are kept.";
|
|
9581
|
+
async function runLogout(_args, io) {
|
|
9582
|
+
refuseInSession(io.env, "logout");
|
|
9583
|
+
const source = tokenSource(io.env, resolveApiUrl(void 0, io.env));
|
|
9584
|
+
const token = loadLogin(source);
|
|
9585
|
+
if (!token) {
|
|
9586
|
+
io.stdout(`Not logged in to ${source.baseUrl}.`);
|
|
9587
|
+
return 0;
|
|
9041
9588
|
}
|
|
9042
|
-
|
|
9043
|
-
let accessToken;
|
|
9589
|
+
if (token.refresh_token) {
|
|
9044
9590
|
try {
|
|
9045
|
-
|
|
9591
|
+
await revokeRefreshToken(source.baseUrl, source.clientId, token.refresh_token);
|
|
9046
9592
|
} catch (error) {
|
|
9047
|
-
|
|
9593
|
+
io.stderr(`warning: could not revoke the session on ${source.baseUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9048
9594
|
}
|
|
9049
|
-
return `Acting as: ${await describeAccount(settings.apiUrl, accessToken, tokenClaims(accessToken).sub)}`;
|
|
9050
|
-
})();
|
|
9051
|
-
return actingAs;
|
|
9052
|
-
}
|
|
9053
|
-
function describeToolExecution(env = process.env) {
|
|
9054
|
-
let settings;
|
|
9055
|
-
try {
|
|
9056
|
-
settings = loadToolsSettings({}, env);
|
|
9057
|
-
} catch (error) {
|
|
9058
|
-
return `Tool execution: unavailable \u2014 ${error instanceof CliError ? error.message.split("\n")[0] : String(error)}`;
|
|
9059
9595
|
}
|
|
9060
|
-
|
|
9596
|
+
forgetLogin(source);
|
|
9597
|
+
io.stdout(`Logged out of ${source.baseUrl}.`);
|
|
9598
|
+
return 0;
|
|
9061
9599
|
}
|
|
9062
9600
|
|
|
9063
9601
|
// src/commands/status.ts
|
|
9064
|
-
|
|
9602
|
+
import path14 from "node:path";
|
|
9603
|
+
var statusUsage = "diverge status\n\nShow the deployment, the cached login (or the session token), whose account it is, what it carries, and who a tool call would run as. One request: the account behind the login.";
|
|
9065
9604
|
async function runStatus(_args, io) {
|
|
9066
9605
|
const apiUrl = resolveApiUrl(void 0, io.env);
|
|
9067
9606
|
const source = tokenSource(io.env, apiUrl);
|
|
9068
9607
|
io.stdout(`diverge ${VERSION}`);
|
|
9069
9608
|
io.stdout(`Deployment: ${apiUrl}`);
|
|
9070
|
-
|
|
9609
|
+
if (source.sessionTokenFile) {
|
|
9610
|
+
readSessionToken(source.sessionTokenFile);
|
|
9611
|
+
io.stdout(`Session token: ${source.sessionTokenFile} (${SESSION_TOKEN_VARIABLE}); no login is read or written`);
|
|
9612
|
+
const account2 = await signedInAs(source);
|
|
9613
|
+
io.stdout(`Signed in as: ${account2.line}`);
|
|
9614
|
+
io.stdout(`Scopes: ${account2.scopes ?? "unknown"}`);
|
|
9615
|
+
io.stdout(describeToolExecution(io.env));
|
|
9616
|
+
return 0;
|
|
9617
|
+
}
|
|
9618
|
+
io.stdout(`State: ${path14.dirname(source.loginFile)}`);
|
|
9071
9619
|
const record = loadLogin(source);
|
|
9072
9620
|
if (!record) {
|
|
9073
9621
|
io.stdout(`Not logged in. Run: diverge login${apiUrl === DEFAULT_API_URL ? "" : ` --api-url ${apiUrl}`}`);
|
|
@@ -9120,7 +9668,9 @@ var tokenUsage = `diverge token [--organization-id <id>]
|
|
|
9120
9668
|
|
|
9121
9669
|
Print a fresh access token and nothing else: the credential helper for Claude
|
|
9122
9670
|
Code, Codex and forge. The token is for the organization named by
|
|
9123
|
-
--organization-id or DIVERGENT_ORG_ID, else the login's default
|
|
9671
|
+
--organization-id or DIVERGENT_ORG_ID, else the login's default. With
|
|
9672
|
+
DIVERGENT_TOKEN_FILE set, it prints the session token in that file, and an
|
|
9673
|
+
organization other than the token's is refused.`;
|
|
9124
9674
|
async function runToken(args, io) {
|
|
9125
9675
|
const { values } = parseArgs5({ args, options: { "organization-id": { type: "string" } }, strict: true, allowPositionals: false });
|
|
9126
9676
|
const organizationId = values["organization-id"]?.trim() || io.env.DIVERGENT_ORG_ID?.trim() || void 0;
|
|
@@ -9134,177 +9684,11 @@ import { parseArgs as parseArgs6 } from "node:util";
|
|
|
9134
9684
|
|
|
9135
9685
|
// src/mcp/bridge.ts
|
|
9136
9686
|
import readline2 from "node:readline";
|
|
9137
|
-
|
|
9138
|
-
// src/tools/client.ts
|
|
9139
|
-
var PENDING_INVOCATION_STATUSES = ["pending", "approved", "executing"];
|
|
9140
|
-
function isPending(result) {
|
|
9141
|
-
return !!result && typeof result === "object" && result.status === "pending_approval";
|
|
9142
|
-
}
|
|
9143
|
-
var REQUEST_TIMEOUT_MS = 12e4;
|
|
9144
|
-
var TOKEN_REFRESH_MARGIN_SECONDS = 60;
|
|
9145
|
-
var ToolsClient = class {
|
|
9146
|
-
constructor(settings, env = process.env, fetchImpl = fetch) {
|
|
9147
|
-
this.settings = settings;
|
|
9148
|
-
this.env = env;
|
|
9149
|
-
this.fetchImpl = fetchImpl;
|
|
9150
|
-
}
|
|
9151
|
-
settings;
|
|
9152
|
-
env;
|
|
9153
|
-
fetchImpl;
|
|
9154
|
-
serviceToken = null;
|
|
9155
|
-
async token() {
|
|
9156
|
-
if (this.settings.mode === "operator") {
|
|
9157
|
-
return (await getUserToken(tokenSource(this.env, this.settings.apiUrl), { organizationId: this.settings.organizationId })).access_token;
|
|
9158
|
-
}
|
|
9159
|
-
if (this.serviceToken && Date.now() < this.serviceToken.expiresAtMs) return this.serviceToken.value;
|
|
9160
|
-
let response;
|
|
9161
|
-
try {
|
|
9162
|
-
response = await this.fetchImpl(tokenEndpoint(this.settings.apiUrl), {
|
|
9163
|
-
method: "POST",
|
|
9164
|
-
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
9165
|
-
body: JSON.stringify({
|
|
9166
|
-
grant_type: "client_credentials",
|
|
9167
|
-
client_id: this.settings.serviceClientId,
|
|
9168
|
-
client_secret: this.settings.serviceClientSecret,
|
|
9169
|
-
scopes: BRIDGE_SCOPES,
|
|
9170
|
-
organization_id: this.settings.organizationId
|
|
9171
|
-
}),
|
|
9172
|
-
signal: AbortSignal.timeout(3e4)
|
|
9173
|
-
});
|
|
9174
|
-
} catch (error) {
|
|
9175
|
-
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9176
|
-
}
|
|
9177
|
-
if (!response.ok) throw new CliError(`Token acquisition failed (${response.status}): ${(await response.text()).slice(0, 400)}`);
|
|
9178
|
-
const body = await response.json();
|
|
9179
|
-
if (!body.access_token) throw new CliError("Token response contained no access_token");
|
|
9180
|
-
const expiresIn = Number(body.expires_in ?? 3600);
|
|
9181
|
-
this.serviceToken = { value: body.access_token, expiresAtMs: Date.now() + Math.max(expiresIn - TOKEN_REFRESH_MARGIN_SECONDS, 30) * 1e3 };
|
|
9182
|
-
return body.access_token;
|
|
9183
|
-
}
|
|
9184
|
-
async headers() {
|
|
9185
|
-
const headers = { Authorization: `Bearer ${await this.token()}`, "Content-Type": "application/json", "User-Agent": USER_AGENT };
|
|
9186
|
-
if (this.settings.mode === "service") headers["x-divergent-user-id"] = this.settings.delegatedUserId;
|
|
9187
|
-
return headers;
|
|
9188
|
-
}
|
|
9189
|
-
scoped(path15) {
|
|
9190
|
-
const query = new URLSearchParams({ organizationId: this.settings.organizationId });
|
|
9191
|
-
if (this.settings.projectId) query.set("projectId", this.settings.projectId);
|
|
9192
|
-
return `${this.settings.apiUrl}${path15}?${query.toString()}`;
|
|
9193
|
-
}
|
|
9194
|
-
async send(method, url, body) {
|
|
9195
|
-
return this.request(method, url, body, void 0);
|
|
9196
|
-
}
|
|
9197
|
-
/**
|
|
9198
|
-
* One request, re-authenticated once on 401 in service mode. `refused`
|
|
9199
|
-
* turns a chosen status into a value instead of an error, for the
|
|
9200
|
-
* outcomes a caller acts on (a manifest the platform would not accept).
|
|
9201
|
-
*/
|
|
9202
|
-
async request(method, url, body, refused) {
|
|
9203
|
-
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
9204
|
-
const headers = await this.headers();
|
|
9205
|
-
let response;
|
|
9206
|
-
try {
|
|
9207
|
-
response = await this.fetchImpl(url, { method, headers, body: body === void 0 ? void 0 : JSON.stringify(body), signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
9208
|
-
} catch (error) {
|
|
9209
|
-
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9210
|
-
}
|
|
9211
|
-
if (response.status === 401 && attempt === 1 && this.settings.mode === "service") {
|
|
9212
|
-
this.serviceToken = null;
|
|
9213
|
-
continue;
|
|
9214
|
-
}
|
|
9215
|
-
const text = await response.text();
|
|
9216
|
-
if (!response.ok) {
|
|
9217
|
-
const handled = refused?.(response.status, text);
|
|
9218
|
-
if (handled !== void 0) return handled;
|
|
9219
|
-
let message = text;
|
|
9220
|
-
try {
|
|
9221
|
-
const parsed = JSON.parse(text);
|
|
9222
|
-
if (typeof parsed.error === "string" && parsed.error) message = parsed.error;
|
|
9223
|
-
} catch {
|
|
9224
|
-
}
|
|
9225
|
-
if (response.status === 403 && /scope/i.test(message)) {
|
|
9226
|
-
throw new CliError(`${response.status}: ${message}
|
|
9227
|
-
The signed-in token is missing a required scope. Re-run: ${LOGIN_HINT}`);
|
|
9228
|
-
}
|
|
9229
|
-
throw new CliError(`${response.status}: ${message}`.slice(0, 2e3));
|
|
9230
|
-
}
|
|
9231
|
-
return text ? JSON.parse(text) : {};
|
|
9232
|
-
}
|
|
9233
|
-
throw new CliError("Request failed after re-authentication");
|
|
9234
|
-
}
|
|
9235
|
-
async listTools() {
|
|
9236
|
-
const body = await this.send("GET", this.scoped("/api/plugins/functions/tools"));
|
|
9237
|
-
return body.tools ?? [];
|
|
9238
|
-
}
|
|
9239
|
-
/**
|
|
9240
|
-
* One tool, looked up at its source when the catalog does not list it yet —
|
|
9241
|
-
* a tool deployed after its server's catalog was read. A 404 is an answer.
|
|
9242
|
-
*/
|
|
9243
|
-
describeTool(name) {
|
|
9244
|
-
return this.request("GET", this.scoped(`/api/plugins/functions/tools/${encodeURIComponent(name)}`), void 0, (status2, text) => {
|
|
9245
|
-
if (status2 !== 404) return void 0;
|
|
9246
|
-
try {
|
|
9247
|
-
const parsed = JSON.parse(text);
|
|
9248
|
-
if (typeof parsed.error === "string" && parsed.error) return { notFound: parsed.error };
|
|
9249
|
-
} catch {
|
|
9250
|
-
}
|
|
9251
|
-
return { notFound: `No tool named '${name}' is available.` };
|
|
9252
|
-
});
|
|
9253
|
-
}
|
|
9254
|
-
/**
|
|
9255
|
-
* One call. The platform answers a completed call with its invocation
|
|
9256
|
-
* envelope, `{status: 'succeeded', invocationId?, result}`; the tool's own
|
|
9257
|
-
* payload is `result` inside it. Every caller wants the payload, so it is
|
|
9258
|
-
* unwrapped here, once — a pending approval passes through as it is.
|
|
9259
|
-
*/
|
|
9260
|
-
async callTool(name, args) {
|
|
9261
|
-
const body = await this.send("POST", this.scoped("/api/plugins/functions/tools/execute"), { toolName: name, arguments: args ?? {} });
|
|
9262
|
-
const outcome = body.result;
|
|
9263
|
-
if (outcome?.status !== "succeeded") return body;
|
|
9264
|
-
return { ...body, result: outcome.result };
|
|
9265
|
-
}
|
|
9266
|
-
/** The read half of raise-and-read (ADR 0047); anyone but the raiser sees a 404. */
|
|
9267
|
-
getInvocation(invocationId) {
|
|
9268
|
-
return this.send("GET", this.scoped(`/api/plugins/functions/tools/invocations/${encodeURIComponent(invocationId)}`));
|
|
9269
|
-
}
|
|
9270
|
-
// ── Tenant plugins (RFC: Tenant Plugins) ──────────────────────────────
|
|
9271
|
-
descriptorsUrl(pluginId) {
|
|
9272
|
-
const base = `${this.settings.apiUrl}/api/plugins/forge/plugins/descriptors${pluginId ? `/${encodeURIComponent(pluginId)}` : ""}`;
|
|
9273
|
-
return `${base}?${new URLSearchParams({ targetOrganizationId: this.settings.organizationId }).toString()}`;
|
|
9274
|
-
}
|
|
9275
|
-
/** Validate (dryRun) or publish a manifest for the organization the login is issued to. */
|
|
9276
|
-
publishPlugin(manifest, options) {
|
|
9277
|
-
return this.request(
|
|
9278
|
-
"POST",
|
|
9279
|
-
this.descriptorsUrl(),
|
|
9280
|
-
{ targetOrganizationId: this.settings.organizationId, manifest, dryRun: options.dryRun },
|
|
9281
|
-
(status2, text) => {
|
|
9282
|
-
if (status2 !== 400) return void 0;
|
|
9283
|
-
try {
|
|
9284
|
-
const parsed = JSON.parse(text);
|
|
9285
|
-
if (Array.isArray(parsed.details)) return { ok: false, details: parsed.details.map(String) };
|
|
9286
|
-
return { ok: false, details: [parsed.error ?? text] };
|
|
9287
|
-
} catch {
|
|
9288
|
-
return { ok: false, details: [text] };
|
|
9289
|
-
}
|
|
9290
|
-
}
|
|
9291
|
-
).then((outcome) => "ok" in outcome ? outcome : { ok: true, result: outcome });
|
|
9292
|
-
}
|
|
9293
|
-
async listPlugins() {
|
|
9294
|
-
const body = await this.send("GET", this.descriptorsUrl());
|
|
9295
|
-
return body.plugins ?? [];
|
|
9296
|
-
}
|
|
9297
|
-
async retirePlugin(pluginId) {
|
|
9298
|
-
const body = await this.send("DELETE", this.descriptorsUrl(pluginId), { targetOrganizationId: this.settings.organizationId });
|
|
9299
|
-
return body.plugin;
|
|
9300
|
-
}
|
|
9301
|
-
};
|
|
9302
|
-
|
|
9303
|
-
// src/mcp/bridge.ts
|
|
9304
9687
|
var PROTOCOL_VERSION = "2025-06-18";
|
|
9305
9688
|
var SERVER_NAME = "divergent-tools";
|
|
9306
9689
|
var SERVER_VERSION = "1.0.0";
|
|
9307
9690
|
var INVOCATION_STATUS_TOOL = "divergent_invocation_status";
|
|
9691
|
+
var SUBMIT_SET_TOOL = "divergent_submit_set";
|
|
9308
9692
|
var PARSE_ERROR = -32700;
|
|
9309
9693
|
var INVALID_REQUEST = -32600;
|
|
9310
9694
|
var METHOD_NOT_FOUND = -32601;
|
|
@@ -9323,6 +9707,32 @@ function invocationStatusTool() {
|
|
|
9323
9707
|
annotations: { readOnlyHint: true }
|
|
9324
9708
|
};
|
|
9325
9709
|
}
|
|
9710
|
+
function submitSetTool() {
|
|
9711
|
+
return {
|
|
9712
|
+
name: SUBMIT_SET_TOOL,
|
|
9713
|
+
description: "Raise several related write calls as ONE decision: the operator approves the set once, then the calls run in order, stopping at the first failure. Use it whenever two or more writes serve one intent (assign a role to several groups, deactivate several users) instead of calling each write on its own. Writes only \u2014 reads and prepared writes are called directly \u2014 and arguments are frozen when raised, so a call cannot use an id an earlier call in the set creates. Returns pending_approval with one invocationId; read every call's outcome (result.calls) with " + INVOCATION_STATUS_TOOL + ".",
|
|
9714
|
+
inputSchema: {
|
|
9715
|
+
type: "object",
|
|
9716
|
+
properties: {
|
|
9717
|
+
summary: { type: "string", description: "What the set is for, in a sentence \u2014 the title the decider reads." },
|
|
9718
|
+
calls: {
|
|
9719
|
+
type: "array",
|
|
9720
|
+
minItems: 1,
|
|
9721
|
+
description: "The writes, in the order they must run.",
|
|
9722
|
+
items: {
|
|
9723
|
+
type: "object",
|
|
9724
|
+
properties: { tool: { type: "string", description: "Tool name." }, args: { type: "object", description: "The tool's arguments." } },
|
|
9725
|
+
required: ["tool"],
|
|
9726
|
+
additionalProperties: false
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
},
|
|
9730
|
+
required: ["calls"],
|
|
9731
|
+
additionalProperties: false
|
|
9732
|
+
},
|
|
9733
|
+
annotations: { readOnlyHint: false }
|
|
9734
|
+
};
|
|
9735
|
+
}
|
|
9326
9736
|
function mcpTool(tool) {
|
|
9327
9737
|
let description = tool.description ?? "";
|
|
9328
9738
|
if (tool.riskLevel === "high" || tool.riskLevel === "medium") description = `[${tool.riskLevel} risk] ${description}`;
|
|
@@ -9360,11 +9770,11 @@ var BridgeServer = class {
|
|
|
9360
9770
|
/**
|
|
9361
9771
|
* An allowlist keeps a harness's context to the tools it was given: the
|
|
9362
9772
|
* whole catalog is tens of thousands of tokens on every request. The
|
|
9363
|
-
* bridge's own
|
|
9364
|
-
* raise-and-read.
|
|
9773
|
+
* bridge's own tools are always present: the status tool is the read half
|
|
9774
|
+
* of raise-and-read, and a set carries only calls the allowlist exposes.
|
|
9365
9775
|
*/
|
|
9366
9776
|
exposes(name) {
|
|
9367
|
-
return name === INVOCATION_STATUS_TOOL || this.allowed === null || this.allowed.has(name);
|
|
9777
|
+
return name === INVOCATION_STATUS_TOOL || name === SUBMIT_SET_TOOL || this.allowed === null || this.allowed.has(name);
|
|
9368
9778
|
}
|
|
9369
9779
|
/** One JSON-RPC message in, one out; null for a notification. The transport never dies on a handler failure. */
|
|
9370
9780
|
async handle(request) {
|
|
@@ -9378,7 +9788,7 @@ var BridgeServer = class {
|
|
|
9378
9788
|
return { jsonrpc: "2.0", id, result: {} };
|
|
9379
9789
|
case "tools/list": {
|
|
9380
9790
|
const tools = (await this.client.listTools()).filter((tool) => this.exposes(tool.name)).map(mcpTool);
|
|
9381
|
-
tools.push(invocationStatusTool());
|
|
9791
|
+
tools.push(submitSetTool(), invocationStatusTool());
|
|
9382
9792
|
return { jsonrpc: "2.0", id, result: { tools } };
|
|
9383
9793
|
}
|
|
9384
9794
|
case "tools/call": {
|
|
@@ -9387,7 +9797,7 @@ var BridgeServer = class {
|
|
|
9387
9797
|
if (typeof name !== "string" || !name) return rpcError(id, INVALID_REQUEST, "Missing tool name");
|
|
9388
9798
|
if (!this.exposes(name)) return { jsonrpc: "2.0", id, result: { content: textContent(`${name} is not exposed by this bridge`), isError: true } };
|
|
9389
9799
|
const args = params.arguments ?? {};
|
|
9390
|
-
const result = name === INVOCATION_STATUS_TOOL ? await this.invocationStatus(args) : await this.call(name, args);
|
|
9800
|
+
const result = name === INVOCATION_STATUS_TOOL ? await this.invocationStatus(args) : name === SUBMIT_SET_TOOL ? await this.submitSet(args) : await this.call(name, args);
|
|
9391
9801
|
return { jsonrpc: "2.0", id, result };
|
|
9392
9802
|
}
|
|
9393
9803
|
default:
|
|
@@ -9397,11 +9807,26 @@ var BridgeServer = class {
|
|
|
9397
9807
|
return rpcError(id, INTERNAL_ERROR, error instanceof CliError ? error.message : `Bridge failure: ${error instanceof Error ? error.message : String(error)}`);
|
|
9398
9808
|
}
|
|
9399
9809
|
}
|
|
9810
|
+
async submitSet(args) {
|
|
9811
|
+
const raw = Array.isArray(args.calls) ? args.calls : [];
|
|
9812
|
+
const calls = raw.flatMap((entry) => {
|
|
9813
|
+
const { tool, args: callArgs } = entry ?? {};
|
|
9814
|
+
return typeof tool === "string" && tool ? [{ tool, args: callArgs && typeof callArgs === "object" && !Array.isArray(callArgs) ? callArgs : {} }] : [];
|
|
9815
|
+
});
|
|
9816
|
+
if (calls.length === 0 || calls.length !== raw.length) return { content: textContent("calls must be a non-empty array of {tool, args}"), isError: true };
|
|
9817
|
+
const hidden = calls.map((call2) => call2.tool).filter((tool) => tool === SUBMIT_SET_TOOL || tool === INVOCATION_STATUS_TOOL || !this.exposes(tool));
|
|
9818
|
+
if (hidden.length) return { content: textContent(`${[...new Set(hidden)].join(", ")} cannot be called in a set through this bridge`), isError: true };
|
|
9819
|
+
const summary = typeof args.summary === "string" && args.summary.trim() ? args.summary.trim() : void 0;
|
|
9820
|
+
return this.settle(() => this.client.callSet(calls, summary));
|
|
9821
|
+
}
|
|
9400
9822
|
/** A denied or failed tool call is a result the agent should reason about, not a transport error. */
|
|
9401
|
-
|
|
9823
|
+
call(name, args) {
|
|
9824
|
+
return this.settle(() => this.client.callTool(name, args));
|
|
9825
|
+
}
|
|
9826
|
+
async settle(send) {
|
|
9402
9827
|
let body;
|
|
9403
9828
|
try {
|
|
9404
|
-
body = await
|
|
9829
|
+
body = await send();
|
|
9405
9830
|
} catch (error) {
|
|
9406
9831
|
if (error instanceof CliError) return { content: textContent(error.message), isError: true };
|
|
9407
9832
|
throw error;
|
|
@@ -9482,7 +9907,7 @@ async function waitForInvocation(id, options, deps) {
|
|
|
9482
9907
|
}
|
|
9483
9908
|
|
|
9484
9909
|
// src/tools/call-args.ts
|
|
9485
|
-
import
|
|
9910
|
+
import fs11 from "node:fs";
|
|
9486
9911
|
async function resolveCallArgs(options, stdin = readStdin) {
|
|
9487
9912
|
if (options.argsJson !== void 0 && options.argsJson !== "{}" && options.argsFile !== void 0) {
|
|
9488
9913
|
throw new CliError("give the arguments once: --args-json or --args-file");
|
|
@@ -9492,7 +9917,7 @@ async function resolveCallArgs(options, stdin = readStdin) {
|
|
|
9492
9917
|
if (options.argsFile !== void 0) {
|
|
9493
9918
|
source = `--args-file ${options.argsFile}`;
|
|
9494
9919
|
try {
|
|
9495
|
-
text =
|
|
9920
|
+
text = fs11.readFileSync(options.argsFile, "utf8");
|
|
9496
9921
|
} catch (error) {
|
|
9497
9922
|
throw new CliError(`${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9498
9923
|
}
|
|
@@ -9565,7 +9990,7 @@ function outcomeOf(tool, invocationId, invocation) {
|
|
|
9565
9990
|
case "expired":
|
|
9566
9991
|
return { tool, status: "expired", invocationId };
|
|
9567
9992
|
case "failed":
|
|
9568
|
-
return { tool, status: "failed", invocationId, error: invocation.errorMessage || "execution failed" };
|
|
9993
|
+
return { tool, status: "failed", invocationId, error: invocation.errorMessage || "execution failed", ...invocation.result != null ? { result: invocation.result } : {} };
|
|
9569
9994
|
default:
|
|
9570
9995
|
return null;
|
|
9571
9996
|
}
|
|
@@ -9584,7 +10009,7 @@ function worstExitCode(outcomes) {
|
|
|
9584
10009
|
}
|
|
9585
10010
|
|
|
9586
10011
|
// src/commands/tools.ts
|
|
9587
|
-
import
|
|
10012
|
+
import fs12 from "node:fs";
|
|
9588
10013
|
|
|
9589
10014
|
// src/tools/print.ts
|
|
9590
10015
|
function matchesCapability(selector, capability) {
|
|
@@ -9656,19 +10081,25 @@ function formatPending(result, apiUrl, organizationId) {
|
|
|
9656
10081
|
}
|
|
9657
10082
|
|
|
9658
10083
|
// src/commands/tools.ts
|
|
9659
|
-
var toolsUsage = `diverge tools <list|capabilities|describe|call|run|invocation|bridge> [--organization-id <id>] [--project-id <id>] ...
|
|
10084
|
+
var toolsUsage = `diverge tools <list|capabilities|describe|call|set|run|invocation|bridge> [--organization-id <id>] [--project-id <id>] ...
|
|
9660
10085
|
|
|
9661
10086
|
list [--filter <text>] [--capability <selector>] [--json]
|
|
9662
|
-
--filter
|
|
10087
|
+
--filter searches tool names and descriptions, ignoring case
|
|
9663
10088
|
capabilities [--json]
|
|
9664
10089
|
describe <name> [--json]
|
|
9665
10090
|
call <name> [--args-json '{...}' | --args-json - | --args-file <path>] [--wait] [--timeout <seconds>] [--json]
|
|
9666
10091
|
arguments inline, from stdin (-), or from a file: PowerShell strips quotes inside inline JSON
|
|
9667
10092
|
--json prints exactly one JSON object on stdout, errors included:
|
|
9668
10093
|
{tool, status: executed|pending|rejected|expired|failed, result?, error?, invocationId?, decideAt?}
|
|
10094
|
+
set <file|-> [--summary <text>] [--wait] [--timeout <seconds>] [--json]
|
|
10095
|
+
several related writes (a JSON array of {tool, args}, or one per line) raised as ONE
|
|
10096
|
+
decision: one card in Compass, run in order once approved, stopping at the first
|
|
10097
|
+
failure; every call's outcome is read back by the set's invocation id.
|
|
10098
|
+
Use this, not one call per write, whenever the writes serve one intent.
|
|
9669
10099
|
run <file|-> [--wait] [--timeout <seconds>]
|
|
9670
|
-
several calls from one file
|
|
9671
|
-
|
|
10100
|
+
several independent calls from one file, in order, one JSON line of outcome each
|
|
10101
|
+
(each write is its own decision; use set for related writes);
|
|
10102
|
+
exit code is the worst: 1 failed, 4 rejected, 5 expired, 3 pending
|
|
9672
10103
|
invocation <id> [--wait] [--timeout <seconds>] [--json]
|
|
9673
10104
|
--json prints the invocation record; the exit code is call's for the same status
|
|
9674
10105
|
bridge [--tools <name,name>] (stdio MCP server; the allowlist keeps a harness to the tools it was given)
|
|
@@ -9718,7 +10149,39 @@ async function call(rest, io) {
|
|
|
9718
10149
|
});
|
|
9719
10150
|
} catch (error) {
|
|
9720
10151
|
if (!json) throw error;
|
|
9721
|
-
outcome = { tool, status: "failed", error: error instanceof Error ? error.message : String(error) };
|
|
10152
|
+
outcome = { tool, status: "failed", error: unknownOption(error, toolsUsage, ["call"]) ?? (error instanceof Error ? error.message : String(error)) };
|
|
10153
|
+
}
|
|
10154
|
+
if (json) io.stdout(JSON.stringify(outcome, null, 2));
|
|
10155
|
+
else printOutcome(outcome, waited, io);
|
|
10156
|
+
return worstExitCode([outcome]);
|
|
10157
|
+
}
|
|
10158
|
+
var SET_OPTIONS = { ...SCOPE_OPTIONS, summary: { type: "string" }, wait: { type: "boolean", default: false }, timeout: { type: "string", default: "600" }, json: { type: "boolean", default: false } };
|
|
10159
|
+
async function set(rest, io) {
|
|
10160
|
+
const json = rest.includes("--json");
|
|
10161
|
+
let waited = "";
|
|
10162
|
+
let outcome;
|
|
10163
|
+
try {
|
|
10164
|
+
const { values, positionals } = parseArgs6({ args: rest, options: SET_OPTIONS, strict: true, allowPositionals: true });
|
|
10165
|
+
const file = positionals[0];
|
|
10166
|
+
if (!file) throw new CliError("set needs a file of calls, or - for stdin");
|
|
10167
|
+
let entries;
|
|
10168
|
+
try {
|
|
10169
|
+
entries = parseBatch(file === "-" ? await readStdin() : fs12.readFileSync(file, "utf8"));
|
|
10170
|
+
} catch (error) {
|
|
10171
|
+
throw new CliError(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
10172
|
+
}
|
|
10173
|
+
const timeoutMs = timeoutOf(values.timeout);
|
|
10174
|
+
if (values.wait) waited = values.timeout;
|
|
10175
|
+
const { settings, client: tools } = await client(values, io);
|
|
10176
|
+
outcome = await runOne({ tool: INVOCATION_SET_TOOL, args: {} }, {
|
|
10177
|
+
callTool: () => tools.callSet(entries, values.summary),
|
|
10178
|
+
decideAt: (pending) => `${settings.apiUrl}${pending.approvalUrl ?? ""}`,
|
|
10179
|
+
...json ? {} : { onPending: (pending) => formatPending(pending, settings.apiUrl, settings.organizationId).forEach((line) => io.stdout(line)) },
|
|
10180
|
+
...values.wait ? { waitFor: waiter(tools, timeoutMs) } : {}
|
|
10181
|
+
});
|
|
10182
|
+
} catch (error) {
|
|
10183
|
+
if (!json) throw error;
|
|
10184
|
+
outcome = { tool: INVOCATION_SET_TOOL, status: "failed", error: unknownOption(error, toolsUsage, ["set"]) ?? (error instanceof Error ? error.message : String(error)) };
|
|
9722
10185
|
}
|
|
9723
10186
|
if (json) io.stdout(JSON.stringify(outcome, null, 2));
|
|
9724
10187
|
else printOutcome(outcome, waited, io);
|
|
@@ -9739,29 +10202,12 @@ function printOutcome(outcome, waited, io) {
|
|
|
9739
10202
|
io.stderr("Expired before anyone decided. Raise a fresh call; the old id is final.");
|
|
9740
10203
|
return;
|
|
9741
10204
|
case "failed":
|
|
10205
|
+
if (outcome.result !== void 0) io.stdout(JSON.stringify(outcome.result, null, 2));
|
|
9742
10206
|
throw new CliError(outcome.invocationId ? `Approved, but execution failed: ${outcome.error}` : outcome.error || "Tool execution failed");
|
|
9743
10207
|
}
|
|
9744
10208
|
}
|
|
9745
|
-
function toolsVerbUsage(verb) {
|
|
9746
|
-
const lines = [];
|
|
9747
|
-
let inVerb = false;
|
|
9748
|
-
for (const line of toolsUsage.split("\n")) {
|
|
9749
|
-
if (/^ {2}\S/.test(line)) inVerb = line.trimStart().startsWith(`${verb} `);
|
|
9750
|
-
else if (!/^ {3,}\S/.test(line)) inVerb = false;
|
|
9751
|
-
if (inVerb) lines.push(line);
|
|
9752
|
-
}
|
|
9753
|
-
return lines.length ? `diverge tools ${verb} ...
|
|
9754
|
-
|
|
9755
|
-
${lines.join("\n")}
|
|
9756
|
-
|
|
9757
|
-
Every tools command takes --organization-id <id> (or DIVERGENT_ORG_ID, else the signed-in login's organization) and --project-id <id> (or DIVERGENT_PROJECT_ID).` : toolsUsage;
|
|
9758
|
-
}
|
|
9759
10209
|
async function runTools(args, io) {
|
|
9760
10210
|
const [verb, ...rest] = args;
|
|
9761
|
-
if (verb && (rest.includes("--help") || rest.includes("-h"))) {
|
|
9762
|
-
io.stdout(toolsVerbUsage(verb));
|
|
9763
|
-
return ExitCode.Ok;
|
|
9764
|
-
}
|
|
9765
10211
|
switch (verb) {
|
|
9766
10212
|
case "list": {
|
|
9767
10213
|
const { values } = parseArgs6({ args: rest, options: { ...SCOPE_OPTIONS, filter: { type: "string" }, capability: { type: "string" }, json: { type: "boolean", default: false } }, strict: true });
|
|
@@ -9799,13 +10245,15 @@ async function runTools(args, io) {
|
|
|
9799
10245
|
}
|
|
9800
10246
|
case "call":
|
|
9801
10247
|
return call(rest, io);
|
|
10248
|
+
case "set":
|
|
10249
|
+
return set(rest, io);
|
|
9802
10250
|
case "run": {
|
|
9803
10251
|
const { values, positionals } = parseArgs6({ args: rest, options: { ...SCOPE_OPTIONS, wait: { type: "boolean", default: false }, timeout: { type: "string", default: "600" } }, strict: true, allowPositionals: true });
|
|
9804
10252
|
const file = positionals[0];
|
|
9805
10253
|
if (!file) throw new CliError("run needs a file of calls, or - for stdin");
|
|
9806
10254
|
let entries;
|
|
9807
10255
|
try {
|
|
9808
|
-
entries = parseBatch(file === "-" ? await readStdin() :
|
|
10256
|
+
entries = parseBatch(file === "-" ? await readStdin() : fs12.readFileSync(file, "utf8"));
|
|
9809
10257
|
} catch (error) {
|
|
9810
10258
|
throw new CliError(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9811
10259
|
}
|
|
@@ -9844,14 +10292,12 @@ async function runTools(args, io) {
|
|
|
9844
10292
|
return serveBridge(new BridgeServer(tools, { tools: allow }), process.stdin, process.stdout);
|
|
9845
10293
|
}
|
|
9846
10294
|
default:
|
|
9847
|
-
throw
|
|
9848
|
-
|
|
9849
|
-
${toolsUsage}`);
|
|
10295
|
+
throw unknownVerb("tools", toolsUsage, [], verb, rest);
|
|
9850
10296
|
}
|
|
9851
10297
|
}
|
|
9852
10298
|
|
|
9853
10299
|
// src/commands/plugins.ts
|
|
9854
|
-
import
|
|
10300
|
+
import fs13 from "node:fs";
|
|
9855
10301
|
import { parseArgs as parseArgs7 } from "node:util";
|
|
9856
10302
|
var pluginsUsage = `diverge plugins <validate|publish|list|retire> [--organization-id <id>] ...
|
|
9857
10303
|
|
|
@@ -9878,7 +10324,7 @@ function readManifest(file) {
|
|
|
9878
10324
|
${pluginsUsage}`);
|
|
9879
10325
|
let text;
|
|
9880
10326
|
try {
|
|
9881
|
-
text =
|
|
10327
|
+
text = fs13.readFileSync(file, "utf8");
|
|
9882
10328
|
} catch (error) {
|
|
9883
10329
|
throw new CliError(`Cannot read ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9884
10330
|
}
|
|
@@ -9897,23 +10343,12 @@ function formatPlugin(plugin) {
|
|
|
9897
10343
|
`${plugin.pluginId}@${plugin.version} ${plugin.name} (${parent}; runtime ${plugin.runtimeType}; digest ${plugin.digest.slice(0, 12)})`,
|
|
9898
10344
|
` tools: ${plugin.toolNames.length ? plugin.toolNames.join(", ") : "none"}`,
|
|
9899
10345
|
...plugin.resourceNames.length ? [` resources: ${plugin.resourceNames.join(", ")}`] : [],
|
|
9900
|
-
...plugin.refusals?.length ? [" NOT SERVED: the platform refuses this version; publish a fixed one:", ...plugin.refusals.map((reason) => ` - ${reason}`)] : []
|
|
10346
|
+
...plugin.refusals?.length ? [" NOT SERVED: the platform refuses this version; publish a fixed one:", ...plugin.refusals.map((reason) => ` - ${reason}`)] : [],
|
|
10347
|
+
...plugin.warnings?.length ? [" WARNING: serving, but accepted under earlier publish rules; the next publish must meet:", ...plugin.warnings.map((reason) => ` - ${reason}`)] : []
|
|
9901
10348
|
];
|
|
9902
10349
|
}
|
|
9903
|
-
function pluginsVerbUsage(verb) {
|
|
9904
|
-
const lines = pluginsUsage.split("\n").filter((line) => line.trimStart().startsWith(`${verb} `));
|
|
9905
|
-
return lines.length ? `diverge plugins ${verb} ...
|
|
9906
|
-
|
|
9907
|
-
${lines.join("\n")}
|
|
9908
|
-
|
|
9909
|
-
Every plugins command takes --organization-id <id> (or DIVERGENT_ORG_ID, else the signed-in login's organization).` : pluginsUsage;
|
|
9910
|
-
}
|
|
9911
10350
|
async function runPlugins(args, io) {
|
|
9912
10351
|
const [verb, ...rest] = args;
|
|
9913
|
-
if (verb && (rest.includes("--help") || rest.includes("-h"))) {
|
|
9914
|
-
io.stdout(pluginsVerbUsage(verb));
|
|
9915
|
-
return ExitCode.Ok;
|
|
9916
|
-
}
|
|
9917
10352
|
switch (verb) {
|
|
9918
10353
|
case "validate": {
|
|
9919
10354
|
const { values, positionals } = parseArgs7({ args: rest, options: { ...SCOPE_OPTIONS2, json: { type: "boolean", default: false } }, allowPositionals: true, strict: true });
|
|
@@ -9971,27 +10406,26 @@ ${pluginsUsage}`);
|
|
|
9971
10406
|
return ExitCode.Ok;
|
|
9972
10407
|
}
|
|
9973
10408
|
default:
|
|
9974
|
-
throw
|
|
9975
|
-
|
|
9976
|
-
${pluginsUsage}`);
|
|
10409
|
+
throw unknownVerb("plugins", pluginsUsage, [], verb, rest);
|
|
9977
10410
|
}
|
|
9978
10411
|
}
|
|
9979
10412
|
|
|
9980
10413
|
// src/commands/update.ts
|
|
9981
10414
|
import { spawn as spawn4 } from "node:child_process";
|
|
10415
|
+
import path16 from "node:path";
|
|
9982
10416
|
|
|
9983
10417
|
// src/update-notice.ts
|
|
9984
10418
|
import { spawn as spawn3 } from "node:child_process";
|
|
9985
|
-
import
|
|
9986
|
-
import
|
|
10419
|
+
import fs14 from "node:fs";
|
|
10420
|
+
import path15 from "node:path";
|
|
9987
10421
|
var UPDATE_CHECK_FILE = "update-check.json";
|
|
9988
10422
|
var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
9989
10423
|
function updateCheckFile(env) {
|
|
9990
|
-
return
|
|
10424
|
+
return path15.join(configDir(env), UPDATE_CHECK_FILE);
|
|
9991
10425
|
}
|
|
9992
10426
|
function readUpdateCheck(env) {
|
|
9993
10427
|
try {
|
|
9994
|
-
const parsed = JSON.parse(
|
|
10428
|
+
const parsed = JSON.parse(fs14.readFileSync(updateCheckFile(env), "utf8"));
|
|
9995
10429
|
if (parsed && typeof parsed === "object" && typeof parsed.checkedAt === "number" && typeof parsed.latest === "string") return parsed;
|
|
9996
10430
|
} catch {
|
|
9997
10431
|
}
|
|
@@ -10006,7 +10440,7 @@ function noticeFor(check, version = VERSION) {
|
|
|
10006
10440
|
}
|
|
10007
10441
|
function noticeApplies(argv, io, version = VERSION) {
|
|
10008
10442
|
if (version === "dev" || !io.interactive) return false;
|
|
10009
|
-
if (io.env.DIVERGE_NO_UPDATE_CHECK?.trim() || io.env.CI?.trim()) return false;
|
|
10443
|
+
if (io.env.DIVERGE_NO_UPDATE_CHECK?.trim() || io.env.CI?.trim() || sessionTokenFile(io.env)) return false;
|
|
10010
10444
|
if (argv[0] === "update") return false;
|
|
10011
10445
|
if (argv[0] === "tools" && argv[1] === "bridge") return false;
|
|
10012
10446
|
return true;
|
|
@@ -10054,6 +10488,7 @@ function isNewer(a, b) {
|
|
|
10054
10488
|
return x.pre > y.pre;
|
|
10055
10489
|
}
|
|
10056
10490
|
async function runUpdate(args, io, deps = { latestVersion, install: installLatest, record: writeUpdateCheck, now: Date.now }) {
|
|
10491
|
+
refuseInSession(io.env, "update");
|
|
10057
10492
|
if (args[0] === "--record") {
|
|
10058
10493
|
try {
|
|
10059
10494
|
deps.record(io.env, { checkedAt: deps.now(), latest: await deps.latestVersion() });
|
|
@@ -10073,10 +10508,20 @@ async function runUpdate(args, io, deps = { latestVersion, install: installLates
|
|
|
10073
10508
|
io.stdout(`diverge ${latest} installed.`);
|
|
10074
10509
|
return ExitCode.Ok;
|
|
10075
10510
|
}
|
|
10076
|
-
function installLatest(version) {
|
|
10077
|
-
|
|
10511
|
+
function installLatest(version, env = process.env, platform = process.platform) {
|
|
10512
|
+
let command = "npm";
|
|
10513
|
+
const args = ["install", "-g", `${PACKAGE_NAME}@${version}`];
|
|
10514
|
+
if (platform === "win32") {
|
|
10515
|
+
const npm = findOnPath("npm", env, platform);
|
|
10516
|
+
if (!npm) throw new CliError("npm was not found on PATH; install Node.js with npm and try again.");
|
|
10517
|
+
command = npm;
|
|
10518
|
+
if (/\.(cmd|bat)$/i.test(npm)) {
|
|
10519
|
+
command = process.execPath;
|
|
10520
|
+
args.unshift(path16.join(path16.dirname(npm), "node_modules", "npm", "bin", "npm-cli.js"));
|
|
10521
|
+
}
|
|
10522
|
+
}
|
|
10078
10523
|
return new Promise((resolve, reject) => {
|
|
10079
|
-
const child = spawn4(
|
|
10524
|
+
const child = spawn4(command, args, { env, stdio: "inherit" });
|
|
10080
10525
|
child.on("error", reject);
|
|
10081
10526
|
child.on("exit", (code2) => resolve(code2 ?? 1));
|
|
10082
10527
|
});
|
|
@@ -10084,9 +10529,9 @@ function installLatest(version) {
|
|
|
10084
10529
|
|
|
10085
10530
|
// src/cli.ts
|
|
10086
10531
|
var COMMANDS = [
|
|
10087
|
-
{ name: "login", summary: "Sign in through the browser", usage: loginUsage, run: runLogin },
|
|
10532
|
+
{ name: "login", summary: "Sign in (authenticate) through the browser", usage: loginUsage, run: runLogin },
|
|
10088
10533
|
{ name: "logout", summary: "Revoke the login and forget it", usage: logoutUsage, run: runLogout },
|
|
10089
|
-
{ name: "status", summary: "Show the deployment and the
|
|
10534
|
+
{ name: "status", summary: "Show who you are signed in as: the deployment, the account and what the login carries", usage: statusUsage, run: runStatus },
|
|
10090
10535
|
{ name: "org", summary: "Show or switch the organization the login acts in", usage: orgUsage, run: runOrg },
|
|
10091
10536
|
{ name: "token", summary: "Print a fresh access token", usage: tokenUsage, run: runToken },
|
|
10092
10537
|
{ name: "agents", summary: "Point a coding agent at the model gateway (setup, run, status)", usage: agentsUsage, run: runAgents },
|
|
@@ -10107,7 +10552,7 @@ function usage() {
|
|
|
10107
10552
|
...lines,
|
|
10108
10553
|
"",
|
|
10109
10554
|
"Run `diverge <command> --help` for its options.",
|
|
10110
|
-
"Environment: DIVERGENT_API_URL (deployment; production when unset), DIVERGE_HOME (state directory, default ~/.diverge), DIVERGENT_ORG_ID and DIVERGENT_PROJECT_ID (the organization and project a command acts in)."
|
|
10555
|
+
"Environment: DIVERGENT_API_URL (deployment; production when unset), DIVERGE_HOME (state directory, default ~/.diverge), DIVERGENT_ORG_ID and DIVERGENT_PROJECT_ID (the organization and project a command acts in), DIVERGENT_TOKEN_FILE (a file holding the token this session runs on, in place of any login)."
|
|
10111
10556
|
].join("\n");
|
|
10112
10557
|
}
|
|
10113
10558
|
async function run2(argv, io) {
|
|
@@ -10122,15 +10567,19 @@ async function run2(argv, io) {
|
|
|
10122
10567
|
}
|
|
10123
10568
|
const command = COMMANDS.find((candidate) => candidate.name === name);
|
|
10124
10569
|
if (!command) {
|
|
10125
|
-
|
|
10570
|
+
const candidates = COMMANDS.map((known) => ({ invocation: `diverge ${known.name}`, name: known.name, summary: known.summary, lines: [known.summary] }));
|
|
10571
|
+
io.stderr(`Unknown command: ${name}.${didYouMean(closest(name, candidates, rest))}
|
|
10126
10572
|
|
|
10127
10573
|
${usage()}`);
|
|
10128
10574
|
return ExitCode.Failure;
|
|
10129
10575
|
}
|
|
10130
10576
|
const own = rest.includes("--") ? rest.slice(0, rest.indexOf("--")) : rest;
|
|
10131
|
-
if (
|
|
10132
|
-
|
|
10133
|
-
|
|
10577
|
+
if (own.includes("--help") || own.includes("-h")) {
|
|
10578
|
+
const path17 = verbPath(command.usage, own);
|
|
10579
|
+
if (path17.length > 0 || own[0].startsWith("-")) {
|
|
10580
|
+
io.stdout(verbUsage(command.name, command.usage, path17));
|
|
10581
|
+
return ExitCode.Ok;
|
|
10582
|
+
}
|
|
10134
10583
|
}
|
|
10135
10584
|
const code2 = await runCommand(command, rest, io);
|
|
10136
10585
|
updateNotice(argv, io);
|
|
@@ -10145,9 +10594,9 @@ async function runCommand(command, rest, io) {
|
|
|
10145
10594
|
return error.exitCode;
|
|
10146
10595
|
}
|
|
10147
10596
|
if (error instanceof Error && error.name === "TypeError" && /Unknown option|Option .* argument|Unexpected argument/.test(error.message)) {
|
|
10148
|
-
io.stderr(`Error: ${error.message}
|
|
10597
|
+
io.stderr(`Error: ${unknownOption(error, command.usage, rest) ?? error.message}
|
|
10149
10598
|
|
|
10150
|
-
${command.usage}`);
|
|
10599
|
+
${verbUsage(command.name, command.usage, verbPath(command.usage, rest))}`);
|
|
10151
10600
|
return ExitCode.Failure;
|
|
10152
10601
|
}
|
|
10153
10602
|
io.stderr(`Error: ${error instanceof Error ? error.message : String(error)}`);
|