commonswarm 0.1.50 → 0.1.52
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/cswarm.cjs +1342 -1201
- package/package.json +1 -1
package/cswarm.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
|
|
|
44
44
|
));
|
|
45
45
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
46
|
|
|
47
|
-
// node_modules/tslib/tslib.es6.mjs
|
|
47
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/tslib/tslib.es6.mjs
|
|
48
48
|
var tslib_es6_exports = {};
|
|
49
49
|
__export(tslib_es6_exports, {
|
|
50
50
|
__addDisposableResource: () => __addDisposableResource,
|
|
@@ -483,7 +483,7 @@ function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
|
483
483
|
}
|
|
484
484
|
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
|
|
485
485
|
var init_tslib_es6 = __esm({
|
|
486
|
-
"node_modules/tslib/tslib.es6.mjs"() {
|
|
486
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/tslib/tslib.es6.mjs"() {
|
|
487
487
|
extendStatics = function(d, b2) {
|
|
488
488
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
|
|
489
489
|
d2.__proto__ = b3;
|
|
@@ -569,9 +569,9 @@ var init_tslib_es6 = __esm({
|
|
|
569
569
|
}
|
|
570
570
|
});
|
|
571
571
|
|
|
572
|
-
// node_modules/@supabase/functions-js/dist/main/helper.js
|
|
572
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/helper.js
|
|
573
573
|
var require_helper = __commonJS({
|
|
574
|
-
"node_modules/@supabase/functions-js/dist/main/helper.js"(exports2) {
|
|
574
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/helper.js"(exports2) {
|
|
575
575
|
"use strict";
|
|
576
576
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
577
577
|
exports2.resolveFetch = void 0;
|
|
@@ -585,9 +585,9 @@ var require_helper = __commonJS({
|
|
|
585
585
|
}
|
|
586
586
|
});
|
|
587
587
|
|
|
588
|
-
// node_modules/@supabase/functions-js/dist/main/types.js
|
|
588
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/types.js
|
|
589
589
|
var require_types = __commonJS({
|
|
590
|
-
"node_modules/@supabase/functions-js/dist/main/types.js"(exports2) {
|
|
590
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/types.js"(exports2) {
|
|
591
591
|
"use strict";
|
|
592
592
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
593
593
|
exports2.FunctionRegion = exports2.FunctionsHttpError = exports2.FunctionsRelayError = exports2.FunctionsFetchError = exports2.FunctionsError = void 0;
|
|
@@ -645,9 +645,9 @@ var require_types = __commonJS({
|
|
|
645
645
|
}
|
|
646
646
|
});
|
|
647
647
|
|
|
648
|
-
// node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
|
|
648
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
|
|
649
649
|
var require_FunctionsClient = __commonJS({
|
|
650
|
-
"node_modules/@supabase/functions-js/dist/main/FunctionsClient.js"(exports2) {
|
|
650
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js"(exports2) {
|
|
651
651
|
"use strict";
|
|
652
652
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
653
653
|
exports2.FunctionsClient = void 0;
|
|
@@ -931,9 +931,9 @@ var require_FunctionsClient = __commonJS({
|
|
|
931
931
|
}
|
|
932
932
|
});
|
|
933
933
|
|
|
934
|
-
// node_modules/@supabase/functions-js/dist/main/index.js
|
|
934
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/index.js
|
|
935
935
|
var require_main = __commonJS({
|
|
936
|
-
"node_modules/@supabase/functions-js/dist/main/index.js"(exports2) {
|
|
936
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/functions-js/dist/main/index.js"(exports2) {
|
|
937
937
|
"use strict";
|
|
938
938
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
939
939
|
exports2.FunctionRegion = exports2.FunctionsRelayError = exports2.FunctionsHttpError = exports2.FunctionsFetchError = exports2.FunctionsError = exports2.FunctionsClient = void 0;
|
|
@@ -960,9 +960,9 @@ var require_main = __commonJS({
|
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
962
|
|
|
963
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
|
|
963
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
|
|
964
964
|
var require_websocket_factory = __commonJS({
|
|
965
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js"(exports2) {
|
|
965
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js"(exports2) {
|
|
966
966
|
"use strict";
|
|
967
967
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
968
968
|
exports2.WebSocketFactory = void 0;
|
|
@@ -1071,9 +1071,9 @@ Suggested solution: ${env.workaround}`;
|
|
|
1071
1071
|
}
|
|
1072
1072
|
});
|
|
1073
1073
|
|
|
1074
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/version.js
|
|
1074
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/version.js
|
|
1075
1075
|
var require_version = __commonJS({
|
|
1076
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/version.js"(exports2) {
|
|
1076
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/version.js"(exports2) {
|
|
1077
1077
|
"use strict";
|
|
1078
1078
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1079
1079
|
exports2.version = void 0;
|
|
@@ -1081,9 +1081,9 @@ var require_version = __commonJS({
|
|
|
1081
1081
|
}
|
|
1082
1082
|
});
|
|
1083
1083
|
|
|
1084
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/constants.js
|
|
1084
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/constants.js
|
|
1085
1085
|
var require_constants = __commonJS({
|
|
1086
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/constants.js"(exports2) {
|
|
1086
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/constants.js"(exports2) {
|
|
1087
1087
|
"use strict";
|
|
1088
1088
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1089
1089
|
exports2.CONNECTION_STATE = exports2.TRANSPORTS = exports2.CHANNEL_EVENTS = exports2.CHANNEL_STATES = exports2.SOCKET_STATES = exports2.MAX_PUSH_BUFFER_SIZE = exports2.WS_CLOSE_NORMAL = exports2.DEFAULT_TIMEOUT = exports2.VERSION = exports2.DEFAULT_VSN = exports2.VSN_2_0_0 = exports2.VSN_1_0_0 = exports2.DEFAULT_VERSION = void 0;
|
|
@@ -1129,9 +1129,9 @@ var require_constants = __commonJS({
|
|
|
1129
1129
|
}
|
|
1130
1130
|
});
|
|
1131
1131
|
|
|
1132
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
|
|
1132
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
|
|
1133
1133
|
var require_serializer = __commonJS({
|
|
1134
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/serializer.js"(exports2) {
|
|
1134
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js"(exports2) {
|
|
1135
1135
|
"use strict";
|
|
1136
1136
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1137
1137
|
var Serializer = class {
|
|
@@ -1283,9 +1283,9 @@ var require_serializer = __commonJS({
|
|
|
1283
1283
|
}
|
|
1284
1284
|
});
|
|
1285
1285
|
|
|
1286
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
|
|
1286
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
|
|
1287
1287
|
var require_transformers = __commonJS({
|
|
1288
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/transformers.js"(exports2) {
|
|
1288
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js"(exports2) {
|
|
1289
1289
|
"use strict";
|
|
1290
1290
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1291
1291
|
exports2.httpEndpointURL = exports2.toTimestampString = exports2.toArray = exports2.toJson = exports2.toNumber = exports2.toBoolean = exports2.convertCell = exports2.convertColumn = exports2.convertChangeData = exports2.PostgresTypes = void 0;
|
|
@@ -1462,9 +1462,9 @@ var require_transformers = __commonJS({
|
|
|
1462
1462
|
}
|
|
1463
1463
|
});
|
|
1464
1464
|
|
|
1465
|
-
// node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
|
|
1465
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
|
|
1466
1466
|
var require_phoenix_cjs = __commonJS({
|
|
1467
|
-
"node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js"(exports2, module2) {
|
|
1467
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js"(exports2, module2) {
|
|
1468
1468
|
"use strict";
|
|
1469
1469
|
var __defProp2 = Object.defineProperty;
|
|
1470
1470
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -3314,9 +3314,9 @@ var require_phoenix_cjs = __commonJS({
|
|
|
3314
3314
|
}
|
|
3315
3315
|
});
|
|
3316
3316
|
|
|
3317
|
-
// node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
|
|
3317
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
|
|
3318
3318
|
var require_presenceAdapter = __commonJS({
|
|
3319
|
-
"node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js"(exports2) {
|
|
3319
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js"(exports2) {
|
|
3320
3320
|
"use strict";
|
|
3321
3321
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3322
3322
|
var phoenix_1 = require_phoenix_cjs();
|
|
@@ -3412,9 +3412,9 @@ var require_presenceAdapter = __commonJS({
|
|
|
3412
3412
|
}
|
|
3413
3413
|
});
|
|
3414
3414
|
|
|
3415
|
-
// node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
|
|
3415
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
|
|
3416
3416
|
var require_RealtimePresence = __commonJS({
|
|
3417
|
-
"node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js"(exports2) {
|
|
3417
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js"(exports2) {
|
|
3418
3418
|
"use strict";
|
|
3419
3419
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3420
3420
|
exports2.REALTIME_PRESENCE_LISTEN_EVENTS = void 0;
|
|
@@ -3456,9 +3456,9 @@ var require_RealtimePresence = __commonJS({
|
|
|
3456
3456
|
}
|
|
3457
3457
|
});
|
|
3458
3458
|
|
|
3459
|
-
// node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js
|
|
3459
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js
|
|
3460
3460
|
var require_normalizeChannelError = __commonJS({
|
|
3461
|
-
"node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js"(exports2) {
|
|
3461
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js"(exports2) {
|
|
3462
3462
|
"use strict";
|
|
3463
3463
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3464
3464
|
exports2.normalizeChannelError = normalizeChannelError;
|
|
@@ -3482,9 +3482,9 @@ var require_normalizeChannelError = __commonJS({
|
|
|
3482
3482
|
}
|
|
3483
3483
|
});
|
|
3484
3484
|
|
|
3485
|
-
// node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
|
|
3485
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
|
|
3486
3486
|
var require_channelAdapter = __commonJS({
|
|
3487
|
-
"node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js"(exports2) {
|
|
3487
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js"(exports2) {
|
|
3488
3488
|
"use strict";
|
|
3489
3489
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3490
3490
|
var constants_1 = require_constants();
|
|
@@ -3589,9 +3589,9 @@ var require_channelAdapter = __commonJS({
|
|
|
3589
3589
|
}
|
|
3590
3590
|
});
|
|
3591
3591
|
|
|
3592
|
-
// node_modules/@supabase/realtime-js/dist/main/RealtimePostgresFilterBuilder.js
|
|
3592
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimePostgresFilterBuilder.js
|
|
3593
3593
|
var require_RealtimePostgresFilterBuilder = __commonJS({
|
|
3594
|
-
"node_modules/@supabase/realtime-js/dist/main/RealtimePostgresFilterBuilder.js"(exports2) {
|
|
3594
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimePostgresFilterBuilder.js"(exports2) {
|
|
3595
3595
|
"use strict";
|
|
3596
3596
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3597
3597
|
exports2.postgresChangesFilter = exports2.RealtimePostgresFilterBuilder = void 0;
|
|
@@ -3713,9 +3713,9 @@ var require_RealtimePostgresFilterBuilder = __commonJS({
|
|
|
3713
3713
|
}
|
|
3714
3714
|
});
|
|
3715
3715
|
|
|
3716
|
-
// node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
|
|
3716
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
|
|
3717
3717
|
var require_RealtimeChannel = __commonJS({
|
|
3718
|
-
"node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js"(exports2) {
|
|
3718
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js"(exports2) {
|
|
3719
3719
|
"use strict";
|
|
3720
3720
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3721
3721
|
exports2.REALTIME_CHANNEL_STATES = exports2.REALTIME_SUBSCRIBE_STATES = exports2.REALTIME_LISTEN_TYPES = exports2.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports2.postgresChangesFilter = exports2.RealtimePostgresFilterBuilder = void 0;
|
|
@@ -4444,9 +4444,9 @@ var require_RealtimeChannel = __commonJS({
|
|
|
4444
4444
|
}
|
|
4445
4445
|
});
|
|
4446
4446
|
|
|
4447
|
-
// node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
|
|
4447
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
|
|
4448
4448
|
var require_socketAdapter = __commonJS({
|
|
4449
|
-
"node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js"(exports2) {
|
|
4449
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js"(exports2) {
|
|
4450
4450
|
"use strict";
|
|
4451
4451
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4452
4452
|
var phoenix_1 = require_phoenix_cjs();
|
|
@@ -4562,9 +4562,9 @@ var require_socketAdapter = __commonJS({
|
|
|
4562
4562
|
}
|
|
4563
4563
|
});
|
|
4564
4564
|
|
|
4565
|
-
// node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
|
|
4565
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
|
|
4566
4566
|
var require_RealtimeClient = __commonJS({
|
|
4567
|
-
"node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js"(exports2) {
|
|
4567
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js"(exports2) {
|
|
4568
4568
|
"use strict";
|
|
4569
4569
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4570
4570
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
@@ -5216,9 +5216,9 @@ var require_RealtimeClient = __commonJS({
|
|
|
5216
5216
|
}
|
|
5217
5217
|
});
|
|
5218
5218
|
|
|
5219
|
-
// node_modules/@supabase/realtime-js/dist/main/index.js
|
|
5219
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/index.js
|
|
5220
5220
|
var require_main2 = __commonJS({
|
|
5221
|
-
"node_modules/@supabase/realtime-js/dist/main/index.js"(exports2) {
|
|
5221
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/realtime-js/dist/main/index.js"(exports2) {
|
|
5222
5222
|
"use strict";
|
|
5223
5223
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5224
5224
|
exports2.WebSocketFactory = exports2.REALTIME_CHANNEL_STATES = exports2.REALTIME_SUBSCRIBE_STATES = exports2.REALTIME_PRESENCE_LISTEN_EVENTS = exports2.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports2.REALTIME_LISTEN_TYPES = exports2.postgresChangesFilter = exports2.RealtimePostgresFilterBuilder = exports2.RealtimeClient = exports2.RealtimeChannel = exports2.RealtimePresence = void 0;
|
|
@@ -5255,9 +5255,9 @@ var require_main2 = __commonJS({
|
|
|
5255
5255
|
}
|
|
5256
5256
|
});
|
|
5257
5257
|
|
|
5258
|
-
// node_modules/@supabase/auth-js/dist/main/lib/version.js
|
|
5258
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/version.js
|
|
5259
5259
|
var require_version2 = __commonJS({
|
|
5260
|
-
"node_modules/@supabase/auth-js/dist/main/lib/version.js"(exports2) {
|
|
5260
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/version.js"(exports2) {
|
|
5261
5261
|
"use strict";
|
|
5262
5262
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5263
5263
|
exports2.version = void 0;
|
|
@@ -5265,9 +5265,9 @@ var require_version2 = __commonJS({
|
|
|
5265
5265
|
}
|
|
5266
5266
|
});
|
|
5267
5267
|
|
|
5268
|
-
// node_modules/@supabase/auth-js/dist/main/lib/constants.js
|
|
5268
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/constants.js
|
|
5269
5269
|
var require_constants2 = __commonJS({
|
|
5270
|
-
"node_modules/@supabase/auth-js/dist/main/lib/constants.js"(exports2) {
|
|
5270
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/constants.js"(exports2) {
|
|
5271
5271
|
"use strict";
|
|
5272
5272
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5273
5273
|
exports2.JWKS_TTL = exports2.BASE64URL_REGEX = exports2.API_VERSIONS = exports2.API_VERSION_HEADER_NAME = exports2.NETWORK_FAILURE = exports2.DEFAULT_HEADERS = exports2.AUDIENCE = exports2.STORAGE_KEY = exports2.GOTRUE_URL = exports2.REFRESH_FAILURE_COOLDOWN_MS = exports2.EXPIRY_MARGIN_MS = exports2.AUTO_REFRESH_TICK_THRESHOLD = exports2.AUTO_REFRESH_TICK_DURATION_MS = void 0;
|
|
@@ -5297,9 +5297,9 @@ var require_constants2 = __commonJS({
|
|
|
5297
5297
|
}
|
|
5298
5298
|
});
|
|
5299
5299
|
|
|
5300
|
-
// node_modules/@supabase/auth-js/dist/main/lib/errors.js
|
|
5300
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/errors.js
|
|
5301
5301
|
var require_errors = __commonJS({
|
|
5302
|
-
"node_modules/@supabase/auth-js/dist/main/lib/errors.js"(exports2) {
|
|
5302
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/errors.js"(exports2) {
|
|
5303
5303
|
"use strict";
|
|
5304
5304
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5305
5305
|
exports2.AuthInvalidJwtError = exports2.AuthWeakPasswordError = exports2.AuthRefreshDiscardedError = exports2.AuthRetryableFetchError = exports2.AuthPKCECodeVerifierMissingError = exports2.AuthPKCEGrantCodeExchangeError = exports2.AuthImplicitGrantRedirectError = exports2.AuthInvalidCredentialsError = exports2.AuthInvalidTokenResponseError = exports2.AuthSessionMissingError = exports2.CustomAuthError = exports2.AuthUnknownError = exports2.AuthApiError = exports2.AuthError = void 0;
|
|
@@ -5455,9 +5455,9 @@ var require_errors = __commonJS({
|
|
|
5455
5455
|
}
|
|
5456
5456
|
});
|
|
5457
5457
|
|
|
5458
|
-
// node_modules/@supabase/auth-js/dist/main/lib/base64url.js
|
|
5458
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/base64url.js
|
|
5459
5459
|
var require_base64url = __commonJS({
|
|
5460
|
-
"node_modules/@supabase/auth-js/dist/main/lib/base64url.js"(exports2) {
|
|
5460
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/base64url.js"(exports2) {
|
|
5461
5461
|
"use strict";
|
|
5462
5462
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5463
5463
|
exports2.byteToBase64URL = byteToBase64URL;
|
|
@@ -5645,9 +5645,9 @@ var require_base64url = __commonJS({
|
|
|
5645
5645
|
}
|
|
5646
5646
|
});
|
|
5647
5647
|
|
|
5648
|
-
// node_modules/@supabase/auth-js/dist/main/lib/helpers.js
|
|
5648
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/helpers.js
|
|
5649
5649
|
var require_helpers = __commonJS({
|
|
5650
|
-
"node_modules/@supabase/auth-js/dist/main/lib/helpers.js"(exports2) {
|
|
5650
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/helpers.js"(exports2) {
|
|
5651
5651
|
"use strict";
|
|
5652
5652
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5653
5653
|
exports2.Deferred = exports2.removeItemAsync = exports2.getItemAsync = exports2.setItemAsync = exports2.looksLikeFetchResponse = exports2.resolveFetch = exports2.supportsLocalStorage = exports2.isBrowser = void 0;
|
|
@@ -5967,9 +5967,9 @@ var require_helpers = __commonJS({
|
|
|
5967
5967
|
}
|
|
5968
5968
|
});
|
|
5969
5969
|
|
|
5970
|
-
// node_modules/@supabase/auth-js/dist/main/lib/fetch.js
|
|
5970
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/fetch.js
|
|
5971
5971
|
var require_fetch = __commonJS({
|
|
5972
|
-
"node_modules/@supabase/auth-js/dist/main/lib/fetch.js"(exports2) {
|
|
5972
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/fetch.js"(exports2) {
|
|
5973
5973
|
"use strict";
|
|
5974
5974
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5975
5975
|
exports2.handleError = handleError2;
|
|
@@ -6151,9 +6151,9 @@ var require_fetch = __commonJS({
|
|
|
6151
6151
|
}
|
|
6152
6152
|
});
|
|
6153
6153
|
|
|
6154
|
-
// node_modules/@supabase/auth-js/dist/main/lib/types.js
|
|
6154
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/types.js
|
|
6155
6155
|
var require_types2 = __commonJS({
|
|
6156
|
-
"node_modules/@supabase/auth-js/dist/main/lib/types.js"(exports2) {
|
|
6156
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/types.js"(exports2) {
|
|
6157
6157
|
"use strict";
|
|
6158
6158
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
6159
6159
|
exports2.SIGN_OUT_SCOPES = void 0;
|
|
@@ -6161,9 +6161,9 @@ var require_types2 = __commonJS({
|
|
|
6161
6161
|
}
|
|
6162
6162
|
});
|
|
6163
6163
|
|
|
6164
|
-
// node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
|
|
6164
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
|
|
6165
6165
|
var require_GoTrueAdminApi = __commonJS({
|
|
6166
|
-
"node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js"(exports2) {
|
|
6166
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js"(exports2) {
|
|
6167
6167
|
"use strict";
|
|
6168
6168
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
6169
6169
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
@@ -7247,9 +7247,9 @@ var require_GoTrueAdminApi = __commonJS({
|
|
|
7247
7247
|
}
|
|
7248
7248
|
});
|
|
7249
7249
|
|
|
7250
|
-
// node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
|
|
7250
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
|
|
7251
7251
|
var require_local_storage = __commonJS({
|
|
7252
|
-
"node_modules/@supabase/auth-js/dist/main/lib/local-storage.js"(exports2) {
|
|
7252
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js"(exports2) {
|
|
7253
7253
|
"use strict";
|
|
7254
7254
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7255
7255
|
exports2.memoryLocalStorageAdapter = memoryLocalStorageAdapter;
|
|
@@ -7269,9 +7269,9 @@ var require_local_storage = __commonJS({
|
|
|
7269
7269
|
}
|
|
7270
7270
|
});
|
|
7271
7271
|
|
|
7272
|
-
// node_modules/@supabase/auth-js/dist/main/lib/locks.js
|
|
7272
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/locks.js
|
|
7273
7273
|
var require_locks = __commonJS({
|
|
7274
|
-
"node_modules/@supabase/auth-js/dist/main/lib/locks.js"(exports2) {
|
|
7274
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/locks.js"(exports2) {
|
|
7275
7275
|
"use strict";
|
|
7276
7276
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7277
7277
|
exports2.ProcessLockAcquireTimeoutError = exports2.NavigatorLockAcquireTimeoutError = exports2.LockAcquireTimeoutError = exports2.internals = void 0;
|
|
@@ -7447,9 +7447,9 @@ var require_locks = __commonJS({
|
|
|
7447
7447
|
}
|
|
7448
7448
|
});
|
|
7449
7449
|
|
|
7450
|
-
// node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
|
|
7450
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
|
|
7451
7451
|
var require_polyfills = __commonJS({
|
|
7452
|
-
"node_modules/@supabase/auth-js/dist/main/lib/polyfills.js"(exports2) {
|
|
7452
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js"(exports2) {
|
|
7453
7453
|
"use strict";
|
|
7454
7454
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7455
7455
|
exports2.polyfillGlobalThis = polyfillGlobalThis;
|
|
@@ -7474,9 +7474,9 @@ var require_polyfills = __commonJS({
|
|
|
7474
7474
|
}
|
|
7475
7475
|
});
|
|
7476
7476
|
|
|
7477
|
-
// node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
|
|
7477
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
|
|
7478
7478
|
var require_ethereum = __commonJS({
|
|
7479
|
-
"node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js"(exports2) {
|
|
7479
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js"(exports2) {
|
|
7480
7480
|
"use strict";
|
|
7481
7481
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7482
7482
|
exports2.getAddress = getAddress;
|
|
@@ -7552,9 +7552,9 @@ ${suffix}`;
|
|
|
7552
7552
|
}
|
|
7553
7553
|
});
|
|
7554
7554
|
|
|
7555
|
-
// node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
|
|
7555
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
|
|
7556
7556
|
var require_webauthn_errors = __commonJS({
|
|
7557
|
-
"node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js"(exports2) {
|
|
7557
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js"(exports2) {
|
|
7558
7558
|
"use strict";
|
|
7559
7559
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7560
7560
|
exports2.WebAuthnUnknownError = exports2.WebAuthnError = void 0;
|
|
@@ -7743,9 +7743,9 @@ var require_webauthn_errors = __commonJS({
|
|
|
7743
7743
|
}
|
|
7744
7744
|
});
|
|
7745
7745
|
|
|
7746
|
-
// node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
|
|
7746
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
|
|
7747
7747
|
var require_webauthn = __commonJS({
|
|
7748
|
-
"node_modules/@supabase/auth-js/dist/main/lib/webauthn.js"(exports2) {
|
|
7748
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js"(exports2) {
|
|
7749
7749
|
"use strict";
|
|
7750
7750
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7751
7751
|
exports2.WebAuthnApi = exports2.DEFAULT_REQUEST_OPTIONS = exports2.DEFAULT_CREATION_OPTIONS = exports2.webAuthnAbortService = exports2.WebAuthnAbortService = exports2.identifyAuthenticationError = exports2.identifyRegistrationError = exports2.isWebAuthnError = exports2.WebAuthnError = void 0;
|
|
@@ -8302,9 +8302,9 @@ var require_webauthn = __commonJS({
|
|
|
8302
8302
|
}
|
|
8303
8303
|
});
|
|
8304
8304
|
|
|
8305
|
-
// node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
|
|
8305
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
|
|
8306
8306
|
var require_GoTrueClient = __commonJS({
|
|
8307
|
-
"node_modules/@supabase/auth-js/dist/main/GoTrueClient.js"(exports2) {
|
|
8307
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js"(exports2) {
|
|
8308
8308
|
"use strict";
|
|
8309
8309
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8310
8310
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
@@ -13442,9 +13442,9 @@ var require_GoTrueClient = __commonJS({
|
|
|
13442
13442
|
}
|
|
13443
13443
|
});
|
|
13444
13444
|
|
|
13445
|
-
// node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
|
|
13445
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
|
|
13446
13446
|
var require_AuthAdminApi = __commonJS({
|
|
13447
|
-
"node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js"(exports2) {
|
|
13447
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js"(exports2) {
|
|
13448
13448
|
"use strict";
|
|
13449
13449
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13450
13450
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
@@ -13454,9 +13454,9 @@ var require_AuthAdminApi = __commonJS({
|
|
|
13454
13454
|
}
|
|
13455
13455
|
});
|
|
13456
13456
|
|
|
13457
|
-
// node_modules/@supabase/auth-js/dist/main/AuthClient.js
|
|
13457
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/AuthClient.js
|
|
13458
13458
|
var require_AuthClient = __commonJS({
|
|
13459
|
-
"node_modules/@supabase/auth-js/dist/main/AuthClient.js"(exports2) {
|
|
13459
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/AuthClient.js"(exports2) {
|
|
13460
13460
|
"use strict";
|
|
13461
13461
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13462
13462
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
@@ -13466,9 +13466,9 @@ var require_AuthClient = __commonJS({
|
|
|
13466
13466
|
}
|
|
13467
13467
|
});
|
|
13468
13468
|
|
|
13469
|
-
// node_modules/@supabase/auth-js/dist/main/index.js
|
|
13469
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/index.js
|
|
13470
13470
|
var require_main3 = __commonJS({
|
|
13471
|
-
"node_modules/@supabase/auth-js/dist/main/index.js"(exports2) {
|
|
13471
|
+
"../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/auth-js/dist/main/index.js"(exports2) {
|
|
13472
13472
|
"use strict";
|
|
13473
13473
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13474
13474
|
exports2.processLock = exports2.lockInternals = exports2.NavigatorLockAcquireTimeoutError = exports2.navigatorLock = exports2.AuthClient = exports2.AuthAdminApi = exports2.GoTrueClient = exports2.GoTrueAdminApi = void 0;
|
|
@@ -13535,7 +13535,7 @@ var import_node_crypto2 = require("node:crypto");
|
|
|
13535
13535
|
var import_node_http = require("node:http");
|
|
13536
13536
|
var import_node_child_process = require("node:child_process");
|
|
13537
13537
|
|
|
13538
|
-
// node_modules/@supabase/supabase-js/dist/index.mjs
|
|
13538
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/supabase-js/dist/index.mjs
|
|
13539
13539
|
var dist_exports = {};
|
|
13540
13540
|
__export(dist_exports, {
|
|
13541
13541
|
FunctionRegion: () => import_functions_js.FunctionRegion,
|
|
@@ -13550,7 +13550,7 @@ __export(dist_exports, {
|
|
|
13550
13550
|
});
|
|
13551
13551
|
var import_functions_js = __toESM(require_main(), 1);
|
|
13552
13552
|
|
|
13553
|
-
// node_modules/@supabase/postgrest-js/dist/index.mjs
|
|
13553
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/postgrest-js/dist/index.mjs
|
|
13554
13554
|
var DEFAULT_MAX_RETRIES = 3;
|
|
13555
13555
|
var getRetryDelay = (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 3e4);
|
|
13556
13556
|
var RETRYABLE_STATUS_CODES = [520, 503];
|
|
@@ -17328,10 +17328,10 @@ var PostgrestClient = class PostgrestClient2 {
|
|
|
17328
17328
|
}
|
|
17329
17329
|
};
|
|
17330
17330
|
|
|
17331
|
-
// node_modules/@supabase/supabase-js/dist/index.mjs
|
|
17331
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/supabase-js/dist/index.mjs
|
|
17332
17332
|
var import_realtime_js = __toESM(require_main2(), 1);
|
|
17333
17333
|
|
|
17334
|
-
// node_modules/iceberg-js/dist/index.mjs
|
|
17334
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/iceberg-js/dist/index.mjs
|
|
17335
17335
|
var IcebergError = class extends Error {
|
|
17336
17336
|
constructor(message, opts) {
|
|
17337
17337
|
super(message);
|
|
@@ -17864,7 +17864,7 @@ var IcebergRestCatalog = class {
|
|
|
17864
17864
|
}
|
|
17865
17865
|
};
|
|
17866
17866
|
|
|
17867
|
-
// node_modules/@supabase/storage-js/dist/index.mjs
|
|
17867
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/storage-js/dist/index.mjs
|
|
17868
17868
|
function _typeof2(o) {
|
|
17869
17869
|
"@babel/helpers - typeof";
|
|
17870
17870
|
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
@@ -20656,7 +20656,7 @@ var StorageClient = class extends StorageBucketApi {
|
|
|
20656
20656
|
}
|
|
20657
20657
|
};
|
|
20658
20658
|
|
|
20659
|
-
// node_modules/@supabase/supabase-js/dist/index.mjs
|
|
20659
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/@supabase/supabase-js/dist/index.mjs
|
|
20660
20660
|
var import_auth_js = __toESM(require_main3(), 1);
|
|
20661
20661
|
__reExport(dist_exports, __toESM(require_main2(), 1));
|
|
20662
20662
|
__reExport(dist_exports, __toESM(require_main3(), 1));
|
|
@@ -24061,11 +24061,11 @@ async function resolveCloudTarget(options) {
|
|
|
24061
24061
|
// src/cloud/seed.ts
|
|
24062
24062
|
var import_node_crypto7 = require("node:crypto");
|
|
24063
24063
|
|
|
24064
|
-
// node_modules/postgres/src/index.js
|
|
24064
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/index.js
|
|
24065
24065
|
var import_os = __toESM(require("os"), 1);
|
|
24066
24066
|
var import_fs = __toESM(require("fs"), 1);
|
|
24067
24067
|
|
|
24068
|
-
// node_modules/postgres/src/query.js
|
|
24068
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/query.js
|
|
24069
24069
|
var originCache = /* @__PURE__ */ new Map();
|
|
24070
24070
|
var originStackCache = /* @__PURE__ */ new Map();
|
|
24071
24071
|
var originError = /* @__PURE__ */ Symbol("OriginError");
|
|
@@ -24202,7 +24202,7 @@ function cachedError(xs) {
|
|
|
24202
24202
|
return originCache.get(xs);
|
|
24203
24203
|
}
|
|
24204
24204
|
|
|
24205
|
-
// node_modules/postgres/src/errors.js
|
|
24205
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/errors.js
|
|
24206
24206
|
var PostgresError = class extends Error {
|
|
24207
24207
|
constructor(x) {
|
|
24208
24208
|
super(x.message);
|
|
@@ -24252,7 +24252,7 @@ function notSupported(x) {
|
|
|
24252
24252
|
return error;
|
|
24253
24253
|
}
|
|
24254
24254
|
|
|
24255
|
-
// node_modules/postgres/src/types.js
|
|
24255
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/types.js
|
|
24256
24256
|
var types = {
|
|
24257
24257
|
string: {
|
|
24258
24258
|
to: 25,
|
|
@@ -24538,14 +24538,14 @@ fromKebab.column = { to: fromKebab };
|
|
|
24538
24538
|
var kebab = { ...toKebab };
|
|
24539
24539
|
kebab.column.to = fromKebab;
|
|
24540
24540
|
|
|
24541
|
-
// node_modules/postgres/src/connection.js
|
|
24541
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/connection.js
|
|
24542
24542
|
var import_net = __toESM(require("net"), 1);
|
|
24543
24543
|
var import_tls = __toESM(require("tls"), 1);
|
|
24544
24544
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
24545
24545
|
var import_stream = __toESM(require("stream"), 1);
|
|
24546
24546
|
var import_perf_hooks = require("perf_hooks");
|
|
24547
24547
|
|
|
24548
|
-
// node_modules/postgres/src/result.js
|
|
24548
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/result.js
|
|
24549
24549
|
var Result = class extends Array {
|
|
24550
24550
|
constructor() {
|
|
24551
24551
|
super();
|
|
@@ -24562,7 +24562,7 @@ var Result = class extends Array {
|
|
|
24562
24562
|
}
|
|
24563
24563
|
};
|
|
24564
24564
|
|
|
24565
|
-
// node_modules/postgres/src/queue.js
|
|
24565
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/queue.js
|
|
24566
24566
|
var queue_default = Queue;
|
|
24567
24567
|
function Queue(initial = []) {
|
|
24568
24568
|
let xs = initial.slice();
|
|
@@ -24589,7 +24589,7 @@ function Queue(initial = []) {
|
|
|
24589
24589
|
};
|
|
24590
24590
|
}
|
|
24591
24591
|
|
|
24592
|
-
// node_modules/postgres/src/bytes.js
|
|
24592
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/bytes.js
|
|
24593
24593
|
var size = 256;
|
|
24594
24594
|
var buffer = Buffer.allocUnsafe(size);
|
|
24595
24595
|
var messages = "BCcDdEFfHPpQSX".split("").reduce((acc, x) => {
|
|
@@ -24662,7 +24662,7 @@ function reset() {
|
|
|
24662
24662
|
return b;
|
|
24663
24663
|
}
|
|
24664
24664
|
|
|
24665
|
-
// node_modules/postgres/src/connection.js
|
|
24665
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/connection.js
|
|
24666
24666
|
var connection_default = Connection;
|
|
24667
24667
|
var uid = 1;
|
|
24668
24668
|
var Sync = bytes_default().S().end();
|
|
@@ -25502,7 +25502,7 @@ function timer(fn, seconds) {
|
|
|
25502
25502
|
}
|
|
25503
25503
|
}
|
|
25504
25504
|
|
|
25505
|
-
// node_modules/postgres/src/subscribe.js
|
|
25505
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/subscribe.js
|
|
25506
25506
|
var noop2 = () => {
|
|
25507
25507
|
};
|
|
25508
25508
|
function Subscribe(postgres2, options) {
|
|
@@ -25714,7 +25714,7 @@ function parseEvent(x) {
|
|
|
25714
25714
|
return (command2 || "*") + (path ? ":" + (path.indexOf(".") === -1 ? "public." + path : path) : "") + (key2 ? "=" + key2 : "");
|
|
25715
25715
|
}
|
|
25716
25716
|
|
|
25717
|
-
// node_modules/postgres/src/large.js
|
|
25717
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/large.js
|
|
25718
25718
|
var import_stream2 = __toESM(require("stream"), 1);
|
|
25719
25719
|
function largeObject(sql, oid, mode3 = 131072 | 262144) {
|
|
25720
25720
|
return new Promise(async (resolve3, reject) => {
|
|
@@ -25780,7 +25780,7 @@ function largeObject(sql, oid, mode3 = 131072 | 262144) {
|
|
|
25780
25780
|
});
|
|
25781
25781
|
}
|
|
25782
25782
|
|
|
25783
|
-
// node_modules/postgres/src/index.js
|
|
25783
|
+
// ../../../../../../../Users/yulanbot/Developer/Ridge.io/cloud-swarm/node_modules/postgres/src/index.js
|
|
25784
25784
|
Object.assign(Postgres, {
|
|
25785
25785
|
PostgresError,
|
|
25786
25786
|
toPascal,
|
|
@@ -26624,6 +26624,138 @@ function parseAgentCredentialInput(value, source) {
|
|
|
26624
26624
|
|
|
26625
26625
|
// src/cloud/renewal.ts
|
|
26626
26626
|
var import_node_crypto9 = require("node:crypto");
|
|
26627
|
+
|
|
26628
|
+
// src/cloud/renewal-grants.ts
|
|
26629
|
+
var UUID_RE5 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
26630
|
+
function nullableString(value, field) {
|
|
26631
|
+
if (value === null) return null;
|
|
26632
|
+
if (typeof value !== "string") {
|
|
26633
|
+
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
26634
|
+
}
|
|
26635
|
+
return value;
|
|
26636
|
+
}
|
|
26637
|
+
function nullableTimestamp(value, field) {
|
|
26638
|
+
const text = nullableString(value, field);
|
|
26639
|
+
if (text !== null && !Number.isFinite(Date.parse(text))) {
|
|
26640
|
+
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
26641
|
+
}
|
|
26642
|
+
return text;
|
|
26643
|
+
}
|
|
26644
|
+
function uuid2(value, field) {
|
|
26645
|
+
if (typeof value !== "string" || !UUID_RE5.test(value)) {
|
|
26646
|
+
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
26647
|
+
}
|
|
26648
|
+
return value.toLowerCase();
|
|
26649
|
+
}
|
|
26650
|
+
function nullableUuid(value, field) {
|
|
26651
|
+
return value === null ? null : uuid2(value, field);
|
|
26652
|
+
}
|
|
26653
|
+
function parseGrant(value) {
|
|
26654
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
26655
|
+
throw new Error("renewal grant read returned a malformed row");
|
|
26656
|
+
}
|
|
26657
|
+
const row = value;
|
|
26658
|
+
if (row.kind !== "timeboxed" && row.kind !== "standing") {
|
|
26659
|
+
throw new Error("renewal grant read returned malformed kind");
|
|
26660
|
+
}
|
|
26661
|
+
const horizon = nullableTimestamp(
|
|
26662
|
+
row.horizon_expires_at,
|
|
26663
|
+
"horizon_expires_at"
|
|
26664
|
+
);
|
|
26665
|
+
if (row.kind === "standing" && horizon !== null || row.kind === "timeboxed" && horizon === null) {
|
|
26666
|
+
throw new Error("renewal grant read returned an invalid kind/horizon pair");
|
|
26667
|
+
}
|
|
26668
|
+
return {
|
|
26669
|
+
renewal_grant_id: uuid2(row.renewal_grant_id, "renewal_grant_id"),
|
|
26670
|
+
principal_id: uuid2(row.principal_id, "principal_id"),
|
|
26671
|
+
kind: row.kind,
|
|
26672
|
+
horizon_expires_at: horizon,
|
|
26673
|
+
bound_device_id: nullableUuid(row.bound_device_id, "bound_device_id"),
|
|
26674
|
+
last_used_at: nullableTimestamp(row.last_used_at, "last_used_at"),
|
|
26675
|
+
last_used_device_id: nullableUuid(
|
|
26676
|
+
row.last_used_device_id,
|
|
26677
|
+
"last_used_device_id"
|
|
26678
|
+
),
|
|
26679
|
+
last_used_from: nullableString(row.last_used_from, "last_used_from"),
|
|
26680
|
+
new_host_at: nullableTimestamp(row.new_host_at, "new_host_at"),
|
|
26681
|
+
suspended_at: nullableTimestamp(row.suspended_at, "suspended_at"),
|
|
26682
|
+
revoked_at: nullableTimestamp(row.revoked_at, "revoked_at"),
|
|
26683
|
+
token_id: nullableUuid(row.token_id, "token_id"),
|
|
26684
|
+
issued_at: nullableTimestamp(row.issued_at, "issued_at"),
|
|
26685
|
+
token_expires_at: nullableTimestamp(
|
|
26686
|
+
row.token_expires_at,
|
|
26687
|
+
"token_expires_at"
|
|
26688
|
+
),
|
|
26689
|
+
token_revoked_at: nullableTimestamp(
|
|
26690
|
+
row.token_revoked_at,
|
|
26691
|
+
"token_revoked_at"
|
|
26692
|
+
)
|
|
26693
|
+
};
|
|
26694
|
+
}
|
|
26695
|
+
async function readRenewalGrants(target2, credential, workspaceId2, fetcher = fetch) {
|
|
26696
|
+
const response = await fetcher(readEndpoint(target2), {
|
|
26697
|
+
method: "POST",
|
|
26698
|
+
headers: {
|
|
26699
|
+
authorization: `Bearer ${credential}`,
|
|
26700
|
+
apikey: target2.anonKey,
|
|
26701
|
+
"content-type": "application/json"
|
|
26702
|
+
},
|
|
26703
|
+
body: JSON.stringify({
|
|
26704
|
+
resource: "renewal_grants",
|
|
26705
|
+
workspace_id: workspaceId2
|
|
26706
|
+
}),
|
|
26707
|
+
signal: AbortSignal.timeout(15e3)
|
|
26708
|
+
});
|
|
26709
|
+
if (!response.ok) {
|
|
26710
|
+
throw new Error(`renewal grant read failed (HTTP ${response.status})`);
|
|
26711
|
+
}
|
|
26712
|
+
const body = await response.json().catch(() => null);
|
|
26713
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
26714
|
+
throw new Error("renewal grant read returned malformed JSON");
|
|
26715
|
+
}
|
|
26716
|
+
const grants = body.grants;
|
|
26717
|
+
if (!Array.isArray(grants)) {
|
|
26718
|
+
throw new Error("renewal grant read returned no grants array");
|
|
26719
|
+
}
|
|
26720
|
+
return grants.map(parseGrant);
|
|
26721
|
+
}
|
|
26722
|
+
var STANDING_IDLE_PAUSE_DAYS = 14;
|
|
26723
|
+
var STANDING_RESUME_ACTORS = [
|
|
26724
|
+
"a workspace owner",
|
|
26725
|
+
"an admin",
|
|
26726
|
+
"the member who added the agent"
|
|
26727
|
+
];
|
|
26728
|
+
function orList(items) {
|
|
26729
|
+
if (items.length === 0) return "";
|
|
26730
|
+
if (items.length === 1) return items[0];
|
|
26731
|
+
return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
|
|
26732
|
+
}
|
|
26733
|
+
var STANDING_RESUME_ACTORS_SENTENCE = orList(STANDING_RESUME_ACTORS);
|
|
26734
|
+
var STANDING_GRANT_RULES = [
|
|
26735
|
+
"Access does not expire.",
|
|
26736
|
+
`${STANDING_IDLE_PAUSE_DAYS} days with no use pauses it; ${STANDING_RESUME_ACTORS_SENTENCE} can resume it.`,
|
|
26737
|
+
"Revoking it is the only permanent stop."
|
|
26738
|
+
];
|
|
26739
|
+
function standingPausedRenewalMessage(idle) {
|
|
26740
|
+
const cause = idle ? `This standing grant went ${STANDING_IDLE_PAUSE_DAYS} days with no use, so CommonSwarm paused it and refused renewal.` : "This renewal grant is paused, so CommonSwarm refused renewal.";
|
|
26741
|
+
return `${cause} It is not revoked and this agent is not gone. Next step: ${STANDING_RESUME_ACTORS_SENTENCE} runs cswarm grant resume, then this agent continues.`;
|
|
26742
|
+
}
|
|
26743
|
+
function describeRenewalGrant(grant) {
|
|
26744
|
+
const lines = grant.kind === "standing" ? [`Grant: standing \u2014 ${STANDING_GRANT_RULES.join(" ")}`] : [`Grant: timeboxed \u2014 renewal horizon ${grant.horizon_expires_at}.`];
|
|
26745
|
+
if (grant.suspended_at !== null) {
|
|
26746
|
+
lines.push(
|
|
26747
|
+
`PAUSED since ${grant.suspended_at} after ${STANDING_IDLE_PAUSE_DAYS} days with no use. This is not revoked and the agent is not gone. Next step: ${orList(STANDING_RESUME_ACTORS)} runs cswarm grant resume --renewal-grant-id ${grant.renewal_grant_id}`
|
|
26748
|
+
);
|
|
26749
|
+
}
|
|
26750
|
+
if (grant.revoked_at !== null) {
|
|
26751
|
+
lines.push(
|
|
26752
|
+
`REVOKED since ${grant.revoked_at}. This is permanent and cannot be resumed. Next step: mint a new grant if this agent should continue.`
|
|
26753
|
+
);
|
|
26754
|
+
}
|
|
26755
|
+
return lines;
|
|
26756
|
+
}
|
|
26757
|
+
|
|
26758
|
+
// src/cloud/renewal.ts
|
|
26627
26759
|
var AGENT_TOKEN_DEFAULT_TTL_MS2 = 60 * 60 * 1e3;
|
|
26628
26760
|
var AGENT_TOKEN_MAX_TTL_MS2 = 8 * 60 * 60 * 1e3;
|
|
26629
26761
|
var RENEWAL_HORIZON_DEFAULT_MS2 = 30 * 24 * 60 * 60 * 1e3;
|
|
@@ -26633,7 +26765,8 @@ function describeMintRenewal(hasExpiry, horizonDays, kind = "timeboxed") {
|
|
|
26633
26765
|
return "This credential does not renew itself; re-issue one by hand when it expires.\n";
|
|
26634
26766
|
}
|
|
26635
26767
|
if (kind === "standing") {
|
|
26636
|
-
return
|
|
26768
|
+
return `Standing grant created. ${STANDING_GRANT_RULES.join(" ")} The bearer credential still rotates before expiry while a cswarm process remains running and secure local state is available.
|
|
26769
|
+
`;
|
|
26637
26770
|
}
|
|
26638
26771
|
const days = Number.isFinite(horizonDays) && horizonDays > 0 ? Math.round(horizonDays) : Math.round(RENEWAL_HORIZON_DEFAULT_MS2 / 864e5);
|
|
26639
26772
|
return `While a cswarm process remains running and secure local state is available, this credential rotates before expiry. A person is asked to authorise it again in ${days} days. A stopped or idle CLI cannot renew it.
|
|
@@ -26644,7 +26777,7 @@ var RENEWAL_LEAD_FLOOR_MS = 5 * 6e4;
|
|
|
26644
26777
|
var RENEWAL_LEAD_CEILING_MS = 15 * 6e4;
|
|
26645
26778
|
var RENEWAL_PENDING_RECOVERY_MS = 60 * 6e4;
|
|
26646
26779
|
var RENEW_TIMEOUT_MS = 3e4;
|
|
26647
|
-
var
|
|
26780
|
+
var UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
26648
26781
|
var AGENT_TOKEN_RE4 = /^swm_agt_[A-Za-z0-9_-]{43}$/;
|
|
26649
26782
|
function renewalDueAt(issuedAt, expiresAt) {
|
|
26650
26783
|
const lifetime = Math.max(0, expiresAt - issuedAt);
|
|
@@ -26803,7 +26936,7 @@ async function requestSuccessor(options) {
|
|
|
26803
26936
|
} catch {
|
|
26804
26937
|
body = {};
|
|
26805
26938
|
}
|
|
26806
|
-
const principalId = typeof body.principal_id === "string" &&
|
|
26939
|
+
const principalId = typeof body.principal_id === "string" && UUID_RE6.test(body.principal_id) ? body.principal_id.toLowerCase() : null;
|
|
26807
26940
|
if (response.status === 400 || response.status === 404) {
|
|
26808
26941
|
throw new RenewalUnsupported(
|
|
26809
26942
|
"this deployment does not offer credential renewal yet, so a credential here still has to be re-issued by hand when it expires"
|
|
@@ -26838,7 +26971,7 @@ async function requestSuccessor(options) {
|
|
|
26838
26971
|
if (reason === "renewal_idle_suspended" || reason === "renewal_grant_suspended") {
|
|
26839
26972
|
throw new RenewalSuspended(
|
|
26840
26973
|
reason,
|
|
26841
|
-
reason === "renewal_idle_suspended"
|
|
26974
|
+
standingPausedRenewalMessage(reason === "renewal_idle_suspended")
|
|
26842
26975
|
);
|
|
26843
26976
|
}
|
|
26844
26977
|
if (reason === "renewal_horizon_reached") {
|
|
@@ -26900,7 +27033,7 @@ async function requestSuccessor(options) {
|
|
|
26900
27033
|
}
|
|
26901
27034
|
const tokenId = typeof body.token_id === "string" ? body.token_id : "";
|
|
26902
27035
|
const runId = typeof body.run_id === "string" ? body.run_id : "";
|
|
26903
|
-
if (!
|
|
27036
|
+
if (!UUID_RE6.test(tokenId) || !UUID_RE6.test(runId) || principalId === null) {
|
|
26904
27037
|
throw new RenewalRefused(
|
|
26905
27038
|
response.status,
|
|
26906
27039
|
"incomplete_successor",
|
|
@@ -27409,7 +27542,7 @@ var MAX_LINK_PAYLOAD_BYTES = 8 * 1024;
|
|
|
27409
27542
|
var MAX_LABEL_INPUT_LENGTH = 1024;
|
|
27410
27543
|
var CONTROL_GLOBAL_RE = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
|
|
27411
27544
|
var ANSI_ESCAPE_GLOBAL_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
|
|
27412
|
-
var
|
|
27545
|
+
var UUID_RE7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
27413
27546
|
var STRICT_BASE64URL_RE = /^[A-Za-z0-9_-]+$/;
|
|
27414
27547
|
var RAW_BASE64_PAYLOAD_CANDIDATE_RE = /^[A-Za-z0-9+/_=-]+$/;
|
|
27415
27548
|
var CURRENT_INVITE_SCHEME = "cswarm://accept/";
|
|
@@ -27460,7 +27593,7 @@ function validatedPayload(value) {
|
|
|
27460
27593
|
throw new Error("invite link target is malformed");
|
|
27461
27594
|
}
|
|
27462
27595
|
cloudTarget(value.url, value.anon_key);
|
|
27463
|
-
if (typeof value.workspace_id !== "string" || !
|
|
27596
|
+
if (typeof value.workspace_id !== "string" || !UUID_RE7.test(value.workspace_id)) {
|
|
27464
27597
|
throw new Error("invite link workspace_id must be a UUID");
|
|
27465
27598
|
}
|
|
27466
27599
|
if (typeof value.invitation_token !== "string") {
|
|
@@ -27470,7 +27603,7 @@ function validatedPayload(value) {
|
|
|
27470
27603
|
if (typeof value.workspace_name !== "string" || typeof value.inviter_display_name !== "string" || value.workspace_name.length > MAX_LABEL_INPUT_LENGTH || value.inviter_display_name.length > MAX_LABEL_INPUT_LENGTH) {
|
|
27471
27604
|
throw new Error("invite link display labels are malformed");
|
|
27472
27605
|
}
|
|
27473
|
-
if (value.inviter_user_id !== void 0 && (typeof value.inviter_user_id !== "string" || !
|
|
27606
|
+
if (value.inviter_user_id !== void 0 && (typeof value.inviter_user_id !== "string" || !UUID_RE7.test(value.inviter_user_id))) {
|
|
27474
27607
|
throw new Error("invite link inviter_user_id must be a UUID");
|
|
27475
27608
|
}
|
|
27476
27609
|
return value;
|
|
@@ -27670,7 +27803,7 @@ function acceptedResponse(result) {
|
|
|
27670
27803
|
}
|
|
27671
27804
|
return result.response;
|
|
27672
27805
|
}
|
|
27673
|
-
function
|
|
27806
|
+
function uuid3(value, field) {
|
|
27674
27807
|
if (typeof value !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) {
|
|
27675
27808
|
throw new Error(`server returned a malformed ${field}`);
|
|
27676
27809
|
}
|
|
@@ -28014,7 +28147,7 @@ function cloudAcceptOperations(target2, store2, fetcher = fetch) {
|
|
|
28014
28147
|
);
|
|
28015
28148
|
return {
|
|
28016
28149
|
status: "accepted",
|
|
28017
|
-
workspaceId:
|
|
28150
|
+
workspaceId: uuid3(response.workspace_id, "workspace_id")
|
|
28018
28151
|
};
|
|
28019
28152
|
} catch (error) {
|
|
28020
28153
|
if (error instanceof CommandHttpError && error.status === 403) {
|
|
@@ -28033,7 +28166,7 @@ function cloudAcceptOperations(target2, store2, fetcher = fetch) {
|
|
|
28033
28166
|
if (result.response.status === "accepted") {
|
|
28034
28167
|
return {
|
|
28035
28168
|
status: "accepted",
|
|
28036
|
-
principalId:
|
|
28169
|
+
principalId: uuid3(result.response.principal_id, "principal_id")
|
|
28037
28170
|
};
|
|
28038
28171
|
}
|
|
28039
28172
|
if (String(result.response.reason) === "principal_name_taken") {
|
|
@@ -28127,113 +28260,6 @@ function renderCapabilityRevoke(capabilityId, revokedAt) {
|
|
|
28127
28260
|
return `Capability link ${capabilityId} was revoked at ${revokedAt}. Anyone who still holds it now gets the same answer as someone holding a link that never existed. Links you have not revoked are unaffected.`;
|
|
28128
28261
|
}
|
|
28129
28262
|
|
|
28130
|
-
// src/cloud/renewal-grants.ts
|
|
28131
|
-
var UUID_RE7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
28132
|
-
function nullableString(value, field) {
|
|
28133
|
-
if (value === null) return null;
|
|
28134
|
-
if (typeof value !== "string") {
|
|
28135
|
-
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
28136
|
-
}
|
|
28137
|
-
return value;
|
|
28138
|
-
}
|
|
28139
|
-
function nullableTimestamp(value, field) {
|
|
28140
|
-
const text = nullableString(value, field);
|
|
28141
|
-
if (text !== null && !Number.isFinite(Date.parse(text))) {
|
|
28142
|
-
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
28143
|
-
}
|
|
28144
|
-
return text;
|
|
28145
|
-
}
|
|
28146
|
-
function uuid3(value, field) {
|
|
28147
|
-
if (typeof value !== "string" || !UUID_RE7.test(value)) {
|
|
28148
|
-
throw new Error(`renewal grant read returned malformed ${field}`);
|
|
28149
|
-
}
|
|
28150
|
-
return value.toLowerCase();
|
|
28151
|
-
}
|
|
28152
|
-
function nullableUuid(value, field) {
|
|
28153
|
-
return value === null ? null : uuid3(value, field);
|
|
28154
|
-
}
|
|
28155
|
-
function parseGrant(value) {
|
|
28156
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
28157
|
-
throw new Error("renewal grant read returned a malformed row");
|
|
28158
|
-
}
|
|
28159
|
-
const row = value;
|
|
28160
|
-
if (row.kind !== "timeboxed" && row.kind !== "standing") {
|
|
28161
|
-
throw new Error("renewal grant read returned malformed kind");
|
|
28162
|
-
}
|
|
28163
|
-
const horizon = nullableTimestamp(
|
|
28164
|
-
row.horizon_expires_at,
|
|
28165
|
-
"horizon_expires_at"
|
|
28166
|
-
);
|
|
28167
|
-
if (row.kind === "standing" && horizon !== null || row.kind === "timeboxed" && horizon === null) {
|
|
28168
|
-
throw new Error("renewal grant read returned an invalid kind/horizon pair");
|
|
28169
|
-
}
|
|
28170
|
-
return {
|
|
28171
|
-
renewal_grant_id: uuid3(row.renewal_grant_id, "renewal_grant_id"),
|
|
28172
|
-
principal_id: uuid3(row.principal_id, "principal_id"),
|
|
28173
|
-
kind: row.kind,
|
|
28174
|
-
horizon_expires_at: horizon,
|
|
28175
|
-
bound_device_id: nullableUuid(row.bound_device_id, "bound_device_id"),
|
|
28176
|
-
last_used_at: nullableTimestamp(row.last_used_at, "last_used_at"),
|
|
28177
|
-
last_used_device_id: nullableUuid(
|
|
28178
|
-
row.last_used_device_id,
|
|
28179
|
-
"last_used_device_id"
|
|
28180
|
-
),
|
|
28181
|
-
last_used_from: nullableString(row.last_used_from, "last_used_from"),
|
|
28182
|
-
new_host_at: nullableTimestamp(row.new_host_at, "new_host_at"),
|
|
28183
|
-
suspended_at: nullableTimestamp(row.suspended_at, "suspended_at"),
|
|
28184
|
-
revoked_at: nullableTimestamp(row.revoked_at, "revoked_at"),
|
|
28185
|
-
token_id: nullableUuid(row.token_id, "token_id"),
|
|
28186
|
-
issued_at: nullableTimestamp(row.issued_at, "issued_at"),
|
|
28187
|
-
token_expires_at: nullableTimestamp(
|
|
28188
|
-
row.token_expires_at,
|
|
28189
|
-
"token_expires_at"
|
|
28190
|
-
),
|
|
28191
|
-
token_revoked_at: nullableTimestamp(
|
|
28192
|
-
row.token_revoked_at,
|
|
28193
|
-
"token_revoked_at"
|
|
28194
|
-
)
|
|
28195
|
-
};
|
|
28196
|
-
}
|
|
28197
|
-
async function readRenewalGrants(target2, credential, workspaceId2, fetcher = fetch) {
|
|
28198
|
-
const response = await fetcher(readEndpoint(target2), {
|
|
28199
|
-
method: "POST",
|
|
28200
|
-
headers: {
|
|
28201
|
-
authorization: `Bearer ${credential}`,
|
|
28202
|
-
apikey: target2.anonKey,
|
|
28203
|
-
"content-type": "application/json"
|
|
28204
|
-
},
|
|
28205
|
-
body: JSON.stringify({
|
|
28206
|
-
resource: "renewal_grants",
|
|
28207
|
-
workspace_id: workspaceId2
|
|
28208
|
-
}),
|
|
28209
|
-
signal: AbortSignal.timeout(15e3)
|
|
28210
|
-
});
|
|
28211
|
-
if (!response.ok) {
|
|
28212
|
-
throw new Error(`renewal grant read failed (HTTP ${response.status})`);
|
|
28213
|
-
}
|
|
28214
|
-
const body = await response.json().catch(() => null);
|
|
28215
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
28216
|
-
throw new Error("renewal grant read returned malformed JSON");
|
|
28217
|
-
}
|
|
28218
|
-
const grants = body.grants;
|
|
28219
|
-
if (!Array.isArray(grants)) {
|
|
28220
|
-
throw new Error("renewal grant read returned no grants array");
|
|
28221
|
-
}
|
|
28222
|
-
return grants.map(parseGrant);
|
|
28223
|
-
}
|
|
28224
|
-
function describeRenewalGrant(grant) {
|
|
28225
|
-
const lines = grant.kind === "standing" ? ["Grant: standing \u2014 does not expire; revoke is the only kill switch."] : [`Grant: timeboxed \u2014 renewal horizon ${grant.horizon_expires_at}.`];
|
|
28226
|
-
if (grant.suspended_at !== null) {
|
|
28227
|
-
lines.push(
|
|
28228
|
-
`SUSPENDED since ${grant.suspended_at}. Next step: ask a workspace owner to revoke this grant and mint a new credential.`
|
|
28229
|
-
);
|
|
28230
|
-
}
|
|
28231
|
-
if (grant.revoked_at !== null) {
|
|
28232
|
-
lines.push(`REVOKED since ${grant.revoked_at}. Next step: mint a new grant if this agent should continue.`);
|
|
28233
|
-
}
|
|
28234
|
-
return lines;
|
|
28235
|
-
}
|
|
28236
|
-
|
|
28237
28263
|
// src/cloud/workspaces.ts
|
|
28238
28264
|
var UUID_RE8 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
28239
28265
|
var ROLES = /* @__PURE__ */ new Set(["owner", "admin", "member"]);
|
|
@@ -31078,136 +31104,728 @@ function signalReceiptJsonPayload(report, nowMs = Date.now()) {
|
|
|
31078
31104
|
};
|
|
31079
31105
|
}
|
|
31080
31106
|
|
|
31081
|
-
// src/cloud/
|
|
31082
|
-
var
|
|
31083
|
-
var
|
|
31084
|
-
var
|
|
31085
|
-
|
|
31107
|
+
// src/cloud/delivery.ts
|
|
31108
|
+
var UUID_RE13 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
31109
|
+
var RFC3339_TIMESTAMP_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-]\d{2}):(\d{2}))$/i;
|
|
31110
|
+
var DELIVERY_KINDS = /* @__PURE__ */ new Set(["ask", "note"]);
|
|
31111
|
+
var SENDER_OWNER_RELATIONS2 = /* @__PURE__ */ new Set([
|
|
31112
|
+
"same_owner",
|
|
31113
|
+
"cross_owner",
|
|
31114
|
+
"unknown"
|
|
31115
|
+
]);
|
|
31116
|
+
var DELIVERY_ACK_OUTCOMES = /* @__PURE__ */ new Set([
|
|
31117
|
+
"replied",
|
|
31118
|
+
"observed",
|
|
31119
|
+
"queued",
|
|
31120
|
+
"expired",
|
|
31121
|
+
"failed_terminal"
|
|
31122
|
+
]);
|
|
31123
|
+
var DELIVERY_HANDLED_OUTCOMES = new Set(
|
|
31124
|
+
[...DELIVERY_ACK_OUTCOMES].filter(
|
|
31125
|
+
(outcome) => outcome === "replied" || outcome === "observed"
|
|
31126
|
+
)
|
|
31127
|
+
);
|
|
31128
|
+
var DELIVERY_PROVIDER_PROVEN_OUTCOMES = new Set(
|
|
31129
|
+
[...DELIVERY_ACK_OUTCOMES].filter((outcome) => outcome === "replied")
|
|
31130
|
+
);
|
|
31131
|
+
function orList2(values2) {
|
|
31132
|
+
return values2.length <= 1 ? values2.join("") : `${values2.slice(0, -1).join(", ")}, or ${values2[values2.length - 1]}`;
|
|
31133
|
+
}
|
|
31134
|
+
var DELIVERY_REQUEST_TIMEOUT_MS = 3e4;
|
|
31135
|
+
var COMMAND_ID_VALIDATOR_RE = /^[A-Za-z0-9_-]{8,72}$/;
|
|
31136
|
+
var FAILED_TERMINAL_CODES_SET = /* @__PURE__ */ new Set([
|
|
31137
|
+
"provider_refused",
|
|
31138
|
+
"local_effect_failed",
|
|
31139
|
+
"host_session_failed",
|
|
31140
|
+
"credential_unavailable"
|
|
31141
|
+
]);
|
|
31142
|
+
var SERVER_ERROR_CODES_SET = /* @__PURE__ */ new Set([
|
|
31143
|
+
"unauthenticated",
|
|
31144
|
+
"fresh_auth_required",
|
|
31145
|
+
"invalid_request",
|
|
31146
|
+
"payload_too_large",
|
|
31147
|
+
"forbidden",
|
|
31148
|
+
"delivery_unavailable",
|
|
31149
|
+
"delivery_ack_conflict",
|
|
31150
|
+
"command_id_conflict",
|
|
31151
|
+
"rate_limited",
|
|
31152
|
+
"upgrade_required",
|
|
31153
|
+
"temporarily_unavailable",
|
|
31154
|
+
"internal_error"
|
|
31155
|
+
]);
|
|
31156
|
+
var DELIVERY_FAILED_TERMINAL_CODES = Object.freeze([
|
|
31157
|
+
"provider_refused",
|
|
31158
|
+
"local_effect_failed",
|
|
31159
|
+
"host_session_failed",
|
|
31160
|
+
"credential_unavailable"
|
|
31161
|
+
]);
|
|
31162
|
+
var DELIVERY_SERVER_ERROR_CODES = Object.freeze([
|
|
31163
|
+
"unauthenticated",
|
|
31164
|
+
"fresh_auth_required",
|
|
31165
|
+
"invalid_request",
|
|
31166
|
+
"payload_too_large",
|
|
31167
|
+
"forbidden",
|
|
31168
|
+
"delivery_unavailable",
|
|
31169
|
+
"delivery_ack_conflict",
|
|
31170
|
+
"command_id_conflict",
|
|
31171
|
+
"rate_limited",
|
|
31172
|
+
"upgrade_required",
|
|
31173
|
+
"temporarily_unavailable",
|
|
31174
|
+
"internal_error"
|
|
31175
|
+
]);
|
|
31176
|
+
var DELIVERY_UNKNOWN_ERROR_CODE = "unknown_error";
|
|
31177
|
+
function observationCommandId(signalId) {
|
|
31178
|
+
checkedUuidRequest(signalId, "signalId");
|
|
31179
|
+
return `observe_${signalId.toLowerCase().replaceAll("-", "")}`;
|
|
31180
|
+
}
|
|
31181
|
+
var DeliveryTransportError = class extends Error {
|
|
31182
|
+
constructor(message) {
|
|
31183
|
+
super(message);
|
|
31184
|
+
this.name = "DeliveryTransportError";
|
|
31185
|
+
}
|
|
31186
|
+
};
|
|
31187
|
+
var DeliveryHttpError = class extends Error {
|
|
31188
|
+
constructor(status, code, message, retryAfterMs = null) {
|
|
31086
31189
|
super(message);
|
|
31087
|
-
this.code = code;
|
|
31088
31190
|
this.status = status;
|
|
31089
|
-
this.
|
|
31191
|
+
this.code = code;
|
|
31192
|
+
this.retryAfterMs = retryAfterMs;
|
|
31193
|
+
this.name = "DeliveryHttpError";
|
|
31090
31194
|
}
|
|
31091
|
-
code;
|
|
31092
31195
|
status;
|
|
31196
|
+
code;
|
|
31197
|
+
retryAfterMs;
|
|
31093
31198
|
};
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
(
|
|
31097
|
-
|
|
31199
|
+
var DeliveryProtocolError = class extends Error {
|
|
31200
|
+
constructor(message) {
|
|
31201
|
+
super(message);
|
|
31202
|
+
this.name = "DeliveryProtocolError";
|
|
31203
|
+
}
|
|
31204
|
+
};
|
|
31205
|
+
function checkedUuid3(value, field) {
|
|
31206
|
+
if (typeof value !== "string" || !UUID_RE13.test(value)) {
|
|
31207
|
+
throw new DeliveryProtocolError(
|
|
31208
|
+
`delivery response returned a malformed ${field}`
|
|
31209
|
+
);
|
|
31210
|
+
}
|
|
31211
|
+
return value.toLowerCase();
|
|
31098
31212
|
}
|
|
31099
|
-
function
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
31103
|
-
|
|
31213
|
+
function isLeapYear(year) {
|
|
31214
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
31215
|
+
}
|
|
31216
|
+
function daysInMonth(year, month) {
|
|
31217
|
+
switch (month) {
|
|
31218
|
+
case 1:
|
|
31219
|
+
case 3:
|
|
31220
|
+
case 5:
|
|
31221
|
+
case 7:
|
|
31222
|
+
case 8:
|
|
31223
|
+
case 10:
|
|
31224
|
+
case 12:
|
|
31225
|
+
return 31;
|
|
31226
|
+
case 4:
|
|
31227
|
+
case 6:
|
|
31228
|
+
case 9:
|
|
31229
|
+
case 11:
|
|
31230
|
+
return 30;
|
|
31231
|
+
case 2:
|
|
31232
|
+
return isLeapYear(year) ? 29 : 28;
|
|
31233
|
+
default:
|
|
31234
|
+
return 0;
|
|
31104
31235
|
}
|
|
31105
|
-
return batches;
|
|
31106
31236
|
}
|
|
31107
|
-
|
|
31108
|
-
|
|
31109
|
-
|
|
31110
|
-
|
|
31111
|
-
try {
|
|
31112
|
-
response = await fetcher(commandEndpoint(target2), {
|
|
31113
|
-
method: "POST",
|
|
31114
|
-
headers: {
|
|
31115
|
-
authorization: `Bearer ${token}`,
|
|
31116
|
-
apikey: target2.anonKey,
|
|
31117
|
-
"content-type": "application/json"
|
|
31118
|
-
},
|
|
31119
|
-
body: JSON.stringify({
|
|
31120
|
-
command_id: newCommandId(),
|
|
31121
|
-
client_version: CLIENT_PROTOCOL_VERSION,
|
|
31122
|
-
workspace_id: workspaceId2,
|
|
31123
|
-
stream: { kind: "workspace" },
|
|
31124
|
-
command: { kind: "signals_seen", signal_ids: signalIds }
|
|
31125
|
-
}),
|
|
31126
|
-
signal: controller.signal
|
|
31127
|
-
});
|
|
31128
|
-
} catch {
|
|
31129
|
-
throw new AgentSeenReportError(
|
|
31130
|
-
"transport",
|
|
31131
|
-
"agent seen report did not reach the command service"
|
|
31237
|
+
function checkedRfc3339Timestamp(value, field) {
|
|
31238
|
+
if (typeof value !== "string") {
|
|
31239
|
+
throw new DeliveryProtocolError(
|
|
31240
|
+
`delivery response returned a malformed ${field}`
|
|
31132
31241
|
);
|
|
31133
|
-
} finally {
|
|
31134
|
-
clearTimeout(timer2);
|
|
31135
31242
|
}
|
|
31136
|
-
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
`
|
|
31140
|
-
response.status
|
|
31243
|
+
const match = RFC3339_TIMESTAMP_RE.exec(value);
|
|
31244
|
+
if (!match) {
|
|
31245
|
+
throw new DeliveryProtocolError(
|
|
31246
|
+
`delivery response returned a malformed ${field}`
|
|
31141
31247
|
);
|
|
31142
31248
|
}
|
|
31143
|
-
|
|
31144
|
-
|
|
31145
|
-
|
|
31146
|
-
|
|
31147
|
-
|
|
31148
|
-
|
|
31149
|
-
|
|
31150
|
-
|
|
31249
|
+
const year = parseInt(match[1], 10);
|
|
31250
|
+
const month = parseInt(match[2], 10);
|
|
31251
|
+
const day = parseInt(match[3], 10);
|
|
31252
|
+
const hour = parseInt(match[4], 10);
|
|
31253
|
+
const minute = parseInt(match[5], 10);
|
|
31254
|
+
const second = parseInt(match[6], 10);
|
|
31255
|
+
if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
|
|
31256
|
+
throw new DeliveryProtocolError(
|
|
31257
|
+
`delivery response returned a malformed ${field}`
|
|
31151
31258
|
);
|
|
31152
31259
|
}
|
|
31153
|
-
if (
|
|
31154
|
-
|
|
31155
|
-
|
|
31156
|
-
|
|
31157
|
-
|
|
31260
|
+
if (match[7] !== void 0 && match[8] !== void 0) {
|
|
31261
|
+
const offsetHour = Math.abs(parseInt(match[7], 10));
|
|
31262
|
+
const offsetMin = parseInt(match[8], 10);
|
|
31263
|
+
if (offsetHour > 23 || offsetMin < 0 || offsetMin > 59) {
|
|
31264
|
+
throw new DeliveryProtocolError(
|
|
31265
|
+
`delivery response returned a malformed ${field}`
|
|
31266
|
+
);
|
|
31267
|
+
}
|
|
31268
|
+
}
|
|
31269
|
+
if (!Number.isFinite(Date.parse(value))) {
|
|
31270
|
+
throw new DeliveryProtocolError(
|
|
31271
|
+
`delivery response returned a malformed ${field}`
|
|
31158
31272
|
);
|
|
31159
31273
|
}
|
|
31274
|
+
return value;
|
|
31160
31275
|
}
|
|
31161
|
-
|
|
31162
|
-
|
|
31163
|
-
|
|
31164
|
-
|
|
31165
|
-
|
|
31166
|
-
|
|
31167
|
-
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
|
|
31171
|
-
|
|
31276
|
+
function checkedLiveLease(leasedUntil, now) {
|
|
31277
|
+
if (Date.parse(leasedUntil) <= now()) {
|
|
31278
|
+
throw new DeliveryProtocolError(
|
|
31279
|
+
"delivery claim response returned an already expired lease"
|
|
31280
|
+
);
|
|
31281
|
+
}
|
|
31282
|
+
}
|
|
31283
|
+
function checkedRelation(value) {
|
|
31284
|
+
if (typeof value !== "string" || !SENDER_OWNER_RELATIONS2.has(value)) {
|
|
31285
|
+
throw new DeliveryProtocolError(
|
|
31286
|
+
"delivery response returned a malformed sender_owner_relation"
|
|
31287
|
+
);
|
|
31288
|
+
}
|
|
31289
|
+
return value;
|
|
31290
|
+
}
|
|
31291
|
+
function checkedNonNegativeCount(value, field) {
|
|
31292
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
31293
|
+
throw new DeliveryProtocolError(
|
|
31294
|
+
`delivery response returned a malformed ${field}`
|
|
31295
|
+
);
|
|
31296
|
+
}
|
|
31297
|
+
return value;
|
|
31298
|
+
}
|
|
31299
|
+
function checkedClaimCapabilities(value) {
|
|
31300
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
31301
|
+
throw new DeliveryProtocolError(
|
|
31302
|
+
"delivery claim response is missing delivery capabilities"
|
|
31303
|
+
);
|
|
31304
|
+
}
|
|
31305
|
+
const row = value;
|
|
31306
|
+
for (const marker of ["delivery_claim", "delivery_ack", "sender_owner_relation"]) {
|
|
31307
|
+
if (row[marker] !== 1) {
|
|
31308
|
+
throw new DeliveryProtocolError(
|
|
31309
|
+
`delivery claim response is missing the ${marker} capability`
|
|
31172
31310
|
);
|
|
31173
31311
|
}
|
|
31174
31312
|
}
|
|
31175
|
-
return {
|
|
31313
|
+
return { deliveryClaim: true, deliveryAck: true, senderOwnerRelation: true };
|
|
31176
31314
|
}
|
|
31177
|
-
|
|
31178
|
-
|
|
31179
|
-
|
|
31180
|
-
|
|
31181
|
-
|
|
31182
|
-
|
|
31183
|
-
|
|
31184
|
-
var SEPARATOR_CLASS_SOURCE = "\\t\\n\\x0b\\f\\r " + EXOTIC_SEPARATORS;
|
|
31185
|
-
var ANSI_ESCAPE_GLOBAL_RE2 = new RegExp("\\u001b\\[[0-?]*[ -\\/]*[@-~]", "g");
|
|
31186
|
-
var CONTROL_AND_SEPARATOR_STRIP_RE = new RegExp(
|
|
31187
|
-
"[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f" + EXOTIC_SEPARATORS + "]",
|
|
31188
|
-
"g"
|
|
31189
|
-
);
|
|
31190
|
-
var CREDENTIAL_PREFIX_RE = new RegExp(
|
|
31191
|
-
`swm_(?:agt|inv|cap)_[^${SEPARATOR_CLASS_SOURCE}]*`,
|
|
31192
|
-
"gi"
|
|
31193
|
-
);
|
|
31194
|
-
function redactCredentialText(value) {
|
|
31195
|
-
return value.replace(ANSI_ESCAPE_GLOBAL_RE2, "").replace(CONTROL_AND_SEPARATOR_STRIP_RE, "").replace(CREDENTIAL_PREFIX_RE, "[redacted-credential]");
|
|
31315
|
+
function checkedOptionalUuidArray(value, field) {
|
|
31316
|
+
if (value === void 0) return;
|
|
31317
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !UUID_RE13.test(item))) {
|
|
31318
|
+
throw new DeliveryProtocolError(
|
|
31319
|
+
`delivery response returned a malformed ${field}`
|
|
31320
|
+
);
|
|
31321
|
+
}
|
|
31196
31322
|
}
|
|
31197
|
-
|
|
31198
|
-
|
|
31199
|
-
|
|
31200
|
-
|
|
31201
|
-
|
|
31202
|
-
|
|
31203
|
-
|
|
31204
|
-
return redactCredentialText(raw).slice(-TAIL_MAX_CHARS).trim();
|
|
31323
|
+
function checkedOptionalArray(value, field) {
|
|
31324
|
+
if (value === void 0) return;
|
|
31325
|
+
if (!Array.isArray(value)) {
|
|
31326
|
+
throw new DeliveryProtocolError(
|
|
31327
|
+
`delivery response returned a malformed ${field}`
|
|
31328
|
+
);
|
|
31329
|
+
}
|
|
31205
31330
|
}
|
|
31206
|
-
function
|
|
31207
|
-
|
|
31208
|
-
|
|
31209
|
-
|
|
31210
|
-
|
|
31331
|
+
function parseDeliveryRow(value, expected, index, now) {
|
|
31332
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
31333
|
+
throw new DeliveryProtocolError(
|
|
31334
|
+
"delivery claim response returned a malformed delivery row"
|
|
31335
|
+
);
|
|
31336
|
+
}
|
|
31337
|
+
const row = value;
|
|
31338
|
+
let signal;
|
|
31339
|
+
try {
|
|
31340
|
+
signal = parseSignalRecord(row.signal);
|
|
31341
|
+
} catch {
|
|
31342
|
+
throw new DeliveryProtocolError(
|
|
31343
|
+
`delivery claim response returned a malformed signal at ${index}`
|
|
31344
|
+
);
|
|
31345
|
+
}
|
|
31346
|
+
if (signal.workspace_id !== expected.workspaceId) {
|
|
31347
|
+
throw new DeliveryProtocolError(
|
|
31348
|
+
"delivery claim response returned a signal for another workspace"
|
|
31349
|
+
);
|
|
31350
|
+
}
|
|
31351
|
+
if (signal.to_agent !== expected.principalId) {
|
|
31352
|
+
throw new DeliveryProtocolError(
|
|
31353
|
+
"delivery claim response returned a signal addressed to another agent"
|
|
31354
|
+
);
|
|
31355
|
+
}
|
|
31356
|
+
if (!DELIVERY_KINDS.has(signal.kind)) {
|
|
31357
|
+
throw new DeliveryProtocolError(
|
|
31358
|
+
"delivery claim response returned a non-direct signal kind"
|
|
31359
|
+
);
|
|
31360
|
+
}
|
|
31361
|
+
const senderOwnerRelation = checkedRelation(row.sender_owner_relation);
|
|
31362
|
+
const leaseId = checkedUuid3(row.lease_id, "lease_id");
|
|
31363
|
+
const leasedUntil = checkedRfc3339Timestamp(row.leased_until, "leased_until");
|
|
31364
|
+
checkedLiveLease(leasedUntil, now);
|
|
31365
|
+
signal.sender_owner_relation = senderOwnerRelation;
|
|
31366
|
+
return { signal, leaseId, leasedUntil, senderOwnerRelation };
|
|
31367
|
+
}
|
|
31368
|
+
function parseClaimSuccess(body, expected, now) {
|
|
31369
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
31370
|
+
throw new DeliveryProtocolError("delivery claim response was not an object");
|
|
31371
|
+
}
|
|
31372
|
+
const row = body;
|
|
31373
|
+
if (row.status !== "accepted" || row.ok !== true) {
|
|
31374
|
+
throw new DeliveryProtocolError(
|
|
31375
|
+
"delivery claim response did not report accepted ok"
|
|
31376
|
+
);
|
|
31377
|
+
}
|
|
31378
|
+
const capabilities = checkedClaimCapabilities(row.capabilities);
|
|
31379
|
+
checkedOptionalUuidArray(row.event_ids, "event_ids");
|
|
31380
|
+
checkedOptionalArray(row.events, "events");
|
|
31381
|
+
if (!Array.isArray(row.deliveries)) {
|
|
31382
|
+
throw new DeliveryProtocolError(
|
|
31383
|
+
"delivery claim response is missing its deliveries array"
|
|
31384
|
+
);
|
|
31385
|
+
}
|
|
31386
|
+
const deliveries = row.deliveries.map(
|
|
31387
|
+
(item, index) => parseDeliveryRow(item, expected, index, now)
|
|
31388
|
+
);
|
|
31389
|
+
const signalIds = /* @__PURE__ */ new Set();
|
|
31390
|
+
const leaseIds = /* @__PURE__ */ new Set();
|
|
31391
|
+
for (const delivery of deliveries) {
|
|
31392
|
+
if (signalIds.has(delivery.signal.id)) {
|
|
31393
|
+
throw new DeliveryProtocolError(
|
|
31394
|
+
"delivery claim response repeats a signal id"
|
|
31395
|
+
);
|
|
31396
|
+
}
|
|
31397
|
+
signalIds.add(delivery.signal.id);
|
|
31398
|
+
if (leaseIds.has(delivery.leaseId)) {
|
|
31399
|
+
throw new DeliveryProtocolError(
|
|
31400
|
+
"delivery claim response repeats a lease id"
|
|
31401
|
+
);
|
|
31402
|
+
}
|
|
31403
|
+
leaseIds.add(delivery.leaseId);
|
|
31404
|
+
}
|
|
31405
|
+
if (deliveries.length > 1) {
|
|
31406
|
+
throw new DeliveryProtocolError(
|
|
31407
|
+
"delivery claim response returned more than one delivery"
|
|
31408
|
+
);
|
|
31409
|
+
}
|
|
31410
|
+
const pendingDeliveryCount = checkedNonNegativeCount(
|
|
31411
|
+
row.pending_delivery_count,
|
|
31412
|
+
"pending_delivery_count"
|
|
31413
|
+
);
|
|
31414
|
+
const terminalDeliveryFailureCount = checkedNonNegativeCount(
|
|
31415
|
+
row.terminal_delivery_failure_count,
|
|
31416
|
+
"terminal_delivery_failure_count"
|
|
31417
|
+
);
|
|
31418
|
+
if (deliveries.length > pendingDeliveryCount) {
|
|
31419
|
+
throw new DeliveryProtocolError(
|
|
31420
|
+
"delivery claim response returned more deliveries than its pending count"
|
|
31421
|
+
);
|
|
31422
|
+
}
|
|
31423
|
+
return {
|
|
31424
|
+
capabilities,
|
|
31425
|
+
deliveries,
|
|
31426
|
+
pendingDeliveryCount,
|
|
31427
|
+
terminalDeliveryFailureCount
|
|
31428
|
+
};
|
|
31429
|
+
}
|
|
31430
|
+
function parseAckSuccess(body, expected) {
|
|
31431
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
31432
|
+
throw new DeliveryProtocolError(
|
|
31433
|
+
"delivery acknowledgement response was not an object"
|
|
31434
|
+
);
|
|
31435
|
+
}
|
|
31436
|
+
const row = body;
|
|
31437
|
+
if (row.status !== "accepted" || row.ok !== true) {
|
|
31438
|
+
throw new DeliveryProtocolError(
|
|
31439
|
+
"delivery acknowledgement response did not report accepted ok"
|
|
31440
|
+
);
|
|
31441
|
+
}
|
|
31442
|
+
checkedOptionalUuidArray(row.event_ids, "event_ids");
|
|
31443
|
+
checkedOptionalArray(row.events, "events");
|
|
31444
|
+
if (row.signal_id !== expected.signalId) {
|
|
31445
|
+
throw new DeliveryProtocolError(
|
|
31446
|
+
"delivery acknowledgement response echoed a different signal id"
|
|
31447
|
+
);
|
|
31448
|
+
}
|
|
31449
|
+
if (row.outcome !== expected.outcome) {
|
|
31450
|
+
throw new DeliveryProtocolError(
|
|
31451
|
+
"delivery acknowledgement response echoed a different outcome"
|
|
31452
|
+
);
|
|
31453
|
+
}
|
|
31454
|
+
}
|
|
31455
|
+
function checkedCommandId(value) {
|
|
31456
|
+
if (typeof value !== "string" || !COMMAND_ID_VALIDATOR_RE.test(value)) {
|
|
31457
|
+
throw new Error(
|
|
31458
|
+
"a delivery command id must be 8..72 characters of [A-Za-z0-9_-]"
|
|
31459
|
+
);
|
|
31460
|
+
}
|
|
31461
|
+
return value;
|
|
31462
|
+
}
|
|
31463
|
+
function checkedUuidRequest(value, field) {
|
|
31464
|
+
if (!UUID_RE13.test(value)) {
|
|
31465
|
+
throw new Error(`${field} must be a UUID for an agent delivery command`);
|
|
31466
|
+
}
|
|
31467
|
+
}
|
|
31468
|
+
function assertAckRequest(request) {
|
|
31469
|
+
checkedCommandId(request.commandId);
|
|
31470
|
+
assertAgentToken(request.credential);
|
|
31471
|
+
checkedUuidRequest(request.workspaceId, "workspaceId");
|
|
31472
|
+
checkedUuidRequest(request.signalId, "signalId");
|
|
31473
|
+
checkedUuidRequest(request.leaseId, "leaseId");
|
|
31474
|
+
checkedUuidRequest(request.listenerInstanceId, "listenerInstanceId");
|
|
31475
|
+
if (!DELIVERY_ACK_OUTCOMES.has(request.outcome)) {
|
|
31476
|
+
throw new Error(
|
|
31477
|
+
`a delivery outcome must be ${orList2([...DELIVERY_ACK_OUTCOMES])}`
|
|
31478
|
+
);
|
|
31479
|
+
}
|
|
31480
|
+
if (request.outcome === "failed_terminal") {
|
|
31481
|
+
if (typeof request.lastErrorCode !== "string" || !FAILED_TERMINAL_CODES_SET.has(request.lastErrorCode)) {
|
|
31482
|
+
throw new Error(
|
|
31483
|
+
`a failed_terminal acknowledgement requires one of ${orList2([...FAILED_TERMINAL_CODES_SET])}`
|
|
31484
|
+
);
|
|
31485
|
+
}
|
|
31486
|
+
} else if (request.lastErrorCode !== null) {
|
|
31487
|
+
throw new Error(
|
|
31488
|
+
"a non-failed acknowledgement must send lastErrorCode null"
|
|
31489
|
+
);
|
|
31490
|
+
}
|
|
31491
|
+
}
|
|
31492
|
+
function boundedDeliveryErrorCode(body) {
|
|
31493
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
31494
|
+
return DELIVERY_UNKNOWN_ERROR_CODE;
|
|
31495
|
+
}
|
|
31496
|
+
const error = body.error;
|
|
31497
|
+
if (typeof error === "string" && SERVER_ERROR_CODES_SET.has(error)) {
|
|
31498
|
+
return error;
|
|
31499
|
+
}
|
|
31500
|
+
return DELIVERY_UNKNOWN_ERROR_CODE;
|
|
31501
|
+
}
|
|
31502
|
+
function refusal(response, text) {
|
|
31503
|
+
let code = DELIVERY_UNKNOWN_ERROR_CODE;
|
|
31504
|
+
try {
|
|
31505
|
+
code = boundedDeliveryErrorCode(JSON.parse(text));
|
|
31506
|
+
} catch {
|
|
31507
|
+
}
|
|
31508
|
+
const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after"));
|
|
31509
|
+
return new DeliveryHttpError(
|
|
31510
|
+
response.status,
|
|
31511
|
+
code,
|
|
31512
|
+
`delivery command failed (HTTP ${response.status}): ${code}`,
|
|
31513
|
+
retryAfterMs
|
|
31514
|
+
);
|
|
31515
|
+
}
|
|
31516
|
+
function successBody(response, text, verb) {
|
|
31517
|
+
try {
|
|
31518
|
+
return JSON.parse(text);
|
|
31519
|
+
} catch {
|
|
31520
|
+
throw new DeliveryProtocolError(
|
|
31521
|
+
`${verb} response was not JSON (HTTP ${response.status})`
|
|
31522
|
+
);
|
|
31523
|
+
}
|
|
31524
|
+
}
|
|
31525
|
+
var DeliveryCommandClient = class {
|
|
31526
|
+
constructor(target2, fetcher = fetch, options = {}) {
|
|
31527
|
+
this.target = target2;
|
|
31528
|
+
this.fetcher = fetcher;
|
|
31529
|
+
this.deadlineMs = options.deadlineMs ?? DELIVERY_REQUEST_TIMEOUT_MS;
|
|
31530
|
+
this.now = options.now ?? Date.now;
|
|
31531
|
+
this.clearTimeoutFn = options.clearTimeout ?? ((timer2) => clearTimeout(timer2));
|
|
31532
|
+
this.createAbortControllerFn = options.createAbortController ?? (() => new AbortController());
|
|
31533
|
+
}
|
|
31534
|
+
target;
|
|
31535
|
+
fetcher;
|
|
31536
|
+
deadlineMs;
|
|
31537
|
+
now;
|
|
31538
|
+
clearTimeoutFn;
|
|
31539
|
+
createAbortControllerFn;
|
|
31540
|
+
async post(request, command2, verb) {
|
|
31541
|
+
if (this.deadlineMs <= 0) {
|
|
31542
|
+
throw new DeliveryTransportError(`${verb} request timed out`);
|
|
31543
|
+
}
|
|
31544
|
+
const deadlineController = this.createAbortControllerFn();
|
|
31545
|
+
let timedOut = false;
|
|
31546
|
+
const signal = deadlineController.signal;
|
|
31547
|
+
let onAbort = () => {
|
|
31548
|
+
};
|
|
31549
|
+
const aborted = new Promise((resolve3) => {
|
|
31550
|
+
onAbort = () => resolve3("timeout");
|
|
31551
|
+
if (signal.aborted) {
|
|
31552
|
+
onAbort();
|
|
31553
|
+
} else {
|
|
31554
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
31555
|
+
}
|
|
31556
|
+
});
|
|
31557
|
+
const timer2 = setTimeout(() => {
|
|
31558
|
+
timedOut = true;
|
|
31559
|
+
deadlineController.abort();
|
|
31560
|
+
}, this.deadlineMs);
|
|
31561
|
+
try {
|
|
31562
|
+
if (signal.aborted) {
|
|
31563
|
+
throw new DeliveryTransportError(`${verb} request timed out`);
|
|
31564
|
+
}
|
|
31565
|
+
const read = (async () => {
|
|
31566
|
+
let response;
|
|
31567
|
+
try {
|
|
31568
|
+
response = await this.fetcher(commandEndpoint(this.target), {
|
|
31569
|
+
method: "POST",
|
|
31570
|
+
headers: {
|
|
31571
|
+
authorization: `Bearer ${request.credential}`,
|
|
31572
|
+
apikey: this.target.anonKey,
|
|
31573
|
+
"content-type": "application/json"
|
|
31574
|
+
},
|
|
31575
|
+
body: JSON.stringify({
|
|
31576
|
+
command_id: request.commandId,
|
|
31577
|
+
client_version: CLIENT_PROTOCOL_VERSION,
|
|
31578
|
+
workspace_id: request.workspaceId.toLowerCase(),
|
|
31579
|
+
stream: { kind: "workspace" },
|
|
31580
|
+
command: command2
|
|
31581
|
+
}),
|
|
31582
|
+
signal
|
|
31583
|
+
});
|
|
31584
|
+
} catch (error) {
|
|
31585
|
+
if (signal.aborted || timedOut || error?.name === "AbortError") {
|
|
31586
|
+
return "timeout";
|
|
31587
|
+
}
|
|
31588
|
+
throw new DeliveryTransportError(
|
|
31589
|
+
`${verb} request failed before a response`
|
|
31590
|
+
);
|
|
31591
|
+
}
|
|
31592
|
+
if (signal.aborted || timedOut) return "timeout";
|
|
31593
|
+
let text;
|
|
31594
|
+
try {
|
|
31595
|
+
text = await response.text();
|
|
31596
|
+
} catch {
|
|
31597
|
+
if (signal.aborted || timedOut) return "timeout";
|
|
31598
|
+
throw new DeliveryTransportError(
|
|
31599
|
+
`${verb} response body was interrupted`
|
|
31600
|
+
);
|
|
31601
|
+
}
|
|
31602
|
+
if (signal.aborted || timedOut) return "timeout";
|
|
31603
|
+
return { response, text };
|
|
31604
|
+
})();
|
|
31605
|
+
const raced = await Promise.race([read, aborted]);
|
|
31606
|
+
if (raced === "timeout") {
|
|
31607
|
+
throw new DeliveryTransportError(`${verb} request timed out`);
|
|
31608
|
+
}
|
|
31609
|
+
return raced;
|
|
31610
|
+
} finally {
|
|
31611
|
+
this.clearTimeoutFn(timer2);
|
|
31612
|
+
signal.removeEventListener("abort", onAbort);
|
|
31613
|
+
}
|
|
31614
|
+
}
|
|
31615
|
+
/** Claim the caller's own single unacked direct-signal delivery row. */
|
|
31616
|
+
async claimAgentInbox(request) {
|
|
31617
|
+
checkedCommandId(request.commandId);
|
|
31618
|
+
assertAgentToken(request.credential);
|
|
31619
|
+
checkedUuidRequest(request.workspaceId, "workspaceId");
|
|
31620
|
+
checkedUuidRequest(request.listenerInstanceId, "listenerInstanceId");
|
|
31621
|
+
checkedUuidRequest(request.expectedPrincipalId, "expectedPrincipalId");
|
|
31622
|
+
const { response, text } = await this.post(request, {
|
|
31623
|
+
kind: "claim_agent_inbox",
|
|
31624
|
+
listener_instance_id: request.listenerInstanceId.toLowerCase(),
|
|
31625
|
+
limit: 1
|
|
31626
|
+
}, "delivery claim");
|
|
31627
|
+
if (!response.ok) throw refusal(response, text);
|
|
31628
|
+
const parsed = parseClaimSuccess(
|
|
31629
|
+
successBody(response, text, "delivery claim"),
|
|
31630
|
+
{
|
|
31631
|
+
workspaceId: request.workspaceId.toLowerCase(),
|
|
31632
|
+
principalId: request.expectedPrincipalId.toLowerCase()
|
|
31633
|
+
},
|
|
31634
|
+
this.now
|
|
31635
|
+
);
|
|
31636
|
+
return {
|
|
31637
|
+
httpStatus: response.status,
|
|
31638
|
+
capabilities: parsed.capabilities,
|
|
31639
|
+
deliveries: parsed.deliveries,
|
|
31640
|
+
pendingDeliveryCount: parsed.pendingDeliveryCount,
|
|
31641
|
+
terminalDeliveryFailureCount: parsed.terminalDeliveryFailureCount
|
|
31642
|
+
};
|
|
31643
|
+
}
|
|
31644
|
+
/** Acknowledge one leased delivery with an exact terminal outcome. */
|
|
31645
|
+
async ackAgentDelivery(request) {
|
|
31646
|
+
assertAckRequest(request);
|
|
31647
|
+
const { response, text } = await this.post(request, {
|
|
31648
|
+
kind: "ack_agent_delivery",
|
|
31649
|
+
signal_id: request.signalId.toLowerCase(),
|
|
31650
|
+
lease_id: request.leaseId.toLowerCase(),
|
|
31651
|
+
listener_instance_id: request.listenerInstanceId.toLowerCase(),
|
|
31652
|
+
outcome: request.outcome,
|
|
31653
|
+
last_error_code: request.lastErrorCode
|
|
31654
|
+
}, "delivery acknowledgement");
|
|
31655
|
+
if (!response.ok) throw refusal(response, text);
|
|
31656
|
+
parseAckSuccess(
|
|
31657
|
+
successBody(response, text, "delivery acknowledgement"),
|
|
31658
|
+
{
|
|
31659
|
+
signalId: request.signalId.toLowerCase(),
|
|
31660
|
+
outcome: request.outcome
|
|
31661
|
+
}
|
|
31662
|
+
);
|
|
31663
|
+
return {
|
|
31664
|
+
httpStatus: response.status,
|
|
31665
|
+
signalId: request.signalId.toLowerCase(),
|
|
31666
|
+
outcome: request.outcome
|
|
31667
|
+
};
|
|
31668
|
+
}
|
|
31669
|
+
/** Mark a queued delivery observed only after the interactive hook surfaced it. */
|
|
31670
|
+
async observeQueuedAgentDelivery(request) {
|
|
31671
|
+
checkedCommandId(request.commandId);
|
|
31672
|
+
assertAgentToken(request.credential);
|
|
31673
|
+
checkedUuidRequest(request.workspaceId, "workspaceId");
|
|
31674
|
+
checkedUuidRequest(request.signalId, "signalId");
|
|
31675
|
+
const { response, text } = await this.post(request, {
|
|
31676
|
+
kind: "ack_agent_delivery",
|
|
31677
|
+
signal_id: request.signalId.toLowerCase(),
|
|
31678
|
+
lease_id: null,
|
|
31679
|
+
listener_instance_id: null,
|
|
31680
|
+
outcome: "observed",
|
|
31681
|
+
last_error_code: null
|
|
31682
|
+
}, "delivery observation");
|
|
31683
|
+
if (!response.ok) throw refusal(response, text);
|
|
31684
|
+
parseAckSuccess(
|
|
31685
|
+
successBody(response, text, "delivery observation"),
|
|
31686
|
+
{
|
|
31687
|
+
signalId: request.signalId.toLowerCase(),
|
|
31688
|
+
outcome: "observed"
|
|
31689
|
+
}
|
|
31690
|
+
);
|
|
31691
|
+
return {
|
|
31692
|
+
httpStatus: response.status,
|
|
31693
|
+
signalId: request.signalId.toLowerCase(),
|
|
31694
|
+
outcome: "observed"
|
|
31695
|
+
};
|
|
31696
|
+
}
|
|
31697
|
+
};
|
|
31698
|
+
|
|
31699
|
+
// src/cloud/agent-signal-receipts.ts
|
|
31700
|
+
var AGENT_SEEN_BATCH_MAX = 50;
|
|
31701
|
+
var AGENT_SEEN_TIMEOUT_MS = 5e3;
|
|
31702
|
+
var AgentSeenReportError = class extends Error {
|
|
31703
|
+
constructor(code, message, status = null) {
|
|
31704
|
+
super(message);
|
|
31705
|
+
this.code = code;
|
|
31706
|
+
this.status = status;
|
|
31707
|
+
this.name = "AgentSeenReportError";
|
|
31708
|
+
}
|
|
31709
|
+
code;
|
|
31710
|
+
status;
|
|
31711
|
+
};
|
|
31712
|
+
function renderedBroadcastIds(rows3) {
|
|
31713
|
+
return [...new Set(rows3.filter(
|
|
31714
|
+
(row) => row.to === null && row.to_agent === null
|
|
31715
|
+
).map((row) => row.id))];
|
|
31716
|
+
}
|
|
31717
|
+
function agentSeenBatches(ids) {
|
|
31718
|
+
const unique = [...new Set(ids)];
|
|
31719
|
+
const batches = [];
|
|
31720
|
+
for (let offset = 0; offset < unique.length; offset += AGENT_SEEN_BATCH_MAX) {
|
|
31721
|
+
batches.push(unique.slice(offset, offset + AGENT_SEEN_BATCH_MAX));
|
|
31722
|
+
}
|
|
31723
|
+
return batches;
|
|
31724
|
+
}
|
|
31725
|
+
async function postAgentSeenBatch(target2, token, workspaceId2, signalIds, fetcher) {
|
|
31726
|
+
const controller = new AbortController();
|
|
31727
|
+
const timer2 = setTimeout(() => controller.abort(), AGENT_SEEN_TIMEOUT_MS);
|
|
31728
|
+
let response;
|
|
31729
|
+
try {
|
|
31730
|
+
response = await fetcher(commandEndpoint(target2), {
|
|
31731
|
+
method: "POST",
|
|
31732
|
+
headers: {
|
|
31733
|
+
authorization: `Bearer ${token}`,
|
|
31734
|
+
apikey: target2.anonKey,
|
|
31735
|
+
"content-type": "application/json"
|
|
31736
|
+
},
|
|
31737
|
+
body: JSON.stringify({
|
|
31738
|
+
command_id: newCommandId(),
|
|
31739
|
+
client_version: CLIENT_PROTOCOL_VERSION,
|
|
31740
|
+
workspace_id: workspaceId2,
|
|
31741
|
+
stream: { kind: "workspace" },
|
|
31742
|
+
command: { kind: "signals_seen", signal_ids: signalIds }
|
|
31743
|
+
}),
|
|
31744
|
+
signal: controller.signal
|
|
31745
|
+
});
|
|
31746
|
+
} catch {
|
|
31747
|
+
throw new AgentSeenReportError(
|
|
31748
|
+
"transport",
|
|
31749
|
+
"agent seen report did not reach the command service"
|
|
31750
|
+
);
|
|
31751
|
+
} finally {
|
|
31752
|
+
clearTimeout(timer2);
|
|
31753
|
+
}
|
|
31754
|
+
if (!response.ok) {
|
|
31755
|
+
throw new AgentSeenReportError(
|
|
31756
|
+
"http",
|
|
31757
|
+
`agent seen report was refused with HTTP ${response.status}`,
|
|
31758
|
+
response.status
|
|
31759
|
+
);
|
|
31760
|
+
}
|
|
31761
|
+
let body;
|
|
31762
|
+
try {
|
|
31763
|
+
body = await response.json();
|
|
31764
|
+
} catch {
|
|
31765
|
+
throw new AgentSeenReportError(
|
|
31766
|
+
"protocol",
|
|
31767
|
+
"agent seen report returned malformed JSON",
|
|
31768
|
+
response.status
|
|
31769
|
+
);
|
|
31770
|
+
}
|
|
31771
|
+
if (!body || typeof body !== "object" || Array.isArray(body) || body.ok !== true) {
|
|
31772
|
+
throw new AgentSeenReportError(
|
|
31773
|
+
"protocol",
|
|
31774
|
+
"agent seen report returned a malformed acknowledgement",
|
|
31775
|
+
response.status
|
|
31776
|
+
);
|
|
31777
|
+
}
|
|
31778
|
+
}
|
|
31779
|
+
async function reportRenderedBroadcasts(target2, token, workspaceId2, signalIds, fetcher = fetch) {
|
|
31780
|
+
const batches = agentSeenBatches(signalIds);
|
|
31781
|
+
const failures = [];
|
|
31782
|
+
let reported = 0;
|
|
31783
|
+
for (const batch of batches) {
|
|
31784
|
+
try {
|
|
31785
|
+
await postAgentSeenBatch(target2, token, workspaceId2, batch, fetcher);
|
|
31786
|
+
reported += batch.length;
|
|
31787
|
+
} catch (error) {
|
|
31788
|
+
failures.push(
|
|
31789
|
+
error instanceof AgentSeenReportError ? error.code : "transport"
|
|
31790
|
+
);
|
|
31791
|
+
}
|
|
31792
|
+
}
|
|
31793
|
+
return { attempted: new Set(signalIds).size, reported, failures };
|
|
31794
|
+
}
|
|
31795
|
+
|
|
31796
|
+
// src/host/opencode.ts
|
|
31797
|
+
var import_node_child_process3 = require("node:child_process");
|
|
31798
|
+
var import_node_crypto12 = require("node:crypto");
|
|
31799
|
+
|
|
31800
|
+
// src/host/credential-redaction.ts
|
|
31801
|
+
var EXOTIC_SEPARATORS = "\\u00a0\\u1680\\u2000-\\u200d\\u2028\\u2029\\u202a-\\u202e\\u2060\\u2066-\\u2069\\u202f\\u205f\\u3000\\ufeff";
|
|
31802
|
+
var SEPARATOR_CLASS_SOURCE = "\\t\\n\\x0b\\f\\r " + EXOTIC_SEPARATORS;
|
|
31803
|
+
var ANSI_ESCAPE_GLOBAL_RE2 = new RegExp("\\u001b\\[[0-?]*[ -\\/]*[@-~]", "g");
|
|
31804
|
+
var CONTROL_AND_SEPARATOR_STRIP_RE = new RegExp(
|
|
31805
|
+
"[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f" + EXOTIC_SEPARATORS + "]",
|
|
31806
|
+
"g"
|
|
31807
|
+
);
|
|
31808
|
+
var CREDENTIAL_PREFIX_RE = new RegExp(
|
|
31809
|
+
`swm_(?:agt|inv|cap)_[^${SEPARATOR_CLASS_SOURCE}]*`,
|
|
31810
|
+
"gi"
|
|
31811
|
+
);
|
|
31812
|
+
function redactCredentialText(value) {
|
|
31813
|
+
return value.replace(ANSI_ESCAPE_GLOBAL_RE2, "").replace(CONTROL_AND_SEPARATOR_STRIP_RE, "").replace(CREDENTIAL_PREFIX_RE, "[redacted-credential]");
|
|
31814
|
+
}
|
|
31815
|
+
|
|
31816
|
+
// src/host/stderr-tail.ts
|
|
31817
|
+
var RING_CAPACITY_BYTES = 4096;
|
|
31818
|
+
var TAIL_MAX_CHARS = 2048;
|
|
31819
|
+
var STDERR_EXIT_GRACE_MS = 100;
|
|
31820
|
+
var STDERR_READABLE_END_GRACE_MS = STDERR_EXIT_GRACE_MS + 50;
|
|
31821
|
+
function sanitizeStderrTail(raw) {
|
|
31822
|
+
return redactCredentialText(raw).slice(-TAIL_MAX_CHARS).trim();
|
|
31823
|
+
}
|
|
31824
|
+
function attachStderrTailRing(stderr) {
|
|
31825
|
+
const chunks = [];
|
|
31826
|
+
let total = 0;
|
|
31827
|
+
let evicted = false;
|
|
31828
|
+
stderr.on("data", (chunk) => {
|
|
31211
31829
|
const buffer2 = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
31212
31830
|
chunks.push(buffer2);
|
|
31213
31831
|
total += buffer2.length;
|
|
@@ -33898,7 +34516,7 @@ async function resolveBudgetAndPrompt(session, prompt, budget) {
|
|
|
33898
34516
|
}
|
|
33899
34517
|
|
|
33900
34518
|
// src/listener/engine.ts
|
|
33901
|
-
var
|
|
34519
|
+
var UUID_RE14 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
33902
34520
|
var TERMINAL_STATES = /* @__PURE__ */ new Set(["done", "expired", "failed"]);
|
|
33903
34521
|
var REPLY_MAX_CODE_UNITS = 2e3;
|
|
33904
34522
|
var TRUNCATION_SUFFIX = "\n[Reply truncated by CommonSwarm]";
|
|
@@ -33906,7 +34524,7 @@ var UNSAFE_CONTROLS_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u
|
|
|
33906
34524
|
var LISTENER_MAX_PROMPT_ATTEMPTS = 3;
|
|
33907
34525
|
var LISTENER_MAX_POST_ATTEMPTS = 5;
|
|
33908
34526
|
function listenerReplyCommandId(signalId, effectOrdinal = 0) {
|
|
33909
|
-
if (!
|
|
34527
|
+
if (!UUID_RE14.test(signalId)) {
|
|
33910
34528
|
throw new Error("listener signal id must be a UUID");
|
|
33911
34529
|
}
|
|
33912
34530
|
if (!Number.isSafeInteger(effectOrdinal) || effectOrdinal < 0) {
|
|
@@ -34399,7 +35017,7 @@ var import_node_crypto13 = require("node:crypto");
|
|
|
34399
35017
|
var import_node_os6 = require("node:os");
|
|
34400
35018
|
var import_node_path9 = require("node:path");
|
|
34401
35019
|
var import_node_util = require("node:util");
|
|
34402
|
-
var
|
|
35020
|
+
var UUID_RE15 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
34403
35021
|
var COMMAND_ID_RE2 = /^[A-Za-z0-9_-]{8,72}$/;
|
|
34404
35022
|
var MAX_EFFECT_BYTES = 1024 * 1024;
|
|
34405
35023
|
var STATES = /* @__PURE__ */ new Set([
|
|
@@ -34449,7 +35067,7 @@ function defaultListenerStateDirectory() {
|
|
|
34449
35067
|
return process.env.XDG_STATE_HOME ? (0, import_node_path9.join)(process.env.XDG_STATE_HOME, "cswarm", "listeners") : (0, import_node_path9.join)((0, import_node_os6.homedir)(), ".cswarm", "listeners");
|
|
34450
35068
|
}
|
|
34451
35069
|
function listenerInstanceKey(input) {
|
|
34452
|
-
if (!
|
|
35070
|
+
if (!UUID_RE15.test(input.workspaceId) || !UUID_RE15.test(input.principalId)) {
|
|
34453
35071
|
throw new Error("listener workspace and principal ids must be UUIDs");
|
|
34454
35072
|
}
|
|
34455
35073
|
if (!input.profileId || input.profileId.includes("\0")) {
|
|
@@ -34482,7 +35100,7 @@ function parseListenerEffectRecord(raw, expectedId) {
|
|
|
34482
35100
|
}
|
|
34483
35101
|
const row = value;
|
|
34484
35102
|
rejectSensitiveKeys(row);
|
|
34485
|
-
if (typeof row.version !== "number" || row.version !== 1 && row.version !== 2 || typeof row.signalId !== "string" || row.signalId.toLowerCase() !== expectedId || !
|
|
35103
|
+
if (typeof row.version !== "number" || row.version !== 1 && row.version !== 2 || typeof row.signalId !== "string" || row.signalId.toLowerCase() !== expectedId || !UUID_RE15.test(row.signalId)) {
|
|
34486
35104
|
throw new Error("stored listener effect is malformed");
|
|
34487
35105
|
}
|
|
34488
35106
|
if (row.version === 1) {
|
|
@@ -34497,7 +35115,7 @@ function upcastV1Ask(row) {
|
|
|
34497
35115
|
if (row.effectOrdinal !== 0 || typeof row.commandId !== "string" || !COMMAND_ID_RE2.test(row.commandId) || typeof row.askBody !== "string" || row.askBody.length < 1 || typeof row.askUntil !== "string" || !Number.isFinite(Date.parse(row.askUntil)) || typeof row.senderOwnerRelation !== "string" || !RELATIONS.has(row.senderOwnerRelation) || typeof row.state !== "string" || !STATES.has(row.state) || !integer(row.promptAttempts) || !integer(row.postAttempts) || !nullableString2(row.replyBody, 2e3) || typeof row.replyTruncated !== "boolean" || !nullableString2(row.replySignalId, 64) || !nullableString2(row.failureCode, 96) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt))) {
|
|
34498
35116
|
throw new Error("stored listener effect is malformed");
|
|
34499
35117
|
}
|
|
34500
|
-
if (row.replySignalId !== null && !
|
|
35118
|
+
if (row.replySignalId !== null && !UUID_RE15.test(row.replySignalId)) {
|
|
34501
35119
|
throw new Error("stored listener effect is malformed");
|
|
34502
35120
|
}
|
|
34503
35121
|
return {
|
|
@@ -34536,7 +35154,7 @@ function parseV2Record(row) {
|
|
|
34536
35154
|
if (typeof row.commandId !== "string" || !COMMAND_ID_RE2.test(row.commandId) || row.state === "observed") {
|
|
34537
35155
|
throw new Error("stored listener effect is malformed");
|
|
34538
35156
|
}
|
|
34539
|
-
if (row.replySignalId !== null && !
|
|
35157
|
+
if (row.replySignalId !== null && !UUID_RE15.test(row.replySignalId)) {
|
|
34540
35158
|
throw new Error("stored listener effect is malformed");
|
|
34541
35159
|
}
|
|
34542
35160
|
}
|
|
@@ -34560,7 +35178,7 @@ function parseV2Record(row) {
|
|
|
34560
35178
|
};
|
|
34561
35179
|
}
|
|
34562
35180
|
function newObservedNoteRecord(input) {
|
|
34563
|
-
if (!
|
|
35181
|
+
if (!UUID_RE15.test(input.signalId)) {
|
|
34564
35182
|
throw new Error("listener note signal id must be a UUID");
|
|
34565
35183
|
}
|
|
34566
35184
|
if (input.body.length < 1) {
|
|
@@ -34694,7 +35312,7 @@ var FileListenerEffectStore = class {
|
|
|
34694
35312
|
);
|
|
34695
35313
|
}
|
|
34696
35314
|
checkedId(signalId) {
|
|
34697
|
-
if (!
|
|
35315
|
+
if (!UUID_RE15.test(signalId)) {
|
|
34698
35316
|
throw new Error("listener signal id must be a UUID");
|
|
34699
35317
|
}
|
|
34700
35318
|
return signalId.toLowerCase();
|
|
@@ -35626,887 +36244,306 @@ var ClaudeListenerModel = class {
|
|
|
35626
36244
|
this.workerCanary = true;
|
|
35627
36245
|
const permissionCallback = (request) => this.workerCanary || this.permissionMode === "deny" ? defaultPermissionCallback(request) : allowOnceOrDeny(request);
|
|
35628
36246
|
try {
|
|
35629
|
-
const handle = await this.openSession({
|
|
35630
|
-
cwd: this.options.cwd,
|
|
35631
|
-
permissionCallback,
|
|
35632
|
-
...this.options.executable ? { executable: this.options.executable } : {},
|
|
35633
|
-
...this.options.env ? { env: this.options.env } : {},
|
|
35634
|
-
...this.options.onVersionNotice ? { onVersionNotice: this.options.onVersionNotice } : {},
|
|
35635
|
-
...this.options.onRuntimeNotice ? { onRuntimeNotice: this.options.onRuntimeNotice } : {},
|
|
35636
|
-
...this.options.events ? { events: this.options.events } : {},
|
|
35637
|
-
signal: controller.signal,
|
|
35638
|
-
...this.options.onWorkerStderrTail ? { onStderrTail: this.options.onWorkerStderrTail } : {},
|
|
35639
|
-
clientName: "cswarm-listener"
|
|
35640
|
-
});
|
|
35641
|
-
this.openingHandle = handle;
|
|
35642
|
-
try {
|
|
35643
|
-
if (this.closed) throw new ClaudeListenerClosedDuringOpen();
|
|
35644
|
-
await this.enablePromptsAfterClaudeCanary(handle);
|
|
35645
|
-
if (this.closed) throw new ClaudeListenerClosedDuringOpen();
|
|
35646
|
-
this.workerCanary = false;
|
|
35647
|
-
this.worker = handle;
|
|
35648
|
-
return handle;
|
|
35649
|
-
} catch (error) {
|
|
35650
|
-
await handle.close();
|
|
35651
|
-
throw error;
|
|
35652
|
-
} finally {
|
|
35653
|
-
if (this.openingHandle === handle) this.openingHandle = null;
|
|
35654
|
-
}
|
|
35655
|
-
} finally {
|
|
35656
|
-
if (this.openingController === controller) this.openingController = null;
|
|
35657
|
-
}
|
|
35658
|
-
}
|
|
35659
|
-
/** Force Claude's measured Write permission path without changing worker cwd. */
|
|
35660
|
-
async enablePromptsAfterClaudeCanary(handle) {
|
|
35661
|
-
const sentinelPath = (0, import_node_path13.join)(
|
|
35662
|
-
(0, import_node_os8.tmpdir)(),
|
|
35663
|
-
`cswarm-claude-permission-canary-${process.pid}-${(0, import_node_crypto16.randomUUID)()}`
|
|
35664
|
-
);
|
|
35665
|
-
let canaryError;
|
|
35666
|
-
let sentinelCreated = false;
|
|
35667
|
-
try {
|
|
35668
|
-
await handle.session.enablePromptsAfterCanary({
|
|
35669
|
-
timeoutMs: ACP_CANARY_TIMEOUT_MS,
|
|
35670
|
-
probeText: `Create the file ${sentinelPath} using the Write tool with content CSWARM_CANARY_NOOP. You must use the Write tool. Do nothing else.`,
|
|
35671
|
-
...this.options.onCanaryAttempt ? { onAttempt: this.options.onCanaryAttempt } : {}
|
|
35672
|
-
});
|
|
35673
|
-
} catch (error) {
|
|
35674
|
-
canaryError = error;
|
|
35675
|
-
} finally {
|
|
35676
|
-
try {
|
|
35677
|
-
await (0, import_promises7.lstat)(sentinelPath);
|
|
35678
|
-
sentinelCreated = true;
|
|
35679
|
-
await (0, import_promises7.unlink)(sentinelPath);
|
|
35680
|
-
} catch (error) {
|
|
35681
|
-
if (error.code !== "ENOENT") throw error;
|
|
35682
|
-
}
|
|
35683
|
-
}
|
|
35684
|
-
if (sentinelCreated) {
|
|
35685
|
-
throw new AcpPermissionCanaryError(
|
|
35686
|
-
"Claude bridge wrote the permission canary sentinel before denial",
|
|
35687
|
-
"claude_canary_write_not_blocked"
|
|
35688
|
-
);
|
|
35689
|
-
}
|
|
35690
|
-
if (canaryError instanceof AcpPermissionCanaryError) {
|
|
35691
|
-
const shape = classifyClaudeCanaryFailure(
|
|
35692
|
-
canaryError.message,
|
|
35693
|
-
canaryError.reasonCode,
|
|
35694
|
-
canaryError.peerError
|
|
35695
|
-
);
|
|
35696
|
-
throw new AcpPermissionCanaryError(
|
|
35697
|
-
canaryError.message,
|
|
35698
|
-
shape.code,
|
|
35699
|
-
shape.minimumRequiredVersion
|
|
35700
|
-
);
|
|
35701
|
-
}
|
|
35702
|
-
if (canaryError !== void 0) throw canaryError;
|
|
35703
|
-
}
|
|
35704
|
-
};
|
|
35705
|
-
|
|
35706
|
-
// src/listener/codex-model.ts
|
|
35707
|
-
var import_node_crypto17 = require("node:crypto");
|
|
35708
|
-
var import_promises8 = require("node:fs/promises");
|
|
35709
|
-
var import_node_os9 = require("node:os");
|
|
35710
|
-
var import_node_path14 = require("node:path");
|
|
35711
|
-
var CodexListenerClosedDuringOpen = class extends Error {
|
|
35712
|
-
constructor() {
|
|
35713
|
-
super("listener model closed while the Codex worker was opening");
|
|
35714
|
-
this.name = "CodexListenerClosedDuringOpen";
|
|
35715
|
-
}
|
|
35716
|
-
};
|
|
35717
|
-
function pathIsInsideOrEqual(ancestor, candidate) {
|
|
35718
|
-
const fromAncestor = (0, import_node_path14.relative)(ancestor, candidate);
|
|
35719
|
-
return fromAncestor === "" || fromAncestor !== ".." && !fromAncestor.startsWith(`..${import_node_path14.sep}`) && !(0, import_node_path14.isAbsolute)(fromAncestor);
|
|
35720
|
-
}
|
|
35721
|
-
var CodexListenerModel = class {
|
|
35722
|
-
constructor(options) {
|
|
35723
|
-
this.options = options;
|
|
35724
|
-
this.openSession = options.open ?? openCodexAcpSession;
|
|
35725
|
-
this.permissionMode = options.permissionMode ?? "deny";
|
|
35726
|
-
}
|
|
35727
|
-
options;
|
|
35728
|
-
openSession;
|
|
35729
|
-
permissionMode;
|
|
35730
|
-
worker = null;
|
|
35731
|
-
opening = null;
|
|
35732
|
-
openingController = null;
|
|
35733
|
-
openingHandle = null;
|
|
35734
|
-
workerCanary = true;
|
|
35735
|
-
closed = false;
|
|
35736
|
-
closePromise = null;
|
|
35737
|
-
/** Initialize the worker and deny canary before reporting ready. */
|
|
35738
|
-
async start() {
|
|
35739
|
-
await this.ensureWorker();
|
|
35740
|
-
}
|
|
35741
|
-
async prompt(_signal, _mode, prompt) {
|
|
35742
|
-
if (this.closed) throw new Error("listener model is closed");
|
|
35743
|
-
const worker = await this.ensureWorker();
|
|
35744
|
-
const budget = this.options.promptTimeoutMs ?? LISTENER_PROMPT_TIMEOUT_MS;
|
|
35745
|
-
try {
|
|
35746
|
-
return await resolveBudgetAndPrompt(worker.session, prompt, budget);
|
|
35747
|
-
} catch (error) {
|
|
35748
|
-
if (error instanceof AcpChildExitError) {
|
|
35749
|
-
try {
|
|
35750
|
-
await worker.close();
|
|
35751
|
-
} finally {
|
|
35752
|
-
if (this.worker === worker) this.worker = null;
|
|
35753
|
-
}
|
|
35754
|
-
}
|
|
35755
|
-
throw error;
|
|
35756
|
-
}
|
|
35757
|
-
}
|
|
35758
|
-
cancel() {
|
|
35759
|
-
this.worker?.session.cancel();
|
|
35760
|
-
}
|
|
35761
|
-
async close() {
|
|
35762
|
-
if (this.closePromise) return this.closePromise;
|
|
35763
|
-
this.closed = true;
|
|
35764
|
-
this.cancel();
|
|
35765
|
-
this.closePromise = (async () => {
|
|
35766
|
-
const closeFailures = [];
|
|
35767
|
-
const opening = this.opening;
|
|
35768
|
-
this.openingController?.abort();
|
|
35769
|
-
const openingHandle = this.openingHandle;
|
|
35770
|
-
if (openingHandle) {
|
|
35771
|
-
try {
|
|
35772
|
-
openingHandle.session.cancel();
|
|
35773
|
-
} catch {
|
|
35774
|
-
}
|
|
35775
|
-
try {
|
|
35776
|
-
await openingHandle.close();
|
|
35777
|
-
} catch (error) {
|
|
35778
|
-
closeFailures.push(error);
|
|
35779
|
-
}
|
|
35780
|
-
}
|
|
35781
|
-
if (opening) {
|
|
35782
|
-
try {
|
|
35783
|
-
await opening;
|
|
35784
|
-
} catch (error) {
|
|
35785
|
-
const code = error.code;
|
|
35786
|
-
if (!(error instanceof CodexListenerClosedDuringOpen) && code !== "cancelled" && !openingHandle) {
|
|
35787
|
-
throw error;
|
|
35788
|
-
}
|
|
35789
|
-
}
|
|
35790
|
-
}
|
|
35791
|
-
const handle = this.worker;
|
|
35792
|
-
this.worker = null;
|
|
35793
|
-
if (handle && handle !== openingHandle) {
|
|
35794
|
-
try {
|
|
35795
|
-
await handle.close();
|
|
35796
|
-
} catch (error) {
|
|
35797
|
-
closeFailures.push(error);
|
|
35798
|
-
}
|
|
35799
|
-
}
|
|
35800
|
-
if (closeFailures.length > 0) throw closeFailures[0];
|
|
35801
|
-
})();
|
|
35802
|
-
return this.closePromise;
|
|
35803
|
-
}
|
|
35804
|
-
async ensureWorker() {
|
|
35805
|
-
if (this.closed) throw new Error("listener model is closed");
|
|
35806
|
-
if (this.worker) return this.worker;
|
|
35807
|
-
if (this.opening) return this.opening;
|
|
35808
|
-
const opening = this.openWorker();
|
|
35809
|
-
this.opening = opening;
|
|
35810
|
-
try {
|
|
35811
|
-
return await opening;
|
|
35812
|
-
} finally {
|
|
35813
|
-
if (this.opening === opening) this.opening = null;
|
|
35814
|
-
}
|
|
35815
|
-
}
|
|
35816
|
-
async openWorker() {
|
|
35817
|
-
const controller = new AbortController();
|
|
35818
|
-
this.openingController = controller;
|
|
35819
|
-
this.workerCanary = true;
|
|
35820
|
-
const permissionCallback = (request) => this.workerCanary || this.permissionMode === "deny" ? defaultPermissionCallback(request) : allowOnceOrDeny(request);
|
|
35821
|
-
try {
|
|
35822
|
-
const handle = await this.openSession({
|
|
35823
|
-
cwd: this.options.cwd,
|
|
35824
|
-
permissionCallback,
|
|
35825
|
-
...this.options.executable ? { executable: this.options.executable } : {},
|
|
35826
|
-
...this.options.env ? { env: this.options.env } : {},
|
|
35827
|
-
...this.options.onVersionNotice ? { onVersionNotice: this.options.onVersionNotice } : {},
|
|
35828
|
-
...this.options.events ? { events: this.options.events } : {},
|
|
35829
|
-
signal: controller.signal,
|
|
35830
|
-
...this.options.onWorkerStderrTail ? { onStderrTail: this.options.onWorkerStderrTail } : {},
|
|
35831
|
-
clientName: "cswarm-listener"
|
|
35832
|
-
});
|
|
35833
|
-
this.openingHandle = handle;
|
|
35834
|
-
try {
|
|
35835
|
-
if (this.closed) throw new CodexListenerClosedDuringOpen();
|
|
35836
|
-
await this.enablePromptsAfterCodexCanary(handle);
|
|
35837
|
-
if (this.closed) throw new CodexListenerClosedDuringOpen();
|
|
35838
|
-
this.workerCanary = false;
|
|
35839
|
-
this.worker = handle;
|
|
35840
|
-
return handle;
|
|
35841
|
-
} catch (error) {
|
|
35842
|
-
await handle.close();
|
|
35843
|
-
throw error;
|
|
35844
|
-
} finally {
|
|
35845
|
-
if (this.openingHandle === handle) this.openingHandle = null;
|
|
35846
|
-
}
|
|
35847
|
-
} finally {
|
|
35848
|
-
if (this.openingController === controller) this.openingController = null;
|
|
35849
|
-
}
|
|
35850
|
-
}
|
|
35851
|
-
/** Force Codex's measured shell permission path without changing worker cwd. */
|
|
35852
|
-
async enablePromptsAfterCodexCanary(handle) {
|
|
35853
|
-
const configuredHome = this.options.env?.HOME;
|
|
35854
|
-
const home = configuredHome && (0, import_node_path14.isAbsolute)(configuredHome) ? configuredHome : (0, import_node_os9.homedir)();
|
|
35855
|
-
const sentinelDirectory = (0, import_node_path14.join)(home, ".cswarm", "canary");
|
|
35856
|
-
await (0, import_promises8.mkdir)(sentinelDirectory, { recursive: true, mode: 448 });
|
|
35857
|
-
await (0, import_promises8.chmod)(sentinelDirectory, 448);
|
|
35858
|
-
const [workerCwd, canaryDirectory] = await Promise.all([
|
|
35859
|
-
(0, import_promises8.realpath)(this.options.cwd),
|
|
35860
|
-
(0, import_promises8.realpath)(sentinelDirectory)
|
|
35861
|
-
]);
|
|
35862
|
-
if (pathIsInsideOrEqual(workerCwd, canaryDirectory)) {
|
|
35863
|
-
throw new AcpPermissionCanaryError(
|
|
35864
|
-
`canary_path_inside_cwd: ${canaryDirectory} is inside listener cwd ${workerCwd}. Next: pass a --cwd that is not your home directory`
|
|
35865
|
-
);
|
|
35866
|
-
}
|
|
35867
|
-
const sentinelPath = (0, import_node_path14.join)(
|
|
35868
|
-
canaryDirectory,
|
|
35869
|
-
`cswarm-codex-permission-canary-${process.pid}-${(0, import_node_crypto17.randomUUID)()}`
|
|
35870
|
-
);
|
|
35871
|
-
let canaryError;
|
|
35872
|
-
let sentinelCreated = false;
|
|
35873
|
-
try {
|
|
35874
|
-
await handle.session.enablePromptsAfterCanary({
|
|
35875
|
-
timeoutMs: ACP_CANARY_TIMEOUT_MS,
|
|
35876
|
-
probeText: `Use a shell command to create ${sentinelPath} with content CSWARM_CANARY_NOOP. You must use the shell. Do nothing else.`,
|
|
35877
|
-
...this.options.onCanaryAttempt ? { onAttempt: this.options.onCanaryAttempt } : {}
|
|
35878
|
-
});
|
|
35879
|
-
} catch (error) {
|
|
35880
|
-
canaryError = error;
|
|
35881
|
-
} finally {
|
|
35882
|
-
try {
|
|
35883
|
-
await (0, import_promises8.lstat)(sentinelPath);
|
|
35884
|
-
sentinelCreated = true;
|
|
35885
|
-
await (0, import_promises8.unlink)(sentinelPath);
|
|
35886
|
-
} catch (error) {
|
|
35887
|
-
if (error.code !== "ENOENT") throw error;
|
|
35888
|
-
}
|
|
35889
|
-
}
|
|
35890
|
-
const observation = handle.session.canaryObservation;
|
|
35891
|
-
const sawPermissionRequest = observation?.sawPermissionRequest === true;
|
|
35892
|
-
const bridgeVersion = handle.providerVersion ?? handle.session.info?.agentVersion ?? "unknown";
|
|
35893
|
-
if (sentinelCreated && !sawPermissionRequest) {
|
|
35894
|
-
throw new AcpPermissionCanaryError(
|
|
35895
|
-
`canary_executed_without_permission: codex-acp ${bridgeVersion} ran the shell probe without a permission request and wrote ${sentinelPath}. Next: replace codex-acp ${bridgeVersion} with a bridge version that asks before writing ${sentinelPath}`
|
|
35896
|
-
);
|
|
35897
|
-
}
|
|
35898
|
-
if (sentinelCreated) {
|
|
35899
|
-
throw new AcpPermissionCanaryError(
|
|
35900
|
-
`canary_write_not_blocked: codex-acp ${bridgeVersion} wrote ${sentinelPath} even though the host rejected the canary. Next: update or reinstall the codex-acp bridge`
|
|
35901
|
-
);
|
|
35902
|
-
}
|
|
35903
|
-
if (canaryError instanceof AcpPermissionCanaryError) {
|
|
35904
|
-
if (canaryError.reasonCode === "timeout") {
|
|
35905
|
-
throw new AcpPermissionCanaryError(
|
|
35906
|
-
`canary_timeout: ${canaryError.message}. Next: retry to run a fresh bounded permission canary`,
|
|
35907
|
-
"timeout"
|
|
35908
|
-
);
|
|
35909
|
-
}
|
|
35910
|
-
if (canaryError.reasonCode !== null) {
|
|
35911
|
-
throw new AcpPermissionCanaryError(
|
|
35912
|
-
`canary_bridge_error: codex-acp ${bridgeVersion} returned ${canaryError.message}. Next: resolve the quoted bridge error, then retry`,
|
|
35913
|
-
canaryError.reasonCode
|
|
35914
|
-
);
|
|
35915
|
-
}
|
|
35916
|
-
if (!sawPermissionRequest) {
|
|
35917
|
-
throw new AcpPermissionCanaryError(
|
|
35918
|
-
`canary_no_tool_call: codex-acp ${bridgeVersion} did not request permission or create ${sentinelPath}. Next: retry to re-sample the model's shell choice`
|
|
35919
|
-
);
|
|
35920
|
-
}
|
|
35921
|
-
}
|
|
35922
|
-
if (canaryError !== void 0) throw canaryError;
|
|
35923
|
-
}
|
|
35924
|
-
};
|
|
35925
|
-
|
|
35926
|
-
// src/listener/runtime.ts
|
|
35927
|
-
var import_node_crypto18 = require("node:crypto");
|
|
35928
|
-
|
|
35929
|
-
// src/cloud/delivery.ts
|
|
35930
|
-
var UUID_RE15 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
35931
|
-
var RFC3339_TIMESTAMP_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-]\d{2}):(\d{2}))$/i;
|
|
35932
|
-
var DELIVERY_KINDS = /* @__PURE__ */ new Set(["ask", "note"]);
|
|
35933
|
-
var SENDER_OWNER_RELATIONS2 = /* @__PURE__ */ new Set([
|
|
35934
|
-
"same_owner",
|
|
35935
|
-
"cross_owner",
|
|
35936
|
-
"unknown"
|
|
35937
|
-
]);
|
|
35938
|
-
var DELIVERY_ACK_OUTCOMES = /* @__PURE__ */ new Set([
|
|
35939
|
-
"replied",
|
|
35940
|
-
"observed",
|
|
35941
|
-
"queued",
|
|
35942
|
-
"expired",
|
|
35943
|
-
"failed_terminal"
|
|
35944
|
-
]);
|
|
35945
|
-
var DELIVERY_REQUEST_TIMEOUT_MS = 3e4;
|
|
35946
|
-
var COMMAND_ID_VALIDATOR_RE = /^[A-Za-z0-9_-]{8,72}$/;
|
|
35947
|
-
var FAILED_TERMINAL_CODES_SET = /* @__PURE__ */ new Set([
|
|
35948
|
-
"provider_refused",
|
|
35949
|
-
"local_effect_failed",
|
|
35950
|
-
"host_session_failed",
|
|
35951
|
-
"credential_unavailable"
|
|
35952
|
-
]);
|
|
35953
|
-
var SERVER_ERROR_CODES_SET = /* @__PURE__ */ new Set([
|
|
35954
|
-
"unauthenticated",
|
|
35955
|
-
"fresh_auth_required",
|
|
35956
|
-
"invalid_request",
|
|
35957
|
-
"payload_too_large",
|
|
35958
|
-
"forbidden",
|
|
35959
|
-
"delivery_unavailable",
|
|
35960
|
-
"delivery_ack_conflict",
|
|
35961
|
-
"command_id_conflict",
|
|
35962
|
-
"rate_limited",
|
|
35963
|
-
"upgrade_required",
|
|
35964
|
-
"temporarily_unavailable",
|
|
35965
|
-
"internal_error"
|
|
35966
|
-
]);
|
|
35967
|
-
var DELIVERY_FAILED_TERMINAL_CODES = Object.freeze([
|
|
35968
|
-
"provider_refused",
|
|
35969
|
-
"local_effect_failed",
|
|
35970
|
-
"host_session_failed",
|
|
35971
|
-
"credential_unavailable"
|
|
35972
|
-
]);
|
|
35973
|
-
var DELIVERY_SERVER_ERROR_CODES = Object.freeze([
|
|
35974
|
-
"unauthenticated",
|
|
35975
|
-
"fresh_auth_required",
|
|
35976
|
-
"invalid_request",
|
|
35977
|
-
"payload_too_large",
|
|
35978
|
-
"forbidden",
|
|
35979
|
-
"delivery_unavailable",
|
|
35980
|
-
"delivery_ack_conflict",
|
|
35981
|
-
"command_id_conflict",
|
|
35982
|
-
"rate_limited",
|
|
35983
|
-
"upgrade_required",
|
|
35984
|
-
"temporarily_unavailable",
|
|
35985
|
-
"internal_error"
|
|
35986
|
-
]);
|
|
35987
|
-
var DELIVERY_UNKNOWN_ERROR_CODE = "unknown_error";
|
|
35988
|
-
function observationCommandId(signalId) {
|
|
35989
|
-
checkedUuidRequest(signalId, "signalId");
|
|
35990
|
-
return `observe_${signalId.toLowerCase().replaceAll("-", "")}`;
|
|
35991
|
-
}
|
|
35992
|
-
var DeliveryTransportError = class extends Error {
|
|
35993
|
-
constructor(message) {
|
|
35994
|
-
super(message);
|
|
35995
|
-
this.name = "DeliveryTransportError";
|
|
35996
|
-
}
|
|
35997
|
-
};
|
|
35998
|
-
var DeliveryHttpError = class extends Error {
|
|
35999
|
-
constructor(status, code, message, retryAfterMs = null) {
|
|
36000
|
-
super(message);
|
|
36001
|
-
this.status = status;
|
|
36002
|
-
this.code = code;
|
|
36003
|
-
this.retryAfterMs = retryAfterMs;
|
|
36004
|
-
this.name = "DeliveryHttpError";
|
|
36005
|
-
}
|
|
36006
|
-
status;
|
|
36007
|
-
code;
|
|
36008
|
-
retryAfterMs;
|
|
36009
|
-
};
|
|
36010
|
-
var DeliveryProtocolError = class extends Error {
|
|
36011
|
-
constructor(message) {
|
|
36012
|
-
super(message);
|
|
36013
|
-
this.name = "DeliveryProtocolError";
|
|
36014
|
-
}
|
|
36015
|
-
};
|
|
36016
|
-
function checkedUuid3(value, field) {
|
|
36017
|
-
if (typeof value !== "string" || !UUID_RE15.test(value)) {
|
|
36018
|
-
throw new DeliveryProtocolError(
|
|
36019
|
-
`delivery response returned a malformed ${field}`
|
|
36020
|
-
);
|
|
36021
|
-
}
|
|
36022
|
-
return value.toLowerCase();
|
|
36023
|
-
}
|
|
36024
|
-
function isLeapYear(year) {
|
|
36025
|
-
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
36026
|
-
}
|
|
36027
|
-
function daysInMonth(year, month) {
|
|
36028
|
-
switch (month) {
|
|
36029
|
-
case 1:
|
|
36030
|
-
case 3:
|
|
36031
|
-
case 5:
|
|
36032
|
-
case 7:
|
|
36033
|
-
case 8:
|
|
36034
|
-
case 10:
|
|
36035
|
-
case 12:
|
|
36036
|
-
return 31;
|
|
36037
|
-
case 4:
|
|
36038
|
-
case 6:
|
|
36039
|
-
case 9:
|
|
36040
|
-
case 11:
|
|
36041
|
-
return 30;
|
|
36042
|
-
case 2:
|
|
36043
|
-
return isLeapYear(year) ? 29 : 28;
|
|
36044
|
-
default:
|
|
36045
|
-
return 0;
|
|
36046
|
-
}
|
|
36047
|
-
}
|
|
36048
|
-
function checkedRfc3339Timestamp(value, field) {
|
|
36049
|
-
if (typeof value !== "string") {
|
|
36050
|
-
throw new DeliveryProtocolError(
|
|
36051
|
-
`delivery response returned a malformed ${field}`
|
|
36052
|
-
);
|
|
36053
|
-
}
|
|
36054
|
-
const match = RFC3339_TIMESTAMP_RE.exec(value);
|
|
36055
|
-
if (!match) {
|
|
36056
|
-
throw new DeliveryProtocolError(
|
|
36057
|
-
`delivery response returned a malformed ${field}`
|
|
36058
|
-
);
|
|
36059
|
-
}
|
|
36060
|
-
const year = parseInt(match[1], 10);
|
|
36061
|
-
const month = parseInt(match[2], 10);
|
|
36062
|
-
const day = parseInt(match[3], 10);
|
|
36063
|
-
const hour = parseInt(match[4], 10);
|
|
36064
|
-
const minute = parseInt(match[5], 10);
|
|
36065
|
-
const second = parseInt(match[6], 10);
|
|
36066
|
-
if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
|
|
36067
|
-
throw new DeliveryProtocolError(
|
|
36068
|
-
`delivery response returned a malformed ${field}`
|
|
36069
|
-
);
|
|
36070
|
-
}
|
|
36071
|
-
if (match[7] !== void 0 && match[8] !== void 0) {
|
|
36072
|
-
const offsetHour = Math.abs(parseInt(match[7], 10));
|
|
36073
|
-
const offsetMin = parseInt(match[8], 10);
|
|
36074
|
-
if (offsetHour > 23 || offsetMin < 0 || offsetMin > 59) {
|
|
36075
|
-
throw new DeliveryProtocolError(
|
|
36076
|
-
`delivery response returned a malformed ${field}`
|
|
36077
|
-
);
|
|
36078
|
-
}
|
|
36079
|
-
}
|
|
36080
|
-
if (!Number.isFinite(Date.parse(value))) {
|
|
36081
|
-
throw new DeliveryProtocolError(
|
|
36082
|
-
`delivery response returned a malformed ${field}`
|
|
36083
|
-
);
|
|
36084
|
-
}
|
|
36085
|
-
return value;
|
|
36086
|
-
}
|
|
36087
|
-
function checkedLiveLease(leasedUntil, now) {
|
|
36088
|
-
if (Date.parse(leasedUntil) <= now()) {
|
|
36089
|
-
throw new DeliveryProtocolError(
|
|
36090
|
-
"delivery claim response returned an already expired lease"
|
|
36091
|
-
);
|
|
36092
|
-
}
|
|
36093
|
-
}
|
|
36094
|
-
function checkedRelation(value) {
|
|
36095
|
-
if (typeof value !== "string" || !SENDER_OWNER_RELATIONS2.has(value)) {
|
|
36096
|
-
throw new DeliveryProtocolError(
|
|
36097
|
-
"delivery response returned a malformed sender_owner_relation"
|
|
36098
|
-
);
|
|
36099
|
-
}
|
|
36100
|
-
return value;
|
|
36101
|
-
}
|
|
36102
|
-
function checkedNonNegativeCount(value, field) {
|
|
36103
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
36104
|
-
throw new DeliveryProtocolError(
|
|
36105
|
-
`delivery response returned a malformed ${field}`
|
|
36106
|
-
);
|
|
36107
|
-
}
|
|
36108
|
-
return value;
|
|
36109
|
-
}
|
|
36110
|
-
function checkedClaimCapabilities(value) {
|
|
36111
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
36112
|
-
throw new DeliveryProtocolError(
|
|
36113
|
-
"delivery claim response is missing delivery capabilities"
|
|
36114
|
-
);
|
|
36115
|
-
}
|
|
36116
|
-
const row = value;
|
|
36117
|
-
for (const marker of ["delivery_claim", "delivery_ack", "sender_owner_relation"]) {
|
|
36118
|
-
if (row[marker] !== 1) {
|
|
36119
|
-
throw new DeliveryProtocolError(
|
|
36120
|
-
`delivery claim response is missing the ${marker} capability`
|
|
36121
|
-
);
|
|
36122
|
-
}
|
|
36123
|
-
}
|
|
36124
|
-
return { deliveryClaim: true, deliveryAck: true, senderOwnerRelation: true };
|
|
36125
|
-
}
|
|
36126
|
-
function checkedOptionalUuidArray(value, field) {
|
|
36127
|
-
if (value === void 0) return;
|
|
36128
|
-
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !UUID_RE15.test(item))) {
|
|
36129
|
-
throw new DeliveryProtocolError(
|
|
36130
|
-
`delivery response returned a malformed ${field}`
|
|
36131
|
-
);
|
|
36132
|
-
}
|
|
36133
|
-
}
|
|
36134
|
-
function checkedOptionalArray(value, field) {
|
|
36135
|
-
if (value === void 0) return;
|
|
36136
|
-
if (!Array.isArray(value)) {
|
|
36137
|
-
throw new DeliveryProtocolError(
|
|
36138
|
-
`delivery response returned a malformed ${field}`
|
|
36139
|
-
);
|
|
36140
|
-
}
|
|
36141
|
-
}
|
|
36142
|
-
function parseDeliveryRow(value, expected, index, now) {
|
|
36143
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
36144
|
-
throw new DeliveryProtocolError(
|
|
36145
|
-
"delivery claim response returned a malformed delivery row"
|
|
36146
|
-
);
|
|
36147
|
-
}
|
|
36148
|
-
const row = value;
|
|
36149
|
-
let signal;
|
|
36150
|
-
try {
|
|
36151
|
-
signal = parseSignalRecord(row.signal);
|
|
36152
|
-
} catch {
|
|
36153
|
-
throw new DeliveryProtocolError(
|
|
36154
|
-
`delivery claim response returned a malformed signal at ${index}`
|
|
36155
|
-
);
|
|
36156
|
-
}
|
|
36157
|
-
if (signal.workspace_id !== expected.workspaceId) {
|
|
36158
|
-
throw new DeliveryProtocolError(
|
|
36159
|
-
"delivery claim response returned a signal for another workspace"
|
|
36160
|
-
);
|
|
36161
|
-
}
|
|
36162
|
-
if (signal.to_agent !== expected.principalId) {
|
|
36163
|
-
throw new DeliveryProtocolError(
|
|
36164
|
-
"delivery claim response returned a signal addressed to another agent"
|
|
36165
|
-
);
|
|
36166
|
-
}
|
|
36167
|
-
if (!DELIVERY_KINDS.has(signal.kind)) {
|
|
36168
|
-
throw new DeliveryProtocolError(
|
|
36169
|
-
"delivery claim response returned a non-direct signal kind"
|
|
36170
|
-
);
|
|
36171
|
-
}
|
|
36172
|
-
const senderOwnerRelation = checkedRelation(row.sender_owner_relation);
|
|
36173
|
-
const leaseId = checkedUuid3(row.lease_id, "lease_id");
|
|
36174
|
-
const leasedUntil = checkedRfc3339Timestamp(row.leased_until, "leased_until");
|
|
36175
|
-
checkedLiveLease(leasedUntil, now);
|
|
36176
|
-
signal.sender_owner_relation = senderOwnerRelation;
|
|
36177
|
-
return { signal, leaseId, leasedUntil, senderOwnerRelation };
|
|
36178
|
-
}
|
|
36179
|
-
function parseClaimSuccess(body, expected, now) {
|
|
36180
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
36181
|
-
throw new DeliveryProtocolError("delivery claim response was not an object");
|
|
36182
|
-
}
|
|
36183
|
-
const row = body;
|
|
36184
|
-
if (row.status !== "accepted" || row.ok !== true) {
|
|
36185
|
-
throw new DeliveryProtocolError(
|
|
36186
|
-
"delivery claim response did not report accepted ok"
|
|
36187
|
-
);
|
|
36188
|
-
}
|
|
36189
|
-
const capabilities = checkedClaimCapabilities(row.capabilities);
|
|
36190
|
-
checkedOptionalUuidArray(row.event_ids, "event_ids");
|
|
36191
|
-
checkedOptionalArray(row.events, "events");
|
|
36192
|
-
if (!Array.isArray(row.deliveries)) {
|
|
36193
|
-
throw new DeliveryProtocolError(
|
|
36194
|
-
"delivery claim response is missing its deliveries array"
|
|
36195
|
-
);
|
|
36196
|
-
}
|
|
36197
|
-
const deliveries = row.deliveries.map(
|
|
36198
|
-
(item, index) => parseDeliveryRow(item, expected, index, now)
|
|
36199
|
-
);
|
|
36200
|
-
const signalIds = /* @__PURE__ */ new Set();
|
|
36201
|
-
const leaseIds = /* @__PURE__ */ new Set();
|
|
36202
|
-
for (const delivery of deliveries) {
|
|
36203
|
-
if (signalIds.has(delivery.signal.id)) {
|
|
36204
|
-
throw new DeliveryProtocolError(
|
|
36205
|
-
"delivery claim response repeats a signal id"
|
|
36206
|
-
);
|
|
36207
|
-
}
|
|
36208
|
-
signalIds.add(delivery.signal.id);
|
|
36209
|
-
if (leaseIds.has(delivery.leaseId)) {
|
|
36210
|
-
throw new DeliveryProtocolError(
|
|
36211
|
-
"delivery claim response repeats a lease id"
|
|
36212
|
-
);
|
|
36213
|
-
}
|
|
36214
|
-
leaseIds.add(delivery.leaseId);
|
|
36215
|
-
}
|
|
36216
|
-
if (deliveries.length > 1) {
|
|
36217
|
-
throw new DeliveryProtocolError(
|
|
36218
|
-
"delivery claim response returned more than one delivery"
|
|
36219
|
-
);
|
|
36220
|
-
}
|
|
36221
|
-
const pendingDeliveryCount = checkedNonNegativeCount(
|
|
36222
|
-
row.pending_delivery_count,
|
|
36223
|
-
"pending_delivery_count"
|
|
36224
|
-
);
|
|
36225
|
-
const terminalDeliveryFailureCount = checkedNonNegativeCount(
|
|
36226
|
-
row.terminal_delivery_failure_count,
|
|
36227
|
-
"terminal_delivery_failure_count"
|
|
36228
|
-
);
|
|
36229
|
-
if (deliveries.length > pendingDeliveryCount) {
|
|
36230
|
-
throw new DeliveryProtocolError(
|
|
36231
|
-
"delivery claim response returned more deliveries than its pending count"
|
|
36232
|
-
);
|
|
36233
|
-
}
|
|
36234
|
-
return {
|
|
36235
|
-
capabilities,
|
|
36236
|
-
deliveries,
|
|
36237
|
-
pendingDeliveryCount,
|
|
36238
|
-
terminalDeliveryFailureCount
|
|
36239
|
-
};
|
|
36240
|
-
}
|
|
36241
|
-
function parseAckSuccess(body, expected) {
|
|
36242
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
36243
|
-
throw new DeliveryProtocolError(
|
|
36244
|
-
"delivery acknowledgement response was not an object"
|
|
36245
|
-
);
|
|
36246
|
-
}
|
|
36247
|
-
const row = body;
|
|
36248
|
-
if (row.status !== "accepted" || row.ok !== true) {
|
|
36249
|
-
throw new DeliveryProtocolError(
|
|
36250
|
-
"delivery acknowledgement response did not report accepted ok"
|
|
36251
|
-
);
|
|
36252
|
-
}
|
|
36253
|
-
checkedOptionalUuidArray(row.event_ids, "event_ids");
|
|
36254
|
-
checkedOptionalArray(row.events, "events");
|
|
36255
|
-
if (row.signal_id !== expected.signalId) {
|
|
36256
|
-
throw new DeliveryProtocolError(
|
|
36257
|
-
"delivery acknowledgement response echoed a different signal id"
|
|
36258
|
-
);
|
|
36259
|
-
}
|
|
36260
|
-
if (row.outcome !== expected.outcome) {
|
|
36261
|
-
throw new DeliveryProtocolError(
|
|
36262
|
-
"delivery acknowledgement response echoed a different outcome"
|
|
36263
|
-
);
|
|
36264
|
-
}
|
|
36265
|
-
}
|
|
36266
|
-
function checkedCommandId(value) {
|
|
36267
|
-
if (typeof value !== "string" || !COMMAND_ID_VALIDATOR_RE.test(value)) {
|
|
36268
|
-
throw new Error(
|
|
36269
|
-
"a delivery command id must be 8..72 characters of [A-Za-z0-9_-]"
|
|
36270
|
-
);
|
|
36271
|
-
}
|
|
36272
|
-
return value;
|
|
36273
|
-
}
|
|
36274
|
-
function checkedUuidRequest(value, field) {
|
|
36275
|
-
if (!UUID_RE15.test(value)) {
|
|
36276
|
-
throw new Error(`${field} must be a UUID for an agent delivery command`);
|
|
36247
|
+
const handle = await this.openSession({
|
|
36248
|
+
cwd: this.options.cwd,
|
|
36249
|
+
permissionCallback,
|
|
36250
|
+
...this.options.executable ? { executable: this.options.executable } : {},
|
|
36251
|
+
...this.options.env ? { env: this.options.env } : {},
|
|
36252
|
+
...this.options.onVersionNotice ? { onVersionNotice: this.options.onVersionNotice } : {},
|
|
36253
|
+
...this.options.onRuntimeNotice ? { onRuntimeNotice: this.options.onRuntimeNotice } : {},
|
|
36254
|
+
...this.options.events ? { events: this.options.events } : {},
|
|
36255
|
+
signal: controller.signal,
|
|
36256
|
+
...this.options.onWorkerStderrTail ? { onStderrTail: this.options.onWorkerStderrTail } : {},
|
|
36257
|
+
clientName: "cswarm-listener"
|
|
36258
|
+
});
|
|
36259
|
+
this.openingHandle = handle;
|
|
36260
|
+
try {
|
|
36261
|
+
if (this.closed) throw new ClaudeListenerClosedDuringOpen();
|
|
36262
|
+
await this.enablePromptsAfterClaudeCanary(handle);
|
|
36263
|
+
if (this.closed) throw new ClaudeListenerClosedDuringOpen();
|
|
36264
|
+
this.workerCanary = false;
|
|
36265
|
+
this.worker = handle;
|
|
36266
|
+
return handle;
|
|
36267
|
+
} catch (error) {
|
|
36268
|
+
await handle.close();
|
|
36269
|
+
throw error;
|
|
36270
|
+
} finally {
|
|
36271
|
+
if (this.openingHandle === handle) this.openingHandle = null;
|
|
36272
|
+
}
|
|
36273
|
+
} finally {
|
|
36274
|
+
if (this.openingController === controller) this.openingController = null;
|
|
36275
|
+
}
|
|
36277
36276
|
}
|
|
36278
|
-
|
|
36279
|
-
|
|
36280
|
-
|
|
36281
|
-
|
|
36282
|
-
|
|
36283
|
-
checkedUuidRequest(request.signalId, "signalId");
|
|
36284
|
-
checkedUuidRequest(request.leaseId, "leaseId");
|
|
36285
|
-
checkedUuidRequest(request.listenerInstanceId, "listenerInstanceId");
|
|
36286
|
-
if (!DELIVERY_ACK_OUTCOMES.has(request.outcome)) {
|
|
36287
|
-
throw new Error(
|
|
36288
|
-
"a delivery outcome must be replied, observed, queued, expired, or failed_terminal"
|
|
36277
|
+
/** Force Claude's measured Write permission path without changing worker cwd. */
|
|
36278
|
+
async enablePromptsAfterClaudeCanary(handle) {
|
|
36279
|
+
const sentinelPath = (0, import_node_path13.join)(
|
|
36280
|
+
(0, import_node_os8.tmpdir)(),
|
|
36281
|
+
`cswarm-claude-permission-canary-${process.pid}-${(0, import_node_crypto16.randomUUID)()}`
|
|
36289
36282
|
);
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
36293
|
-
|
|
36294
|
-
|
|
36283
|
+
let canaryError;
|
|
36284
|
+
let sentinelCreated = false;
|
|
36285
|
+
try {
|
|
36286
|
+
await handle.session.enablePromptsAfterCanary({
|
|
36287
|
+
timeoutMs: ACP_CANARY_TIMEOUT_MS,
|
|
36288
|
+
probeText: `Create the file ${sentinelPath} using the Write tool with content CSWARM_CANARY_NOOP. You must use the Write tool. Do nothing else.`,
|
|
36289
|
+
...this.options.onCanaryAttempt ? { onAttempt: this.options.onCanaryAttempt } : {}
|
|
36290
|
+
});
|
|
36291
|
+
} catch (error) {
|
|
36292
|
+
canaryError = error;
|
|
36293
|
+
} finally {
|
|
36294
|
+
try {
|
|
36295
|
+
await (0, import_promises7.lstat)(sentinelPath);
|
|
36296
|
+
sentinelCreated = true;
|
|
36297
|
+
await (0, import_promises7.unlink)(sentinelPath);
|
|
36298
|
+
} catch (error) {
|
|
36299
|
+
if (error.code !== "ENOENT") throw error;
|
|
36300
|
+
}
|
|
36301
|
+
}
|
|
36302
|
+
if (sentinelCreated) {
|
|
36303
|
+
throw new AcpPermissionCanaryError(
|
|
36304
|
+
"Claude bridge wrote the permission canary sentinel before denial",
|
|
36305
|
+
"claude_canary_write_not_blocked"
|
|
36295
36306
|
);
|
|
36296
36307
|
}
|
|
36297
|
-
|
|
36298
|
-
|
|
36299
|
-
|
|
36300
|
-
|
|
36301
|
-
|
|
36302
|
-
|
|
36303
|
-
|
|
36304
|
-
|
|
36305
|
-
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
|
|
36309
|
-
|
|
36308
|
+
if (canaryError instanceof AcpPermissionCanaryError) {
|
|
36309
|
+
const shape = classifyClaudeCanaryFailure(
|
|
36310
|
+
canaryError.message,
|
|
36311
|
+
canaryError.reasonCode,
|
|
36312
|
+
canaryError.peerError
|
|
36313
|
+
);
|
|
36314
|
+
throw new AcpPermissionCanaryError(
|
|
36315
|
+
canaryError.message,
|
|
36316
|
+
shape.code,
|
|
36317
|
+
shape.minimumRequiredVersion
|
|
36318
|
+
);
|
|
36319
|
+
}
|
|
36320
|
+
if (canaryError !== void 0) throw canaryError;
|
|
36310
36321
|
}
|
|
36311
|
-
|
|
36312
|
-
|
|
36313
|
-
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36322
|
+
};
|
|
36323
|
+
|
|
36324
|
+
// src/listener/codex-model.ts
|
|
36325
|
+
var import_node_crypto17 = require("node:crypto");
|
|
36326
|
+
var import_promises8 = require("node:fs/promises");
|
|
36327
|
+
var import_node_os9 = require("node:os");
|
|
36328
|
+
var import_node_path14 = require("node:path");
|
|
36329
|
+
var CodexListenerClosedDuringOpen = class extends Error {
|
|
36330
|
+
constructor() {
|
|
36331
|
+
super("listener model closed while the Codex worker was opening");
|
|
36332
|
+
this.name = "CodexListenerClosedDuringOpen";
|
|
36318
36333
|
}
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
`delivery command failed (HTTP ${response.status}): ${code}`,
|
|
36324
|
-
retryAfterMs
|
|
36325
|
-
);
|
|
36334
|
+
};
|
|
36335
|
+
function pathIsInsideOrEqual(ancestor, candidate) {
|
|
36336
|
+
const fromAncestor = (0, import_node_path14.relative)(ancestor, candidate);
|
|
36337
|
+
return fromAncestor === "" || fromAncestor !== ".." && !fromAncestor.startsWith(`..${import_node_path14.sep}`) && !(0, import_node_path14.isAbsolute)(fromAncestor);
|
|
36326
36338
|
}
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
`${verb} response was not JSON (HTTP ${response.status})`
|
|
36333
|
-
);
|
|
36339
|
+
var CodexListenerModel = class {
|
|
36340
|
+
constructor(options) {
|
|
36341
|
+
this.options = options;
|
|
36342
|
+
this.openSession = options.open ?? openCodexAcpSession;
|
|
36343
|
+
this.permissionMode = options.permissionMode ?? "deny";
|
|
36334
36344
|
}
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36341
|
-
|
|
36342
|
-
|
|
36343
|
-
|
|
36345
|
+
options;
|
|
36346
|
+
openSession;
|
|
36347
|
+
permissionMode;
|
|
36348
|
+
worker = null;
|
|
36349
|
+
opening = null;
|
|
36350
|
+
openingController = null;
|
|
36351
|
+
openingHandle = null;
|
|
36352
|
+
workerCanary = true;
|
|
36353
|
+
closed = false;
|
|
36354
|
+
closePromise = null;
|
|
36355
|
+
/** Initialize the worker and deny canary before reporting ready. */
|
|
36356
|
+
async start() {
|
|
36357
|
+
await this.ensureWorker();
|
|
36344
36358
|
}
|
|
36345
|
-
|
|
36346
|
-
|
|
36347
|
-
|
|
36348
|
-
|
|
36349
|
-
clearTimeoutFn;
|
|
36350
|
-
createAbortControllerFn;
|
|
36351
|
-
async post(request, command2, verb) {
|
|
36352
|
-
if (this.deadlineMs <= 0) {
|
|
36353
|
-
throw new DeliveryTransportError(`${verb} request timed out`);
|
|
36354
|
-
}
|
|
36355
|
-
const deadlineController = this.createAbortControllerFn();
|
|
36356
|
-
let timedOut = false;
|
|
36357
|
-
const signal = deadlineController.signal;
|
|
36358
|
-
let onAbort = () => {
|
|
36359
|
-
};
|
|
36360
|
-
const aborted = new Promise((resolve3) => {
|
|
36361
|
-
onAbort = () => resolve3("timeout");
|
|
36362
|
-
if (signal.aborted) {
|
|
36363
|
-
onAbort();
|
|
36364
|
-
} else {
|
|
36365
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
36366
|
-
}
|
|
36367
|
-
});
|
|
36368
|
-
const timer2 = setTimeout(() => {
|
|
36369
|
-
timedOut = true;
|
|
36370
|
-
deadlineController.abort();
|
|
36371
|
-
}, this.deadlineMs);
|
|
36359
|
+
async prompt(_signal, _mode, prompt) {
|
|
36360
|
+
if (this.closed) throw new Error("listener model is closed");
|
|
36361
|
+
const worker = await this.ensureWorker();
|
|
36362
|
+
const budget = this.options.promptTimeoutMs ?? LISTENER_PROMPT_TIMEOUT_MS;
|
|
36372
36363
|
try {
|
|
36373
|
-
|
|
36374
|
-
|
|
36364
|
+
return await resolveBudgetAndPrompt(worker.session, prompt, budget);
|
|
36365
|
+
} catch (error) {
|
|
36366
|
+
if (error instanceof AcpChildExitError) {
|
|
36367
|
+
try {
|
|
36368
|
+
await worker.close();
|
|
36369
|
+
} finally {
|
|
36370
|
+
if (this.worker === worker) this.worker = null;
|
|
36371
|
+
}
|
|
36375
36372
|
}
|
|
36376
|
-
|
|
36377
|
-
|
|
36373
|
+
throw error;
|
|
36374
|
+
}
|
|
36375
|
+
}
|
|
36376
|
+
cancel() {
|
|
36377
|
+
this.worker?.session.cancel();
|
|
36378
|
+
}
|
|
36379
|
+
async close() {
|
|
36380
|
+
if (this.closePromise) return this.closePromise;
|
|
36381
|
+
this.closed = true;
|
|
36382
|
+
this.cancel();
|
|
36383
|
+
this.closePromise = (async () => {
|
|
36384
|
+
const closeFailures = [];
|
|
36385
|
+
const opening = this.opening;
|
|
36386
|
+
this.openingController?.abort();
|
|
36387
|
+
const openingHandle = this.openingHandle;
|
|
36388
|
+
if (openingHandle) {
|
|
36378
36389
|
try {
|
|
36379
|
-
|
|
36380
|
-
|
|
36381
|
-
|
|
36382
|
-
|
|
36383
|
-
|
|
36384
|
-
"content-type": "application/json"
|
|
36385
|
-
},
|
|
36386
|
-
body: JSON.stringify({
|
|
36387
|
-
command_id: request.commandId,
|
|
36388
|
-
client_version: CLIENT_PROTOCOL_VERSION,
|
|
36389
|
-
workspace_id: request.workspaceId.toLowerCase(),
|
|
36390
|
-
stream: { kind: "workspace" },
|
|
36391
|
-
command: command2
|
|
36392
|
-
}),
|
|
36393
|
-
signal
|
|
36394
|
-
});
|
|
36390
|
+
openingHandle.session.cancel();
|
|
36391
|
+
} catch {
|
|
36392
|
+
}
|
|
36393
|
+
try {
|
|
36394
|
+
await openingHandle.close();
|
|
36395
36395
|
} catch (error) {
|
|
36396
|
-
|
|
36397
|
-
|
|
36396
|
+
closeFailures.push(error);
|
|
36397
|
+
}
|
|
36398
|
+
}
|
|
36399
|
+
if (opening) {
|
|
36400
|
+
try {
|
|
36401
|
+
await opening;
|
|
36402
|
+
} catch (error) {
|
|
36403
|
+
const code = error.code;
|
|
36404
|
+
if (!(error instanceof CodexListenerClosedDuringOpen) && code !== "cancelled" && !openingHandle) {
|
|
36405
|
+
throw error;
|
|
36398
36406
|
}
|
|
36399
|
-
throw new DeliveryTransportError(
|
|
36400
|
-
`${verb} request failed before a response`
|
|
36401
|
-
);
|
|
36402
36407
|
}
|
|
36403
|
-
|
|
36404
|
-
|
|
36408
|
+
}
|
|
36409
|
+
const handle = this.worker;
|
|
36410
|
+
this.worker = null;
|
|
36411
|
+
if (handle && handle !== openingHandle) {
|
|
36405
36412
|
try {
|
|
36406
|
-
|
|
36407
|
-
} catch {
|
|
36408
|
-
|
|
36409
|
-
throw new DeliveryTransportError(
|
|
36410
|
-
`${verb} response body was interrupted`
|
|
36411
|
-
);
|
|
36413
|
+
await handle.close();
|
|
36414
|
+
} catch (error) {
|
|
36415
|
+
closeFailures.push(error);
|
|
36412
36416
|
}
|
|
36413
|
-
if (signal.aborted || timedOut) return "timeout";
|
|
36414
|
-
return { response, text };
|
|
36415
|
-
})();
|
|
36416
|
-
const raced = await Promise.race([read, aborted]);
|
|
36417
|
-
if (raced === "timeout") {
|
|
36418
|
-
throw new DeliveryTransportError(`${verb} request timed out`);
|
|
36419
36417
|
}
|
|
36420
|
-
|
|
36418
|
+
if (closeFailures.length > 0) throw closeFailures[0];
|
|
36419
|
+
})();
|
|
36420
|
+
return this.closePromise;
|
|
36421
|
+
}
|
|
36422
|
+
async ensureWorker() {
|
|
36423
|
+
if (this.closed) throw new Error("listener model is closed");
|
|
36424
|
+
if (this.worker) return this.worker;
|
|
36425
|
+
if (this.opening) return this.opening;
|
|
36426
|
+
const opening = this.openWorker();
|
|
36427
|
+
this.opening = opening;
|
|
36428
|
+
try {
|
|
36429
|
+
return await opening;
|
|
36421
36430
|
} finally {
|
|
36422
|
-
this.
|
|
36423
|
-
signal.removeEventListener("abort", onAbort);
|
|
36431
|
+
if (this.opening === opening) this.opening = null;
|
|
36424
36432
|
}
|
|
36425
36433
|
}
|
|
36426
|
-
|
|
36427
|
-
|
|
36428
|
-
|
|
36429
|
-
|
|
36430
|
-
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36435
|
-
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36444
|
-
|
|
36445
|
-
|
|
36446
|
-
|
|
36447
|
-
|
|
36448
|
-
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
|
|
36453
|
-
|
|
36454
|
-
|
|
36455
|
-
|
|
36456
|
-
async ackAgentDelivery(request) {
|
|
36457
|
-
assertAckRequest(request);
|
|
36458
|
-
const { response, text } = await this.post(request, {
|
|
36459
|
-
kind: "ack_agent_delivery",
|
|
36460
|
-
signal_id: request.signalId.toLowerCase(),
|
|
36461
|
-
lease_id: request.leaseId.toLowerCase(),
|
|
36462
|
-
listener_instance_id: request.listenerInstanceId.toLowerCase(),
|
|
36463
|
-
outcome: request.outcome,
|
|
36464
|
-
last_error_code: request.lastErrorCode
|
|
36465
|
-
}, "delivery acknowledgement");
|
|
36466
|
-
if (!response.ok) throw refusal(response, text);
|
|
36467
|
-
parseAckSuccess(
|
|
36468
|
-
successBody(response, text, "delivery acknowledgement"),
|
|
36469
|
-
{
|
|
36470
|
-
signalId: request.signalId.toLowerCase(),
|
|
36471
|
-
outcome: request.outcome
|
|
36434
|
+
async openWorker() {
|
|
36435
|
+
const controller = new AbortController();
|
|
36436
|
+
this.openingController = controller;
|
|
36437
|
+
this.workerCanary = true;
|
|
36438
|
+
const permissionCallback = (request) => this.workerCanary || this.permissionMode === "deny" ? defaultPermissionCallback(request) : allowOnceOrDeny(request);
|
|
36439
|
+
try {
|
|
36440
|
+
const handle = await this.openSession({
|
|
36441
|
+
cwd: this.options.cwd,
|
|
36442
|
+
permissionCallback,
|
|
36443
|
+
...this.options.executable ? { executable: this.options.executable } : {},
|
|
36444
|
+
...this.options.env ? { env: this.options.env } : {},
|
|
36445
|
+
...this.options.onVersionNotice ? { onVersionNotice: this.options.onVersionNotice } : {},
|
|
36446
|
+
...this.options.events ? { events: this.options.events } : {},
|
|
36447
|
+
signal: controller.signal,
|
|
36448
|
+
...this.options.onWorkerStderrTail ? { onStderrTail: this.options.onWorkerStderrTail } : {},
|
|
36449
|
+
clientName: "cswarm-listener"
|
|
36450
|
+
});
|
|
36451
|
+
this.openingHandle = handle;
|
|
36452
|
+
try {
|
|
36453
|
+
if (this.closed) throw new CodexListenerClosedDuringOpen();
|
|
36454
|
+
await this.enablePromptsAfterCodexCanary(handle);
|
|
36455
|
+
if (this.closed) throw new CodexListenerClosedDuringOpen();
|
|
36456
|
+
this.workerCanary = false;
|
|
36457
|
+
this.worker = handle;
|
|
36458
|
+
return handle;
|
|
36459
|
+
} catch (error) {
|
|
36460
|
+
await handle.close();
|
|
36461
|
+
throw error;
|
|
36462
|
+
} finally {
|
|
36463
|
+
if (this.openingHandle === handle) this.openingHandle = null;
|
|
36472
36464
|
}
|
|
36473
|
-
|
|
36474
|
-
|
|
36475
|
-
|
|
36476
|
-
signalId: request.signalId.toLowerCase(),
|
|
36477
|
-
outcome: request.outcome
|
|
36478
|
-
};
|
|
36465
|
+
} finally {
|
|
36466
|
+
if (this.openingController === controller) this.openingController = null;
|
|
36467
|
+
}
|
|
36479
36468
|
}
|
|
36480
|
-
/**
|
|
36481
|
-
async
|
|
36482
|
-
|
|
36483
|
-
|
|
36484
|
-
|
|
36485
|
-
|
|
36486
|
-
|
|
36487
|
-
|
|
36488
|
-
|
|
36489
|
-
|
|
36490
|
-
|
|
36491
|
-
|
|
36492
|
-
|
|
36493
|
-
|
|
36494
|
-
|
|
36495
|
-
|
|
36496
|
-
|
|
36497
|
-
|
|
36498
|
-
|
|
36499
|
-
outcome: "observed"
|
|
36500
|
-
}
|
|
36469
|
+
/** Force Codex's measured shell permission path without changing worker cwd. */
|
|
36470
|
+
async enablePromptsAfterCodexCanary(handle) {
|
|
36471
|
+
const configuredHome = this.options.env?.HOME;
|
|
36472
|
+
const home = configuredHome && (0, import_node_path14.isAbsolute)(configuredHome) ? configuredHome : (0, import_node_os9.homedir)();
|
|
36473
|
+
const sentinelDirectory = (0, import_node_path14.join)(home, ".cswarm", "canary");
|
|
36474
|
+
await (0, import_promises8.mkdir)(sentinelDirectory, { recursive: true, mode: 448 });
|
|
36475
|
+
await (0, import_promises8.chmod)(sentinelDirectory, 448);
|
|
36476
|
+
const [workerCwd, canaryDirectory] = await Promise.all([
|
|
36477
|
+
(0, import_promises8.realpath)(this.options.cwd),
|
|
36478
|
+
(0, import_promises8.realpath)(sentinelDirectory)
|
|
36479
|
+
]);
|
|
36480
|
+
if (pathIsInsideOrEqual(workerCwd, canaryDirectory)) {
|
|
36481
|
+
throw new AcpPermissionCanaryError(
|
|
36482
|
+
`canary_path_inside_cwd: ${canaryDirectory} is inside listener cwd ${workerCwd}. Next: pass a --cwd that is not your home directory`
|
|
36483
|
+
);
|
|
36484
|
+
}
|
|
36485
|
+
const sentinelPath = (0, import_node_path14.join)(
|
|
36486
|
+
canaryDirectory,
|
|
36487
|
+
`cswarm-codex-permission-canary-${process.pid}-${(0, import_node_crypto17.randomUUID)()}`
|
|
36501
36488
|
);
|
|
36502
|
-
|
|
36503
|
-
|
|
36504
|
-
|
|
36505
|
-
|
|
36506
|
-
|
|
36489
|
+
let canaryError;
|
|
36490
|
+
let sentinelCreated = false;
|
|
36491
|
+
try {
|
|
36492
|
+
await handle.session.enablePromptsAfterCanary({
|
|
36493
|
+
timeoutMs: ACP_CANARY_TIMEOUT_MS,
|
|
36494
|
+
probeText: `Use a shell command to create ${sentinelPath} with content CSWARM_CANARY_NOOP. You must use the shell. Do nothing else.`,
|
|
36495
|
+
...this.options.onCanaryAttempt ? { onAttempt: this.options.onCanaryAttempt } : {}
|
|
36496
|
+
});
|
|
36497
|
+
} catch (error) {
|
|
36498
|
+
canaryError = error;
|
|
36499
|
+
} finally {
|
|
36500
|
+
try {
|
|
36501
|
+
await (0, import_promises8.lstat)(sentinelPath);
|
|
36502
|
+
sentinelCreated = true;
|
|
36503
|
+
await (0, import_promises8.unlink)(sentinelPath);
|
|
36504
|
+
} catch (error) {
|
|
36505
|
+
if (error.code !== "ENOENT") throw error;
|
|
36506
|
+
}
|
|
36507
|
+
}
|
|
36508
|
+
const observation = handle.session.canaryObservation;
|
|
36509
|
+
const sawPermissionRequest = observation?.sawPermissionRequest === true;
|
|
36510
|
+
const bridgeVersion = handle.providerVersion ?? handle.session.info?.agentVersion ?? "unknown";
|
|
36511
|
+
if (sentinelCreated && !sawPermissionRequest) {
|
|
36512
|
+
throw new AcpPermissionCanaryError(
|
|
36513
|
+
`canary_executed_without_permission: codex-acp ${bridgeVersion} ran the shell probe without a permission request and wrote ${sentinelPath}. Next: replace codex-acp ${bridgeVersion} with a bridge version that asks before writing ${sentinelPath}`
|
|
36514
|
+
);
|
|
36515
|
+
}
|
|
36516
|
+
if (sentinelCreated) {
|
|
36517
|
+
throw new AcpPermissionCanaryError(
|
|
36518
|
+
`canary_write_not_blocked: codex-acp ${bridgeVersion} wrote ${sentinelPath} even though the host rejected the canary. Next: update or reinstall the codex-acp bridge`
|
|
36519
|
+
);
|
|
36520
|
+
}
|
|
36521
|
+
if (canaryError instanceof AcpPermissionCanaryError) {
|
|
36522
|
+
if (canaryError.reasonCode === "timeout") {
|
|
36523
|
+
throw new AcpPermissionCanaryError(
|
|
36524
|
+
`canary_timeout: ${canaryError.message}. Next: retry to run a fresh bounded permission canary`,
|
|
36525
|
+
"timeout"
|
|
36526
|
+
);
|
|
36527
|
+
}
|
|
36528
|
+
if (canaryError.reasonCode !== null) {
|
|
36529
|
+
throw new AcpPermissionCanaryError(
|
|
36530
|
+
`canary_bridge_error: codex-acp ${bridgeVersion} returned ${canaryError.message}. Next: resolve the quoted bridge error, then retry`,
|
|
36531
|
+
canaryError.reasonCode
|
|
36532
|
+
);
|
|
36533
|
+
}
|
|
36534
|
+
if (!sawPermissionRequest) {
|
|
36535
|
+
throw new AcpPermissionCanaryError(
|
|
36536
|
+
`canary_no_tool_call: codex-acp ${bridgeVersion} did not request permission or create ${sentinelPath}. Next: retry to re-sample the model's shell choice`
|
|
36537
|
+
);
|
|
36538
|
+
}
|
|
36539
|
+
}
|
|
36540
|
+
if (canaryError !== void 0) throw canaryError;
|
|
36507
36541
|
}
|
|
36508
36542
|
};
|
|
36509
36543
|
|
|
36544
|
+
// src/listener/runtime.ts
|
|
36545
|
+
var import_node_crypto18 = require("node:crypto");
|
|
36546
|
+
|
|
36510
36547
|
// src/listener/main-routing.ts
|
|
36511
36548
|
var import_node_path15 = require("node:path");
|
|
36512
36549
|
var UUID_RE16 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
@@ -38103,6 +38140,7 @@ var MAX_CONTROL_BYTES = 8 * 1024;
|
|
|
38103
38140
|
var CONTROL_TIMEOUT_MS = 2e3;
|
|
38104
38141
|
var START_LOCK_WAIT_MS = 2e3;
|
|
38105
38142
|
var START_LOCK_STALE_MS = 1e4;
|
|
38143
|
+
var LISTENER_DELIVERY_FAILING_THRESHOLD = 3;
|
|
38106
38144
|
var ListenerAlreadyRunningError = class extends Error {
|
|
38107
38145
|
constructor() {
|
|
38108
38146
|
super("a listener is already running for this agent principal");
|
|
@@ -38165,6 +38203,9 @@ var STATUS_ALLOWED_KEYS = /* @__PURE__ */ new Set([
|
|
|
38165
38203
|
"lastTerminalDeliveryFailureAt",
|
|
38166
38204
|
"lastClaimAt",
|
|
38167
38205
|
"lastAckAt",
|
|
38206
|
+
"lastAckOutcome",
|
|
38207
|
+
"consecutiveAckFailureCount",
|
|
38208
|
+
"lastAckSignalId",
|
|
38168
38209
|
"routeMode",
|
|
38169
38210
|
"deferOverChars",
|
|
38170
38211
|
"pendingForMainCount",
|
|
@@ -38204,8 +38245,11 @@ var STATUS_DELIVERY_KEYS = [
|
|
|
38204
38245
|
"lastTerminalDeliveryFailureCount",
|
|
38205
38246
|
"lastTerminalDeliveryFailureAt",
|
|
38206
38247
|
"lastClaimAt",
|
|
38207
|
-
"lastAckAt"
|
|
38248
|
+
"lastAckAt",
|
|
38249
|
+
"lastAckOutcome",
|
|
38250
|
+
"consecutiveAckFailureCount"
|
|
38208
38251
|
];
|
|
38252
|
+
var deliveryOutcomes = DELIVERY_ACK_OUTCOMES;
|
|
38209
38253
|
function parseStatus(raw, rejectUnknownKeys = false) {
|
|
38210
38254
|
let value;
|
|
38211
38255
|
try {
|
|
@@ -38229,7 +38273,7 @@ function parseStatus(raw, rejectUnknownKeys = false) {
|
|
|
38229
38273
|
const nullableCount = (candidate) => candidate === null || typeof candidate === "number" && Number.isSafeInteger(candidate) && candidate >= 0;
|
|
38230
38274
|
const nullableTimestamp3 = (candidate) => candidate === null || typeof candidate === "string" && Number.isFinite(Date.parse(candidate));
|
|
38231
38275
|
const readHealth = row.readHealth === void 0 ? void 0 : parseListenerReadHealth(row.readHealth, rejectUnknownKeys);
|
|
38232
|
-
if (row.version !== 1 || typeof row.instanceId !== "string" || !UUID_RE18.test(row.instanceId) || row.provider !== "grok" && row.provider !== "opencode" && row.provider !== "claude" && row.provider !== "codex" || typeof row.profileId !== "string" || typeof row.workspaceId !== "string" || !UUID_RE18.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE18.test(row.principalId) || !Number.isSafeInteger(row.pid) || row.pid < 1 || typeof row.state !== "string" || !["starting", "ready", "stopping", "stopped", "failed"].includes(row.state) || typeof row.startedAt !== "string" || !Number.isFinite(Date.parse(row.startedAt)) || !(row.readyAt === null || typeof row.readyAt === "string" && Number.isFinite(Date.parse(row.readyAt))) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt)) || !(row.stoppedAt === null || typeof row.stoppedAt === "string" && Number.isFinite(Date.parse(row.stoppedAt))) || !nullableUuid3(row.lastSignalId) || !(row.lastErrorCode === null || typeof row.lastErrorCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorCode)) || !(row.lastErrorDetail === void 0 || row.lastErrorDetail === null || typeof row.lastErrorDetail === "string" && row.lastErrorDetail.length > 0 && row.lastErrorDetail.length <= 2048 && !/swm_(?:agt|inv|cap)_/i.test(row.lastErrorDetail)) || !(row.lastErrorReasonCode === void 0 || row.lastErrorReasonCode === null || typeof row.lastErrorReasonCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorReasonCode)) || !(row.providerExecutable === void 0 || row.providerExecutable === null || typeof row.providerExecutable === "string" && (0, import_node_path16.isAbsolute)(row.providerExecutable)) || !(row.providerVersion === void 0 || row.providerVersion === null || typeof row.providerVersion === "string" && SEMVER_RE2.test(row.providerVersion)) || !(row.providerLastMeasuredVersion === void 0 || row.providerLastMeasuredVersion === null || typeof row.providerLastMeasuredVersion === "string" && SEMVER_RE2.test(row.providerLastMeasuredVersion)) || !(row.providerBundledAgentSdkVersion === void 0 || row.providerBundledAgentSdkVersion === null || typeof row.providerBundledAgentSdkVersion === "string" && SEMVER_RE2.test(row.providerBundledAgentSdkVersion)) || !(row.providerBundledClaudeCodeVersion === void 0 || row.providerBundledClaudeCodeVersion === null || typeof row.providerBundledClaudeCodeVersion === "string" && SEMVER_RE2.test(row.providerBundledClaudeCodeVersion)) || !(row.providerMinimumRequiredVersion === void 0 || row.providerMinimumRequiredVersion === null || typeof row.providerMinimumRequiredVersion === "string" && SEMVER_RE2.test(row.providerMinimumRequiredVersion)) || !(row.cswarmVersion === void 0 || row.cswarmVersion === null || typeof row.cswarmVersion === "string" && SEMVER_RE2.test(row.cswarmVersion)) || (row.providerVersion === null || row.providerVersion === void 0) !== (row.providerLastMeasuredVersion === null || row.providerLastMeasuredVersion === void 0) || !(row.lastWorkerStderrTail === void 0 || row.lastWorkerStderrTail === null || typeof row.lastWorkerStderrTail === "string" && row.lastWorkerStderrTail.length > 0 && row.lastWorkerStderrTail.length <= 2048 && !/swm_(?:agt|inv|cap)_/i.test(row.lastWorkerStderrTail)) || typeof row.logPath !== "string" || !(0, import_node_path16.isAbsolute)(row.logPath) || !(row.deliveryMode === void 0 || row.deliveryMode === null || typeof row.deliveryMode === "string" && STATUS_DELIVERY_MODES.has(row.deliveryMode)) || !(row.pendingDeliveryCount === void 0 || nullableCount(row.pendingDeliveryCount)) || !(row.lastTerminalDeliveryFailureCount === void 0 || nullableCount(row.lastTerminalDeliveryFailureCount)) || !(row.lastTerminalDeliveryFailureAt === void 0 || nullableTimestamp3(row.lastTerminalDeliveryFailureAt)) || !(row.lastClaimAt === void 0 || nullableTimestamp3(row.lastClaimAt)) || !(row.lastAckAt === void 0 || nullableTimestamp3(row.lastAckAt)) || !(row.routeMode === void 0 || row.routeMode === "worker" || row.routeMode === "main" || row.routeMode === "split") || !(row.deferOverChars === void 0 || row.deferOverChars === null || typeof row.deferOverChars === "number" && Number.isSafeInteger(row.deferOverChars) && row.deferOverChars >= 1 && row.deferOverChars <= 1e4) || !(row.pendingForMainCount === void 0 || typeof row.pendingForMainCount === "number" && Number.isSafeInteger(row.pendingForMainCount) && row.pendingForMainCount >= 0) || !(row.droppedForMainCount === void 0 || typeof row.droppedForMainCount === "number" && Number.isSafeInteger(row.droppedForMainCount) && row.droppedForMainCount >= 0) || readHealth === null || !(row.connectionsOpened === void 0 || typeof row.connectionsOpened === "number" && Number.isSafeInteger(row.connectionsOpened) && row.connectionsOpened >= 0) || !(row.connectionReuseRatio === void 0 || typeof row.connectionReuseRatio === "number" && Number.isFinite(row.connectionReuseRatio) && row.connectionReuseRatio >= 0) || !(row.activityPublishFailures === void 0 || typeof row.activityPublishFailures === "number" && Number.isSafeInteger(row.activityPublishFailures) && row.activityPublishFailures >= 0) || !(row.activityLastErrorCode === void 0 || row.activityLastErrorCode === null || typeof row.activityLastErrorCode === "string" && STATUS_ACTIVITY_ERROR_CODES.has(
|
|
38276
|
+
if (row.version !== 1 || typeof row.instanceId !== "string" || !UUID_RE18.test(row.instanceId) || row.provider !== "grok" && row.provider !== "opencode" && row.provider !== "claude" && row.provider !== "codex" || typeof row.profileId !== "string" || typeof row.workspaceId !== "string" || !UUID_RE18.test(row.workspaceId) || typeof row.principalId !== "string" || !UUID_RE18.test(row.principalId) || !Number.isSafeInteger(row.pid) || row.pid < 1 || typeof row.state !== "string" || !["starting", "ready", "stopping", "stopped", "failed"].includes(row.state) || typeof row.startedAt !== "string" || !Number.isFinite(Date.parse(row.startedAt)) || !(row.readyAt === null || typeof row.readyAt === "string" && Number.isFinite(Date.parse(row.readyAt))) || typeof row.updatedAt !== "string" || !Number.isFinite(Date.parse(row.updatedAt)) || !(row.stoppedAt === null || typeof row.stoppedAt === "string" && Number.isFinite(Date.parse(row.stoppedAt))) || !nullableUuid3(row.lastSignalId) || !(row.lastErrorCode === null || typeof row.lastErrorCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorCode)) || !(row.lastErrorDetail === void 0 || row.lastErrorDetail === null || typeof row.lastErrorDetail === "string" && row.lastErrorDetail.length > 0 && row.lastErrorDetail.length <= 2048 && !/swm_(?:agt|inv|cap)_/i.test(row.lastErrorDetail)) || !(row.lastErrorReasonCode === void 0 || row.lastErrorReasonCode === null || typeof row.lastErrorReasonCode === "string" && /^[a-z0-9_-]{1,96}$/.test(row.lastErrorReasonCode)) || !(row.providerExecutable === void 0 || row.providerExecutable === null || typeof row.providerExecutable === "string" && (0, import_node_path16.isAbsolute)(row.providerExecutable)) || !(row.providerVersion === void 0 || row.providerVersion === null || typeof row.providerVersion === "string" && SEMVER_RE2.test(row.providerVersion)) || !(row.providerLastMeasuredVersion === void 0 || row.providerLastMeasuredVersion === null || typeof row.providerLastMeasuredVersion === "string" && SEMVER_RE2.test(row.providerLastMeasuredVersion)) || !(row.providerBundledAgentSdkVersion === void 0 || row.providerBundledAgentSdkVersion === null || typeof row.providerBundledAgentSdkVersion === "string" && SEMVER_RE2.test(row.providerBundledAgentSdkVersion)) || !(row.providerBundledClaudeCodeVersion === void 0 || row.providerBundledClaudeCodeVersion === null || typeof row.providerBundledClaudeCodeVersion === "string" && SEMVER_RE2.test(row.providerBundledClaudeCodeVersion)) || !(row.providerMinimumRequiredVersion === void 0 || row.providerMinimumRequiredVersion === null || typeof row.providerMinimumRequiredVersion === "string" && SEMVER_RE2.test(row.providerMinimumRequiredVersion)) || !(row.cswarmVersion === void 0 || row.cswarmVersion === null || typeof row.cswarmVersion === "string" && SEMVER_RE2.test(row.cswarmVersion)) || (row.providerVersion === null || row.providerVersion === void 0) !== (row.providerLastMeasuredVersion === null || row.providerLastMeasuredVersion === void 0) || !(row.lastWorkerStderrTail === void 0 || row.lastWorkerStderrTail === null || typeof row.lastWorkerStderrTail === "string" && row.lastWorkerStderrTail.length > 0 && row.lastWorkerStderrTail.length <= 2048 && !/swm_(?:agt|inv|cap)_/i.test(row.lastWorkerStderrTail)) || typeof row.logPath !== "string" || !(0, import_node_path16.isAbsolute)(row.logPath) || !(row.deliveryMode === void 0 || row.deliveryMode === null || typeof row.deliveryMode === "string" && STATUS_DELIVERY_MODES.has(row.deliveryMode)) || !(row.pendingDeliveryCount === void 0 || nullableCount(row.pendingDeliveryCount)) || !(row.lastTerminalDeliveryFailureCount === void 0 || nullableCount(row.lastTerminalDeliveryFailureCount)) || !(row.lastTerminalDeliveryFailureAt === void 0 || nullableTimestamp3(row.lastTerminalDeliveryFailureAt)) || !(row.lastClaimAt === void 0 || nullableTimestamp3(row.lastClaimAt)) || !(row.lastAckAt === void 0 || nullableTimestamp3(row.lastAckAt)) || !(row.lastAckOutcome === void 0 || row.lastAckOutcome === null || typeof row.lastAckOutcome === "string" && deliveryOutcomes.has(row.lastAckOutcome)) || !(row.consecutiveAckFailureCount === void 0 || nullableCount(row.consecutiveAckFailureCount)) || !(row.lastAckSignalId === void 0 || row.lastAckSignalId === null || typeof row.lastAckSignalId === "string" && UUID_RE18.test(row.lastAckSignalId)) || !(row.routeMode === void 0 || row.routeMode === "worker" || row.routeMode === "main" || row.routeMode === "split") || !(row.deferOverChars === void 0 || row.deferOverChars === null || typeof row.deferOverChars === "number" && Number.isSafeInteger(row.deferOverChars) && row.deferOverChars >= 1 && row.deferOverChars <= 1e4) || !(row.pendingForMainCount === void 0 || typeof row.pendingForMainCount === "number" && Number.isSafeInteger(row.pendingForMainCount) && row.pendingForMainCount >= 0) || !(row.droppedForMainCount === void 0 || typeof row.droppedForMainCount === "number" && Number.isSafeInteger(row.droppedForMainCount) && row.droppedForMainCount >= 0) || readHealth === null || !(row.connectionsOpened === void 0 || typeof row.connectionsOpened === "number" && Number.isSafeInteger(row.connectionsOpened) && row.connectionsOpened >= 0) || !(row.connectionReuseRatio === void 0 || typeof row.connectionReuseRatio === "number" && Number.isFinite(row.connectionReuseRatio) && row.connectionReuseRatio >= 0) || !(row.activityPublishFailures === void 0 || typeof row.activityPublishFailures === "number" && Number.isSafeInteger(row.activityPublishFailures) && row.activityPublishFailures >= 0) || !(row.activityLastErrorCode === void 0 || row.activityLastErrorCode === null || typeof row.activityLastErrorCode === "string" && STATUS_ACTIVITY_ERROR_CODES.has(
|
|
38233
38277
|
row.activityLastErrorCode
|
|
38234
38278
|
))) {
|
|
38235
38279
|
throw new Error("stored listener status is malformed");
|
|
@@ -38250,6 +38294,11 @@ function parseStatus(raw, rejectUnknownKeys = false) {
|
|
|
38250
38294
|
lastTerminalDeliveryFailureAt: row.lastTerminalDeliveryFailureAt ?? null,
|
|
38251
38295
|
lastClaimAt: row.lastClaimAt ?? null,
|
|
38252
38296
|
lastAckAt: row.lastAckAt ?? null,
|
|
38297
|
+
lastAckOutcome: row.lastAckOutcome ?? null,
|
|
38298
|
+
consecutiveAckFailureCount: row.consecutiveAckFailureCount ?? null,
|
|
38299
|
+
// Optional key: present only when the file carried it, so a status written
|
|
38300
|
+
// without it round-trips byte-for-byte (the routeMode pattern).
|
|
38301
|
+
...row.lastAckSignalId === void 0 ? {} : { lastAckSignalId: row.lastAckSignalId ?? null },
|
|
38253
38302
|
lastErrorDetail: row.lastErrorDetail ?? null,
|
|
38254
38303
|
lastWorkerStderrTail: row.lastWorkerStderrTail ?? null,
|
|
38255
38304
|
providerVersion: row.providerVersion ?? null,
|
|
@@ -38329,13 +38378,6 @@ async function appendListenerEvent(paths, event) {
|
|
|
38329
38378
|
"dropped_count"
|
|
38330
38379
|
]);
|
|
38331
38380
|
const deliveryModes = /* @__PURE__ */ new Set(["durable_claim", "cursor_fallback"]);
|
|
38332
|
-
const deliveryOutcomes = /* @__PURE__ */ new Set([
|
|
38333
|
-
"replied",
|
|
38334
|
-
"observed",
|
|
38335
|
-
"queued",
|
|
38336
|
-
"expired",
|
|
38337
|
-
"failed_terminal"
|
|
38338
|
-
]);
|
|
38339
38381
|
const routeModes = /* @__PURE__ */ new Set(["worker", "main", "split"]);
|
|
38340
38382
|
const routeDecisions = /* @__PURE__ */ new Set(["worker", "main"]);
|
|
38341
38383
|
for (const [key2, value] of Object.entries(event)) {
|
|
@@ -38745,6 +38787,7 @@ async function runListenerSupervisor(options) {
|
|
|
38745
38787
|
const startedAt = iso2(now);
|
|
38746
38788
|
const controller = new AbortController();
|
|
38747
38789
|
const proposedInstanceId = (0, import_node_crypto20.randomUUID)();
|
|
38790
|
+
const carried = await readListenerStatus(options.paths).catch(() => null);
|
|
38748
38791
|
let status = {
|
|
38749
38792
|
version: 1,
|
|
38750
38793
|
instanceId: proposedInstanceId,
|
|
@@ -38760,7 +38803,7 @@ async function runListenerSupervisor(options) {
|
|
|
38760
38803
|
readyAt: null,
|
|
38761
38804
|
updatedAt: startedAt,
|
|
38762
38805
|
stoppedAt: null,
|
|
38763
|
-
lastSignalId: null,
|
|
38806
|
+
lastSignalId: carried?.lastSignalId ?? null,
|
|
38764
38807
|
lastErrorCode: null,
|
|
38765
38808
|
lastErrorDetail: null,
|
|
38766
38809
|
lastErrorReasonCode: null,
|
|
@@ -38776,7 +38819,14 @@ async function runListenerSupervisor(options) {
|
|
|
38776
38819
|
lastTerminalDeliveryFailureCount: null,
|
|
38777
38820
|
lastTerminalDeliveryFailureAt: null,
|
|
38778
38821
|
lastClaimAt: null,
|
|
38779
|
-
|
|
38822
|
+
/* The ack record is carried WHOLE. Carrying the outcome and the run without
|
|
38823
|
+
their timestamp and signal id rendered a screen whose own sentences
|
|
38824
|
+
disagreed -- "the newest delivery acknowledgement was replied" above
|
|
38825
|
+
"No signal has been handled yet." */
|
|
38826
|
+
lastAckAt: carried?.lastAckAt ?? null,
|
|
38827
|
+
lastAckOutcome: carried?.lastAckOutcome ?? null,
|
|
38828
|
+
consecutiveAckFailureCount: carried?.consecutiveAckFailureCount ?? null,
|
|
38829
|
+
lastAckSignalId: carried?.lastAckSignalId ?? null,
|
|
38780
38830
|
routeMode: options.routeMode ?? "worker",
|
|
38781
38831
|
deferOverChars: options.deferOverChars ?? null,
|
|
38782
38832
|
pendingForMainCount: 0,
|
|
@@ -38857,6 +38907,17 @@ async function runListenerSupervisor(options) {
|
|
|
38857
38907
|
const versionNotice = options.getProviderVersionNotice?.() ?? null;
|
|
38858
38908
|
transition("ready", {
|
|
38859
38909
|
readyAt: event.ts,
|
|
38910
|
+
// Deliberately does NOT clear consecutiveAckFailureCount. Reaching
|
|
38911
|
+
// `ready` is not provider proof: the permission canary is its own
|
|
38912
|
+
// prompt, and a provider can answer it and fail every real one --
|
|
38913
|
+
// tests/listener-cli-process.test.ts builds such a child, whose
|
|
38914
|
+
// `failPrompts` trips only non-canary prompts (that test does not
|
|
38915
|
+
// restart it, so it does not by itself exercise this path). Clearing
|
|
38916
|
+
// the run here while `lastAckOutcome` still held a stale `observed`
|
|
38917
|
+
// put `HANDLED: yes` back on the incident screen after any restartable
|
|
38918
|
+
// blip. Only a `replied` ack clears the run; the pin is in
|
|
38919
|
+
// tests/listener-runtime.test.ts, which fires `ready` after the
|
|
38920
|
+
// measured incident and asserts the run survives it.
|
|
38860
38921
|
lastErrorCode: null,
|
|
38861
38922
|
lastErrorDetail: null,
|
|
38862
38923
|
lastErrorReasonCode: null,
|
|
@@ -39041,9 +39102,14 @@ async function runListenerSupervisor(options) {
|
|
|
39041
39102
|
return;
|
|
39042
39103
|
}
|
|
39043
39104
|
if (event.type === "delivery_ack") {
|
|
39105
|
+
const failed = event.outcome === "failed_terminal";
|
|
39106
|
+
const providerProven = DELIVERY_PROVIDER_PROVEN_OUTCOMES.has(event.outcome);
|
|
39044
39107
|
status = {
|
|
39045
39108
|
...status,
|
|
39046
39109
|
lastAckAt: event.ts,
|
|
39110
|
+
lastAckOutcome: event.outcome,
|
|
39111
|
+
lastAckSignalId: event.signalId,
|
|
39112
|
+
consecutiveAckFailureCount: failed ? (status.consecutiveAckFailureCount ?? 0) + 1 : providerProven ? 0 : status.consecutiveAckFailureCount,
|
|
39047
39113
|
pendingDeliveryCount: null,
|
|
39048
39114
|
lastSignalId: event.signalId,
|
|
39049
39115
|
updatedAt: event.ts
|
|
@@ -41938,6 +42004,7 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
41938
42004
|
"permissions",
|
|
41939
42005
|
"principal-id",
|
|
41940
42006
|
"provider",
|
|
42007
|
+
"renewal-grant-id",
|
|
41941
42008
|
"repo",
|
|
41942
42009
|
"reveal-anon-key",
|
|
41943
42010
|
"route",
|
|
@@ -41989,8 +42056,8 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
41989
42056
|
]);
|
|
41990
42057
|
var UUID_RE23 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
41991
42058
|
function packageVersion() {
|
|
41992
|
-
if ("0.1.
|
|
41993
|
-
return "0.1.
|
|
42059
|
+
if ("0.1.52".length > 0) {
|
|
42060
|
+
return "0.1.52";
|
|
41994
42061
|
}
|
|
41995
42062
|
try {
|
|
41996
42063
|
const value = JSON.parse(
|
|
@@ -42151,6 +42218,7 @@ Usage:
|
|
|
42151
42218
|
cswarm token mint [--url <url> --anon-key <key>] [--workspace-id <uuid>] --principal-id <uuid> --run-id <uuid> --task-id <uuid> --epoch <n> [--ttl-ms <ms>] [--renewal-horizon-days <1..90> | --standing --confirm-standing]
|
|
42152
42219
|
cswarm token revoke [--url <url> --anon-key <key>] [--workspace-id <uuid>] --token-id <uuid>
|
|
42153
42220
|
cswarm token revoke ${requiredAgentCredential} [--url <url> --anon-key <key>] --workspace-id <uuid> [--token-id <uuid>]
|
|
42221
|
+
cswarm grant resume [--url <url> --anon-key <key>] [--workspace-id <uuid>] --renewal-grant-id <uuid> [--json] # lifts an idle pause; a REVOKED grant is refused
|
|
42154
42222
|
cswarm link new [--url <url> --anon-key <key>] [--workspace-id <uuid>] --task-id <uuid> [--ttl-ms <ms>] [--site <origin>] [--json]
|
|
42155
42223
|
cswarm link revoke [--url <url> --anon-key <key>] [--workspace-id <uuid>] --capability-id <uuid> [--json]
|
|
42156
42224
|
cswarm command <kind> [--url <url> --anon-key <key>] [--workspace-id <uuid>] ${agentCredential2} [command fields]
|
|
@@ -43293,6 +43361,43 @@ async function runToken(args) {
|
|
|
43293
43361
|
expiresAt
|
|
43294
43362
|
}));
|
|
43295
43363
|
}
|
|
43364
|
+
async function runGrant(args) {
|
|
43365
|
+
const action = args.positionals[1];
|
|
43366
|
+
args.assertShape(
|
|
43367
|
+
[
|
|
43368
|
+
...TARGET_FLAGS,
|
|
43369
|
+
"workspace-id",
|
|
43370
|
+
"renewal-grant-id",
|
|
43371
|
+
/* `--json` accepted, no effect — see the note on `runInvite`. D-064. */
|
|
43372
|
+
"json"
|
|
43373
|
+
],
|
|
43374
|
+
2
|
|
43375
|
+
);
|
|
43376
|
+
if (action !== "resume") {
|
|
43377
|
+
throw new UsageError(`unknown grant command: ${action ?? "(missing)"}`);
|
|
43378
|
+
}
|
|
43379
|
+
const renewalGrantId = args.required("renewal-grant-id");
|
|
43380
|
+
const cloud = await target(args);
|
|
43381
|
+
const human = await humanCredential(args, cloud);
|
|
43382
|
+
const workspace = await workspaceId(args, cloud, human);
|
|
43383
|
+
const response = acceptedConnect(
|
|
43384
|
+
"grant resume",
|
|
43385
|
+
await sendConnectWithPending(
|
|
43386
|
+
new ThinCommandClient(cloud),
|
|
43387
|
+
human,
|
|
43388
|
+
workspace,
|
|
43389
|
+
{ kind: "resume_renewal_grant", renewal_grant_id: renewalGrantId }
|
|
43390
|
+
)
|
|
43391
|
+
);
|
|
43392
|
+
const resumedAt = response.resumed_at ?? null;
|
|
43393
|
+
process.stdout.write(
|
|
43394
|
+
`Grant resumed${resumedAt === null ? "" : ` at ${resumedAt}`}.
|
|
43395
|
+
Renewal is allowed again. Nothing has reached the agent yet: it starts renewing when its own cswarm process next tries, so start that process if it is not running.
|
|
43396
|
+
The idle clock restarts now \u2014 another ${STANDING_IDLE_PAUSE_DAYS} days with no use pauses it again.
|
|
43397
|
+
Confirm with: cswarm whoami --agent-token-file <path>
|
|
43398
|
+
`
|
|
43399
|
+
);
|
|
43400
|
+
}
|
|
43296
43401
|
async function runTokenRevoke(args) {
|
|
43297
43402
|
if (hasAgentCredential(args)) {
|
|
43298
43403
|
args.assertShape(
|
|
@@ -45027,7 +45132,9 @@ function listenerAttendanceState(status, evidence) {
|
|
|
45027
45132
|
const connected = status.state === "ready";
|
|
45028
45133
|
const attendanceState = routeMode === "worker" ? "not_required" : pending > 0 ? "unattended" : evidence.hookSurfaceAdvanced ? "attended" : "unproven";
|
|
45029
45134
|
const attended = attendanceState === "attended" ? true : attendanceState === "unattended" ? false : null;
|
|
45030
|
-
const
|
|
45135
|
+
const lastAckOutcome = status.lastAckOutcome ?? null;
|
|
45136
|
+
const deliveryFailing = (status.consecutiveAckFailureCount ?? 0) >= LISTENER_DELIVERY_FAILING_THRESHOLD;
|
|
45137
|
+
const handled = pending > 0 ? false : routeMode !== "worker" || lastAckOutcome === null ? null : deliveryFailing ? false : DELIVERY_HANDLED_OUTCOMES.has(lastAckOutcome) ? true : lastAckOutcome === "failed_terminal" ? false : null;
|
|
45031
45138
|
return {
|
|
45032
45139
|
connected,
|
|
45033
45140
|
attended,
|
|
@@ -45068,10 +45175,36 @@ function listenerLapseNotices(status, summary) {
|
|
|
45068
45175
|
}
|
|
45069
45176
|
if (summary.throughputLapseHours.length > 0) {
|
|
45070
45177
|
const latest = summary.throughputLapseHours.at(-1);
|
|
45178
|
+
const pending = status.pendingDeliveryCount;
|
|
45179
|
+
const pendingClause = pending === null ? " No pending count was recorded." : ` Pending deliveries now: ${pending}.`;
|
|
45180
|
+
const lapseRetries = summary.retryHours.find((hour) => hour.hourStart === latest.hourStart)?.retries ?? 0;
|
|
45071
45181
|
notices.push({
|
|
45072
45182
|
code: "listener_claim_throughput_lapse",
|
|
45073
|
-
message: `Claim throughput fell below
|
|
45074
|
-
nextStep: "
|
|
45183
|
+
message: `Claim throughput fell below ${LISTENER_THROUGHPUT_LAPSE_RATIO.toFixed(2)} for the full hour at ${latest.hourStart}: ${latest.claims}/${Math.round(latest.expectedClaims)} expected (${latest.ratio.toFixed(3)}).${pendingClause}`,
|
|
45184
|
+
nextStep: lapseRetries > 0 ? `Reads also failed in that hour: ${lapseRetries} ${lapseRetries === 1 ? "retry" : "retries"} recorded. Read those failures first; any notice above names the code. A retry does not say where the fault was \u2014 host_ports_exhausted is a retry AND a host fault.` : "No read retries were recorded in that hour, so the reads were not FAILING. That does not settle whether they were SLOW: a read that succeeds slowly records nothing here, and a claim retry sleeps in the claim loop without recording either. This notice measured nothing else about that hour, and nothing about the host \u2014 read any other notice above before looking further. Cheapest checks first: load average (uptime), process count, memory pressure (sysctl kern.memorystatus_vm_pressure_level, 1 is normal), sockets (netstat -an | grep -c TIME_WAIT)."
|
|
45185
|
+
});
|
|
45186
|
+
}
|
|
45187
|
+
const consecutive = status.consecutiveAckFailureCount ?? 0;
|
|
45188
|
+
if (consecutive >= LISTENER_DELIVERY_FAILING_THRESHOLD) {
|
|
45189
|
+
notices.push({
|
|
45190
|
+
code: "listener_delivery_failing",
|
|
45191
|
+
message: (
|
|
45192
|
+
// Do not assert "messages are not being answered": a notes-only listener
|
|
45193
|
+
// acks `observed` and is fine. State only what the run records.
|
|
45194
|
+
`The listener recorded ${consecutive} terminal delivery ${consecutive === 1 ? "failure" : "failures"} with no reply since. The newest acknowledgement was ${status.lastAckOutcome ?? "not recorded"} at ${status.lastAckAt ?? "an unknown time"}. The most recent listener error code is ${status.lastErrorCode ?? "not recorded"}.`
|
|
45195
|
+
),
|
|
45196
|
+
nextStep: (
|
|
45197
|
+
// `failed_terminal` covers a refusing-but-healthy provider, a dead host
|
|
45198
|
+
// session, and a local post failure, and the run alone cannot tell them
|
|
45199
|
+
// apart — so name the check, not a diagnosis. The command needs the
|
|
45200
|
+
// credential on stdin, and the listener is still running here.
|
|
45201
|
+
// `stop` takes --principal-id and needs no credential, so it must not
|
|
45202
|
+
// read stdin: one pipe cannot feed both halves of a chained command.
|
|
45203
|
+
// `listen stop` returns while the state is still `stopping` (D-074), and
|
|
45204
|
+
// `listen start` refuses a listener that is stopping, so the two verbs
|
|
45205
|
+
// race unless the confirm step sits between them.
|
|
45206
|
+
`Read the failure codes in ${status.logPath}, then stop the listener with: cswarm listen stop --workspace-id ${status.workspaceId} --principal-id ${status.principalId}. Wait until it is no longer running -- state stopped or failed, not stopping -- confirming with: cswarm listen status --workspace-id ${status.workspaceId} --principal-id ${status.principalId}. Then restart it by piping the same agent credential into: ${listenerRestartCommand(status)}`
|
|
45207
|
+
)
|
|
45075
45208
|
});
|
|
45076
45209
|
}
|
|
45077
45210
|
return notices;
|
|
@@ -45169,6 +45302,9 @@ function listenerStatusJson(status, permissionMode, evidence = {
|
|
|
45169
45302
|
lastTerminalDeliveryFailureAt: status.lastTerminalDeliveryFailureAt ?? null,
|
|
45170
45303
|
lastClaimAt: status.lastClaimAt ?? null,
|
|
45171
45304
|
lastAckAt: status.lastAckAt ?? null,
|
|
45305
|
+
lastAckOutcome: status.lastAckOutcome ?? null,
|
|
45306
|
+
consecutiveAckFailureCount: status.consecutiveAckFailureCount ?? null,
|
|
45307
|
+
lastAckSignalId: status.lastAckSignalId ?? null,
|
|
45172
45308
|
routeMode: status.routeMode ?? "worker",
|
|
45173
45309
|
deferOverChars: status.deferOverChars ?? null,
|
|
45174
45310
|
pendingForMainCount: status.pendingForMainCount ?? 0,
|
|
@@ -45194,6 +45330,7 @@ function renderListenerStatus(status, evidence = {
|
|
|
45194
45330
|
hookSurfaceAdvanced: false
|
|
45195
45331
|
}, nowMs = Date.now(), installed = null) {
|
|
45196
45332
|
const routeMode = status.routeMode ?? "worker";
|
|
45333
|
+
const deliveryFailureRun = status.consecutiveAckFailureCount ?? 0;
|
|
45197
45334
|
const pendingForMainCount = status.pendingForMainCount ?? 0;
|
|
45198
45335
|
const droppedForMainCount = status.droppedForMainCount ?? 0;
|
|
45199
45336
|
const unattendedCount = `${pendingForMainCount} ${pendingForMainCount === 1 ? "message is" : "messages are"} unattended`;
|
|
@@ -45205,7 +45342,7 @@ function renderListenerStatus(status, evidence = {
|
|
|
45205
45342
|
lapseNotices.length > 0 ? `Listener LAPSE for agent ${status.principalId}: ${lapseNotices.map((notice) => notice.code).join(", ")}.` : pendingForMainCount > 0 ? `Listener WARNING for agent ${status.principalId}: ${unattendedCount}.` : `Listener ${status.state} for agent ${status.principalId}.`,
|
|
45206
45343
|
`CONNECTED: ${attendance.connected ? "yes" : "no"}. Transport state is ${status.state}.`,
|
|
45207
45344
|
`ATTENDED: ${attendance.attendanceState === "attended" ? "yes. The session hook has surfaced messages on this host" : attendance.attendanceState === "unattended" ? "no. The main-session queue is not draining" : attendance.attendanceState === "not_required" ? "not required for the worker route" : "not yet proven on this host"}.`,
|
|
45208
|
-
`HANDLED: ${attendance.handledState === "handled" ?
|
|
45345
|
+
`HANDLED: ${attendance.handledState === "handled" ? `yes. The newest delivery acknowledgement was ${status.lastAckOutcome}` : attendance.handledState === "not_handled" ? routeMode === "worker" ? deliveryFailureRun >= LISTENER_DELIVERY_FAILING_THRESHOLD ? `no. ${deliveryFailureRun} ${deliveryFailureRun === 1 ? "delivery has" : "deliveries have"} failed since the last reply; the newest delivery acknowledgement was ${status.lastAckOutcome ?? "not recorded"}${status.lastErrorCode ? ` (${status.lastErrorCode})` : ""}` : `no. The newest delivery acknowledgement was ${status.lastAckOutcome ?? "not recorded"}${status.lastErrorCode ? ` (${status.lastErrorCode})` : ""}` : "no. Queued messages have not reached the session hook" : "not yet measured"}.`,
|
|
45209
45346
|
`Provider: ${status.provider}; process: ${status.pid}; started: ${status.startedAt}.`,
|
|
45210
45347
|
`Provider executable: ${status.providerExecutable ?? "not measured"}.`,
|
|
45211
45348
|
`Connections opened: ${status.connectionsOpened ?? "not measured"}.`,
|
|
@@ -45213,7 +45350,7 @@ function renderListenerStatus(status, evidence = {
|
|
|
45213
45350
|
...status.activityPublishFailures !== void 0 && status.activityPublishFailures > 0 ? [`Activity publish failures: ${status.activityPublishFailures}.`] : [],
|
|
45214
45351
|
...status.activityLastErrorCode ? [`Last activity publish error code: ${status.activityLastErrorCode}.`] : [],
|
|
45215
45352
|
status.readyAt ? `Ready since: ${status.readyAt}.` : "Not ready yet.",
|
|
45216
|
-
status.lastSignalId ? pendingForMainCount > 0 ? `Last claimed and queued signal: ${status.lastSignalId}. It is not handled yet.` : routeMode === "worker" ? `Last
|
|
45353
|
+
status.lastSignalId ? pendingForMainCount > 0 ? `Last claimed and queued signal: ${status.lastSignalId}. It is not handled yet.` : routeMode === "worker" ? status.lastAckAt === null ? `Last listener signal: ${status.lastSignalId}. No delivery acknowledgement is recorded.` : status.lastAckOutcome === null ? `Last listener signal: ${status.lastSignalId}. An acknowledgement was recorded at ${status.lastAckAt}; its outcome was not recorded.` : !status.lastAckSignalId ? `Last listener signal: ${status.lastSignalId}. The newest acknowledgement was ${status.lastAckOutcome}; which signal it belonged to was not recorded.` : status.lastAckOutcome === "failed_terminal" ? `Last failed delivery signal: ${status.lastAckSignalId}.` : DELIVERY_HANDLED_OUTCOMES.has(status.lastAckOutcome) && deliveryFailureRun < LISTENER_DELIVERY_FAILING_THRESHOLD ? `Last handled signal: ${status.lastAckSignalId}.` : `Last acknowledged signal: ${status.lastAckSignalId}. Its outcome was ${status.lastAckOutcome}.` : `Last listener signal: ${status.lastSignalId}. Local status does not prove its final observed receipt.` : "No signal has been handled yet.",
|
|
45217
45354
|
status.lastErrorCode ? `Last status code: ${status.lastErrorCode}.` : "No listener process error is recorded.",
|
|
45218
45355
|
readHealth.currentEpisodeStartedAt === null ? "Current read retry episode: none." : `Current read retry episode: ${readHealth.currentEpisodeAttempts} attempt${readHealth.currentEpisodeAttempts === 1 ? "" : "s"} since ${readHealth.currentEpisodeStartedAt}; reason ${readHealth.currentReasonCode}${readHealth.currentHttpStatus === null ? "" : ` (HTTP ${readHealth.currentHttpStatus})`}${readHealth.currentErrorConstructor === null ? "" : ` (${readHealth.currentErrorConstructor})`}.`,
|
|
45219
45356
|
`Read retry episodes in the last 24h: ${readSummary.episodesLast24h}; retries in the rolling hour: ${readSummary.retriesLastHour}.`,
|
|
@@ -45319,7 +45456,7 @@ function renderListenerStatus(status, evidence = {
|
|
|
45319
45456
|
}
|
|
45320
45457
|
if (status.lastTerminalDeliveryFailureCount !== null && status.lastTerminalDeliveryFailureCount > 0) {
|
|
45321
45458
|
lines.push(
|
|
45322
|
-
`The last claim reported ${status.lastTerminalDeliveryFailureCount}
|
|
45459
|
+
`The last claim reported ${status.lastTerminalDeliveryFailureCount} ${status.lastTerminalDeliveryFailureCount === 1 ? "delivery the service gave up on because this listener never acknowledged it. It remains" : "deliveries the service gave up on because this listener never acknowledged them. They remain"} recorded, and the listener will keep receiving.`
|
|
45323
45460
|
);
|
|
45324
45461
|
}
|
|
45325
45462
|
if (status.state === "stopping" || status.state === "starting") {
|
|
@@ -47391,6 +47528,10 @@ async function main() {
|
|
|
47391
47528
|
await runToken(args);
|
|
47392
47529
|
return;
|
|
47393
47530
|
}
|
|
47531
|
+
if (verb === "grant") {
|
|
47532
|
+
await runGrant(args);
|
|
47533
|
+
return;
|
|
47534
|
+
}
|
|
47394
47535
|
if (verb === "link") {
|
|
47395
47536
|
await runLink(args);
|
|
47396
47537
|
return;
|