@divergeai/cli 0.1.23 → 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 +56 -6
- package/dist/diverge.mjs +1124 -766
- 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;
|
|
@@ -7886,11 +7931,11 @@ function verbPath(usage2, args) {
|
|
|
7886
7931
|
function groupOptions(usage2) {
|
|
7887
7932
|
return usage2.split("\n", 1)[0].match(/\[--[^\]]+\]/g) ?? [];
|
|
7888
7933
|
}
|
|
7889
|
-
function verbUsage(command, usage2,
|
|
7890
|
-
const lines = usageEntries(usage2).filter((entry) => startsWith(entry.verbs,
|
|
7891
|
-
if (
|
|
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;
|
|
7892
7937
|
const shared = groupOptions(usage2);
|
|
7893
|
-
return [`diverge ${command} ${
|
|
7938
|
+
return [`diverge ${command} ${path17.join(" ")} ...`, "", ...lines, ...shared.length ? ["", `Every ${command} command also takes ${shared.join(" ")}.`] : []].join("\n");
|
|
7894
7939
|
}
|
|
7895
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"]);
|
|
7896
7941
|
function distance(a, b) {
|
|
@@ -7942,12 +7987,12 @@ function didYouMean(matches) {
|
|
|
7942
7987
|
return ` Did you mean one of:
|
|
7943
7988
|
${matches.map((match) => ` ${shown(match)}`).join("\n")}`;
|
|
7944
7989
|
}
|
|
7945
|
-
function verbCandidates(command, usage2,
|
|
7990
|
+
function verbCandidates(command, usage2, path17) {
|
|
7946
7991
|
const byName = /* @__PURE__ */ new Map();
|
|
7947
7992
|
for (const entry of usageEntries(usage2)) {
|
|
7948
|
-
if (!startsWith(entry.verbs,
|
|
7949
|
-
const name = entry.verbs[
|
|
7950
|
-
const invocation = ["diverge", command, ...
|
|
7993
|
+
if (!startsWith(entry.verbs, path17)) continue;
|
|
7994
|
+
const name = entry.verbs[path17.length] ?? "";
|
|
7995
|
+
const invocation = ["diverge", command, ...path17, ...name ? [name] : []].join(" ");
|
|
7951
7996
|
const lines = [entry.summary, ...entry.lines.slice(1).map((line) => line.trim())].filter(Boolean);
|
|
7952
7997
|
const known = byName.get(name);
|
|
7953
7998
|
if (known) known.lines.push(...lines);
|
|
@@ -7955,9 +8000,9 @@ function verbCandidates(command, usage2, path15) {
|
|
|
7955
8000
|
}
|
|
7956
8001
|
return [...byName.values()];
|
|
7957
8002
|
}
|
|
7958
|
-
function unknownVerb(command, usage2,
|
|
7959
|
-
const candidates = verbCandidates(command, usage2,
|
|
7960
|
-
const where = [command, ...
|
|
8003
|
+
function unknownVerb(command, usage2, path17, verb, rest = []) {
|
|
8004
|
+
const candidates = verbCandidates(command, usage2, path17);
|
|
8005
|
+
const where = [command, ...path17].join(" ");
|
|
7961
8006
|
if (!verb) return new CliError(`${where} needs one of: ${candidates.map((candidate) => candidate.name).filter(Boolean).join(", ")}
|
|
7962
8007
|
|
|
7963
8008
|
${usage2}`);
|
|
@@ -7965,10 +8010,10 @@ ${usage2}`);
|
|
|
7965
8010
|
|
|
7966
8011
|
${usage2}`);
|
|
7967
8012
|
}
|
|
7968
|
-
function optionCandidates(usage2,
|
|
8013
|
+
function optionCandidates(usage2, path17) {
|
|
7969
8014
|
const entries = usageEntries(usage2);
|
|
7970
8015
|
const [header = "", ...body] = usage2.split("\n");
|
|
7971
|
-
const described = entries.length === 0 ||
|
|
8016
|
+
const described = entries.length === 0 || path17.length === 0 ? body : entries.filter((entry) => startsWith(entry.verbs, path17)).flatMap((entry) => entry.lines);
|
|
7972
8017
|
const byName = /* @__PURE__ */ new Map();
|
|
7973
8018
|
const add = (line, describes) => {
|
|
7974
8019
|
for (const [flag] of line.matchAll(/--[a-z][a-z-]*/g)) {
|
|
@@ -7985,8 +8030,8 @@ function unknownOption(error, usage2, args) {
|
|
|
7985
8030
|
if (!(error instanceof Error) || error.name !== "TypeError") return null;
|
|
7986
8031
|
const option = /^Unknown option '([^']+)'/.exec(error.message)?.[1];
|
|
7987
8032
|
if (!option) return null;
|
|
7988
|
-
const
|
|
7989
|
-
return `Unknown option: ${option}.${didYouMean(closest(option, optionCandidates(usage2,
|
|
8033
|
+
const path17 = verbPath(usage2, args);
|
|
8034
|
+
return `Unknown option: ${option}.${didYouMean(closest(option, optionCandidates(usage2, path17)))}`;
|
|
7990
8035
|
}
|
|
7991
8036
|
|
|
7992
8037
|
// src/commands/login.ts
|
|
@@ -8076,6 +8121,7 @@ function resolveLoginHint(flag, previous) {
|
|
|
8076
8121
|
return remembered || void 0;
|
|
8077
8122
|
}
|
|
8078
8123
|
async function runLogin(args, io) {
|
|
8124
|
+
refuseInSession(io.env, "login");
|
|
8079
8125
|
const { values } = parseArgs({
|
|
8080
8126
|
args,
|
|
8081
8127
|
options: {
|
|
@@ -8157,6 +8203,14 @@ function surfaceBaseUrl(apiUrl, surface) {
|
|
|
8157
8203
|
}
|
|
8158
8204
|
|
|
8159
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
|
+
}
|
|
8160
8214
|
async function listModels(apiUrl, accessToken, surface) {
|
|
8161
8215
|
try {
|
|
8162
8216
|
const body = await fetchJson(`${surfaceBaseUrl(apiUrl, surface)}/v1/models`, {
|
|
@@ -8173,7 +8227,7 @@ async function listModels(apiUrl, accessToken, surface) {
|
|
|
8173
8227
|
}
|
|
8174
8228
|
async function ensureInferenceLogin(io, apiUrl, organizationId) {
|
|
8175
8229
|
const source = tokenSource(io.env, apiUrl);
|
|
8176
|
-
if (!loadLogin(source)) {
|
|
8230
|
+
if (!source.sessionTokenFile && !loadLogin(source)) {
|
|
8177
8231
|
if (!io.interactive) throw new CliError(`Not signed in to ${apiUrl}. Run: diverge login${organizationId ? ` --organization-id ${organizationId}` : ""}`);
|
|
8178
8232
|
await runLogin(organizationId ? ["--organization-id", organizationId] : [], io);
|
|
8179
8233
|
}
|
|
@@ -8254,39 +8308,294 @@ function mergeCodexConfig(existing, block) {
|
|
|
8254
8308
|
|
|
8255
8309
|
// src/agents/dsh.ts
|
|
8256
8310
|
var import_yaml = __toESM(require_dist(), 1);
|
|
8257
|
-
import
|
|
8311
|
+
import fs5 from "node:fs";
|
|
8258
8312
|
import { createRequire } from "node:module";
|
|
8259
8313
|
import os4 from "node:os";
|
|
8260
8314
|
import path6 from "node:path";
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
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 };
|
|
8264
8346
|
}
|
|
8265
|
-
function
|
|
8266
|
-
|
|
8267
|
-
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}` : ""}`;
|
|
8268
8349
|
}
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
`
|
|
8284
|
-
`
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
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>`,
|
|
8581
|
+
"- id: llm-pi-ai",
|
|
8582
|
+
" config:",
|
|
8583
|
+
" providers:",
|
|
8584
|
+
` ${route}:`,
|
|
8585
|
+
` displayName: Divergent (${options.surface})`,
|
|
8586
|
+
` api: ${api}`,
|
|
8587
|
+
` baseURL: ${endpoint}`,
|
|
8588
|
+
` apiKeyEnv: ${tokenEnv}`,
|
|
8589
|
+
" 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
|
+
]),
|
|
8596
|
+
"- id: agent-default-model",
|
|
8597
|
+
" config:",
|
|
8598
|
+
` provider: ${route}`,
|
|
8290
8599
|
` model: ${JSON.stringify(options.defaultModel)}`,
|
|
8291
8600
|
// dsh's native DeepSeek adapter needs a vendor key nobody here holds and,
|
|
8292
8601
|
// where one exists, would send the organization's code straight to the
|
|
@@ -8299,9 +8608,33 @@ function dshPatchYaml(options) {
|
|
|
8299
8608
|
"- id: session-telemetry-otel",
|
|
8300
8609
|
" disabled: true",
|
|
8301
8610
|
...dshSearchRows(),
|
|
8611
|
+
...dshShellRows(),
|
|
8612
|
+
...dshBrowserRows(),
|
|
8302
8613
|
""
|
|
8303
8614
|
].join("\n");
|
|
8304
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
|
+
}
|
|
8305
8638
|
function dshSearchRows() {
|
|
8306
8639
|
return [
|
|
8307
8640
|
"- id: web-search-deepseek",
|
|
@@ -8350,17 +8683,17 @@ var DSH_USER_PRESETS_DIR = ".agent-presets";
|
|
|
8350
8683
|
function dshPackageDir(binary) {
|
|
8351
8684
|
if (/\.(cmd|bat)$/i.test(binary)) {
|
|
8352
8685
|
const dir2 = path6.join(path6.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
|
|
8353
|
-
return
|
|
8686
|
+
return fs5.existsSync(path6.join(dir2, "package.json")) ? dir2 : null;
|
|
8354
8687
|
}
|
|
8355
8688
|
let dir;
|
|
8356
8689
|
try {
|
|
8357
|
-
dir = path6.dirname(
|
|
8690
|
+
dir = path6.dirname(fs5.realpathSync(binary));
|
|
8358
8691
|
} catch {
|
|
8359
8692
|
return null;
|
|
8360
8693
|
}
|
|
8361
8694
|
for (; ; ) {
|
|
8362
8695
|
try {
|
|
8363
|
-
if (JSON.parse(
|
|
8696
|
+
if (JSON.parse(fs5.readFileSync(path6.join(dir, "package.json"), "utf8")).name === "@deepseek-ai/dsh") return dir;
|
|
8364
8697
|
} catch {
|
|
8365
8698
|
}
|
|
8366
8699
|
const parent = path6.dirname(dir);
|
|
@@ -8372,7 +8705,7 @@ function shippedPresetDir(packageDir, id = "standard") {
|
|
|
8372
8705
|
try {
|
|
8373
8706
|
const require2 = createRequire(path6.join(packageDir, "package.json"));
|
|
8374
8707
|
const dir = path6.join(path6.dirname(require2.resolve("@deepseek-ai/dsh-agent-presets/package.json")), "presets", id);
|
|
8375
|
-
return
|
|
8708
|
+
return fs5.existsSync(path6.join(dir, "agent.cordis.yml")) ? dir : null;
|
|
8376
8709
|
} catch {
|
|
8377
8710
|
return null;
|
|
8378
8711
|
}
|
|
@@ -8410,7 +8743,7 @@ var DIVERGENT_PRESET_METADATA = [
|
|
|
8410
8743
|
].join("\n");
|
|
8411
8744
|
function writeDivergentPreset(home, shippedDir) {
|
|
8412
8745
|
const dir = path6.join(home, DSH_USER_PRESETS_DIR, DIVERGENT_PRESET_ID);
|
|
8413
|
-
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);
|
|
8414
8747
|
writeTextAtomic(path6.join(dir, "preset.yml"), DIVERGENT_PRESET_METADATA, 420);
|
|
8415
8748
|
return dir;
|
|
8416
8749
|
}
|
|
@@ -8434,7 +8767,12 @@ function mergeOpencodeConfig(existing, options) {
|
|
|
8434
8767
|
const config = structuredClone(existing ?? {});
|
|
8435
8768
|
config.$schema ??= "https://opencode.ai/config.json";
|
|
8436
8769
|
const providers = { ...config.provider ?? {} };
|
|
8437
|
-
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
|
+
}]));
|
|
8438
8776
|
const options_ = { baseURL: `${options.baseUrl}/v1`, apiKey: `{env:${tokenEnv}}` };
|
|
8439
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 };
|
|
8440
8778
|
config.provider = providers;
|
|
@@ -8443,26 +8781,10 @@ function mergeOpencodeConfig(existing, options) {
|
|
|
8443
8781
|
|
|
8444
8782
|
// src/agents/run-dsh.ts
|
|
8445
8783
|
import { spawn as spawn2 } from "node:child_process";
|
|
8446
|
-
import
|
|
8784
|
+
import fs6 from "node:fs";
|
|
8447
8785
|
import path8 from "node:path";
|
|
8448
|
-
function findOnPath(name, env = process.env, platform = process.platform) {
|
|
8449
|
-
const dirs = (env.PATH ?? "").split(path8.delimiter).filter(Boolean);
|
|
8450
|
-
const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
8451
|
-
const candidates = platform === "win32" ? extensions.map((extension) => `${name}${extension.toLowerCase()}`) : [name];
|
|
8452
|
-
for (const dir of dirs) {
|
|
8453
|
-
for (const candidate of candidates) {
|
|
8454
|
-
const full = path8.join(dir, candidate);
|
|
8455
|
-
try {
|
|
8456
|
-
fs5.accessSync(full, fs5.constants.X_OK);
|
|
8457
|
-
if (fs5.statSync(full).isFile()) return full;
|
|
8458
|
-
} catch {
|
|
8459
|
-
}
|
|
8460
|
-
}
|
|
8461
|
-
}
|
|
8462
|
-
return null;
|
|
8463
|
-
}
|
|
8464
8786
|
function writeDshToken(credentialsPath, accessToken) {
|
|
8465
|
-
const existing =
|
|
8787
|
+
const existing = fs6.existsSync(credentialsPath) ? fs6.readFileSync(credentialsPath, "utf8") : null;
|
|
8466
8788
|
let merged;
|
|
8467
8789
|
try {
|
|
8468
8790
|
merged = mergeDshCredentials(existing, accessToken);
|
|
@@ -8471,6 +8793,33 @@ function writeDshToken(credentialsPath, accessToken) {
|
|
|
8471
8793
|
}
|
|
8472
8794
|
writeTextAtomic(credentialsPath, merged, 384);
|
|
8473
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
|
+
}
|
|
8474
8823
|
function dshArgs(overlayPath, args) {
|
|
8475
8824
|
const rest = args.includes("--profile") ? args : args.length === 0 ? ["--profile", "web"] : ["--profile", "headless", ...args];
|
|
8476
8825
|
return ["--patch", overlayPath, ...rest];
|
|
@@ -8480,7 +8829,7 @@ function dshLaunch(binary, args, platform = process.platform, execPath = process
|
|
|
8480
8829
|
const packageDir = path8.join(path8.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
|
|
8481
8830
|
let bin;
|
|
8482
8831
|
try {
|
|
8483
|
-
bin = JSON.parse(
|
|
8832
|
+
bin = JSON.parse(fs6.readFileSync(path8.join(packageDir, "package.json"), "utf8")).bin;
|
|
8484
8833
|
} catch {
|
|
8485
8834
|
throw new CliError(`${binary} is not an npm shim for @deepseek-ai/dsh (no ${packageDir}); reinstall: npm install -g @deepseek-ai/dsh`);
|
|
8486
8835
|
}
|
|
@@ -8503,9 +8852,14 @@ async function keepTokenFresh(loop) {
|
|
|
8503
8852
|
}
|
|
8504
8853
|
}
|
|
8505
8854
|
function runDsh(options) {
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
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);
|
|
8509
8863
|
const launch = dshLaunch(options.binary, dshArgs(options.overlayPath, options.args));
|
|
8510
8864
|
const child = spawn2(launch.command, launch.args, { env, stdio: "inherit" });
|
|
8511
8865
|
let exited = false;
|
|
@@ -8531,7 +8885,7 @@ function runDsh(options) {
|
|
|
8531
8885
|
process.on("SIGTERM", terminate);
|
|
8532
8886
|
const loop = keepTokenFresh({
|
|
8533
8887
|
freshToken: options.freshToken,
|
|
8534
|
-
write:
|
|
8888
|
+
write: writeToken,
|
|
8535
8889
|
isRunning: () => !exited,
|
|
8536
8890
|
sleep: (ms) => new Promise((resolve) => {
|
|
8537
8891
|
const timer = setTimeout(() => {
|
|
@@ -8552,6 +8906,26 @@ function runDsh(options) {
|
|
|
8552
8906
|
});
|
|
8553
8907
|
}
|
|
8554
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
|
+
|
|
8555
8929
|
// src/commands/skills.ts
|
|
8556
8930
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
8557
8931
|
|
|
@@ -8583,36 +8957,66 @@ The other skills installed beside this one are the organization's own
|
|
|
8583
8957
|
procedures; each names the tools it is about. Prefer a procedure over
|
|
8584
8958
|
guessing a tool.
|
|
8585
8959
|
|
|
8586
|
-
## Arguments:
|
|
8960
|
+
## Arguments: pipe them through stdin
|
|
8587
8961
|
|
|
8588
8962
|
Shells mangle JSON. Windows PowerShell strips the double quotes inside an
|
|
8589
8963
|
inline argument, so \`--args-json '{"a":"b"}'\` can arrive as \`{a:b}\`.
|
|
8590
|
-
|
|
8591
|
-
|
|
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:
|
|
8592
8966
|
|
|
8593
8967
|
\`\`\`bash
|
|
8594
|
-
diverge tools describe
|
|
8595
|
-
|
|
8596
|
-
{"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}
|
|
8597
8971
|
JSON
|
|
8598
|
-
diverge tools call divix-data-sync_implementation_search_source --args-file /tmp/args.json
|
|
8599
8972
|
\`\`\`
|
|
8600
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
|
+
|
|
8601
8978
|
## Read the outcome from stdout with --json
|
|
8602
8979
|
|
|
8603
8980
|
\`call --json\` prints exactly one JSON object on stdout whatever happens,
|
|
8604
8981
|
errors included: \`{"tool", "status", "result"?, "error"?, "invocationId"?,
|
|
8605
8982
|
"decideAt"?}\`, where status is executed, pending, rejected, expired or failed.
|
|
8606
|
-
|
|
8607
|
-
|
|
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.
|
|
8608
9011
|
|
|
8609
|
-
## Several calls at once
|
|
9012
|
+
## Several independent calls at once
|
|
8610
9013
|
|
|
8611
|
-
When a task needs a sequence of calls,
|
|
8612
|
-
once instead of one round trip each
|
|
8613
|
-
array of \`{"tool": "...", "args": {...}}
|
|
8614
|
-
order; each prints one JSON line of outcome, the same shape as
|
|
8615
|
-
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.
|
|
8616
9020
|
|
|
8617
9021
|
## Exit codes are the contract
|
|
8618
9022
|
|
|
@@ -8640,26 +9044,91 @@ cadence). Never decide your own invocation from any surface you can drive.
|
|
|
8640
9044
|
- \`--json\` on \`list\`, \`describe\` and \`invocation\` gives raw records.
|
|
8641
9045
|
`
|
|
8642
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
|
+
}
|
|
8643
9112
|
|
|
8644
9113
|
// src/skills/install.ts
|
|
8645
|
-
import
|
|
9114
|
+
import fs8 from "node:fs";
|
|
8646
9115
|
import os6 from "node:os";
|
|
8647
|
-
import
|
|
9116
|
+
import path10 from "node:path";
|
|
8648
9117
|
var HARNESSES = ["claude", "codex", "dsh"];
|
|
8649
9118
|
var SKILLS_MANIFEST = ".diverge-skills.json";
|
|
8650
9119
|
function skillsRoot(harness, env = process.env) {
|
|
8651
9120
|
switch (harness) {
|
|
8652
9121
|
case "claude":
|
|
8653
|
-
return
|
|
9122
|
+
return path10.join(env.CLAUDE_CONFIG_DIR?.trim() || path10.join(os6.homedir(), ".claude"), "skills");
|
|
8654
9123
|
case "codex":
|
|
8655
|
-
return
|
|
9124
|
+
return path10.join(env.CODEX_HOME?.trim() || path10.join(os6.homedir(), ".codex"), "skills");
|
|
8656
9125
|
case "dsh":
|
|
8657
|
-
return
|
|
9126
|
+
return path10.join(dshHome(env), "skills");
|
|
8658
9127
|
}
|
|
8659
9128
|
}
|
|
8660
9129
|
function readSkillsManifest(root) {
|
|
8661
9130
|
try {
|
|
8662
|
-
const parsed = JSON.parse(
|
|
9131
|
+
const parsed = JSON.parse(fs8.readFileSync(path10.join(root, SKILLS_MANIFEST), "utf8"));
|
|
8663
9132
|
if (parsed && typeof parsed === "object" && typeof parsed.skills === "object") return parsed;
|
|
8664
9133
|
} catch {
|
|
8665
9134
|
}
|
|
@@ -8676,7 +9145,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8676
9145
|
const updated = [];
|
|
8677
9146
|
for (const skill of skills) {
|
|
8678
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`);
|
|
8679
|
-
writeTextAtomic(
|
|
9148
|
+
writeTextAtomic(path10.join(root, skill.name, "SKILL.md"), skill.content, 420);
|
|
8680
9149
|
written.push(skill.name);
|
|
8681
9150
|
if (!(skill.name in held)) added.push(skill.name);
|
|
8682
9151
|
else if (held[skill.name] !== skill.updatedAt) updated.push(skill.name);
|
|
@@ -8684,7 +9153,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8684
9153
|
const removed = [];
|
|
8685
9154
|
for (const name of Object.keys(previous?.skills ?? {})) {
|
|
8686
9155
|
if (skills.some((skill) => skill.name === name)) continue;
|
|
8687
|
-
|
|
9156
|
+
fs8.rmSync(path10.join(root, name), { recursive: true, force: true });
|
|
8688
9157
|
removed.push(name);
|
|
8689
9158
|
}
|
|
8690
9159
|
const manifest = {
|
|
@@ -8692,7 +9161,7 @@ function installSkills(root, skills, source, now = () => /* @__PURE__ */ new Dat
|
|
|
8692
9161
|
source,
|
|
8693
9162
|
skills: Object.fromEntries(skills.map((skill) => [skill.name, skill.updatedAt]))
|
|
8694
9163
|
};
|
|
8695
|
-
writeJsonAtomic(
|
|
9164
|
+
writeJsonAtomic(path10.join(root, SKILLS_MANIFEST), manifest, 420);
|
|
8696
9165
|
return { root, written, added, updated, removed };
|
|
8697
9166
|
}
|
|
8698
9167
|
function skillsStatus(root, skills) {
|
|
@@ -8702,7 +9171,7 @@ function skillsStatus(root, skills) {
|
|
|
8702
9171
|
const behind = [];
|
|
8703
9172
|
const missing = [];
|
|
8704
9173
|
for (const skill of skills) {
|
|
8705
|
-
if (!(skill.name in held) || !
|
|
9174
|
+
if (!(skill.name in held) || !fs8.existsSync(path10.join(root, skill.name, "SKILL.md"))) missing.push(skill.name);
|
|
8706
9175
|
else if (held[skill.name] !== skill.updatedAt) behind.push(skill.name);
|
|
8707
9176
|
else current.push(skill.name);
|
|
8708
9177
|
}
|
|
@@ -8724,7 +9193,7 @@ async function fetchInstallableSkills(baseUrl, accessToken) {
|
|
|
8724
9193
|
var skillsUsage = `diverge skills <list|install|status> [--harness claude,codex,dsh] [--into <dir>]
|
|
8725
9194
|
|
|
8726
9195
|
list the skills the platform serves you: your organization's skills whose tools you can run
|
|
8727
|
-
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
|
|
8728
9197
|
(~/.claude/skills, ~/.codex/skills, $DSH_HOME/skills); retires the ones the organization retired;
|
|
8729
9198
|
reports what changed \u2014 the full list is \`skills list\`
|
|
8730
9199
|
status what each folder holds against what the platform serves now
|
|
@@ -8736,7 +9205,7 @@ async function installableSkillSet(apiUrl, env) {
|
|
|
8736
9205
|
const organizationId = tokenClaims(token.access_token).organizationId;
|
|
8737
9206
|
if (!organizationId) throw new CliError("The login has no default organization; run: diverge org use <id|name>");
|
|
8738
9207
|
const served = await fetchInstallableSkills(apiUrl, token.access_token);
|
|
8739
|
-
return { skills:
|
|
9208
|
+
return { skills: served.skills, organizationId };
|
|
8740
9209
|
}
|
|
8741
9210
|
function harnessesOf(flag) {
|
|
8742
9211
|
if (!flag) return [...HARNESSES];
|
|
@@ -8746,7 +9215,7 @@ function harnessesOf(flag) {
|
|
|
8746
9215
|
}
|
|
8747
9216
|
function installForHarness(io, harness, skills, apiUrl, into) {
|
|
8748
9217
|
const root = into ?? skillsRoot(harness, io.env);
|
|
8749
|
-
const result = installSkills(root, skills, apiUrl);
|
|
9218
|
+
const result = installSkills(root, [...bundledSkills(harness), ...skills], apiUrl);
|
|
8750
9219
|
const changes = [
|
|
8751
9220
|
...result.added.length ? [`${result.added.length} new: ${few(result.added)}`] : [],
|
|
8752
9221
|
...result.updated.length ? [`${result.updated.length} updated: ${few(result.updated)}`] : [],
|
|
@@ -8761,8 +9230,8 @@ async function runSkills(args, io) {
|
|
|
8761
9230
|
switch (verb) {
|
|
8762
9231
|
case "list": {
|
|
8763
9232
|
const { skills, organizationId } = await installableSkillSet(apiUrl, io.env);
|
|
8764
|
-
io.stdout(`Skills the platform serves you at organization ${organizationId}:`);
|
|
8765
|
-
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)"}`);
|
|
8766
9235
|
return ExitCode.Ok;
|
|
8767
9236
|
}
|
|
8768
9237
|
case "install": {
|
|
@@ -8775,7 +9244,7 @@ async function runSkills(args, io) {
|
|
|
8775
9244
|
const { skills } = await installableSkillSet(apiUrl, io.env);
|
|
8776
9245
|
let behind = false;
|
|
8777
9246
|
for (const harness of harnessesOf(values.harness)) {
|
|
8778
|
-
const status2 = skillsStatus(values.into ?? skillsRoot(harness, io.env), skills);
|
|
9247
|
+
const status2 = skillsStatus(values.into ?? skillsRoot(harness, io.env), [...bundledSkills(harness), ...skills]);
|
|
8779
9248
|
const parts = [`${status2.current.length} current`];
|
|
8780
9249
|
if (status2.behind.length) parts.push(`${status2.behind.length} behind (${few(status2.behind)})`);
|
|
8781
9250
|
if (status2.missing.length) parts.push(`${status2.missing.length} missing${status2.current.length || status2.behind.length ? ` (${few(status2.missing)})` : ""}`);
|
|
@@ -8793,9 +9262,9 @@ async function runSkills(args, io) {
|
|
|
8793
9262
|
|
|
8794
9263
|
// src/agents/rotate.ts
|
|
8795
9264
|
import os7 from "node:os";
|
|
8796
|
-
import
|
|
9265
|
+
import path11 from "node:path";
|
|
8797
9266
|
function defaultTokenFilePath() {
|
|
8798
|
-
return
|
|
9267
|
+
return path11.join(os7.homedir(), ".divergent", "token");
|
|
8799
9268
|
}
|
|
8800
9269
|
var MIN_ROTATE_INTERVAL_SECONDS = 60;
|
|
8801
9270
|
async function rotateTokenFile(loop) {
|
|
@@ -8810,19 +9279,19 @@ async function rotateTokenFile(loop) {
|
|
|
8810
9279
|
}
|
|
8811
9280
|
|
|
8812
9281
|
// src/agents/self-command.ts
|
|
8813
|
-
import
|
|
8814
|
-
import
|
|
9282
|
+
import fs9 from "node:fs";
|
|
9283
|
+
import path12 from "node:path";
|
|
8815
9284
|
function resolveSelfCommand(argv = process.argv, platform = process.platform, execPath = process.execPath) {
|
|
8816
9285
|
const script = argv[1];
|
|
8817
9286
|
if (!script) return { command: execPath, args: [] };
|
|
8818
9287
|
if (platform !== "win32") {
|
|
8819
9288
|
try {
|
|
8820
|
-
|
|
8821
|
-
return { command:
|
|
9289
|
+
fs9.accessSync(script, fs9.constants.X_OK);
|
|
9290
|
+
return { command: path12.resolve(script), args: [] };
|
|
8822
9291
|
} catch {
|
|
8823
9292
|
}
|
|
8824
9293
|
}
|
|
8825
|
-
return { command: execPath, args: [
|
|
9294
|
+
return { command: execPath, args: [fs9.realpathSync(script)] };
|
|
8826
9295
|
}
|
|
8827
9296
|
function shellCommand(self, ...trailing) {
|
|
8828
9297
|
return [self.command, ...self.args, ...trailing].map((part) => /[\s"]/.test(part) ? `"${part.replace(/"/g, '\\"')}"` : part).join(" ");
|
|
@@ -8849,11 +9318,11 @@ function surfaceOf(value, fallback) {
|
|
|
8849
9318
|
throw new CliError(`--surface must be one of: ${SURFACES.join(", ")}`);
|
|
8850
9319
|
}
|
|
8851
9320
|
function readJson(file) {
|
|
8852
|
-
if (!
|
|
8853
|
-
return JSON.parse(
|
|
9321
|
+
if (!fs10.existsSync(file)) return null;
|
|
9322
|
+
return JSON.parse(fs10.readFileSync(file, "utf8"));
|
|
8854
9323
|
}
|
|
8855
9324
|
async function servedModels(apiUrl, token, surface) {
|
|
8856
|
-
return (await listModels(apiUrl, token.access_token, surface)).map(
|
|
9325
|
+
return (await listModels(apiUrl, token.access_token, surface)).map(servedModel);
|
|
8857
9326
|
}
|
|
8858
9327
|
function syncDivergentPreset(io, binary, home) {
|
|
8859
9328
|
if (!binary) {
|
|
@@ -8867,8 +9336,8 @@ function syncDivergentPreset(io, binary, home) {
|
|
|
8867
9336
|
return;
|
|
8868
9337
|
}
|
|
8869
9338
|
const dir = writeDivergentPreset(home, shipped);
|
|
8870
|
-
const settingsPath =
|
|
8871
|
-
const settings = withDivergentPresetDefault(
|
|
9339
|
+
const settingsPath = path13.join(home, "settings.yaml");
|
|
9340
|
+
const settings = withDivergentPresetDefault(fs10.existsSync(settingsPath) ? fs10.readFileSync(settingsPath, "utf8") : null);
|
|
8872
9341
|
if (settings !== null) writeTextAtomic(settingsPath, settings);
|
|
8873
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" : ""}.`);
|
|
8874
9343
|
}
|
|
@@ -8881,11 +9350,12 @@ async function skillsFor(io, apiUrl, harness) {
|
|
|
8881
9350
|
}
|
|
8882
9351
|
}
|
|
8883
9352
|
async function overlayAndDefault(apiUrl, token, surface, io, requested) {
|
|
8884
|
-
const
|
|
9353
|
+
const served = await servedModels(apiUrl, token, surface);
|
|
9354
|
+
const models = served.map((model) => model.id);
|
|
8885
9355
|
if (models.length === 0) throw new CliError(`the gateway serves no models on the ${surface} surface for this organization`);
|
|
8886
9356
|
if (requested && !models.includes(requested)) throw new CliError(`${requested} is not served on the ${surface} surface; choose one of: ${models.join(", ")}`);
|
|
8887
9357
|
const defaultModel = dshDefaultModel(models, requested);
|
|
8888
|
-
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 };
|
|
8889
9359
|
}
|
|
8890
9360
|
function organizationArgs(organizationId) {
|
|
8891
9361
|
const trimmed = organizationId?.trim();
|
|
@@ -8939,7 +9409,7 @@ async function setup(args, io) {
|
|
|
8939
9409
|
}
|
|
8940
9410
|
const token = await ensureInferenceLogin(io, apiUrl, values["organization-id"]);
|
|
8941
9411
|
const file = values.config ?? codexConfigPath();
|
|
8942
|
-
const existing =
|
|
9412
|
+
const existing = fs10.existsSync(file) ? fs10.readFileSync(file, "utf8") : null;
|
|
8943
9413
|
writeTextAtomic(file, mergeCodexConfig(existing, block));
|
|
8944
9414
|
io.stdout(`Codex provider divergent \u2192 ${openaiBaseUrl(apiUrl)} as you, organization ${tokenClaims(token.access_token).organizationId}. Wrote ${file}.`);
|
|
8945
9415
|
io.stdout('Select it per run with: codex -c model_provider=divergent (or set model_provider = "divergent" in the config)');
|
|
@@ -8956,7 +9426,7 @@ async function setup(args, io) {
|
|
|
8956
9426
|
io.stdout(overlay.trimEnd());
|
|
8957
9427
|
return ExitCode.Ok;
|
|
8958
9428
|
}
|
|
8959
|
-
const file = values.into ??
|
|
9429
|
+
const file = values.into ?? path13.join(dshHome(io.env), `divergent-${surface}.yml`);
|
|
8960
9430
|
writeTextAtomic(file, overlay);
|
|
8961
9431
|
io.stdout(`dsh route divergent-${surface} \u2192 ${surfaceBaseUrl(apiUrl, surface)} as you, organization ${tokenClaims(token.access_token).organizationId}, default model ${defaultModel}. Wrote ${file}.`);
|
|
8962
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.");
|
|
@@ -8985,16 +9455,16 @@ async function run(args, io) {
|
|
|
8985
9455
|
await skillsFor(io, apiUrl, "dsh");
|
|
8986
9456
|
const { overlay, defaultModel } = await overlayAndDefault(apiUrl, token, surface, io, values.model);
|
|
8987
9457
|
const home = dshHome(io.env);
|
|
8988
|
-
const settingsPath =
|
|
9458
|
+
const settingsPath = path13.join(home, "settings.yaml");
|
|
8989
9459
|
let pinned;
|
|
8990
9460
|
try {
|
|
8991
|
-
pinned = dshSettingsDefaultModel(
|
|
9461
|
+
pinned = dshSettingsDefaultModel(fs10.existsSync(settingsPath) ? fs10.readFileSync(settingsPath, "utf8") : null, surface);
|
|
8992
9462
|
} catch (error) {
|
|
8993
9463
|
throw new CliError(`${settingsPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8994
9464
|
}
|
|
8995
9465
|
const served = servedIds(overlay);
|
|
8996
9466
|
if (pinned && !served.includes(pinned)) throw new CliError(stalePinMessage(settingsPath, pinned, surface, served));
|
|
8997
|
-
const overlayPath =
|
|
9467
|
+
const overlayPath = path13.join(home, `divergent-${surface}.yml`);
|
|
8998
9468
|
writeTextAtomic(overlayPath, overlay);
|
|
8999
9469
|
syncDivergentPreset(io, binary, home);
|
|
9000
9470
|
io.stderr(`dsh on divergent-${surface} as you (organization ${tokenClaims(token.access_token).organizationId}), default model ${defaultModel}`);
|
|
@@ -9003,7 +9473,10 @@ async function run(args, io) {
|
|
|
9003
9473
|
return runDsh({
|
|
9004
9474
|
binary,
|
|
9005
9475
|
overlayPath,
|
|
9006
|
-
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])] },
|
|
9007
9480
|
args: passthrough,
|
|
9008
9481
|
env: io.env,
|
|
9009
9482
|
initialToken: token.access_token,
|
|
@@ -9026,7 +9499,7 @@ async function status(args, io) {
|
|
|
9026
9499
|
io.stdout(`Organization: ${claims.organizationId}`);
|
|
9027
9500
|
io.stdout(`Scopes: ${(claims.scopes ?? []).join(" ")}`);
|
|
9028
9501
|
for (const surface of SURFACES) {
|
|
9029
|
-
const models = await servedModels(apiUrl, token, surface);
|
|
9502
|
+
const models = (await servedModels(apiUrl, token, surface)).map((model) => model.id);
|
|
9030
9503
|
io.stdout(`Models (${surface}): ${models.length ? models.join(", ") : "(none served on this surface)"}`);
|
|
9031
9504
|
}
|
|
9032
9505
|
return ExitCode.Ok;
|
|
@@ -9078,6 +9551,7 @@ there, which proves you may act in it. For one command, pass
|
|
|
9078
9551
|
--organization-id <id> (or set DIVERGENT_ORG_ID) instead. A platform actor may
|
|
9079
9552
|
act in, and so sees, every organization.`;
|
|
9080
9553
|
async function runOrg(args, io) {
|
|
9554
|
+
refuseInSession(io.env, "org");
|
|
9081
9555
|
const { positionals } = parseArgs4({ args, options: {}, strict: true, allowPositionals: true });
|
|
9082
9556
|
const verb = positionals[0];
|
|
9083
9557
|
if (verb && verb !== "use") throw unknownVerb("org", orgUsage, [], verb, positionals.slice(1));
|
|
@@ -9088,107 +9562,60 @@ async function runOrg(args, io) {
|
|
|
9088
9562
|
if (!verb) {
|
|
9089
9563
|
if (organizations.length === 0) {
|
|
9090
9564
|
io.stdout("You are not a member of any organization.");
|
|
9091
|
-
return 0;
|
|
9092
|
-
}
|
|
9093
|
-
for (const organization of organizations) io.stdout(`${organization.id === current ? "*" : " "} ${organization.name} (${organization.id})`);
|
|
9094
|
-
return 0;
|
|
9095
|
-
}
|
|
9096
|
-
const target = positionals[1];
|
|
9097
|
-
if (!target) throw new CliError("org use needs an organization id or name");
|
|
9098
|
-
const choice = chooseOrganization({ flag: target, organizations });
|
|
9099
|
-
if (choice.kind !== "chosen") throw new CliError("org use needs an organization id or name");
|
|
9100
|
-
const token = await useOrganization(source, choice.organizationId);
|
|
9101
|
-
io.stdout(`Default organization: ${choice.name ? `${choice.name} (${choice.organizationId})` : choice.organizationId}; scopes ${(tokenClaims(token.access_token).scopes ?? []).join(" ") || "none"}`);
|
|
9102
|
-
return 0;
|
|
9103
|
-
}
|
|
9104
|
-
|
|
9105
|
-
// src/commands/logout.ts
|
|
9106
|
-
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.";
|
|
9107
|
-
async function runLogout(_args, io) {
|
|
9108
|
-
const source = tokenSource(io.env, resolveApiUrl(void 0, io.env));
|
|
9109
|
-
const token = loadLogin(source);
|
|
9110
|
-
if (!token) {
|
|
9111
|
-
io.stdout(`Not logged in to ${source.baseUrl}.`);
|
|
9112
|
-
return 0;
|
|
9113
|
-
}
|
|
9114
|
-
if (token.refresh_token) {
|
|
9115
|
-
try {
|
|
9116
|
-
await revokeRefreshToken(source.baseUrl, source.clientId, token.refresh_token);
|
|
9117
|
-
} catch (error) {
|
|
9118
|
-
io.stderr(`warning: could not revoke the session on ${source.baseUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9119
|
-
}
|
|
9120
|
-
}
|
|
9121
|
-
forgetLogin(source);
|
|
9122
|
-
io.stdout(`Logged out of ${source.baseUrl}.`);
|
|
9123
|
-
return 0;
|
|
9124
|
-
}
|
|
9125
|
-
|
|
9126
|
-
// src/commands/status.ts
|
|
9127
|
-
import path13 from "node:path";
|
|
9128
|
-
|
|
9129
|
-
// src/tools/settings.ts
|
|
9130
|
-
var BRIDGE_SCOPES = "mcp:read mcp:execute";
|
|
9131
|
-
var LOGIN_HINT = "diverge login";
|
|
9132
|
-
function loadToolsSettings(options, env = process.env) {
|
|
9133
|
-
const apiUrl = resolveApiUrl(void 0, env);
|
|
9134
|
-
const projectId = options.projectId?.trim() || env.DIVERGENT_PROJECT_ID?.trim() || void 0;
|
|
9135
|
-
let organizationId = options.organizationId?.trim() || env.DIVERGENT_ORG_ID?.trim() || "";
|
|
9136
|
-
const cached = loadLogin(tokenSource(env, apiUrl));
|
|
9137
|
-
if (cached) {
|
|
9138
|
-
organizationId ||= cached.organization ?? "";
|
|
9139
|
-
if (!organizationId) throw new CliError(`The login has no default organization. Pass --organization-id or choose one: diverge org use <id|name>`);
|
|
9140
|
-
return { apiUrl, organizationId, projectId, mode: "operator", clientId: clientId(env) };
|
|
9141
|
-
}
|
|
9142
|
-
const serviceClientId = env.DIVERGENT_CLIENT_ID?.trim() ?? "";
|
|
9143
|
-
const serviceClientSecret = env.DIVERGENT_CLIENT_SECRET?.trim() ?? "";
|
|
9144
|
-
const delegatedUserId = env.DIVERGENT_USER_ID?.trim() ?? "";
|
|
9145
|
-
if (!serviceClientId || !serviceClientSecret) {
|
|
9146
|
-
throw noLogin(apiUrl, "Or, unattended, set DIVERGENT_CLIENT_ID, DIVERGENT_CLIENT_SECRET, DIVERGENT_USER_ID and DIVERGENT_ORG_ID.");
|
|
9147
|
-
}
|
|
9148
|
-
if (!organizationId) throw new CliError("Service credentials act in the organization named: pass --organization-id or set DIVERGENT_ORG_ID.");
|
|
9149
|
-
if (!delegatedUserId) {
|
|
9150
|
-
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.
|
|
9151
|
-
Signing in as yourself avoids this entirely: ${LOGIN_HINT}`);
|
|
9565
|
+
return 0;
|
|
9566
|
+
}
|
|
9567
|
+
for (const organization of organizations) io.stdout(`${organization.id === current ? "*" : " "} ${organization.name} (${organization.id})`);
|
|
9568
|
+
return 0;
|
|
9152
9569
|
}
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9570
|
+
const target = positionals[1];
|
|
9571
|
+
if (!target) throw new CliError("org use needs an organization id or name");
|
|
9572
|
+
const choice = chooseOrganization({ flag: target, organizations });
|
|
9573
|
+
if (choice.kind !== "chosen") throw new CliError("org use needs an organization id or name");
|
|
9574
|
+
const token = await useOrganization(source, choice.organizationId);
|
|
9575
|
+
io.stdout(`Default organization: ${choice.name ? `${choice.name} (${choice.organizationId})` : choice.organizationId}; scopes ${(tokenClaims(token.access_token).scopes ?? []).join(" ") || "none"}`);
|
|
9576
|
+
return 0;
|
|
9157
9577
|
}
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
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;
|
|
9162
9588
|
}
|
|
9163
|
-
|
|
9164
|
-
let accessToken;
|
|
9589
|
+
if (token.refresh_token) {
|
|
9165
9590
|
try {
|
|
9166
|
-
|
|
9591
|
+
await revokeRefreshToken(source.baseUrl, source.clientId, token.refresh_token);
|
|
9167
9592
|
} catch (error) {
|
|
9168
|
-
|
|
9593
|
+
io.stderr(`warning: could not revoke the session on ${source.baseUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9169
9594
|
}
|
|
9170
|
-
return `Acting as: ${await describeAccount(settings.apiUrl, accessToken, tokenClaims(accessToken).sub)}`;
|
|
9171
|
-
})();
|
|
9172
|
-
return actingAs;
|
|
9173
|
-
}
|
|
9174
|
-
function describeToolExecution(env = process.env) {
|
|
9175
|
-
let settings;
|
|
9176
|
-
try {
|
|
9177
|
-
settings = loadToolsSettings({}, env);
|
|
9178
|
-
} catch (error) {
|
|
9179
|
-
return `Tool execution: unavailable \u2014 ${error instanceof CliError ? error.message.split("\n")[0] : String(error)}`;
|
|
9180
9595
|
}
|
|
9181
|
-
|
|
9596
|
+
forgetLogin(source);
|
|
9597
|
+
io.stdout(`Logged out of ${source.baseUrl}.`);
|
|
9598
|
+
return 0;
|
|
9182
9599
|
}
|
|
9183
9600
|
|
|
9184
9601
|
// src/commands/status.ts
|
|
9185
|
-
|
|
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.";
|
|
9186
9604
|
async function runStatus(_args, io) {
|
|
9187
9605
|
const apiUrl = resolveApiUrl(void 0, io.env);
|
|
9188
9606
|
const source = tokenSource(io.env, apiUrl);
|
|
9189
9607
|
io.stdout(`diverge ${VERSION}`);
|
|
9190
9608
|
io.stdout(`Deployment: ${apiUrl}`);
|
|
9191
|
-
|
|
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)}`);
|
|
9192
9619
|
const record = loadLogin(source);
|
|
9193
9620
|
if (!record) {
|
|
9194
9621
|
io.stdout(`Not logged in. Run: diverge login${apiUrl === DEFAULT_API_URL ? "" : ` --api-url ${apiUrl}`}`);
|
|
@@ -9241,7 +9668,9 @@ var tokenUsage = `diverge token [--organization-id <id>]
|
|
|
9241
9668
|
|
|
9242
9669
|
Print a fresh access token and nothing else: the credential helper for Claude
|
|
9243
9670
|
Code, Codex and forge. The token is for the organization named by
|
|
9244
|
-
--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.`;
|
|
9245
9674
|
async function runToken(args, io) {
|
|
9246
9675
|
const { values } = parseArgs5({ args, options: { "organization-id": { type: "string" } }, strict: true, allowPositionals: false });
|
|
9247
9676
|
const organizationId = values["organization-id"]?.trim() || io.env.DIVERGENT_ORG_ID?.trim() || void 0;
|
|
@@ -9255,177 +9684,11 @@ import { parseArgs as parseArgs6 } from "node:util";
|
|
|
9255
9684
|
|
|
9256
9685
|
// src/mcp/bridge.ts
|
|
9257
9686
|
import readline2 from "node:readline";
|
|
9258
|
-
|
|
9259
|
-
// src/tools/client.ts
|
|
9260
|
-
var PENDING_INVOCATION_STATUSES = ["pending", "approved", "executing"];
|
|
9261
|
-
function isPending(result) {
|
|
9262
|
-
return !!result && typeof result === "object" && result.status === "pending_approval";
|
|
9263
|
-
}
|
|
9264
|
-
var REQUEST_TIMEOUT_MS = 12e4;
|
|
9265
|
-
var TOKEN_REFRESH_MARGIN_SECONDS = 60;
|
|
9266
|
-
var ToolsClient = class {
|
|
9267
|
-
constructor(settings, env = process.env, fetchImpl = fetch) {
|
|
9268
|
-
this.settings = settings;
|
|
9269
|
-
this.env = env;
|
|
9270
|
-
this.fetchImpl = fetchImpl;
|
|
9271
|
-
}
|
|
9272
|
-
settings;
|
|
9273
|
-
env;
|
|
9274
|
-
fetchImpl;
|
|
9275
|
-
serviceToken = null;
|
|
9276
|
-
async token() {
|
|
9277
|
-
if (this.settings.mode === "operator") {
|
|
9278
|
-
return (await getUserToken(tokenSource(this.env, this.settings.apiUrl), { organizationId: this.settings.organizationId })).access_token;
|
|
9279
|
-
}
|
|
9280
|
-
if (this.serviceToken && Date.now() < this.serviceToken.expiresAtMs) return this.serviceToken.value;
|
|
9281
|
-
let response;
|
|
9282
|
-
try {
|
|
9283
|
-
response = await this.fetchImpl(tokenEndpoint(this.settings.apiUrl), {
|
|
9284
|
-
method: "POST",
|
|
9285
|
-
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
9286
|
-
body: JSON.stringify({
|
|
9287
|
-
grant_type: "client_credentials",
|
|
9288
|
-
client_id: this.settings.serviceClientId,
|
|
9289
|
-
client_secret: this.settings.serviceClientSecret,
|
|
9290
|
-
scopes: BRIDGE_SCOPES,
|
|
9291
|
-
organization_id: this.settings.organizationId
|
|
9292
|
-
}),
|
|
9293
|
-
signal: AbortSignal.timeout(3e4)
|
|
9294
|
-
});
|
|
9295
|
-
} catch (error) {
|
|
9296
|
-
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9297
|
-
}
|
|
9298
|
-
if (!response.ok) throw new CliError(`Token acquisition failed (${response.status}): ${(await response.text()).slice(0, 400)}`);
|
|
9299
|
-
const body = await response.json();
|
|
9300
|
-
if (!body.access_token) throw new CliError("Token response contained no access_token");
|
|
9301
|
-
const expiresIn = Number(body.expires_in ?? 3600);
|
|
9302
|
-
this.serviceToken = { value: body.access_token, expiresAtMs: Date.now() + Math.max(expiresIn - TOKEN_REFRESH_MARGIN_SECONDS, 30) * 1e3 };
|
|
9303
|
-
return body.access_token;
|
|
9304
|
-
}
|
|
9305
|
-
async headers() {
|
|
9306
|
-
const headers = { Authorization: `Bearer ${await this.token()}`, "Content-Type": "application/json", "User-Agent": USER_AGENT };
|
|
9307
|
-
if (this.settings.mode === "service") headers["x-divergent-user-id"] = this.settings.delegatedUserId;
|
|
9308
|
-
return headers;
|
|
9309
|
-
}
|
|
9310
|
-
scoped(path15) {
|
|
9311
|
-
const query = new URLSearchParams({ organizationId: this.settings.organizationId });
|
|
9312
|
-
if (this.settings.projectId) query.set("projectId", this.settings.projectId);
|
|
9313
|
-
return `${this.settings.apiUrl}${path15}?${query.toString()}`;
|
|
9314
|
-
}
|
|
9315
|
-
async send(method, url, body) {
|
|
9316
|
-
return this.request(method, url, body, void 0);
|
|
9317
|
-
}
|
|
9318
|
-
/**
|
|
9319
|
-
* One request, re-authenticated once on 401 in service mode. `refused`
|
|
9320
|
-
* turns a chosen status into a value instead of an error, for the
|
|
9321
|
-
* outcomes a caller acts on (a manifest the platform would not accept).
|
|
9322
|
-
*/
|
|
9323
|
-
async request(method, url, body, refused) {
|
|
9324
|
-
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
9325
|
-
const headers = await this.headers();
|
|
9326
|
-
let response;
|
|
9327
|
-
try {
|
|
9328
|
-
response = await this.fetchImpl(url, { method, headers, body: body === void 0 ? void 0 : JSON.stringify(body), signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
9329
|
-
} catch (error) {
|
|
9330
|
-
throw new CliError(`Cannot reach ${this.settings.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9331
|
-
}
|
|
9332
|
-
if (response.status === 401 && attempt === 1 && this.settings.mode === "service") {
|
|
9333
|
-
this.serviceToken = null;
|
|
9334
|
-
continue;
|
|
9335
|
-
}
|
|
9336
|
-
const text = await response.text();
|
|
9337
|
-
if (!response.ok) {
|
|
9338
|
-
const handled = refused?.(response.status, text);
|
|
9339
|
-
if (handled !== void 0) return handled;
|
|
9340
|
-
let message = text;
|
|
9341
|
-
try {
|
|
9342
|
-
const parsed = JSON.parse(text);
|
|
9343
|
-
if (typeof parsed.error === "string" && parsed.error) message = parsed.error;
|
|
9344
|
-
} catch {
|
|
9345
|
-
}
|
|
9346
|
-
if (response.status === 403 && /scope/i.test(message)) {
|
|
9347
|
-
throw new CliError(`${response.status}: ${message}
|
|
9348
|
-
The signed-in token is missing a required scope. Re-run: ${LOGIN_HINT}`);
|
|
9349
|
-
}
|
|
9350
|
-
throw new CliError(`${response.status}: ${message}`.slice(0, 2e3));
|
|
9351
|
-
}
|
|
9352
|
-
return text ? JSON.parse(text) : {};
|
|
9353
|
-
}
|
|
9354
|
-
throw new CliError("Request failed after re-authentication");
|
|
9355
|
-
}
|
|
9356
|
-
async listTools() {
|
|
9357
|
-
const body = await this.send("GET", this.scoped("/api/plugins/functions/tools"));
|
|
9358
|
-
return body.tools ?? [];
|
|
9359
|
-
}
|
|
9360
|
-
/**
|
|
9361
|
-
* One tool, looked up at its source when the catalog does not list it yet —
|
|
9362
|
-
* a tool deployed after its server's catalog was read. A 404 is an answer.
|
|
9363
|
-
*/
|
|
9364
|
-
describeTool(name) {
|
|
9365
|
-
return this.request("GET", this.scoped(`/api/plugins/functions/tools/${encodeURIComponent(name)}`), void 0, (status2, text) => {
|
|
9366
|
-
if (status2 !== 404) return void 0;
|
|
9367
|
-
try {
|
|
9368
|
-
const parsed = JSON.parse(text);
|
|
9369
|
-
if (typeof parsed.error === "string" && parsed.error) return { notFound: parsed.error };
|
|
9370
|
-
} catch {
|
|
9371
|
-
}
|
|
9372
|
-
return { notFound: `No tool named '${name}' is available.` };
|
|
9373
|
-
});
|
|
9374
|
-
}
|
|
9375
|
-
/**
|
|
9376
|
-
* One call. The platform answers a completed call with its invocation
|
|
9377
|
-
* envelope, `{status: 'succeeded', invocationId?, result}`; the tool's own
|
|
9378
|
-
* payload is `result` inside it. Every caller wants the payload, so it is
|
|
9379
|
-
* unwrapped here, once — a pending approval passes through as it is.
|
|
9380
|
-
*/
|
|
9381
|
-
async callTool(name, args) {
|
|
9382
|
-
const body = await this.send("POST", this.scoped("/api/plugins/functions/tools/execute"), { toolName: name, arguments: args ?? {} });
|
|
9383
|
-
const outcome = body.result;
|
|
9384
|
-
if (outcome?.status !== "succeeded") return body;
|
|
9385
|
-
return { ...body, result: outcome.result };
|
|
9386
|
-
}
|
|
9387
|
-
/** The read half of raise-and-read (ADR 0047); anyone but the raiser sees a 404. */
|
|
9388
|
-
getInvocation(invocationId) {
|
|
9389
|
-
return this.send("GET", this.scoped(`/api/plugins/functions/tools/invocations/${encodeURIComponent(invocationId)}`));
|
|
9390
|
-
}
|
|
9391
|
-
// ── Tenant plugins (RFC: Tenant Plugins) ──────────────────────────────
|
|
9392
|
-
descriptorsUrl(pluginId) {
|
|
9393
|
-
const base = `${this.settings.apiUrl}/api/plugins/forge/plugins/descriptors${pluginId ? `/${encodeURIComponent(pluginId)}` : ""}`;
|
|
9394
|
-
return `${base}?${new URLSearchParams({ targetOrganizationId: this.settings.organizationId }).toString()}`;
|
|
9395
|
-
}
|
|
9396
|
-
/** Validate (dryRun) or publish a manifest for the organization the login is issued to. */
|
|
9397
|
-
publishPlugin(manifest, options) {
|
|
9398
|
-
return this.request(
|
|
9399
|
-
"POST",
|
|
9400
|
-
this.descriptorsUrl(),
|
|
9401
|
-
{ targetOrganizationId: this.settings.organizationId, manifest, dryRun: options.dryRun },
|
|
9402
|
-
(status2, text) => {
|
|
9403
|
-
if (status2 !== 400) return void 0;
|
|
9404
|
-
try {
|
|
9405
|
-
const parsed = JSON.parse(text);
|
|
9406
|
-
if (Array.isArray(parsed.details)) return { ok: false, details: parsed.details.map(String) };
|
|
9407
|
-
return { ok: false, details: [parsed.error ?? text] };
|
|
9408
|
-
} catch {
|
|
9409
|
-
return { ok: false, details: [text] };
|
|
9410
|
-
}
|
|
9411
|
-
}
|
|
9412
|
-
).then((outcome) => "ok" in outcome ? outcome : { ok: true, result: outcome });
|
|
9413
|
-
}
|
|
9414
|
-
async listPlugins() {
|
|
9415
|
-
const body = await this.send("GET", this.descriptorsUrl());
|
|
9416
|
-
return body.plugins ?? [];
|
|
9417
|
-
}
|
|
9418
|
-
async retirePlugin(pluginId) {
|
|
9419
|
-
const body = await this.send("DELETE", this.descriptorsUrl(pluginId), { targetOrganizationId: this.settings.organizationId });
|
|
9420
|
-
return body.plugin;
|
|
9421
|
-
}
|
|
9422
|
-
};
|
|
9423
|
-
|
|
9424
|
-
// src/mcp/bridge.ts
|
|
9425
9687
|
var PROTOCOL_VERSION = "2025-06-18";
|
|
9426
9688
|
var SERVER_NAME = "divergent-tools";
|
|
9427
9689
|
var SERVER_VERSION = "1.0.0";
|
|
9428
9690
|
var INVOCATION_STATUS_TOOL = "divergent_invocation_status";
|
|
9691
|
+
var SUBMIT_SET_TOOL = "divergent_submit_set";
|
|
9429
9692
|
var PARSE_ERROR = -32700;
|
|
9430
9693
|
var INVALID_REQUEST = -32600;
|
|
9431
9694
|
var METHOD_NOT_FOUND = -32601;
|
|
@@ -9444,6 +9707,32 @@ function invocationStatusTool() {
|
|
|
9444
9707
|
annotations: { readOnlyHint: true }
|
|
9445
9708
|
};
|
|
9446
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
|
+
}
|
|
9447
9736
|
function mcpTool(tool) {
|
|
9448
9737
|
let description = tool.description ?? "";
|
|
9449
9738
|
if (tool.riskLevel === "high" || tool.riskLevel === "medium") description = `[${tool.riskLevel} risk] ${description}`;
|
|
@@ -9481,11 +9770,11 @@ var BridgeServer = class {
|
|
|
9481
9770
|
/**
|
|
9482
9771
|
* An allowlist keeps a harness's context to the tools it was given: the
|
|
9483
9772
|
* whole catalog is tens of thousands of tokens on every request. The
|
|
9484
|
-
* bridge's own
|
|
9485
|
-
* 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.
|
|
9486
9775
|
*/
|
|
9487
9776
|
exposes(name) {
|
|
9488
|
-
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);
|
|
9489
9778
|
}
|
|
9490
9779
|
/** One JSON-RPC message in, one out; null for a notification. The transport never dies on a handler failure. */
|
|
9491
9780
|
async handle(request) {
|
|
@@ -9499,7 +9788,7 @@ var BridgeServer = class {
|
|
|
9499
9788
|
return { jsonrpc: "2.0", id, result: {} };
|
|
9500
9789
|
case "tools/list": {
|
|
9501
9790
|
const tools = (await this.client.listTools()).filter((tool) => this.exposes(tool.name)).map(mcpTool);
|
|
9502
|
-
tools.push(invocationStatusTool());
|
|
9791
|
+
tools.push(submitSetTool(), invocationStatusTool());
|
|
9503
9792
|
return { jsonrpc: "2.0", id, result: { tools } };
|
|
9504
9793
|
}
|
|
9505
9794
|
case "tools/call": {
|
|
@@ -9508,7 +9797,7 @@ var BridgeServer = class {
|
|
|
9508
9797
|
if (typeof name !== "string" || !name) return rpcError(id, INVALID_REQUEST, "Missing tool name");
|
|
9509
9798
|
if (!this.exposes(name)) return { jsonrpc: "2.0", id, result: { content: textContent(`${name} is not exposed by this bridge`), isError: true } };
|
|
9510
9799
|
const args = params.arguments ?? {};
|
|
9511
|
-
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);
|
|
9512
9801
|
return { jsonrpc: "2.0", id, result };
|
|
9513
9802
|
}
|
|
9514
9803
|
default:
|
|
@@ -9518,11 +9807,26 @@ var BridgeServer = class {
|
|
|
9518
9807
|
return rpcError(id, INTERNAL_ERROR, error instanceof CliError ? error.message : `Bridge failure: ${error instanceof Error ? error.message : String(error)}`);
|
|
9519
9808
|
}
|
|
9520
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
|
+
}
|
|
9521
9822
|
/** A denied or failed tool call is a result the agent should reason about, not a transport error. */
|
|
9522
|
-
|
|
9823
|
+
call(name, args) {
|
|
9824
|
+
return this.settle(() => this.client.callTool(name, args));
|
|
9825
|
+
}
|
|
9826
|
+
async settle(send) {
|
|
9523
9827
|
let body;
|
|
9524
9828
|
try {
|
|
9525
|
-
body = await
|
|
9829
|
+
body = await send();
|
|
9526
9830
|
} catch (error) {
|
|
9527
9831
|
if (error instanceof CliError) return { content: textContent(error.message), isError: true };
|
|
9528
9832
|
throw error;
|
|
@@ -9603,7 +9907,7 @@ async function waitForInvocation(id, options, deps) {
|
|
|
9603
9907
|
}
|
|
9604
9908
|
|
|
9605
9909
|
// src/tools/call-args.ts
|
|
9606
|
-
import
|
|
9910
|
+
import fs11 from "node:fs";
|
|
9607
9911
|
async function resolveCallArgs(options, stdin = readStdin) {
|
|
9608
9912
|
if (options.argsJson !== void 0 && options.argsJson !== "{}" && options.argsFile !== void 0) {
|
|
9609
9913
|
throw new CliError("give the arguments once: --args-json or --args-file");
|
|
@@ -9613,7 +9917,7 @@ async function resolveCallArgs(options, stdin = readStdin) {
|
|
|
9613
9917
|
if (options.argsFile !== void 0) {
|
|
9614
9918
|
source = `--args-file ${options.argsFile}`;
|
|
9615
9919
|
try {
|
|
9616
|
-
text =
|
|
9920
|
+
text = fs11.readFileSync(options.argsFile, "utf8");
|
|
9617
9921
|
} catch (error) {
|
|
9618
9922
|
throw new CliError(`${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9619
9923
|
}
|
|
@@ -9686,7 +9990,7 @@ function outcomeOf(tool, invocationId, invocation) {
|
|
|
9686
9990
|
case "expired":
|
|
9687
9991
|
return { tool, status: "expired", invocationId };
|
|
9688
9992
|
case "failed":
|
|
9689
|
-
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 } : {} };
|
|
9690
9994
|
default:
|
|
9691
9995
|
return null;
|
|
9692
9996
|
}
|
|
@@ -9705,7 +10009,7 @@ function worstExitCode(outcomes) {
|
|
|
9705
10009
|
}
|
|
9706
10010
|
|
|
9707
10011
|
// src/commands/tools.ts
|
|
9708
|
-
import
|
|
10012
|
+
import fs12 from "node:fs";
|
|
9709
10013
|
|
|
9710
10014
|
// src/tools/print.ts
|
|
9711
10015
|
function matchesCapability(selector, capability) {
|
|
@@ -9777,7 +10081,7 @@ function formatPending(result, apiUrl, organizationId) {
|
|
|
9777
10081
|
}
|
|
9778
10082
|
|
|
9779
10083
|
// src/commands/tools.ts
|
|
9780
|
-
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>] ...
|
|
9781
10085
|
|
|
9782
10086
|
list [--filter <text>] [--capability <selector>] [--json]
|
|
9783
10087
|
--filter searches tool names and descriptions, ignoring case
|
|
@@ -9787,9 +10091,15 @@ var toolsUsage = `diverge tools <list|capabilities|describe|call|run|invocation|
|
|
|
9787
10091
|
arguments inline, from stdin (-), or from a file: PowerShell strips quotes inside inline JSON
|
|
9788
10092
|
--json prints exactly one JSON object on stdout, errors included:
|
|
9789
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.
|
|
9790
10099
|
run <file|-> [--wait] [--timeout <seconds>]
|
|
9791
|
-
several calls from one file
|
|
9792
|
-
|
|
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
|
|
9793
10103
|
invocation <id> [--wait] [--timeout <seconds>] [--json]
|
|
9794
10104
|
--json prints the invocation record; the exit code is call's for the same status
|
|
9795
10105
|
bridge [--tools <name,name>] (stdio MCP server; the allowlist keeps a harness to the tools it was given)
|
|
@@ -9845,6 +10155,38 @@ async function call(rest, io) {
|
|
|
9845
10155
|
else printOutcome(outcome, waited, io);
|
|
9846
10156
|
return worstExitCode([outcome]);
|
|
9847
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)) };
|
|
10185
|
+
}
|
|
10186
|
+
if (json) io.stdout(JSON.stringify(outcome, null, 2));
|
|
10187
|
+
else printOutcome(outcome, waited, io);
|
|
10188
|
+
return worstExitCode([outcome]);
|
|
10189
|
+
}
|
|
9848
10190
|
function printOutcome(outcome, waited, io) {
|
|
9849
10191
|
switch (outcome.status) {
|
|
9850
10192
|
case "executed":
|
|
@@ -9860,6 +10202,7 @@ function printOutcome(outcome, waited, io) {
|
|
|
9860
10202
|
io.stderr("Expired before anyone decided. Raise a fresh call; the old id is final.");
|
|
9861
10203
|
return;
|
|
9862
10204
|
case "failed":
|
|
10205
|
+
if (outcome.result !== void 0) io.stdout(JSON.stringify(outcome.result, null, 2));
|
|
9863
10206
|
throw new CliError(outcome.invocationId ? `Approved, but execution failed: ${outcome.error}` : outcome.error || "Tool execution failed");
|
|
9864
10207
|
}
|
|
9865
10208
|
}
|
|
@@ -9902,13 +10245,15 @@ async function runTools(args, io) {
|
|
|
9902
10245
|
}
|
|
9903
10246
|
case "call":
|
|
9904
10247
|
return call(rest, io);
|
|
10248
|
+
case "set":
|
|
10249
|
+
return set(rest, io);
|
|
9905
10250
|
case "run": {
|
|
9906
10251
|
const { values, positionals } = parseArgs6({ args: rest, options: { ...SCOPE_OPTIONS, wait: { type: "boolean", default: false }, timeout: { type: "string", default: "600" } }, strict: true, allowPositionals: true });
|
|
9907
10252
|
const file = positionals[0];
|
|
9908
10253
|
if (!file) throw new CliError("run needs a file of calls, or - for stdin");
|
|
9909
10254
|
let entries;
|
|
9910
10255
|
try {
|
|
9911
|
-
entries = parseBatch(file === "-" ? await readStdin() :
|
|
10256
|
+
entries = parseBatch(file === "-" ? await readStdin() : fs12.readFileSync(file, "utf8"));
|
|
9912
10257
|
} catch (error) {
|
|
9913
10258
|
throw new CliError(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9914
10259
|
}
|
|
@@ -9952,7 +10297,7 @@ async function runTools(args, io) {
|
|
|
9952
10297
|
}
|
|
9953
10298
|
|
|
9954
10299
|
// src/commands/plugins.ts
|
|
9955
|
-
import
|
|
10300
|
+
import fs13 from "node:fs";
|
|
9956
10301
|
import { parseArgs as parseArgs7 } from "node:util";
|
|
9957
10302
|
var pluginsUsage = `diverge plugins <validate|publish|list|retire> [--organization-id <id>] ...
|
|
9958
10303
|
|
|
@@ -9979,7 +10324,7 @@ function readManifest(file) {
|
|
|
9979
10324
|
${pluginsUsage}`);
|
|
9980
10325
|
let text;
|
|
9981
10326
|
try {
|
|
9982
|
-
text =
|
|
10327
|
+
text = fs13.readFileSync(file, "utf8");
|
|
9983
10328
|
} catch (error) {
|
|
9984
10329
|
throw new CliError(`Cannot read ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
9985
10330
|
}
|
|
@@ -9998,7 +10343,8 @@ function formatPlugin(plugin) {
|
|
|
9998
10343
|
`${plugin.pluginId}@${plugin.version} ${plugin.name} (${parent}; runtime ${plugin.runtimeType}; digest ${plugin.digest.slice(0, 12)})`,
|
|
9999
10344
|
` tools: ${plugin.toolNames.length ? plugin.toolNames.join(", ") : "none"}`,
|
|
10000
10345
|
...plugin.resourceNames.length ? [` resources: ${plugin.resourceNames.join(", ")}`] : [],
|
|
10001
|
-
...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}`)] : []
|
|
10002
10348
|
];
|
|
10003
10349
|
}
|
|
10004
10350
|
async function runPlugins(args, io) {
|
|
@@ -10066,19 +10412,20 @@ ${pluginsUsage}`);
|
|
|
10066
10412
|
|
|
10067
10413
|
// src/commands/update.ts
|
|
10068
10414
|
import { spawn as spawn4 } from "node:child_process";
|
|
10415
|
+
import path16 from "node:path";
|
|
10069
10416
|
|
|
10070
10417
|
// src/update-notice.ts
|
|
10071
10418
|
import { spawn as spawn3 } from "node:child_process";
|
|
10072
|
-
import
|
|
10073
|
-
import
|
|
10419
|
+
import fs14 from "node:fs";
|
|
10420
|
+
import path15 from "node:path";
|
|
10074
10421
|
var UPDATE_CHECK_FILE = "update-check.json";
|
|
10075
10422
|
var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
10076
10423
|
function updateCheckFile(env) {
|
|
10077
|
-
return
|
|
10424
|
+
return path15.join(configDir(env), UPDATE_CHECK_FILE);
|
|
10078
10425
|
}
|
|
10079
10426
|
function readUpdateCheck(env) {
|
|
10080
10427
|
try {
|
|
10081
|
-
const parsed = JSON.parse(
|
|
10428
|
+
const parsed = JSON.parse(fs14.readFileSync(updateCheckFile(env), "utf8"));
|
|
10082
10429
|
if (parsed && typeof parsed === "object" && typeof parsed.checkedAt === "number" && typeof parsed.latest === "string") return parsed;
|
|
10083
10430
|
} catch {
|
|
10084
10431
|
}
|
|
@@ -10093,7 +10440,7 @@ function noticeFor(check, version = VERSION) {
|
|
|
10093
10440
|
}
|
|
10094
10441
|
function noticeApplies(argv, io, version = VERSION) {
|
|
10095
10442
|
if (version === "dev" || !io.interactive) return false;
|
|
10096
|
-
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;
|
|
10097
10444
|
if (argv[0] === "update") return false;
|
|
10098
10445
|
if (argv[0] === "tools" && argv[1] === "bridge") return false;
|
|
10099
10446
|
return true;
|
|
@@ -10141,6 +10488,7 @@ function isNewer(a, b) {
|
|
|
10141
10488
|
return x.pre > y.pre;
|
|
10142
10489
|
}
|
|
10143
10490
|
async function runUpdate(args, io, deps = { latestVersion, install: installLatest, record: writeUpdateCheck, now: Date.now }) {
|
|
10491
|
+
refuseInSession(io.env, "update");
|
|
10144
10492
|
if (args[0] === "--record") {
|
|
10145
10493
|
try {
|
|
10146
10494
|
deps.record(io.env, { checkedAt: deps.now(), latest: await deps.latestVersion() });
|
|
@@ -10160,10 +10508,20 @@ async function runUpdate(args, io, deps = { latestVersion, install: installLates
|
|
|
10160
10508
|
io.stdout(`diverge ${latest} installed.`);
|
|
10161
10509
|
return ExitCode.Ok;
|
|
10162
10510
|
}
|
|
10163
|
-
function installLatest(version) {
|
|
10164
|
-
|
|
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
|
+
}
|
|
10165
10523
|
return new Promise((resolve, reject) => {
|
|
10166
|
-
const child = spawn4(
|
|
10524
|
+
const child = spawn4(command, args, { env, stdio: "inherit" });
|
|
10167
10525
|
child.on("error", reject);
|
|
10168
10526
|
child.on("exit", (code2) => resolve(code2 ?? 1));
|
|
10169
10527
|
});
|
|
@@ -10194,7 +10552,7 @@ function usage() {
|
|
|
10194
10552
|
...lines,
|
|
10195
10553
|
"",
|
|
10196
10554
|
"Run `diverge <command> --help` for its options.",
|
|
10197
|
-
"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)."
|
|
10198
10556
|
].join("\n");
|
|
10199
10557
|
}
|
|
10200
10558
|
async function run2(argv, io) {
|
|
@@ -10217,9 +10575,9 @@ ${usage()}`);
|
|
|
10217
10575
|
}
|
|
10218
10576
|
const own = rest.includes("--") ? rest.slice(0, rest.indexOf("--")) : rest;
|
|
10219
10577
|
if (own.includes("--help") || own.includes("-h")) {
|
|
10220
|
-
const
|
|
10221
|
-
if (
|
|
10222
|
-
io.stdout(verbUsage(command.name, command.usage,
|
|
10578
|
+
const path17 = verbPath(command.usage, own);
|
|
10579
|
+
if (path17.length > 0 || own[0].startsWith("-")) {
|
|
10580
|
+
io.stdout(verbUsage(command.name, command.usage, path17));
|
|
10223
10581
|
return ExitCode.Ok;
|
|
10224
10582
|
}
|
|
10225
10583
|
}
|