@promptframe/creation 0.3.11 → 0.3.13
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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +7 -1
- package/dist/cli.mjs +1142 -658
- package/docs/install-guidance.json +15 -1
- package/docs/installing.md +15 -3
- package/lib/account-bridge.mjs +4 -3
- package/lib/antigravity-host-session.mjs +159 -0
- package/lib/antigravity-installation.mjs +200 -0
- package/lib/cli.mjs +22 -8
- package/lib/connection.mjs +14 -3
- package/lib/host-context.mjs +5 -5
- package/lib/host-identity.mjs +14 -7
- package/lib/local-accounts.mjs +30 -2
- package/lib/runtime-bootstrap.mjs +2 -1
- package/lib/runtime-launch.mjs +2 -1
- package/lib/runtime-package.mjs +3 -1
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/creation-setup/SKILL.md +8 -4
package/dist/cli.mjs
CHANGED
|
@@ -407,11 +407,11 @@ var require_codegen = __commonJS({
|
|
|
407
407
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
408
408
|
return `${varKind} ${this.name}${rhs};` + _n2;
|
|
409
409
|
}
|
|
410
|
-
optimizeNames(names,
|
|
410
|
+
optimizeNames(names, constants9) {
|
|
411
411
|
if (!names[this.name.str])
|
|
412
412
|
return;
|
|
413
413
|
if (this.rhs)
|
|
414
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
414
|
+
this.rhs = optimizeExpr(this.rhs, names, constants9);
|
|
415
415
|
return this;
|
|
416
416
|
}
|
|
417
417
|
get names() {
|
|
@@ -428,10 +428,10 @@ var require_codegen = __commonJS({
|
|
|
428
428
|
render({ _n: _n2 }) {
|
|
429
429
|
return `${this.lhs} = ${this.rhs};` + _n2;
|
|
430
430
|
}
|
|
431
|
-
optimizeNames(names,
|
|
431
|
+
optimizeNames(names, constants9) {
|
|
432
432
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
433
433
|
return;
|
|
434
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
434
|
+
this.rhs = optimizeExpr(this.rhs, names, constants9);
|
|
435
435
|
return this;
|
|
436
436
|
}
|
|
437
437
|
get names() {
|
|
@@ -470,9 +470,9 @@ var require_codegen = __commonJS({
|
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
472
|
var Throw = class extends Node {
|
|
473
|
-
constructor(
|
|
473
|
+
constructor(error6) {
|
|
474
474
|
super();
|
|
475
|
-
this.error =
|
|
475
|
+
this.error = error6;
|
|
476
476
|
}
|
|
477
477
|
render({ _n: _n2 }) {
|
|
478
478
|
return `throw ${this.error};` + _n2;
|
|
@@ -492,8 +492,8 @@ var require_codegen = __commonJS({
|
|
|
492
492
|
optimizeNodes() {
|
|
493
493
|
return `${this.code}` ? this : void 0;
|
|
494
494
|
}
|
|
495
|
-
optimizeNames(names,
|
|
496
|
-
this.code = optimizeExpr(this.code, names,
|
|
495
|
+
optimizeNames(names, constants9) {
|
|
496
|
+
this.code = optimizeExpr(this.code, names, constants9);
|
|
497
497
|
return this;
|
|
498
498
|
}
|
|
499
499
|
get names() {
|
|
@@ -522,12 +522,12 @@ var require_codegen = __commonJS({
|
|
|
522
522
|
}
|
|
523
523
|
return nodes.length > 0 ? this : void 0;
|
|
524
524
|
}
|
|
525
|
-
optimizeNames(names,
|
|
525
|
+
optimizeNames(names, constants9) {
|
|
526
526
|
const { nodes } = this;
|
|
527
527
|
let i = nodes.length;
|
|
528
528
|
while (i--) {
|
|
529
529
|
const n = nodes[i];
|
|
530
|
-
if (n.optimizeNames(names,
|
|
530
|
+
if (n.optimizeNames(names, constants9))
|
|
531
531
|
continue;
|
|
532
532
|
subtractNames(names, n.names);
|
|
533
533
|
nodes.splice(i, 1);
|
|
@@ -580,12 +580,12 @@ var require_codegen = __commonJS({
|
|
|
580
580
|
return void 0;
|
|
581
581
|
return this;
|
|
582
582
|
}
|
|
583
|
-
optimizeNames(names,
|
|
583
|
+
optimizeNames(names, constants9) {
|
|
584
584
|
var _a3;
|
|
585
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
586
|
-
if (!(super.optimizeNames(names,
|
|
585
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants9);
|
|
586
|
+
if (!(super.optimizeNames(names, constants9) || this.else))
|
|
587
587
|
return;
|
|
588
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
588
|
+
this.condition = optimizeExpr(this.condition, names, constants9);
|
|
589
589
|
return this;
|
|
590
590
|
}
|
|
591
591
|
get names() {
|
|
@@ -608,10 +608,10 @@ var require_codegen = __commonJS({
|
|
|
608
608
|
render(opts) {
|
|
609
609
|
return `for(${this.iteration})` + super.render(opts);
|
|
610
610
|
}
|
|
611
|
-
optimizeNames(names,
|
|
612
|
-
if (!super.optimizeNames(names,
|
|
611
|
+
optimizeNames(names, constants9) {
|
|
612
|
+
if (!super.optimizeNames(names, constants9))
|
|
613
613
|
return;
|
|
614
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
614
|
+
this.iteration = optimizeExpr(this.iteration, names, constants9);
|
|
615
615
|
return this;
|
|
616
616
|
}
|
|
617
617
|
get names() {
|
|
@@ -647,10 +647,10 @@ var require_codegen = __commonJS({
|
|
|
647
647
|
render(opts) {
|
|
648
648
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
649
649
|
}
|
|
650
|
-
optimizeNames(names,
|
|
651
|
-
if (!super.optimizeNames(names,
|
|
650
|
+
optimizeNames(names, constants9) {
|
|
651
|
+
if (!super.optimizeNames(names, constants9))
|
|
652
652
|
return;
|
|
653
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
653
|
+
this.iterable = optimizeExpr(this.iterable, names, constants9);
|
|
654
654
|
return this;
|
|
655
655
|
}
|
|
656
656
|
get names() {
|
|
@@ -692,11 +692,11 @@ var require_codegen = __commonJS({
|
|
|
692
692
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
693
693
|
return this;
|
|
694
694
|
}
|
|
695
|
-
optimizeNames(names,
|
|
695
|
+
optimizeNames(names, constants9) {
|
|
696
696
|
var _a3, _b;
|
|
697
|
-
super.optimizeNames(names,
|
|
698
|
-
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
699
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names,
|
|
697
|
+
super.optimizeNames(names, constants9);
|
|
698
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants9);
|
|
699
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants9);
|
|
700
700
|
return this;
|
|
701
701
|
}
|
|
702
702
|
get names() {
|
|
@@ -709,9 +709,9 @@ var require_codegen = __commonJS({
|
|
|
709
709
|
}
|
|
710
710
|
};
|
|
711
711
|
var Catch = class extends BlockNode {
|
|
712
|
-
constructor(
|
|
712
|
+
constructor(error6) {
|
|
713
713
|
super();
|
|
714
|
-
this.error =
|
|
714
|
+
this.error = error6;
|
|
715
715
|
}
|
|
716
716
|
render(opts) {
|
|
717
717
|
return `catch(${this.error})` + super.render(opts);
|
|
@@ -902,9 +902,9 @@ var require_codegen = __commonJS({
|
|
|
902
902
|
this._blockNode(node2);
|
|
903
903
|
this.code(tryBody);
|
|
904
904
|
if (catchCode) {
|
|
905
|
-
const
|
|
906
|
-
this._currNode = node2.catch = new Catch(
|
|
907
|
-
catchCode(
|
|
905
|
+
const error6 = this.name("e");
|
|
906
|
+
this._currNode = node2.catch = new Catch(error6);
|
|
907
|
+
catchCode(error6);
|
|
908
908
|
}
|
|
909
909
|
if (finallyCode) {
|
|
910
910
|
this._currNode = node2.finally = new Finally();
|
|
@@ -913,8 +913,8 @@ var require_codegen = __commonJS({
|
|
|
913
913
|
return this._endBlockNode(Catch, Finally);
|
|
914
914
|
}
|
|
915
915
|
// `throw` statement
|
|
916
|
-
throw(
|
|
917
|
-
return this._leafNode(new Throw(
|
|
916
|
+
throw(error6) {
|
|
917
|
+
return this._leafNode(new Throw(error6));
|
|
918
918
|
}
|
|
919
919
|
// start self-balancing block
|
|
920
920
|
block(body, nodeCount) {
|
|
@@ -997,7 +997,7 @@ var require_codegen = __commonJS({
|
|
|
997
997
|
function addExprNames(names, from) {
|
|
998
998
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
999
999
|
}
|
|
1000
|
-
function optimizeExpr(expr, names,
|
|
1000
|
+
function optimizeExpr(expr, names, constants9) {
|
|
1001
1001
|
if (expr instanceof code_1.Name)
|
|
1002
1002
|
return replaceName(expr);
|
|
1003
1003
|
if (!canOptimize(expr))
|
|
@@ -1012,14 +1012,14 @@ var require_codegen = __commonJS({
|
|
|
1012
1012
|
return items;
|
|
1013
1013
|
}, []));
|
|
1014
1014
|
function replaceName(n) {
|
|
1015
|
-
const c =
|
|
1015
|
+
const c = constants9[n.str];
|
|
1016
1016
|
if (c === void 0 || names[n.str] !== 1)
|
|
1017
1017
|
return n;
|
|
1018
1018
|
delete names[n.str];
|
|
1019
1019
|
return c;
|
|
1020
1020
|
}
|
|
1021
1021
|
function canOptimize(e) {
|
|
1022
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
1022
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants9[c.str] !== void 0);
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
1025
|
function subtractNames(names, from) {
|
|
@@ -1058,10 +1058,10 @@ var require_util = __commonJS({
|
|
|
1058
1058
|
var codegen_1 = require_codegen();
|
|
1059
1059
|
var code_1 = require_code();
|
|
1060
1060
|
function toHash(arr) {
|
|
1061
|
-
const
|
|
1061
|
+
const hash8 = {};
|
|
1062
1062
|
for (const item of arr)
|
|
1063
|
-
|
|
1064
|
-
return
|
|
1063
|
+
hash8[item] = true;
|
|
1064
|
+
return hash8;
|
|
1065
1065
|
}
|
|
1066
1066
|
exports.toHash = toHash;
|
|
1067
1067
|
function alwaysValidSchema(it2, schema) {
|
|
@@ -1270,10 +1270,10 @@ var require_errors = __commonJS({
|
|
|
1270
1270
|
exports.keyword$DataError = {
|
|
1271
1271
|
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
|
|
1272
1272
|
};
|
|
1273
|
-
function reportError(cxt,
|
|
1273
|
+
function reportError(cxt, error6 = exports.keywordError, errorPaths, overrideAllErrors) {
|
|
1274
1274
|
const { it: it2 } = cxt;
|
|
1275
1275
|
const { gen, compositeRule, allErrors } = it2;
|
|
1276
|
-
const errObj = errorObjectCode(cxt,
|
|
1276
|
+
const errObj = errorObjectCode(cxt, error6, errorPaths);
|
|
1277
1277
|
if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) {
|
|
1278
1278
|
addError(gen, errObj);
|
|
1279
1279
|
} else {
|
|
@@ -1281,10 +1281,10 @@ var require_errors = __commonJS({
|
|
|
1281
1281
|
}
|
|
1282
1282
|
}
|
|
1283
1283
|
exports.reportError = reportError;
|
|
1284
|
-
function reportExtraError(cxt,
|
|
1284
|
+
function reportExtraError(cxt, error6 = exports.keywordError, errorPaths) {
|
|
1285
1285
|
const { it: it2 } = cxt;
|
|
1286
1286
|
const { gen, compositeRule, allErrors } = it2;
|
|
1287
|
-
const errObj = errorObjectCode(cxt,
|
|
1287
|
+
const errObj = errorObjectCode(cxt, error6, errorPaths);
|
|
1288
1288
|
addError(gen, errObj);
|
|
1289
1289
|
if (!(compositeRule || allErrors)) {
|
|
1290
1290
|
returnErrors(it2, names_1.default.vErrors);
|
|
@@ -1335,19 +1335,19 @@ var require_errors = __commonJS({
|
|
|
1335
1335
|
schema: new codegen_1.Name("schema"),
|
|
1336
1336
|
parentSchema: new codegen_1.Name("parentSchema")
|
|
1337
1337
|
};
|
|
1338
|
-
function errorObjectCode(cxt,
|
|
1338
|
+
function errorObjectCode(cxt, error6, errorPaths) {
|
|
1339
1339
|
const { createErrors } = cxt.it;
|
|
1340
1340
|
if (createErrors === false)
|
|
1341
1341
|
return (0, codegen_1._)`{}`;
|
|
1342
|
-
return errorObject(cxt,
|
|
1342
|
+
return errorObject(cxt, error6, errorPaths);
|
|
1343
1343
|
}
|
|
1344
|
-
function errorObject(cxt,
|
|
1344
|
+
function errorObject(cxt, error6, errorPaths = {}) {
|
|
1345
1345
|
const { gen, it: it2 } = cxt;
|
|
1346
1346
|
const keyValues = [
|
|
1347
1347
|
errorInstancePath(it2, errorPaths),
|
|
1348
1348
|
errorSchemaPath(cxt, errorPaths)
|
|
1349
1349
|
];
|
|
1350
|
-
extraErrorProps(cxt,
|
|
1350
|
+
extraErrorProps(cxt, error6, keyValues);
|
|
1351
1351
|
return gen.object(...keyValues);
|
|
1352
1352
|
}
|
|
1353
1353
|
function errorInstancePath({ errorPath }, { instancePath }) {
|
|
@@ -3259,8 +3259,8 @@ var require_utils = __commonJS({
|
|
|
3259
3259
|
}
|
|
3260
3260
|
return ind;
|
|
3261
3261
|
}
|
|
3262
|
-
function removeDotSegments(
|
|
3263
|
-
let input =
|
|
3262
|
+
function removeDotSegments(path23) {
|
|
3263
|
+
let input = path23;
|
|
3264
3264
|
const output = [];
|
|
3265
3265
|
let nextSlash = -1;
|
|
3266
3266
|
let len = 0;
|
|
@@ -3349,9 +3349,9 @@ var require_utils = __commonJS({
|
|
|
3349
3349
|
let output = "";
|
|
3350
3350
|
for (let i = 0; i < input.length; i++) {
|
|
3351
3351
|
if (input[i] === "%" && i + 2 < input.length) {
|
|
3352
|
-
const
|
|
3353
|
-
if (isHexPair(
|
|
3354
|
-
const normalizedHex =
|
|
3352
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3353
|
+
if (isHexPair(hex3)) {
|
|
3354
|
+
const normalizedHex = hex3.toUpperCase();
|
|
3355
3355
|
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3356
3356
|
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
3357
3357
|
output += decoded;
|
|
@@ -3371,9 +3371,9 @@ var require_utils = __commonJS({
|
|
|
3371
3371
|
for (let i = 0; i < input.length; i++) {
|
|
3372
3372
|
const ch = input[i];
|
|
3373
3373
|
if (ch === "%" && i + 2 < input.length) {
|
|
3374
|
-
const
|
|
3375
|
-
if (isHexPair(
|
|
3376
|
-
const normalizedHex =
|
|
3374
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3375
|
+
if (isHexPair(hex3)) {
|
|
3376
|
+
const normalizedHex = hex3.toUpperCase();
|
|
3377
3377
|
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3378
3378
|
if (decoded !== "." && isUnreserved(decoded)) {
|
|
3379
3379
|
output += decoded;
|
|
@@ -3413,9 +3413,9 @@ var require_utils = __commonJS({
|
|
|
3413
3413
|
for (let i = 0; i < input.length; i++) {
|
|
3414
3414
|
const ch = input[i];
|
|
3415
3415
|
if (ch === "%" && i + 2 < input.length) {
|
|
3416
|
-
const
|
|
3417
|
-
if (isHexPair(
|
|
3418
|
-
output += "%" +
|
|
3416
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3417
|
+
if (isHexPair(hex3)) {
|
|
3418
|
+
output += "%" + hex3.toUpperCase();
|
|
3419
3419
|
i += 2;
|
|
3420
3420
|
continue;
|
|
3421
3421
|
}
|
|
@@ -3451,9 +3451,9 @@ var require_utils = __commonJS({
|
|
|
3451
3451
|
for (let i = 0; i < input.length; i++) {
|
|
3452
3452
|
const ch = input[i];
|
|
3453
3453
|
if (ch === "%" && i + 2 < input.length) {
|
|
3454
|
-
const
|
|
3455
|
-
if (isHexPair(
|
|
3456
|
-
output += "%" +
|
|
3454
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3455
|
+
if (isHexPair(hex3)) {
|
|
3456
|
+
output += "%" + hex3.toUpperCase();
|
|
3457
3457
|
i += 2;
|
|
3458
3458
|
continue;
|
|
3459
3459
|
}
|
|
@@ -3498,9 +3498,9 @@ var require_utils = __commonJS({
|
|
|
3498
3498
|
for (let i = 0; i < input.length; i++) {
|
|
3499
3499
|
const ch = input[i];
|
|
3500
3500
|
if (ch === "%" && i + 2 < input.length) {
|
|
3501
|
-
const
|
|
3502
|
-
if (isHexPair(
|
|
3503
|
-
const normalizedHex =
|
|
3501
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3502
|
+
if (isHexPair(hex3)) {
|
|
3503
|
+
const normalizedHex = hex3.toUpperCase();
|
|
3504
3504
|
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3505
3505
|
if (isUnreserved(decoded)) {
|
|
3506
3506
|
output += decoded;
|
|
@@ -3538,9 +3538,9 @@ var require_utils = __commonJS({
|
|
|
3538
3538
|
let output = "";
|
|
3539
3539
|
for (let i = 0; i < input.length; i++) {
|
|
3540
3540
|
if (input[i] === "%" && i + 2 < input.length) {
|
|
3541
|
-
const
|
|
3542
|
-
if (isHexPair(
|
|
3543
|
-
output += "%" +
|
|
3541
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3542
|
+
if (isHexPair(hex3)) {
|
|
3543
|
+
output += "%" + hex3.toUpperCase();
|
|
3544
3544
|
i += 2;
|
|
3545
3545
|
continue;
|
|
3546
3546
|
}
|
|
@@ -3669,8 +3669,8 @@ var require_schemes = __commonJS({
|
|
|
3669
3669
|
}
|
|
3670
3670
|
if (wsComponent.resourceName) {
|
|
3671
3671
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
3672
|
-
const
|
|
3673
|
-
wsComponent.path =
|
|
3672
|
+
const path23 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
3673
|
+
wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
|
|
3674
3674
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
3675
3675
|
wsComponent.resourceName = void 0;
|
|
3676
3676
|
}
|
|
@@ -5012,7 +5012,7 @@ var require_limitNumber = __commonJS({
|
|
|
5012
5012
|
exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
|
5013
5013
|
exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
|
|
5014
5014
|
};
|
|
5015
|
-
var
|
|
5015
|
+
var error6 = {
|
|
5016
5016
|
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
|
5017
5017
|
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
|
|
5018
5018
|
};
|
|
@@ -5021,7 +5021,7 @@ var require_limitNumber = __commonJS({
|
|
|
5021
5021
|
type: "number",
|
|
5022
5022
|
schemaType: "number",
|
|
5023
5023
|
$data: true,
|
|
5024
|
-
error:
|
|
5024
|
+
error: error6,
|
|
5025
5025
|
code(cxt) {
|
|
5026
5026
|
const { keyword, data, schemaCode } = cxt;
|
|
5027
5027
|
cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
|
@@ -5037,7 +5037,7 @@ var require_multipleOf = __commonJS({
|
|
|
5037
5037
|
"use strict";
|
|
5038
5038
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5039
5039
|
var codegen_1 = require_codegen();
|
|
5040
|
-
var
|
|
5040
|
+
var error6 = {
|
|
5041
5041
|
message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
|
|
5042
5042
|
params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
|
|
5043
5043
|
};
|
|
@@ -5046,7 +5046,7 @@ var require_multipleOf = __commonJS({
|
|
|
5046
5046
|
type: "number",
|
|
5047
5047
|
schemaType: "number",
|
|
5048
5048
|
$data: true,
|
|
5049
|
-
error:
|
|
5049
|
+
error: error6,
|
|
5050
5050
|
code(cxt) {
|
|
5051
5051
|
const { gen, data, schemaCode, it: it2 } = cxt;
|
|
5052
5052
|
const prec = it2.opts.multipleOfPrecision;
|
|
@@ -5093,7 +5093,7 @@ var require_limitLength = __commonJS({
|
|
|
5093
5093
|
var codegen_1 = require_codegen();
|
|
5094
5094
|
var util_1 = require_util();
|
|
5095
5095
|
var ucs2length_1 = require_ucs2length();
|
|
5096
|
-
var
|
|
5096
|
+
var error6 = {
|
|
5097
5097
|
message({ keyword, schemaCode }) {
|
|
5098
5098
|
const comp = keyword === "maxLength" ? "more" : "fewer";
|
|
5099
5099
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
|
|
@@ -5105,7 +5105,7 @@ var require_limitLength = __commonJS({
|
|
|
5105
5105
|
type: "string",
|
|
5106
5106
|
schemaType: "number",
|
|
5107
5107
|
$data: true,
|
|
5108
|
-
error:
|
|
5108
|
+
error: error6,
|
|
5109
5109
|
code(cxt) {
|
|
5110
5110
|
const { keyword, data, schemaCode, it: it2 } = cxt;
|
|
5111
5111
|
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -5125,7 +5125,7 @@ var require_pattern = __commonJS({
|
|
|
5125
5125
|
var code_1 = require_code2();
|
|
5126
5126
|
var util_1 = require_util();
|
|
5127
5127
|
var codegen_1 = require_codegen();
|
|
5128
|
-
var
|
|
5128
|
+
var error6 = {
|
|
5129
5129
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
5130
5130
|
params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
|
|
5131
5131
|
};
|
|
@@ -5134,7 +5134,7 @@ var require_pattern = __commonJS({
|
|
|
5134
5134
|
type: "string",
|
|
5135
5135
|
schemaType: "string",
|
|
5136
5136
|
$data: true,
|
|
5137
|
-
error:
|
|
5137
|
+
error: error6,
|
|
5138
5138
|
code(cxt) {
|
|
5139
5139
|
const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
|
|
5140
5140
|
const u2 = it2.opts.unicodeRegExp ? "u" : "";
|
|
@@ -5160,7 +5160,7 @@ var require_limitProperties = __commonJS({
|
|
|
5160
5160
|
"use strict";
|
|
5161
5161
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5162
5162
|
var codegen_1 = require_codegen();
|
|
5163
|
-
var
|
|
5163
|
+
var error6 = {
|
|
5164
5164
|
message({ keyword, schemaCode }) {
|
|
5165
5165
|
const comp = keyword === "maxProperties" ? "more" : "fewer";
|
|
5166
5166
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
|
|
@@ -5172,7 +5172,7 @@ var require_limitProperties = __commonJS({
|
|
|
5172
5172
|
type: "object",
|
|
5173
5173
|
schemaType: "number",
|
|
5174
5174
|
$data: true,
|
|
5175
|
-
error:
|
|
5175
|
+
error: error6,
|
|
5176
5176
|
code(cxt) {
|
|
5177
5177
|
const { keyword, data, schemaCode } = cxt;
|
|
5178
5178
|
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -5191,7 +5191,7 @@ var require_required = __commonJS({
|
|
|
5191
5191
|
var code_1 = require_code2();
|
|
5192
5192
|
var codegen_1 = require_codegen();
|
|
5193
5193
|
var util_1 = require_util();
|
|
5194
|
-
var
|
|
5194
|
+
var error6 = {
|
|
5195
5195
|
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
5196
5196
|
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
5197
5197
|
};
|
|
@@ -5200,7 +5200,7 @@ var require_required = __commonJS({
|
|
|
5200
5200
|
type: "object",
|
|
5201
5201
|
schemaType: "array",
|
|
5202
5202
|
$data: true,
|
|
5203
|
-
error:
|
|
5203
|
+
error: error6,
|
|
5204
5204
|
code(cxt) {
|
|
5205
5205
|
const { gen, schema, schemaCode, data, $data, it: it2 } = cxt;
|
|
5206
5206
|
const { opts } = it2;
|
|
@@ -5271,7 +5271,7 @@ var require_limitItems = __commonJS({
|
|
|
5271
5271
|
"use strict";
|
|
5272
5272
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5273
5273
|
var codegen_1 = require_codegen();
|
|
5274
|
-
var
|
|
5274
|
+
var error6 = {
|
|
5275
5275
|
message({ keyword, schemaCode }) {
|
|
5276
5276
|
const comp = keyword === "maxItems" ? "more" : "fewer";
|
|
5277
5277
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
|
|
@@ -5283,7 +5283,7 @@ var require_limitItems = __commonJS({
|
|
|
5283
5283
|
type: "array",
|
|
5284
5284
|
schemaType: "number",
|
|
5285
5285
|
$data: true,
|
|
5286
|
-
error:
|
|
5286
|
+
error: error6,
|
|
5287
5287
|
code(cxt) {
|
|
5288
5288
|
const { keyword, data, schemaCode } = cxt;
|
|
5289
5289
|
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -5314,7 +5314,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5314
5314
|
var codegen_1 = require_codegen();
|
|
5315
5315
|
var util_1 = require_util();
|
|
5316
5316
|
var equal_1 = require_equal();
|
|
5317
|
-
var
|
|
5317
|
+
var error6 = {
|
|
5318
5318
|
message: ({ params: { i, j: j2 } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j2} and ${i} are identical)`,
|
|
5319
5319
|
params: ({ params: { i, j: j2 } }) => (0, codegen_1._)`{i: ${i}, j: ${j2}}`
|
|
5320
5320
|
};
|
|
@@ -5323,7 +5323,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5323
5323
|
type: "array",
|
|
5324
5324
|
schemaType: "boolean",
|
|
5325
5325
|
$data: true,
|
|
5326
|
-
error:
|
|
5326
|
+
error: error6,
|
|
5327
5327
|
code(cxt) {
|
|
5328
5328
|
const { gen, data, $data, schema, parentSchema, schemaCode, it: it2 } = cxt;
|
|
5329
5329
|
if (!$data && !schema)
|
|
@@ -5380,14 +5380,14 @@ var require_const = __commonJS({
|
|
|
5380
5380
|
var codegen_1 = require_codegen();
|
|
5381
5381
|
var util_1 = require_util();
|
|
5382
5382
|
var equal_1 = require_equal();
|
|
5383
|
-
var
|
|
5383
|
+
var error6 = {
|
|
5384
5384
|
message: "must be equal to constant",
|
|
5385
5385
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
|
|
5386
5386
|
};
|
|
5387
5387
|
var def = {
|
|
5388
5388
|
keyword: "const",
|
|
5389
5389
|
$data: true,
|
|
5390
|
-
error:
|
|
5390
|
+
error: error6,
|
|
5391
5391
|
code(cxt) {
|
|
5392
5392
|
const { gen, data, $data, schemaCode, schema } = cxt;
|
|
5393
5393
|
if ($data || schema && typeof schema == "object") {
|
|
@@ -5409,7 +5409,7 @@ var require_enum = __commonJS({
|
|
|
5409
5409
|
var codegen_1 = require_codegen();
|
|
5410
5410
|
var util_1 = require_util();
|
|
5411
5411
|
var equal_1 = require_equal();
|
|
5412
|
-
var
|
|
5412
|
+
var error6 = {
|
|
5413
5413
|
message: "must be equal to one of the allowed values",
|
|
5414
5414
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
|
|
5415
5415
|
};
|
|
@@ -5417,7 +5417,7 @@ var require_enum = __commonJS({
|
|
|
5417
5417
|
keyword: "enum",
|
|
5418
5418
|
schemaType: "array",
|
|
5419
5419
|
$data: true,
|
|
5420
|
-
error:
|
|
5420
|
+
error: error6,
|
|
5421
5421
|
code(cxt) {
|
|
5422
5422
|
const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
|
|
5423
5423
|
if (!$data && schema.length === 0)
|
|
@@ -5496,7 +5496,7 @@ var require_additionalItems = __commonJS({
|
|
|
5496
5496
|
exports.validateAdditionalItems = void 0;
|
|
5497
5497
|
var codegen_1 = require_codegen();
|
|
5498
5498
|
var util_1 = require_util();
|
|
5499
|
-
var
|
|
5499
|
+
var error6 = {
|
|
5500
5500
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
5501
5501
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
5502
5502
|
};
|
|
@@ -5505,7 +5505,7 @@ var require_additionalItems = __commonJS({
|
|
|
5505
5505
|
type: "array",
|
|
5506
5506
|
schemaType: ["boolean", "object"],
|
|
5507
5507
|
before: "uniqueItems",
|
|
5508
|
-
error:
|
|
5508
|
+
error: error6,
|
|
5509
5509
|
code(cxt) {
|
|
5510
5510
|
const { parentSchema, it: it2 } = cxt;
|
|
5511
5511
|
const { items } = parentSchema;
|
|
@@ -5624,7 +5624,7 @@ var require_items2020 = __commonJS({
|
|
|
5624
5624
|
var util_1 = require_util();
|
|
5625
5625
|
var code_1 = require_code2();
|
|
5626
5626
|
var additionalItems_1 = require_additionalItems();
|
|
5627
|
-
var
|
|
5627
|
+
var error6 = {
|
|
5628
5628
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
5629
5629
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
5630
5630
|
};
|
|
@@ -5633,7 +5633,7 @@ var require_items2020 = __commonJS({
|
|
|
5633
5633
|
type: "array",
|
|
5634
5634
|
schemaType: ["object", "boolean"],
|
|
5635
5635
|
before: "uniqueItems",
|
|
5636
|
-
error:
|
|
5636
|
+
error: error6,
|
|
5637
5637
|
code(cxt) {
|
|
5638
5638
|
const { schema, parentSchema, it: it2 } = cxt;
|
|
5639
5639
|
const { prefixItems } = parentSchema;
|
|
@@ -5657,7 +5657,7 @@ var require_contains = __commonJS({
|
|
|
5657
5657
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5658
5658
|
var codegen_1 = require_codegen();
|
|
5659
5659
|
var util_1 = require_util();
|
|
5660
|
-
var
|
|
5660
|
+
var error6 = {
|
|
5661
5661
|
message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
|
|
5662
5662
|
params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
|
|
5663
5663
|
};
|
|
@@ -5667,7 +5667,7 @@ var require_contains = __commonJS({
|
|
|
5667
5667
|
schemaType: ["object", "boolean"],
|
|
5668
5668
|
before: "uniqueItems",
|
|
5669
5669
|
trackErrors: true,
|
|
5670
|
-
error:
|
|
5670
|
+
error: error6,
|
|
5671
5671
|
code(cxt) {
|
|
5672
5672
|
const { gen, schema, parentSchema, data, it: it2 } = cxt;
|
|
5673
5673
|
let min;
|
|
@@ -5845,7 +5845,7 @@ var require_propertyNames = __commonJS({
|
|
|
5845
5845
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5846
5846
|
var codegen_1 = require_codegen();
|
|
5847
5847
|
var util_1 = require_util();
|
|
5848
|
-
var
|
|
5848
|
+
var error6 = {
|
|
5849
5849
|
message: "property name must be valid",
|
|
5850
5850
|
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
|
|
5851
5851
|
};
|
|
@@ -5853,7 +5853,7 @@ var require_propertyNames = __commonJS({
|
|
|
5853
5853
|
keyword: "propertyNames",
|
|
5854
5854
|
type: "object",
|
|
5855
5855
|
schemaType: ["object", "boolean"],
|
|
5856
|
-
error:
|
|
5856
|
+
error: error6,
|
|
5857
5857
|
code(cxt) {
|
|
5858
5858
|
const { gen, schema, data, it: it2 } = cxt;
|
|
5859
5859
|
if ((0, util_1.alwaysValidSchema)(it2, schema))
|
|
@@ -5890,7 +5890,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5890
5890
|
var codegen_1 = require_codegen();
|
|
5891
5891
|
var names_1 = require_names();
|
|
5892
5892
|
var util_1 = require_util();
|
|
5893
|
-
var
|
|
5893
|
+
var error6 = {
|
|
5894
5894
|
message: "must NOT have additional properties",
|
|
5895
5895
|
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
|
|
5896
5896
|
};
|
|
@@ -5900,7 +5900,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5900
5900
|
schemaType: ["boolean", "object"],
|
|
5901
5901
|
allowUndefined: true,
|
|
5902
5902
|
trackErrors: true,
|
|
5903
|
-
error:
|
|
5903
|
+
error: error6,
|
|
5904
5904
|
code(cxt) {
|
|
5905
5905
|
const { gen, schema, parentSchema, data, errsCount, it: it2 } = cxt;
|
|
5906
5906
|
if (!errsCount)
|
|
@@ -6174,7 +6174,7 @@ var require_oneOf = __commonJS({
|
|
|
6174
6174
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6175
6175
|
var codegen_1 = require_codegen();
|
|
6176
6176
|
var util_1 = require_util();
|
|
6177
|
-
var
|
|
6177
|
+
var error6 = {
|
|
6178
6178
|
message: "must match exactly one schema in oneOf",
|
|
6179
6179
|
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
|
|
6180
6180
|
};
|
|
@@ -6182,7 +6182,7 @@ var require_oneOf = __commonJS({
|
|
|
6182
6182
|
keyword: "oneOf",
|
|
6183
6183
|
schemaType: "array",
|
|
6184
6184
|
trackErrors: true,
|
|
6185
|
-
error:
|
|
6185
|
+
error: error6,
|
|
6186
6186
|
code(cxt) {
|
|
6187
6187
|
const { gen, schema, parentSchema, it: it2 } = cxt;
|
|
6188
6188
|
if (!Array.isArray(schema))
|
|
@@ -6259,7 +6259,7 @@ var require_if = __commonJS({
|
|
|
6259
6259
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6260
6260
|
var codegen_1 = require_codegen();
|
|
6261
6261
|
var util_1 = require_util();
|
|
6262
|
-
var
|
|
6262
|
+
var error6 = {
|
|
6263
6263
|
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
|
|
6264
6264
|
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
|
|
6265
6265
|
};
|
|
@@ -6267,7 +6267,7 @@ var require_if = __commonJS({
|
|
|
6267
6267
|
keyword: "if",
|
|
6268
6268
|
schemaType: ["object", "boolean"],
|
|
6269
6269
|
trackErrors: true,
|
|
6270
|
-
error:
|
|
6270
|
+
error: error6,
|
|
6271
6271
|
code(cxt) {
|
|
6272
6272
|
const { gen, parentSchema, it: it2 } = cxt;
|
|
6273
6273
|
if (parentSchema.then === void 0 && parentSchema.else === void 0) {
|
|
@@ -6393,7 +6393,7 @@ var require_format = __commonJS({
|
|
|
6393
6393
|
"use strict";
|
|
6394
6394
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6395
6395
|
var codegen_1 = require_codegen();
|
|
6396
|
-
var
|
|
6396
|
+
var error6 = {
|
|
6397
6397
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
|
|
6398
6398
|
params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
|
|
6399
6399
|
};
|
|
@@ -6402,7 +6402,7 @@ var require_format = __commonJS({
|
|
|
6402
6402
|
type: ["number", "string"],
|
|
6403
6403
|
schemaType: "string",
|
|
6404
6404
|
$data: true,
|
|
6405
|
-
error:
|
|
6405
|
+
error: error6,
|
|
6406
6406
|
code(cxt, ruleType) {
|
|
6407
6407
|
const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
|
|
6408
6408
|
const { opts, errSchemaPath, schemaEnv, self } = it2;
|
|
@@ -6557,7 +6557,7 @@ var require_discriminator = __commonJS({
|
|
|
6557
6557
|
var compile_1 = require_compile();
|
|
6558
6558
|
var ref_error_1 = require_ref_error();
|
|
6559
6559
|
var util_1 = require_util();
|
|
6560
|
-
var
|
|
6560
|
+
var error6 = {
|
|
6561
6561
|
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
|
|
6562
6562
|
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
|
|
6563
6563
|
};
|
|
@@ -6565,7 +6565,7 @@ var require_discriminator = __commonJS({
|
|
|
6565
6565
|
keyword: "discriminator",
|
|
6566
6566
|
type: "object",
|
|
6567
6567
|
schemaType: "object",
|
|
6568
|
-
error:
|
|
6568
|
+
error: error6,
|
|
6569
6569
|
code(cxt) {
|
|
6570
6570
|
const { gen, data, schema, parentSchema, it: it2 } = cxt;
|
|
6571
6571
|
const { oneOf } = parentSchema;
|
|
@@ -7097,7 +7097,7 @@ var require_limit = __commonJS({
|
|
|
7097
7097
|
formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
|
7098
7098
|
formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
|
|
7099
7099
|
};
|
|
7100
|
-
var
|
|
7100
|
+
var error6 = {
|
|
7101
7101
|
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
|
|
7102
7102
|
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
|
|
7103
7103
|
};
|
|
@@ -7106,7 +7106,7 @@ var require_limit = __commonJS({
|
|
|
7106
7106
|
type: "string",
|
|
7107
7107
|
schemaType: "string",
|
|
7108
7108
|
$data: true,
|
|
7109
|
-
error:
|
|
7109
|
+
error: error6,
|
|
7110
7110
|
code(cxt) {
|
|
7111
7111
|
const { gen, data, schemaCode, keyword, it: it2 } = cxt;
|
|
7112
7112
|
const { opts, self } = it2;
|
|
@@ -7351,9 +7351,9 @@ var secure = async (file, directory3 = false) => {
|
|
|
7351
7351
|
let info5;
|
|
7352
7352
|
try {
|
|
7353
7353
|
info5 = await lstat(file);
|
|
7354
|
-
} catch (
|
|
7355
|
-
if (
|
|
7356
|
-
throw
|
|
7354
|
+
} catch (error6) {
|
|
7355
|
+
if (error6.code === "ENOENT") return null;
|
|
7356
|
+
throw error6;
|
|
7357
7357
|
}
|
|
7358
7358
|
if (info5.isSymbolicLink() || !(directory3 ? info5.isDirectory() : info5.isFile()) || info5.uid !== process.getuid?.() || (info5.mode & 63) !== 0)
|
|
7359
7359
|
throw new CreationClientError("credentials.private_owner_required");
|
|
@@ -7386,8 +7386,8 @@ async function writeCredentials(value2, file = credentialsPath()) {
|
|
|
7386
7386
|
});
|
|
7387
7387
|
await rename(temporary, file);
|
|
7388
7388
|
} finally {
|
|
7389
|
-
await unlink(temporary).catch((
|
|
7390
|
-
if (
|
|
7389
|
+
await unlink(temporary).catch((error6) => {
|
|
7390
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
7391
7391
|
});
|
|
7392
7392
|
}
|
|
7393
7393
|
}
|
|
@@ -7420,8 +7420,8 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
|
|
|
7420
7420
|
let handle;
|
|
7421
7421
|
try {
|
|
7422
7422
|
handle = await open(selected, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
7423
|
-
} catch (
|
|
7424
|
-
throw failure(
|
|
7423
|
+
} catch (error6) {
|
|
7424
|
+
throw failure(error6.code === "ELOOP" ? "file_not_regular" : error6.code === "EACCES" || error6.code === "EPERM" ? "file_read_denied" : "file_not_on_bridge_host");
|
|
7425
7425
|
}
|
|
7426
7426
|
const abort = new AbortController(), streams = /* @__PURE__ */ new Map(), reads = /* @__PURE__ */ new Set();
|
|
7427
7427
|
let closing = false, closed = false, original, closePromise;
|
|
@@ -7446,8 +7446,8 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
|
|
|
7446
7446
|
try {
|
|
7447
7447
|
const [current, named] = await Promise.all([handle.stat({ bigint: true }), lstat2(selected, { bigint: true })]);
|
|
7448
7448
|
if (!current.isFile() || !named.isFile() || !equal(original, fingerprint(current)) || !equal(original, fingerprint(named))) throw failure("file_changed");
|
|
7449
|
-
} catch (
|
|
7450
|
-
if (
|
|
7449
|
+
} catch (error6) {
|
|
7450
|
+
if (error6 instanceof CreationClientError) throw error6;
|
|
7451
7451
|
throw failure("file_changed");
|
|
7452
7452
|
}
|
|
7453
7453
|
};
|
|
@@ -7466,17 +7466,17 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
|
|
|
7466
7466
|
if (stat3.size <= 0n || stat3.size > BigInt(maxBytes2)) throw failure("file_size_limit");
|
|
7467
7467
|
original = fingerprint(stat3);
|
|
7468
7468
|
await assertUnchanged();
|
|
7469
|
-
const
|
|
7469
|
+
const hash8 = createHash("sha256"), buffer = Buffer.allocUnsafe(LOCAL_UPLOAD_READ_BYTES);
|
|
7470
7470
|
for (let position = 0; position < original.sizeBytes; ) {
|
|
7471
7471
|
checkSignal();
|
|
7472
7472
|
const length = Math.min(buffer.length, original.sizeBytes - position);
|
|
7473
7473
|
const { bytesRead } = await read2(buffer, 0, length, position);
|
|
7474
7474
|
if (bytesRead === 0) throw failure("file_changed");
|
|
7475
|
-
|
|
7475
|
+
hash8.update(buffer.subarray(0, bytesRead));
|
|
7476
7476
|
position += bytesRead;
|
|
7477
7477
|
}
|
|
7478
7478
|
await assertUnchanged();
|
|
7479
|
-
const checksum = "sha256:" +
|
|
7479
|
+
const checksum = "sha256:" + hash8.digest("hex");
|
|
7480
7480
|
return {
|
|
7481
7481
|
name,
|
|
7482
7482
|
sizeBytes: original.sizeBytes,
|
|
@@ -7509,9 +7509,9 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
|
|
|
7509
7509
|
return stream;
|
|
7510
7510
|
}
|
|
7511
7511
|
};
|
|
7512
|
-
} catch (
|
|
7512
|
+
} catch (error6) {
|
|
7513
7513
|
await close();
|
|
7514
|
-
if (
|
|
7514
|
+
if (error6 instanceof CreationClientError) throw error6;
|
|
7515
7515
|
throw failure("file_read_failed");
|
|
7516
7516
|
}
|
|
7517
7517
|
}
|
|
@@ -7547,13 +7547,13 @@ var causes = /* @__PURE__ */ new Set([
|
|
|
7547
7547
|
"validation_refused",
|
|
7548
7548
|
"stream_unconfirmed"
|
|
7549
7549
|
]);
|
|
7550
|
-
var localCause = (
|
|
7550
|
+
var localCause = (error6) => error6 instanceof CreationClientError ? {
|
|
7551
7551
|
"creation.local_upload.file_read_failed": "local_read_failed",
|
|
7552
7552
|
"creation.local_upload.file_changed": "local_file_changed",
|
|
7553
7553
|
"creation.local_upload.file_read_cancelled": "local_read_cancelled"
|
|
7554
|
-
}[
|
|
7555
|
-
var networkCause = (
|
|
7556
|
-
const code = typeof
|
|
7554
|
+
}[error6.message] : void 0;
|
|
7555
|
+
var networkCause = (error6) => {
|
|
7556
|
+
const code = typeof error6?.cause?.code === "string" ? error6.cause.code : error6?.code;
|
|
7557
7557
|
if (["ENOTFOUND", "EAI_AGAIN"].includes(code)) return "dns_failure";
|
|
7558
7558
|
if (code === "ECONNREFUSED") return "connection_refused";
|
|
7559
7559
|
if (["ECONNRESET", "EPIPE", "UND_ERR_SOCKET"].includes(code)) return "connection_interrupted";
|
|
@@ -7624,9 +7624,9 @@ async function transferGrantedPart(file, authorization, grant, {
|
|
|
7624
7624
|
report("checking_file", { bytesRead: 0 });
|
|
7625
7625
|
try {
|
|
7626
7626
|
await file.assertUnchanged();
|
|
7627
|
-
} catch (
|
|
7628
|
-
report("checking_file", { causeCode: localCause(
|
|
7629
|
-
throw
|
|
7627
|
+
} catch (error6) {
|
|
7628
|
+
report("checking_file", { causeCode: localCause(error6) ?? "local_read_failed" });
|
|
7629
|
+
throw error6;
|
|
7630
7630
|
}
|
|
7631
7631
|
if (signal?.aborted) fail("transfer_cancelled");
|
|
7632
7632
|
const controller = new AbortController();
|
|
@@ -7665,12 +7665,12 @@ async function transferGrantedPart(file, authorization, grant, {
|
|
|
7665
7665
|
yield chunk;
|
|
7666
7666
|
}
|
|
7667
7667
|
report("awaiting_response", { bytesRead });
|
|
7668
|
-
} catch (
|
|
7668
|
+
} catch (error6) {
|
|
7669
7669
|
if (!reason && !closing) {
|
|
7670
7670
|
streamFailure = true;
|
|
7671
|
-
report("streaming", { bytesRead, causeCode: localCause(
|
|
7671
|
+
report("streaming", { bytesRead, causeCode: localCause(error6) ?? (["EIO", "EACCES", "EPERM", "ESTALE", "EBADF"].includes(error6?.code) ? "local_read_failed" : "stream_unconfirmed") });
|
|
7672
7672
|
}
|
|
7673
|
-
throw
|
|
7673
|
+
throw error6;
|
|
7674
7674
|
}
|
|
7675
7675
|
}
|
|
7676
7676
|
try {
|
|
@@ -7698,9 +7698,9 @@ async function transferGrantedPart(file, authorization, grant, {
|
|
|
7698
7698
|
report("checking_file", { bytesRead });
|
|
7699
7699
|
try {
|
|
7700
7700
|
await file.assertUnchanged();
|
|
7701
|
-
} catch (
|
|
7702
|
-
report("checking_file", { bytesRead, causeCode: localCause(
|
|
7703
|
-
throw
|
|
7701
|
+
} catch (error6) {
|
|
7702
|
+
report("checking_file", { bytesRead, causeCode: localCause(error6) ?? "local_read_failed" });
|
|
7703
|
+
throw error6;
|
|
7704
7704
|
}
|
|
7705
7705
|
report("reading_receipt", { bytesRead });
|
|
7706
7706
|
const etag = response.headers.get("etag");
|
|
@@ -7709,13 +7709,13 @@ async function transferGrantedPart(file, authorization, grant, {
|
|
|
7709
7709
|
fail("part_receipt_unconfirmed");
|
|
7710
7710
|
}
|
|
7711
7711
|
return { partNumber: grant.partNumber, etag, sizeBytes };
|
|
7712
|
-
} catch (
|
|
7712
|
+
} catch (error6) {
|
|
7713
7713
|
if (reason) fail(reason);
|
|
7714
|
-
if (
|
|
7715
|
-
if (localCause(
|
|
7716
|
-
throw
|
|
7714
|
+
if (error6 instanceof CreationClientError) {
|
|
7715
|
+
if (localCause(error6)) onTransferState({ causeCode: localCause(error6) });
|
|
7716
|
+
throw error6;
|
|
7717
7717
|
}
|
|
7718
|
-
if (!streamFailure) onTransferState({ causeCode: networkCause(
|
|
7718
|
+
if (!streamFailure) onTransferState({ causeCode: networkCause(error6) });
|
|
7719
7719
|
fail("part_transfer_unconfirmed");
|
|
7720
7720
|
} finally {
|
|
7721
7721
|
closing = true;
|
|
@@ -7733,8 +7733,8 @@ async function transferGrantedPart(file, authorization, grant, {
|
|
|
7733
7733
|
}
|
|
7734
7734
|
var effects = /* @__PURE__ */ new WeakMap();
|
|
7735
7735
|
var diagnostics = /* @__PURE__ */ new WeakMap();
|
|
7736
|
-
var readPartTransferEffect = (
|
|
7737
|
-
var readPartTransferDiagnostic = (
|
|
7736
|
+
var readPartTransferEffect = (error6) => error6 && typeof error6 === "object" ? effects.get(error6) : void 0;
|
|
7737
|
+
var readPartTransferDiagnostic = (error6) => error6 && typeof error6 === "object" ? diagnostics.get(error6) : void 0;
|
|
7738
7738
|
async function uploadGrantedPart(file, authorization, grant, options = {}) {
|
|
7739
7739
|
let dispatched = false, state = { stage: "validating", bytesRead: 0 };
|
|
7740
7740
|
const monotonic = options.monotonicNow ?? (() => performance2.now()), started = monotonic();
|
|
@@ -7745,15 +7745,15 @@ async function uploadGrantedPart(file, authorization, grant, options = {}) {
|
|
|
7745
7745
|
dispatched = true;
|
|
7746
7746
|
return (options.fetch ?? globalThis.fetch)(...args2);
|
|
7747
7747
|
} });
|
|
7748
|
-
} catch (
|
|
7749
|
-
if (
|
|
7750
|
-
if (
|
|
7748
|
+
} catch (error6) {
|
|
7749
|
+
if (error6 && typeof error6 === "object") effects.set(error6, dispatched ? "unknown" : "not_dispatched");
|
|
7750
|
+
if (error6 && typeof error6 === "object") diagnostics.set(error6, safePartTransferDiagnostic({
|
|
7751
7751
|
...state,
|
|
7752
7752
|
requestId: options.requestId,
|
|
7753
|
-
causeCode: state.causeCode ?? (!dispatched && state.stage === "validating" ? "validation_refused" : networkCause(
|
|
7753
|
+
causeCode: state.causeCode ?? (!dispatched && state.stage === "validating" ? "validation_refused" : networkCause(error6)),
|
|
7754
7754
|
elapsedMs: Math.max(0, Math.floor(monotonic() - started))
|
|
7755
7755
|
}));
|
|
7756
|
-
throw
|
|
7756
|
+
throw error6;
|
|
7757
7757
|
}
|
|
7758
7758
|
}
|
|
7759
7759
|
|
|
@@ -7979,7 +7979,7 @@ var digest = (value2) => createHash2("sha256").update(JSON.stringify(value2)).di
|
|
|
7979
7979
|
var fail3 = (code) => {
|
|
7980
7980
|
throw new CreationClientError("creation.local_upload." + code);
|
|
7981
7981
|
};
|
|
7982
|
-
var knownError = (
|
|
7982
|
+
var knownError = (error6) => error6 instanceof CreationClientError && /^creation\.[a-z0-9_.:-]{1,180}$/.test(error6.message) ? error6.message : "creation.local_upload.control_unconfirmed";
|
|
7983
7983
|
var createRefusal = (code) => /^creation\.direct_object_upload\.(?:size_limit_exceeded|pending_bytes_quota_exceeded|concurrent_multipart_quota_exceeded|daily_bytes_quota_exceeded|durable_storage_quota_exceeded|capacity_unavailable|admission_facts_unavailable)$/.test(code);
|
|
7984
7984
|
var typeByExtension = {
|
|
7985
7985
|
".png": ["image", "image/png"],
|
|
@@ -8214,14 +8214,14 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8214
8214
|
job.progress = progress.bytesRead;
|
|
8215
8215
|
}
|
|
8216
8216
|
});
|
|
8217
|
-
} catch (
|
|
8218
|
-
const diagnostic = readPartTransferDiagnostic(
|
|
8217
|
+
} catch (error6) {
|
|
8218
|
+
const diagnostic = readPartTransferDiagnostic(error6);
|
|
8219
8219
|
if (diagnostic) state.lastTransferDiagnostic = diagnostic;
|
|
8220
|
-
if (readPartTransferEffect(
|
|
8220
|
+
if (readPartTransferEffect(error6) === "not_dispatched") {
|
|
8221
8221
|
delete state.pendingPart;
|
|
8222
8222
|
await save();
|
|
8223
8223
|
}
|
|
8224
|
-
throw
|
|
8224
|
+
throw error6;
|
|
8225
8225
|
}
|
|
8226
8226
|
state.parts.push(part);
|
|
8227
8227
|
state.parts.sort((a, b2) => a.partNumber - b2.partNumber);
|
|
@@ -8348,11 +8348,11 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8348
8348
|
let created;
|
|
8349
8349
|
try {
|
|
8350
8350
|
created = await rpc(send, { action: "create", request: state.request });
|
|
8351
|
-
} catch (
|
|
8352
|
-
const code = knownError(
|
|
8351
|
+
} catch (error6) {
|
|
8352
|
+
const code = knownError(error6);
|
|
8353
8353
|
state.createDisposition = createRefusal(code) ? "rejected" : "unconfirmed";
|
|
8354
8354
|
if (createRefusal(code)) state.createErrorCode = code;
|
|
8355
|
-
throw
|
|
8355
|
+
throw error6;
|
|
8356
8356
|
}
|
|
8357
8357
|
authorization = created.authorization;
|
|
8358
8358
|
const session = authorization?.session;
|
|
@@ -8370,9 +8370,9 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8370
8370
|
job = { state, file, abort, progress: 0, save: () => persistence.write(key, state) };
|
|
8371
8371
|
jobs.set(key, job);
|
|
8372
8372
|
file = void 0;
|
|
8373
|
-
job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2, options) => send(transfer2, { signal: abort.signal, ...options }), binding)).catch(async (
|
|
8373
|
+
job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2, options) => send(transfer2, { signal: abort.signal, ...options }), binding)).catch(async (error6) => {
|
|
8374
8374
|
state.phase = "paused";
|
|
8375
|
-
state.errorCode = abort.signal.aborted ? "creation.local_upload.transfer_cancelled" : knownError(
|
|
8375
|
+
state.errorCode = abort.signal.aborted ? "creation.local_upload.transfer_cancelled" : knownError(error6);
|
|
8376
8376
|
await job.save();
|
|
8377
8377
|
}).finally(async () => {
|
|
8378
8378
|
try {
|
|
@@ -8388,13 +8388,13 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8388
8388
|
job.done.catch(() => {
|
|
8389
8389
|
});
|
|
8390
8390
|
return view(state, job);
|
|
8391
|
-
} catch (
|
|
8391
|
+
} catch (error6) {
|
|
8392
8392
|
if (state) {
|
|
8393
8393
|
state.phase = state.createDisposition === "rejected" && !state.uploadId ? "create_rejected" : "paused";
|
|
8394
|
-
state.errorCode = knownError(
|
|
8394
|
+
state.errorCode = knownError(error6);
|
|
8395
8395
|
await persistence.write(key, state);
|
|
8396
8396
|
}
|
|
8397
|
-
throw
|
|
8397
|
+
throw error6;
|
|
8398
8398
|
} finally {
|
|
8399
8399
|
if (!jobs.has(key)) {
|
|
8400
8400
|
await file?.close();
|
|
@@ -8429,11 +8429,11 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8429
8429
|
}
|
|
8430
8430
|
|
|
8431
8431
|
// lib/version.mjs
|
|
8432
|
-
var CLIENT_VERSION = "0.3.
|
|
8432
|
+
var CLIENT_VERSION = "0.3.13";
|
|
8433
8433
|
var CLIENT_PROTOCOL = "creation-client/v1";
|
|
8434
8434
|
|
|
8435
8435
|
// lib/cli.mjs
|
|
8436
|
-
import { randomBytes as
|
|
8436
|
+
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
8437
8437
|
import { spawn as spawn2 } from "node:child_process";
|
|
8438
8438
|
|
|
8439
8439
|
// node_modules/zod/v4/core/util.js
|
|
@@ -8673,10 +8673,10 @@ function mergeDefs(...defs) {
|
|
|
8673
8673
|
function cloneDef(schema) {
|
|
8674
8674
|
return mergeDefs(schema._zod.def);
|
|
8675
8675
|
}
|
|
8676
|
-
function getElementAtPath(obj,
|
|
8677
|
-
if (!
|
|
8676
|
+
function getElementAtPath(obj, path23) {
|
|
8677
|
+
if (!path23)
|
|
8678
8678
|
return obj;
|
|
8679
|
-
return
|
|
8679
|
+
return path23.reduce((acc, key) => acc?.[key], obj);
|
|
8680
8680
|
}
|
|
8681
8681
|
function promiseAllObject(promisesObj) {
|
|
8682
8682
|
const keys = Object.keys(promisesObj);
|
|
@@ -9016,11 +9016,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
9016
9016
|
}
|
|
9017
9017
|
return false;
|
|
9018
9018
|
}
|
|
9019
|
-
function prefixIssues(
|
|
9019
|
+
function prefixIssues(path23, issues) {
|
|
9020
9020
|
return issues.map((iss) => {
|
|
9021
9021
|
var _a3;
|
|
9022
9022
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
9023
|
-
iss.path.unshift(
|
|
9023
|
+
iss.path.unshift(path23);
|
|
9024
9024
|
return iss;
|
|
9025
9025
|
});
|
|
9026
9026
|
}
|
|
@@ -9160,8 +9160,8 @@ function base64urlToUint8Array(base64url2) {
|
|
|
9160
9160
|
function uint8ArrayToBase64url(bytes2) {
|
|
9161
9161
|
return uint8ArrayToBase64(bytes2).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
9162
9162
|
}
|
|
9163
|
-
function hexToUint8Array(
|
|
9164
|
-
const cleanHex =
|
|
9163
|
+
function hexToUint8Array(hex3) {
|
|
9164
|
+
const cleanHex = hex3.replace(/^0x/, "");
|
|
9165
9165
|
if (cleanHex.length % 2 !== 0) {
|
|
9166
9166
|
throw new Error("Invalid hex string length");
|
|
9167
9167
|
}
|
|
@@ -9467,10 +9467,10 @@ function node(obj, key, make) {
|
|
|
9467
9467
|
}
|
|
9468
9468
|
return obj[key];
|
|
9469
9469
|
}
|
|
9470
|
-
function flattenError(
|
|
9470
|
+
function flattenError(error6, mapper = (issue2) => issue2.message) {
|
|
9471
9471
|
const fieldErrors = {};
|
|
9472
9472
|
const formErrors = [];
|
|
9473
|
-
for (const sub of
|
|
9473
|
+
for (const sub of error6.issues) {
|
|
9474
9474
|
if (sub.path.length > 0) {
|
|
9475
9475
|
node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
9476
9476
|
} else {
|
|
@@ -9479,18 +9479,18 @@ function flattenError(error5, mapper = (issue2) => issue2.message) {
|
|
|
9479
9479
|
}
|
|
9480
9480
|
return { formErrors, fieldErrors };
|
|
9481
9481
|
}
|
|
9482
|
-
function formatError(
|
|
9482
|
+
function formatError(error6, mapper = (issue2) => issue2.message) {
|
|
9483
9483
|
const fieldErrors = { _errors: [] };
|
|
9484
|
-
const processError = (
|
|
9485
|
-
for (const issue2 of
|
|
9484
|
+
const processError = (error7, path23 = []) => {
|
|
9485
|
+
for (const issue2 of error7.issues) {
|
|
9486
9486
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
9487
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
9487
|
+
issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
|
|
9488
9488
|
} else if (issue2.code === "invalid_key") {
|
|
9489
|
-
processError({ issues: issue2.issues }, [...
|
|
9489
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
9490
9490
|
} else if (issue2.code === "invalid_element") {
|
|
9491
|
-
processError({ issues: issue2.issues }, [...
|
|
9491
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
9492
9492
|
} else {
|
|
9493
|
-
const fullpath = [...
|
|
9493
|
+
const fullpath = [...path23, ...issue2.path];
|
|
9494
9494
|
if (fullpath.length === 0) {
|
|
9495
9495
|
fieldErrors._errors.push(mapper(issue2));
|
|
9496
9496
|
} else {
|
|
@@ -9524,7 +9524,7 @@ function formatError(error5, mapper = (issue2) => issue2.message) {
|
|
|
9524
9524
|
}
|
|
9525
9525
|
}
|
|
9526
9526
|
};
|
|
9527
|
-
processError(
|
|
9527
|
+
processError(error6);
|
|
9528
9528
|
return fieldErrors;
|
|
9529
9529
|
}
|
|
9530
9530
|
|
|
@@ -9573,19 +9573,19 @@ var _safeParse = (_Err) => (schema, value2, _ctx) => {
|
|
|
9573
9573
|
};
|
|
9574
9574
|
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
9575
9575
|
function failure2(Err, issues, ctx) {
|
|
9576
|
-
let
|
|
9576
|
+
let error6;
|
|
9577
9577
|
return {
|
|
9578
9578
|
success: false,
|
|
9579
9579
|
get error() {
|
|
9580
|
-
if (!
|
|
9581
|
-
|
|
9580
|
+
if (!error6) {
|
|
9581
|
+
error6 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
9582
9582
|
issues = void 0;
|
|
9583
9583
|
ctx = void 0;
|
|
9584
9584
|
}
|
|
9585
|
-
return
|
|
9585
|
+
return error6;
|
|
9586
9586
|
},
|
|
9587
9587
|
set error(e) {
|
|
9588
|
-
|
|
9588
|
+
error6 = e;
|
|
9589
9589
|
issues = void 0;
|
|
9590
9590
|
ctx = void 0;
|
|
9591
9591
|
}
|
|
@@ -16726,8 +16726,8 @@ var Protocol = class {
|
|
|
16726
16726
|
resolver(message);
|
|
16727
16727
|
} else {
|
|
16728
16728
|
const errorMessage = message;
|
|
16729
|
-
const
|
|
16730
|
-
resolver(
|
|
16729
|
+
const error6 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
|
|
16730
|
+
resolver(error6);
|
|
16731
16731
|
}
|
|
16732
16732
|
} else {
|
|
16733
16733
|
const messageType = queuedMessage.type === "response" ? "Response" : "Error";
|
|
@@ -16771,8 +16771,8 @@ var Protocol = class {
|
|
|
16771
16771
|
nextCursor,
|
|
16772
16772
|
_meta: {}
|
|
16773
16773
|
};
|
|
16774
|
-
} catch (
|
|
16775
|
-
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${
|
|
16774
|
+
} catch (error6) {
|
|
16775
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error6 instanceof Error ? error6.message : String(error6)}`);
|
|
16776
16776
|
}
|
|
16777
16777
|
});
|
|
16778
16778
|
this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
|
|
@@ -16794,11 +16794,11 @@ var Protocol = class {
|
|
|
16794
16794
|
_meta: {},
|
|
16795
16795
|
...cancelledTask
|
|
16796
16796
|
};
|
|
16797
|
-
} catch (
|
|
16798
|
-
if (
|
|
16799
|
-
throw
|
|
16797
|
+
} catch (error6) {
|
|
16798
|
+
if (error6 instanceof McpError) {
|
|
16799
|
+
throw error6;
|
|
16800
16800
|
}
|
|
16801
|
-
throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${
|
|
16801
|
+
throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error6 instanceof Error ? error6.message : String(error6)}`);
|
|
16802
16802
|
}
|
|
16803
16803
|
});
|
|
16804
16804
|
}
|
|
@@ -16859,9 +16859,9 @@ var Protocol = class {
|
|
|
16859
16859
|
this._onclose();
|
|
16860
16860
|
};
|
|
16861
16861
|
const _onerror = this.transport?.onerror;
|
|
16862
|
-
this._transport.onerror = (
|
|
16863
|
-
_onerror?.(
|
|
16864
|
-
this._onerror(
|
|
16862
|
+
this._transport.onerror = (error6) => {
|
|
16863
|
+
_onerror?.(error6);
|
|
16864
|
+
this._onerror(error6);
|
|
16865
16865
|
};
|
|
16866
16866
|
const _onmessage = this._transport?.onmessage;
|
|
16867
16867
|
this._transport.onmessage = (message, extra) => {
|
|
@@ -16892,22 +16892,22 @@ var Protocol = class {
|
|
|
16892
16892
|
controller.abort();
|
|
16893
16893
|
}
|
|
16894
16894
|
this._requestHandlerAbortControllers.clear();
|
|
16895
|
-
const
|
|
16895
|
+
const error6 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
16896
16896
|
this._transport = void 0;
|
|
16897
16897
|
this.onclose?.();
|
|
16898
16898
|
for (const handler of responseHandlers.values()) {
|
|
16899
|
-
handler(
|
|
16899
|
+
handler(error6);
|
|
16900
16900
|
}
|
|
16901
16901
|
}
|
|
16902
|
-
_onerror(
|
|
16903
|
-
this.onerror?.(
|
|
16902
|
+
_onerror(error6) {
|
|
16903
|
+
this.onerror?.(error6);
|
|
16904
16904
|
}
|
|
16905
16905
|
_onnotification(notification) {
|
|
16906
16906
|
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
16907
16907
|
if (handler === void 0) {
|
|
16908
16908
|
return;
|
|
16909
16909
|
}
|
|
16910
|
-
Promise.resolve().then(() => handler(notification)).catch((
|
|
16910
|
+
Promise.resolve().then(() => handler(notification)).catch((error6) => this._onerror(new Error(`Uncaught error in notification handler: ${error6}`)));
|
|
16911
16911
|
}
|
|
16912
16912
|
_onrequest(request, extra) {
|
|
16913
16913
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
@@ -16937,15 +16937,15 @@ var Protocol = class {
|
|
|
16937
16937
|
};
|
|
16938
16938
|
if (relatedTaskId && relatedTaskLookup) {
|
|
16939
16939
|
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
16940
|
-
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((
|
|
16940
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
|
|
16941
16941
|
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
16942
16942
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
16943
16943
|
type: "error",
|
|
16944
16944
|
message: errorResponse,
|
|
16945
16945
|
timestamp: Date.now()
|
|
16946
|
-
}, capturedTransport?.sessionId).catch((
|
|
16946
|
+
}, capturedTransport?.sessionId).catch((error6) => this._onerror(new Error(`Failed to enqueue error response: ${error6}`)));
|
|
16947
16947
|
} else {
|
|
16948
|
-
capturedTransport?.send(errorResponse).catch((
|
|
16948
|
+
capturedTransport?.send(errorResponse).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
|
|
16949
16949
|
}
|
|
16950
16950
|
return;
|
|
16951
16951
|
}
|
|
@@ -17014,7 +17014,7 @@ var Protocol = class {
|
|
|
17014
17014
|
} else {
|
|
17015
17015
|
await capturedTransport?.send(response);
|
|
17016
17016
|
}
|
|
17017
|
-
}, async (
|
|
17017
|
+
}, async (error6) => {
|
|
17018
17018
|
if (abortController.signal.aborted) {
|
|
17019
17019
|
return;
|
|
17020
17020
|
}
|
|
@@ -17022,9 +17022,9 @@ var Protocol = class {
|
|
|
17022
17022
|
jsonrpc: "2.0",
|
|
17023
17023
|
id: request.id,
|
|
17024
17024
|
error: {
|
|
17025
|
-
code: Number.isSafeInteger(
|
|
17026
|
-
message:
|
|
17027
|
-
...
|
|
17025
|
+
code: Number.isSafeInteger(error6["code"]) ? error6["code"] : ErrorCode.InternalError,
|
|
17026
|
+
message: error6.message ?? "Internal error",
|
|
17027
|
+
...error6["data"] !== void 0 && { data: error6["data"] }
|
|
17028
17028
|
}
|
|
17029
17029
|
};
|
|
17030
17030
|
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
@@ -17036,7 +17036,7 @@ var Protocol = class {
|
|
|
17036
17036
|
} else {
|
|
17037
17037
|
await capturedTransport?.send(errorResponse);
|
|
17038
17038
|
}
|
|
17039
|
-
}).catch((
|
|
17039
|
+
}).catch((error6) => this._onerror(new Error(`Failed to send response: ${error6}`))).finally(() => {
|
|
17040
17040
|
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
17041
17041
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
17042
17042
|
}
|
|
@@ -17055,11 +17055,11 @@ var Protocol = class {
|
|
|
17055
17055
|
if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) {
|
|
17056
17056
|
try {
|
|
17057
17057
|
this._resetTimeout(messageId);
|
|
17058
|
-
} catch (
|
|
17058
|
+
} catch (error6) {
|
|
17059
17059
|
this._responseHandlers.delete(messageId);
|
|
17060
17060
|
this._progressHandlers.delete(messageId);
|
|
17061
17061
|
this._cleanupTimeout(messageId);
|
|
17062
|
-
responseHandler(
|
|
17062
|
+
responseHandler(error6);
|
|
17063
17063
|
return;
|
|
17064
17064
|
}
|
|
17065
17065
|
}
|
|
@@ -17073,8 +17073,8 @@ var Protocol = class {
|
|
|
17073
17073
|
if (isJSONRPCResultResponse(response)) {
|
|
17074
17074
|
resolver(response);
|
|
17075
17075
|
} else {
|
|
17076
|
-
const
|
|
17077
|
-
resolver(
|
|
17076
|
+
const error6 = new McpError(response.error.code, response.error.message, response.error.data);
|
|
17077
|
+
resolver(error6);
|
|
17078
17078
|
}
|
|
17079
17079
|
return;
|
|
17080
17080
|
}
|
|
@@ -17102,8 +17102,8 @@ var Protocol = class {
|
|
|
17102
17102
|
if (isJSONRPCResultResponse(response)) {
|
|
17103
17103
|
handler(response);
|
|
17104
17104
|
} else {
|
|
17105
|
-
const
|
|
17106
|
-
handler(
|
|
17105
|
+
const error6 = McpError.fromError(response.error.code, response.error.message, response.error.data);
|
|
17106
|
+
handler(error6);
|
|
17107
17107
|
}
|
|
17108
17108
|
}
|
|
17109
17109
|
get transport() {
|
|
@@ -17148,10 +17148,10 @@ var Protocol = class {
|
|
|
17148
17148
|
try {
|
|
17149
17149
|
const result = await this.request(request, resultSchema, options);
|
|
17150
17150
|
yield { type: "result", result };
|
|
17151
|
-
} catch (
|
|
17151
|
+
} catch (error6) {
|
|
17152
17152
|
yield {
|
|
17153
17153
|
type: "error",
|
|
17154
|
-
error:
|
|
17154
|
+
error: error6 instanceof McpError ? error6 : new McpError(ErrorCode.InternalError, String(error6))
|
|
17155
17155
|
};
|
|
17156
17156
|
}
|
|
17157
17157
|
return;
|
|
@@ -17194,10 +17194,10 @@ var Protocol = class {
|
|
|
17194
17194
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
17195
17195
|
options?.signal?.throwIfAborted();
|
|
17196
17196
|
}
|
|
17197
|
-
} catch (
|
|
17197
|
+
} catch (error6) {
|
|
17198
17198
|
yield {
|
|
17199
17199
|
type: "error",
|
|
17200
|
-
error:
|
|
17200
|
+
error: error6 instanceof McpError ? error6 : new McpError(ErrorCode.InternalError, String(error6))
|
|
17201
17201
|
};
|
|
17202
17202
|
}
|
|
17203
17203
|
}
|
|
@@ -17209,8 +17209,8 @@ var Protocol = class {
|
|
|
17209
17209
|
request(request, resultSchema, options) {
|
|
17210
17210
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
17211
17211
|
return new Promise((resolve, reject) => {
|
|
17212
|
-
const earlyReject = (
|
|
17213
|
-
reject(
|
|
17212
|
+
const earlyReject = (error6) => {
|
|
17213
|
+
reject(error6);
|
|
17214
17214
|
};
|
|
17215
17215
|
if (!this._transport) {
|
|
17216
17216
|
earlyReject(new Error("Not connected"));
|
|
@@ -17270,9 +17270,9 @@ var Protocol = class {
|
|
|
17270
17270
|
requestId: messageId,
|
|
17271
17271
|
reason: String(reason)
|
|
17272
17272
|
}
|
|
17273
|
-
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((
|
|
17274
|
-
const
|
|
17275
|
-
reject(
|
|
17273
|
+
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error7) => this._onerror(new Error(`Failed to send cancellation: ${error7}`)));
|
|
17274
|
+
const error6 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
|
|
17275
|
+
reject(error6);
|
|
17276
17276
|
};
|
|
17277
17277
|
this._responseHandlers.set(messageId, (response) => {
|
|
17278
17278
|
if (options?.signal?.aborted) {
|
|
@@ -17288,8 +17288,8 @@ var Protocol = class {
|
|
|
17288
17288
|
} else {
|
|
17289
17289
|
resolve(parseResult.data);
|
|
17290
17290
|
}
|
|
17291
|
-
} catch (
|
|
17292
|
-
reject(
|
|
17291
|
+
} catch (error6) {
|
|
17292
|
+
reject(error6);
|
|
17293
17293
|
}
|
|
17294
17294
|
});
|
|
17295
17295
|
options?.signal?.addEventListener("abort", () => {
|
|
@@ -17313,14 +17313,14 @@ var Protocol = class {
|
|
|
17313
17313
|
type: "request",
|
|
17314
17314
|
message: jsonrpcRequest,
|
|
17315
17315
|
timestamp: Date.now()
|
|
17316
|
-
}).catch((
|
|
17316
|
+
}).catch((error6) => {
|
|
17317
17317
|
this._cleanupTimeout(messageId);
|
|
17318
|
-
reject(
|
|
17318
|
+
reject(error6);
|
|
17319
17319
|
});
|
|
17320
17320
|
} else {
|
|
17321
|
-
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((
|
|
17321
|
+
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error6) => {
|
|
17322
17322
|
this._cleanupTimeout(messageId);
|
|
17323
|
-
reject(
|
|
17323
|
+
reject(error6);
|
|
17324
17324
|
});
|
|
17325
17325
|
}
|
|
17326
17326
|
});
|
|
@@ -17413,7 +17413,7 @@ var Protocol = class {
|
|
|
17413
17413
|
}
|
|
17414
17414
|
};
|
|
17415
17415
|
}
|
|
17416
|
-
this._transport?.send(jsonrpcNotification2, options).catch((
|
|
17416
|
+
this._transport?.send(jsonrpcNotification2, options).catch((error6) => this._onerror(error6));
|
|
17417
17417
|
});
|
|
17418
17418
|
return;
|
|
17419
17419
|
}
|
|
@@ -18267,11 +18267,11 @@ var Server = class extends Protocol {
|
|
|
18267
18267
|
if (!validationResult.valid) {
|
|
18268
18268
|
throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
|
|
18269
18269
|
}
|
|
18270
|
-
} catch (
|
|
18271
|
-
if (
|
|
18272
|
-
throw
|
|
18270
|
+
} catch (error6) {
|
|
18271
|
+
if (error6 instanceof McpError) {
|
|
18272
|
+
throw error6;
|
|
18273
18273
|
}
|
|
18274
|
-
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${
|
|
18274
|
+
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error6 instanceof Error ? error6.message : String(error6)}`);
|
|
18275
18275
|
}
|
|
18276
18276
|
}
|
|
18277
18277
|
return result;
|
|
@@ -18383,14 +18383,14 @@ var StdioServerTransport = class {
|
|
|
18383
18383
|
try {
|
|
18384
18384
|
this._readBuffer.append(chunk);
|
|
18385
18385
|
this.processReadBuffer();
|
|
18386
|
-
} catch (
|
|
18387
|
-
this.onerror?.(
|
|
18386
|
+
} catch (error6) {
|
|
18387
|
+
this.onerror?.(error6);
|
|
18388
18388
|
this.close().catch(() => {
|
|
18389
18389
|
});
|
|
18390
18390
|
}
|
|
18391
18391
|
};
|
|
18392
|
-
this._onerror = (
|
|
18393
|
-
this.onerror?.(
|
|
18392
|
+
this._onerror = (error6) => {
|
|
18393
|
+
this.onerror?.(error6);
|
|
18394
18394
|
};
|
|
18395
18395
|
this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
|
|
18396
18396
|
}
|
|
@@ -18413,8 +18413,8 @@ var StdioServerTransport = class {
|
|
|
18413
18413
|
break;
|
|
18414
18414
|
}
|
|
18415
18415
|
this.onmessage?.(message);
|
|
18416
|
-
} catch (
|
|
18417
|
-
this.onerror?.(
|
|
18416
|
+
} catch (error6) {
|
|
18417
|
+
this.onerror?.(error6);
|
|
18418
18418
|
}
|
|
18419
18419
|
}
|
|
18420
18420
|
}
|
|
@@ -18511,14 +18511,14 @@ var ExperimentalClientTasks = class {
|
|
|
18511
18511
|
};
|
|
18512
18512
|
return;
|
|
18513
18513
|
}
|
|
18514
|
-
} catch (
|
|
18515
|
-
if (
|
|
18516
|
-
yield { type: "error", error:
|
|
18514
|
+
} catch (error6) {
|
|
18515
|
+
if (error6 instanceof McpError) {
|
|
18516
|
+
yield { type: "error", error: error6 };
|
|
18517
18517
|
return;
|
|
18518
18518
|
}
|
|
18519
18519
|
yield {
|
|
18520
18520
|
type: "error",
|
|
18521
|
-
error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${
|
|
18521
|
+
error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error6 instanceof Error ? error6.message : String(error6)}`)
|
|
18522
18522
|
};
|
|
18523
18523
|
return;
|
|
18524
18524
|
}
|
|
@@ -18831,9 +18831,9 @@ var Client = class extends Protocol {
|
|
|
18831
18831
|
this._setupListChangedHandlers(this._pendingListChangedConfig);
|
|
18832
18832
|
this._pendingListChangedConfig = void 0;
|
|
18833
18833
|
}
|
|
18834
|
-
} catch (
|
|
18834
|
+
} catch (error6) {
|
|
18835
18835
|
void this.close();
|
|
18836
|
-
throw
|
|
18836
|
+
throw error6;
|
|
18837
18837
|
}
|
|
18838
18838
|
}
|
|
18839
18839
|
/**
|
|
@@ -19003,11 +19003,11 @@ var Client = class extends Protocol {
|
|
|
19003
19003
|
if (!validationResult.valid) {
|
|
19004
19004
|
throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
|
|
19005
19005
|
}
|
|
19006
|
-
} catch (
|
|
19007
|
-
if (
|
|
19008
|
-
throw
|
|
19006
|
+
} catch (error6) {
|
|
19007
|
+
if (error6 instanceof McpError) {
|
|
19008
|
+
throw error6;
|
|
19009
19009
|
}
|
|
19010
|
-
throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${
|
|
19010
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error6 instanceof Error ? error6.message : String(error6)}`);
|
|
19011
19011
|
}
|
|
19012
19012
|
}
|
|
19013
19013
|
}
|
|
@@ -19082,8 +19082,8 @@ var Client = class extends Protocol {
|
|
|
19082
19082
|
const items = await fetcher();
|
|
19083
19083
|
onChanged(null, items);
|
|
19084
19084
|
} catch (e) {
|
|
19085
|
-
const
|
|
19086
|
-
onChanged(
|
|
19085
|
+
const error6 = e instanceof Error ? e : new Error(String(e));
|
|
19086
|
+
onChanged(error6, null);
|
|
19087
19087
|
}
|
|
19088
19088
|
};
|
|
19089
19089
|
const handler = () => {
|
|
@@ -19224,8 +19224,8 @@ async function random(size) {
|
|
|
19224
19224
|
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
19225
19225
|
let result = "";
|
|
19226
19226
|
while (result.length < size) {
|
|
19227
|
-
const
|
|
19228
|
-
for (const randomByte of
|
|
19227
|
+
const randomBytes11 = await getRandomValues(size - result.length);
|
|
19228
|
+
for (const randomByte of randomBytes11) {
|
|
19229
19229
|
if (randomByte < evenDistCutoff) {
|
|
19230
19230
|
result += mask[randomByte % mask.length];
|
|
19231
19231
|
}
|
|
@@ -19590,12 +19590,12 @@ async function parseErrorResponse(input) {
|
|
|
19590
19590
|
const body = input instanceof Response ? await input.text() : input;
|
|
19591
19591
|
try {
|
|
19592
19592
|
const result = OAuthErrorResponseSchema.parse(JSON.parse(body));
|
|
19593
|
-
const { error:
|
|
19594
|
-
const errorClass = OAUTH_ERRORS[
|
|
19593
|
+
const { error: error6, error_description, error_uri } = result;
|
|
19594
|
+
const errorClass = OAUTH_ERRORS[error6] || ServerError;
|
|
19595
19595
|
return new errorClass(error_description || "", error_uri);
|
|
19596
|
-
} catch (
|
|
19596
|
+
} catch (error6) {
|
|
19597
19597
|
const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : void 0;
|
|
19598
|
-
const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${
|
|
19598
|
+
const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error6}. Raw body: ${body}`}`;
|
|
19599
19599
|
return new ServerError(errorMessage);
|
|
19600
19600
|
}
|
|
19601
19601
|
}
|
|
@@ -19622,15 +19622,15 @@ function boundElsewhereError(stored, issuer) {
|
|
|
19622
19622
|
async function auth(provider, options) {
|
|
19623
19623
|
try {
|
|
19624
19624
|
return await authInternal(provider, options);
|
|
19625
|
-
} catch (
|
|
19626
|
-
if (
|
|
19625
|
+
} catch (error6) {
|
|
19626
|
+
if (error6 instanceof InvalidClientError || error6 instanceof UnauthorizedClientError) {
|
|
19627
19627
|
await provider.invalidateCredentials?.("all");
|
|
19628
19628
|
return await authInternal(provider, options);
|
|
19629
|
-
} else if (
|
|
19629
|
+
} else if (error6 instanceof InvalidGrantError) {
|
|
19630
19630
|
await provider.invalidateCredentials?.("tokens");
|
|
19631
19631
|
return await authInternal(provider, options);
|
|
19632
19632
|
}
|
|
19633
|
-
throw
|
|
19633
|
+
throw error6;
|
|
19634
19634
|
}
|
|
19635
19635
|
}
|
|
19636
19636
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
@@ -19746,10 +19746,10 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
19746
19746
|
await bindClientInformation();
|
|
19747
19747
|
await provider.saveTokens({ ...newTokens, issuer });
|
|
19748
19748
|
return "AUTHORIZED";
|
|
19749
|
-
} catch (
|
|
19750
|
-
if (!(
|
|
19749
|
+
} catch (error6) {
|
|
19750
|
+
if (!(error6 instanceof OAuthError) || error6 instanceof ServerError) {
|
|
19751
19751
|
} else {
|
|
19752
|
-
throw
|
|
19752
|
+
throw error6;
|
|
19753
19753
|
}
|
|
19754
19754
|
}
|
|
19755
19755
|
}
|
|
@@ -19807,11 +19807,11 @@ function extractWWWAuthenticateParams(res) {
|
|
|
19807
19807
|
}
|
|
19808
19808
|
}
|
|
19809
19809
|
const scope = extractFieldFromWwwAuth(res, "scope") || void 0;
|
|
19810
|
-
const
|
|
19810
|
+
const error6 = extractFieldFromWwwAuth(res, "error") || void 0;
|
|
19811
19811
|
return {
|
|
19812
19812
|
resourceMetadataUrl,
|
|
19813
19813
|
scope,
|
|
19814
|
-
error:
|
|
19814
|
+
error: error6
|
|
19815
19815
|
};
|
|
19816
19816
|
}
|
|
19817
19817
|
function extractFieldFromWwwAuth(response, fieldName) {
|
|
@@ -19844,15 +19844,15 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
|
|
|
19844
19844
|
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
19845
19845
|
try {
|
|
19846
19846
|
return await fetchWithinOrigin(fetchFn)(url2, { headers });
|
|
19847
|
-
} catch (
|
|
19848
|
-
if (
|
|
19847
|
+
} catch (error6) {
|
|
19848
|
+
if (error6 instanceof TypeError) {
|
|
19849
19849
|
if (headers) {
|
|
19850
19850
|
return fetchWithCorsRetry(url2, void 0, fetchFn);
|
|
19851
19851
|
} else {
|
|
19852
19852
|
return void 0;
|
|
19853
19853
|
}
|
|
19854
19854
|
}
|
|
19855
|
-
throw
|
|
19855
|
+
throw error6;
|
|
19856
19856
|
}
|
|
19857
19857
|
}
|
|
19858
19858
|
function buildWellKnownPath(wellKnownPrefix, pathname = "", options = {}) {
|
|
@@ -20301,8 +20301,8 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
20301
20301
|
onEvent: (event) => {
|
|
20302
20302
|
controller.enqueue(event);
|
|
20303
20303
|
},
|
|
20304
|
-
onError(
|
|
20305
|
-
typeof onError == "function" && onError(
|
|
20304
|
+
onError(error6) {
|
|
20305
|
+
typeof onError == "function" && onError(error6), (onError === "terminate" || error6.type === "max-buffer-size-exceeded") && controller.error(error6);
|
|
20306
20306
|
},
|
|
20307
20307
|
onRetry,
|
|
20308
20308
|
onComment,
|
|
@@ -20364,9 +20364,9 @@ var StreamableHTTPClientTransport = class {
|
|
|
20364
20364
|
scope: this._scope,
|
|
20365
20365
|
fetchFn: this._fetchWithInit
|
|
20366
20366
|
});
|
|
20367
|
-
} catch (
|
|
20368
|
-
this.onerror?.(
|
|
20369
|
-
throw
|
|
20367
|
+
} catch (error6) {
|
|
20368
|
+
this.onerror?.(error6);
|
|
20369
|
+
throw error6;
|
|
20370
20370
|
}
|
|
20371
20371
|
if (result !== "AUTHORIZED") {
|
|
20372
20372
|
throw new UnauthorizedError();
|
|
@@ -20419,9 +20419,9 @@ var StreamableHTTPClientTransport = class {
|
|
|
20419
20419
|
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
20420
20420
|
}
|
|
20421
20421
|
this._handleSseStream(response.body, options, true);
|
|
20422
|
-
} catch (
|
|
20423
|
-
this.onerror?.(
|
|
20424
|
-
throw
|
|
20422
|
+
} catch (error6) {
|
|
20423
|
+
this.onerror?.(error6);
|
|
20424
|
+
throw error6;
|
|
20425
20425
|
}
|
|
20426
20426
|
}
|
|
20427
20427
|
/**
|
|
@@ -20453,8 +20453,8 @@ var StreamableHTTPClientTransport = class {
|
|
|
20453
20453
|
}
|
|
20454
20454
|
const delay = this._getNextReconnectionDelay(attemptCount);
|
|
20455
20455
|
this._reconnectionTimeout = setTimeout(() => {
|
|
20456
|
-
this._startOrAuthSse(options).catch((
|
|
20457
|
-
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${
|
|
20456
|
+
this._startOrAuthSse(options).catch((error6) => {
|
|
20457
|
+
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error6 instanceof Error ? error6.message : String(error6)}`));
|
|
20458
20458
|
this._scheduleReconnection(options, attemptCount + 1);
|
|
20459
20459
|
});
|
|
20460
20460
|
}, delay);
|
|
@@ -20497,8 +20497,8 @@ var StreamableHTTPClientTransport = class {
|
|
|
20497
20497
|
}
|
|
20498
20498
|
}
|
|
20499
20499
|
this.onmessage?.(message);
|
|
20500
|
-
} catch (
|
|
20501
|
-
this.onerror?.(
|
|
20500
|
+
} catch (error6) {
|
|
20501
|
+
this.onerror?.(error6);
|
|
20502
20502
|
}
|
|
20503
20503
|
}
|
|
20504
20504
|
}
|
|
@@ -20511,8 +20511,8 @@ var StreamableHTTPClientTransport = class {
|
|
|
20511
20511
|
replayMessageId
|
|
20512
20512
|
}, 0);
|
|
20513
20513
|
}
|
|
20514
|
-
} catch (
|
|
20515
|
-
this.onerror?.(new Error(`SSE stream disconnected: ${
|
|
20514
|
+
} catch (error6) {
|
|
20515
|
+
this.onerror?.(new Error(`SSE stream disconnected: ${error6}`));
|
|
20516
20516
|
const canResume = isReconnectable || hasPrimingEvent;
|
|
20517
20517
|
const needsReconnect = canResume && !receivedResponse;
|
|
20518
20518
|
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
@@ -20522,8 +20522,8 @@ var StreamableHTTPClientTransport = class {
|
|
|
20522
20522
|
onresumptiontoken,
|
|
20523
20523
|
replayMessageId
|
|
20524
20524
|
}, 0);
|
|
20525
|
-
} catch (
|
|
20526
|
-
this.onerror?.(new Error(`Failed to reconnect: ${
|
|
20525
|
+
} catch (error7) {
|
|
20526
|
+
this.onerror?.(new Error(`Failed to reconnect: ${error7 instanceof Error ? error7.message : String(error7)}`));
|
|
20527
20527
|
}
|
|
20528
20528
|
}
|
|
20529
20529
|
}
|
|
@@ -20606,8 +20606,8 @@ var StreamableHTTPClientTransport = class {
|
|
|
20606
20606
|
return this.send(message);
|
|
20607
20607
|
}
|
|
20608
20608
|
if (response.status === 403 && this._authProvider) {
|
|
20609
|
-
const { resourceMetadataUrl, scope, error:
|
|
20610
|
-
if (
|
|
20609
|
+
const { resourceMetadataUrl, scope, error: error6 } = extractWWWAuthenticateParams(response);
|
|
20610
|
+
if (error6 === "insufficient_scope") {
|
|
20611
20611
|
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
20612
20612
|
if (this._lastUpscopingHeader === wwwAuthHeader) {
|
|
20613
20613
|
throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
|
|
@@ -20662,9 +20662,9 @@ var StreamableHTTPClientTransport = class {
|
|
|
20662
20662
|
} else {
|
|
20663
20663
|
await response.body?.cancel();
|
|
20664
20664
|
}
|
|
20665
|
-
} catch (
|
|
20666
|
-
this.onerror?.(
|
|
20667
|
-
throw
|
|
20665
|
+
} catch (error6) {
|
|
20666
|
+
this.onerror?.(error6);
|
|
20667
|
+
throw error6;
|
|
20668
20668
|
}
|
|
20669
20669
|
}
|
|
20670
20670
|
get sessionId() {
|
|
@@ -20699,9 +20699,9 @@ var StreamableHTTPClientTransport = class {
|
|
|
20699
20699
|
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
20700
20700
|
}
|
|
20701
20701
|
this._sessionId = void 0;
|
|
20702
|
-
} catch (
|
|
20703
|
-
this.onerror?.(
|
|
20704
|
-
throw
|
|
20702
|
+
} catch (error6) {
|
|
20703
|
+
this.onerror?.(error6);
|
|
20704
|
+
throw error6;
|
|
20705
20705
|
}
|
|
20706
20706
|
}
|
|
20707
20707
|
setProtocolVersion(version3) {
|
|
@@ -20726,21 +20726,27 @@ var StreamableHTTPClientTransport = class {
|
|
|
20726
20726
|
};
|
|
20727
20727
|
|
|
20728
20728
|
// lib/host-identity.mjs
|
|
20729
|
+
var SUPPORTED_HOSTS = Object.freeze(["codex", "claude-code", "antigravity"]);
|
|
20730
|
+
var isHookProofHost = (kind) => kind === "claude-code" || kind === "antigravity";
|
|
20731
|
+
var DEFAULT_CLIENT_NAMES = Object.freeze({
|
|
20732
|
+
codex: "Codex PromptFrame",
|
|
20733
|
+
"claude-code": "Claude Code PromptFrame",
|
|
20734
|
+
antigravity: "Antigravity PromptFrame"
|
|
20735
|
+
});
|
|
20729
20736
|
function hostClientName(savedName, host) {
|
|
20730
|
-
return
|
|
20737
|
+
return Object.values(DEFAULT_CLIENT_NAMES).includes(savedName) ? DEFAULT_CLIENT_NAMES[host.kind] ?? DEFAULT_CLIENT_NAMES.codex : savedName;
|
|
20731
20738
|
}
|
|
20732
20739
|
var threadFormat = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
20733
20740
|
function resolveHostIdentity({ host, env = process.env } = {}) {
|
|
20734
20741
|
const kind = host ?? (env.CLAUDECODE === "1" ? "claude-code" : "codex");
|
|
20735
|
-
if (!
|
|
20736
|
-
if (kind === "codex") return Object.freeze({ kind });
|
|
20742
|
+
if (!SUPPORTED_HOSTS.includes(kind)) throw new CreationClientError("creation.host_unsupported");
|
|
20737
20743
|
return Object.freeze({ kind });
|
|
20738
20744
|
}
|
|
20739
20745
|
function hostParameters(params, host, access2) {
|
|
20740
20746
|
const meta2 = params._meta ?? {};
|
|
20741
20747
|
if (Object.keys(meta2).some((key) => key.startsWith("promptframe.") || ["controlVersion", "controller", "clientDigest", "token", "catalogVersion", "platformDigest"].includes(key)))
|
|
20742
20748
|
throw new CreationClientError("creation.transport_authority_managed_by_bridge");
|
|
20743
|
-
if (host.kind
|
|
20749
|
+
if (isHookProofHost(host.kind)) {
|
|
20744
20750
|
if (Object.hasOwn(meta2, "threadId")) throw new CreationClientError("creation.transport_authority_managed_by_bridge");
|
|
20745
20751
|
if (!host.threadId) {
|
|
20746
20752
|
if (access2 === "independent-read") return params;
|
|
@@ -20815,7 +20821,7 @@ var BridgeCompatibilityError = class extends CreationClientError {
|
|
|
20815
20821
|
});
|
|
20816
20822
|
}
|
|
20817
20823
|
};
|
|
20818
|
-
var bridgeErrorDetails = (
|
|
20824
|
+
var bridgeErrorDetails = (error6) => error6 instanceof BridgeCompatibilityError ? error6.bridgeFacts : void 0;
|
|
20819
20825
|
function declaredHostContentCapabilities(capabilities, { initialized = false, standardContent = false } = {}) {
|
|
20820
20826
|
const requested = capabilities?.experimental?.["promptframe.contentTypes"];
|
|
20821
20827
|
if (requested === void 0 && initialized && standardContent)
|
|
@@ -20827,7 +20833,7 @@ var declaredHostContentTypes = (capabilities) => declaredHostContentCapabilities
|
|
|
20827
20833
|
|
|
20828
20834
|
// lib/local-accounts.mjs
|
|
20829
20835
|
import { constants as constants3 } from "node:fs";
|
|
20830
|
-
import { open as open4, lstat as lstat4, mkdir as mkdir3, rename as rename3, unlink as unlink3, opendir } from "node:fs/promises";
|
|
20836
|
+
import { open as open4, lstat as lstat4, mkdir as mkdir3, rename as rename3, unlink as unlink3, opendir, link } from "node:fs/promises";
|
|
20831
20837
|
import { homedir as homedir2 } from "node:os";
|
|
20832
20838
|
import path5 from "node:path";
|
|
20833
20839
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
@@ -20877,9 +20883,9 @@ async function directory2(file, create = false) {
|
|
|
20877
20883
|
try {
|
|
20878
20884
|
privateOwner(await lstat4(file), true);
|
|
20879
20885
|
return true;
|
|
20880
|
-
} catch (
|
|
20881
|
-
if (!create &&
|
|
20882
|
-
throw
|
|
20886
|
+
} catch (error6) {
|
|
20887
|
+
if (!create && error6.code === "ENOENT") return false;
|
|
20888
|
+
throw error6;
|
|
20883
20889
|
}
|
|
20884
20890
|
}
|
|
20885
20891
|
async function ownedPath(root, segments, create = false) {
|
|
@@ -20907,10 +20913,10 @@ async function readJson(file) {
|
|
|
20907
20913
|
} catch {
|
|
20908
20914
|
throw failure3("record_invalid");
|
|
20909
20915
|
}
|
|
20910
|
-
} catch (
|
|
20911
|
-
if (
|
|
20912
|
-
if (
|
|
20913
|
-
throw
|
|
20916
|
+
} catch (error6) {
|
|
20917
|
+
if (error6.code === "ENOENT") return void 0;
|
|
20918
|
+
if (error6.code === "ELOOP") throw failure3("private_storage_required");
|
|
20919
|
+
throw error6;
|
|
20914
20920
|
} finally {
|
|
20915
20921
|
await fd?.close();
|
|
20916
20922
|
}
|
|
@@ -20934,15 +20940,15 @@ async function writeJson(directoryPath, name, value2) {
|
|
|
20934
20940
|
if (current.dev !== owner.dev || current.ino !== owner.ino) throw failure3("reference_changed");
|
|
20935
20941
|
try {
|
|
20936
20942
|
privateOwner(await lstat4(path5.join(directoryPath, name)));
|
|
20937
|
-
} catch (
|
|
20938
|
-
if (
|
|
20943
|
+
} catch (error6) {
|
|
20944
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
20939
20945
|
}
|
|
20940
20946
|
await rename3(temporary, path5.join(directoryPath, name));
|
|
20941
20947
|
await parent.sync();
|
|
20942
20948
|
} finally {
|
|
20943
20949
|
await parent.close();
|
|
20944
|
-
await unlink3(temporary).catch((
|
|
20945
|
-
if (
|
|
20950
|
+
await unlink3(temporary).catch((error6) => {
|
|
20951
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
20946
20952
|
});
|
|
20947
20953
|
}
|
|
20948
20954
|
}
|
|
@@ -21080,7 +21086,7 @@ async function listAccounts({ root = localAccountsRoot(), now = Date.now() } = {
|
|
|
21080
21086
|
return { accounts, complete: true };
|
|
21081
21087
|
}
|
|
21082
21088
|
function localAgentDigest(agent) {
|
|
21083
|
-
if (!agent || !["codex", "claude-code"].includes(agent.kind) || typeof agent.sessionId !== "string" || !threadFormat.test(agent.sessionId)) throw failure3("agent_required");
|
|
21089
|
+
if (!agent || !["codex", "claude-code", "antigravity"].includes(agent.kind) || typeof agent.sessionId !== "string" || !threadFormat.test(agent.sessionId)) throw failure3("agent_required");
|
|
21084
21090
|
return hash(JSON.stringify([agent.kind, agent.sessionId.toLowerCase()]));
|
|
21085
21091
|
}
|
|
21086
21092
|
async function selectAccount({ root = localAccountsRoot(), agent, identity }) {
|
|
@@ -21118,8 +21124,49 @@ var readLocalAuthorizations = accountIO(readAuthorizations);
|
|
|
21118
21124
|
var listLocalAccounts = accountIO(listAccounts);
|
|
21119
21125
|
var selectLocalAccount = accountIO(selectAccount);
|
|
21120
21126
|
var readSelectedLocalAccount = accountIO(readSelectedAccount);
|
|
21127
|
+
async function clientObservationInstance({ root = localAccountsRoot(), identity, configFile: configFile2 }) {
|
|
21128
|
+
identity = parseAccountIdentity(identity);
|
|
21129
|
+
if (typeof configFile2 !== "string" || !path5.isAbsolute(configFile2)) throw failure3("reference_invalid");
|
|
21130
|
+
const parent = await ownedPath(root, ["client-observations", "v1", identity.platformDigest.slice(7), identity.accountDigest.slice(7)], true);
|
|
21131
|
+
const file = path5.join(parent, localReferenceId("creation", path5.resolve(configFile2)).slice(7) + ".json");
|
|
21132
|
+
const parse4 = (value3) => {
|
|
21133
|
+
if (!plain(value3) || Object.keys(value3).sort().join(",") !== "contractVersion,instanceId" || value3.contractVersion !== "promptframe-client-instance/v1" || typeof value3.instanceId !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(value3.instanceId)) throw failure3("record_invalid");
|
|
21134
|
+
return value3.instanceId;
|
|
21135
|
+
};
|
|
21136
|
+
const existing = await readJson(file);
|
|
21137
|
+
if (existing) return parse4(existing);
|
|
21138
|
+
const value2 = { contractVersion: "promptframe-client-instance/v1", instanceId: randomUUID() };
|
|
21139
|
+
const temporary = path5.join(parent, "." + randomUUID() + ".tmp");
|
|
21140
|
+
let fd;
|
|
21141
|
+
try {
|
|
21142
|
+
fd = await open4(temporary, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
21143
|
+
await fd.writeFile(JSON.stringify(value2) + "\n");
|
|
21144
|
+
await fd.sync();
|
|
21145
|
+
await fd.close();
|
|
21146
|
+
fd = void 0;
|
|
21147
|
+
await link(temporary, file);
|
|
21148
|
+
const directoryHandle = await open4(parent, constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
|
|
21149
|
+
try {
|
|
21150
|
+
privateOwner(await directoryHandle.stat(), true);
|
|
21151
|
+
await directoryHandle.sync();
|
|
21152
|
+
} finally {
|
|
21153
|
+
await directoryHandle.close();
|
|
21154
|
+
}
|
|
21155
|
+
return value2.instanceId;
|
|
21156
|
+
} catch (error6) {
|
|
21157
|
+
if (error6.code === "EEXIST") return parse4(await readJson(file));
|
|
21158
|
+
throw error6;
|
|
21159
|
+
} finally {
|
|
21160
|
+
await fd?.close();
|
|
21161
|
+
await unlink3(temporary).catch((error6) => {
|
|
21162
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
21163
|
+
});
|
|
21164
|
+
}
|
|
21165
|
+
}
|
|
21166
|
+
var localClientObservationInstance = accountIO(clientObservationInstance);
|
|
21121
21167
|
|
|
21122
21168
|
// lib/connection.mjs
|
|
21169
|
+
import path6 from "node:path";
|
|
21123
21170
|
function connectionAccountIdentity(client, expected) {
|
|
21124
21171
|
const raw = client.getServerCapabilities()?.experimental?.["promptframe.accountIdentity"];
|
|
21125
21172
|
if (raw === void 0) {
|
|
@@ -21134,7 +21181,8 @@ function connectionAccountIdentity(client, expected) {
|
|
|
21134
21181
|
}
|
|
21135
21182
|
return actual;
|
|
21136
21183
|
}
|
|
21137
|
-
async function connectPlatform(credentials, { host = resolveHostIdentity(), contentTypes = () => ["text"], contentSource = () => "text-fallback", enforceMinimum = true, signal, expectedIdentity } = {}) {
|
|
21184
|
+
async function connectPlatform(credentials, { host = resolveHostIdentity(), contentTypes = () => ["text"], contentSource = () => "text-fallback", enforceMinimum = true, signal, expectedIdentity, clientConfigFile, observationRoot } = {}) {
|
|
21185
|
+
let observation;
|
|
21138
21186
|
const client = new Client(
|
|
21139
21187
|
{ name: "promptframe-creation-bridge", version: CLIENT_VERSION },
|
|
21140
21188
|
{ capabilities: {} }
|
|
@@ -21147,6 +21195,7 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
|
|
|
21147
21195
|
const types = declaredHostContentTypes({ experimental: { "promptframe.contentTypes": contentTypes() } });
|
|
21148
21196
|
headers.set("X-PromptFrame-Content-Types", JSON.stringify(types));
|
|
21149
21197
|
headers.set("X-PromptFrame-Content-Source", contentSource());
|
|
21198
|
+
if (observation) headers.set("X-PromptFrame-Client-Observation", encodeURIComponent(JSON.stringify(observation)));
|
|
21150
21199
|
return fetch(url2, { ...init, headers, ...signal ? { signal: init?.signal ? AbortSignal.any([init.signal, signal]) : signal } : {} });
|
|
21151
21200
|
},
|
|
21152
21201
|
requestInit: {
|
|
@@ -21165,19 +21214,35 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
|
|
|
21165
21214
|
);
|
|
21166
21215
|
try {
|
|
21167
21216
|
await client.connect(transport2, signal ? { signal } : void 0);
|
|
21168
|
-
connectionAccountIdentity(client, expectedIdentity);
|
|
21217
|
+
const identity = connectionAccountIdentity(client, expectedIdentity);
|
|
21218
|
+
if (identity && clientConfigFile) try {
|
|
21219
|
+
const instanceId = await localClientObservationInstance({
|
|
21220
|
+
identity,
|
|
21221
|
+
configFile: clientConfigFile,
|
|
21222
|
+
root: observationRoot ?? path6.join(path6.dirname(clientConfigFile), "client-observations")
|
|
21223
|
+
});
|
|
21224
|
+
const systemFamily = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform === "linux" ? process.env.WSL_INTEROP || process.env.WSL_DISTRO_NAME ? "WSL" : "Linux" : "unknown";
|
|
21225
|
+
observation = {
|
|
21226
|
+
contractVersion: "promptframe-client-observation/v1",
|
|
21227
|
+
instanceId,
|
|
21228
|
+
systemFamily,
|
|
21229
|
+
application: host.kind === "claude-code" ? "Claude Code" : host.kind === "antigravity" ? "Antigravity" : host.kind === "codex" ? "Codex" : "Creation",
|
|
21230
|
+
applicationVersion: CLIENT_VERSION
|
|
21231
|
+
};
|
|
21232
|
+
} catch {
|
|
21233
|
+
}
|
|
21169
21234
|
if (enforceMinimum) assertBridgeCompatible(client.getServerCapabilities(), CLIENT_VERSION);
|
|
21170
21235
|
else readPlatformBridgePolicy(client.getServerCapabilities());
|
|
21171
21236
|
return client;
|
|
21172
|
-
} catch (
|
|
21237
|
+
} catch (error6) {
|
|
21173
21238
|
await client.close().catch(() => {
|
|
21174
21239
|
});
|
|
21175
|
-
throw
|
|
21240
|
+
throw error6;
|
|
21176
21241
|
}
|
|
21177
21242
|
}
|
|
21178
21243
|
|
|
21179
21244
|
// lib/account-bridge.mjs
|
|
21180
|
-
import
|
|
21245
|
+
import path10 from "node:path";
|
|
21181
21246
|
|
|
21182
21247
|
// lib/host-context.mjs
|
|
21183
21248
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -21185,13 +21250,13 @@ import { createHash as createHash6 } from "node:crypto";
|
|
|
21185
21250
|
// lib/claude-host-session.mjs
|
|
21186
21251
|
import { constants as constants4 } from "node:fs";
|
|
21187
21252
|
import { open as open5, mkdir as mkdir4, lstat as lstat5, rename as rename4, unlink as unlink4, rmdir as rmdir2 } from "node:fs/promises";
|
|
21188
|
-
import
|
|
21253
|
+
import path8 from "node:path";
|
|
21189
21254
|
import { homedir as homedir4 } from "node:os";
|
|
21190
21255
|
import { createHash as createHash5, randomBytes as randomBytes3 } from "node:crypto";
|
|
21191
21256
|
|
|
21192
21257
|
// lib/claude-host-process.mjs
|
|
21193
21258
|
import { readFile as readFile3, readlink, stat } from "node:fs/promises";
|
|
21194
|
-
import
|
|
21259
|
+
import path7 from "node:path";
|
|
21195
21260
|
import { homedir as homedir3 } from "node:os";
|
|
21196
21261
|
import { createHash as createHash4 } from "node:crypto";
|
|
21197
21262
|
var hash2 = (value2) => createHash4("sha256").update(JSON.stringify(value2)).digest("hex");
|
|
@@ -21225,8 +21290,8 @@ async function claudeHostProcess({
|
|
|
21225
21290
|
if (visited.has(child.ppid)) return null;
|
|
21226
21291
|
visited.add(child.ppid);
|
|
21227
21292
|
const host = await readBirth(child.ppid);
|
|
21228
|
-
const roots2 = [
|
|
21229
|
-
if (roots2.some((root) =>
|
|
21293
|
+
const roots2 = [path7.join(home, ".claude", "remote", "ccd-cli"), path7.join(home, ".local", "share", "claude", "versions")];
|
|
21294
|
+
if (roots2.some((root) => path7.dirname(host.exe) === root)) {
|
|
21230
21295
|
const executable = await readExecutable(host.exe);
|
|
21231
21296
|
if (host.uid !== uid || ![uid, 0].includes(executable.uid) || !executable.isFile() || executable.mode & 18 || host.inode !== executable.ino || host.device !== executable.dev) return null;
|
|
21232
21297
|
if (purpose === "hook") {
|
|
@@ -21234,8 +21299,8 @@ async function claudeHostProcess({
|
|
|
21234
21299
|
if (!entryFile || !command2.some((arg) => arg.includes(entryFile)) || !command2.some((arg) => arg === "claude-host-hook" || arg.includes(" claude-host-hook"))) return null;
|
|
21235
21300
|
}
|
|
21236
21301
|
const binding = { pid: host.pid, birth: host.birth, uid, device: host.device, inode: host.inode, exe: host.exe, boot };
|
|
21237
|
-
const
|
|
21238
|
-
return { binding, digest:
|
|
21302
|
+
const digest6 = hash2(binding);
|
|
21303
|
+
return { binding, digest: digest6, eventOrder: { birth: child.birth, pid: child.pid }, async isCurrent() {
|
|
21239
21304
|
try {
|
|
21240
21305
|
const current = await readBirth(binding.pid);
|
|
21241
21306
|
return current.birth === binding.birth && current.uid === uid && current.device === binding.device && current.inode === binding.inode && current.exe === binding.exe && await readBoot() === boot;
|
|
@@ -21291,9 +21356,9 @@ async function privateRead(file) {
|
|
|
21291
21356
|
}
|
|
21292
21357
|
async function createClaudeHostSession({ configFile: configFile2, env = process.env, root, association, hookProcess = false } = {}) {
|
|
21293
21358
|
const owner = association === void 0 ? await claudeHostProcess({ env, purpose: hookProcess ? "hook" : "bridge" }) : association;
|
|
21294
|
-
const base = root ??
|
|
21295
|
-
const namespace = owner ?
|
|
21296
|
-
const stateFile = namespace &&
|
|
21359
|
+
const base = root ?? path8.join(env.CLAUDE_CONFIG_DIR ?? path8.join(homedir4(), ".claude"), "promptframe-host-sessions");
|
|
21360
|
+
const namespace = owner ? path8.join(base, digest2([owner.digest, path8.resolve(configFile2)])) : null;
|
|
21361
|
+
const stateFile = namespace && path8.join(namespace, "state.json");
|
|
21297
21362
|
async function state() {
|
|
21298
21363
|
if (!owner || !await owner.isCurrent()) return null;
|
|
21299
21364
|
const value2 = await privateRead(stateFile);
|
|
@@ -21305,7 +21370,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
|
|
|
21305
21370
|
if (!owner || !await owner.isCurrent()) throw error2("host_identity_unavailable");
|
|
21306
21371
|
await privateDirectory(base);
|
|
21307
21372
|
await privateDirectory(namespace);
|
|
21308
|
-
const lock =
|
|
21373
|
+
const lock = path8.join(namespace, "write.lock");
|
|
21309
21374
|
let acquired = false;
|
|
21310
21375
|
for (let count = 0; count < 100; count++) try {
|
|
21311
21376
|
await mkdir4(lock, { mode: 448 });
|
|
@@ -21327,7 +21392,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
|
|
|
21327
21392
|
}
|
|
21328
21393
|
const body = JSON.stringify(next);
|
|
21329
21394
|
if (Buffer.byteLength(body) > 196608) throw error2("host_identity_unavailable");
|
|
21330
|
-
temporary =
|
|
21395
|
+
temporary = path8.join(namespace, "state-" + randomBytes3(16).toString("hex") + ".partial");
|
|
21331
21396
|
const file = await open5(temporary, constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL | constants4.O_NOFOLLOW, 384);
|
|
21332
21397
|
try {
|
|
21333
21398
|
await file.writeFile(body);
|
|
@@ -21451,34 +21516,34 @@ async function runClaudeHostHook({ configFile: configFile2, input = process.stdi
|
|
|
21451
21516
|
// lib/development-pairing.mjs
|
|
21452
21517
|
import { open as open6, stat as stat2 } from "node:fs/promises";
|
|
21453
21518
|
import { constants as constants5 } from "node:fs";
|
|
21454
|
-
import
|
|
21519
|
+
import path9 from "node:path";
|
|
21455
21520
|
async function readDevelopmentPairingFile(filePath, { signal } = {}) {
|
|
21456
|
-
const
|
|
21521
|
+
const fail9 = () => {
|
|
21457
21522
|
throw new CreationClientError("creation.development_pairing.private_file_unavailable");
|
|
21458
21523
|
};
|
|
21459
|
-
if (typeof filePath !== "string" || filePath.length > 4096 || !
|
|
21524
|
+
if (typeof filePath !== "string" || filePath.length > 4096 || !path9.isAbsolute(filePath)) fail9();
|
|
21460
21525
|
let file;
|
|
21461
21526
|
try {
|
|
21462
21527
|
signal?.throwIfAborted();
|
|
21463
21528
|
file = await open6(filePath, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
|
|
21464
21529
|
const before = await file.stat();
|
|
21465
|
-
if (!before.isFile() || before.size < 2 || before.size > 8192 || process.platform !== "win32" && ((before.mode & 63) !== 0 || before.uid !== process.getuid()))
|
|
21530
|
+
if (!before.isFile() || before.size < 2 || before.size > 8192 || process.platform !== "win32" && ((before.mode & 63) !== 0 || before.uid !== process.getuid())) fail9();
|
|
21466
21531
|
const bytes2 = Buffer.alloc(before.size);
|
|
21467
21532
|
let offset = 0;
|
|
21468
21533
|
while (offset < bytes2.length) {
|
|
21469
21534
|
signal?.throwIfAborted();
|
|
21470
21535
|
const read2 = await file.read(bytes2, offset, bytes2.length - offset, offset);
|
|
21471
|
-
if (!read2.bytesRead)
|
|
21536
|
+
if (!read2.bytesRead) fail9();
|
|
21472
21537
|
offset += read2.bytesRead;
|
|
21473
21538
|
}
|
|
21474
21539
|
const after = await file.stat(), named = await stat2(filePath);
|
|
21475
21540
|
signal?.throwIfAborted();
|
|
21476
|
-
if ([after, named].some((value3) => value3.dev !== before.dev || value3.ino !== before.ino || value3.size !== before.size || value3.mtimeMs !== before.mtimeMs || value3.ctimeMs !== before.ctimeMs))
|
|
21541
|
+
if ([after, named].some((value3) => value3.dev !== before.dev || value3.ino !== before.ino || value3.size !== before.size || value3.mtimeMs !== before.mtimeMs || value3.ctimeMs !== before.ctimeMs)) fail9();
|
|
21477
21542
|
const value2 = JSON.parse(bytes2.toString("utf8"));
|
|
21478
|
-
if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
|
|
21543
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) fail9();
|
|
21479
21544
|
return Object.fromEntries(["url", "connectionId", "credential", "studioOrigin", "expiresAt", "contractVersion", "lifecycle"].filter((key) => Object.hasOwn(value2, key)).map((key) => [key, value2[key]]));
|
|
21480
21545
|
} catch {
|
|
21481
|
-
|
|
21546
|
+
fail9();
|
|
21482
21547
|
} finally {
|
|
21483
21548
|
await file?.close();
|
|
21484
21549
|
}
|
|
@@ -21503,10 +21568,10 @@ var boundedSet = (map, key, value2) => {
|
|
|
21503
21568
|
async function resolveHostCallBinding(raw, { host = resolveHostIdentity(), hostSession } = {}) {
|
|
21504
21569
|
for (const field of ["threadId", "controller", "clientDigest", "token", "controlVersion", "developmentPairing"]) if (Object.hasOwn(raw.arguments ?? {}, field))
|
|
21505
21570
|
throw new CreationClientError("creation.transport_authority_managed_by_bridge");
|
|
21506
|
-
if (host.kind
|
|
21571
|
+
if (isHookProofHost(host.kind)) {
|
|
21507
21572
|
if (hostSession) return hostSession.begin(raw);
|
|
21508
21573
|
if (raw.arguments?.[CLAUDE_HOST_PROOF] !== void 0) throw new CreationClientError("creation.host_identity_invalid");
|
|
21509
|
-
return { host: { kind:
|
|
21574
|
+
return { host: { kind: host.kind }, arguments: raw.arguments, assertCurrent: async () => {
|
|
21510
21575
|
} };
|
|
21511
21576
|
}
|
|
21512
21577
|
if (Object.hasOwn(raw.arguments ?? {}, CLAUDE_HOST_PROOF)) throw new CreationClientError("creation.transport_authority_managed_by_bridge");
|
|
@@ -21582,7 +21647,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
|
|
|
21582
21647
|
if (!schema || schema.type !== "object") throw new CreationClientError("creation.upgrade_required");
|
|
21583
21648
|
const p2 = schema.properties;
|
|
21584
21649
|
const { controlVersion: _managed, developmentPairing: _privatePairing, ...properties } = p2 ?? {};
|
|
21585
|
-
return { ...tool, inputSchema: { ...schema, properties: { ...properties, ...host.kind
|
|
21650
|
+
return { ...tool, inputSchema: { ...schema, properties: { ...properties, ...isHookProofHost(host.kind) ? {
|
|
21586
21651
|
[CLAUDE_HOST_PROOF]: { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\u7684\u5355\u6B21\u8EAB\u4EFD\u51ED\u8BC1\uFF1B\u8BF7\u4FDD\u7559\uFF0C\u4E0D\u81EA\u884C\u586B\u5199\u3002" }
|
|
21587
21652
|
} : {} }, ...schema.required ? { required: schema.required.filter((name) => name !== "controlVersion") } : {} } };
|
|
21588
21653
|
}) };
|
|
@@ -21617,7 +21682,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
|
|
|
21617
21682
|
}
|
|
21618
21683
|
async function knowledgeRead(kind, method, raw = {}) {
|
|
21619
21684
|
if (!upstream[kind]) throw new CreationClientError("creation.knowledge_unsupported");
|
|
21620
|
-
const params = hostParameters(raw, host.kind
|
|
21685
|
+
const params = hostParameters(raw, isHookProofHost(host.kind) ? { kind: host.kind } : host, "independent-read"), order = ++sequence;
|
|
21621
21686
|
const result = assertMcpResponseBudget(await client[method](params, void 0, { timeout: 6e4 }));
|
|
21622
21687
|
const version3 = result._meta?.[kind === "resources" && method === "listResources" ? "promptframe.guideDirectoryVersion" : "promptframe.guideVersion"];
|
|
21623
21688
|
const key = JSON.stringify([kind, method, raw.uri ?? raw.arguments?.projectId ?? null]);
|
|
@@ -21740,9 +21805,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
|
|
|
21740
21805
|
let response;
|
|
21741
21806
|
try {
|
|
21742
21807
|
response = await send(outgoing, binding);
|
|
21743
|
-
} catch (
|
|
21808
|
+
} catch (error6) {
|
|
21744
21809
|
invalidate();
|
|
21745
|
-
throw
|
|
21810
|
+
throw error6;
|
|
21746
21811
|
}
|
|
21747
21812
|
if (response.result.isError) invalidate();
|
|
21748
21813
|
return response.result;
|
|
@@ -21768,7 +21833,7 @@ function localTool(name, host) {
|
|
|
21768
21833
|
identityKey: { type: "string", pattern: "^[a-f0-9]{64}-[a-f0-9]{64}$" },
|
|
21769
21834
|
referenceId: { type: "string", pattern: "^sha256:[a-f0-9]{64}$", description: "\u540C\u4E00\u8D26\u53F7\u6709\u591A\u4EFD\u521B\u4F5C\u6388\u6743\u65F6\u53EF\u660E\u786E\u9009\u62E9\u5217\u8868\u4E2D\u7684\u5F15\u7528\u3002" }
|
|
21770
21835
|
} : {};
|
|
21771
|
-
if (host.kind
|
|
21836
|
+
if (isHookProofHost(host.kind)) properties[CLAUDE_HOST_PROOF] = { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\uFF0C\u4FDD\u7559\u539F\u503C\u3002" };
|
|
21772
21837
|
return {
|
|
21773
21838
|
name,
|
|
21774
21839
|
description: name === listName ? "\u5217\u51FA\u672C\u673A\u5DF2\u767B\u8BB0\u8D26\u53F7\u7684\u5B89\u5168\u6458\u8981\u548C\u7F3A\u5C11\u7684\u6388\u6743\u7C7B\u578B\uFF0C\u4E0D\u8FD4\u56DE\u51ED\u636E\u6216\u672C\u673A\u8DEF\u5F84\u3002" : "\u53EA\u4E3A\u5F53\u524D\u5BBF\u4E3B\u4F1A\u8BDD\u9009\u62E9\u672C\u673A\u5DF2\u6388\u6743\u8D26\u53F7\uFF1B\u4E0D\u5207\u6362\u5176\u5B83Agent\uFF0C\u4E0D\u7533\u8BF7\u7F16\u8F91\u6743\u6216\u91CD\u653E\u4E1A\u52A1\u3002",
|
|
@@ -21804,11 +21869,11 @@ function createAccountAwareBridge(defaultClient, {
|
|
|
21804
21869
|
function caller(raw, binding, required2 = false) {
|
|
21805
21870
|
const params = { ...raw, arguments: binding.arguments };
|
|
21806
21871
|
hostParameters(params, binding.host, required2 ? "authority" : "independent-read");
|
|
21807
|
-
const sessionId = binding.host.kind
|
|
21872
|
+
const sessionId = isHookProofHost(binding.host.kind) ? binding.host.threadId : params._meta?.threadId;
|
|
21808
21873
|
return sessionId ? { kind: binding.host.kind, sessionId } : void 0;
|
|
21809
21874
|
}
|
|
21810
21875
|
async function context(identity, agent, referenceId) {
|
|
21811
|
-
if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation",
|
|
21876
|
+
if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation", path10.resolve(configFile2)))) return primary;
|
|
21812
21877
|
const refs = await readLocalAuthorizations({ root, identity, client: "creation" });
|
|
21813
21878
|
if (!refs.length) throw error3("creation_authorization_missing");
|
|
21814
21879
|
let ref = referenceId ? refs.find((value2) => value2.referenceId === referenceId) : refs.length === 1 ? refs[0] : void 0;
|
|
@@ -21819,7 +21884,7 @@ function createAccountAwareBridge(defaultClient, {
|
|
|
21819
21884
|
const pending = (async () => {
|
|
21820
21885
|
const saved = await readCredentials(ref.configFile);
|
|
21821
21886
|
if (!saved || localCredentialDigest(saved.token) !== ref.credentialDigest || normalizeEndpoint(saved.endpoint) !== normalizeEndpoint(ref.endpoint)) throw error3("reference_changed");
|
|
21822
|
-
const client = await connect(saved, { ...connectionOptions, host, expectedIdentity: identity });
|
|
21887
|
+
const client = await connect(saved, { ...connectionOptions, host, expectedIdentity: identity, clientConfigFile: ref.configFile });
|
|
21823
21888
|
try {
|
|
21824
21889
|
connectionAccountIdentity(client, identity);
|
|
21825
21890
|
return { client, bridge: makeBridge(client, saved, createLocalUploads?.({ identity, agent, configFile: ref.configFile })), identity, owned: true };
|
|
@@ -21910,8 +21975,189 @@ function createAccountAwareBridge(defaultClient, {
|
|
|
21910
21975
|
};
|
|
21911
21976
|
}
|
|
21912
21977
|
|
|
21978
|
+
// lib/antigravity-host-session.mjs
|
|
21979
|
+
import { constants as constants6 } from "node:fs";
|
|
21980
|
+
import { open as open7, mkdir as mkdir5, lstat as lstat6, rename as rename5, unlink as unlink5, rmdir as rmdir3 } from "node:fs/promises";
|
|
21981
|
+
import path11 from "node:path";
|
|
21982
|
+
import { homedir as homedir5 } from "node:os";
|
|
21983
|
+
import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
|
|
21984
|
+
var hex2 = /^[0-9a-f]{64}$/;
|
|
21985
|
+
var TICKET_TTL_MS = 12e4;
|
|
21986
|
+
var MAX_TICKETS = 256;
|
|
21987
|
+
var error4 = (code) => new CreationClientError("creation." + code);
|
|
21988
|
+
var canonical3 = (value2) => {
|
|
21989
|
+
if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2)) return JSON.stringify(value2);
|
|
21990
|
+
if (Array.isArray(value2)) return "[" + value2.map(canonical3).join(",") + "]";
|
|
21991
|
+
if (value2 && typeof value2 === "object" && [Object.prototype, null].includes(Object.getPrototypeOf(value2)))
|
|
21992
|
+
return "{" + Object.keys(value2).sort().map((key) => JSON.stringify(key) + ":" + canonical3(value2[key])).join(",") + "}";
|
|
21993
|
+
throw error4("request_invalid");
|
|
21994
|
+
};
|
|
21995
|
+
var digest4 = (value2) => createHash7("sha256").update(canonical3(value2)).digest("hex");
|
|
21996
|
+
var withoutProof2 = (args2) => Object.fromEntries(Object.entries(args2 ?? {}).filter(([key]) => key !== CLAUDE_HOST_PROOF));
|
|
21997
|
+
function isPromptFrameToolName(name) {
|
|
21998
|
+
if (typeof name !== "string" || !name || name.length > 200) return false;
|
|
21999
|
+
return /(?:^|[_:])promptframe/i.test(name) || /^platform_[a-z0-9_]+$/i.test(name);
|
|
22000
|
+
}
|
|
22001
|
+
function toolNameMatches(hookToolName, bridgeToolName) {
|
|
22002
|
+
if (typeof hookToolName !== "string" || typeof bridgeToolName !== "string" || !bridgeToolName) return false;
|
|
22003
|
+
if (hookToolName === bridgeToolName) return true;
|
|
22004
|
+
return hookToolName.endsWith("_" + bridgeToolName) || hookToolName.endsWith(":" + bridgeToolName);
|
|
22005
|
+
}
|
|
22006
|
+
async function privateDirectory2(directory3) {
|
|
22007
|
+
try {
|
|
22008
|
+
await mkdir5(directory3, { recursive: true, mode: 448 });
|
|
22009
|
+
} catch (e) {
|
|
22010
|
+
if (e.code !== "EEXIST") throw e;
|
|
22011
|
+
}
|
|
22012
|
+
const info5 = await lstat6(directory3);
|
|
22013
|
+
if (!info5.isDirectory() || info5.isSymbolicLink() || info5.uid !== process.getuid?.() || info5.mode & 63) throw error4("host_identity_unavailable");
|
|
22014
|
+
}
|
|
22015
|
+
async function privateRead2(file) {
|
|
22016
|
+
let handle;
|
|
22017
|
+
try {
|
|
22018
|
+
handle = await open7(file, constants6.O_RDONLY | constants6.O_NOFOLLOW);
|
|
22019
|
+
const info5 = await handle.stat();
|
|
22020
|
+
if (!info5.isFile() || info5.uid !== process.getuid?.() || info5.mode & 63 || info5.size > 262144) throw error4("host_identity_unavailable");
|
|
22021
|
+
return JSON.parse(await handle.readFile("utf8"));
|
|
22022
|
+
} catch (e) {
|
|
22023
|
+
if (e.code === "ENOENT") return null;
|
|
22024
|
+
throw e;
|
|
22025
|
+
} finally {
|
|
22026
|
+
await handle?.close();
|
|
22027
|
+
}
|
|
22028
|
+
}
|
|
22029
|
+
function antigravityConfigRoot(env = process.env) {
|
|
22030
|
+
return path11.resolve(env.ANTIGRAVITY_CONFIG_DIR ?? env.GEMINI_CONFIG_DIR ?? path11.join(homedir5(), ".gemini", "config"));
|
|
22031
|
+
}
|
|
22032
|
+
async function createAntigravityHostSession({ configFile: configFile2, env = process.env, root, now = () => Date.now() } = {}) {
|
|
22033
|
+
const base = root ?? path11.join(antigravityConfigRoot(env), "promptframe-host-sessions");
|
|
22034
|
+
const namespace = path11.join(base, digest4(path11.resolve(configFile2)));
|
|
22035
|
+
const stateFile = path11.join(namespace, "state.json");
|
|
22036
|
+
async function readState() {
|
|
22037
|
+
const value2 = await privateRead2(stateFile);
|
|
22038
|
+
if (!value2) return { contractVersion: "antigravity-host-session/v1", tickets: {} };
|
|
22039
|
+
if (value2.contractVersion !== "antigravity-host-session/v1" || !value2.tickets || typeof value2.tickets !== "object" || Array.isArray(value2.tickets) || Object.keys(value2.tickets).length > MAX_TICKETS + 32) throw error4("host_identity_unavailable");
|
|
22040
|
+
return value2;
|
|
22041
|
+
}
|
|
22042
|
+
async function transaction(work) {
|
|
22043
|
+
await privateDirectory2(base);
|
|
22044
|
+
await privateDirectory2(namespace);
|
|
22045
|
+
const lock = path11.join(namespace, "write.lock");
|
|
22046
|
+
let acquired = false;
|
|
22047
|
+
for (let count = 0; count < 100; count++) try {
|
|
22048
|
+
await mkdir5(lock, { mode: 448 });
|
|
22049
|
+
acquired = true;
|
|
22050
|
+
break;
|
|
22051
|
+
} catch (e) {
|
|
22052
|
+
if (e.code !== "EEXIST") throw e;
|
|
22053
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
22054
|
+
}
|
|
22055
|
+
if (!acquired) throw error4("host_identity_unavailable");
|
|
22056
|
+
let temporary;
|
|
22057
|
+
try {
|
|
22058
|
+
const current = await readState();
|
|
22059
|
+
const next = await work(current);
|
|
22060
|
+
if (next === void 0) return;
|
|
22061
|
+
const body = JSON.stringify(next);
|
|
22062
|
+
if (Buffer.byteLength(body) > 262144) throw error4("host_identity_unavailable");
|
|
22063
|
+
temporary = path11.join(namespace, "state-" + randomBytes4(16).toString("hex") + ".partial");
|
|
22064
|
+
const file = await open7(temporary, constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL | constants6.O_NOFOLLOW, 384);
|
|
22065
|
+
try {
|
|
22066
|
+
await file.writeFile(body);
|
|
22067
|
+
await file.sync();
|
|
22068
|
+
} finally {
|
|
22069
|
+
await file.close();
|
|
22070
|
+
}
|
|
22071
|
+
await rename5(temporary, stateFile);
|
|
22072
|
+
temporary = void 0;
|
|
22073
|
+
const directory3 = await open7(namespace, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
|
|
22074
|
+
try {
|
|
22075
|
+
await directory3.sync();
|
|
22076
|
+
} finally {
|
|
22077
|
+
await directory3.close();
|
|
22078
|
+
}
|
|
22079
|
+
} finally {
|
|
22080
|
+
if (temporary) await unlink5(temporary).catch(() => {
|
|
22081
|
+
});
|
|
22082
|
+
await rmdir3(lock).catch(() => {
|
|
22083
|
+
});
|
|
22084
|
+
}
|
|
22085
|
+
}
|
|
22086
|
+
function pruneTickets(tickets, currentTime) {
|
|
22087
|
+
const kept = {};
|
|
22088
|
+
for (const [k2, v2] of Object.entries(tickets)) {
|
|
22089
|
+
if (v2 && typeof v2 === "object" && typeof v2.expiresAt === "number" && v2.expiresAt > currentTime && typeof v2.conversationId === "string" && threadFormat.test(v2.conversationId)) kept[k2] = v2;
|
|
22090
|
+
}
|
|
22091
|
+
const keys = Object.keys(kept);
|
|
22092
|
+
while (keys.length >= MAX_TICKETS) delete kept[keys.shift()];
|
|
22093
|
+
return kept;
|
|
22094
|
+
}
|
|
22095
|
+
async function begin(raw) {
|
|
22096
|
+
const proof = raw.arguments?.[CLAUDE_HOST_PROOF], args2 = withoutProof2(raw.arguments);
|
|
22097
|
+
if (proof === void 0) return { host: { kind: "antigravity" }, assertCurrent: async () => {
|
|
22098
|
+
}, arguments: args2 };
|
|
22099
|
+
if (typeof proof !== "string" || !hex2.test(proof)) throw error4("host_identity_invalid");
|
|
22100
|
+
const argsHash = digest4(args2), currentTime = now();
|
|
22101
|
+
let accepted;
|
|
22102
|
+
try {
|
|
22103
|
+
await transaction((current) => {
|
|
22104
|
+
const ticket = current.tickets[proof];
|
|
22105
|
+
if (!ticket || ticket.expiresAt <= currentTime || ticket.argsDigest !== argsHash || !toolNameMatches(ticket.toolName, raw.name) || !threadFormat.test(ticket.conversationId ?? ""))
|
|
22106
|
+
throw error4("host_identity_invalid");
|
|
22107
|
+
accepted = { threadId: ticket.conversationId.toLowerCase() };
|
|
22108
|
+
delete current.tickets[proof];
|
|
22109
|
+
current.tickets = pruneTickets(current.tickets, currentTime);
|
|
22110
|
+
return current;
|
|
22111
|
+
});
|
|
22112
|
+
} catch (e) {
|
|
22113
|
+
if (e instanceof CreationClientError) throw e;
|
|
22114
|
+
throw error4("host_identity_unavailable");
|
|
22115
|
+
}
|
|
22116
|
+
return { host: { kind: "antigravity", threadId: accepted.threadId }, arguments: args2, assertCurrent: async () => {
|
|
22117
|
+
} };
|
|
22118
|
+
}
|
|
22119
|
+
async function hook(input) {
|
|
22120
|
+
const event = input?.hookEventName;
|
|
22121
|
+
if (event !== void 0 && event !== "PreToolUse") return {};
|
|
22122
|
+
const toolCall = input?.toolCall;
|
|
22123
|
+
if (!toolCall || typeof toolCall !== "object" || typeof toolCall.name !== "string") return { decision: "allow" };
|
|
22124
|
+
if (!isPromptFrameToolName(toolCall.name)) return { decision: "allow" };
|
|
22125
|
+
const rawArgs = toolCall.args && typeof toolCall.args === "object" && !Array.isArray(toolCall.args) ? toolCall.args : {};
|
|
22126
|
+
const conversationId = typeof input.conversationId === "string" && threadFormat.test(input.conversationId) ? input.conversationId.toLowerCase() : null;
|
|
22127
|
+
if (!conversationId) {
|
|
22128
|
+
return Object.hasOwn(rawArgs, CLAUDE_HOST_PROOF) ? { decision: "deny", reason: "Missing valid Antigravity conversationId for PromptFrame proof." } : { decision: "allow" };
|
|
22129
|
+
}
|
|
22130
|
+
const args2 = withoutProof2(rawArgs), argsHash = digest4(args2), currentTime = now();
|
|
22131
|
+
let token;
|
|
22132
|
+
await transaction((current) => {
|
|
22133
|
+
const tickets = pruneTickets(current.tickets, currentTime);
|
|
22134
|
+
token = randomBytes4(32).toString("hex");
|
|
22135
|
+
tickets[token] = { toolName: toolCall.name, argsDigest: argsHash, conversationId, expiresAt: currentTime + TICKET_TTL_MS };
|
|
22136
|
+
return { contractVersion: "antigravity-host-session/v1", tickets };
|
|
22137
|
+
});
|
|
22138
|
+
return { decision: "allow", overwrite: { [CLAUDE_HOST_PROOF]: token } };
|
|
22139
|
+
}
|
|
22140
|
+
return { begin, hook };
|
|
22141
|
+
}
|
|
22142
|
+
async function readAntigravityHookInput(input) {
|
|
22143
|
+
const chunks = [];
|
|
22144
|
+
let bytes2 = 0;
|
|
22145
|
+
for await (const value2 of input) {
|
|
22146
|
+
const chunk = Buffer.isBuffer(value2) ? value2 : Buffer.from(value2);
|
|
22147
|
+
bytes2 += chunk.length;
|
|
22148
|
+
if (bytes2 > 2 * 1024 * 1024 + 65536) throw error4("host_identity_invalid");
|
|
22149
|
+
chunks.push(chunk);
|
|
22150
|
+
}
|
|
22151
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes2)));
|
|
22152
|
+
}
|
|
22153
|
+
async function runAntigravityHostHook({ configFile: configFile2, input = process.stdin, output = process.stdout, env = process.env } = {}) {
|
|
22154
|
+
const body = await readAntigravityHookInput(input);
|
|
22155
|
+
const store = await createAntigravityHostSession({ configFile: configFile2, env });
|
|
22156
|
+
output.write(JSON.stringify(await store.hook(body)) + "\n");
|
|
22157
|
+
}
|
|
22158
|
+
|
|
21913
22159
|
// lib/runtime-bootstrap.mjs
|
|
21914
|
-
import { createHash as
|
|
22160
|
+
import { createHash as createHash9, randomBytes as randomBytes5 } from "node:crypto";
|
|
21915
22161
|
import { gunzipSync } from "node:zlib";
|
|
21916
22162
|
|
|
21917
22163
|
// node_modules/tar/dist/esm/index.min.js
|
|
@@ -24884,18 +25130,18 @@ var To = (s3) => {
|
|
|
24884
25130
|
};
|
|
24885
25131
|
|
|
24886
25132
|
// lib/runtime-bootstrap.mjs
|
|
24887
|
-
import { lstat as
|
|
25133
|
+
import { lstat as lstat8, mkdir as mkdir6, open as open8, readFile as readFile5, readdir as readdir3, rename as rename6, rm, statfs } from "node:fs/promises";
|
|
24888
25134
|
import { execFile } from "node:child_process";
|
|
24889
25135
|
import { promisify } from "node:util";
|
|
24890
|
-
import
|
|
25136
|
+
import path13 from "node:path";
|
|
24891
25137
|
|
|
24892
25138
|
// lib/runtime-package.mjs
|
|
24893
|
-
import { lstat as
|
|
24894
|
-
import { createHash as
|
|
24895
|
-
import
|
|
25139
|
+
import { lstat as lstat7, readdir as readdir2, readFile as readFile4 } from "node:fs/promises";
|
|
25140
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
25141
|
+
import path12 from "node:path";
|
|
24896
25142
|
var RUNTIME_PACKAGE_ENTRIES = Object.freeze(["package.json", "README.md", "LICENSE", "bin", "dist", "lib", "skills", "docs", ".codex-plugin", ".mcp.json"]);
|
|
24897
25143
|
var OPTIONAL_HOST_ENTRIES = Object.freeze([".claude-plugin", ".claude-mcp.json"]);
|
|
24898
|
-
var hash3 = (b2) =>
|
|
25144
|
+
var hash3 = (b2) => createHash8("sha256").update(b2).digest("hex");
|
|
24899
25145
|
var invalid = (code) => {
|
|
24900
25146
|
throw new CreationClientError("installation." + code);
|
|
24901
25147
|
};
|
|
@@ -24904,7 +25150,7 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24904
25150
|
entries2 = [...RUNTIME_PACKAGE_ENTRIES];
|
|
24905
25151
|
for (const name of OPTIONAL_HOST_ENTRIES) {
|
|
24906
25152
|
try {
|
|
24907
|
-
await
|
|
25153
|
+
await lstat7(path12.join(root, name));
|
|
24908
25154
|
entries2.push(name);
|
|
24909
25155
|
} catch (e) {
|
|
24910
25156
|
if (e.code !== "ENOENT") throw e;
|
|
@@ -24916,19 +25162,19 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24916
25162
|
async function walk(relative) {
|
|
24917
25163
|
let s3;
|
|
24918
25164
|
try {
|
|
24919
|
-
s3 = await
|
|
24920
|
-
} catch (
|
|
24921
|
-
if (
|
|
25165
|
+
s3 = await lstat7(path12.join(root, relative));
|
|
25166
|
+
} catch (error6) {
|
|
25167
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
24922
25168
|
}
|
|
24923
25169
|
if (!s3 || s3.isSymbolicLink()) invalid("package_file_invalid");
|
|
24924
25170
|
if (s3.isDirectory()) {
|
|
24925
|
-
for (const name of (await readdir2(
|
|
25171
|
+
for (const name of (await readdir2(path12.join(root, relative))).sort()) {
|
|
24926
25172
|
if (name === "node_modules" || name === "credentials.json" || name.startsWith(".env")) invalid("package_file_invalid");
|
|
24927
|
-
await walk(
|
|
25173
|
+
await walk(path12.join(relative, name));
|
|
24928
25174
|
}
|
|
24929
25175
|
} else if (s3.isFile()) {
|
|
24930
25176
|
if (s3.size > 32 * 1024 * 1024) invalid("package_too_large");
|
|
24931
|
-
const body = await readFile4(
|
|
25177
|
+
const body = await readFile4(path12.join(root, relative));
|
|
24932
25178
|
bytes2 += body.length;
|
|
24933
25179
|
if (files.length >= 1024 || bytes2 > 32 * 1024 * 1024) invalid("package_too_large");
|
|
24934
25180
|
files.push({ path: relative, bytes: body.length, sha256: hash3(body), body });
|
|
@@ -24941,11 +25187,13 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24941
25187
|
if (pkg.name !== "@promptframe/creation" || !/^\d+\.\d+\.\d+$/.test(pkg.version) || plugin.version !== pkg.version) invalid("package_identity_invalid");
|
|
24942
25188
|
const claude = files.find((f2) => f2.path === ".claude-plugin/plugin.json");
|
|
24943
25189
|
if (claude && JSON.parse(claude.body).version !== pkg.version) invalid("package_identity_invalid");
|
|
25190
|
+
const antigravity = files.some((f2) => f2.path === "lib/antigravity-host-session.mjs");
|
|
25191
|
+
const hosts = ["codex", ...claude ? ["claude-code"] : [], ...antigravity ? ["antigravity"] : []];
|
|
24944
25192
|
return {
|
|
24945
25193
|
files,
|
|
24946
25194
|
version: pkg.version,
|
|
24947
|
-
hosts
|
|
24948
|
-
payloadDigest: hash3(JSON.stringify(files.map(({ path:
|
|
25195
|
+
hosts,
|
|
25196
|
+
payloadDigest: hash3(JSON.stringify(files.map(({ path: path23, bytes: bytes3, sha256 }) => ({ path: path23, bytes: bytes3, sha256 }))))
|
|
24949
25197
|
};
|
|
24950
25198
|
}
|
|
24951
25199
|
|
|
@@ -24955,9 +25203,9 @@ var REGISTRY = "https://registry.npmjs.org";
|
|
|
24955
25203
|
var MAX_ARCHIVE = 8 * 1024 * 1024;
|
|
24956
25204
|
var MAX_PAYLOAD = 32 * 1024 * 1024;
|
|
24957
25205
|
var MAX_TAR = 36 * 1024 * 1024;
|
|
24958
|
-
var hash4 = (b2) =>
|
|
25206
|
+
var hash4 = (b2) => createHash9("sha256").update(b2).digest("hex");
|
|
24959
25207
|
var execute = promisify(execFile);
|
|
24960
|
-
var
|
|
25208
|
+
var error5 = (code) => new CreationClientError("creation." + code);
|
|
24961
25209
|
var version2 = (v2) => {
|
|
24962
25210
|
compareBridgeVersions(v2, v2);
|
|
24963
25211
|
return v2;
|
|
@@ -24975,34 +25223,34 @@ var RuntimeSelectionError = class extends CreationClientError {
|
|
|
24975
25223
|
});
|
|
24976
25224
|
}
|
|
24977
25225
|
};
|
|
24978
|
-
var runtimeErrorDetails = (
|
|
25226
|
+
var runtimeErrorDetails = (error6) => error6 instanceof RuntimeSelectionError ? error6.runtimeFacts : void 0;
|
|
24979
25227
|
var snapshot = (payload) => ({
|
|
24980
25228
|
version: payload.version,
|
|
24981
25229
|
hosts: payload.hosts,
|
|
24982
25230
|
payloadDigest: payload.payloadDigest,
|
|
24983
|
-
files: payload.files.map(({ path:
|
|
25231
|
+
files: payload.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))
|
|
24984
25232
|
});
|
|
24985
25233
|
async function info(file) {
|
|
24986
25234
|
try {
|
|
24987
|
-
return await
|
|
25235
|
+
return await lstat8(file);
|
|
24988
25236
|
} catch (e) {
|
|
24989
25237
|
if (e.code === "ENOENT") return null;
|
|
24990
25238
|
throw e;
|
|
24991
25239
|
}
|
|
24992
25240
|
}
|
|
24993
|
-
async function
|
|
24994
|
-
await
|
|
24995
|
-
const s3 = await
|
|
24996
|
-
if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) throw
|
|
25241
|
+
async function privateDirectory3(dir) {
|
|
25242
|
+
await mkdir6(dir, { recursive: true, mode: 448 });
|
|
25243
|
+
const s3 = await lstat8(dir);
|
|
25244
|
+
if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) throw error5("runtime_cache_owner_invalid");
|
|
24997
25245
|
}
|
|
24998
25246
|
async function privateJSON(file) {
|
|
24999
25247
|
const s3 = await info(file);
|
|
25000
25248
|
if (!s3) return null;
|
|
25001
|
-
if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) throw
|
|
25249
|
+
if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) throw error5("runtime_cache_invalid");
|
|
25002
25250
|
return JSON.parse(await readFile5(file, "utf8"));
|
|
25003
25251
|
}
|
|
25004
25252
|
async function syncDirectory2(dir) {
|
|
25005
|
-
const fd = await
|
|
25253
|
+
const fd = await open8(dir, "r");
|
|
25006
25254
|
try {
|
|
25007
25255
|
await fd.sync();
|
|
25008
25256
|
} finally {
|
|
@@ -25010,7 +25258,7 @@ async function syncDirectory2(dir) {
|
|
|
25010
25258
|
}
|
|
25011
25259
|
}
|
|
25012
25260
|
async function exclusiveJSON(file, value2) {
|
|
25013
|
-
const fd = await
|
|
25261
|
+
const fd = await open8(file, "wx", 384);
|
|
25014
25262
|
try {
|
|
25015
25263
|
await fd.writeFile(JSON.stringify(value2) + "\n");
|
|
25016
25264
|
await fd.sync();
|
|
@@ -25022,9 +25270,9 @@ function checkedRuntimeMetadata(value2, expectedVersion) {
|
|
|
25022
25270
|
version2(expectedVersion);
|
|
25023
25271
|
const tarball = REGISTRY + "/@promptframe/creation/-/creation-" + expectedVersion + ".tgz";
|
|
25024
25272
|
if (value2?.name !== PACKAGE || value2.version !== expectedVersion || value2.dist?.tarball !== tarball || typeof value2.dist.integrity !== "string" || !/^sha512-[A-Za-z0-9+/]{86}==$/.test(value2.dist.integrity))
|
|
25025
|
-
throw
|
|
25273
|
+
throw error5("runtime_registry_identity_invalid");
|
|
25026
25274
|
const encoded = value2.dist.integrity.slice(7);
|
|
25027
|
-
if (Buffer.from(encoded, "base64").toString("base64") !== encoded) throw
|
|
25275
|
+
if (Buffer.from(encoded, "base64").toString("base64") !== encoded) throw error5("runtime_registry_identity_invalid");
|
|
25028
25276
|
return { version: expectedVersion, integrity: value2.dist.integrity, tarball };
|
|
25029
25277
|
}
|
|
25030
25278
|
async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2, timeoutMs }) {
|
|
@@ -25034,12 +25282,12 @@ async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2
|
|
|
25034
25282
|
let response;
|
|
25035
25283
|
try {
|
|
25036
25284
|
response = await fetchImpl(url2, { signal: controller.signal, redirect: "error" });
|
|
25037
|
-
if (response.status !== 200 || Number(response.headers.get("content-length") ?? 0) > maxBytes2 || !response.body) throw
|
|
25285
|
+
if (response.status !== 200 || Number(response.headers.get("content-length") ?? 0) > maxBytes2 || !response.body) throw error5("runtime_fetch_unavailable");
|
|
25038
25286
|
const chunks = [];
|
|
25039
25287
|
let count = 0;
|
|
25040
25288
|
for await (const chunk of response.body) {
|
|
25041
25289
|
count += chunk.length;
|
|
25042
|
-
if (count > maxBytes2) throw
|
|
25290
|
+
if (count > maxBytes2) throw error5("runtime_download_capacity");
|
|
25043
25291
|
chunks.push(Buffer.from(chunk));
|
|
25044
25292
|
}
|
|
25045
25293
|
return Buffer.concat(chunks, count);
|
|
@@ -25047,68 +25295,68 @@ async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2
|
|
|
25047
25295
|
await response?.body?.cancel().catch(() => {
|
|
25048
25296
|
});
|
|
25049
25297
|
if (e instanceof CreationClientError) throw e;
|
|
25050
|
-
throw
|
|
25298
|
+
throw error5("runtime_fetch_unavailable");
|
|
25051
25299
|
} finally {
|
|
25052
25300
|
clearTimeout(timer);
|
|
25053
25301
|
signal?.removeEventListener("abort", abort);
|
|
25054
25302
|
}
|
|
25055
25303
|
}
|
|
25056
25304
|
async function readRuntimeArchive(archive, metadata) {
|
|
25057
|
-
if (!Buffer.isBuffer(archive) || archive.length > MAX_ARCHIVE || "sha512-" +
|
|
25305
|
+
if (!Buffer.isBuffer(archive) || archive.length > MAX_ARCHIVE || "sha512-" + createHash9("sha512").update(archive).digest("base64") !== metadata.integrity) throw error5("runtime_integrity_invalid");
|
|
25058
25306
|
let raw;
|
|
25059
25307
|
try {
|
|
25060
25308
|
raw = gunzipSync(archive, { maxOutputLength: MAX_TAR });
|
|
25061
25309
|
} catch {
|
|
25062
|
-
throw
|
|
25310
|
+
throw error5("runtime_archive_invalid");
|
|
25063
25311
|
}
|
|
25064
25312
|
const files = [], names = /* @__PURE__ */ new Set();
|
|
25065
25313
|
let total = 0, entries2 = 0, failure4;
|
|
25066
25314
|
const parser = Ct({ strict: true, onReadEntry: (entry) => {
|
|
25067
25315
|
const name = entry.path;
|
|
25068
|
-
if (++entries2 > 2048 || !["File", "Directory"].includes(entry.type) || !Number.isSafeInteger(entry.size) || entry.size < 0 || entry.size > MAX_PAYLOAD || typeof name !== "string" || name.length > 240 || !name.startsWith("package/") || name.includes("\\") || /[\x00-\x1f\x7f]/.test(name)) failure4 =
|
|
25316
|
+
if (++entries2 > 2048 || !["File", "Directory"].includes(entry.type) || !Number.isSafeInteger(entry.size) || entry.size < 0 || entry.size > MAX_PAYLOAD || typeof name !== "string" || name.length > 240 || !name.startsWith("package/") || name.includes("\\") || /[\x00-\x1f\x7f]/.test(name)) failure4 = error5("runtime_archive_invalid");
|
|
25069
25317
|
const relative = name.slice(8).replace(/\/$/, "");
|
|
25070
25318
|
if (relative && (relative.normalize("NFC") !== relative || /[<>:"|?*]/.test(relative) || relative.split("/").some((p2) => !p2 || p2 === "." || p2 === ".." || /[. ]$/.test(p2) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(p2) || p2 === "node_modules" || p2 === "credentials.json" || p2.startsWith(".env")) || !roots.has(relative.split("/")[0])))
|
|
25071
|
-
failure4 =
|
|
25319
|
+
failure4 = error5("runtime_archive_invalid");
|
|
25072
25320
|
const portableName = relative.toLowerCase();
|
|
25073
|
-
if (names.has(portableName)) failure4 =
|
|
25321
|
+
if (names.has(portableName)) failure4 = error5("runtime_archive_invalid");
|
|
25074
25322
|
names.add(portableName);
|
|
25075
25323
|
if (entry.type === "Directory") {
|
|
25076
|
-
if (entry.size !== 0) failure4 =
|
|
25324
|
+
if (entry.size !== 0) failure4 = error5("runtime_archive_invalid");
|
|
25077
25325
|
return;
|
|
25078
25326
|
}
|
|
25079
25327
|
total += entry.size;
|
|
25080
|
-
if (total > MAX_PAYLOAD || files.length >= 1024 || !relative) failure4 =
|
|
25328
|
+
if (total > MAX_PAYLOAD || files.length >= 1024 || !relative) failure4 = error5("runtime_archive_capacity");
|
|
25081
25329
|
const chunks = [];
|
|
25082
25330
|
let bytes2 = 0;
|
|
25083
25331
|
entry.on("data", (chunk) => {
|
|
25084
25332
|
bytes2 += chunk.length;
|
|
25085
|
-
if (bytes2 > entry.size) failure4 =
|
|
25333
|
+
if (bytes2 > entry.size) failure4 = error5("runtime_archive_invalid");
|
|
25086
25334
|
if (!failure4) chunks.push(Buffer.from(chunk));
|
|
25087
25335
|
});
|
|
25088
25336
|
entry.on("end", () => {
|
|
25089
|
-
if (bytes2 !== entry.size) failure4 =
|
|
25337
|
+
if (bytes2 !== entry.size) failure4 = error5("runtime_archive_invalid");
|
|
25090
25338
|
if (!failure4) files.push({ path: relative, body: Buffer.concat(chunks, bytes2) });
|
|
25091
25339
|
});
|
|
25092
25340
|
} });
|
|
25093
25341
|
await new Promise((resolve, reject) => {
|
|
25094
|
-
parser.once("error", () => reject(
|
|
25342
|
+
parser.once("error", () => reject(error5("runtime_archive_invalid")));
|
|
25095
25343
|
parser.once("end", resolve);
|
|
25096
25344
|
parser.end(raw);
|
|
25097
25345
|
});
|
|
25098
25346
|
if (failure4) throw failure4;
|
|
25099
|
-
if (!files.length || files.length > 1024) throw
|
|
25347
|
+
if (!files.length || files.length > 1024) throw error5("runtime_archive_invalid");
|
|
25100
25348
|
return files;
|
|
25101
25349
|
}
|
|
25102
25350
|
async function cacheLock(root, signal) {
|
|
25103
|
-
const name =
|
|
25351
|
+
const name = path13.join(root, "prepare.lock"), end = Date.now() + 5e3;
|
|
25104
25352
|
let fd;
|
|
25105
25353
|
while (!fd) {
|
|
25106
25354
|
signal?.throwIfAborted();
|
|
25107
25355
|
try {
|
|
25108
|
-
fd = await
|
|
25356
|
+
fd = await open8(name, "wx", 384);
|
|
25109
25357
|
} catch (e) {
|
|
25110
25358
|
if (e.code !== "EEXIST") throw e;
|
|
25111
|
-
if (Date.now() >= end) throw
|
|
25359
|
+
if (Date.now() >= end) throw error5("runtime_cache_busy");
|
|
25112
25360
|
await pause(50);
|
|
25113
25361
|
}
|
|
25114
25362
|
}
|
|
@@ -25126,51 +25374,51 @@ async function cacheLock(root, signal) {
|
|
|
25126
25374
|
return async () => {
|
|
25127
25375
|
const now = await info(name);
|
|
25128
25376
|
await fd.close();
|
|
25129
|
-
if (!now || now.dev !== owned.dev || now.ino !== owned.ino) throw
|
|
25377
|
+
if (!now || now.dev !== owned.dev || now.ino !== owned.ino) throw error5("runtime_lock_changed");
|
|
25130
25378
|
await rm(name);
|
|
25131
25379
|
};
|
|
25132
25380
|
}
|
|
25133
25381
|
async function verifyCached(target, metadata, hostKind) {
|
|
25134
25382
|
if (!await info(target)) return null;
|
|
25135
|
-
await
|
|
25136
|
-
const manifest = await privateJSON(
|
|
25383
|
+
await privateDirectory3(target);
|
|
25384
|
+
const manifest = await privateJSON(path13.join(target, "runtime.json"));
|
|
25137
25385
|
if (!manifest || manifest.contractVersion !== "creation-verified-runtime/v1" || manifest.version !== metadata.version || manifest.integrity !== metadata.integrity)
|
|
25138
|
-
throw
|
|
25386
|
+
throw error5("runtime_cache_invalid");
|
|
25139
25387
|
const names = (await readdir3(target)).filter((name) => name !== "runtime.json").sort();
|
|
25140
|
-
if (names.some((name) => !roots.has(name)) || RUNTIME_PACKAGE_ENTRIES.some((name) => !names.includes(name))) throw
|
|
25388
|
+
if (names.some((name) => !roots.has(name)) || RUNTIME_PACKAGE_ENTRIES.some((name) => !names.includes(name))) throw error5("runtime_cache_invalid");
|
|
25141
25389
|
const payload = await inspectRuntimePackage(target, { entries: names });
|
|
25142
|
-
if (!payload.hosts.includes(hostKind)) throw
|
|
25143
|
-
if (JSON.stringify(snapshot(payload)) !== JSON.stringify(manifest.payload)) throw
|
|
25390
|
+
if (!payload.hosts.includes(hostKind)) throw error5("runtime_host_unsupported");
|
|
25391
|
+
if (JSON.stringify(snapshot(payload)) !== JSON.stringify(manifest.payload)) throw error5("runtime_cache_invalid");
|
|
25144
25392
|
return { version: payload.version, root: target, integrity: metadata.integrity, reused: true };
|
|
25145
25393
|
}
|
|
25146
25394
|
async function checkedVersionIndex(cacheRoot, metadata) {
|
|
25147
|
-
const old = await privateJSON(
|
|
25148
|
-
if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw
|
|
25395
|
+
const old = await privateJSON(path13.join(cacheRoot, "version-" + metadata.version + ".json"));
|
|
25396
|
+
if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw error5("runtime_registry_identity_conflict");
|
|
25149
25397
|
return old;
|
|
25150
25398
|
}
|
|
25151
25399
|
async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
|
|
25152
|
-
if (!
|
|
25153
|
-
if (!
|
|
25400
|
+
if (!SUPPORTED_HOSTS.includes(hostKind)) throw error5("runtime_host_unsupported");
|
|
25401
|
+
if (!path13.isAbsolute(cacheRoot ?? "")) throw error5("runtime_cache_owner_invalid");
|
|
25154
25402
|
metadata = checkedRuntimeMetadata({ name: PACKAGE, version: metadata.version, dist: metadata }, metadata.version);
|
|
25155
|
-
await
|
|
25403
|
+
await privateDirectory3(cacheRoot);
|
|
25156
25404
|
await checkedVersionIndex(cacheRoot, metadata);
|
|
25157
|
-
const target =
|
|
25405
|
+
const target = path13.join(cacheRoot, metadata.version + "-" + hash4(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
|
|
25158
25406
|
if (existing) return existing;
|
|
25159
25407
|
const archive = await boundedGet(metadata.tarball, { fetchImpl, signal, maxBytes: MAX_ARCHIVE, timeoutMs: 15e3 });
|
|
25160
25408
|
const files = await readRuntimeArchive(archive, metadata), release = await cacheLock(cacheRoot, signal);
|
|
25161
|
-
const temporary =
|
|
25409
|
+
const temporary = path13.join(cacheRoot, ".partial-" + randomBytes5(12).toString("hex"));
|
|
25162
25410
|
try {
|
|
25163
25411
|
const index = await checkedVersionIndex(cacheRoot, metadata);
|
|
25164
25412
|
const found = await verifyCached(target, metadata, hostKind);
|
|
25165
25413
|
if (found) return found;
|
|
25166
25414
|
const space = await statfs(cacheRoot, { bigint: true }), needed = BigInt(files.reduce((n, f2) => n + f2.body.length, 0) + 4 * 1024 * 1024);
|
|
25167
|
-
if (space.bavail * space.bsize < needed) throw
|
|
25168
|
-
await
|
|
25415
|
+
if (space.bavail * space.bsize < needed) throw error5("runtime_cache_capacity");
|
|
25416
|
+
await mkdir6(temporary, { mode: 448 });
|
|
25169
25417
|
for (const file of files) {
|
|
25170
25418
|
signal?.throwIfAborted();
|
|
25171
|
-
const dest =
|
|
25172
|
-
await
|
|
25173
|
-
const fd = await
|
|
25419
|
+
const dest = path13.join(temporary, ...file.path.split("/"));
|
|
25420
|
+
await mkdir6(path13.dirname(dest), { recursive: true, mode: 448 });
|
|
25421
|
+
const fd = await open8(dest, "wx", 384);
|
|
25174
25422
|
try {
|
|
25175
25423
|
await fd.writeFile(file.body);
|
|
25176
25424
|
await fd.sync();
|
|
@@ -25179,26 +25427,26 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25179
25427
|
}
|
|
25180
25428
|
}
|
|
25181
25429
|
const entries2 = [...new Set(files.map((file) => file.path.split("/")[0]))].sort();
|
|
25182
|
-
if (RUNTIME_PACKAGE_ENTRIES.some((name) => !entries2.includes(name))) throw
|
|
25430
|
+
if (RUNTIME_PACKAGE_ENTRIES.some((name) => !entries2.includes(name))) throw error5("runtime_package_incomplete");
|
|
25183
25431
|
const payload = await inspectRuntimePackage(temporary, { entries: entries2 });
|
|
25184
|
-
if (!payload.hosts.includes(hostKind)) throw
|
|
25185
|
-
if (payload.version !== metadata.version) throw
|
|
25432
|
+
if (!payload.hosts.includes(hostKind)) throw error5("runtime_host_unsupported");
|
|
25433
|
+
if (payload.version !== metadata.version) throw error5("runtime_package_version_invalid");
|
|
25186
25434
|
const pkg = JSON.parse(payload.files.find((f2) => f2.path === "package.json").body);
|
|
25187
|
-
if (pkg.repository?.url !== "git+https://github.com/ty-teams/promptframe-creation.git" || pkg.private === true) throw
|
|
25435
|
+
if (pkg.repository?.url !== "git+https://github.com/ty-teams/promptframe-creation.git" || pkg.private === true) throw error5("runtime_package_identity_invalid");
|
|
25188
25436
|
if (checkRuntime) await checkRuntime(temporary, metadata.version);
|
|
25189
25437
|
else {
|
|
25190
25438
|
const result = await execute(
|
|
25191
25439
|
process.execPath,
|
|
25192
|
-
[
|
|
25440
|
+
[path13.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
|
|
25193
25441
|
{ timeout: 5e3, maxBuffer: 65536, windowsHide: true, signal, env: {
|
|
25194
25442
|
...process.env,
|
|
25195
|
-
PROMPTFRAME_CREATION_CONFIG:
|
|
25443
|
+
PROMPTFRAME_CREATION_CONFIG: path13.join(temporary, "no-credentials.json")
|
|
25196
25444
|
} }
|
|
25197
25445
|
);
|
|
25198
|
-
if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw
|
|
25446
|
+
if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw error5("runtime_package_version_invalid");
|
|
25199
25447
|
}
|
|
25200
25448
|
signal?.throwIfAborted();
|
|
25201
|
-
await exclusiveJSON(
|
|
25449
|
+
await exclusiveJSON(path13.join(temporary, "runtime.json"), {
|
|
25202
25450
|
contractVersion: "creation-verified-runtime/v1",
|
|
25203
25451
|
version: metadata.version,
|
|
25204
25452
|
integrity: metadata.integrity,
|
|
@@ -25206,10 +25454,10 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25206
25454
|
});
|
|
25207
25455
|
await syncDirectory2(temporary);
|
|
25208
25456
|
if (!index) {
|
|
25209
|
-
await exclusiveJSON(
|
|
25457
|
+
await exclusiveJSON(path13.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
|
|
25210
25458
|
await syncDirectory2(cacheRoot);
|
|
25211
25459
|
}
|
|
25212
|
-
await
|
|
25460
|
+
await rename6(temporary, target);
|
|
25213
25461
|
await syncDirectory2(cacheRoot);
|
|
25214
25462
|
return { version: metadata.version, root: target, integrity: metadata.integrity, reused: false };
|
|
25215
25463
|
} finally {
|
|
@@ -25223,7 +25471,7 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25223
25471
|
async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, resolvedVersion, cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
|
|
25224
25472
|
version2(currentVersion);
|
|
25225
25473
|
if (lockedVersion !== void 0) version2(lockedVersion);
|
|
25226
|
-
if (resolvedVersion !== void 0 && resolvedVersion !== currentVersion) throw
|
|
25474
|
+
if (resolvedVersion !== void 0 && resolvedVersion !== currentVersion) throw error5("runtime_selection_identity_invalid");
|
|
25227
25475
|
if (!policy) throw new RuntimeSelectionError(
|
|
25228
25476
|
"platform_bridge_policy_unavailable",
|
|
25229
25477
|
currentVersion,
|
|
@@ -25242,13 +25490,13 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
|
|
|
25242
25490
|
return { version: currentVersion, current: true, locked: lockedVersion !== void 0, status: "current" };
|
|
25243
25491
|
}
|
|
25244
25492
|
try {
|
|
25245
|
-
await
|
|
25493
|
+
await privateDirectory3(cacheRoot);
|
|
25246
25494
|
let metadata, metadataSource = "registry";
|
|
25247
25495
|
try {
|
|
25248
25496
|
const raw = await boundedGet(REGISTRY + "/@promptframe%2fcreation/" + target, { fetchImpl, signal, maxBytes: 256 * 1024, timeoutMs: 5e3 });
|
|
25249
25497
|
metadata = checkedRuntimeMetadata(JSON.parse(raw), target);
|
|
25250
25498
|
} catch (e) {
|
|
25251
|
-
const prior = await privateJSON(
|
|
25499
|
+
const prior = await privateJSON(path13.join(cacheRoot, "version-" + target + ".json"));
|
|
25252
25500
|
if (!prior) throw e;
|
|
25253
25501
|
metadata = checkedRuntimeMetadata({ name: PACKAGE, version: target, dist: prior }, target);
|
|
25254
25502
|
metadataSource = "previously-verified-cache";
|
|
@@ -25261,29 +25509,29 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
|
|
|
25261
25509
|
metadataSource
|
|
25262
25510
|
};
|
|
25263
25511
|
} catch (e) {
|
|
25264
|
-
if (signal?.aborted) throw
|
|
25512
|
+
if (signal?.aborted) throw error5("runtime_selection_interrupted");
|
|
25265
25513
|
if (lockedVersion !== void 0)
|
|
25266
25514
|
throw new RuntimeSelectionError("bridge_locked_version_unavailable", currentVersion, lockedVersion, policy, "retry_same_fixed_version_in_new_session");
|
|
25267
25515
|
if (policy && compareBridgeVersions(currentVersion, policy.minBridge) >= 0)
|
|
25268
25516
|
return { version: currentVersion, current: true, locked: false, status: "update_unavailable_current_compatible" };
|
|
25269
25517
|
if (policy) assertBridgeCompatible({ experimental: { "promptframe.creation": policy } }, currentVersion);
|
|
25270
25518
|
if (e instanceof CreationClientError) throw e;
|
|
25271
|
-
throw
|
|
25519
|
+
throw error5("runtime_selection_unavailable");
|
|
25272
25520
|
}
|
|
25273
25521
|
}
|
|
25274
25522
|
|
|
25275
25523
|
// lib/runtime-launch.mjs
|
|
25276
25524
|
import { spawn } from "node:child_process";
|
|
25277
|
-
import
|
|
25525
|
+
import path14 from "node:path";
|
|
25278
25526
|
async function launchSelectedBridge(selection, { host, configFile: configFile2, spawnImpl = spawn, env = process.env } = {}) {
|
|
25279
|
-
if (!
|
|
25527
|
+
if (!path14.isAbsolute(selection.root ?? "") || !path14.isAbsolute(configFile2 ?? "") || !SUPPORTED_HOSTS.includes(host?.kind))
|
|
25280
25528
|
throw new CreationClientError("creation.runtime_launch_invalid");
|
|
25281
25529
|
let child;
|
|
25282
25530
|
try {
|
|
25283
25531
|
child = spawnImpl(
|
|
25284
25532
|
process.execPath,
|
|
25285
25533
|
[
|
|
25286
|
-
|
|
25534
|
+
path14.join(selection.root, "bin/promptframe-creation.mjs"),
|
|
25287
25535
|
"bridge",
|
|
25288
25536
|
"--config",
|
|
25289
25537
|
configFile2,
|
|
@@ -25325,10 +25573,10 @@ async function launchSelectedBridge(selection, { host, configFile: configFile2,
|
|
|
25325
25573
|
// lib/user-installation.mjs
|
|
25326
25574
|
import { execFile as execFile2 } from "node:child_process";
|
|
25327
25575
|
import { promisify as promisify2 } from "node:util";
|
|
25328
|
-
import { createHash as
|
|
25329
|
-
import { lstat as
|
|
25330
|
-
import { homedir as
|
|
25331
|
-
import
|
|
25576
|
+
import { createHash as createHash10, randomBytes as randomBytes6 } from "node:crypto";
|
|
25577
|
+
import { lstat as lstat9, mkdir as mkdir7, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename7, rm as rm2, open as open9 } from "node:fs/promises";
|
|
25578
|
+
import { homedir as homedir6 } from "node:os";
|
|
25579
|
+
import path15 from "node:path";
|
|
25332
25580
|
|
|
25333
25581
|
// node_modules/smol-toml/dist/error.js
|
|
25334
25582
|
function getLineColFromPtr(string4, ptr) {
|
|
@@ -25420,14 +25668,14 @@ function parseString(ctx) {
|
|
|
25420
25668
|
let value2 = 0;
|
|
25421
25669
|
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
25422
25670
|
for (let j2 = 0; j2 < len; j2++, ctx.p++) {
|
|
25423
|
-
let
|
|
25671
|
+
let hex3 = ctx.s.charCodeAt(ctx.p);
|
|
25424
25672
|
let digit = (
|
|
25425
25673
|
/* 0-9 */
|
|
25426
|
-
|
|
25674
|
+
hex3 >= 48 && hex3 <= 57 ? hex3 - 48 : (
|
|
25427
25675
|
/* A-F */
|
|
25428
|
-
|
|
25676
|
+
hex3 >= 65 && hex3 <= 70 ? hex3 - 65 + 10 : (
|
|
25429
25677
|
/* a-f */
|
|
25430
|
-
|
|
25678
|
+
hex3 >= 97 && hex3 <= 102 ? hex3 - 97 + 10 : -1
|
|
25431
25679
|
)
|
|
25432
25680
|
)
|
|
25433
25681
|
);
|
|
@@ -26090,7 +26338,7 @@ var HAS_WELLFORMED = !!"".isWellFormed;
|
|
|
26090
26338
|
|
|
26091
26339
|
// lib/user-installation.mjs
|
|
26092
26340
|
var execute2 = promisify2(execFile2);
|
|
26093
|
-
var hash5 = (b2) =>
|
|
26341
|
+
var hash5 = (b2) => createHash10("sha256").update(b2).digest("hex");
|
|
26094
26342
|
var InstallationError = class extends CreationClientError {
|
|
26095
26343
|
constructor(code, details) {
|
|
26096
26344
|
super("installation." + code);
|
|
@@ -26100,7 +26348,7 @@ var InstallationError = class extends CreationClientError {
|
|
|
26100
26348
|
var fail4 = (code, details) => {
|
|
26101
26349
|
throw new InstallationError(code, details);
|
|
26102
26350
|
};
|
|
26103
|
-
var installationErrorDetails = (
|
|
26351
|
+
var installationErrorDetails = (error6) => error6 instanceof InstallationError ? error6.details : void 0;
|
|
26104
26352
|
function compareVersions(a, b2) {
|
|
26105
26353
|
const left = a.split(".").map(BigInt), right = b2.split(".").map(BigInt);
|
|
26106
26354
|
for (let i = 0; i < 3; i++) {
|
|
@@ -26129,8 +26377,8 @@ function validProfile(profile) {
|
|
|
26129
26377
|
}
|
|
26130
26378
|
function profileCredentialsPath(profile = "default", env = process.env) {
|
|
26131
26379
|
validProfile(profile);
|
|
26132
|
-
return profile === "default" ? credentialsPath(env) :
|
|
26133
|
-
env.XDG_CONFIG_HOME ??
|
|
26380
|
+
return profile === "default" ? credentialsPath(env) : path15.resolve(
|
|
26381
|
+
env.XDG_CONFIG_HOME ?? path15.join(homedir6(), ".config"),
|
|
26134
26382
|
"promptframe-creation",
|
|
26135
26383
|
"profiles",
|
|
26136
26384
|
profile,
|
|
@@ -26139,18 +26387,18 @@ function profileCredentialsPath(profile = "default", env = process.env) {
|
|
|
26139
26387
|
}
|
|
26140
26388
|
async function info2(file) {
|
|
26141
26389
|
try {
|
|
26142
|
-
return await
|
|
26390
|
+
return await lstat9(file);
|
|
26143
26391
|
} catch (e) {
|
|
26144
26392
|
if (e.code === "ENOENT") return null;
|
|
26145
26393
|
throw e;
|
|
26146
26394
|
}
|
|
26147
26395
|
}
|
|
26148
|
-
async function
|
|
26149
|
-
await
|
|
26150
|
-
const s3 = await
|
|
26396
|
+
async function privateDirectory4(dir) {
|
|
26397
|
+
await mkdir7(dir, { recursive: true, mode: 448 });
|
|
26398
|
+
const s3 = await lstat9(dir);
|
|
26151
26399
|
if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) fail4("private_owner_required");
|
|
26152
26400
|
}
|
|
26153
|
-
async function
|
|
26401
|
+
async function privateRead3(file) {
|
|
26154
26402
|
const s3 = await info2(file);
|
|
26155
26403
|
if (!s3) return null;
|
|
26156
26404
|
if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) fail4("state_invalid");
|
|
@@ -26162,20 +26410,20 @@ async function packageJSON(file) {
|
|
|
26162
26410
|
return json(file);
|
|
26163
26411
|
}
|
|
26164
26412
|
function sameTransport(actual, expected) {
|
|
26165
|
-
return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" &&
|
|
26413
|
+
return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path15.resolve(actual.cwd) === path15.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
|
|
26166
26414
|
}
|
|
26167
26415
|
async function managedTransport(installed, versions, serverName, profile, configFile2) {
|
|
26168
26416
|
if (!installed) return null;
|
|
26169
26417
|
const root = installed.source?.path;
|
|
26170
|
-
if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !==
|
|
26171
|
-
const directory3 = await info2(root), definition = await info2(
|
|
26418
|
+
if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path15.join(versions, installed.version)) fail4("existing_registration_requires_review");
|
|
26419
|
+
const directory3 = await info2(root), definition = await info2(path15.join(root, ".mcp.json"));
|
|
26172
26420
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || !definition?.isFile() || definition.isSymbolicLink()) fail4("installed_files_invalid");
|
|
26173
|
-
const ready = await
|
|
26421
|
+
const ready = await privateRead3(path15.join(root, "installation.json"));
|
|
26174
26422
|
if (!ready || ready.profile !== profile || ready.configFile !== configFile2 || ready.version !== installed.version) fail4("existing_registration_requires_review");
|
|
26175
|
-
const bytes2 = await readFile6(
|
|
26423
|
+
const bytes2 = await readFile6(path15.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
|
|
26176
26424
|
if (!entry || entry.bytes !== bytes2.length || entry.sha256 !== hash5(bytes2)) fail4("installed_files_invalid");
|
|
26177
26425
|
const mcp = JSON.parse(bytes2).mcpServers?.[serverName];
|
|
26178
|
-
if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([
|
|
26426
|
+
if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path15.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
|
|
26179
26427
|
return mcp;
|
|
26180
26428
|
}
|
|
26181
26429
|
async function officialNpmInstallation(installed, servers, env, profile, configFile2) {
|
|
@@ -26183,12 +26431,12 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
|
|
|
26183
26431
|
const candidates = installed.filter((p3) => p3.enabled === true && p3.name === "promptframe-creation" && p3.pluginId === "promptframe-creation@" + p3.marketplaceName && /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(p3.marketplaceName ?? "") && /^\d+\.\d+\.\d+$/.test(p3.version ?? "") && p3.source?.source === "npm" && p3.source.package === "@promptframe/creation" && p3.source.version === p3.version && ["https://registry.npmjs.org", "https://registry.npmjs.org/"].includes(p3.source.registry));
|
|
26184
26432
|
if (candidates.length > 1) fail4("existing_registration_requires_review");
|
|
26185
26433
|
if (!candidates.length) return null;
|
|
26186
|
-
const p2 = candidates[0], root =
|
|
26434
|
+
const p2 = candidates[0], root = path15.join(path15.resolve(env.CODEX_HOME ?? path15.join(homedir6(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
|
|
26187
26435
|
const directory3 = await info2(root);
|
|
26188
26436
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink()) fail4("installed_files_invalid");
|
|
26189
|
-
const pkg = await packageJSON(
|
|
26437
|
+
const pkg = await packageJSON(path15.join(root, "package.json")), manifest = await packageJSON(path15.join(root, ".codex-plugin/plugin.json"));
|
|
26190
26438
|
if (pkg.name !== "@promptframe/creation" || pkg.version !== p2.version || manifest.name !== p2.name || manifest.version !== p2.version) fail4("installed_files_invalid");
|
|
26191
|
-
const definition = (await packageJSON(
|
|
26439
|
+
const definition = (await packageJSON(path15.join(root, ".mcp.json"))).mcpServers?.promptframe;
|
|
26192
26440
|
if (!definition || definition.command !== "node" || definition.cwd !== "." || JSON.stringify(definition.args) !== JSON.stringify(["bin/promptframe-creation.mjs", "bridge"]) || JSON.stringify(definition.env_vars) !== JSON.stringify(["PROMPTFRAME_CREATION_CONFIG", "XDG_CONFIG_HOME"])) fail4("legacy_mcp_entry_requires_review");
|
|
26193
26441
|
if (servers.length !== 1 || servers[0].enabled !== true || !sameTransport(servers[0].transport, { ...definition, cwd: root }) || JSON.stringify(servers[0].transport.env_vars) !== JSON.stringify(definition.env_vars)) fail4("legacy_mcp_entry_requires_review");
|
|
26194
26442
|
return {
|
|
@@ -26205,17 +26453,17 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
|
|
|
26205
26453
|
};
|
|
26206
26454
|
}
|
|
26207
26455
|
async function atomicJSON(file, value2) {
|
|
26208
|
-
const temp = file + "." +
|
|
26456
|
+
const temp = file + "." + randomBytes6(12).toString("hex") + ".tmp";
|
|
26209
26457
|
try {
|
|
26210
|
-
const out = await
|
|
26458
|
+
const out = await open9(temp, "wx", 384);
|
|
26211
26459
|
try {
|
|
26212
26460
|
await out.writeFile(JSON.stringify(value2, null, 2) + "\n");
|
|
26213
26461
|
await out.sync();
|
|
26214
26462
|
} finally {
|
|
26215
26463
|
await out.close();
|
|
26216
26464
|
}
|
|
26217
|
-
await
|
|
26218
|
-
const directory3 = await
|
|
26465
|
+
await rename7(temp, file);
|
|
26466
|
+
const directory3 = await open9(path15.dirname(file), "r");
|
|
26219
26467
|
try {
|
|
26220
26468
|
await directory3.sync();
|
|
26221
26469
|
} finally {
|
|
@@ -26226,13 +26474,13 @@ async function atomicJSON(file, value2) {
|
|
|
26226
26474
|
}
|
|
26227
26475
|
}
|
|
26228
26476
|
async function acquire(root, signal) {
|
|
26229
|
-
const lock =
|
|
26477
|
+
const lock = path15.join(root, "install.lock");
|
|
26230
26478
|
const end = Date.now() + 3e4;
|
|
26231
26479
|
let owned = false;
|
|
26232
26480
|
while (!owned) {
|
|
26233
26481
|
signal?.throwIfAborted();
|
|
26234
26482
|
try {
|
|
26235
|
-
await
|
|
26483
|
+
await mkdir7(lock, { mode: 448 });
|
|
26236
26484
|
owned = true;
|
|
26237
26485
|
} catch (e) {
|
|
26238
26486
|
if (e.code !== "EEXIST") throw e;
|
|
@@ -26241,7 +26489,7 @@ async function acquire(root, signal) {
|
|
|
26241
26489
|
}
|
|
26242
26490
|
}
|
|
26243
26491
|
try {
|
|
26244
|
-
await writeFile2(
|
|
26492
|
+
await writeFile2(path15.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
|
|
26245
26493
|
} catch (e) {
|
|
26246
26494
|
await rm2(lock, { recursive: true, force: true });
|
|
26247
26495
|
throw e;
|
|
@@ -26282,7 +26530,7 @@ async function codexJSON(runCodex, args2) {
|
|
|
26282
26530
|
}
|
|
26283
26531
|
}
|
|
26284
26532
|
async function relatedPlugins(runCodex, pluginName, env) {
|
|
26285
|
-
const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 =
|
|
26533
|
+
const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path15.join(path15.resolve(env.CODEX_HOME ?? path15.join(homedir6(), ".codex")), "config.toml");
|
|
26286
26534
|
try {
|
|
26287
26535
|
const s3 = await info2(config2);
|
|
26288
26536
|
if (s3) {
|
|
@@ -26302,10 +26550,10 @@ async function relatedPlugins(runCodex, pluginName, env) {
|
|
|
26302
26550
|
const state = await codexJSON(runCodex, ["plugin", "marketplace", "list", "--json"]);
|
|
26303
26551
|
if (!Array.isArray(state?.marketplaces) || state.marketplaces.length > 128) fail4("local_catalog_unconfirmed");
|
|
26304
26552
|
for (const market of state.marketplaces) {
|
|
26305
|
-
if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !
|
|
26553
|
+
if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path15.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
|
|
26306
26554
|
let catalog;
|
|
26307
26555
|
try {
|
|
26308
|
-
catalog = await packageJSON(
|
|
26556
|
+
catalog = await packageJSON(path15.join(market.root, ".agents/plugins/marketplace.json"));
|
|
26309
26557
|
} catch {
|
|
26310
26558
|
fail4("local_catalog_unconfirmed", { phase: "local_check", commandKind: "marketplace_read", localRegistrationState: "unknown", action: "restore_local_marketplace_catalog" });
|
|
26311
26559
|
}
|
|
@@ -26336,7 +26584,7 @@ async function relatedPlugins(runCodex, pluginName, env) {
|
|
|
26336
26584
|
}
|
|
26337
26585
|
async function runNode(root, version3) {
|
|
26338
26586
|
try {
|
|
26339
|
-
const result = await execute2(process.execPath, [
|
|
26587
|
+
const result = await execute2(process.execPath, [path15.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
|
|
26340
26588
|
if (result.stdout.trim() !== version3) fail4("runtime_version_mismatch");
|
|
26341
26589
|
} catch (e) {
|
|
26342
26590
|
if (e instanceof CreationClientError) throw e;
|
|
@@ -26350,7 +26598,7 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
|
|
|
26350
26598
|
if (!major || Number(major[1]) < 20) throw Error("unsupported_node");
|
|
26351
26599
|
const result = await execute2(
|
|
26352
26600
|
command2,
|
|
26353
|
-
[
|
|
26601
|
+
[path15.join(root, "bin/promptframe-creation.mjs"), "--version"],
|
|
26354
26602
|
{ env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 }
|
|
26355
26603
|
);
|
|
26356
26604
|
if (result.stdout.trim() !== version3) throw Error("wrong_version");
|
|
@@ -26364,8 +26612,8 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
|
|
|
26364
26612
|
}
|
|
26365
26613
|
var installationFiles = Object.freeze({
|
|
26366
26614
|
info: info2,
|
|
26367
|
-
privateDirectory:
|
|
26368
|
-
privateRead:
|
|
26615
|
+
privateDirectory: privateDirectory4,
|
|
26616
|
+
privateRead: privateRead3,
|
|
26369
26617
|
atomicJSON,
|
|
26370
26618
|
acquire,
|
|
26371
26619
|
runNode,
|
|
@@ -26387,21 +26635,21 @@ async function installForUser({
|
|
|
26387
26635
|
const versionOutput = await runCodex(["--version"]);
|
|
26388
26636
|
const match = versionOutput.match(/codex-cli (\d+)\.(\d+)\.(\d+)/);
|
|
26389
26637
|
if (!match || Number(match[1]) === 0 && Number(match[2]) < 160) fail4("codex_0160_required");
|
|
26390
|
-
const payload = await inspectRuntimePackage(
|
|
26391
|
-
const root =
|
|
26392
|
-
await
|
|
26638
|
+
const payload = await inspectRuntimePackage(path15.resolve(sourceRoot));
|
|
26639
|
+
const root = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir6(), ".local/share"), "promptframe-creation", profile);
|
|
26640
|
+
await privateDirectory4(root);
|
|
26393
26641
|
const release = await acquire(root, signal);
|
|
26394
|
-
const versions =
|
|
26395
|
-
const marketplaceFile =
|
|
26642
|
+
const versions = path15.join(root, "versions"), currentFile = path15.join(root, "current.json"), pendingFile = path15.join(root, "registration-pending.json");
|
|
26643
|
+
const marketplaceFile = path15.join(root, ".agents/plugins/marketplace.json");
|
|
26396
26644
|
const pluginName = "promptframe-creation" + (profile === "default" ? "" : "-" + profile), marketplace = "promptframe-creation-user" + (profile === "default" ? "" : "-" + profile);
|
|
26397
26645
|
const pluginId = pluginName + "@" + marketplace;
|
|
26398
|
-
const versionRoot =
|
|
26646
|
+
const versionRoot = path15.join(versions, payload.version), temporary = path15.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
|
|
26399
26647
|
let previous, registrationStarted = false, newFiles = 0;
|
|
26400
26648
|
try {
|
|
26401
26649
|
signal?.throwIfAborted();
|
|
26402
|
-
await
|
|
26403
|
-
await
|
|
26404
|
-
previous = await
|
|
26650
|
+
await privateDirectory4(versions);
|
|
26651
|
+
await privateDirectory4(path15.dirname(marketplaceFile));
|
|
26652
|
+
previous = await privateRead3(currentFile);
|
|
26405
26653
|
if (previous && (previous.profile !== profile || previous.pluginId !== pluginId || previous.configFile !== configFile2)) fail4("profile_binding_conflict");
|
|
26406
26654
|
const state = { installed: await relatedPlugins(runCodex, pluginName, env) };
|
|
26407
26655
|
const installed = state.installed.find((x) => x.pluginId === pluginId);
|
|
@@ -26409,14 +26657,14 @@ async function installForUser({
|
|
|
26409
26657
|
if (!Array.isArray(legacy)) fail4("local_registration_unconfirmed");
|
|
26410
26658
|
const serverName = "promptframe" + (profile === "default" ? "" : "-" + profile);
|
|
26411
26659
|
const servers = legacy.filter((x) => x.name === serverName);
|
|
26412
|
-
const pending = await
|
|
26660
|
+
const pending = await privateRead3(pendingFile);
|
|
26413
26661
|
if (pending) {
|
|
26414
|
-
if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !==
|
|
26662
|
+
if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path15.join(versions, pending.version)) fail4("profile_binding_conflict");
|
|
26415
26663
|
if (installed?.version !== pending.version || installed.enabled !== true || installed.source?.path !== pending.versionRoot)
|
|
26416
26664
|
fail4("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
|
|
26417
26665
|
const transport2 = await managedTransport(installed, versions, serverName, profile, configFile2);
|
|
26418
26666
|
if (servers.length !== 1 || servers[0].enabled === false || !sameTransport(servers[0].transport, transport2)) fail4("registration_unconfirmed_keep_existing");
|
|
26419
|
-
const ready = await
|
|
26667
|
+
const ready = await privateRead3(path15.join(pending.versionRoot, "installation.json"));
|
|
26420
26668
|
if (ready?.payloadDigest !== pending.payloadDigest) fail4("installed_files_invalid");
|
|
26421
26669
|
previous = pending;
|
|
26422
26670
|
await atomicJSON(currentFile, pending);
|
|
@@ -26471,43 +26719,43 @@ async function installForUser({
|
|
|
26471
26719
|
const target = await info2(versionRoot);
|
|
26472
26720
|
if (target) {
|
|
26473
26721
|
if (!target.isDirectory() || target.isSymbolicLink()) fail4("version_content_conflict");
|
|
26474
|
-
const ready = await
|
|
26722
|
+
const ready = await privateRead3(path15.join(versionRoot, "installation.json"));
|
|
26475
26723
|
if (!ready || ready.payloadDigest !== payload.payloadDigest || ready.profile !== profile || ready.configFile !== configFile2) fail4("version_content_conflict");
|
|
26476
26724
|
for (const f2 of ready.files) {
|
|
26477
26725
|
if (!payload.files.some((p2) => p2.path === f2.path)) fail4("installed_files_invalid");
|
|
26478
|
-
const file =
|
|
26726
|
+
const file = path15.join(versionRoot, f2.path), s3 = await info2(file);
|
|
26479
26727
|
if (!s3?.isFile() || s3.isSymbolicLink() || s3.size !== f2.bytes || hash5(await readFile6(file)) !== f2.sha256) fail4("installed_files_invalid");
|
|
26480
26728
|
}
|
|
26481
26729
|
if (ready.files.length !== payload.files.length) fail4("installed_files_invalid");
|
|
26482
26730
|
} else {
|
|
26483
|
-
await
|
|
26731
|
+
await mkdir7(temporary, { mode: 448 });
|
|
26484
26732
|
for (const f2 of payload.files) {
|
|
26485
26733
|
signal?.throwIfAborted();
|
|
26486
|
-
await
|
|
26487
|
-
await writeFile2(
|
|
26734
|
+
await mkdir7(path15.dirname(path15.join(temporary, f2.path)), { recursive: true, mode: 448 });
|
|
26735
|
+
await writeFile2(path15.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
|
|
26488
26736
|
}
|
|
26489
|
-
const manifest = await json(
|
|
26737
|
+
const manifest = await json(path15.join(temporary, ".codex-plugin/plugin.json"));
|
|
26490
26738
|
manifest.name = pluginName;
|
|
26491
|
-
await writeFile2(
|
|
26739
|
+
await writeFile2(path15.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
26492
26740
|
const mcp = { mcpServers: { ["promptframe" + (profile === "default" ? "" : "-" + profile)]: {
|
|
26493
26741
|
command: process.execPath,
|
|
26494
|
-
args: [
|
|
26742
|
+
args: [path15.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
|
|
26495
26743
|
cwd: versionRoot
|
|
26496
26744
|
} } };
|
|
26497
|
-
await writeFile2(
|
|
26745
|
+
await writeFile2(path15.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
|
|
26498
26746
|
await checkRuntime(temporary, payload.version);
|
|
26499
26747
|
const files = [];
|
|
26500
26748
|
for (const f2 of payload.files) {
|
|
26501
|
-
const body = await readFile6(
|
|
26749
|
+
const body = await readFile6(path15.join(temporary, f2.path));
|
|
26502
26750
|
files.push({ path: f2.path, bytes: body.length, sha256: hash5(body) });
|
|
26503
26751
|
}
|
|
26504
|
-
await atomicJSON(
|
|
26752
|
+
await atomicJSON(path15.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
|
|
26505
26753
|
signal?.throwIfAborted();
|
|
26506
|
-
await
|
|
26754
|
+
await rename7(temporary, versionRoot);
|
|
26507
26755
|
newFiles = payload.files.length;
|
|
26508
26756
|
}
|
|
26509
26757
|
if (newFiles === 0) {
|
|
26510
|
-
const launch = (await json(
|
|
26758
|
+
const launch = (await json(path15.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
|
|
26511
26759
|
await verifyInstalledRuntime(versionRoot, payload.version, launch.command, { env });
|
|
26512
26760
|
}
|
|
26513
26761
|
const complete = { version: payload.version, profile, configFile: configFile2, pluginId, versionRoot, payloadDigest: payload.payloadDigest };
|
|
@@ -26546,16 +26794,16 @@ async function installForUser({
|
|
|
26546
26794
|
reloadRequired: !already,
|
|
26547
26795
|
recordedRuntimeRetained: Boolean(already && recorded && recorded.command !== process.execPath)
|
|
26548
26796
|
};
|
|
26549
|
-
} catch (
|
|
26797
|
+
} catch (error6) {
|
|
26550
26798
|
if (registrationStarted) {
|
|
26551
26799
|
fail4("registration_unconfirmed_keep_existing", {
|
|
26552
|
-
...installationErrorDetails(
|
|
26800
|
+
...installationErrorDetails(error6),
|
|
26553
26801
|
phase: "registration_observation",
|
|
26554
26802
|
localRegistrationState: "unknown",
|
|
26555
26803
|
action: "inspect_same_registration_no_second_add"
|
|
26556
26804
|
});
|
|
26557
26805
|
}
|
|
26558
|
-
if (
|
|
26806
|
+
if (error6 instanceof CreationClientError) throw error6;
|
|
26559
26807
|
if (signal?.aborted) fail4("interrupted_keep_existing");
|
|
26560
26808
|
fail4("failed_keep_existing");
|
|
26561
26809
|
} finally {
|
|
@@ -26565,10 +26813,10 @@ async function installForUser({
|
|
|
26565
26813
|
}
|
|
26566
26814
|
|
|
26567
26815
|
// lib/claude-installation.mjs
|
|
26568
|
-
import { createHash as
|
|
26569
|
-
import { mkdir as
|
|
26570
|
-
import { homedir as
|
|
26571
|
-
import
|
|
26816
|
+
import { createHash as createHash13, randomBytes as randomBytes8 } from "node:crypto";
|
|
26817
|
+
import { mkdir as mkdir9, open as open12, readFile as readFile9, rename as rename9, rm as rm5 } from "node:fs/promises";
|
|
26818
|
+
import { homedir as homedir11 } from "node:os";
|
|
26819
|
+
import path20 from "node:path";
|
|
26572
26820
|
|
|
26573
26821
|
// lib/claude-hook-definition.mjs
|
|
26574
26822
|
function claudeHostHooks({ pluginName = "promptframe-creation", serverName, configFile: configFile2, nodeCommand = "node", runtimeRoot = "${CLAUDE_PLUGIN_ROOT}" } = {}) {
|
|
@@ -26591,10 +26839,10 @@ function claudeHostHooks({ pluginName = "promptframe-creation", serverName, conf
|
|
|
26591
26839
|
// lib/claude-command.mjs
|
|
26592
26840
|
import { execFile as execFile3 } from "node:child_process";
|
|
26593
26841
|
import { promisify as promisify3 } from "node:util";
|
|
26594
|
-
import { access, lstat as
|
|
26595
|
-
import { constants as
|
|
26596
|
-
import { homedir as
|
|
26597
|
-
import
|
|
26842
|
+
import { access, lstat as lstat10, readdir as readdir5 } from "node:fs/promises";
|
|
26843
|
+
import { constants as constants7 } from "node:fs";
|
|
26844
|
+
import { homedir as homedir7 } from "node:os";
|
|
26845
|
+
import path16 from "node:path";
|
|
26598
26846
|
var execute3 = promisify3(execFile3);
|
|
26599
26847
|
var ClaudeCommandError = class extends CreationClientError {
|
|
26600
26848
|
constructor(code, details) {
|
|
@@ -26602,24 +26850,24 @@ var ClaudeCommandError = class extends CreationClientError {
|
|
|
26602
26850
|
this.details = details;
|
|
26603
26851
|
}
|
|
26604
26852
|
};
|
|
26605
|
-
var claudeErrorDetails = (
|
|
26606
|
-
async function resolveClaudeCommand({ env = process.env, homeDirectory =
|
|
26853
|
+
var claudeErrorDetails = (error6) => error6 instanceof ClaudeCommandError ? error6.details : void 0;
|
|
26854
|
+
async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir7(), executable } = {}) {
|
|
26607
26855
|
const selected = executable ?? env.PROMPTFRAME_CLAUDE_BIN;
|
|
26608
26856
|
if (selected) {
|
|
26609
|
-
if (!
|
|
26610
|
-
await access(selected,
|
|
26857
|
+
if (!path16.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
|
|
26858
|
+
await access(selected, constants7.X_OK);
|
|
26611
26859
|
return selected;
|
|
26612
26860
|
}
|
|
26613
|
-
for (const directory3 of (env.PATH ?? "").split(
|
|
26614
|
-
const file =
|
|
26861
|
+
for (const directory3 of (env.PATH ?? "").split(path16.delimiter).filter(path16.isAbsolute)) {
|
|
26862
|
+
const file = path16.join(directory3, process.platform === "win32" ? "claude.exe" : "claude");
|
|
26615
26863
|
try {
|
|
26616
|
-
await access(file,
|
|
26864
|
+
await access(file, constants7.X_OK);
|
|
26617
26865
|
return file;
|
|
26618
26866
|
} catch (e) {
|
|
26619
26867
|
if (!["ENOENT", "EACCES", "ENOTDIR"].includes(e.code)) throw e;
|
|
26620
26868
|
}
|
|
26621
26869
|
}
|
|
26622
|
-
const root =
|
|
26870
|
+
const root = path16.join(homeDirectory, ".claude/remote/ccd-cli");
|
|
26623
26871
|
let entries2;
|
|
26624
26872
|
try {
|
|
26625
26873
|
entries2 = await readdir5(root);
|
|
@@ -26632,9 +26880,9 @@ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir
|
|
|
26632
26880
|
for (const name of entries2) {
|
|
26633
26881
|
const match = name.match(/^(\d+)\.(\d+)\.(\d+)-[a-f0-9]{6,40}$/);
|
|
26634
26882
|
if (!match) continue;
|
|
26635
|
-
const file =
|
|
26883
|
+
const file = path16.join(root, name), s3 = await lstat10(file);
|
|
26636
26884
|
if (s3.isFile() && !s3.isSymbolicLink() && s3.uid === process.getuid?.()) {
|
|
26637
|
-
await access(file,
|
|
26885
|
+
await access(file, constants7.X_OK);
|
|
26638
26886
|
candidates.push({ file, version: match.slice(1).map(Number) });
|
|
26639
26887
|
}
|
|
26640
26888
|
}
|
|
@@ -26670,17 +26918,17 @@ function createClaudeRunner({ env = process.env, executable, signal, resolve = r
|
|
|
26670
26918
|
}
|
|
26671
26919
|
|
|
26672
26920
|
// lib/claude-local-state.mjs
|
|
26673
|
-
import { readFile as readFile7, lstat as
|
|
26674
|
-
import { homedir as
|
|
26675
|
-
import
|
|
26921
|
+
import { readFile as readFile7, lstat as lstat11 } from "node:fs/promises";
|
|
26922
|
+
import { homedir as homedir8 } from "node:os";
|
|
26923
|
+
import path17 from "node:path";
|
|
26676
26924
|
function claudeConfigRoot(env = process.env) {
|
|
26677
|
-
return
|
|
26925
|
+
return path17.resolve(env.CLAUDE_CONFIG_DIR ?? path17.join(homedir8(), ".claude"));
|
|
26678
26926
|
}
|
|
26679
26927
|
async function readClaudeUserServer(serverName, env = process.env) {
|
|
26680
|
-
const file = env.CLAUDE_CONFIG_DIR ?
|
|
26928
|
+
const file = env.CLAUDE_CONFIG_DIR ? path17.join(claudeConfigRoot(env), ".claude.json") : path17.join(homedir8(), ".claude.json");
|
|
26681
26929
|
let info5;
|
|
26682
26930
|
try {
|
|
26683
|
-
info5 = await
|
|
26931
|
+
info5 = await lstat11(file);
|
|
26684
26932
|
} catch (e) {
|
|
26685
26933
|
if (e.code === "ENOENT") return null;
|
|
26686
26934
|
throw new CreationClientError("installation.claude_local_registration_unconfirmed");
|
|
@@ -26700,26 +26948,26 @@ async function readClaudeUserServer(serverName, env = process.env) {
|
|
|
26700
26948
|
}
|
|
26701
26949
|
|
|
26702
26950
|
// lib/claude-mcp-installation.mjs
|
|
26703
|
-
import { createHash as
|
|
26704
|
-
import { mkdir as
|
|
26705
|
-
import { homedir as
|
|
26706
|
-
import
|
|
26951
|
+
import { createHash as createHash12, randomBytes as randomBytes7 } from "node:crypto";
|
|
26952
|
+
import { mkdir as mkdir8, open as open11, readFile as readFile8, readdir as readdir6, rename as rename8, rm as rm4, lstat as lstat12 } from "node:fs/promises";
|
|
26953
|
+
import { homedir as homedir10 } from "node:os";
|
|
26954
|
+
import path19 from "node:path";
|
|
26707
26955
|
|
|
26708
26956
|
// lib/claude-hook-registration.mjs
|
|
26709
|
-
import { createHash as
|
|
26710
|
-
import { open as
|
|
26711
|
-
import { constants as
|
|
26712
|
-
import
|
|
26713
|
-
import { homedir as
|
|
26714
|
-
var { privateDirectory:
|
|
26715
|
-
var
|
|
26957
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
26958
|
+
import { open as open10, rm as rm3 } from "node:fs/promises";
|
|
26959
|
+
import { constants as constants8 } from "node:fs";
|
|
26960
|
+
import path18 from "node:path";
|
|
26961
|
+
import { homedir as homedir9 } from "node:os";
|
|
26962
|
+
var { privateDirectory: privateDirectory5, privateRead: privateRead4, atomicJSON: atomicJSON2, acquire: acquire2 } = installationFiles;
|
|
26963
|
+
var digest5 = (value2) => createHash11("sha256").update(JSON.stringify(value2)).digest("hex");
|
|
26716
26964
|
var fail5 = () => {
|
|
26717
26965
|
throw new CreationClientError("installation.claude_hooks_require_review");
|
|
26718
26966
|
};
|
|
26719
26967
|
async function settings(file) {
|
|
26720
26968
|
let handle;
|
|
26721
26969
|
try {
|
|
26722
|
-
handle = await
|
|
26970
|
+
handle = await open10(file, constants8.O_RDONLY | constants8.O_NOFOLLOW);
|
|
26723
26971
|
const info5 = await handle.stat();
|
|
26724
26972
|
if (!info5.isFile() || info5.uid !== process.getuid?.() || info5.size > 512 * 1024) fail5();
|
|
26725
26973
|
const value2 = JSON.parse(await handle.readFile("utf8"));
|
|
@@ -26732,29 +26980,29 @@ async function settings(file) {
|
|
|
26732
26980
|
await handle?.close();
|
|
26733
26981
|
}
|
|
26734
26982
|
}
|
|
26735
|
-
var contains = (value2, entries2) => Object.entries(entries2).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) =>
|
|
26983
|
+
var contains = (value2, entries2) => Object.entries(entries2).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) => digest5(actual) === digest5(entry)).length === 1));
|
|
26736
26984
|
async function verifyClaudeFallbackHooks(record2, env) {
|
|
26737
|
-
if (!record2?.settingsFile || record2.settingsFile !==
|
|
26985
|
+
if (!record2?.settingsFile || record2.settingsFile !== path18.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
|
|
26738
26986
|
if (!contains(await settings(record2.settingsFile), record2.entries)) fail5();
|
|
26739
26987
|
return true;
|
|
26740
26988
|
}
|
|
26741
26989
|
async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCommand, signal }) {
|
|
26742
|
-
const directory3 = claudeConfigRoot(env), file =
|
|
26743
|
-
const guard =
|
|
26744
|
-
env.XDG_DATA_HOME ??
|
|
26990
|
+
const directory3 = claudeConfigRoot(env), file = path18.join(directory3, "settings.json");
|
|
26991
|
+
const guard = path18.resolve(
|
|
26992
|
+
env.XDG_DATA_HOME ?? path18.join(homedir9(), ".local/share"),
|
|
26745
26993
|
"promptframe-creation",
|
|
26746
|
-
"claude-hook-writer-" +
|
|
26994
|
+
"claude-hook-writer-" + digest5(directory3)
|
|
26747
26995
|
);
|
|
26748
|
-
await
|
|
26996
|
+
await privateDirectory5(guard);
|
|
26749
26997
|
const release = await acquire2(guard, signal);
|
|
26750
|
-
const markerFile =
|
|
26998
|
+
const markerFile = path18.join(root, "hooks-current.json"), pendingFile = path18.join(root, "hooks-pending.json");
|
|
26751
26999
|
try {
|
|
26752
|
-
await
|
|
27000
|
+
await privateDirectory5(directory3);
|
|
26753
27001
|
const entries2 = claudeHostHooks({ serverName: record2.serverName, configFile: record2.configFile, nodeCommand, runtimeRoot: record2.versionRoot });
|
|
26754
27002
|
const expected = { contractVersion: "creation-claude-hooks/v1", settingsFile: file, profile: record2.profile, entries: entries2 };
|
|
26755
|
-
const pending = await
|
|
27003
|
+
const pending = await privateRead4(pendingFile), previous = await privateRead4(markerFile), before = await settings(file);
|
|
26756
27004
|
if (pending) {
|
|
26757
|
-
if (
|
|
27005
|
+
if (digest5(pending) !== digest5(expected) || !contains(before, entries2)) throw new CreationClientError("installation.registration_unconfirmed_keep_existing");
|
|
26758
27006
|
await atomicJSON2(markerFile, expected);
|
|
26759
27007
|
await rm3(pendingFile);
|
|
26760
27008
|
return expected;
|
|
@@ -26762,19 +27010,19 @@ async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCom
|
|
|
26762
27010
|
if (previous) {
|
|
26763
27011
|
if (previous.contractVersion !== expected.contractVersion || previous.profile !== record2.profile || previous.settingsFile !== file) fail5();
|
|
26764
27012
|
await verifyClaudeFallbackHooks(previous, env);
|
|
26765
|
-
if (
|
|
27013
|
+
if (digest5(previous) === digest5(expected)) return previous;
|
|
26766
27014
|
}
|
|
26767
27015
|
const next = { ...before, hooks: { ...before.hooks } };
|
|
26768
27016
|
for (const [event, wanted] of Object.entries(entries2)) {
|
|
26769
27017
|
const actual = next.hooks[event] ?? [];
|
|
26770
27018
|
if (!Array.isArray(actual)) fail5();
|
|
26771
|
-
const owned = new Set((previous?.entries[event] ?? []).map(
|
|
26772
|
-
if (wanted.some((entry) => actual.some((value2) =>
|
|
26773
|
-
next.hooks[event] = [...actual.filter((entry) => !owned.has(
|
|
27019
|
+
const owned = new Set((previous?.entries[event] ?? []).map(digest5));
|
|
27020
|
+
if (wanted.some((entry) => actual.some((value2) => digest5(value2) === digest5(entry)) && !owned.has(digest5(entry)))) fail5();
|
|
27021
|
+
next.hooks[event] = [...actual.filter((entry) => !owned.has(digest5(entry))), ...wanted];
|
|
26774
27022
|
}
|
|
26775
27023
|
signal?.throwIfAborted();
|
|
26776
27024
|
await atomicJSON2(pendingFile, expected);
|
|
26777
|
-
if (
|
|
27025
|
+
if (digest5(await settings(file)) !== digest5(before)) fail5();
|
|
26778
27026
|
await atomicJSON2(file, next);
|
|
26779
27027
|
if (!contains(await settings(file), entries2)) throw new CreationClientError("installation.registration_unconfirmed_keep_existing");
|
|
26780
27028
|
await atomicJSON2(markerFile, expected);
|
|
@@ -26786,24 +27034,24 @@ async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCom
|
|
|
26786
27034
|
}
|
|
26787
27035
|
|
|
26788
27036
|
// lib/claude-mcp-installation.mjs
|
|
26789
|
-
var { info: info3, privateDirectory:
|
|
26790
|
-
var hash6 = (body) =>
|
|
27037
|
+
var { info: info3, privateDirectory: privateDirectory6, privateRead: privateRead5, atomicJSON: atomicJSON3, acquire: acquire3, compareVersions: compareVersions2 } = installationFiles;
|
|
27038
|
+
var hash6 = (body) => createHash12("sha256").update(body).digest("hex");
|
|
26791
27039
|
var FallbackError = class extends CreationClientError {
|
|
26792
27040
|
constructor(code, details) {
|
|
26793
27041
|
super("installation." + code);
|
|
26794
27042
|
this.details = details;
|
|
26795
27043
|
}
|
|
26796
27044
|
};
|
|
26797
|
-
var fallbackErrorDetails = (
|
|
27045
|
+
var fallbackErrorDetails = (error6) => error6 instanceof FallbackError ? error6.details : void 0;
|
|
26798
27046
|
var fail6 = (code, details) => {
|
|
26799
27047
|
throw new FallbackError(code, details);
|
|
26800
27048
|
};
|
|
26801
27049
|
async function claimSkillDirectory(root) {
|
|
26802
27050
|
try {
|
|
26803
|
-
await
|
|
26804
|
-
} catch (
|
|
26805
|
-
if (
|
|
26806
|
-
throw
|
|
27051
|
+
await mkdir8(root, { mode: 448 });
|
|
27052
|
+
} catch (error6) {
|
|
27053
|
+
if (error6.code === "EEXIST") fail6("claude_skill_requires_review");
|
|
27054
|
+
throw error6;
|
|
26807
27055
|
}
|
|
26808
27056
|
}
|
|
26809
27057
|
function same(a, b2, depth = 0) {
|
|
@@ -26813,17 +27061,17 @@ function same(a, b2, depth = 0) {
|
|
|
26813
27061
|
return left.length <= 256 && left.length === right.length && left.every((key, i) => key === right[i] && same(a[key], b2[key], depth + 1));
|
|
26814
27062
|
}
|
|
26815
27063
|
async function atomicText(file, body) {
|
|
26816
|
-
const temporary = file + "." +
|
|
27064
|
+
const temporary = file + "." + randomBytes7(12).toString("hex") + ".tmp";
|
|
26817
27065
|
try {
|
|
26818
|
-
const fd = await
|
|
27066
|
+
const fd = await open11(temporary, "wx", 384);
|
|
26819
27067
|
try {
|
|
26820
27068
|
await fd.writeFile(body);
|
|
26821
27069
|
await fd.sync();
|
|
26822
27070
|
} finally {
|
|
26823
27071
|
await fd.close();
|
|
26824
27072
|
}
|
|
26825
|
-
await
|
|
26826
|
-
const dir = await
|
|
27073
|
+
await rename8(temporary, file);
|
|
27074
|
+
const dir = await open11(path19.dirname(file), "r");
|
|
26827
27075
|
try {
|
|
26828
27076
|
await dir.sync();
|
|
26829
27077
|
} finally {
|
|
@@ -26836,15 +27084,15 @@ async function atomicText(file, body) {
|
|
|
26836
27084
|
async function verifyVersion(root, record2) {
|
|
26837
27085
|
const directory3 = await info3(root);
|
|
26838
27086
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_installed_files_invalid");
|
|
26839
|
-
const marker = await
|
|
26840
|
-
if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !
|
|
27087
|
+
const marker = await privateRead5(path19.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
|
|
27088
|
+
if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path19.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
|
|
26841
27089
|
return marker;
|
|
26842
27090
|
}
|
|
26843
27091
|
function mcpDefinition(record2, nodeCommand) {
|
|
26844
27092
|
return {
|
|
26845
27093
|
type: "stdio",
|
|
26846
27094
|
command: nodeCommand,
|
|
26847
|
-
args: [
|
|
27095
|
+
args: [path19.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
|
|
26848
27096
|
};
|
|
26849
27097
|
}
|
|
26850
27098
|
function skillBody(payload, sourceName, name) {
|
|
@@ -26860,14 +27108,14 @@ async function observedSkill(plan, record2, { allowBefore = false } = {}) {
|
|
|
26860
27108
|
if (!directory3.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_skill_requires_review");
|
|
26861
27109
|
const names = await readdir6(plan.root);
|
|
26862
27110
|
if (names.some((n) => !["SKILL.md", "promptframe-installation.json"].includes(n))) fail6("claude_skill_requires_review");
|
|
26863
|
-
const marker = await
|
|
27111
|
+
const marker = await privateRead5(path19.join(plan.root, "promptframe-installation.json")), file = path19.join(plan.root, "SKILL.md"), s3 = await info3(file);
|
|
26864
27112
|
if (!marker || marker.host !== "claude-code" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.name !== plan.name)
|
|
26865
27113
|
fail6("claude_skill_requires_review");
|
|
26866
27114
|
if (!s3 && allowBefore && plan.beforeSHA === null && marker.sha256 === null) return false;
|
|
26867
27115
|
if (!s3?.isFile() || s3.isSymbolicLink() || s3.size > 256 * 1024) fail6("claude_skill_requires_review");
|
|
26868
|
-
const
|
|
26869
|
-
if (
|
|
26870
|
-
if (allowBefore && (
|
|
27116
|
+
const digest6 = hash6(await readFile8(file));
|
|
27117
|
+
if (digest6 === plan.sha256 && marker.sha256 === plan.sha256) return true;
|
|
27118
|
+
if (allowBefore && (digest6 === plan.beforeSHA || digest6 === plan.sha256) && marker.sha256 === plan.beforeSHA) return false;
|
|
26871
27119
|
fail6("claude_skill_requires_review");
|
|
26872
27120
|
}
|
|
26873
27121
|
async function installClaudeMcpFallback({
|
|
@@ -26882,17 +27130,17 @@ async function installClaudeMcpFallback({
|
|
|
26882
27130
|
nodeCommand,
|
|
26883
27131
|
writeSkill = atomicText
|
|
26884
27132
|
}) {
|
|
26885
|
-
const payload = await inspectRuntimePackage(
|
|
26886
|
-
await
|
|
26887
|
-
const release = await acquire3(root, signal), versions =
|
|
27133
|
+
const payload = await inspectRuntimePackage(path19.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
|
|
27134
|
+
await privateDirectory6(root);
|
|
27135
|
+
const release = await acquire3(root, signal), versions = path19.join(root, "versions"), currentFile = path19.join(root, "current.json"), pendingFile = path19.join(root, "registration-pending.json"), versionRoot = path19.join(versions, payload.version), temporary = path19.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
|
|
26888
27136
|
let writeStarted = false, newFiles = 0;
|
|
26889
27137
|
const complete = { host: "claude-code", mode: "mcp-and-skills", profile, configFile: configFile2, serverName, version: payload.version, versionRoot, payloadDigest: payload.payloadDigest };
|
|
26890
27138
|
const checkBinding = (record2) => {
|
|
26891
|
-
if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !==
|
|
27139
|
+
if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path19.join(versions, record2.version))) fail6("profile_binding_conflict");
|
|
26892
27140
|
};
|
|
26893
27141
|
try {
|
|
26894
|
-
await
|
|
26895
|
-
let previous = await
|
|
27142
|
+
await privateDirectory6(versions);
|
|
27143
|
+
let previous = await privateRead5(currentFile), pending = await privateRead5(pendingFile);
|
|
26896
27144
|
checkBinding(previous);
|
|
26897
27145
|
checkBinding(pending);
|
|
26898
27146
|
let saved = await readClaudeUserServer(serverName, env);
|
|
@@ -26905,7 +27153,7 @@ async function installClaudeMcpFallback({
|
|
|
26905
27153
|
if (!Array.isArray(record2.skills) || record2.skills.length !== 2) fail6("claude_skill_requires_review");
|
|
26906
27154
|
for (const [i, skill] of record2.skills.entries()) {
|
|
26907
27155
|
const name = ["creation-setup", "video-creation"][i] + suffix;
|
|
26908
|
-
if (skill.name !== name || skill.root !==
|
|
27156
|
+
if (skill.name !== name || skill.root !== path19.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
|
|
26909
27157
|
fail6("claude_skill_requires_review");
|
|
26910
27158
|
if (!await observedSkill(skill, record2)) return false;
|
|
26911
27159
|
}
|
|
@@ -26945,12 +27193,12 @@ async function installClaudeMcpFallback({
|
|
|
26945
27193
|
} else if (saved && !pending) fail6("legacy_mcp_entry_requires_review");
|
|
26946
27194
|
if (await info3(versionRoot)) await verifyVersion(versionRoot, complete);
|
|
26947
27195
|
else {
|
|
26948
|
-
await
|
|
27196
|
+
await mkdir8(temporary, { mode: 448 });
|
|
26949
27197
|
for (const file of payload.files) {
|
|
26950
27198
|
signal?.throwIfAborted();
|
|
26951
|
-
const dest =
|
|
26952
|
-
await
|
|
26953
|
-
const fd = await
|
|
27199
|
+
const dest = path19.join(temporary, file.path);
|
|
27200
|
+
await mkdir8(path19.dirname(dest), { recursive: true, mode: 448 });
|
|
27201
|
+
const fd = await open11(dest, "wx", 384);
|
|
26954
27202
|
try {
|
|
26955
27203
|
await fd.writeFile(file.body);
|
|
26956
27204
|
await fd.sync();
|
|
@@ -26959,21 +27207,21 @@ async function installClaudeMcpFallback({
|
|
|
26959
27207
|
}
|
|
26960
27208
|
}
|
|
26961
27209
|
await checkRuntime(temporary, payload.version);
|
|
26962
|
-
await atomicJSON3(
|
|
27210
|
+
await atomicJSON3(path19.join(temporary, "installation.json"), { ...complete, nodeCommand });
|
|
26963
27211
|
signal?.throwIfAborted();
|
|
26964
|
-
await
|
|
27212
|
+
await rename8(temporary, versionRoot);
|
|
26965
27213
|
newFiles = payload.files.length;
|
|
26966
27214
|
}
|
|
26967
27215
|
const ready = await verifyVersion(versionRoot, complete);
|
|
26968
27216
|
complete.server = mcpDefinition(complete, ready.nodeCommand);
|
|
26969
27217
|
if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, ready.nodeCommand, { env });
|
|
26970
|
-
const skillRoot =
|
|
26971
|
-
await
|
|
26972
|
-
const parent = await
|
|
27218
|
+
const skillRoot = path19.join(claudeConfigRoot(env), "skills");
|
|
27219
|
+
await mkdir8(skillRoot, { recursive: true, mode: 448 });
|
|
27220
|
+
const parent = await lstat12(skillRoot);
|
|
26973
27221
|
if (!parent.isDirectory() || parent.isSymbolicLink() || parent.uid !== process.getuid?.()) fail6("claude_skill_requires_review");
|
|
26974
27222
|
const plans = [];
|
|
26975
27223
|
for (const sourceName of ["creation-setup", "video-creation"]) {
|
|
26976
|
-
const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root:
|
|
27224
|
+
const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path19.join(skillRoot, name), sha256: hash6(body) };
|
|
26977
27225
|
if (pending) {
|
|
26978
27226
|
const old = pending.skills?.find((s3) => s3.name === name);
|
|
26979
27227
|
if (!old || old.root !== skill.root || old.sha256 !== skill.sha256) fail6("registration_unconfirmed_keep_existing");
|
|
@@ -26982,7 +27230,7 @@ async function installClaudeMcpFallback({
|
|
|
26982
27230
|
const existing = await info3(skill.root);
|
|
26983
27231
|
let beforeSHA = null;
|
|
26984
27232
|
if (existing) {
|
|
26985
|
-
const marker = await
|
|
27233
|
+
const marker = await privateRead5(path19.join(skill.root, "promptframe-installation.json"));
|
|
26986
27234
|
if (!marker || marker.profile !== profile || marker.configFile !== configFile2 || marker.name !== name) fail6("claude_skill_requires_review");
|
|
26987
27235
|
const old = { ...skill, sha256: marker.sha256 };
|
|
26988
27236
|
if (!await observedSkill(old, complete)) fail6("claude_skill_requires_review");
|
|
@@ -27003,10 +27251,10 @@ async function installClaudeMcpFallback({
|
|
|
27003
27251
|
} else {
|
|
27004
27252
|
if (plan.beforeSHA !== null) fail6("claude_skill_requires_review");
|
|
27005
27253
|
await claimSkillDirectory(plan.root);
|
|
27006
|
-
await atomicJSON3(
|
|
27254
|
+
await atomicJSON3(path19.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
|
|
27007
27255
|
}
|
|
27008
|
-
await writeSkill(
|
|
27009
|
-
await atomicJSON3(
|
|
27256
|
+
await writeSkill(path19.join(plan.root, "SKILL.md"), plan.body);
|
|
27257
|
+
await atomicJSON3(path19.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
|
|
27010
27258
|
}
|
|
27011
27259
|
signal?.throwIfAborted();
|
|
27012
27260
|
if (compareVersions2(payload.version, "0.3.1") >= 0) complete.hostHooks = await registerClaudeFallbackHooks({ record: complete, root, env, nodeCommand: ready.nodeCommand, signal });
|
|
@@ -27031,9 +27279,9 @@ async function installClaudeMcpFallback({
|
|
|
27031
27279
|
requestedVersion: payload.version,
|
|
27032
27280
|
versionStatus: "current"
|
|
27033
27281
|
};
|
|
27034
|
-
} catch (
|
|
27282
|
+
} catch (error6) {
|
|
27035
27283
|
if (writeStarted) fail6("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
|
|
27036
|
-
if (
|
|
27284
|
+
if (error6 instanceof CreationClientError) throw error6;
|
|
27037
27285
|
fail6(signal?.aborted ? "interrupted_keep_existing" : "failed_keep_existing");
|
|
27038
27286
|
} finally {
|
|
27039
27287
|
await rm4(temporary, { recursive: true, force: true });
|
|
@@ -27042,7 +27290,7 @@ async function installClaudeMcpFallback({
|
|
|
27042
27290
|
}
|
|
27043
27291
|
|
|
27044
27292
|
// lib/claude-installation.mjs
|
|
27045
|
-
var { info: info4, privateDirectory:
|
|
27293
|
+
var { info: info4, privateDirectory: privateDirectory7, privateRead: privateRead6, atomicJSON: atomicJSON4, acquire: acquire4, runNode: runNode2, checkInstalledRuntime: checkInstalledRuntime2, compareVersions: compareVersions3, validProfile: validProfile2 } = installationFiles;
|
|
27046
27294
|
var effectiveRoot = (plugin) => plugin.readFromFolder ?? plugin.installPath;
|
|
27047
27295
|
var effectiveVersion = (plugin) => plugin.readFromFolder !== void 0 ? plugin.folderVersion : plugin.version;
|
|
27048
27296
|
var ClaudeInstallationError = class extends CreationClientError {
|
|
@@ -27051,7 +27299,7 @@ var ClaudeInstallationError = class extends CreationClientError {
|
|
|
27051
27299
|
this.details = details;
|
|
27052
27300
|
}
|
|
27053
27301
|
};
|
|
27054
|
-
var claudeInstallationDetails = (
|
|
27302
|
+
var claudeInstallationDetails = (error6) => error6 instanceof ClaudeInstallationError ? error6.details : void 0;
|
|
27055
27303
|
var fail7 = (code, details) => {
|
|
27056
27304
|
throw new ClaudeInstallationError(code, details);
|
|
27057
27305
|
};
|
|
@@ -27075,7 +27323,7 @@ async function registrations(run, pluginName, marketplace, root) {
|
|
|
27075
27323
|
if (plugins.some((p2) => !p2 || typeof p2.id !== "string" || !p2.id || p2.id.length > 256 || typeof p2.scope !== "string" || typeof p2.version !== "string" || typeof p2.enabled !== "boolean" || typeof p2.installPath !== "string") || markets.some((p2) => !p2 || typeof p2.name !== "string" || !p2.name || typeof p2.source !== "string"))
|
|
27076
27324
|
fail7("claude_local_registration_unconfirmed");
|
|
27077
27325
|
const related = plugins.filter((p2) => typeof p2?.id === "string" && p2.id.startsWith(pluginName + "@"));
|
|
27078
|
-
if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !
|
|
27326
|
+
if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path20.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path20.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
|
|
27079
27327
|
fail7("claude_existing_registration_requires_review");
|
|
27080
27328
|
const found = markets.filter((p2) => p2?.name === marketplace);
|
|
27081
27329
|
if (found.length > 1 || found.some((p2) => p2.source !== "directory" || p2.path !== root || p2.installLocation !== root))
|
|
@@ -27095,19 +27343,19 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
|
|
|
27095
27343
|
const directory3 = await info4(root);
|
|
27096
27344
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63)
|
|
27097
27345
|
fail7("claude_installed_files_invalid");
|
|
27098
|
-
const ready = await
|
|
27346
|
+
const ready = await privateRead6(path20.join(root, "installation.json"));
|
|
27099
27347
|
if (!ready || ready.host !== "claude-code" || ready.version !== version3 || ready.profile !== profile || ready.configFile !== configFile2 || ready.payloadDigest !== payloadDigest || !Array.isArray(ready.files) || ready.files.length > 1024) fail7("claude_installed_files_invalid");
|
|
27100
27348
|
const actual = await inspectRuntimePackage(root);
|
|
27101
|
-
if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path:
|
|
27349
|
+
if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
|
|
27102
27350
|
fail7("claude_installed_files_invalid");
|
|
27103
|
-
const manifest = JSON.parse(await readFile9(
|
|
27351
|
+
const manifest = JSON.parse(await readFile9(path20.join(root, ".claude-plugin/plugin.json"), "utf8"));
|
|
27104
27352
|
if (manifest.name !== pluginName || manifest.version !== version3 || manifest.skills !== "./skills/" || manifest.mcpServers !== "./.claude-mcp.json")
|
|
27105
27353
|
fail7("claude_installed_files_invalid");
|
|
27106
27354
|
let runtimeCommand;
|
|
27107
27355
|
for (const file of [".mcp.json", ".claude-mcp.json"]) {
|
|
27108
|
-
const mcp = JSON.parse(await readFile9(
|
|
27356
|
+
const mcp = JSON.parse(await readFile9(path20.join(root, file), "utf8"));
|
|
27109
27357
|
const command2 = mcp.mcpServers?.[serverName]?.command;
|
|
27110
|
-
if (!
|
|
27358
|
+
if (!path20.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
|
|
27111
27359
|
runtimeCommand = command2;
|
|
27112
27360
|
}
|
|
27113
27361
|
if (compareVersions3(version3, "0.3.1") >= 0 && JSON.stringify(manifest.hooks) !== JSON.stringify(claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand: runtimeCommand })))
|
|
@@ -27117,8 +27365,8 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
|
|
|
27117
27365
|
async function installForClaudeUser(options = {}) {
|
|
27118
27366
|
const profile = options.profile ?? "default", env = options.env ?? process.env;
|
|
27119
27367
|
validProfile2(profile);
|
|
27120
|
-
const modeRoot =
|
|
27121
|
-
await
|
|
27368
|
+
const modeRoot = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
|
|
27369
|
+
await privateDirectory7(modeRoot);
|
|
27122
27370
|
const release = await acquire4(modeRoot, options.signal);
|
|
27123
27371
|
try {
|
|
27124
27372
|
return await installClaudeUserLocked(options);
|
|
@@ -27139,37 +27387,37 @@ async function installClaudeUserLocked({
|
|
|
27139
27387
|
nodeCommand = process.execPath
|
|
27140
27388
|
} = {}) {
|
|
27141
27389
|
validProfile2(profile);
|
|
27142
|
-
if (!
|
|
27390
|
+
if (!path20.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
|
|
27143
27391
|
const hostVersion = (await runClaude(["--version"])).trim().match(/^(\d+\.\d+\.\d+) \(Claude Code\)$/);
|
|
27144
27392
|
if (!hostVersion || compareVersions3(hostVersion[1], "2.1.295") < 0) fail7("claude_21295_required");
|
|
27145
27393
|
const help = await runClaude(["--help"]);
|
|
27146
27394
|
if (typeof help !== "string" || Buffer.byteLength(help) > 128 * 1024) fail7("claude_capabilities_unconfirmed");
|
|
27147
27395
|
const hasPlugin = /^\s+plugin(?:\|plugins)?\s/m.test(help), hasMcp = /^\s+mcp\s/m.test(help);
|
|
27148
|
-
const base =
|
|
27149
|
-
const pluginPending = await info4(
|
|
27396
|
+
const base = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path20.join(base, "claude-code-mcp"), pluginRoot = path20.join(base, "claude-code");
|
|
27397
|
+
const pluginPending = await info4(path20.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path20.join(pluginRoot, "current.json")), fallbackState = await info4(path20.join(fallbackRoot, "current.json")) || await info4(path20.join(fallbackRoot, "registration-pending.json"));
|
|
27150
27398
|
if ((!hasPlugin || fallbackState) && (pluginPending || pluginCurrent)) fail7("registration_unconfirmed_keep_existing");
|
|
27151
27399
|
if (!hasPlugin || fallbackState) {
|
|
27152
27400
|
if (!hasMcp) fail7("claude_capabilities_unconfirmed");
|
|
27153
27401
|
return installClaudeMcpFallback({ sourceRoot, profile, env, configFile: configFile2, signal, runClaude, checkRuntime, verifyInstalledRuntime, nodeCommand });
|
|
27154
27402
|
}
|
|
27155
|
-
const payload = await inspectRuntimePackage(
|
|
27403
|
+
const payload = await inspectRuntimePackage(path20.resolve(sourceRoot));
|
|
27156
27404
|
if (!payload.files.some((f2) => f2.path === ".claude-plugin/plugin.json") || !payload.files.some((f2) => f2.path === ".claude-mcp.json"))
|
|
27157
27405
|
fail7("claude_package_incomplete");
|
|
27158
|
-
const root =
|
|
27159
|
-
await
|
|
27406
|
+
const root = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile, "claude-code");
|
|
27407
|
+
await privateDirectory7(root);
|
|
27160
27408
|
const release = await acquire4(root, signal);
|
|
27161
27409
|
const suffix = profile === "default" ? "" : "-" + profile, pluginName = "promptframe-creation" + suffix, marketplace = "promptframe-creation-user" + suffix, pluginId = pluginName + "@" + marketplace, serverName = "promptframe" + suffix;
|
|
27162
|
-
const versions =
|
|
27410
|
+
const versions = path20.join(root, "versions"), currentFile = path20.join(root, "current.json"), pendingFile = path20.join(root, "registration-pending.json"), catalogFile = path20.join(root, ".claude-plugin/marketplace.json"), versionRoot = path20.join(versions, payload.version), temporary = path20.join(versions, ".partial-" + randomBytes8(12).toString("hex"));
|
|
27163
27411
|
let registrationStarted = false, newFiles = 0;
|
|
27164
27412
|
try {
|
|
27165
27413
|
signal?.throwIfAborted();
|
|
27166
|
-
await
|
|
27167
|
-
await
|
|
27414
|
+
await privateDirectory7(versions);
|
|
27415
|
+
await privateDirectory7(path20.dirname(catalogFile));
|
|
27168
27416
|
await legacyUserMcp(env, serverName);
|
|
27169
|
-
let previous = await
|
|
27417
|
+
let previous = await privateRead6(currentFile), pending = await privateRead6(pendingFile), state = await registrations(runClaude, pluginName, marketplace, root);
|
|
27170
27418
|
const binding = { profile, configFile: configFile2, pluginId, pluginName, serverName, host: "claude-code" };
|
|
27171
27419
|
const checkBinding = (record2) => {
|
|
27172
|
-
if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !==
|
|
27420
|
+
if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path20.join(versions, record2.version))) fail7("profile_binding_conflict");
|
|
27173
27421
|
};
|
|
27174
27422
|
checkBinding(previous);
|
|
27175
27423
|
checkBinding(pending);
|
|
@@ -27213,12 +27461,12 @@ async function installClaudeUserLocked({
|
|
|
27213
27461
|
const ready = await verifyVersion2(versionRoot, { ...complete, pluginName, serverName });
|
|
27214
27462
|
runtimeCommands.set(versionRoot, ready.runtimeCommand);
|
|
27215
27463
|
} else {
|
|
27216
|
-
await
|
|
27464
|
+
await mkdir9(temporary, { mode: 448 });
|
|
27217
27465
|
for (const file of payload.files) {
|
|
27218
27466
|
signal?.throwIfAborted();
|
|
27219
|
-
const dest =
|
|
27220
|
-
await
|
|
27221
|
-
const fd = await
|
|
27467
|
+
const dest = path20.join(temporary, file.path);
|
|
27468
|
+
await mkdir9(path20.dirname(dest), { recursive: true, mode: 448 });
|
|
27469
|
+
const fd = await open12(dest, "wx", 384);
|
|
27222
27470
|
try {
|
|
27223
27471
|
await fd.writeFile(file.body);
|
|
27224
27472
|
await fd.sync();
|
|
@@ -27226,21 +27474,21 @@ async function installClaudeUserLocked({
|
|
|
27226
27474
|
await fd.close();
|
|
27227
27475
|
}
|
|
27228
27476
|
}
|
|
27229
|
-
const manifest = JSON.parse(await readFile9(
|
|
27477
|
+
const manifest = JSON.parse(await readFile9(path20.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
|
|
27230
27478
|
manifest.name = pluginName;
|
|
27231
27479
|
if (manifest.hooks) manifest.hooks = claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand });
|
|
27232
|
-
await atomicJSON4(
|
|
27233
|
-
for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(
|
|
27480
|
+
await atomicJSON4(path20.join(temporary, ".claude-plugin/plugin.json"), manifest);
|
|
27481
|
+
for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path20.join(temporary, file), transport(serverName, configFile2, nodeCommand));
|
|
27234
27482
|
await checkRuntime(temporary, payload.version);
|
|
27235
27483
|
const installed = await inspectRuntimePackage(temporary);
|
|
27236
|
-
await atomicJSON4(
|
|
27484
|
+
await atomicJSON4(path20.join(temporary, "installation.json"), {
|
|
27237
27485
|
...binding,
|
|
27238
27486
|
version: payload.version,
|
|
27239
27487
|
payloadDigest: payload.payloadDigest,
|
|
27240
|
-
files: installed.files.map(({ path:
|
|
27488
|
+
files: installed.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))
|
|
27241
27489
|
});
|
|
27242
27490
|
signal?.throwIfAborted();
|
|
27243
|
-
await
|
|
27491
|
+
await rename9(temporary, versionRoot);
|
|
27244
27492
|
newFiles = payload.files.length;
|
|
27245
27493
|
}
|
|
27246
27494
|
if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, runtimeCommands.get(versionRoot), { env });
|
|
@@ -27275,14 +27523,14 @@ async function installClaudeUserLocked({
|
|
|
27275
27523
|
requestedVersion: payload.version,
|
|
27276
27524
|
recordedRuntimeRetained: runtimeCommands.has(versionRoot) && runtimeCommands.get(versionRoot) !== nodeCommand
|
|
27277
27525
|
};
|
|
27278
|
-
} catch (
|
|
27526
|
+
} catch (error6) {
|
|
27279
27527
|
if (registrationStarted) fail7("registration_unconfirmed_keep_existing", {
|
|
27280
|
-
...claudeErrorDetails(
|
|
27528
|
+
...claudeErrorDetails(error6),
|
|
27281
27529
|
phase: "registration_observation",
|
|
27282
27530
|
localRegistrationState: "unknown",
|
|
27283
27531
|
action: "inspect_same_registration_no_second_add"
|
|
27284
27532
|
});
|
|
27285
|
-
if (
|
|
27533
|
+
if (error6 instanceof CreationClientError) throw error6;
|
|
27286
27534
|
fail7(signal?.aborted ? "interrupted_keep_existing" : "failed_keep_existing");
|
|
27287
27535
|
} finally {
|
|
27288
27536
|
await rm5(temporary, { recursive: true, force: true });
|
|
@@ -27290,9 +27538,240 @@ async function installClaudeUserLocked({
|
|
|
27290
27538
|
}
|
|
27291
27539
|
}
|
|
27292
27540
|
|
|
27541
|
+
// lib/antigravity-installation.mjs
|
|
27542
|
+
import { lstat as lstat13, mkdir as mkdir10, open as open13, readFile as readFile10, rename as rename10, rm as rm6 } from "node:fs/promises";
|
|
27543
|
+
import { createHash as createHash14, randomBytes as randomBytes9 } from "node:crypto";
|
|
27544
|
+
import { homedir as homedir12 } from "node:os";
|
|
27545
|
+
import path21 from "node:path";
|
|
27546
|
+
var hash7 = (b2) => createHash14("sha256").update(b2).digest("hex");
|
|
27547
|
+
var fail8 = (code) => {
|
|
27548
|
+
throw new CreationClientError("installation." + code);
|
|
27549
|
+
};
|
|
27550
|
+
var profileFormat = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
27551
|
+
function shellQuote(value2) {
|
|
27552
|
+
return '"' + String(value2).replace(/(["\\$`])/g, "\\$1") + '"';
|
|
27553
|
+
}
|
|
27554
|
+
function antigravityPluginManifest({ version: version3, name = "promptframe-creation", displayName = "PromptFrame Creation" }) {
|
|
27555
|
+
return {
|
|
27556
|
+
name,
|
|
27557
|
+
displayName,
|
|
27558
|
+
description: "PromptFrame video creation Skill and MCP bridge for Antigravity: inspect projects, plan shots, search/author components, preview and render videos.",
|
|
27559
|
+
version: version3,
|
|
27560
|
+
repository: "https://github.com/ty-teams/promptframe-creation",
|
|
27561
|
+
suggestedPrompts: [
|
|
27562
|
+
"\u5217\u51FA\u6211\u5728 PromptFrame \u5F53\u524D\u9879\u76EE\u4E2D\u7684\u4F5C\u54C1\u5E76\u8BFB\u53D6\u6700\u65B0\u72B6\u6001",
|
|
27563
|
+
"\u5E2E\u6211\u5728 PromptFrame \u4E2D\u89C4\u5212\u5E76\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u79D1\u666E\u89C6\u9891\u5206\u955C",
|
|
27564
|
+
"\u5728\u7EC4\u4EF6\u5E02\u573A\u641C\u7D22\u9002\u5408\u6570\u636E\u5BF9\u6BD4\u5C55\u793A\u7684\u53EF\u89C6\u5316\u7EC4\u4EF6"
|
|
27565
|
+
]
|
|
27566
|
+
};
|
|
27567
|
+
}
|
|
27568
|
+
function antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot, configFile: configFile2 }) {
|
|
27569
|
+
return {
|
|
27570
|
+
mcpServers: {
|
|
27571
|
+
[serverName]: {
|
|
27572
|
+
command: nodeCommand,
|
|
27573
|
+
args: [path21.join(runtimeRoot, "bin", "promptframe-creation.mjs"), "bridge", "--config", configFile2, "--host", "antigravity"]
|
|
27574
|
+
}
|
|
27575
|
+
}
|
|
27576
|
+
};
|
|
27577
|
+
}
|
|
27578
|
+
function antigravityHooksConfig({ nodeCommand, runtimeRoot, configFile: configFile2 }) {
|
|
27579
|
+
const cliPath = path21.join(runtimeRoot, "bin", "promptframe-creation.mjs");
|
|
27580
|
+
const command2 = [shellQuote(nodeCommand), shellQuote(cliPath), "antigravity-host-hook", "--config", shellQuote(configFile2)].join(" ");
|
|
27581
|
+
return {
|
|
27582
|
+
"promptframe-host-identity": {
|
|
27583
|
+
PreToolUse: [
|
|
27584
|
+
{
|
|
27585
|
+
matcher: "(.*promptframe.*|^platform_.*)",
|
|
27586
|
+
hooks: [{ type: "command", command: command2, timeout: 5 }]
|
|
27587
|
+
}
|
|
27588
|
+
]
|
|
27589
|
+
}
|
|
27590
|
+
};
|
|
27591
|
+
}
|
|
27592
|
+
async function readJsonOrNull(file) {
|
|
27593
|
+
try {
|
|
27594
|
+
return JSON.parse(await readFile10(file, "utf8"));
|
|
27595
|
+
} catch (e) {
|
|
27596
|
+
if (e.code === "ENOENT") return null;
|
|
27597
|
+
throw e;
|
|
27598
|
+
}
|
|
27599
|
+
}
|
|
27600
|
+
async function writeFileAtomic(file, content, mode = 384) {
|
|
27601
|
+
await mkdir10(path21.dirname(file), { recursive: true, mode: 448 });
|
|
27602
|
+
const tmp = file + "." + randomBytes9(8).toString("hex") + ".partial";
|
|
27603
|
+
const fd = await open13(tmp, "wx", mode);
|
|
27604
|
+
try {
|
|
27605
|
+
await fd.writeFile(content);
|
|
27606
|
+
await fd.sync();
|
|
27607
|
+
} finally {
|
|
27608
|
+
await fd.close();
|
|
27609
|
+
}
|
|
27610
|
+
await rename10(tmp, file);
|
|
27611
|
+
}
|
|
27612
|
+
async function copyPackagePayload(payload, destRoot) {
|
|
27613
|
+
const tmp = destRoot + ".partial-" + randomBytes9(8).toString("hex");
|
|
27614
|
+
await mkdir10(tmp, { recursive: true, mode: 448 });
|
|
27615
|
+
try {
|
|
27616
|
+
for (const file of payload.files) {
|
|
27617
|
+
const dest = path21.join(tmp, ...file.path.split("/"));
|
|
27618
|
+
await mkdir10(path21.dirname(dest), { recursive: true, mode: 448 });
|
|
27619
|
+
const fd = await open13(dest, "wx", 384);
|
|
27620
|
+
try {
|
|
27621
|
+
await fd.writeFile(file.body);
|
|
27622
|
+
await fd.sync();
|
|
27623
|
+
} finally {
|
|
27624
|
+
await fd.close();
|
|
27625
|
+
}
|
|
27626
|
+
}
|
|
27627
|
+
await rename10(tmp, destRoot);
|
|
27628
|
+
} catch (e) {
|
|
27629
|
+
await rm6(tmp, { recursive: true, force: true }).catch(() => {
|
|
27630
|
+
});
|
|
27631
|
+
throw e;
|
|
27632
|
+
}
|
|
27633
|
+
}
|
|
27634
|
+
async function installForAntigravityUser({
|
|
27635
|
+
sourceRoot,
|
|
27636
|
+
profile = "default",
|
|
27637
|
+
configFile: configFile2,
|
|
27638
|
+
env = process.env,
|
|
27639
|
+
nodeCommand = process.execPath,
|
|
27640
|
+
signal
|
|
27641
|
+
} = {}) {
|
|
27642
|
+
if (!profileFormat.test(profile)) fail8("profile_invalid");
|
|
27643
|
+
if (!path21.isAbsolute(configFile2 ?? "")) fail8("config_path_invalid");
|
|
27644
|
+
signal?.throwIfAborted();
|
|
27645
|
+
const payload = await inspectRuntimePackage(sourceRoot);
|
|
27646
|
+
const suffix = profile === "default" ? "" : "-" + profile;
|
|
27647
|
+
const pluginDirName = "promptframe-creation" + suffix;
|
|
27648
|
+
const serverName = "promptframe-creation" + suffix;
|
|
27649
|
+
const dataRoot = path21.resolve(env.XDG_DATA_HOME ?? path21.join(homedir12(), ".local", "share"), "promptframe-creation", profile, "antigravity");
|
|
27650
|
+
const versionRoot = path21.join(dataRoot, "versions", payload.version);
|
|
27651
|
+
const pluginsRoot = path21.join(antigravityConfigRoot(env), "plugins");
|
|
27652
|
+
const pluginDir = path21.join(pluginsRoot, pluginDirName);
|
|
27653
|
+
const markerFile = path21.join(pluginDir, "promptframe-installation.json");
|
|
27654
|
+
let pluginDirectoryExists = false;
|
|
27655
|
+
try {
|
|
27656
|
+
const status = await lstat13(pluginDir);
|
|
27657
|
+
if (!status.isDirectory() || status.isSymbolicLink()) fail8("managed_installation_invalid");
|
|
27658
|
+
pluginDirectoryExists = true;
|
|
27659
|
+
} catch (error6) {
|
|
27660
|
+
if (error6.code !== "ENOENT") throw error6;
|
|
27661
|
+
}
|
|
27662
|
+
const existing = await readJsonOrNull(markerFile);
|
|
27663
|
+
if (pluginDirectoryExists && !existing) fail8("managed_installation_invalid");
|
|
27664
|
+
if (existing) {
|
|
27665
|
+
if (existing.host !== "antigravity" || existing.profile !== profile || existing.configFile !== configFile2 || typeof existing.version !== "string" || !/^\d+\.\d+\.\d+$/.test(existing.version)) fail8("managed_installation_invalid");
|
|
27666
|
+
const cmp = compareBridgeVersions(existing.version, payload.version);
|
|
27667
|
+
if (cmp > 0) {
|
|
27668
|
+
return {
|
|
27669
|
+
registered: true,
|
|
27670
|
+
pluginInstalled: true,
|
|
27671
|
+
pluginEnabled: true,
|
|
27672
|
+
reused: true,
|
|
27673
|
+
host: "antigravity",
|
|
27674
|
+
installationMode: "antigravity-plugin",
|
|
27675
|
+
profile,
|
|
27676
|
+
version: existing.version,
|
|
27677
|
+
requestedVersion: payload.version,
|
|
27678
|
+
versionStatus: "newer_installed_kept",
|
|
27679
|
+
recordedRuntimeRetained: true,
|
|
27680
|
+
pluginDir,
|
|
27681
|
+
serverName,
|
|
27682
|
+
skillsInstalled: true,
|
|
27683
|
+
skills: [{ name: "creation-setup" }, { name: "video-creation" }]
|
|
27684
|
+
};
|
|
27685
|
+
}
|
|
27686
|
+
if (cmp === 0 && existing.payloadDigest === payload.payloadDigest && existing.versionRoot === versionRoot) {
|
|
27687
|
+
return {
|
|
27688
|
+
registered: true,
|
|
27689
|
+
pluginInstalled: true,
|
|
27690
|
+
pluginEnabled: true,
|
|
27691
|
+
reused: true,
|
|
27692
|
+
host: "antigravity",
|
|
27693
|
+
installationMode: "antigravity-plugin",
|
|
27694
|
+
profile,
|
|
27695
|
+
version: payload.version,
|
|
27696
|
+
requestedVersion: payload.version,
|
|
27697
|
+
versionStatus: "already_current",
|
|
27698
|
+
recordedRuntimeRetained: false,
|
|
27699
|
+
pluginDir,
|
|
27700
|
+
serverName,
|
|
27701
|
+
skillsInstalled: true,
|
|
27702
|
+
skills: [{ name: "creation-setup" }, { name: "video-creation" }]
|
|
27703
|
+
};
|
|
27704
|
+
}
|
|
27705
|
+
}
|
|
27706
|
+
let versionExists = false;
|
|
27707
|
+
try {
|
|
27708
|
+
const s3 = await lstat13(versionRoot);
|
|
27709
|
+
versionExists = s3.isDirectory() && !s3.isSymbolicLink();
|
|
27710
|
+
} catch (e) {
|
|
27711
|
+
if (e.code !== "ENOENT") throw e;
|
|
27712
|
+
}
|
|
27713
|
+
if (!versionExists) {
|
|
27714
|
+
await mkdir10(path21.dirname(versionRoot), { recursive: true, mode: 448 });
|
|
27715
|
+
await copyPackagePayload(payload, versionRoot);
|
|
27716
|
+
}
|
|
27717
|
+
signal?.throwIfAborted();
|
|
27718
|
+
if (!existing) {
|
|
27719
|
+
await mkdir10(pluginsRoot, { recursive: true, mode: 448 });
|
|
27720
|
+
await mkdir10(pluginDir, { mode: 448 });
|
|
27721
|
+
}
|
|
27722
|
+
const pluginJson = JSON.stringify(antigravityPluginManifest({
|
|
27723
|
+
version: payload.version,
|
|
27724
|
+
name: pluginDirName,
|
|
27725
|
+
displayName: profile === "default" ? "PromptFrame Creation" : "PromptFrame Creation (" + profile + ")"
|
|
27726
|
+
}), null, 2) + "\n";
|
|
27727
|
+
const mcpJson = JSON.stringify(antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot: versionRoot, configFile: configFile2 }), null, 2) + "\n";
|
|
27728
|
+
const hooksJson = JSON.stringify(antigravityHooksConfig({ nodeCommand, runtimeRoot: versionRoot, configFile: configFile2 }), null, 2) + "\n";
|
|
27729
|
+
await writeFileAtomic(path21.join(pluginDir, "plugin.json"), pluginJson, 420);
|
|
27730
|
+
await writeFileAtomic(path21.join(pluginDir, "mcp_config.json"), mcpJson, 384);
|
|
27731
|
+
await writeFileAtomic(path21.join(pluginDir, "hooks.json"), hooksJson, 384);
|
|
27732
|
+
const skillEntries = payload.files.filter((f2) => f2.path.startsWith("skills/") && f2.path.endsWith("/SKILL.md"));
|
|
27733
|
+
for (const skill of skillEntries) {
|
|
27734
|
+
const dest = path21.join(pluginDir, ...skill.path.split("/"));
|
|
27735
|
+
await writeFileAtomic(dest, skill.body, 420);
|
|
27736
|
+
}
|
|
27737
|
+
const record2 = {
|
|
27738
|
+
contractVersion: "antigravity-plugin-installation/v1",
|
|
27739
|
+
host: "antigravity",
|
|
27740
|
+
profile,
|
|
27741
|
+
configFile: configFile2,
|
|
27742
|
+
pluginDirName,
|
|
27743
|
+
serverName,
|
|
27744
|
+
version: payload.version,
|
|
27745
|
+
versionRoot,
|
|
27746
|
+
nodeCommand,
|
|
27747
|
+
payloadDigest: payload.payloadDigest,
|
|
27748
|
+
mcpDigest: hash7(mcpJson),
|
|
27749
|
+
hooksDigest: hash7(hooksJson),
|
|
27750
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
27751
|
+
};
|
|
27752
|
+
await writeFileAtomic(markerFile, JSON.stringify(record2, null, 2) + "\n", 384);
|
|
27753
|
+
return {
|
|
27754
|
+
registered: true,
|
|
27755
|
+
pluginInstalled: true,
|
|
27756
|
+
pluginEnabled: true,
|
|
27757
|
+
reused: false,
|
|
27758
|
+
host: "antigravity",
|
|
27759
|
+
installationMode: "antigravity-plugin",
|
|
27760
|
+
profile,
|
|
27761
|
+
version: payload.version,
|
|
27762
|
+
requestedVersion: payload.version,
|
|
27763
|
+
versionStatus: existing ? "upgraded" : "installed",
|
|
27764
|
+
recordedRuntimeRetained: false,
|
|
27765
|
+
pluginDir,
|
|
27766
|
+
serverName,
|
|
27767
|
+
skillsInstalled: true,
|
|
27768
|
+
skills: skillEntries.map((s3) => ({ name: s3.path.split("/")[1] }))
|
|
27769
|
+
};
|
|
27770
|
+
}
|
|
27771
|
+
|
|
27293
27772
|
// lib/cli.mjs
|
|
27294
27773
|
import { fileURLToPath } from "node:url";
|
|
27295
|
-
import
|
|
27774
|
+
import path22 from "node:path";
|
|
27296
27775
|
var args = process.argv.slice(2);
|
|
27297
27776
|
var command = args.shift();
|
|
27298
27777
|
var value = (key) => {
|
|
@@ -27300,9 +27779,9 @@ var value = (key) => {
|
|
|
27300
27779
|
return i < 0 ? void 0 : args[i + 1];
|
|
27301
27780
|
};
|
|
27302
27781
|
var log = (value2) => process.stdout.write(JSON.stringify(value2) + "\n");
|
|
27303
|
-
var configFile = () => value("--config") ?
|
|
27782
|
+
var configFile = () => value("--config") ? path22.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
|
|
27304
27783
|
async function probe(credentials) {
|
|
27305
|
-
const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }) });
|
|
27784
|
+
const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }), clientConfigFile: configFile() });
|
|
27306
27785
|
try {
|
|
27307
27786
|
return { tools: (await client.listTools()).tools.length, accountIdentity: connectionAccountIdentity(client) };
|
|
27308
27787
|
} finally {
|
|
@@ -27321,8 +27800,8 @@ async function rememberAuthorization(credentials, file, accountIdentity) {
|
|
|
27321
27800
|
profile: value("--profile") ?? "default"
|
|
27322
27801
|
});
|
|
27323
27802
|
return { status: "recorded" };
|
|
27324
|
-
} catch (
|
|
27325
|
-
return { status: "unavailable", reasonCode:
|
|
27803
|
+
} catch (error6) {
|
|
27804
|
+
return { status: "unavailable", reasonCode: error6 instanceof CreationClientError ? error6.message : "accounts.storage_unavailable" };
|
|
27326
27805
|
}
|
|
27327
27806
|
}
|
|
27328
27807
|
async function tokenInput() {
|
|
@@ -27422,8 +27901,8 @@ async function setup({ silent = false } = {}) {
|
|
|
27422
27901
|
version: 1,
|
|
27423
27902
|
endpoint,
|
|
27424
27903
|
token,
|
|
27425
|
-
clientId: existing?.clientId ??
|
|
27426
|
-
clientName: value("--name") ?? existing?.clientName ?? (resolveHostIdentity({ host: value("--host") })
|
|
27904
|
+
clientId: existing?.clientId ?? randomBytes10(24).toString("base64url"),
|
|
27905
|
+
clientName: value("--name") ?? existing?.clientName ?? hostClientName("Codex PromptFrame", resolveHostIdentity({ host: value("--host") })),
|
|
27427
27906
|
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
27428
27907
|
};
|
|
27429
27908
|
const { tools, accountIdentity } = await probe(credentials);
|
|
@@ -27447,7 +27926,8 @@ async function bridge() {
|
|
|
27447
27926
|
contentTypes: () => contentTypes,
|
|
27448
27927
|
contentSource: () => contentSource,
|
|
27449
27928
|
enforceMinimum: false,
|
|
27450
|
-
signal: startup.signal
|
|
27929
|
+
signal: startup.signal,
|
|
27930
|
+
clientConfigFile: configFile()
|
|
27451
27931
|
});
|
|
27452
27932
|
upstream = client.getServerCapabilities() ?? {};
|
|
27453
27933
|
policy = readPlatformBridgePolicy(upstream);
|
|
@@ -27458,14 +27938,14 @@ async function bridge() {
|
|
|
27458
27938
|
resolvedVersion: value("--resolved-runtime-version"),
|
|
27459
27939
|
signal: startup.signal,
|
|
27460
27940
|
hostKind: identity.kind,
|
|
27461
|
-
cacheRoot:
|
|
27941
|
+
cacheRoot: path22.join(path22.dirname(configFile()), "runtime-cache")
|
|
27462
27942
|
});
|
|
27463
27943
|
startup.signal.throwIfAborted();
|
|
27464
|
-
} catch (
|
|
27944
|
+
} catch (error6) {
|
|
27465
27945
|
await client?.close().catch(() => {
|
|
27466
27946
|
});
|
|
27467
27947
|
if (startup.signal.aborted) throw new CreationClientError("creation.runtime_selection_interrupted");
|
|
27468
|
-
throw
|
|
27948
|
+
throw error6;
|
|
27469
27949
|
} finally {
|
|
27470
27950
|
process.removeListener("SIGINT", abort);
|
|
27471
27951
|
process.removeListener("SIGTERM", abort);
|
|
@@ -27477,7 +27957,7 @@ async function bridge() {
|
|
|
27477
27957
|
return;
|
|
27478
27958
|
}
|
|
27479
27959
|
await rememberAuthorization(credentials, configFile(), connectionAccountIdentity(client));
|
|
27480
|
-
const hostSession = identity.kind === "claude-code" ? await createClaudeHostSession({ configFile: configFile() }) : void 0;
|
|
27960
|
+
const hostSession = identity.kind === "claude-code" ? await createClaudeHostSession({ configFile: configFile() }) : identity.kind === "antigravity" ? await createAntigravityHostSession({ configFile: configFile() }) : void 0;
|
|
27481
27961
|
const server = new Server(
|
|
27482
27962
|
{ name: "promptframe-creation", version: CLIENT_VERSION },
|
|
27483
27963
|
{ capabilities: {
|
|
@@ -27497,9 +27977,9 @@ async function bridge() {
|
|
|
27497
27977
|
hostSession,
|
|
27498
27978
|
connectionOptions: { contentTypes: () => contentTypes, contentSource: () => contentSource },
|
|
27499
27979
|
createLocalUploads: ({ identity: account, agent, configFile: file }) => createLocalUploadManager({
|
|
27500
|
-
stateRoot:
|
|
27980
|
+
stateRoot: path22.join(path22.dirname(file), "local-upload-state", "accounts", localAccountKey(account), localAgentDigest(agent).slice(7))
|
|
27501
27981
|
}),
|
|
27502
|
-
localUploads: createLocalUploadManager({ stateRoot:
|
|
27982
|
+
localUploads: createLocalUploadManager({ stateRoot: path22.join(path22.dirname(configFile()), "local-upload-state") }),
|
|
27503
27983
|
onCatalogChange: () => server.sendToolListChanged(),
|
|
27504
27984
|
onKnowledgeChange: (kind) => kind === "resources" ? server.sendResourceListChanged() : server.sendPromptListChanged()
|
|
27505
27985
|
});
|
|
@@ -27514,11 +27994,11 @@ async function bridge() {
|
|
|
27514
27994
|
const knowledgeHandler = (schema, method) => server.setRequestHandler(schema, async (request) => {
|
|
27515
27995
|
try {
|
|
27516
27996
|
return await host[method](request.params ?? {});
|
|
27517
|
-
} catch (
|
|
27518
|
-
const remote =
|
|
27519
|
-
const code =
|
|
27520
|
-
const knownRemote = typeof remote === "string" && code === remote && typeof
|
|
27521
|
-
throw new McpError(knownRemote ?
|
|
27997
|
+
} catch (error6) {
|
|
27998
|
+
const remote = error6?.data?.errorCode;
|
|
27999
|
+
const code = error6 instanceof CreationClientError ? error6.message : typeof remote === "string" && /^(?:creation|creative_skill)\.[a-z0-9_.:-]{1,160}$/.test(remote) ? remote : "creation.connection_unresolved";
|
|
28000
|
+
const knownRemote = typeof remote === "string" && code === remote && typeof error6.code === "number" && Object.values(ErrorCode).includes(error6.code);
|
|
28001
|
+
throw new McpError(knownRemote ? error6.code : error6 instanceof CreationClientError ? ErrorCode.InvalidParams : ErrorCode.InternalError, code, { errorCode: code });
|
|
27522
28002
|
}
|
|
27523
28003
|
});
|
|
27524
28004
|
if (upstream.resources) {
|
|
@@ -27540,7 +28020,7 @@ async function bridge() {
|
|
|
27540
28020
|
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
27541
28021
|
try {
|
|
27542
28022
|
return await host.call(request.params, { signal: extra.signal });
|
|
27543
|
-
} catch (
|
|
28023
|
+
} catch (error6) {
|
|
27544
28024
|
return {
|
|
27545
28025
|
isError: true,
|
|
27546
28026
|
content: [
|
|
@@ -27548,9 +28028,9 @@ async function bridge() {
|
|
|
27548
28028
|
type: "text",
|
|
27549
28029
|
text: JSON.stringify({
|
|
27550
28030
|
success: false,
|
|
27551
|
-
errorCode:
|
|
27552
|
-
...
|
|
27553
|
-
action:
|
|
28031
|
+
errorCode: error6 instanceof CreationClientError ? error6.message : "creation.connection_unresolved",
|
|
28032
|
+
...error6 instanceof CreationClientError && error6.message === "creation.host_session_changed" ? { effectStatus: "unknown", automaticReplayAllowed: false } : {},
|
|
28033
|
+
action: error6 instanceof CreationClientError ? error6.message === "creation.host_session_changed" ? "read_original_task_without_replaying_business" : error6.message.startsWith("creation.host_") ? "use_supported_host_with_session_identity" : error6.message === "creation.editor_not_current" ? "request_control_and_confirm_in_studio" : "read_current_platform_facts_without_replaying_business" : "read_original_task_or_retry_same_idempotency_key"
|
|
27554
28034
|
})
|
|
27555
28035
|
}
|
|
27556
28036
|
]
|
|
@@ -27587,7 +28067,8 @@ try {
|
|
|
27587
28067
|
process.once("SIGINT", abort);
|
|
27588
28068
|
process.once("SIGTERM", abort);
|
|
27589
28069
|
try {
|
|
27590
|
-
const host = resolveHostIdentity({ host: value("--host") })
|
|
28070
|
+
const host = resolveHostIdentity({ host: value("--host") });
|
|
28071
|
+
const installer = host.kind === "claude-code" ? installForClaudeUser : host.kind === "antigravity" ? installForAntigravityUser : installForUser;
|
|
27591
28072
|
const installed = await installer({
|
|
27592
28073
|
sourceRoot: fileURLToPath(new URL("..", import.meta.url)),
|
|
27593
28074
|
executable: value("--claude-bin"),
|
|
@@ -27596,6 +28077,7 @@ try {
|
|
|
27596
28077
|
signal: signal.signal
|
|
27597
28078
|
});
|
|
27598
28079
|
const skillNames = installed.skills?.map((skill) => skill.name) ?? ["creation-setup", "video-creation"];
|
|
28080
|
+
const nextStep = host.kind === "claude-code" ? "On this host, start a new Claude Code session." : host.kind === "antigravity" ? "On this host, start a new Antigravity conversation (or check promptframe-creation in Customizations)." : "On this host, open a new Local chat (CLI: start a new session).";
|
|
27599
28081
|
log({
|
|
27600
28082
|
...connection,
|
|
27601
28083
|
pluginRegistered: (installed.pluginInstalled ?? true) && installed.registered,
|
|
@@ -27605,6 +28087,7 @@ try {
|
|
|
27605
28087
|
pluginInstalled: installed.pluginInstalled ?? true,
|
|
27606
28088
|
pluginEnabled: installed.pluginEnabled ?? true,
|
|
27607
28089
|
...installed.installationMode ? { installationMode: installed.installationMode, skillsInstalled: installed.skillsInstalled, skills: skillNames } : {},
|
|
28090
|
+
...installed.pluginDir ? { pluginDir: installed.pluginDir } : {},
|
|
27608
28091
|
hostMcpConnected: "not_verified",
|
|
27609
28092
|
sessionLoaded: "not_verified",
|
|
27610
28093
|
installationReused: installed.reused,
|
|
@@ -27612,7 +28095,7 @@ try {
|
|
|
27612
28095
|
requestedVersion: installed.requestedVersion,
|
|
27613
28096
|
versionStatus: installed.versionStatus,
|
|
27614
28097
|
recordedRuntimeRetained: installed.recordedRuntimeRetained ?? false,
|
|
27615
|
-
next:
|
|
28098
|
+
next: nextStep + " Check " + skillNames.join(", ") + " and the PromptFrame MCP tools together. Keep the existing Token; no reinstall or product repository is needed." + (installed.recordedRuntimeRetained ? " Keep this version's recorded Node path available." : ""),
|
|
27616
28099
|
hostThreadIdentity: "verified_by_the_platform_on_actual_host_tool_calls"
|
|
27617
28100
|
});
|
|
27618
28101
|
} finally {
|
|
@@ -27621,6 +28104,7 @@ try {
|
|
|
27621
28104
|
}
|
|
27622
28105
|
} else if (command === "bridge") await bridge();
|
|
27623
28106
|
else if (command === "claude-host-hook") await runClaudeHostHook({ configFile: configFile() });
|
|
28107
|
+
else if (command === "antigravity-host-hook") await runAntigravityHostHook({ configFile: configFile() });
|
|
27624
28108
|
else if (command === "--version") process.stdout.write(CLIENT_VERSION + "\n");
|
|
27625
28109
|
else if (command === "accounts") {
|
|
27626
28110
|
if (args[0] === "refresh") {
|
|
@@ -27644,19 +28128,19 @@ try {
|
|
|
27644
28128
|
});
|
|
27645
28129
|
} else if (command === "help" || command === "--help" || !command) {
|
|
27646
28130
|
process.stdout.write(
|
|
27647
|
-
"promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0
|
|
28131
|
+
"promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code|antigravity] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0, Claude Code >=2.1.295 or Google Antigravity. Token input is masked in a terminal or accepted through --token-stdin; never use a Token command argument.\nBridge startup checks the platform minimum/recommended version. --bridge-version locks one exact compatible version for this new session; active bridges are not replaced.\n"
|
|
27648
28132
|
);
|
|
27649
28133
|
} else throw new CreationClientError("command.unknown");
|
|
27650
|
-
} catch (
|
|
28134
|
+
} catch (error6) {
|
|
27651
28135
|
process.stderr.write(
|
|
27652
28136
|
JSON.stringify({
|
|
27653
|
-
...installationErrorDetails(
|
|
27654
|
-
...claudeInstallationDetails(
|
|
27655
|
-
...claudeErrorDetails(
|
|
27656
|
-
...fallbackErrorDetails(
|
|
27657
|
-
...bridgeErrorDetails(
|
|
27658
|
-
...runtimeErrorDetails(
|
|
27659
|
-
error:
|
|
28137
|
+
...installationErrorDetails(error6),
|
|
28138
|
+
...claudeInstallationDetails(error6),
|
|
28139
|
+
...claudeErrorDetails(error6),
|
|
28140
|
+
...fallbackErrorDetails(error6),
|
|
28141
|
+
...bridgeErrorDetails(error6),
|
|
28142
|
+
...runtimeErrorDetails(error6),
|
|
28143
|
+
error: error6 instanceof CreationClientError ? error6.message : "creation.connection_failed"
|
|
27660
28144
|
}) + "\n"
|
|
27661
28145
|
);
|
|
27662
28146
|
process.exitCode = 1;
|