@paigy/harness 0.3.32 → 0.3.34
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/dist/cli.js +832 -441
- package/dist/main.js +664 -292
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -24,9 +24,9 @@ var __export = (target, all) => {
|
|
|
24
24
|
};
|
|
25
25
|
var __copyProps = (to, from, except, desc) => {
|
|
26
26
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let
|
|
28
|
-
if (!__hasOwnProp.call(to,
|
|
29
|
-
__defProp(to,
|
|
27
|
+
for (let key3 of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key3) && key3 !== except)
|
|
29
|
+
__defProp(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc(from, key3)) || desc.enumerable });
|
|
30
30
|
}
|
|
31
31
|
return to;
|
|
32
32
|
};
|
|
@@ -172,9 +172,9 @@ var init_util = __esm({
|
|
|
172
172
|
};
|
|
173
173
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
174
174
|
const keys = [];
|
|
175
|
-
for (const
|
|
176
|
-
if (Object.prototype.hasOwnProperty.call(object,
|
|
177
|
-
keys.push(
|
|
175
|
+
for (const key3 in object) {
|
|
176
|
+
if (Object.prototype.hasOwnProperty.call(object, key3)) {
|
|
177
|
+
keys.push(key3);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return keys;
|
|
@@ -603,10 +603,10 @@ var init_parseUtil = __esm({
|
|
|
603
603
|
static async mergeObjectAsync(status, pairs) {
|
|
604
604
|
const syncPairs = [];
|
|
605
605
|
for (const pair of pairs) {
|
|
606
|
-
const
|
|
606
|
+
const key3 = await pair.key;
|
|
607
607
|
const value = await pair.value;
|
|
608
608
|
syncPairs.push({
|
|
609
|
-
key,
|
|
609
|
+
key: key3,
|
|
610
610
|
value
|
|
611
611
|
});
|
|
612
612
|
}
|
|
@@ -615,17 +615,17 @@ var init_parseUtil = __esm({
|
|
|
615
615
|
static mergeObjectSync(status, pairs) {
|
|
616
616
|
const finalObject = {};
|
|
617
617
|
for (const pair of pairs) {
|
|
618
|
-
const { key, value } = pair;
|
|
619
|
-
if (
|
|
618
|
+
const { key: key3, value } = pair;
|
|
619
|
+
if (key3.status === "aborted")
|
|
620
620
|
return INVALID;
|
|
621
621
|
if (value.status === "aborted")
|
|
622
622
|
return INVALID;
|
|
623
|
-
if (
|
|
623
|
+
if (key3.status === "dirty")
|
|
624
624
|
status.dirty();
|
|
625
625
|
if (value.status === "dirty")
|
|
626
626
|
status.dirty();
|
|
627
|
-
if (
|
|
628
|
-
finalObject[
|
|
627
|
+
if (key3.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
628
|
+
finalObject[key3.value] = value.value;
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
return { status: status.value, value: finalObject };
|
|
@@ -759,9 +759,9 @@ function floatSafeRemainder(val, step2) {
|
|
|
759
759
|
function deepPartialify(schema) {
|
|
760
760
|
if (schema instanceof ZodObject) {
|
|
761
761
|
const newShape = {};
|
|
762
|
-
for (const
|
|
763
|
-
const fieldSchema = schema.shape[
|
|
764
|
-
newShape[
|
|
762
|
+
for (const key3 in schema.shape) {
|
|
763
|
+
const fieldSchema = schema.shape[key3];
|
|
764
|
+
newShape[key3] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
765
765
|
}
|
|
766
766
|
return new ZodObject({
|
|
767
767
|
...schema._def,
|
|
@@ -789,14 +789,14 @@ function mergeValues(a, b) {
|
|
|
789
789
|
return { valid: true, data: a };
|
|
790
790
|
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
791
791
|
const bKeys = util.objectKeys(b);
|
|
792
|
-
const sharedKeys = util.objectKeys(a).filter((
|
|
792
|
+
const sharedKeys = util.objectKeys(a).filter((key3) => bKeys.indexOf(key3) !== -1);
|
|
793
793
|
const newObj = { ...a, ...b };
|
|
794
|
-
for (const
|
|
795
|
-
const sharedValue = mergeValues(a[
|
|
794
|
+
for (const key3 of sharedKeys) {
|
|
795
|
+
const sharedValue = mergeValues(a[key3], b[key3]);
|
|
796
796
|
if (!sharedValue.valid) {
|
|
797
797
|
return { valid: false };
|
|
798
798
|
}
|
|
799
|
-
newObj[
|
|
799
|
+
newObj[key3] = sharedValue.data;
|
|
800
800
|
}
|
|
801
801
|
return { valid: true, data: newObj };
|
|
802
802
|
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
@@ -864,12 +864,12 @@ var init_types = __esm({
|
|
|
864
864
|
init_parseUtil();
|
|
865
865
|
init_util();
|
|
866
866
|
ParseInputLazyPath = class {
|
|
867
|
-
constructor(parent, value, path,
|
|
867
|
+
constructor(parent, value, path, key3) {
|
|
868
868
|
this._cachedPath = [];
|
|
869
869
|
this.parent = parent;
|
|
870
870
|
this.data = value;
|
|
871
871
|
this._path = path;
|
|
872
|
-
this._key =
|
|
872
|
+
this._key = key3;
|
|
873
873
|
}
|
|
874
874
|
get path() {
|
|
875
875
|
if (!this._cachedPath.length) {
|
|
@@ -1125,8 +1125,8 @@ var init_types = __esm({
|
|
|
1125
1125
|
promise() {
|
|
1126
1126
|
return ZodPromise.create(this, this._def);
|
|
1127
1127
|
}
|
|
1128
|
-
or(
|
|
1129
|
-
return ZodUnion.create([this,
|
|
1128
|
+
or(option3) {
|
|
1129
|
+
return ZodUnion.create([this, option3], this._def);
|
|
1130
1130
|
}
|
|
1131
1131
|
and(incoming) {
|
|
1132
1132
|
return ZodIntersection.create(this, incoming, this._def);
|
|
@@ -2547,29 +2547,29 @@ var init_types = __esm({
|
|
|
2547
2547
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2548
2548
|
const extraKeys = [];
|
|
2549
2549
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
2550
|
-
for (const
|
|
2551
|
-
if (!shapeKeys.includes(
|
|
2552
|
-
extraKeys.push(
|
|
2550
|
+
for (const key3 in ctx.data) {
|
|
2551
|
+
if (!shapeKeys.includes(key3)) {
|
|
2552
|
+
extraKeys.push(key3);
|
|
2553
2553
|
}
|
|
2554
2554
|
}
|
|
2555
2555
|
}
|
|
2556
2556
|
const pairs = [];
|
|
2557
|
-
for (const
|
|
2558
|
-
const keyValidator = shape[
|
|
2559
|
-
const value = ctx.data[
|
|
2557
|
+
for (const key3 of shapeKeys) {
|
|
2558
|
+
const keyValidator = shape[key3];
|
|
2559
|
+
const value = ctx.data[key3];
|
|
2560
2560
|
pairs.push({
|
|
2561
|
-
key: { status: "valid", value:
|
|
2562
|
-
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path,
|
|
2563
|
-
alwaysSet:
|
|
2561
|
+
key: { status: "valid", value: key3 },
|
|
2562
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key3)),
|
|
2563
|
+
alwaysSet: key3 in ctx.data
|
|
2564
2564
|
});
|
|
2565
2565
|
}
|
|
2566
2566
|
if (this._def.catchall instanceof ZodNever) {
|
|
2567
2567
|
const unknownKeys = this._def.unknownKeys;
|
|
2568
2568
|
if (unknownKeys === "passthrough") {
|
|
2569
|
-
for (const
|
|
2569
|
+
for (const key3 of extraKeys) {
|
|
2570
2570
|
pairs.push({
|
|
2571
|
-
key: { status: "valid", value:
|
|
2572
|
-
value: { status: "valid", value: ctx.data[
|
|
2571
|
+
key: { status: "valid", value: key3 },
|
|
2572
|
+
value: { status: "valid", value: ctx.data[key3] }
|
|
2573
2573
|
});
|
|
2574
2574
|
}
|
|
2575
2575
|
} else if (unknownKeys === "strict") {
|
|
@@ -2586,15 +2586,15 @@ var init_types = __esm({
|
|
|
2586
2586
|
}
|
|
2587
2587
|
} else {
|
|
2588
2588
|
const catchall = this._def.catchall;
|
|
2589
|
-
for (const
|
|
2590
|
-
const value = ctx.data[
|
|
2589
|
+
for (const key3 of extraKeys) {
|
|
2590
|
+
const value = ctx.data[key3];
|
|
2591
2591
|
pairs.push({
|
|
2592
|
-
key: { status: "valid", value:
|
|
2592
|
+
key: { status: "valid", value: key3 },
|
|
2593
2593
|
value: catchall._parse(
|
|
2594
|
-
new ParseInputLazyPath(ctx, value, ctx.path,
|
|
2594
|
+
new ParseInputLazyPath(ctx, value, ctx.path, key3)
|
|
2595
2595
|
//, ctx.child(key), value, getParsedType(value)
|
|
2596
2596
|
),
|
|
2597
|
-
alwaysSet:
|
|
2597
|
+
alwaysSet: key3 in ctx.data
|
|
2598
2598
|
});
|
|
2599
2599
|
}
|
|
2600
2600
|
}
|
|
@@ -2602,10 +2602,10 @@ var init_types = __esm({
|
|
|
2602
2602
|
return Promise.resolve().then(async () => {
|
|
2603
2603
|
const syncPairs = [];
|
|
2604
2604
|
for (const pair of pairs) {
|
|
2605
|
-
const
|
|
2605
|
+
const key3 = await pair.key;
|
|
2606
2606
|
const value = await pair.value;
|
|
2607
2607
|
syncPairs.push({
|
|
2608
|
-
key,
|
|
2608
|
+
key: key3,
|
|
2609
2609
|
value,
|
|
2610
2610
|
alwaysSet: pair.alwaysSet
|
|
2611
2611
|
});
|
|
@@ -2730,8 +2730,8 @@ var init_types = __esm({
|
|
|
2730
2730
|
// }) as any;
|
|
2731
2731
|
// return merged;
|
|
2732
2732
|
// }
|
|
2733
|
-
setKey(
|
|
2734
|
-
return this.augment({ [
|
|
2733
|
+
setKey(key3, schema) {
|
|
2734
|
+
return this.augment({ [key3]: schema });
|
|
2735
2735
|
}
|
|
2736
2736
|
// merge<Incoming extends AnyZodObject>(
|
|
2737
2737
|
// merging: Incoming
|
|
@@ -2762,9 +2762,9 @@ var init_types = __esm({
|
|
|
2762
2762
|
}
|
|
2763
2763
|
pick(mask) {
|
|
2764
2764
|
const shape = {};
|
|
2765
|
-
for (const
|
|
2766
|
-
if (mask[
|
|
2767
|
-
shape[
|
|
2765
|
+
for (const key3 of util.objectKeys(mask)) {
|
|
2766
|
+
if (mask[key3] && this.shape[key3]) {
|
|
2767
|
+
shape[key3] = this.shape[key3];
|
|
2768
2768
|
}
|
|
2769
2769
|
}
|
|
2770
2770
|
return new _ZodObject({
|
|
@@ -2774,9 +2774,9 @@ var init_types = __esm({
|
|
|
2774
2774
|
}
|
|
2775
2775
|
omit(mask) {
|
|
2776
2776
|
const shape = {};
|
|
2777
|
-
for (const
|
|
2778
|
-
if (!mask[
|
|
2779
|
-
shape[
|
|
2777
|
+
for (const key3 of util.objectKeys(this.shape)) {
|
|
2778
|
+
if (!mask[key3]) {
|
|
2779
|
+
shape[key3] = this.shape[key3];
|
|
2780
2780
|
}
|
|
2781
2781
|
}
|
|
2782
2782
|
return new _ZodObject({
|
|
@@ -2792,12 +2792,12 @@ var init_types = __esm({
|
|
|
2792
2792
|
}
|
|
2793
2793
|
partial(mask) {
|
|
2794
2794
|
const newShape = {};
|
|
2795
|
-
for (const
|
|
2796
|
-
const fieldSchema = this.shape[
|
|
2797
|
-
if (mask && !mask[
|
|
2798
|
-
newShape[
|
|
2795
|
+
for (const key3 of util.objectKeys(this.shape)) {
|
|
2796
|
+
const fieldSchema = this.shape[key3];
|
|
2797
|
+
if (mask && !mask[key3]) {
|
|
2798
|
+
newShape[key3] = fieldSchema;
|
|
2799
2799
|
} else {
|
|
2800
|
-
newShape[
|
|
2800
|
+
newShape[key3] = fieldSchema.optional();
|
|
2801
2801
|
}
|
|
2802
2802
|
}
|
|
2803
2803
|
return new _ZodObject({
|
|
@@ -2807,16 +2807,16 @@ var init_types = __esm({
|
|
|
2807
2807
|
}
|
|
2808
2808
|
required(mask) {
|
|
2809
2809
|
const newShape = {};
|
|
2810
|
-
for (const
|
|
2811
|
-
if (mask && !mask[
|
|
2812
|
-
newShape[
|
|
2810
|
+
for (const key3 of util.objectKeys(this.shape)) {
|
|
2811
|
+
if (mask && !mask[key3]) {
|
|
2812
|
+
newShape[key3] = this.shape[key3];
|
|
2813
2813
|
} else {
|
|
2814
|
-
const fieldSchema = this.shape[
|
|
2814
|
+
const fieldSchema = this.shape[key3];
|
|
2815
2815
|
let newField = fieldSchema;
|
|
2816
2816
|
while (newField instanceof ZodOptional) {
|
|
2817
2817
|
newField = newField._def.innerType;
|
|
2818
2818
|
}
|
|
2819
|
-
newShape[
|
|
2819
|
+
newShape[key3] = newField;
|
|
2820
2820
|
}
|
|
2821
2821
|
}
|
|
2822
2822
|
return new _ZodObject({
|
|
@@ -2879,7 +2879,7 @@ var init_types = __esm({
|
|
|
2879
2879
|
return INVALID;
|
|
2880
2880
|
}
|
|
2881
2881
|
if (ctx.common.async) {
|
|
2882
|
-
return Promise.all(options.map(async (
|
|
2882
|
+
return Promise.all(options.map(async (option3) => {
|
|
2883
2883
|
const childCtx = {
|
|
2884
2884
|
...ctx,
|
|
2885
2885
|
common: {
|
|
@@ -2889,7 +2889,7 @@ var init_types = __esm({
|
|
|
2889
2889
|
parent: null
|
|
2890
2890
|
};
|
|
2891
2891
|
return {
|
|
2892
|
-
result: await
|
|
2892
|
+
result: await option3._parseAsync({
|
|
2893
2893
|
data: ctx.data,
|
|
2894
2894
|
path: ctx.path,
|
|
2895
2895
|
parent: childCtx
|
|
@@ -2900,7 +2900,7 @@ var init_types = __esm({
|
|
|
2900
2900
|
} else {
|
|
2901
2901
|
let dirty = void 0;
|
|
2902
2902
|
const issues = [];
|
|
2903
|
-
for (const
|
|
2903
|
+
for (const option3 of options) {
|
|
2904
2904
|
const childCtx = {
|
|
2905
2905
|
...ctx,
|
|
2906
2906
|
common: {
|
|
@@ -2909,7 +2909,7 @@ var init_types = __esm({
|
|
|
2909
2909
|
},
|
|
2910
2910
|
parent: null
|
|
2911
2911
|
};
|
|
2912
|
-
const result =
|
|
2912
|
+
const result = option3._parseSync({
|
|
2913
2913
|
data: ctx.data,
|
|
2914
2914
|
path: ctx.path,
|
|
2915
2915
|
parent: childCtx
|
|
@@ -2990,8 +2990,8 @@ var init_types = __esm({
|
|
|
2990
2990
|
}
|
|
2991
2991
|
const discriminator = this.discriminator;
|
|
2992
2992
|
const discriminatorValue = ctx.data[discriminator];
|
|
2993
|
-
const
|
|
2994
|
-
if (!
|
|
2993
|
+
const option3 = this.optionsMap.get(discriminatorValue);
|
|
2994
|
+
if (!option3) {
|
|
2995
2995
|
addIssueToContext(ctx, {
|
|
2996
2996
|
code: ZodIssueCode.invalid_union_discriminator,
|
|
2997
2997
|
options: Array.from(this.optionsMap.keys()),
|
|
@@ -3000,13 +3000,13 @@ var init_types = __esm({
|
|
|
3000
3000
|
return INVALID;
|
|
3001
3001
|
}
|
|
3002
3002
|
if (ctx.common.async) {
|
|
3003
|
-
return
|
|
3003
|
+
return option3._parseAsync({
|
|
3004
3004
|
data: ctx.data,
|
|
3005
3005
|
path: ctx.path,
|
|
3006
3006
|
parent: ctx
|
|
3007
3007
|
});
|
|
3008
3008
|
} else {
|
|
3009
|
-
return
|
|
3009
|
+
return option3._parseSync({
|
|
3010
3010
|
data: ctx.data,
|
|
3011
3011
|
path: ctx.path,
|
|
3012
3012
|
parent: ctx
|
|
@@ -3193,11 +3193,11 @@ var init_types = __esm({
|
|
|
3193
3193
|
const pairs = [];
|
|
3194
3194
|
const keyType = this._def.keyType;
|
|
3195
3195
|
const valueType = this._def.valueType;
|
|
3196
|
-
for (const
|
|
3196
|
+
for (const key3 in ctx.data) {
|
|
3197
3197
|
pairs.push({
|
|
3198
|
-
key: keyType._parse(new ParseInputLazyPath(ctx,
|
|
3199
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[
|
|
3200
|
-
alwaysSet:
|
|
3198
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key3, ctx.path, key3)),
|
|
3199
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key3], ctx.path, key3)),
|
|
3200
|
+
alwaysSet: key3 in ctx.data
|
|
3201
3201
|
});
|
|
3202
3202
|
}
|
|
3203
3203
|
if (ctx.common.async) {
|
|
@@ -3245,9 +3245,9 @@ var init_types = __esm({
|
|
|
3245
3245
|
}
|
|
3246
3246
|
const keyType = this._def.keyType;
|
|
3247
3247
|
const valueType = this._def.valueType;
|
|
3248
|
-
const pairs = [...ctx.data.entries()].map(([
|
|
3248
|
+
const pairs = [...ctx.data.entries()].map(([key3, value], index) => {
|
|
3249
3249
|
return {
|
|
3250
|
-
key: keyType._parse(new ParseInputLazyPath(ctx,
|
|
3250
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key3, ctx.path, [index, "key"])),
|
|
3251
3251
|
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
3252
3252
|
};
|
|
3253
3253
|
});
|
|
@@ -3255,30 +3255,30 @@ var init_types = __esm({
|
|
|
3255
3255
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3256
3256
|
return Promise.resolve().then(async () => {
|
|
3257
3257
|
for (const pair of pairs) {
|
|
3258
|
-
const
|
|
3258
|
+
const key3 = await pair.key;
|
|
3259
3259
|
const value = await pair.value;
|
|
3260
|
-
if (
|
|
3260
|
+
if (key3.status === "aborted" || value.status === "aborted") {
|
|
3261
3261
|
return INVALID;
|
|
3262
3262
|
}
|
|
3263
|
-
if (
|
|
3263
|
+
if (key3.status === "dirty" || value.status === "dirty") {
|
|
3264
3264
|
status.dirty();
|
|
3265
3265
|
}
|
|
3266
|
-
finalMap.set(
|
|
3266
|
+
finalMap.set(key3.value, value.value);
|
|
3267
3267
|
}
|
|
3268
3268
|
return { status: status.value, value: finalMap };
|
|
3269
3269
|
});
|
|
3270
3270
|
} else {
|
|
3271
3271
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3272
3272
|
for (const pair of pairs) {
|
|
3273
|
-
const
|
|
3273
|
+
const key3 = pair.key;
|
|
3274
3274
|
const value = pair.value;
|
|
3275
|
-
if (
|
|
3275
|
+
if (key3.status === "aborted" || value.status === "aborted") {
|
|
3276
3276
|
return INVALID;
|
|
3277
3277
|
}
|
|
3278
|
-
if (
|
|
3278
|
+
if (key3.status === "dirty" || value.status === "dirty") {
|
|
3279
3279
|
status.dirty();
|
|
3280
3280
|
}
|
|
3281
|
-
finalMap.set(
|
|
3281
|
+
finalMap.set(key3.value, value.value);
|
|
3282
3282
|
}
|
|
3283
3283
|
return { status: status.value, value: finalMap };
|
|
3284
3284
|
}
|
|
@@ -4794,9 +4794,9 @@ var require_constants = __commonJS({
|
|
|
4794
4794
|
"X-XSS-Protection"
|
|
4795
4795
|
];
|
|
4796
4796
|
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
4797
|
-
const
|
|
4798
|
-
const lowerCasedKey =
|
|
4799
|
-
headerNameLowerCasedRecord[
|
|
4797
|
+
const key3 = wellknownHeaderNames[i];
|
|
4798
|
+
const lowerCasedKey = key3.toLowerCase();
|
|
4799
|
+
headerNameLowerCasedRecord[key3] = headerNameLowerCasedRecord[lowerCasedKey] = lowerCasedKey;
|
|
4800
4800
|
}
|
|
4801
4801
|
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
|
|
4802
4802
|
module.exports = {
|
|
@@ -4830,16 +4830,16 @@ var require_tree = __commonJS({
|
|
|
4830
4830
|
* @param {any} value
|
|
4831
4831
|
* @param {number} index
|
|
4832
4832
|
*/
|
|
4833
|
-
constructor(
|
|
4834
|
-
if (index === void 0 || index >=
|
|
4833
|
+
constructor(key3, value, index) {
|
|
4834
|
+
if (index === void 0 || index >= key3.length) {
|
|
4835
4835
|
throw new TypeError("Unreachable");
|
|
4836
4836
|
}
|
|
4837
|
-
const code = this.code =
|
|
4837
|
+
const code = this.code = key3.charCodeAt(index);
|
|
4838
4838
|
if (code > 127) {
|
|
4839
4839
|
throw new TypeError("key must be ascii string");
|
|
4840
4840
|
}
|
|
4841
|
-
if (
|
|
4842
|
-
this.middle = new _TstNode(
|
|
4841
|
+
if (key3.length !== ++index) {
|
|
4842
|
+
this.middle = new _TstNode(key3, value, index);
|
|
4843
4843
|
} else {
|
|
4844
4844
|
this.value = value;
|
|
4845
4845
|
}
|
|
@@ -4848,15 +4848,15 @@ var require_tree = __commonJS({
|
|
|
4848
4848
|
* @param {string} key
|
|
4849
4849
|
* @param {any} value
|
|
4850
4850
|
*/
|
|
4851
|
-
add(
|
|
4852
|
-
const length =
|
|
4851
|
+
add(key3, value) {
|
|
4852
|
+
const length = key3.length;
|
|
4853
4853
|
if (length === 0) {
|
|
4854
4854
|
throw new TypeError("Unreachable");
|
|
4855
4855
|
}
|
|
4856
4856
|
let index = 0;
|
|
4857
4857
|
let node = this;
|
|
4858
4858
|
while (true) {
|
|
4859
|
-
const code =
|
|
4859
|
+
const code = key3.charCodeAt(index);
|
|
4860
4860
|
if (code > 127) {
|
|
4861
4861
|
throw new TypeError("key must be ascii string");
|
|
4862
4862
|
}
|
|
@@ -4867,20 +4867,20 @@ var require_tree = __commonJS({
|
|
|
4867
4867
|
} else if (node.middle !== null) {
|
|
4868
4868
|
node = node.middle;
|
|
4869
4869
|
} else {
|
|
4870
|
-
node.middle = new _TstNode(
|
|
4870
|
+
node.middle = new _TstNode(key3, value, index);
|
|
4871
4871
|
break;
|
|
4872
4872
|
}
|
|
4873
4873
|
} else if (node.code < code) {
|
|
4874
4874
|
if (node.left !== null) {
|
|
4875
4875
|
node = node.left;
|
|
4876
4876
|
} else {
|
|
4877
|
-
node.left = new _TstNode(
|
|
4877
|
+
node.left = new _TstNode(key3, value, index);
|
|
4878
4878
|
break;
|
|
4879
4879
|
}
|
|
4880
4880
|
} else if (node.right !== null) {
|
|
4881
4881
|
node = node.right;
|
|
4882
4882
|
} else {
|
|
4883
|
-
node.right = new _TstNode(
|
|
4883
|
+
node.right = new _TstNode(key3, value, index);
|
|
4884
4884
|
break;
|
|
4885
4885
|
}
|
|
4886
4886
|
}
|
|
@@ -4889,12 +4889,12 @@ var require_tree = __commonJS({
|
|
|
4889
4889
|
* @param {Uint8Array} key
|
|
4890
4890
|
* @return {TstNode | null}
|
|
4891
4891
|
*/
|
|
4892
|
-
search(
|
|
4893
|
-
const keylength =
|
|
4892
|
+
search(key3) {
|
|
4893
|
+
const keylength = key3.length;
|
|
4894
4894
|
let index = 0;
|
|
4895
4895
|
let node = this;
|
|
4896
4896
|
while (node !== null && index < keylength) {
|
|
4897
|
-
let code =
|
|
4897
|
+
let code = key3[index];
|
|
4898
4898
|
if (code <= 90 && code >= 65) {
|
|
4899
4899
|
code |= 32;
|
|
4900
4900
|
}
|
|
@@ -4919,25 +4919,25 @@ var require_tree = __commonJS({
|
|
|
4919
4919
|
* @param {string} key
|
|
4920
4920
|
* @param {any} value
|
|
4921
4921
|
* */
|
|
4922
|
-
insert(
|
|
4922
|
+
insert(key3, value) {
|
|
4923
4923
|
if (this.node === null) {
|
|
4924
|
-
this.node = new TstNode(
|
|
4924
|
+
this.node = new TstNode(key3, value, 0);
|
|
4925
4925
|
} else {
|
|
4926
|
-
this.node.add(
|
|
4926
|
+
this.node.add(key3, value);
|
|
4927
4927
|
}
|
|
4928
4928
|
}
|
|
4929
4929
|
/**
|
|
4930
4930
|
* @param {Uint8Array} key
|
|
4931
4931
|
* @return {any}
|
|
4932
4932
|
*/
|
|
4933
|
-
lookup(
|
|
4934
|
-
return this.node?.search(
|
|
4933
|
+
lookup(key3) {
|
|
4934
|
+
return this.node?.search(key3)?.value ?? null;
|
|
4935
4935
|
}
|
|
4936
4936
|
};
|
|
4937
4937
|
var tree = new TernarySearchTree();
|
|
4938
4938
|
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
4939
|
-
const
|
|
4940
|
-
tree.insert(
|
|
4939
|
+
const key3 = headerNameLowerCasedRecord[wellknownHeaderNames[i]];
|
|
4940
|
+
tree.insert(key3, key3);
|
|
4941
4941
|
}
|
|
4942
4942
|
module.exports = {
|
|
4943
4943
|
TernarySearchTree,
|
|
@@ -5161,20 +5161,20 @@ var require_util = __commonJS({
|
|
|
5161
5161
|
function parseHeaders(headers, obj) {
|
|
5162
5162
|
if (obj === void 0) obj = {};
|
|
5163
5163
|
for (let i = 0; i < headers.length; i += 2) {
|
|
5164
|
-
const
|
|
5165
|
-
let val = obj[
|
|
5164
|
+
const key3 = headerNameToString(headers[i]);
|
|
5165
|
+
let val = obj[key3];
|
|
5166
5166
|
if (val) {
|
|
5167
5167
|
if (typeof val === "string") {
|
|
5168
5168
|
val = [val];
|
|
5169
|
-
obj[
|
|
5169
|
+
obj[key3] = val;
|
|
5170
5170
|
}
|
|
5171
5171
|
val.push(headers[i + 1].toString("utf8"));
|
|
5172
5172
|
} else {
|
|
5173
5173
|
const headersValue = headers[i + 1];
|
|
5174
5174
|
if (typeof headersValue === "string") {
|
|
5175
|
-
obj[
|
|
5175
|
+
obj[key3] = headersValue;
|
|
5176
5176
|
} else {
|
|
5177
|
-
obj[
|
|
5177
|
+
obj[key3] = Array.isArray(headersValue) ? headersValue.map((x) => x.toString("utf8")) : headersValue.toString("utf8");
|
|
5178
5178
|
}
|
|
5179
5179
|
}
|
|
5180
5180
|
}
|
|
@@ -5188,21 +5188,21 @@ var require_util = __commonJS({
|
|
|
5188
5188
|
const ret = new Array(len);
|
|
5189
5189
|
let hasContentLength = false;
|
|
5190
5190
|
let contentDispositionIdx = -1;
|
|
5191
|
-
let
|
|
5191
|
+
let key3;
|
|
5192
5192
|
let val;
|
|
5193
5193
|
let kLen = 0;
|
|
5194
5194
|
for (let n = 0; n < headers.length; n += 2) {
|
|
5195
|
-
|
|
5195
|
+
key3 = headers[n];
|
|
5196
5196
|
val = headers[n + 1];
|
|
5197
|
-
typeof
|
|
5197
|
+
typeof key3 !== "string" && (key3 = key3.toString());
|
|
5198
5198
|
typeof val !== "string" && (val = val.toString("utf8"));
|
|
5199
|
-
kLen =
|
|
5200
|
-
if (kLen === 14 &&
|
|
5199
|
+
kLen = key3.length;
|
|
5200
|
+
if (kLen === 14 && key3[7] === "-" && (key3 === "content-length" || key3.toLowerCase() === "content-length")) {
|
|
5201
5201
|
hasContentLength = true;
|
|
5202
|
-
} else if (kLen === 19 &&
|
|
5202
|
+
} else if (kLen === 19 && key3[7] === "-" && (key3 === "content-disposition" || key3.toLowerCase() === "content-disposition")) {
|
|
5203
5203
|
contentDispositionIdx = n + 1;
|
|
5204
5204
|
}
|
|
5205
|
-
ret[n] =
|
|
5205
|
+
ret[n] = key3;
|
|
5206
5206
|
ret[n + 1] = val;
|
|
5207
5207
|
}
|
|
5208
5208
|
if (hasContentLength && contentDispositionIdx !== -1) {
|
|
@@ -5887,20 +5887,20 @@ var require_request = __commonJS({
|
|
|
5887
5887
|
this.endHandler = null;
|
|
5888
5888
|
}
|
|
5889
5889
|
}
|
|
5890
|
-
addHeader(
|
|
5891
|
-
processHeader(this,
|
|
5890
|
+
addHeader(key3, value) {
|
|
5891
|
+
processHeader(this, key3, value);
|
|
5892
5892
|
return this;
|
|
5893
5893
|
}
|
|
5894
5894
|
};
|
|
5895
|
-
function processHeader(request,
|
|
5895
|
+
function processHeader(request, key3, val) {
|
|
5896
5896
|
if (val && (typeof val === "object" && !Array.isArray(val))) {
|
|
5897
|
-
throw new InvalidArgumentError(`invalid ${
|
|
5897
|
+
throw new InvalidArgumentError(`invalid ${key3} header`);
|
|
5898
5898
|
} else if (val === void 0) {
|
|
5899
5899
|
return;
|
|
5900
5900
|
}
|
|
5901
|
-
let headerName = headerNameLowerCasedRecord[
|
|
5901
|
+
let headerName = headerNameLowerCasedRecord[key3];
|
|
5902
5902
|
if (headerName === void 0) {
|
|
5903
|
-
headerName =
|
|
5903
|
+
headerName = key3.toLowerCase();
|
|
5904
5904
|
if (headerNameLowerCasedRecord[headerName] === void 0 && !isValidHTTPToken(headerName)) {
|
|
5905
5905
|
throw new InvalidArgumentError("invalid header key");
|
|
5906
5906
|
}
|
|
@@ -5910,13 +5910,13 @@ var require_request = __commonJS({
|
|
|
5910
5910
|
for (let i = 0; i < val.length; i++) {
|
|
5911
5911
|
if (typeof val[i] === "string") {
|
|
5912
5912
|
if (!isValidHeaderValue(val[i])) {
|
|
5913
|
-
throw new InvalidArgumentError(`invalid ${
|
|
5913
|
+
throw new InvalidArgumentError(`invalid ${key3} header`);
|
|
5914
5914
|
}
|
|
5915
5915
|
arr.push(val[i]);
|
|
5916
5916
|
} else if (val[i] === null) {
|
|
5917
5917
|
arr.push("");
|
|
5918
5918
|
} else if (typeof val[i] === "object") {
|
|
5919
|
-
throw new InvalidArgumentError(`invalid ${
|
|
5919
|
+
throw new InvalidArgumentError(`invalid ${key3} header`);
|
|
5920
5920
|
} else {
|
|
5921
5921
|
arr.push(`${val[i]}`);
|
|
5922
5922
|
}
|
|
@@ -5924,7 +5924,7 @@ var require_request = __commonJS({
|
|
|
5924
5924
|
val = arr;
|
|
5925
5925
|
} else if (typeof val === "string") {
|
|
5926
5926
|
if (!isValidHeaderValue(val)) {
|
|
5927
|
-
throw new InvalidArgumentError(`invalid ${
|
|
5927
|
+
throw new InvalidArgumentError(`invalid ${key3} header`);
|
|
5928
5928
|
}
|
|
5929
5929
|
} else if (val === null) {
|
|
5930
5930
|
val = "";
|
|
@@ -5949,7 +5949,7 @@ var require_request = __commonJS({
|
|
|
5949
5949
|
}
|
|
5950
5950
|
} else if (request.contentType === null && headerName === "content-type") {
|
|
5951
5951
|
request.contentType = val;
|
|
5952
|
-
request.headers.push(
|
|
5952
|
+
request.headers.push(key3, val);
|
|
5953
5953
|
} else if (headerName === "transfer-encoding" || headerName === "keep-alive" || headerName === "upgrade") {
|
|
5954
5954
|
throw new InvalidArgumentError(`invalid ${headerName} header`);
|
|
5955
5955
|
} else if (headerName === "connection") {
|
|
@@ -5963,7 +5963,7 @@ var require_request = __commonJS({
|
|
|
5963
5963
|
} else if (headerName === "expect") {
|
|
5964
5964
|
throw new NotSupportedError("expect header not supported");
|
|
5965
5965
|
} else {
|
|
5966
|
-
request.headers.push(
|
|
5966
|
+
request.headers.push(key3, val);
|
|
5967
5967
|
}
|
|
5968
5968
|
}
|
|
5969
5969
|
module.exports = Request;
|
|
@@ -6443,13 +6443,13 @@ var require_connect = __commonJS({
|
|
|
6443
6443
|
constructor(maxCachedSessions) {
|
|
6444
6444
|
this._maxCachedSessions = maxCachedSessions;
|
|
6445
6445
|
this._sessionCache = /* @__PURE__ */ new Map();
|
|
6446
|
-
this._sessionRegistry = new global.FinalizationRegistry((
|
|
6446
|
+
this._sessionRegistry = new global.FinalizationRegistry((key3) => {
|
|
6447
6447
|
if (this._sessionCache.size < this._maxCachedSessions) {
|
|
6448
6448
|
return;
|
|
6449
6449
|
}
|
|
6450
|
-
const ref = this._sessionCache.get(
|
|
6450
|
+
const ref = this._sessionCache.get(key3);
|
|
6451
6451
|
if (ref !== void 0 && ref.deref() === void 0) {
|
|
6452
|
-
this._sessionCache.delete(
|
|
6452
|
+
this._sessionCache.delete(key3);
|
|
6453
6453
|
}
|
|
6454
6454
|
});
|
|
6455
6455
|
}
|
|
@@ -6613,10 +6613,10 @@ var require_utils = __commonJS({
|
|
|
6613
6613
|
exports.enumToMap = void 0;
|
|
6614
6614
|
function enumToMap(obj) {
|
|
6615
6615
|
const res = {};
|
|
6616
|
-
Object.keys(obj).forEach((
|
|
6617
|
-
const value = obj[
|
|
6616
|
+
Object.keys(obj).forEach((key3) => {
|
|
6617
|
+
const value = obj[key3];
|
|
6618
6618
|
if (typeof value === "number") {
|
|
6619
|
-
res[
|
|
6619
|
+
res[key3] = value;
|
|
6620
6620
|
}
|
|
6621
6621
|
});
|
|
6622
6622
|
return res;
|
|
@@ -6793,9 +6793,9 @@ var require_constants2 = __commonJS({
|
|
|
6793
6793
|
];
|
|
6794
6794
|
exports.METHOD_MAP = utils_1.enumToMap(METHODS);
|
|
6795
6795
|
exports.H_METHOD_MAP = {};
|
|
6796
|
-
Object.keys(exports.METHOD_MAP).forEach((
|
|
6797
|
-
if (/^H/.test(
|
|
6798
|
-
exports.H_METHOD_MAP[
|
|
6796
|
+
Object.keys(exports.METHOD_MAP).forEach((key3) => {
|
|
6797
|
+
if (/^H/.test(key3)) {
|
|
6798
|
+
exports.H_METHOD_MAP[key3] = exports.METHOD_MAP[key3];
|
|
6799
6799
|
}
|
|
6800
6800
|
});
|
|
6801
6801
|
var FINISH;
|
|
@@ -7480,25 +7480,25 @@ var require_data_url = __commonJS({
|
|
|
7480
7480
|
function isHTTPWhiteSpace(char) {
|
|
7481
7481
|
return char === 13 || char === 10 || char === 9 || char === 32;
|
|
7482
7482
|
}
|
|
7483
|
-
function removeHTTPWhitespace(
|
|
7484
|
-
return removeChars(
|
|
7483
|
+
function removeHTTPWhitespace(str3, leading = true, trailing = true) {
|
|
7484
|
+
return removeChars(str3, leading, trailing, isHTTPWhiteSpace);
|
|
7485
7485
|
}
|
|
7486
7486
|
function isASCIIWhitespace(char) {
|
|
7487
7487
|
return char === 13 || char === 10 || char === 9 || char === 12 || char === 32;
|
|
7488
7488
|
}
|
|
7489
|
-
function removeASCIIWhitespace(
|
|
7490
|
-
return removeChars(
|
|
7489
|
+
function removeASCIIWhitespace(str3, leading = true, trailing = true) {
|
|
7490
|
+
return removeChars(str3, leading, trailing, isASCIIWhitespace);
|
|
7491
7491
|
}
|
|
7492
|
-
function removeChars(
|
|
7492
|
+
function removeChars(str3, leading, trailing, predicate) {
|
|
7493
7493
|
let lead = 0;
|
|
7494
|
-
let trail =
|
|
7494
|
+
let trail = str3.length - 1;
|
|
7495
7495
|
if (leading) {
|
|
7496
|
-
while (lead <
|
|
7496
|
+
while (lead < str3.length && predicate(str3.charCodeAt(lead))) lead++;
|
|
7497
7497
|
}
|
|
7498
7498
|
if (trailing) {
|
|
7499
|
-
while (trail > 0 && predicate(
|
|
7499
|
+
while (trail > 0 && predicate(str3.charCodeAt(trail))) trail--;
|
|
7500
7500
|
}
|
|
7501
|
-
return lead === 0 && trail ===
|
|
7501
|
+
return lead === 0 && trail === str3.length - 1 ? str3 : str3.slice(lead, trail + 1);
|
|
7502
7502
|
}
|
|
7503
7503
|
function isomorphicDecode(input) {
|
|
7504
7504
|
const length = input.length;
|
|
@@ -7766,19 +7766,19 @@ var require_webidl = __commonJS({
|
|
|
7766
7766
|
const result = {};
|
|
7767
7767
|
if (!types.isProxy(O)) {
|
|
7768
7768
|
const keys2 = [...Object.getOwnPropertyNames(O), ...Object.getOwnPropertySymbols(O)];
|
|
7769
|
-
for (const
|
|
7770
|
-
const typedKey = keyConverter(
|
|
7771
|
-
const typedValue = valueConverter(O[
|
|
7769
|
+
for (const key3 of keys2) {
|
|
7770
|
+
const typedKey = keyConverter(key3, prefix, argument);
|
|
7771
|
+
const typedValue = valueConverter(O[key3], prefix, argument);
|
|
7772
7772
|
result[typedKey] = typedValue;
|
|
7773
7773
|
}
|
|
7774
7774
|
return result;
|
|
7775
7775
|
}
|
|
7776
7776
|
const keys = Reflect.ownKeys(O);
|
|
7777
|
-
for (const
|
|
7778
|
-
const desc = Reflect.getOwnPropertyDescriptor(O,
|
|
7777
|
+
for (const key3 of keys) {
|
|
7778
|
+
const desc = Reflect.getOwnPropertyDescriptor(O, key3);
|
|
7779
7779
|
if (desc?.enumerable) {
|
|
7780
|
-
const typedKey = keyConverter(
|
|
7781
|
-
const typedValue = valueConverter(O[
|
|
7780
|
+
const typedKey = keyConverter(key3, prefix, argument);
|
|
7781
|
+
const typedValue = valueConverter(O[key3], prefix, argument);
|
|
7782
7782
|
result[typedKey] = typedValue;
|
|
7783
7783
|
}
|
|
7784
7784
|
}
|
|
@@ -7809,29 +7809,29 @@ var require_webidl = __commonJS({
|
|
|
7809
7809
|
});
|
|
7810
7810
|
}
|
|
7811
7811
|
for (const options of converters) {
|
|
7812
|
-
const { key, defaultValue, required, converter } = options;
|
|
7812
|
+
const { key: key3, defaultValue, required, converter } = options;
|
|
7813
7813
|
if (required === true) {
|
|
7814
|
-
if (!Object.hasOwn(dictionary,
|
|
7814
|
+
if (!Object.hasOwn(dictionary, key3)) {
|
|
7815
7815
|
throw webidl.errors.exception({
|
|
7816
7816
|
header: prefix,
|
|
7817
|
-
message: `Missing required key "${
|
|
7817
|
+
message: `Missing required key "${key3}".`
|
|
7818
7818
|
});
|
|
7819
7819
|
}
|
|
7820
7820
|
}
|
|
7821
|
-
let value = dictionary[
|
|
7821
|
+
let value = dictionary[key3];
|
|
7822
7822
|
const hasDefault = Object.hasOwn(options, "defaultValue");
|
|
7823
7823
|
if (hasDefault && value !== null) {
|
|
7824
7824
|
value ??= defaultValue();
|
|
7825
7825
|
}
|
|
7826
7826
|
if (required || hasDefault || value !== void 0) {
|
|
7827
|
-
value = converter(value, prefix, `${argument}.${
|
|
7827
|
+
value = converter(value, prefix, `${argument}.${key3}`);
|
|
7828
7828
|
if (options.allowedValues && !options.allowedValues.includes(value)) {
|
|
7829
7829
|
throw webidl.errors.exception({
|
|
7830
7830
|
header: prefix,
|
|
7831
7831
|
message: `${value} is not an accepted type. Expected one of ${options.allowedValues.join(", ")}.`
|
|
7832
7832
|
});
|
|
7833
7833
|
}
|
|
7834
|
-
dict[
|
|
7834
|
+
dict[key3] = value;
|
|
7835
7835
|
}
|
|
7836
7836
|
}
|
|
7837
7837
|
return dict;
|
|
@@ -8446,18 +8446,18 @@ var require_util2 = __commonJS({
|
|
|
8446
8446
|
done: true
|
|
8447
8447
|
};
|
|
8448
8448
|
}
|
|
8449
|
-
const { [keyIndex]:
|
|
8449
|
+
const { [keyIndex]: key3, [valueIndex]: value } = values[index];
|
|
8450
8450
|
this.#index = index + 1;
|
|
8451
8451
|
let result;
|
|
8452
8452
|
switch (this.#kind) {
|
|
8453
8453
|
case "key":
|
|
8454
|
-
result =
|
|
8454
|
+
result = key3;
|
|
8455
8455
|
break;
|
|
8456
8456
|
case "value":
|
|
8457
8457
|
result = value;
|
|
8458
8458
|
break;
|
|
8459
8459
|
case "key+value":
|
|
8460
|
-
result = [
|
|
8460
|
+
result = [key3, value];
|
|
8461
8461
|
break;
|
|
8462
8462
|
}
|
|
8463
8463
|
return {
|
|
@@ -8523,8 +8523,8 @@ var require_util2 = __commonJS({
|
|
|
8523
8523
|
`Failed to execute 'forEach' on '${name}': parameter 1 is not of type 'Function'.`
|
|
8524
8524
|
);
|
|
8525
8525
|
}
|
|
8526
|
-
for (const { 0:
|
|
8527
|
-
callbackfn.call(thisArg, value,
|
|
8526
|
+
for (const { 0: key3, 1: value } of makeIterator(this, "key+value")) {
|
|
8527
|
+
callbackfn.call(thisArg, value, key3, this);
|
|
8528
8528
|
}
|
|
8529
8529
|
}
|
|
8530
8530
|
}
|
|
@@ -9417,7 +9417,7 @@ var require_body = __commonJS({
|
|
|
9417
9417
|
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, "0")}`;
|
|
9418
9418
|
const prefix = `--${boundary}\r
|
|
9419
9419
|
Content-Disposition: form-data`;
|
|
9420
|
-
const escape = (
|
|
9420
|
+
const escape = (str3) => str3.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
9421
9421
|
const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
|
|
9422
9422
|
const blobParts = [];
|
|
9423
9423
|
const rn = new Uint8Array([13, 10]);
|
|
@@ -9966,15 +9966,15 @@ var require_client_h1 = __commonJS({
|
|
|
9966
9966
|
} else {
|
|
9967
9967
|
this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf]);
|
|
9968
9968
|
}
|
|
9969
|
-
const
|
|
9970
|
-
if (
|
|
9971
|
-
const headerName = util2.bufferToLowerCasedHeaderName(
|
|
9969
|
+
const key3 = this.headers[len - 2];
|
|
9970
|
+
if (key3.length === 10) {
|
|
9971
|
+
const headerName = util2.bufferToLowerCasedHeaderName(key3);
|
|
9972
9972
|
if (headerName === "keep-alive") {
|
|
9973
9973
|
this.keepAlive += buf.toString();
|
|
9974
9974
|
} else if (headerName === "connection") {
|
|
9975
9975
|
this.connection += buf.toString();
|
|
9976
9976
|
}
|
|
9977
|
-
} else if (
|
|
9977
|
+
} else if (key3.length === 14 && util2.bufferToLowerCasedHeaderName(key3) === "content-length") {
|
|
9978
9978
|
this.contentLength += buf.toString();
|
|
9979
9979
|
}
|
|
9980
9980
|
this.trackHeader(buf.length);
|
|
@@ -10459,15 +10459,15 @@ upgrade: ${upgrade}\r
|
|
|
10459
10459
|
}
|
|
10460
10460
|
if (Array.isArray(headers)) {
|
|
10461
10461
|
for (let n = 0; n < headers.length; n += 2) {
|
|
10462
|
-
const
|
|
10462
|
+
const key3 = headers[n + 0];
|
|
10463
10463
|
const val = headers[n + 1];
|
|
10464
10464
|
if (Array.isArray(val)) {
|
|
10465
10465
|
for (let i = 0; i < val.length; i++) {
|
|
10466
|
-
header += `${
|
|
10466
|
+
header += `${key3}: ${val[i]}\r
|
|
10467
10467
|
`;
|
|
10468
10468
|
}
|
|
10469
10469
|
} else {
|
|
10470
|
-
header += `${
|
|
10470
|
+
header += `${key3}: ${val}\r
|
|
10471
10471
|
`;
|
|
10472
10472
|
}
|
|
10473
10473
|
}
|
|
@@ -10929,8 +10929,8 @@ var require_client_h2 = __commonJS({
|
|
|
10929
10929
|
this[kSocket][kError] = err;
|
|
10930
10930
|
this[kClient][kOnError](err);
|
|
10931
10931
|
}
|
|
10932
|
-
function onHttp2FrameError(type, code,
|
|
10933
|
-
if (
|
|
10932
|
+
function onHttp2FrameError(type, code, id3) {
|
|
10933
|
+
if (id3 === 0) {
|
|
10934
10934
|
const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
|
|
10935
10935
|
this[kSocket][kError] = err;
|
|
10936
10936
|
this[kClient][kOnError](err);
|
|
@@ -10974,18 +10974,18 @@ var require_client_h2 = __commonJS({
|
|
|
10974
10974
|
}
|
|
10975
10975
|
const headers = {};
|
|
10976
10976
|
for (let n = 0; n < reqHeaders.length; n += 2) {
|
|
10977
|
-
const
|
|
10977
|
+
const key3 = reqHeaders[n + 0];
|
|
10978
10978
|
const val = reqHeaders[n + 1];
|
|
10979
10979
|
if (Array.isArray(val)) {
|
|
10980
10980
|
for (let i = 0; i < val.length; i++) {
|
|
10981
|
-
if (headers[
|
|
10982
|
-
headers[
|
|
10981
|
+
if (headers[key3]) {
|
|
10982
|
+
headers[key3] += `,${val[i]}`;
|
|
10983
10983
|
} else {
|
|
10984
|
-
headers[
|
|
10984
|
+
headers[key3] = val[i];
|
|
10985
10985
|
}
|
|
10986
10986
|
}
|
|
10987
10987
|
} else {
|
|
10988
|
-
headers[
|
|
10988
|
+
headers[key3] = val;
|
|
10989
10989
|
}
|
|
10990
10990
|
}
|
|
10991
10991
|
let stream;
|
|
@@ -11450,9 +11450,9 @@ var require_redirect_handler = __commonJS({
|
|
|
11450
11450
|
}
|
|
11451
11451
|
}
|
|
11452
11452
|
} else if (headers && typeof headers === "object") {
|
|
11453
|
-
for (const
|
|
11454
|
-
if (!shouldRemoveHeader(
|
|
11455
|
-
ret.push(
|
|
11453
|
+
for (const key3 of Object.keys(headers)) {
|
|
11454
|
+
if (!shouldRemoveHeader(key3, removeContent, unknownOrigin)) {
|
|
11455
|
+
ret.push(key3, headers[key3]);
|
|
11456
11456
|
}
|
|
11457
11457
|
}
|
|
11458
11458
|
} else {
|
|
@@ -12530,16 +12530,16 @@ var require_agent = __commonJS({
|
|
|
12530
12530
|
return ret;
|
|
12531
12531
|
}
|
|
12532
12532
|
[kDispatch](opts, handler) {
|
|
12533
|
-
let
|
|
12533
|
+
let key3;
|
|
12534
12534
|
if (opts.origin && (typeof opts.origin === "string" || opts.origin instanceof URL)) {
|
|
12535
|
-
|
|
12535
|
+
key3 = String(opts.origin);
|
|
12536
12536
|
} else {
|
|
12537
12537
|
throw new InvalidArgumentError("opts.origin must be a non-empty string or URL.");
|
|
12538
12538
|
}
|
|
12539
|
-
let dispatcher = this[kClients].get(
|
|
12539
|
+
let dispatcher = this[kClients].get(key3);
|
|
12540
12540
|
if (!dispatcher) {
|
|
12541
12541
|
dispatcher = this[kFactory](opts.origin, this[kOptions]).on("drain", this[kOnDrain]).on("connect", this[kOnConnect]).on("disconnect", this[kOnDisconnect]).on("connectionError", this[kOnConnectionError]);
|
|
12542
|
-
this[kClients].set(
|
|
12542
|
+
this[kClients].set(key3, dispatcher);
|
|
12543
12543
|
}
|
|
12544
12544
|
return dispatcher.dispatch(opts, handler);
|
|
12545
12545
|
}
|
|
@@ -12778,7 +12778,7 @@ var require_proxy_agent = __commonJS({
|
|
|
12778
12778
|
return headers;
|
|
12779
12779
|
}
|
|
12780
12780
|
function throwIfProxyAuthIsSent(headers) {
|
|
12781
|
-
const existProxyAuth = headers && Object.keys(headers).find((
|
|
12781
|
+
const existProxyAuth = headers && Object.keys(headers).find((key3) => key3.toLowerCase() === "proxy-authorization");
|
|
12782
12782
|
if (existProxyAuth) {
|
|
12783
12783
|
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
|
|
12784
12784
|
}
|
|
@@ -14507,18 +14507,18 @@ var require_mock_utils = __commonJS({
|
|
|
14507
14507
|
})
|
|
14508
14508
|
);
|
|
14509
14509
|
}
|
|
14510
|
-
function getHeaderByName(headers,
|
|
14510
|
+
function getHeaderByName(headers, key3) {
|
|
14511
14511
|
if (Array.isArray(headers)) {
|
|
14512
14512
|
for (let i = 0; i < headers.length; i += 2) {
|
|
14513
|
-
if (headers[i].toLocaleLowerCase() ===
|
|
14513
|
+
if (headers[i].toLocaleLowerCase() === key3.toLocaleLowerCase()) {
|
|
14514
14514
|
return headers[i + 1];
|
|
14515
14515
|
}
|
|
14516
14516
|
}
|
|
14517
14517
|
return void 0;
|
|
14518
14518
|
} else if (typeof headers.get === "function") {
|
|
14519
|
-
return headers.get(
|
|
14519
|
+
return headers.get(key3);
|
|
14520
14520
|
} else {
|
|
14521
|
-
return lowerCaseEntries(headers)[
|
|
14521
|
+
return lowerCaseEntries(headers)[key3.toLocaleLowerCase()];
|
|
14522
14522
|
}
|
|
14523
14523
|
}
|
|
14524
14524
|
function buildHeadersFromArray(headers) {
|
|
@@ -14582,41 +14582,41 @@ var require_mock_utils = __commonJS({
|
|
|
14582
14582
|
return data.toString();
|
|
14583
14583
|
}
|
|
14584
14584
|
}
|
|
14585
|
-
function getMockDispatch(mockDispatches,
|
|
14586
|
-
const basePath =
|
|
14585
|
+
function getMockDispatch(mockDispatches, key3) {
|
|
14586
|
+
const basePath = key3.query ? buildURL(key3.path, key3.query) : key3.path;
|
|
14587
14587
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
14588
14588
|
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path }) => matchValue(safeUrl(path), resolvedPath));
|
|
14589
14589
|
if (matchedMockDispatches.length === 0) {
|
|
14590
14590
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
14591
14591
|
}
|
|
14592
|
-
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method,
|
|
14592
|
+
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method, key3.method));
|
|
14593
14593
|
if (matchedMockDispatches.length === 0) {
|
|
14594
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for method '${
|
|
14594
|
+
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key3.method}' on path '${resolvedPath}'`);
|
|
14595
14595
|
}
|
|
14596
|
-
matchedMockDispatches = matchedMockDispatches.filter(({ body }) => typeof body !== "undefined" ? matchValue(body,
|
|
14596
|
+
matchedMockDispatches = matchedMockDispatches.filter(({ body }) => typeof body !== "undefined" ? matchValue(body, key3.body) : true);
|
|
14597
14597
|
if (matchedMockDispatches.length === 0) {
|
|
14598
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for body '${
|
|
14598
|
+
throw new MockNotMatchedError(`Mock dispatch not matched for body '${key3.body}' on path '${resolvedPath}'`);
|
|
14599
14599
|
}
|
|
14600
|
-
matchedMockDispatches = matchedMockDispatches.filter((mockDispatch2) => matchHeaders(mockDispatch2,
|
|
14600
|
+
matchedMockDispatches = matchedMockDispatches.filter((mockDispatch2) => matchHeaders(mockDispatch2, key3.headers));
|
|
14601
14601
|
if (matchedMockDispatches.length === 0) {
|
|
14602
|
-
const headers = typeof
|
|
14602
|
+
const headers = typeof key3.headers === "object" ? JSON.stringify(key3.headers) : key3.headers;
|
|
14603
14603
|
throw new MockNotMatchedError(`Mock dispatch not matched for headers '${headers}' on path '${resolvedPath}'`);
|
|
14604
14604
|
}
|
|
14605
14605
|
return matchedMockDispatches[0];
|
|
14606
14606
|
}
|
|
14607
|
-
function addMockDispatch(mockDispatches,
|
|
14607
|
+
function addMockDispatch(mockDispatches, key3, data) {
|
|
14608
14608
|
const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false };
|
|
14609
14609
|
const replyData = typeof data === "function" ? { callback: data } : { ...data };
|
|
14610
|
-
const newMockDispatch = { ...baseData, ...
|
|
14610
|
+
const newMockDispatch = { ...baseData, ...key3, pending: true, data: { error: null, ...replyData } };
|
|
14611
14611
|
mockDispatches.push(newMockDispatch);
|
|
14612
14612
|
return newMockDispatch;
|
|
14613
14613
|
}
|
|
14614
|
-
function deleteMockDispatch(mockDispatches,
|
|
14614
|
+
function deleteMockDispatch(mockDispatches, key3) {
|
|
14615
14615
|
const index = mockDispatches.findIndex((dispatch) => {
|
|
14616
14616
|
if (!dispatch.consumed) {
|
|
14617
14617
|
return false;
|
|
14618
14618
|
}
|
|
14619
|
-
return matchKey(dispatch,
|
|
14619
|
+
return matchKey(dispatch, key3);
|
|
14620
14620
|
});
|
|
14621
14621
|
if (index !== -1) {
|
|
14622
14622
|
mockDispatches.splice(index, 1);
|
|
@@ -14636,9 +14636,9 @@ var require_mock_utils = __commonJS({
|
|
|
14636
14636
|
const keys = Object.keys(data);
|
|
14637
14637
|
const result = [];
|
|
14638
14638
|
for (let i = 0; i < keys.length; ++i) {
|
|
14639
|
-
const
|
|
14640
|
-
const value = data[
|
|
14641
|
-
const name = Buffer.from(`${
|
|
14639
|
+
const key3 = keys[i];
|
|
14640
|
+
const value = data[key3];
|
|
14641
|
+
const name = Buffer.from(`${key3}`);
|
|
14642
14642
|
if (Array.isArray(value)) {
|
|
14643
14643
|
for (let j = 0; j < value.length; ++j) {
|
|
14644
14644
|
result.push(name, Buffer.from(`${value[j]}`));
|
|
@@ -14660,8 +14660,8 @@ var require_mock_utils = __commonJS({
|
|
|
14660
14660
|
return Buffer.concat(buffers).toString("utf8");
|
|
14661
14661
|
}
|
|
14662
14662
|
function mockDispatch(opts, handler) {
|
|
14663
|
-
const
|
|
14664
|
-
const mockDispatch2 = getMockDispatch(this[kDispatches],
|
|
14663
|
+
const key3 = buildKey(opts);
|
|
14664
|
+
const mockDispatch2 = getMockDispatch(this[kDispatches], key3);
|
|
14665
14665
|
mockDispatch2.timesInvoked++;
|
|
14666
14666
|
if (mockDispatch2.data.callback) {
|
|
14667
14667
|
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
@@ -14671,7 +14671,7 @@ var require_mock_utils = __commonJS({
|
|
|
14671
14671
|
mockDispatch2.consumed = !persist && timesInvoked >= times;
|
|
14672
14672
|
mockDispatch2.pending = timesInvoked < times;
|
|
14673
14673
|
if (error !== null) {
|
|
14674
|
-
deleteMockDispatch(this[kDispatches],
|
|
14674
|
+
deleteMockDispatch(this[kDispatches], key3);
|
|
14675
14675
|
handler.onError(error);
|
|
14676
14676
|
return true;
|
|
14677
14677
|
}
|
|
@@ -14696,7 +14696,7 @@ var require_mock_utils = __commonJS({
|
|
|
14696
14696
|
handler.onHeaders?.(statusCode, responseHeaders, resume, getStatusText(statusCode));
|
|
14697
14697
|
handler.onData?.(Buffer.from(responseData));
|
|
14698
14698
|
handler.onComplete?.(responseTrailers);
|
|
14699
|
-
deleteMockDispatch(mockDispatches,
|
|
14699
|
+
deleteMockDispatch(mockDispatches, key3);
|
|
14700
14700
|
}
|
|
14701
14701
|
function resume() {
|
|
14702
14702
|
}
|
|
@@ -16603,16 +16603,16 @@ var require_dispatcher_weakref = __commonJS({
|
|
|
16603
16603
|
constructor(finalizer) {
|
|
16604
16604
|
this.finalizer = finalizer;
|
|
16605
16605
|
}
|
|
16606
|
-
register(dispatcher,
|
|
16606
|
+
register(dispatcher, key3) {
|
|
16607
16607
|
if (dispatcher.on) {
|
|
16608
16608
|
dispatcher.on("disconnect", () => {
|
|
16609
16609
|
if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) {
|
|
16610
|
-
this.finalizer(
|
|
16610
|
+
this.finalizer(key3);
|
|
16611
16611
|
}
|
|
16612
16612
|
});
|
|
16613
16613
|
}
|
|
16614
16614
|
}
|
|
16615
|
-
unregister(
|
|
16615
|
+
unregister(key3) {
|
|
16616
16616
|
}
|
|
16617
16617
|
};
|
|
16618
16618
|
module.exports = function() {
|
|
@@ -20065,8 +20065,8 @@ var require_util6 = __commonJS({
|
|
|
20065
20065
|
if (!part.includes("=")) {
|
|
20066
20066
|
throw new Error("Invalid unparsed");
|
|
20067
20067
|
}
|
|
20068
|
-
const [
|
|
20069
|
-
out.push(`${
|
|
20068
|
+
const [key3, ...value] = part.split("=");
|
|
20069
|
+
out.push(`${key3.trim()}=${value.join("=")}`);
|
|
20070
20070
|
}
|
|
20071
20071
|
return out.join("; ");
|
|
20072
20072
|
}
|
|
@@ -20265,9 +20265,9 @@ var require_cookies = __commonJS({
|
|
|
20265
20265
|
webidl.argumentLengthCheck(arguments, 2, "setCookie");
|
|
20266
20266
|
webidl.brandCheck(headers, Headers, { strict: false });
|
|
20267
20267
|
cookie = webidl.converters.Cookie(cookie);
|
|
20268
|
-
const
|
|
20269
|
-
if (
|
|
20270
|
-
headers.append("Set-Cookie",
|
|
20268
|
+
const str3 = stringify(cookie);
|
|
20269
|
+
if (str3) {
|
|
20270
|
+
headers.append("Set-Cookie", str3);
|
|
20271
20271
|
}
|
|
20272
20272
|
}
|
|
20273
20273
|
webidl.converters.DeleteCookieAttributes = webidl.dictionaryConverter([
|
|
@@ -22796,31 +22796,35 @@ async function reach(url, init) {
|
|
|
22796
22796
|
function reachAs(session, instance) {
|
|
22797
22797
|
return (url, init) => send(url, init, session, instance);
|
|
22798
22798
|
}
|
|
22799
|
+
function setClient(name) {
|
|
22800
|
+
CLIENT = name;
|
|
22801
|
+
}
|
|
22799
22802
|
async function send(url, init, session, instance = envSession("PAIGY_INSTANCE_ID") ?? INSTANCE_ID) {
|
|
22800
22803
|
try {
|
|
22801
22804
|
const headers = {
|
|
22802
22805
|
...init?.headers,
|
|
22803
22806
|
"x-paigy-instance": instance,
|
|
22804
|
-
"x-paigy-session": session
|
|
22807
|
+
"x-paigy-session": session,
|
|
22808
|
+
...CLIENT ? { "x-paigy-client": CLIENT } : {}
|
|
22805
22809
|
};
|
|
22806
22810
|
return await fetch(url, { ...init, headers, dispatcher: await proxy() });
|
|
22807
22811
|
} catch (e) {
|
|
22808
22812
|
throw new Error(`${NETWORK_MSG} (${e?.message ?? String(e)})`);
|
|
22809
22813
|
}
|
|
22810
22814
|
}
|
|
22811
|
-
function addErrorMessage(res,
|
|
22815
|
+
function addErrorMessage(res, key22, errorMessage, refs) {
|
|
22812
22816
|
if (!refs?.errorMessages)
|
|
22813
22817
|
return;
|
|
22814
22818
|
if (errorMessage) {
|
|
22815
22819
|
res.errorMessage = {
|
|
22816
22820
|
...res.errorMessage,
|
|
22817
|
-
[
|
|
22821
|
+
[key22]: errorMessage
|
|
22818
22822
|
};
|
|
22819
22823
|
}
|
|
22820
22824
|
}
|
|
22821
|
-
function setResponseValueAndErrors(res,
|
|
22822
|
-
res[
|
|
22823
|
-
addErrorMessage(res,
|
|
22825
|
+
function setResponseValueAndErrors(res, key22, value, errorMessage, refs) {
|
|
22826
|
+
res[key22] = value;
|
|
22827
|
+
addErrorMessage(res, key22, errorMessage, refs);
|
|
22824
22828
|
}
|
|
22825
22829
|
function parseAnyDef(refs) {
|
|
22826
22830
|
if (refs.target !== "openAi") {
|
|
@@ -23283,11 +23287,11 @@ function parseRecordDef(def, refs) {
|
|
|
23283
23287
|
return {
|
|
23284
23288
|
type: "object",
|
|
23285
23289
|
required: def.keyType._def.values,
|
|
23286
|
-
properties: def.keyType._def.values.reduce((acc,
|
|
23290
|
+
properties: def.keyType._def.values.reduce((acc, key22) => ({
|
|
23287
23291
|
...acc,
|
|
23288
|
-
[
|
|
23292
|
+
[key22]: parseDef(def.valueType._def, {
|
|
23289
23293
|
...refs,
|
|
23290
|
-
currentPath: [...refs.currentPath, "properties",
|
|
23294
|
+
currentPath: [...refs.currentPath, "properties", key22]
|
|
23291
23295
|
}) ?? parseAnyDef(refs)
|
|
23292
23296
|
}), {}),
|
|
23293
23297
|
additionalProperties: refs.rejectedAdditionalProperties
|
|
@@ -23350,10 +23354,10 @@ function parseMapDef(def, refs) {
|
|
|
23350
23354
|
}
|
|
23351
23355
|
function parseNativeEnumDef(def) {
|
|
23352
23356
|
const object = def.values;
|
|
23353
|
-
const actualKeys = Object.keys(def.values).filter((
|
|
23354
|
-
return typeof object[object[
|
|
23357
|
+
const actualKeys = Object.keys(def.values).filter((key22) => {
|
|
23358
|
+
return typeof object[object[key22]] !== "number";
|
|
23355
23359
|
});
|
|
23356
|
-
const actualValues = actualKeys.map((
|
|
23360
|
+
const actualValues = actualKeys.map((key22) => object[key22]);
|
|
23357
23361
|
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
23358
23362
|
return {
|
|
23359
23363
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
@@ -23687,8 +23691,8 @@ function mcpInputSchema(s) {
|
|
|
23687
23691
|
return draft2020(schema);
|
|
23688
23692
|
}
|
|
23689
23693
|
function sessionSlot(sessionId2) {
|
|
23690
|
-
const
|
|
23691
|
-
return `session:${
|
|
23694
|
+
const id22 = sessionId2 ?? sessionId();
|
|
23695
|
+
return `session:${id22.slice(0, 8)}`;
|
|
23692
23696
|
}
|
|
23693
23697
|
function agentName() {
|
|
23694
23698
|
return process.env.PAIGY_AGENT || sessionSlot();
|
|
@@ -23743,7 +23747,7 @@ function updateSlot(agent2, patch) {
|
|
|
23743
23747
|
}
|
|
23744
23748
|
function slotIdentity(agent2) {
|
|
23745
23749
|
const t = readTokenFile()[agent2];
|
|
23746
|
-
return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null };
|
|
23750
|
+
return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null, harness: t?.harness ?? null, sessionId: t?.session_id ?? null, fullSession: t?.full_session ?? null };
|
|
23747
23751
|
}
|
|
23748
23752
|
function readToken(agent2 = agentName()) {
|
|
23749
23753
|
if (process.env.PAIGY_TOKEN) return process.env.PAIGY_TOKEN;
|
|
@@ -23893,7 +23897,9 @@ async function recordDecision(decision, opts = {}) {
|
|
|
23893
23897
|
async function heartbeat(runtime, opts = {}) {
|
|
23894
23898
|
const body = {
|
|
23895
23899
|
...runtime !== void 0 ? { runtime } : {},
|
|
23896
|
-
...opts.activity !== void 0 ? { activity: opts.activity } : {}
|
|
23900
|
+
...opts.activity !== void 0 ? { activity: opts.activity } : {},
|
|
23901
|
+
// A listener's beat (`paigy-listen`): stamps when it last swept, and is not presence.
|
|
23902
|
+
...opts.listening ? { listening: true } : {}
|
|
23897
23903
|
};
|
|
23898
23904
|
const res = await ensureAuthed(await reach(`${BACKEND_URL}/api/presence`, {
|
|
23899
23905
|
method: "POST",
|
|
@@ -23976,6 +23982,7 @@ async function contact(input, opts = {}) {
|
|
|
23976
23982
|
let deliveryId;
|
|
23977
23983
|
let deliveries = [];
|
|
23978
23984
|
let recorded = [];
|
|
23985
|
+
let demoted;
|
|
23979
23986
|
if ("deliveryId" in parsed) {
|
|
23980
23987
|
deliveryId = parsed.deliveryId;
|
|
23981
23988
|
} else {
|
|
@@ -24006,13 +24013,14 @@ async function contact(input, opts = {}) {
|
|
|
24006
24013
|
if (!res.ok) await fail("batch contact", res);
|
|
24007
24014
|
const receipt = await res.json();
|
|
24008
24015
|
deliveries = receipt.deliveries ?? [];
|
|
24016
|
+
if (parsed.channel === "call" && receipt.channel && receipt.channel !== "call") demoted = DEMOTED;
|
|
24009
24017
|
recorded = receipt.recorded ?? [];
|
|
24010
24018
|
if (deliveries.length === 0 && recorded.length) return { sent: false, recorded, message: NOT_SENT };
|
|
24011
24019
|
if (deliveries.length === 0) throw new Error("Goal contact returned no Delivery identities");
|
|
24012
24020
|
deliveryId = deliveries[0]?.deliveryId ?? "";
|
|
24013
24021
|
if (!deliveryId) throw new Error("Goal contact returned no valid Delivery identity");
|
|
24014
24022
|
}
|
|
24015
|
-
const all = deliveries.filter((d) => !!d.deliveryId && !!d.goalId).map(({ id, deliveryId: deliveryId2, goalId }) => ({ ...
|
|
24023
|
+
const all = deliveries.filter((d) => !!d.deliveryId && !!d.goalId).map(({ id: id22, deliveryId: deliveryId2, goalId }) => ({ ...id22 ? { id: id22 } : {}, deliveryId: deliveryId2, goalId }));
|
|
24016
24024
|
const joinedCard = deliveries[0]?.joinedCard === true;
|
|
24017
24025
|
const joinedCall = deliveries[0]?.joinedCall === true;
|
|
24018
24026
|
const read = async (signal2) => {
|
|
@@ -24024,7 +24032,8 @@ async function contact(input, opts = {}) {
|
|
|
24024
24032
|
...all.length > 1 ? { deliveries: all } : {},
|
|
24025
24033
|
...recorded.length ? { recorded, notSent: NOT_SENT } : {},
|
|
24026
24034
|
...joinedCard ? { joinedCard: true } : {},
|
|
24027
|
-
...joinedCall ? { joinedCall: true } : {}
|
|
24035
|
+
...joinedCall ? { joinedCall: true } : {},
|
|
24036
|
+
...demoted ? { demoted } : {}
|
|
24028
24037
|
};
|
|
24029
24038
|
};
|
|
24030
24039
|
const settled = (d) => d.kind === "notification" || d.state === "closed" || d.answers.length > 0 || d.entries.some((e) => e.kind === "contribution");
|
|
@@ -24156,9 +24165,9 @@ function connect(line) {
|
|
|
24156
24165
|
ws.addEventListener("error", again);
|
|
24157
24166
|
}
|
|
24158
24167
|
function subscribeRealtime(args) {
|
|
24159
|
-
const
|
|
24160
|
-
let line = lines.get(
|
|
24161
|
-
if (!line) lines.set(
|
|
24168
|
+
const key22 = `${args.url} ${args.anonKey}`;
|
|
24169
|
+
let line = lines.get(key22);
|
|
24170
|
+
if (!line) lines.set(key22, line = { url: args.url, anonKey: args.anonKey, open: false, attempt: 0, ref: 0, topics: /* @__PURE__ */ new Map() });
|
|
24162
24171
|
let t = line.topics.get(args.topic);
|
|
24163
24172
|
if (!t) {
|
|
24164
24173
|
line.topics.set(args.topic, t = { listeners: /* @__PURE__ */ new Set(), joined: false, attempt: 0 });
|
|
@@ -24180,7 +24189,7 @@ function subscribeRealtime(args) {
|
|
|
24180
24189
|
if (line.open) frame(line, `realtime:${args.topic}`, "phx_leave", {});
|
|
24181
24190
|
return;
|
|
24182
24191
|
}
|
|
24183
|
-
lines.delete(
|
|
24192
|
+
lines.delete(key22);
|
|
24184
24193
|
stop(line);
|
|
24185
24194
|
try {
|
|
24186
24195
|
line.ws?.close();
|
|
@@ -24212,7 +24221,29 @@ async function subscribeWake(onNudge, opts = {}) {
|
|
|
24212
24221
|
}
|
|
24213
24222
|
};
|
|
24214
24223
|
}
|
|
24215
|
-
|
|
24224
|
+
function withCodexEnv(text) {
|
|
24225
|
+
const head = /^\[mcp_servers\.paigy\][ \t]*(?:#[^\n]*)?\r?\n/m.exec(text);
|
|
24226
|
+
if (!head) return null;
|
|
24227
|
+
const start = head.index + head[0].length;
|
|
24228
|
+
const next = /^\[/m.exec(text.slice(start));
|
|
24229
|
+
const end = next ? start + next.index : text.length;
|
|
24230
|
+
const block2 = text.slice(start, end);
|
|
24231
|
+
const assignment = /^[ \t]*env_vars[ \t]*=/m.exec(block2);
|
|
24232
|
+
let updated;
|
|
24233
|
+
if (!assignment) updated = `env_vars = [${CODEX_ENV.map((v) => JSON.stringify(v)).join(", ")}]
|
|
24234
|
+
${block2}`;
|
|
24235
|
+
else {
|
|
24236
|
+
const array = /^[ \t]*env_vars[ \t]*=[ \t]*\[((?:#[^\n]*|[^\]"'#]|"[^"\n]*"|'[^'\n]*')*)\]/m.exec(block2);
|
|
24237
|
+
if (!array) return null;
|
|
24238
|
+
const existing = [...array[1].matchAll(/"([^"\n]*)"|'([^'\n]*)'|#[^\n]*/g)].flatMap((m) => m[0].startsWith("#") ? [] : [m[1] ?? m[2]]);
|
|
24239
|
+
const missing2 = CODEX_ENV.filter((v) => !existing.includes(v));
|
|
24240
|
+
if (!missing2.length) return text;
|
|
24241
|
+
const opening = array.index + array[0].indexOf("[") + 1;
|
|
24242
|
+
updated = block2.slice(0, opening) + missing2.map((v) => JSON.stringify(v)).join(", ") + (existing.length ? ", " : "") + block2.slice(opening);
|
|
24243
|
+
}
|
|
24244
|
+
return text.slice(0, start) + updated + text.slice(end);
|
|
24245
|
+
}
|
|
24246
|
+
var import_undici, require2, CODEX_ENV, BACKEND_URL, NETWORK_MSG, PROXY_ENV, agent, INSTANCE_ID, WORKSPACE_ID, envSession, lineage, CLIENT, ignoreOverride, defaultOptions, getDefaultOptions, getRefs, getRelativePath, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, get$ref, addMeta, zodToJsonSchema, OPTIONS_MIN, OPTIONS_MAX, OptionSchema, OptionInputSchema, NIGHT, AskInputSchema, StartContactSchema, ContactSchema, CONTACT_SCHEMA, CONTACT_DESCRIPTION, CreateGoalSchema, CreateGoalToolSchema, CREATE_GOAL_DESCRIPTION, UpdateGoalSchema, UpdateGoalToolSchema, ClaimGoalSchema, GetGoalSchema, GET_GOAL_DESCRIPTION, UPDATE_GOAL_DESCRIPTION, CLAIM_GOAL_DESCRIPTION, CHECK_REPLIES_DESCRIPTION, CheckRepliesSchema, AGENT_TOOLS, AGENT_TOOL_NAMES, id, key, participant, SourceSchema, ResultRefSchema, NodeRefSchema, DependencySchema, goalState, existingGoalChanges, GoalChangeSchema, BrainGoalChangeSchema, option, QuestionChangeSchema, lessonScope, LessonChangeSchema, BrainNextSchema, messageBase, BrainMessageSchema, BrainSearchSchema, BrainResultSchema, str, strs, CompactResultSchema, COMPACT_RESULT_JSON_SCHEMA, LIVE_MS, WORKING_MS, ContextSchema, ParticipantSchema, TransformSchema, VisualSchema, NotifyLevelSchema, SelectShapeSchema, ReceiptEventSchema, AttentionSchema, NotifyRequestFields, NotifyRequestSchema, NotifyStatusSchema, AgentStateSchema, TurnSchema, UserAnswerSchema, IntentSchema, RideAlongSchema, AwaitItemSchema, VoiceKeySchema, AgendaTurnSchema, CLAIM_STALE_MS, InboxItemSchema, APNS_TOKEN_RE, PushTokenSchema, MissedCallSchema, clock, QUIET, BrokerTuningSchema, UserSettingsSchema, HistoryWorkSchema, HistoryEntrySchema, HistoryPageSchema, ACTIVITY_LINES, ACTIVITY_LINE_MAX, AgentActivitySchema, ConnectionSummarySchema, LedgerItemSchema, AgentLedgerSchema, ReassignResultSchema, LessonStateSchema, LessonViewSchema, QueueQuestionSchema, QueueReplySchema, QueueItemSchema, QueueDeltaSchema, COLD_AFTER_MS, NoteSourceSchema, NoteStatusSchema, NoteRepeatSchema, DecisionSchema, NoteSchema, TriageItemSchema, TriageAssignmentSchema, TriageStatusSchema, SubmitTriageSchema, TriageProposalSchema, AcceptTriageSchema, AcceptTriageResultSchema, DeliveryModeSchema, WAKE_EVENT, wakeChannel, RegisterDeliverySchema, OAuthStartSchema, DeliveryConfigSchema, HostDecisionSchema, WakeNudgeSchema, PairingStatusSchema, DeviceCodeSchema, DeviceInfoSchema, DeviceTokenSchema, SupportRequestSchema, NotificationFeedbackKindSchema, SlimOptionSchema, QuestionRowSchema, WorkStateSchema, WorkRowSchema, ComputerRowSchema, AgentRowSchema, SnapshotSchema, CallRecapSchema, TOKEN_PATH, KEY_PATH, sleep, UnpairedError, RevokedError, ApiError, tokenOverride, authToken, AWAIT_WINDOW_MS, asked, NOT_SENT, DEMOTED, HEARTBEAT_MS, RETRY_MS, JOIN, JOIN_TIMEOUT_MS, lines;
|
|
24216
24247
|
var init_dist = __esm({
|
|
24217
24248
|
"../../packages/sdk/dist/index.js"() {
|
|
24218
24249
|
"use strict";
|
|
@@ -24223,9 +24254,10 @@ var init_dist = __esm({
|
|
|
24223
24254
|
init_v3();
|
|
24224
24255
|
init_v3();
|
|
24225
24256
|
init_zod();
|
|
24257
|
+
init_zod();
|
|
24226
24258
|
import_undici = __toESM(require_undici(), 1);
|
|
24227
24259
|
require2 = __sdkCreateRequire(import.meta.url);
|
|
24228
|
-
CODEX_ENV = ["CODEX_THREAD_ID", "CODEX_SESSION_ID", "PAIGY_TOKEN", "PAIGY_SESSION_ID", "PAIGY_HARNESS", "PAIGY_INSTANCE_ID"];
|
|
24260
|
+
CODEX_ENV = ["CODEX_THREAD_ID", "CODEX_SESSION_ID", "CODEX_HOME", "PAIGY_TOKEN", "PAIGY_SESSION_ID", "PAIGY_HARNESS", "PAIGY_INSTANCE_ID", "PAIGY_ON_WAKE"];
|
|
24229
24261
|
BACKEND_URL = process.env.PAIGY_BACKEND_URL ?? "https://paigy.ai";
|
|
24230
24262
|
NETWORK_MSG = `Can't reach ${BACKEND_URL} \u2014 the connection was blocked or dropped before an HTTP response. If this agent runs in a sandboxed environment with a network allowlist (e.g. Claude Code on the web, CI), ask the user to add the Paigy domain (paigy.ai) to the environment's allowed domains, then retry.`;
|
|
24231
24263
|
PROXY_ENV = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
@@ -24237,8 +24269,8 @@ var init_dist = __esm({
|
|
|
24237
24269
|
return INSTANCE_ID;
|
|
24238
24270
|
}
|
|
24239
24271
|
})();
|
|
24240
|
-
envSession = (
|
|
24241
|
-
const v = process.env[
|
|
24272
|
+
envSession = (key22) => {
|
|
24273
|
+
const v = process.env[key22];
|
|
24242
24274
|
return v && v.trim() ? v : void 0;
|
|
24243
24275
|
};
|
|
24244
24276
|
ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
@@ -24623,32 +24655,31 @@ var init_dist = __esm({
|
|
|
24623
24655
|
NIGHT = { from: 23, to: 7 };
|
|
24624
24656
|
AskInputSchema = external_exports.object({
|
|
24625
24657
|
id: external_exports.string().optional().describe("Optional idempotency key or client-side ID for this specific ask."),
|
|
24626
|
-
parentId: external_exports.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and
|
|
24658
|
+
parentId: external_exports.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and the question starts a new Goal of yours."),
|
|
24627
24659
|
repo: external_exports.string().optional().describe("Optional repository context."),
|
|
24628
24660
|
ask: external_exports.string().trim().min(1).max(1e4).describe(
|
|
24629
|
-
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy
|
|
24661
|
+
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy sends each ask exactly as you wrote it: a bundled ask arrives as one card. News, progress and findings are their own contact; ANY contact for a person already on a call JOINS that call, whatever channel you asked for, so several arrive as one call."
|
|
24630
24662
|
),
|
|
24631
24663
|
options: external_exports.array(OptionInputSchema).min(1).max(6).optional(),
|
|
24632
|
-
//
|
|
24633
|
-
//
|
|
24634
|
-
//
|
|
24635
|
-
//
|
|
24636
|
-
// shape (`goal/intake.ts` `answerOf`), and this reaches it as the agent's view, weighed, not obeyed.
|
|
24664
|
+
// HOW THE OPTIONS ARE ANSWERED, SAID BY THE AGENT (owner, 2026-10-02: "one and many makes sense";
|
|
24665
|
+
// brain_prompts.md §1: structured agent questions need no model). Every card was pick-one while no
|
|
24666
|
+
// agent sent this; no read reshapes cards any more, so this is the card's shape, and the
|
|
24667
|
+
// description says so plainly.
|
|
24637
24668
|
select: external_exports.enum(["one", "many"]).optional().describe(
|
|
24638
|
-
|
|
24669
|
+
'How the options are answered: "many" makes a checklist (they may want several, e.g. independent fixes), "one" (the default) a pick (choosing one rules out the others). Send "many" whenever more than one option could be wanted at once. The person can always answer in their own words as well. Ignored without options.'
|
|
24639
24670
|
),
|
|
24640
24671
|
answers: external_exports.string().trim().regex(/^[0-9a-fA-F-]{8,36}$/).optional().describe(
|
|
24641
|
-
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them.
|
|
24672
|
+
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them. parentId is optional here: the question's own Goal is used. The reply is sent to them as it is; to also ask something new, send that as its own ask."
|
|
24642
24673
|
)
|
|
24643
24674
|
}).strict();
|
|
24644
24675
|
StartContactSchema = external_exports.object({
|
|
24645
|
-
asks: external_exports.array(AskInputSchema).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is;
|
|
24676
|
+
asks: external_exports.array(AskInputSchema).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is; an ask naming no Goal starts a new Goal of yours."),
|
|
24646
24677
|
waiting: external_exports.enum(["none", "hard"]).default("none").describe("hard requests a call even when channel is notification; user permissions and ring cooldowns still apply."),
|
|
24647
24678
|
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
24648
24679
|
}).strict();
|
|
24649
24680
|
ContactSchema = external_exports.union([StartContactSchema, external_exports.object({ deliveryId: external_exports.string().uuid() }).strict()]);
|
|
24650
24681
|
CONTACT_SCHEMA = { type: "object", ...mcpInputSchema(ContactSchema) };
|
|
24651
|
-
CONTACT_DESCRIPTION = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none
|
|
24682
|
+
CONTACT_DESCRIPTION = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none starts a new Goal of yours. Notification returns immediately; collect durable answers with check_replies. On stdio, a Call holds one cancellable ~45s window; continue with ONLY {deliveryId}. One question per 'ask'; several questions are several objects in 'asks'. Each ask is sent exactly as written, with no reading in between: a bundled ask arrives as one card, so separate questions are separate asks. An ask with no options that is not blocking is a report, and a report is an UPDATE, never a claim on them: it reaches them and is listed apart from what waits on them, so no answer is owed and none should be awaited. On a Goal whose report card is still open it is added to that card, with no new push; Where your work stands while under way is progress: report it with update_goal, not contact. Send options (or waiting:'hard') when you actually need an answer. Each option's label must stand on its own \u2014 the person may see only the labels \u2014 so never a label that points into your text ('All three', 'Option 2', '1 and 3 only'). select:'many' makes the card a checklist, for independent options they may want several of; select:'one' (the default) a pick, for alternatives. The person can always answer in their own words, so never add an 'Other' option. If the person is already on a call, your contact joins that call automatically \u2014 whatever channel you asked for, with no ring \u2014 and the Delivery it returns IS that call: reread it with contact({deliveryId}) to see everything answered on it so far, and contact again while it is live to add information or a further question to the same call.";
|
|
24652
24683
|
CreateGoalSchema = external_exports.object({
|
|
24653
24684
|
outcome: external_exports.string().trim().min(1).max(1e4),
|
|
24654
24685
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -24722,6 +24753,153 @@ var init_dist = __esm({
|
|
|
24722
24753
|
{ name: "update_goal", description: UPDATE_GOAL_DESCRIPTION, inputSchema: mcpInputSchema(UpdateGoalToolSchema) }
|
|
24723
24754
|
];
|
|
24724
24755
|
AGENT_TOOL_NAMES = AGENT_TOOLS.map((t) => t.name);
|
|
24756
|
+
id = external_exports.string().uuid();
|
|
24757
|
+
key = external_exports.string().min(1).max(40);
|
|
24758
|
+
participant = external_exports.string().regex(/^(human|agent):.+$/, "a participant ID such as agent:<uuid>");
|
|
24759
|
+
SourceSchema = external_exports.object({ entryId: id }).strict();
|
|
24760
|
+
ResultRefSchema = external_exports.union([external_exports.object({ id }).strict(), external_exports.object({ local: key }).strict()]);
|
|
24761
|
+
NodeRefSchema = external_exports.object({ type: external_exports.enum(["goal", "question"]), id }).strict();
|
|
24762
|
+
DependencySchema = external_exports.object({
|
|
24763
|
+
blocker: NodeRefSchema,
|
|
24764
|
+
blocked: NodeRefSchema,
|
|
24765
|
+
action: external_exports.enum(["start", "complete", "answer"]),
|
|
24766
|
+
reason: external_exports.string().max(500).optional()
|
|
24767
|
+
}).strict();
|
|
24768
|
+
goalState = external_exports.enum(["open", "completed", "canceled"]);
|
|
24769
|
+
existingGoalChanges = [
|
|
24770
|
+
external_exports.object({ kind: external_exports.literal("edit"), goalId: id, title: external_exports.string().min(1).max(120).optional(), outcome: external_exports.string().min(1).optional() }).strict().refine((c) => c.title !== void 0 || c.outcome !== void 0, "an edit changes the title or the outcome"),
|
|
24771
|
+
external_exports.object({ kind: external_exports.literal("state"), goalId: id, state: goalState }).strict(),
|
|
24772
|
+
external_exports.object({ kind: external_exports.literal("assign"), goalId: id, ownerId: participant }).strict(),
|
|
24773
|
+
external_exports.object({ kind: external_exports.literal("defer"), goalId: id, until: external_exports.string().datetime().nullable() }).strict(),
|
|
24774
|
+
external_exports.object({ kind: external_exports.literal("move"), goalId: id, parentGoalId: id.nullable() }).strict(),
|
|
24775
|
+
external_exports.object({
|
|
24776
|
+
kind: external_exports.literal("dependency"),
|
|
24777
|
+
change: external_exports.enum(["add", "remove"]),
|
|
24778
|
+
goalId: id,
|
|
24779
|
+
dependsOnGoalId: id,
|
|
24780
|
+
action: external_exports.enum(["start", "complete"]),
|
|
24781
|
+
reason: external_exports.string().max(500).optional()
|
|
24782
|
+
}).strict()
|
|
24783
|
+
];
|
|
24784
|
+
GoalChangeSchema = external_exports.union([
|
|
24785
|
+
external_exports.object({
|
|
24786
|
+
kind: external_exports.literal("create"),
|
|
24787
|
+
title: external_exports.string().min(1).max(120),
|
|
24788
|
+
outcome: external_exports.string().min(1),
|
|
24789
|
+
ownerId: participant,
|
|
24790
|
+
parentGoalId: id.optional(),
|
|
24791
|
+
sourceEntryIds: external_exports.array(id)
|
|
24792
|
+
}).strict(),
|
|
24793
|
+
...existingGoalChanges
|
|
24794
|
+
]);
|
|
24795
|
+
BrainGoalChangeSchema = external_exports.union([
|
|
24796
|
+
// newSession: Paigy starts a session to own it (owner, 2026-10-06); until it has, the person owns it.
|
|
24797
|
+
external_exports.object({
|
|
24798
|
+
kind: external_exports.literal("create"),
|
|
24799
|
+
outcome: external_exports.string().min(1),
|
|
24800
|
+
title: external_exports.string().min(1).max(120),
|
|
24801
|
+
ownerId: participant,
|
|
24802
|
+
parentGoal: ResultRefSchema.nullable(),
|
|
24803
|
+
newSession: external_exports.literal(true).optional()
|
|
24804
|
+
}).strict(),
|
|
24805
|
+
...existingGoalChanges
|
|
24806
|
+
]);
|
|
24807
|
+
option = external_exports.object({ id: external_exports.string().min(1).max(40), label: external_exports.string().min(1), hint: external_exports.string().optional() }).strict();
|
|
24808
|
+
QuestionChangeSchema = external_exports.union([
|
|
24809
|
+
external_exports.object({
|
|
24810
|
+
kind: external_exports.literal("create"),
|
|
24811
|
+
text: external_exports.string().min(1),
|
|
24812
|
+
answererId: participant,
|
|
24813
|
+
goal: ResultRefSchema.optional(),
|
|
24814
|
+
blocks: external_exports.array(external_exports.object({ question: ResultRefSchema }).strict()),
|
|
24815
|
+
options: external_exports.array(option).min(2).optional(),
|
|
24816
|
+
pickMode: external_exports.enum(["one", "many", "rank"]).optional()
|
|
24817
|
+
}).strict().refine((c) => c.options === void 0 === (c.pickMode === void 0), "options and pickMode come together"),
|
|
24818
|
+
external_exports.object({ kind: external_exports.literal("edit"), questionId: id, text: external_exports.string().min(1) }).strict(),
|
|
24819
|
+
external_exports.object({ kind: external_exports.literal("assign"), questionId: id, answererId: participant }).strict(),
|
|
24820
|
+
external_exports.object({ kind: external_exports.literal("withdraw"), questionId: id }).strict(),
|
|
24821
|
+
external_exports.object({ kind: external_exports.literal("dependency"), change: external_exports.enum(["add", "remove"]), edge: DependencySchema }).strict()
|
|
24822
|
+
]);
|
|
24823
|
+
lessonScope = external_exports.union([
|
|
24824
|
+
external_exports.object({ kind: external_exports.literal("user") }).strict(),
|
|
24825
|
+
external_exports.object({ kind: external_exports.literal("goal"), goal: ResultRefSchema }).strict()
|
|
24826
|
+
]);
|
|
24827
|
+
LessonChangeSchema = external_exports.union([
|
|
24828
|
+
external_exports.object({ kind: external_exports.literal("remember"), text: external_exports.string().min(1), scope: lessonScope }).strict(),
|
|
24829
|
+
external_exports.object({ kind: external_exports.literal("revise"), lessonId: id, text: external_exports.string().min(1), scope: lessonScope }).strict(),
|
|
24830
|
+
external_exports.object({ kind: external_exports.literal("withdraw"), lessonId: id }).strict()
|
|
24831
|
+
]);
|
|
24832
|
+
BrainNextSchema = external_exports.object({
|
|
24833
|
+
instructions: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key).min(1) }).strict()),
|
|
24834
|
+
say: external_exports.array(key),
|
|
24835
|
+
then: external_exports.enum(["listen", "hold", "end", "none"]),
|
|
24836
|
+
waitFor: external_exports.array(ResultRefSchema),
|
|
24837
|
+
reason: external_exports.string()
|
|
24838
|
+
}).strict();
|
|
24839
|
+
messageBase = {
|
|
24840
|
+
key,
|
|
24841
|
+
text: external_exports.string().min(1),
|
|
24842
|
+
goals: external_exports.array(ResultRefSchema),
|
|
24843
|
+
questions: external_exports.array(ResultRefSchema),
|
|
24844
|
+
entryKeys: external_exports.array(key),
|
|
24845
|
+
obligationIds: external_exports.array(id)
|
|
24846
|
+
};
|
|
24847
|
+
BrainMessageSchema = external_exports.union([
|
|
24848
|
+
external_exports.object({ ...messageBase, to: external_exports.object({ kind: external_exports.literal("user") }).strict() }).strict(),
|
|
24849
|
+
external_exports.object({
|
|
24850
|
+
...messageBase,
|
|
24851
|
+
to: external_exports.object({ kind: external_exports.literal("agent"), agentId: external_exports.string().regex(/^agent:(?!paigy$)\S+$/) }).strict(),
|
|
24852
|
+
call: external_exports.object({ callId: id, listen: external_exports.literal(true) }).strict().optional()
|
|
24853
|
+
}).strict()
|
|
24854
|
+
]);
|
|
24855
|
+
BrainSearchSchema = external_exports.object({
|
|
24856
|
+
query: external_exports.string().min(1).max(500),
|
|
24857
|
+
within: external_exports.array(external_exports.enum(["entries", "goals", "answers"])).min(1),
|
|
24858
|
+
goalId: id.optional()
|
|
24859
|
+
}).strict();
|
|
24860
|
+
BrainResultSchema = external_exports.object({
|
|
24861
|
+
messages: external_exports.array(BrainMessageSchema),
|
|
24862
|
+
entries: external_exports.array(external_exports.object({ key, sources: external_exports.array(SourceSchema).min(1), goals: external_exports.array(ResultRefSchema) }).strict()),
|
|
24863
|
+
questions: external_exports.array(external_exports.object({ key, entryKeys: external_exports.array(key), change: QuestionChangeSchema }).strict()),
|
|
24864
|
+
answers: external_exports.array(external_exports.object({
|
|
24865
|
+
question: ResultRefSchema,
|
|
24866
|
+
entryKeys: external_exports.array(key).min(1),
|
|
24867
|
+
summary: external_exports.string().min(1),
|
|
24868
|
+
selectedOptionIds: external_exports.array(external_exports.string().min(1)).optional()
|
|
24869
|
+
}).strict()),
|
|
24870
|
+
goals: external_exports.array(external_exports.object({ key, entryKeys: external_exports.array(key), change: BrainGoalChangeSchema }).strict()),
|
|
24871
|
+
feedback: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key).min(1) }).strict()),
|
|
24872
|
+
lessons: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key).min(1), change: LessonChangeSchema }).strict()),
|
|
24873
|
+
next: BrainNextSchema,
|
|
24874
|
+
search: BrainSearchSchema.optional()
|
|
24875
|
+
}).strict();
|
|
24876
|
+
str = external_exports.string();
|
|
24877
|
+
strs = external_exports.array(external_exports.string());
|
|
24878
|
+
CompactResultSchema = external_exports.object({
|
|
24879
|
+
next: external_exports.object({ say: strs, then: external_exports.enum(["listen", "hold", "end", "none"]), waitFor: strs, reason: str, instructions: strs }).strict(),
|
|
24880
|
+
messages: external_exports.array(external_exports.object({ key: str, to: str, text: str, about: strs, entries: strs, owed: strs, inviteToCall: external_exports.boolean() }).strict()),
|
|
24881
|
+
entries: external_exports.array(external_exports.object({ key: str, from: str, on: strs }).strict()),
|
|
24882
|
+
answers: external_exports.array(external_exports.object({ question: str, entries: strs, summary: str, picked: strs }).strict()),
|
|
24883
|
+
changes: external_exports.array(external_exports.object({
|
|
24884
|
+
key: str,
|
|
24885
|
+
what: external_exports.enum(["goal", "question", "lesson"]),
|
|
24886
|
+
op: external_exports.enum(["create", "edit", "assign", "open", "complete", "cancel", "defer", "move", "block", "unblock", "withdraw", "remember", "revise"]),
|
|
24887
|
+
id: str,
|
|
24888
|
+
text: str,
|
|
24889
|
+
title: str,
|
|
24890
|
+
who: str,
|
|
24891
|
+
under: str,
|
|
24892
|
+
gate: external_exports.enum(["start", "complete", "answer", "none"]),
|
|
24893
|
+
options: external_exports.array(external_exports.object({ id: str, label: str }).strict()),
|
|
24894
|
+
pick: external_exports.enum(["one", "many", "rank", "words"]),
|
|
24895
|
+
entries: strs
|
|
24896
|
+
}).strict()),
|
|
24897
|
+
feedback: external_exports.array(strs),
|
|
24898
|
+
search: external_exports.object({ query: str, within: strs, goal: str }).strict()
|
|
24899
|
+
}).strict();
|
|
24900
|
+
COMPACT_RESULT_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
24901
|
+
zodToJsonSchema(CompactResultSchema, { $refStrategy: "none" })
|
|
24902
|
+
);
|
|
24725
24903
|
LIVE_MS = 3 * 6e4;
|
|
24726
24904
|
WORKING_MS = 60 * 6e4;
|
|
24727
24905
|
ContextSchema = external_exports.object({
|
|
@@ -24941,7 +25119,7 @@ var init_dist = __esm({
|
|
|
24941
25119
|
* (`parseDelay`, #1292), and a value here simply wins over that reading. */
|
|
24942
25120
|
dueInSeconds: external_exports.number().int().positive().optional(),
|
|
24943
25121
|
/** Feedback only (#812): WHICH failure the complaint names — typed by the mapper that
|
|
24944
|
-
* already read the utterance, so `
|
|
25122
|
+
* already read the utterance, so `signals.kind` stops defaulting to
|
|
24945
25123
|
* 'other' on every row. A table that records that something was wrong and nothing
|
|
24946
25124
|
* about what cannot answer "is the bot looping less this week?". */
|
|
24947
25125
|
fault: external_exports.enum(["loop", "unanswered", "overridden", "misheard", "slow", "other"]).optional()
|
|
@@ -25225,7 +25403,18 @@ var init_dist = __esm({
|
|
|
25225
25403
|
/** THAT GOAL'S NAME (#2416) — what Activity's row is headed by, since a row there is one Goal
|
|
25226
25404
|
* and the cards it holds sit behind it. Stamped by the same read as `goalState`. */
|
|
25227
25405
|
goalTitle: external_exports.string().optional()
|
|
25228
|
-
}).optional()
|
|
25406
|
+
}).optional(),
|
|
25407
|
+
/** WHAT THIS CARD IS, IN TWELVE CHARACTERS (#3019) — the hash of every other field on it, stamped
|
|
25408
|
+
* by the one read that serves the open list (`apps/api/src/inbox/project.ts` `inboxFor`). It is
|
|
25409
|
+
* how the incremental read knows a card has not moved: the phone echoes back the revs it holds
|
|
25410
|
+
* (`POST /api/inbox/changes`) and is sent only the cards whose rev differs.
|
|
25411
|
+
*
|
|
25412
|
+
* THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK — the same mechanism as `QueueItem.rev`
|
|
25413
|
+
* (#2928) and an entry's (#3018), for the same reason: a card shows facts no `updated_at` of its
|
|
25414
|
+
* own moves (its Goal's state and name, how cold the work behind it has gone, whether a ring is
|
|
25415
|
+
* live). Optional, so a fixture, the demo and the archive lens need not spell one, and a card
|
|
25416
|
+
* with no rev is simply always re-sent. */
|
|
25417
|
+
rev: external_exports.string().optional()
|
|
25229
25418
|
});
|
|
25230
25419
|
APNS_TOKEN_RE = /^[0-9a-fA-F]{64}$/;
|
|
25231
25420
|
PushTokenSchema = external_exports.object({
|
|
@@ -25437,39 +25626,22 @@ var init_dist = __esm({
|
|
|
25437
25626
|
moved: external_exports.object({ asks: external_exports.number(), answered: external_exports.number(), requests: external_exports.number(), goals: external_exports.number(), callbacks: external_exports.number() }),
|
|
25438
25627
|
parentId: external_exports.string().nullable()
|
|
25439
25628
|
});
|
|
25440
|
-
|
|
25441
|
-
|
|
25629
|
+
LessonStateSchema = external_exports.enum(["active", "proposed", "retired"]);
|
|
25630
|
+
LessonViewSchema = external_exports.object({
|
|
25442
25631
|
id: external_exports.string(),
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
/** The
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25449
|
-
rationale: external_exports.string().nullable(),
|
|
25450
|
-
/** Where the ruling lives: a repo/workspace, or 'global'. */
|
|
25451
|
-
scope: external_exports.string(),
|
|
25452
|
-
ring: MoveRingSchema,
|
|
25453
|
-
/** True = the user pinned it with `always` (travel granted by hand, not by evidence). */
|
|
25632
|
+
text: external_exports.string(),
|
|
25633
|
+
state: LessonStateSchema,
|
|
25634
|
+
/** The Goal it is scoped to; null = the whole account. */
|
|
25635
|
+
scopeGoalId: external_exports.string().nullable(),
|
|
25636
|
+
goalTitle: external_exports.string().nullable(),
|
|
25637
|
+
version: external_exports.number(),
|
|
25454
25638
|
pinned: external_exports.boolean(),
|
|
25455
|
-
/**
|
|
25456
|
-
|
|
25457
|
-
|
|
25458
|
-
|
|
25459
|
-
|
|
25460
|
-
|
|
25461
|
-
lastUsedAt: external_exports.string().nullable(),
|
|
25462
|
-
/** How many asks it has answered. Instrumentation — deliberately NOT an input to the
|
|
25463
|
-
* evidence curve: firing says the question keeps arising, not that the ruling is right. */
|
|
25464
|
-
usedCount: external_exports.number(),
|
|
25465
|
-
/** Ledger: outcomes that said it held up. Saturating — the tenth is worth almost nothing. */
|
|
25466
|
-
confirms: external_exports.number(),
|
|
25467
|
-
/** Ledger: contradictions, in signal units (a full override = 1, weaker signals less).
|
|
25468
|
-
* Linear and priced above the entire confirmation budget, so any full counter wins. */
|
|
25469
|
-
counters: external_exports.number(),
|
|
25470
|
-
/** The agent that asked the question this move came from, when known. Null for a move
|
|
25471
|
-
* distilled from a clarify ruling (those carry no agent) or one whose source rows are gone. */
|
|
25472
|
-
learnedFrom: external_exports.object({ id: external_exports.string(), name: external_exports.string() }).nullable()
|
|
25639
|
+
/** When the person last wrote its text themselves. */
|
|
25640
|
+
editedAt: external_exports.string().nullable(),
|
|
25641
|
+
createdAt: external_exports.string(),
|
|
25642
|
+
updatedAt: external_exports.string(),
|
|
25643
|
+
/** The Entries it came from, oldest first; `words` is null when an Entry has none to show (sealed). */
|
|
25644
|
+
sources: external_exports.array(external_exports.object({ entryId: external_exports.string(), words: external_exports.string().nullable(), at: external_exports.string() }))
|
|
25473
25645
|
});
|
|
25474
25646
|
QueueQuestionSchema = external_exports.object({
|
|
25475
25647
|
/** The decision need's id — what an answer is accepted against. */
|
|
@@ -25597,7 +25769,22 @@ var init_dist = __esm({
|
|
|
25597
25769
|
* minute after the person speaks erases their instant from it, and the durable traces the client
|
|
25598
25770
|
* can see (`replies`, `questions[].answeredAt`) miss a spontaneous note entirely — a `request`
|
|
25599
25771
|
* Entry with no `about_id` is in neither. */
|
|
25600
|
-
lastPersonAt: external_exports.string().nullable().optional()
|
|
25772
|
+
lastPersonAt: external_exports.string().nullable().optional(),
|
|
25773
|
+
/** WHAT THIS ROW IS, IN TWELVE CHARACTERS (#2928) — the hash of every other field on it, stamped
|
|
25774
|
+
* by the one projection that builds the row (`apps/api/src/goal/queue.ts`). It is how the
|
|
25775
|
+
* incremental read knows a row has not moved: the phone echoes back the revs it holds
|
|
25776
|
+
* (`POST /api/goals/changes`) and is sent only the rows whose rev differs.
|
|
25777
|
+
*
|
|
25778
|
+
* IT IS THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK. Nothing here reasons about which
|
|
25779
|
+
* writes change which field — the comparison is over the bytes the phone is holding, so a fact
|
|
25780
|
+
* the row shows that no `updated_at` moves for (a lease lapsing, a dependency's state, a
|
|
25781
|
+
* sibling appearing in `childGoalIds`) cannot go unnoticed. Optional because a hand-built
|
|
25782
|
+
* queue (a fixture, the demo) spells none, and a row with no rev is simply always re-sent. */
|
|
25783
|
+
rev: external_exports.string().optional()
|
|
25784
|
+
});
|
|
25785
|
+
QueueDeltaSchema = external_exports.object({
|
|
25786
|
+
ids: external_exports.array(external_exports.string()),
|
|
25787
|
+
items: external_exports.array(QueueItemSchema)
|
|
25601
25788
|
});
|
|
25602
25789
|
COLD_AFTER_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
25603
25790
|
NoteSourceSchema = external_exports.enum(["app", "call"]);
|
|
@@ -25770,6 +25957,11 @@ var init_dist = __esm({
|
|
|
25770
25957
|
/** Local host recovery must preserve the launch's runtime and Paigy identity. */
|
|
25771
25958
|
harness: external_exports.enum(["claude", "codex", "agy"]).optional(),
|
|
25772
25959
|
session_id: external_exports.string().uuid().optional(),
|
|
25960
|
+
/** A conversation the host must not resume: its context is full, so every turn fails
|
|
25961
|
+
* ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
|
|
25962
|
+
* whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
|
|
25963
|
+
* copy that types the person's words into a turn that cannot run (Calls, 2026-10-06). */
|
|
25964
|
+
full_session: external_exports.string().optional(),
|
|
25773
25965
|
uik_pub: external_exports.string().nullable().optional()
|
|
25774
25966
|
});
|
|
25775
25967
|
SupportRequestSchema = external_exports.object({
|
|
@@ -25949,6 +26141,7 @@ var init_dist = __esm({
|
|
|
25949
26141
|
authToken = (explicit) => explicit ?? tokenOverride ?? readToken();
|
|
25950
26142
|
AWAIT_WINDOW_MS = 45e3;
|
|
25951
26143
|
NOT_SENT = "Recorded as progress, not sent: nobody was notified. If the person should see it (a result, something to try or check, a finding), contact again and say so; report progress with update_goal.";
|
|
26144
|
+
DEMOTED = "Delivered as a card, not a call: the person's settings do not allow a call right now (silent, quiet hours, or a mode). It has reached them; do not send it again, with or without a Goal.";
|
|
25952
26145
|
HEARTBEAT_MS = 25e3;
|
|
25953
26146
|
RETRY_MS = [1e3, 2e3, 5e3, 1e4, 3e4];
|
|
25954
26147
|
JOIN = { config: { broadcast: { self: false } } };
|
|
@@ -26851,14 +27044,14 @@ var require_regex = __commonJS({
|
|
|
26851
27044
|
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
26852
27045
|
var TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
26853
27046
|
var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
26854
|
-
exports.testKanji = function testKanji(
|
|
26855
|
-
return TEST_KANJI.test(
|
|
27047
|
+
exports.testKanji = function testKanji(str3) {
|
|
27048
|
+
return TEST_KANJI.test(str3);
|
|
26856
27049
|
};
|
|
26857
|
-
exports.testNumeric = function testNumeric(
|
|
26858
|
-
return TEST_NUMERIC.test(
|
|
27050
|
+
exports.testNumeric = function testNumeric(str3) {
|
|
27051
|
+
return TEST_NUMERIC.test(str3);
|
|
26859
27052
|
};
|
|
26860
|
-
exports.testAlphanumeric = function testAlphanumeric(
|
|
26861
|
-
return TEST_ALPHANUMERIC.test(
|
|
27053
|
+
exports.testAlphanumeric = function testAlphanumeric(str3) {
|
|
27054
|
+
return TEST_ALPHANUMERIC.test(str3);
|
|
26862
27055
|
};
|
|
26863
27056
|
}
|
|
26864
27057
|
});
|
|
@@ -27308,11 +27501,11 @@ var require_dijkstra = __commonJS({
|
|
|
27308
27501
|
*/
|
|
27309
27502
|
PriorityQueue: {
|
|
27310
27503
|
make: function(opts) {
|
|
27311
|
-
var T = dijkstra.PriorityQueue, t = {},
|
|
27504
|
+
var T = dijkstra.PriorityQueue, t = {}, key3;
|
|
27312
27505
|
opts = opts || {};
|
|
27313
|
-
for (
|
|
27314
|
-
if (T.hasOwnProperty(
|
|
27315
|
-
t[
|
|
27506
|
+
for (key3 in T) {
|
|
27507
|
+
if (T.hasOwnProperty(key3)) {
|
|
27508
|
+
t[key3] = T[key3];
|
|
27316
27509
|
}
|
|
27317
27510
|
}
|
|
27318
27511
|
t.queue = [];
|
|
@@ -27360,13 +27553,13 @@ var require_segments = __commonJS({
|
|
|
27360
27553
|
var Regex = require_regex();
|
|
27361
27554
|
var Utils = require_utils2();
|
|
27362
27555
|
var dijkstra = require_dijkstra();
|
|
27363
|
-
function getStringByteLength(
|
|
27364
|
-
return unescape(encodeURIComponent(
|
|
27556
|
+
function getStringByteLength(str3) {
|
|
27557
|
+
return unescape(encodeURIComponent(str3)).length;
|
|
27365
27558
|
}
|
|
27366
|
-
function getSegments(regex, mode,
|
|
27559
|
+
function getSegments(regex, mode, str3) {
|
|
27367
27560
|
const segments = [];
|
|
27368
27561
|
let result;
|
|
27369
|
-
while ((result = regex.exec(
|
|
27562
|
+
while ((result = regex.exec(str3)) !== null) {
|
|
27370
27563
|
segments.push({
|
|
27371
27564
|
data: result[0],
|
|
27372
27565
|
index: result.index,
|
|
@@ -27463,18 +27656,18 @@ var require_segments = __commonJS({
|
|
|
27463
27656
|
const currentNodeIds = [];
|
|
27464
27657
|
for (let j = 0; j < nodeGroup.length; j++) {
|
|
27465
27658
|
const node = nodeGroup[j];
|
|
27466
|
-
const
|
|
27467
|
-
currentNodeIds.push(
|
|
27468
|
-
table[
|
|
27469
|
-
graph[
|
|
27659
|
+
const key3 = "" + i + j;
|
|
27660
|
+
currentNodeIds.push(key3);
|
|
27661
|
+
table[key3] = { node, lastCount: 0 };
|
|
27662
|
+
graph[key3] = {};
|
|
27470
27663
|
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
27471
27664
|
const prevNodeId = prevNodeIds[n];
|
|
27472
27665
|
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
27473
|
-
graph[prevNodeId][
|
|
27666
|
+
graph[prevNodeId][key3] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
27474
27667
|
table[prevNodeId].lastCount += node.length;
|
|
27475
27668
|
} else {
|
|
27476
27669
|
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
27477
|
-
graph[prevNodeId][
|
|
27670
|
+
graph[prevNodeId][key3] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
27478
27671
|
}
|
|
27479
27672
|
}
|
|
27480
27673
|
}
|
|
@@ -30200,13 +30393,13 @@ var require_svg_tag = __commonJS({
|
|
|
30200
30393
|
var Utils = require_utils3();
|
|
30201
30394
|
function getColorAttrib(color, attrib) {
|
|
30202
30395
|
const alpha = color.a / 255;
|
|
30203
|
-
const
|
|
30204
|
-
return alpha < 1 ?
|
|
30396
|
+
const str3 = attrib + '="' + color.hex + '"';
|
|
30397
|
+
return alpha < 1 ? str3 + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str3;
|
|
30205
30398
|
}
|
|
30206
30399
|
function svgCmd(cmd, x, y) {
|
|
30207
|
-
let
|
|
30208
|
-
if (typeof y !== "undefined")
|
|
30209
|
-
return
|
|
30400
|
+
let str3 = cmd + x;
|
|
30401
|
+
if (typeof y !== "undefined") str3 += " " + y;
|
|
30402
|
+
return str3;
|
|
30210
30403
|
}
|
|
30211
30404
|
function qrToPath(data, size, margin) {
|
|
30212
30405
|
let path = "";
|
|
@@ -30854,16 +31047,16 @@ function parseVerdicts(raw, knownIds, knownAgents) {
|
|
|
30854
31047
|
const seen = /* @__PURE__ */ new Set();
|
|
30855
31048
|
for (const row of rows) {
|
|
30856
31049
|
const r = row;
|
|
30857
|
-
const
|
|
30858
|
-
if (!
|
|
31050
|
+
const id3 = typeof r?.id === "string" ? r.id : "";
|
|
31051
|
+
if (!id3) {
|
|
30859
31052
|
dropped.push({ row, reason: "no id" });
|
|
30860
31053
|
continue;
|
|
30861
31054
|
}
|
|
30862
|
-
if (!knownIds.has(
|
|
31055
|
+
if (!knownIds.has(id3)) {
|
|
30863
31056
|
dropped.push({ row, reason: "id is not a note in this queue" });
|
|
30864
31057
|
continue;
|
|
30865
31058
|
}
|
|
30866
|
-
if (seen.has(
|
|
31059
|
+
if (seen.has(id3)) {
|
|
30867
31060
|
dropped.push({ row, reason: "duplicate verdict for this note" });
|
|
30868
31061
|
continue;
|
|
30869
31062
|
}
|
|
@@ -30878,12 +31071,12 @@ function parseVerdicts(raw, knownIds, knownAgents) {
|
|
|
30878
31071
|
continue;
|
|
30879
31072
|
}
|
|
30880
31073
|
verdicts.push({
|
|
30881
|
-
id,
|
|
31074
|
+
id: id3,
|
|
30882
31075
|
verdict,
|
|
30883
31076
|
agent: verdict === "assign" ? agent2 : null,
|
|
30884
31077
|
why: typeof r?.why === "string" ? r.why.trim().slice(0, 200) : null
|
|
30885
31078
|
});
|
|
30886
|
-
seen.add(
|
|
31079
|
+
seen.add(id3);
|
|
30887
31080
|
}
|
|
30888
31081
|
return { ok: true, verdicts, dropped };
|
|
30889
31082
|
}
|
|
@@ -31051,7 +31244,7 @@ async function runTriage(opts, deps = {}) {
|
|
|
31051
31244
|
const acted = suggested(run);
|
|
31052
31245
|
log(acted === 0 ? "Nothing to suggest \u2014 sent, so your phone shows the queue as clean." : `Sent to your phone \u2014 accept it there (${plural(acted, "suggestion")}).`);
|
|
31053
31246
|
if (!opts.apply) return 0;
|
|
31054
|
-
const accept = deps.accept ?? ((
|
|
31247
|
+
const accept = deps.accept ?? ((id3, body) => acceptTriage(id3, body));
|
|
31055
31248
|
const groups = [
|
|
31056
31249
|
{ body: { group: "close" }, label: `close ${plural(run.close.length, "note")}`, count: run.close.length, preapproved: opts.yes.close },
|
|
31057
31250
|
{ body: { group: "stale" }, label: `close ${plural(run.stale.length, "stale note")}`, count: run.stale.length, preapproved: opts.yes.stale },
|
|
@@ -31300,10 +31493,10 @@ var AcpDriver = class {
|
|
|
31300
31493
|
return this.flush();
|
|
31301
31494
|
}
|
|
31302
31495
|
/** Answer a PermissionEvent (ask mode). The id is the request's JSON-RPC id as a string. */
|
|
31303
|
-
respond(
|
|
31304
|
-
const request = this.pending.get(
|
|
31496
|
+
respond(id3, decision) {
|
|
31497
|
+
const request = this.pending.get(id3);
|
|
31305
31498
|
if (!request) return [];
|
|
31306
|
-
this.pending.delete(
|
|
31499
|
+
this.pending.delete(id3);
|
|
31307
31500
|
const optionId = optionFor(request.options, decision);
|
|
31308
31501
|
return [
|
|
31309
31502
|
optionId ? frame2({ id: request.id, result: { outcome: { outcome: "selected", optionId } } }) : frame2({ id: request.id, result: { outcome: { outcome: "cancelled" } } })
|
|
@@ -31457,7 +31650,7 @@ var AcpDriver = class {
|
|
|
31457
31650
|
writes: [frame2({ id: msg.id, error: { code: -32601, message: `Method not found: ${msg.method}` } })]
|
|
31458
31651
|
};
|
|
31459
31652
|
}
|
|
31460
|
-
const
|
|
31653
|
+
const id3 = msg.id;
|
|
31461
31654
|
const options = msg.params?.options ?? [];
|
|
31462
31655
|
const title = msg.params?.toolCall?.title?.trim() || "a tool call";
|
|
31463
31656
|
const tool = msg.params?.toolCall?.kind ?? "tool";
|
|
@@ -31468,21 +31661,21 @@ var AcpDriver = class {
|
|
|
31468
31661
|
// means "don't stall the agent", never "don't tell the user".
|
|
31469
31662
|
events: [{ kind: "turn", role: "agent", text: `auto-approved: ${title}`, tools: [tool] }],
|
|
31470
31663
|
writes: [
|
|
31471
|
-
optionId ? frame2({ id, result: { outcome: { outcome: "selected", optionId } } }) : frame2({ id, result: { outcome: { outcome: "cancelled" } } })
|
|
31664
|
+
optionId ? frame2({ id: id3, result: { outcome: { outcome: "selected", optionId } } }) : frame2({ id: id3, result: { outcome: { outcome: "cancelled" } } })
|
|
31472
31665
|
]
|
|
31473
31666
|
};
|
|
31474
31667
|
}
|
|
31475
|
-
this.pending.set(String(
|
|
31668
|
+
this.pending.set(String(id3), { id: id3, options });
|
|
31476
31669
|
return {
|
|
31477
|
-
events: [{ kind: "permission", id: String(
|
|
31670
|
+
events: [{ kind: "permission", id: String(id3), tool, summary: title }],
|
|
31478
31671
|
writes: []
|
|
31479
31672
|
};
|
|
31480
31673
|
}
|
|
31481
31674
|
/** The frame that opens the conversation: a resume of `resume` while there is one to try,
|
|
31482
31675
|
* else a new session. */
|
|
31483
|
-
opening(
|
|
31676
|
+
opening(id3) {
|
|
31484
31677
|
const params = { cwd: this.cwd, mcpServers: [], ...this.meta ? { _meta: this.meta } : {} };
|
|
31485
|
-
return this.resume ? { id, method: "session/resume", params: { sessionId: this.resume, ...params } } : { id, method: "session/new", params };
|
|
31678
|
+
return this.resume ? { id: id3, method: "session/resume", params: { sessionId: this.resume, ...params } } : { id: id3, method: "session/new", params };
|
|
31486
31679
|
}
|
|
31487
31680
|
/** Send the queued prompts as one turn, if the agent can take one right now. */
|
|
31488
31681
|
flush() {
|
|
@@ -31603,7 +31796,7 @@ function startSession(opts) {
|
|
|
31603
31796
|
}
|
|
31604
31797
|
const codexConfig = opts.harness === "codex" ? JSON.parse(process.env.CODEX_CONFIG || "{}") : null;
|
|
31605
31798
|
if (codexConfig) {
|
|
31606
|
-
const
|
|
31799
|
+
const key3 = "mcp_servers.paigy.env_vars";
|
|
31607
31800
|
const configPath = join5(process.env.CODEX_HOME || join5(homedir4(), ".codex"), "config.toml");
|
|
31608
31801
|
const saved = existsSync3(configPath) ? readFileSync3(configPath, "utf8") : "";
|
|
31609
31802
|
const registered = /\[mcp_servers\.paigy\][\s\S]*?(?=\n\[|$)/.exec(saved)?.[0];
|
|
@@ -31614,7 +31807,7 @@ function startSession(opts) {
|
|
|
31614
31807
|
}
|
|
31615
31808
|
const savedVars = registered?.match(/env_vars\s*=\s*\[([\s\S]*?)\]/)?.[1] ?? "";
|
|
31616
31809
|
const inherited = [...savedVars.matchAll(/["']([A-Za-z_][A-Za-z0-9_]*)["']/g)].map((match) => match[1]);
|
|
31617
|
-
codexConfig[
|
|
31810
|
+
codexConfig[key3] = [.../* @__PURE__ */ new Set([...inherited, ...codexConfig[key3] ?? codexConfig.mcp_servers?.paigy?.env_vars ?? [], ...CODEX_ENV])];
|
|
31618
31811
|
}
|
|
31619
31812
|
const child = (opts.spawnFn ?? spawn)(opts.bin ?? ADAPTER_BIN[opts.harness], [], {
|
|
31620
31813
|
cwd,
|
|
@@ -31690,8 +31883,8 @@ function startSession(opts) {
|
|
|
31690
31883
|
send(text) {
|
|
31691
31884
|
write(driver.send(text));
|
|
31692
31885
|
},
|
|
31693
|
-
respond(
|
|
31694
|
-
write(driver.respond(
|
|
31886
|
+
respond(id3, decision) {
|
|
31887
|
+
write(driver.respond(id3, decision));
|
|
31695
31888
|
},
|
|
31696
31889
|
stop() {
|
|
31697
31890
|
write(driver.close());
|
|
@@ -31763,19 +31956,19 @@ var getRefs2 = (options) => {
|
|
|
31763
31956
|
};
|
|
31764
31957
|
|
|
31765
31958
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
31766
|
-
function addErrorMessage2(res,
|
|
31959
|
+
function addErrorMessage2(res, key3, errorMessage, refs) {
|
|
31767
31960
|
if (!refs?.errorMessages)
|
|
31768
31961
|
return;
|
|
31769
31962
|
if (errorMessage) {
|
|
31770
31963
|
res.errorMessage = {
|
|
31771
31964
|
...res.errorMessage,
|
|
31772
|
-
[
|
|
31965
|
+
[key3]: errorMessage
|
|
31773
31966
|
};
|
|
31774
31967
|
}
|
|
31775
31968
|
}
|
|
31776
|
-
function setResponseValueAndErrors2(res,
|
|
31777
|
-
res[
|
|
31778
|
-
addErrorMessage2(res,
|
|
31969
|
+
function setResponseValueAndErrors2(res, key3, value, errorMessage, refs) {
|
|
31970
|
+
res[key3] = value;
|
|
31971
|
+
addErrorMessage2(res, key3, errorMessage, refs);
|
|
31779
31972
|
}
|
|
31780
31973
|
|
|
31781
31974
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
@@ -32374,11 +32567,11 @@ function parseRecordDef2(def, refs) {
|
|
|
32374
32567
|
return {
|
|
32375
32568
|
type: "object",
|
|
32376
32569
|
required: def.keyType._def.values,
|
|
32377
|
-
properties: def.keyType._def.values.reduce((acc,
|
|
32570
|
+
properties: def.keyType._def.values.reduce((acc, key3) => ({
|
|
32378
32571
|
...acc,
|
|
32379
|
-
[
|
|
32572
|
+
[key3]: parseDef2(def.valueType._def, {
|
|
32380
32573
|
...refs,
|
|
32381
|
-
currentPath: [...refs.currentPath, "properties",
|
|
32574
|
+
currentPath: [...refs.currentPath, "properties", key3]
|
|
32382
32575
|
}) ?? parseAnyDef2(refs)
|
|
32383
32576
|
}), {}),
|
|
32384
32577
|
additionalProperties: refs.rejectedAdditionalProperties
|
|
@@ -32445,10 +32638,10 @@ function parseMapDef2(def, refs) {
|
|
|
32445
32638
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
32446
32639
|
function parseNativeEnumDef2(def) {
|
|
32447
32640
|
const object = def.values;
|
|
32448
|
-
const actualKeys = Object.keys(def.values).filter((
|
|
32449
|
-
return typeof object[object[
|
|
32641
|
+
const actualKeys = Object.keys(def.values).filter((key3) => {
|
|
32642
|
+
return typeof object[object[key3]] !== "number";
|
|
32450
32643
|
});
|
|
32451
|
-
const actualValues = actualKeys.map((
|
|
32644
|
+
const actualValues = actualKeys.map((key3) => object[key3]);
|
|
32452
32645
|
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
32453
32646
|
return {
|
|
32454
32647
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
@@ -33000,6 +33193,7 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
33000
33193
|
|
|
33001
33194
|
// ../../packages/schema/dist/index.js
|
|
33002
33195
|
init_zod();
|
|
33196
|
+
init_zod();
|
|
33003
33197
|
var OPTIONS_MIN2 = 2;
|
|
33004
33198
|
var OPTIONS_MAX2 = 6;
|
|
33005
33199
|
var OptionSchema2 = external_exports.object({
|
|
@@ -33050,32 +33244,31 @@ function mcpInputSchema2(s) {
|
|
|
33050
33244
|
}
|
|
33051
33245
|
var AskInputSchema2 = external_exports.object({
|
|
33052
33246
|
id: external_exports.string().optional().describe("Optional idempotency key or client-side ID for this specific ask."),
|
|
33053
|
-
parentId: external_exports.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and
|
|
33247
|
+
parentId: external_exports.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and the question starts a new Goal of yours."),
|
|
33054
33248
|
repo: external_exports.string().optional().describe("Optional repository context."),
|
|
33055
33249
|
ask: external_exports.string().trim().min(1).max(1e4).describe(
|
|
33056
|
-
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy
|
|
33250
|
+
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy sends each ask exactly as you wrote it: a bundled ask arrives as one card. News, progress and findings are their own contact; ANY contact for a person already on a call JOINS that call, whatever channel you asked for, so several arrive as one call."
|
|
33057
33251
|
),
|
|
33058
33252
|
options: external_exports.array(OptionInputSchema2).min(1).max(6).optional(),
|
|
33059
|
-
//
|
|
33060
|
-
//
|
|
33061
|
-
//
|
|
33062
|
-
//
|
|
33063
|
-
// shape (`goal/intake.ts` `answerOf`), and this reaches it as the agent's view, weighed, not obeyed.
|
|
33253
|
+
// HOW THE OPTIONS ARE ANSWERED, SAID BY THE AGENT (owner, 2026-10-02: "one and many makes sense";
|
|
33254
|
+
// brain_prompts.md §1: structured agent questions need no model). Every card was pick-one while no
|
|
33255
|
+
// agent sent this; no read reshapes cards any more, so this is the card's shape, and the
|
|
33256
|
+
// description says so plainly.
|
|
33064
33257
|
select: external_exports.enum(["one", "many"]).optional().describe(
|
|
33065
|
-
|
|
33258
|
+
'How the options are answered: "many" makes a checklist (they may want several, e.g. independent fixes), "one" (the default) a pick (choosing one rules out the others). Send "many" whenever more than one option could be wanted at once. The person can always answer in their own words as well. Ignored without options.'
|
|
33066
33259
|
),
|
|
33067
33260
|
answers: external_exports.string().trim().regex(/^[0-9a-fA-F-]{8,36}$/).optional().describe(
|
|
33068
|
-
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them.
|
|
33261
|
+
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them. parentId is optional here: the question's own Goal is used. The reply is sent to them as it is; to also ask something new, send that as its own ask."
|
|
33069
33262
|
)
|
|
33070
33263
|
}).strict();
|
|
33071
33264
|
var StartContactSchema2 = external_exports.object({
|
|
33072
|
-
asks: external_exports.array(AskInputSchema2).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is;
|
|
33265
|
+
asks: external_exports.array(AskInputSchema2).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is; an ask naming no Goal starts a new Goal of yours."),
|
|
33073
33266
|
waiting: external_exports.enum(["none", "hard"]).default("none").describe("hard requests a call even when channel is notification; user permissions and ring cooldowns still apply."),
|
|
33074
33267
|
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
33075
33268
|
}).strict();
|
|
33076
33269
|
var ContactSchema2 = external_exports.union([StartContactSchema2, external_exports.object({ deliveryId: external_exports.string().uuid() }).strict()]);
|
|
33077
33270
|
var CONTACT_SCHEMA2 = { type: "object", ...mcpInputSchema2(ContactSchema2) };
|
|
33078
|
-
var CONTACT_DESCRIPTION2 = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none
|
|
33271
|
+
var CONTACT_DESCRIPTION2 = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none starts a new Goal of yours. Notification returns immediately; collect durable answers with check_replies. On stdio, a Call holds one cancellable ~45s window; continue with ONLY {deliveryId}. One question per 'ask'; several questions are several objects in 'asks'. Each ask is sent exactly as written, with no reading in between: a bundled ask arrives as one card, so separate questions are separate asks. An ask with no options that is not blocking is a report, and a report is an UPDATE, never a claim on them: it reaches them and is listed apart from what waits on them, so no answer is owed and none should be awaited. On a Goal whose report card is still open it is added to that card, with no new push; Where your work stands while under way is progress: report it with update_goal, not contact. Send options (or waiting:'hard') when you actually need an answer. Each option's label must stand on its own \u2014 the person may see only the labels \u2014 so never a label that points into your text ('All three', 'Option 2', '1 and 3 only'). select:'many' makes the card a checklist, for independent options they may want several of; select:'one' (the default) a pick, for alternatives. The person can always answer in their own words, so never add an 'Other' option. If the person is already on a call, your contact joins that call automatically \u2014 whatever channel you asked for, with no ring \u2014 and the Delivery it returns IS that call: reread it with contact({deliveryId}) to see everything answered on it so far, and contact again while it is live to add information or a further question to the same call.";
|
|
33079
33272
|
var CreateGoalSchema2 = external_exports.object({
|
|
33080
33273
|
outcome: external_exports.string().trim().min(1).max(1e4),
|
|
33081
33274
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -33149,6 +33342,153 @@ var AGENT_TOOLS2 = [
|
|
|
33149
33342
|
{ name: "update_goal", description: UPDATE_GOAL_DESCRIPTION2, inputSchema: mcpInputSchema2(UpdateGoalToolSchema2) }
|
|
33150
33343
|
];
|
|
33151
33344
|
var AGENT_TOOL_NAMES2 = AGENT_TOOLS2.map((t) => t.name);
|
|
33345
|
+
var id2 = external_exports.string().uuid();
|
|
33346
|
+
var key2 = external_exports.string().min(1).max(40);
|
|
33347
|
+
var participant2 = external_exports.string().regex(/^(human|agent):.+$/, "a participant ID such as agent:<uuid>");
|
|
33348
|
+
var SourceSchema2 = external_exports.object({ entryId: id2 }).strict();
|
|
33349
|
+
var ResultRefSchema2 = external_exports.union([external_exports.object({ id: id2 }).strict(), external_exports.object({ local: key2 }).strict()]);
|
|
33350
|
+
var NodeRefSchema2 = external_exports.object({ type: external_exports.enum(["goal", "question"]), id: id2 }).strict();
|
|
33351
|
+
var DependencySchema2 = external_exports.object({
|
|
33352
|
+
blocker: NodeRefSchema2,
|
|
33353
|
+
blocked: NodeRefSchema2,
|
|
33354
|
+
action: external_exports.enum(["start", "complete", "answer"]),
|
|
33355
|
+
reason: external_exports.string().max(500).optional()
|
|
33356
|
+
}).strict();
|
|
33357
|
+
var goalState2 = external_exports.enum(["open", "completed", "canceled"]);
|
|
33358
|
+
var existingGoalChanges2 = [
|
|
33359
|
+
external_exports.object({ kind: external_exports.literal("edit"), goalId: id2, title: external_exports.string().min(1).max(120).optional(), outcome: external_exports.string().min(1).optional() }).strict().refine((c) => c.title !== void 0 || c.outcome !== void 0, "an edit changes the title or the outcome"),
|
|
33360
|
+
external_exports.object({ kind: external_exports.literal("state"), goalId: id2, state: goalState2 }).strict(),
|
|
33361
|
+
external_exports.object({ kind: external_exports.literal("assign"), goalId: id2, ownerId: participant2 }).strict(),
|
|
33362
|
+
external_exports.object({ kind: external_exports.literal("defer"), goalId: id2, until: external_exports.string().datetime().nullable() }).strict(),
|
|
33363
|
+
external_exports.object({ kind: external_exports.literal("move"), goalId: id2, parentGoalId: id2.nullable() }).strict(),
|
|
33364
|
+
external_exports.object({
|
|
33365
|
+
kind: external_exports.literal("dependency"),
|
|
33366
|
+
change: external_exports.enum(["add", "remove"]),
|
|
33367
|
+
goalId: id2,
|
|
33368
|
+
dependsOnGoalId: id2,
|
|
33369
|
+
action: external_exports.enum(["start", "complete"]),
|
|
33370
|
+
reason: external_exports.string().max(500).optional()
|
|
33371
|
+
}).strict()
|
|
33372
|
+
];
|
|
33373
|
+
var GoalChangeSchema2 = external_exports.union([
|
|
33374
|
+
external_exports.object({
|
|
33375
|
+
kind: external_exports.literal("create"),
|
|
33376
|
+
title: external_exports.string().min(1).max(120),
|
|
33377
|
+
outcome: external_exports.string().min(1),
|
|
33378
|
+
ownerId: participant2,
|
|
33379
|
+
parentGoalId: id2.optional(),
|
|
33380
|
+
sourceEntryIds: external_exports.array(id2)
|
|
33381
|
+
}).strict(),
|
|
33382
|
+
...existingGoalChanges2
|
|
33383
|
+
]);
|
|
33384
|
+
var BrainGoalChangeSchema2 = external_exports.union([
|
|
33385
|
+
// newSession: Paigy starts a session to own it (owner, 2026-10-06); until it has, the person owns it.
|
|
33386
|
+
external_exports.object({
|
|
33387
|
+
kind: external_exports.literal("create"),
|
|
33388
|
+
outcome: external_exports.string().min(1),
|
|
33389
|
+
title: external_exports.string().min(1).max(120),
|
|
33390
|
+
ownerId: participant2,
|
|
33391
|
+
parentGoal: ResultRefSchema2.nullable(),
|
|
33392
|
+
newSession: external_exports.literal(true).optional()
|
|
33393
|
+
}).strict(),
|
|
33394
|
+
...existingGoalChanges2
|
|
33395
|
+
]);
|
|
33396
|
+
var option2 = external_exports.object({ id: external_exports.string().min(1).max(40), label: external_exports.string().min(1), hint: external_exports.string().optional() }).strict();
|
|
33397
|
+
var QuestionChangeSchema2 = external_exports.union([
|
|
33398
|
+
external_exports.object({
|
|
33399
|
+
kind: external_exports.literal("create"),
|
|
33400
|
+
text: external_exports.string().min(1),
|
|
33401
|
+
answererId: participant2,
|
|
33402
|
+
goal: ResultRefSchema2.optional(),
|
|
33403
|
+
blocks: external_exports.array(external_exports.object({ question: ResultRefSchema2 }).strict()),
|
|
33404
|
+
options: external_exports.array(option2).min(2).optional(),
|
|
33405
|
+
pickMode: external_exports.enum(["one", "many", "rank"]).optional()
|
|
33406
|
+
}).strict().refine((c) => c.options === void 0 === (c.pickMode === void 0), "options and pickMode come together"),
|
|
33407
|
+
external_exports.object({ kind: external_exports.literal("edit"), questionId: id2, text: external_exports.string().min(1) }).strict(),
|
|
33408
|
+
external_exports.object({ kind: external_exports.literal("assign"), questionId: id2, answererId: participant2 }).strict(),
|
|
33409
|
+
external_exports.object({ kind: external_exports.literal("withdraw"), questionId: id2 }).strict(),
|
|
33410
|
+
external_exports.object({ kind: external_exports.literal("dependency"), change: external_exports.enum(["add", "remove"]), edge: DependencySchema2 }).strict()
|
|
33411
|
+
]);
|
|
33412
|
+
var lessonScope2 = external_exports.union([
|
|
33413
|
+
external_exports.object({ kind: external_exports.literal("user") }).strict(),
|
|
33414
|
+
external_exports.object({ kind: external_exports.literal("goal"), goal: ResultRefSchema2 }).strict()
|
|
33415
|
+
]);
|
|
33416
|
+
var LessonChangeSchema2 = external_exports.union([
|
|
33417
|
+
external_exports.object({ kind: external_exports.literal("remember"), text: external_exports.string().min(1), scope: lessonScope2 }).strict(),
|
|
33418
|
+
external_exports.object({ kind: external_exports.literal("revise"), lessonId: id2, text: external_exports.string().min(1), scope: lessonScope2 }).strict(),
|
|
33419
|
+
external_exports.object({ kind: external_exports.literal("withdraw"), lessonId: id2 }).strict()
|
|
33420
|
+
]);
|
|
33421
|
+
var BrainNextSchema2 = external_exports.object({
|
|
33422
|
+
instructions: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key2).min(1) }).strict()),
|
|
33423
|
+
say: external_exports.array(key2),
|
|
33424
|
+
then: external_exports.enum(["listen", "hold", "end", "none"]),
|
|
33425
|
+
waitFor: external_exports.array(ResultRefSchema2),
|
|
33426
|
+
reason: external_exports.string()
|
|
33427
|
+
}).strict();
|
|
33428
|
+
var messageBase2 = {
|
|
33429
|
+
key: key2,
|
|
33430
|
+
text: external_exports.string().min(1),
|
|
33431
|
+
goals: external_exports.array(ResultRefSchema2),
|
|
33432
|
+
questions: external_exports.array(ResultRefSchema2),
|
|
33433
|
+
entryKeys: external_exports.array(key2),
|
|
33434
|
+
obligationIds: external_exports.array(id2)
|
|
33435
|
+
};
|
|
33436
|
+
var BrainMessageSchema2 = external_exports.union([
|
|
33437
|
+
external_exports.object({ ...messageBase2, to: external_exports.object({ kind: external_exports.literal("user") }).strict() }).strict(),
|
|
33438
|
+
external_exports.object({
|
|
33439
|
+
...messageBase2,
|
|
33440
|
+
to: external_exports.object({ kind: external_exports.literal("agent"), agentId: external_exports.string().regex(/^agent:(?!paigy$)\S+$/) }).strict(),
|
|
33441
|
+
call: external_exports.object({ callId: id2, listen: external_exports.literal(true) }).strict().optional()
|
|
33442
|
+
}).strict()
|
|
33443
|
+
]);
|
|
33444
|
+
var BrainSearchSchema2 = external_exports.object({
|
|
33445
|
+
query: external_exports.string().min(1).max(500),
|
|
33446
|
+
within: external_exports.array(external_exports.enum(["entries", "goals", "answers"])).min(1),
|
|
33447
|
+
goalId: id2.optional()
|
|
33448
|
+
}).strict();
|
|
33449
|
+
var BrainResultSchema2 = external_exports.object({
|
|
33450
|
+
messages: external_exports.array(BrainMessageSchema2),
|
|
33451
|
+
entries: external_exports.array(external_exports.object({ key: key2, sources: external_exports.array(SourceSchema2).min(1), goals: external_exports.array(ResultRefSchema2) }).strict()),
|
|
33452
|
+
questions: external_exports.array(external_exports.object({ key: key2, entryKeys: external_exports.array(key2), change: QuestionChangeSchema2 }).strict()),
|
|
33453
|
+
answers: external_exports.array(external_exports.object({
|
|
33454
|
+
question: ResultRefSchema2,
|
|
33455
|
+
entryKeys: external_exports.array(key2).min(1),
|
|
33456
|
+
summary: external_exports.string().min(1),
|
|
33457
|
+
selectedOptionIds: external_exports.array(external_exports.string().min(1)).optional()
|
|
33458
|
+
}).strict()),
|
|
33459
|
+
goals: external_exports.array(external_exports.object({ key: key2, entryKeys: external_exports.array(key2), change: BrainGoalChangeSchema2 }).strict()),
|
|
33460
|
+
feedback: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key2).min(1) }).strict()),
|
|
33461
|
+
lessons: external_exports.array(external_exports.object({ entryKeys: external_exports.array(key2).min(1), change: LessonChangeSchema2 }).strict()),
|
|
33462
|
+
next: BrainNextSchema2,
|
|
33463
|
+
search: BrainSearchSchema2.optional()
|
|
33464
|
+
}).strict();
|
|
33465
|
+
var str2 = external_exports.string();
|
|
33466
|
+
var strs2 = external_exports.array(external_exports.string());
|
|
33467
|
+
var CompactResultSchema2 = external_exports.object({
|
|
33468
|
+
next: external_exports.object({ say: strs2, then: external_exports.enum(["listen", "hold", "end", "none"]), waitFor: strs2, reason: str2, instructions: strs2 }).strict(),
|
|
33469
|
+
messages: external_exports.array(external_exports.object({ key: str2, to: str2, text: str2, about: strs2, entries: strs2, owed: strs2, inviteToCall: external_exports.boolean() }).strict()),
|
|
33470
|
+
entries: external_exports.array(external_exports.object({ key: str2, from: str2, on: strs2 }).strict()),
|
|
33471
|
+
answers: external_exports.array(external_exports.object({ question: str2, entries: strs2, summary: str2, picked: strs2 }).strict()),
|
|
33472
|
+
changes: external_exports.array(external_exports.object({
|
|
33473
|
+
key: str2,
|
|
33474
|
+
what: external_exports.enum(["goal", "question", "lesson"]),
|
|
33475
|
+
op: external_exports.enum(["create", "edit", "assign", "open", "complete", "cancel", "defer", "move", "block", "unblock", "withdraw", "remember", "revise"]),
|
|
33476
|
+
id: str2,
|
|
33477
|
+
text: str2,
|
|
33478
|
+
title: str2,
|
|
33479
|
+
who: str2,
|
|
33480
|
+
under: str2,
|
|
33481
|
+
gate: external_exports.enum(["start", "complete", "answer", "none"]),
|
|
33482
|
+
options: external_exports.array(external_exports.object({ id: str2, label: str2 }).strict()),
|
|
33483
|
+
pick: external_exports.enum(["one", "many", "rank", "words"]),
|
|
33484
|
+
entries: strs2
|
|
33485
|
+
}).strict()),
|
|
33486
|
+
feedback: external_exports.array(strs2),
|
|
33487
|
+
search: external_exports.object({ query: str2, within: strs2, goal: str2 }).strict()
|
|
33488
|
+
}).strict();
|
|
33489
|
+
var COMPACT_RESULT_JSON_SCHEMA2 = (({ $schema: _, ...rest }) => rest)(
|
|
33490
|
+
zodToJsonSchema2(CompactResultSchema2, { $refStrategy: "none" })
|
|
33491
|
+
);
|
|
33152
33492
|
function entryWords(entry) {
|
|
33153
33493
|
const content = entry.content;
|
|
33154
33494
|
if (content && "sealed" in content) return "";
|
|
@@ -33161,6 +33501,8 @@ function entryWords(entry) {
|
|
|
33161
33501
|
const description = plain.description;
|
|
33162
33502
|
const parts = [title, ...Array.isArray(description) ? description : []].filter((v) => typeof v === "string");
|
|
33163
33503
|
if (parts.length) return parts.join("\n\n");
|
|
33504
|
+
const line = plain.line;
|
|
33505
|
+
if (typeof line === "string" && line.trim()) return line;
|
|
33164
33506
|
}
|
|
33165
33507
|
return entry.sources.map((source) => source.text).join("\n");
|
|
33166
33508
|
}
|
|
@@ -33383,7 +33725,7 @@ var IntentSchema2 = external_exports.object({
|
|
|
33383
33725
|
* (`parseDelay`, #1292), and a value here simply wins over that reading. */
|
|
33384
33726
|
dueInSeconds: external_exports.number().int().positive().optional(),
|
|
33385
33727
|
/** Feedback only (#812): WHICH failure the complaint names — typed by the mapper that
|
|
33386
|
-
* already read the utterance, so `
|
|
33728
|
+
* already read the utterance, so `signals.kind` stops defaulting to
|
|
33387
33729
|
* 'other' on every row. A table that records that something was wrong and nothing
|
|
33388
33730
|
* about what cannot answer "is the bot looping less this week?". */
|
|
33389
33731
|
fault: external_exports.enum(["loop", "unanswered", "overridden", "misheard", "slow", "other"]).optional()
|
|
@@ -33667,7 +34009,18 @@ var InboxItemSchema2 = external_exports.object({
|
|
|
33667
34009
|
/** THAT GOAL'S NAME (#2416) — what Activity's row is headed by, since a row there is one Goal
|
|
33668
34010
|
* and the cards it holds sit behind it. Stamped by the same read as `goalState`. */
|
|
33669
34011
|
goalTitle: external_exports.string().optional()
|
|
33670
|
-
}).optional()
|
|
34012
|
+
}).optional(),
|
|
34013
|
+
/** WHAT THIS CARD IS, IN TWELVE CHARACTERS (#3019) — the hash of every other field on it, stamped
|
|
34014
|
+
* by the one read that serves the open list (`apps/api/src/inbox/project.ts` `inboxFor`). It is
|
|
34015
|
+
* how the incremental read knows a card has not moved: the phone echoes back the revs it holds
|
|
34016
|
+
* (`POST /api/inbox/changes`) and is sent only the cards whose rev differs.
|
|
34017
|
+
*
|
|
34018
|
+
* THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK — the same mechanism as `QueueItem.rev`
|
|
34019
|
+
* (#2928) and an entry's (#3018), for the same reason: a card shows facts no `updated_at` of its
|
|
34020
|
+
* own moves (its Goal's state and name, how cold the work behind it has gone, whether a ring is
|
|
34021
|
+
* live). Optional, so a fixture, the demo and the archive lens need not spell one, and a card
|
|
34022
|
+
* with no rev is simply always re-sent. */
|
|
34023
|
+
rev: external_exports.string().optional()
|
|
33671
34024
|
});
|
|
33672
34025
|
var APNS_TOKEN_RE2 = /^[0-9a-fA-F]{64}$/;
|
|
33673
34026
|
var PushTokenSchema2 = external_exports.object({
|
|
@@ -33879,39 +34232,22 @@ var ReassignResultSchema2 = external_exports.object({
|
|
|
33879
34232
|
moved: external_exports.object({ asks: external_exports.number(), answered: external_exports.number(), requests: external_exports.number(), goals: external_exports.number(), callbacks: external_exports.number() }),
|
|
33880
34233
|
parentId: external_exports.string().nullable()
|
|
33881
34234
|
});
|
|
33882
|
-
var
|
|
33883
|
-
var
|
|
34235
|
+
var LessonStateSchema2 = external_exports.enum(["active", "proposed", "retired"]);
|
|
34236
|
+
var LessonViewSchema2 = external_exports.object({
|
|
33884
34237
|
id: external_exports.string(),
|
|
33885
|
-
|
|
33886
|
-
|
|
33887
|
-
/** The
|
|
33888
|
-
|
|
33889
|
-
|
|
33890
|
-
|
|
33891
|
-
rationale: external_exports.string().nullable(),
|
|
33892
|
-
/** Where the ruling lives: a repo/workspace, or 'global'. */
|
|
33893
|
-
scope: external_exports.string(),
|
|
33894
|
-
ring: MoveRingSchema2,
|
|
33895
|
-
/** True = the user pinned it with `always` (travel granted by hand, not by evidence). */
|
|
34238
|
+
text: external_exports.string(),
|
|
34239
|
+
state: LessonStateSchema2,
|
|
34240
|
+
/** The Goal it is scoped to; null = the whole account. */
|
|
34241
|
+
scopeGoalId: external_exports.string().nullable(),
|
|
34242
|
+
goalTitle: external_exports.string().nullable(),
|
|
34243
|
+
version: external_exports.number(),
|
|
33896
34244
|
pinned: external_exports.boolean(),
|
|
33897
|
-
/**
|
|
33898
|
-
|
|
33899
|
-
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
lastUsedAt: external_exports.string().nullable(),
|
|
33904
|
-
/** How many asks it has answered. Instrumentation — deliberately NOT an input to the
|
|
33905
|
-
* evidence curve: firing says the question keeps arising, not that the ruling is right. */
|
|
33906
|
-
usedCount: external_exports.number(),
|
|
33907
|
-
/** Ledger: outcomes that said it held up. Saturating — the tenth is worth almost nothing. */
|
|
33908
|
-
confirms: external_exports.number(),
|
|
33909
|
-
/** Ledger: contradictions, in signal units (a full override = 1, weaker signals less).
|
|
33910
|
-
* Linear and priced above the entire confirmation budget, so any full counter wins. */
|
|
33911
|
-
counters: external_exports.number(),
|
|
33912
|
-
/** The agent that asked the question this move came from, when known. Null for a move
|
|
33913
|
-
* distilled from a clarify ruling (those carry no agent) or one whose source rows are gone. */
|
|
33914
|
-
learnedFrom: external_exports.object({ id: external_exports.string(), name: external_exports.string() }).nullable()
|
|
34245
|
+
/** When the person last wrote its text themselves. */
|
|
34246
|
+
editedAt: external_exports.string().nullable(),
|
|
34247
|
+
createdAt: external_exports.string(),
|
|
34248
|
+
updatedAt: external_exports.string(),
|
|
34249
|
+
/** The Entries it came from, oldest first; `words` is null when an Entry has none to show (sealed). */
|
|
34250
|
+
sources: external_exports.array(external_exports.object({ entryId: external_exports.string(), words: external_exports.string().nullable(), at: external_exports.string() }))
|
|
33915
34251
|
});
|
|
33916
34252
|
var QueueQuestionSchema2 = external_exports.object({
|
|
33917
34253
|
/** The decision need's id — what an answer is accepted against. */
|
|
@@ -34039,7 +34375,22 @@ var QueueItemSchema2 = external_exports.object({
|
|
|
34039
34375
|
* minute after the person speaks erases their instant from it, and the durable traces the client
|
|
34040
34376
|
* can see (`replies`, `questions[].answeredAt`) miss a spontaneous note entirely — a `request`
|
|
34041
34377
|
* Entry with no `about_id` is in neither. */
|
|
34042
|
-
lastPersonAt: external_exports.string().nullable().optional()
|
|
34378
|
+
lastPersonAt: external_exports.string().nullable().optional(),
|
|
34379
|
+
/** WHAT THIS ROW IS, IN TWELVE CHARACTERS (#2928) — the hash of every other field on it, stamped
|
|
34380
|
+
* by the one projection that builds the row (`apps/api/src/goal/queue.ts`). It is how the
|
|
34381
|
+
* incremental read knows a row has not moved: the phone echoes back the revs it holds
|
|
34382
|
+
* (`POST /api/goals/changes`) and is sent only the rows whose rev differs.
|
|
34383
|
+
*
|
|
34384
|
+
* IT IS THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK. Nothing here reasons about which
|
|
34385
|
+
* writes change which field — the comparison is over the bytes the phone is holding, so a fact
|
|
34386
|
+
* the row shows that no `updated_at` moves for (a lease lapsing, a dependency's state, a
|
|
34387
|
+
* sibling appearing in `childGoalIds`) cannot go unnoticed. Optional because a hand-built
|
|
34388
|
+
* queue (a fixture, the demo) spells none, and a row with no rev is simply always re-sent. */
|
|
34389
|
+
rev: external_exports.string().optional()
|
|
34390
|
+
});
|
|
34391
|
+
var QueueDeltaSchema2 = external_exports.object({
|
|
34392
|
+
ids: external_exports.array(external_exports.string()),
|
|
34393
|
+
items: external_exports.array(QueueItemSchema2)
|
|
34043
34394
|
});
|
|
34044
34395
|
var COLD_AFTER_MS2 = 3 * 24 * 60 * 60 * 1e3;
|
|
34045
34396
|
var NoteSourceSchema2 = external_exports.enum(["app", "call"]);
|
|
@@ -34210,6 +34561,11 @@ var DeviceTokenSchema2 = external_exports.object({
|
|
|
34210
34561
|
/** Local host recovery must preserve the launch's runtime and Paigy identity. */
|
|
34211
34562
|
harness: external_exports.enum(["claude", "codex", "agy"]).optional(),
|
|
34212
34563
|
session_id: external_exports.string().uuid().optional(),
|
|
34564
|
+
/** A conversation the host must not resume: its context is full, so every turn fails
|
|
34565
|
+
* ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
|
|
34566
|
+
* whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
|
|
34567
|
+
* copy that types the person's words into a turn that cannot run (Calls, 2026-10-06). */
|
|
34568
|
+
full_session: external_exports.string().optional(),
|
|
34213
34569
|
uik_pub: external_exports.string().nullable().optional()
|
|
34214
34570
|
});
|
|
34215
34571
|
var SupportRequestSchema2 = external_exports.object({
|
|
@@ -34587,17 +34943,31 @@ async function finish(result, state, rail, opts) {
|
|
|
34587
34943
|
}
|
|
34588
34944
|
async function cannotWork(report, state, rail, opts) {
|
|
34589
34945
|
state.resting = true;
|
|
34946
|
+
const say = (parentId) => rail.contact({ asks: [{ ask: report, ...parentId ? { parentId } : {} }], waiting: "none", channel: "notification" });
|
|
34590
34947
|
try {
|
|
34591
34948
|
if (!state.goal) {
|
|
34592
|
-
const claimed = await rail.claim();
|
|
34593
|
-
if (
|
|
34594
|
-
|
|
34949
|
+
const claimed = await rail.claim().catch(() => void 0);
|
|
34950
|
+
if (claimed?.goalId && claimed.revision !== void 0) state.goal = { id: claimed.goalId, revision: claimed.revision };
|
|
34951
|
+
}
|
|
34952
|
+
if (!state.goal) {
|
|
34953
|
+
await say();
|
|
34954
|
+
return;
|
|
34955
|
+
}
|
|
34956
|
+
try {
|
|
34957
|
+
await say(state.goal.id);
|
|
34958
|
+
} catch (error) {
|
|
34959
|
+
if (!/goal_parent_invalid/.test(error.message)) throw error;
|
|
34960
|
+
opts?.log?.(`\u26A0 the held Goal ${state.goal.id.slice(0, 8)} refused the notice (goal_parent_invalid) \u2014 saying it unplaced`);
|
|
34961
|
+
await say();
|
|
34595
34962
|
}
|
|
34596
|
-
await rail.contact({ asks: [{ ask: report, parentId: state.goal.id }], waiting: "none", channel: "notification" });
|
|
34597
34963
|
} catch (error) {
|
|
34598
34964
|
opts?.log?.(`\u26A0 could not say the agent cannot work: ${error.message}`);
|
|
34599
34965
|
}
|
|
34600
34966
|
}
|
|
34967
|
+
function conversationFull(result) {
|
|
34968
|
+
return /prompt is too long/i.test(result ?? "");
|
|
34969
|
+
}
|
|
34970
|
+
var FULL_NOTICE = "This agent's conversation is full, so it can no longer take a turn. Its session has ended and will not be resumed; its Goals go to the dead-agent handoff.";
|
|
34601
34971
|
async function afterTurn(event, state, rail, opts) {
|
|
34602
34972
|
if (event.failed) {
|
|
34603
34973
|
const limit = limitIn(event.result, (opts?.now ?? Date.now)());
|
|
@@ -34610,6 +34980,11 @@ async function afterTurn(event, state, rail, opts) {
|
|
|
34610
34980
|
opts?.log?.(`\u23F8 paused by the usage limit until ${limit.resets}: nothing is typed in until then, and it carries on by itself`);
|
|
34611
34981
|
return limit;
|
|
34612
34982
|
}
|
|
34983
|
+
if (conversationFull(event.result)) {
|
|
34984
|
+
if (!state.full) await cannotWork(FULL_NOTICE, state, rail, opts);
|
|
34985
|
+
state.full = true;
|
|
34986
|
+
return void 0;
|
|
34987
|
+
}
|
|
34613
34988
|
await cannotWork(`The agent stopped without finishing.
|
|
34614
34989
|
|
|
34615
34990
|
${event.result?.trim() || "No result reported."}`, state, rail, opts);
|
|
@@ -34679,9 +35054,9 @@ function unheard(brief, state, since = null, after = -1, reviewSince) {
|
|
|
34679
35054
|
if (text) words2.push(text);
|
|
34680
35055
|
}
|
|
34681
35056
|
if (pendingAt !== null) for (const answer of brief.answers ?? []) {
|
|
34682
|
-
const
|
|
34683
|
-
if (seen.has(
|
|
34684
|
-
seen.add(
|
|
35057
|
+
const key3 = `answer:${answer.decisionNeedId}`;
|
|
35058
|
+
if (seen.has(key3) || Date.parse(answer.acceptedAt) < pendingAt) continue;
|
|
35059
|
+
seen.add(key3);
|
|
34685
35060
|
words2.push(`Answer to question ${answer.decisionNeedId}: ${JSON.stringify(answer.result)}`);
|
|
34686
35061
|
}
|
|
34687
35062
|
return words2;
|
|
@@ -34726,16 +35101,16 @@ async function gather(state, rail, held) {
|
|
|
34726
35101
|
const listed = /* @__PURE__ */ new Set();
|
|
34727
35102
|
const announced = state.announced ??= /* @__PURE__ */ new Set();
|
|
34728
35103
|
if (waiting) {
|
|
34729
|
-
for (const
|
|
35104
|
+
for (const id3 of announced) if (!(waiting.assigned ?? []).some((g) => g.goalId === id3)) announced.delete(id3);
|
|
34730
35105
|
}
|
|
34731
35106
|
for (const g of waiting?.assigned ?? []) if (g.goalId !== state.goal.id && !announced.has(g.goalId)) look2(g.goalId, "assigned", g.title);
|
|
34732
35107
|
for (const g of waiting?.review ?? []) {
|
|
34733
35108
|
listed.add(g.goalId);
|
|
34734
35109
|
look2(g.goalId, "waiting work", g.title);
|
|
34735
35110
|
}
|
|
34736
|
-
for (const d of waiting?.deliveries ?? []) for (const
|
|
34737
|
-
listed.add(
|
|
34738
|
-
look2(
|
|
35111
|
+
for (const d of waiting?.deliveries ?? []) for (const id3 of d.goalIds) {
|
|
35112
|
+
listed.add(id3);
|
|
35113
|
+
look2(id3, "waiting work");
|
|
34739
35114
|
}
|
|
34740
35115
|
const moved = movedBelow(held, state);
|
|
34741
35116
|
for (const { goal, since } of moved) look2(goal.goalId, "subtree", goal.title, since);
|
|
@@ -34773,7 +35148,7 @@ var block = (h) => [
|
|
|
34773
35148
|
...h.note ? [`The last note on it, from the agent before you: ${h.note}`] : [],
|
|
34774
35149
|
...h.words
|
|
34775
35150
|
].join("\n\n");
|
|
34776
|
-
var short = (ids) => ids.map((
|
|
35151
|
+
var short = (ids) => ids.map((id3) => id3.slice(0, 8)).join(", ");
|
|
34777
35152
|
var given = (heard) => heard.filter((h) => h.via === "assigned").map((h) => h.goalId);
|
|
34778
35153
|
async function hear(session, state, rail, held, opts) {
|
|
34779
35154
|
const log = opts?.log;
|
|
@@ -35037,7 +35412,12 @@ ${event.message}`, state, rail, { log: opts.log });
|
|
|
35037
35412
|
tail = [];
|
|
35038
35413
|
const carried = state.carriedOn && !event.failed;
|
|
35039
35414
|
if (await afterTurn(event, state, rail, { log: opts.log })) LIMITS.paused(name, Date.now());
|
|
35040
|
-
else if (
|
|
35415
|
+
else if (state.full) {
|
|
35416
|
+
opts.log(`\u25A0 ${name}'s conversation is full \u2014 ending this run; it will not be resumed`);
|
|
35417
|
+
opts.onFull?.(speaksAs);
|
|
35418
|
+
stop2();
|
|
35419
|
+
return;
|
|
35420
|
+
} else if (carried) runningAgain();
|
|
35041
35421
|
clock4.nudge("rest");
|
|
35042
35422
|
}
|
|
35043
35423
|
}
|
|
@@ -35502,26 +35882,33 @@ var claimedRun = (sessionId2) => {
|
|
|
35502
35882
|
return { slot, key: runKey(slot) };
|
|
35503
35883
|
};
|
|
35504
35884
|
var launchRun = (spec) => ({ session: spec.sessionId });
|
|
35885
|
+
var BOUND_ELSEWHERE_MS = 10 * 6e4;
|
|
35886
|
+
var boundElsewhere = /* @__PURE__ */ new Map();
|
|
35887
|
+
var BOUND_SKIP = "is bound to the session it was paired in, which this host cannot name \u2014 run `paigy-harness handoff` as it, in its folder, to record it";
|
|
35505
35888
|
var NOTHING_WAITING = "has nothing waiting";
|
|
35506
35889
|
async function waitingWork(token, session) {
|
|
35890
|
+
const quiet = boundElsewhere.get(token);
|
|
35891
|
+
if (quiet !== void 0 && Date.now() < quiet) return { skip: BOUND_SKIP };
|
|
35507
35892
|
let found;
|
|
35508
35893
|
try {
|
|
35509
35894
|
found = await checkReplies({ token, ...session ? { reach: reachAs(session) } : {} });
|
|
35510
35895
|
} catch (error) {
|
|
35511
35896
|
if (error instanceof RevokedError) return { skip: "was revoked: its credential is gone for good", revoked: true };
|
|
35512
35897
|
if (error instanceof ApiError && error.body?.error === "identity_session_mismatch") {
|
|
35513
|
-
|
|
35898
|
+
boundElsewhere.set(token, Date.now() + BOUND_ELSEWHERE_MS);
|
|
35899
|
+
return { skip: BOUND_SKIP };
|
|
35514
35900
|
}
|
|
35515
35901
|
return { skip: `could not read what is waiting (${error.message})` };
|
|
35516
35902
|
}
|
|
35903
|
+
boundElsewhere.delete(token);
|
|
35517
35904
|
const next = found.claimable;
|
|
35518
35905
|
const about = next ? { goalId: next.goalId, ...next.since ? { since: next.since } : {} } : {};
|
|
35519
35906
|
const n = found.deliveries.length;
|
|
35520
35907
|
if (n) return { waiting: n === 1 ? "a message" : `${n} messages`, ...about };
|
|
35521
35908
|
return next ? { waiting: `Goal ${next.goalId.slice(0, 8)}${next.title ? ` "${next.title}"` : ""}`, ...about } : { skip: NOTHING_WAITING };
|
|
35522
35909
|
}
|
|
35523
|
-
function evict(runs,
|
|
35524
|
-
if (runs.get(
|
|
35910
|
+
function evict(runs, key3, run) {
|
|
35911
|
+
if (runs.get(key3)?.run === run) runs.delete(key3);
|
|
35525
35912
|
}
|
|
35526
35913
|
var PRESENCE_FRESH_MS = 3 * 6e4;
|
|
35527
35914
|
var IDLE_HOLDER_MS = 30 * 6e4;
|
|
@@ -35564,9 +35951,9 @@ function startHost(opts) {
|
|
|
35564
35951
|
const agent2 = slotIdentity(slot).tokenId;
|
|
35565
35952
|
if (!agent2) return;
|
|
35566
35953
|
const goalId = found?.goalId;
|
|
35567
|
-
const
|
|
35568
|
-
if (recorded.get(slot) ===
|
|
35569
|
-
recorded.set(slot,
|
|
35954
|
+
const key3 = `${decision}:${goalId ?? ""}`;
|
|
35955
|
+
if (recorded.get(slot) === key3) return;
|
|
35956
|
+
recorded.set(slot, key3);
|
|
35570
35957
|
void recordDecision({
|
|
35571
35958
|
agent: agent2,
|
|
35572
35959
|
decision,
|
|
@@ -35616,7 +36003,7 @@ function startHost(opts) {
|
|
|
35616
36003
|
const specs = await claimSessions(asHost).catch(() => []);
|
|
35617
36004
|
for (const spec of specs) {
|
|
35618
36005
|
const label = spec.name ?? spec.harness;
|
|
35619
|
-
const { slot, key } = claimedRun(spec.sessionId);
|
|
36006
|
+
const { slot, key: key3 } = claimedRun(spec.sessionId);
|
|
35620
36007
|
const log = (line) => opts.log(`[${label}] ${line}`);
|
|
35621
36008
|
try {
|
|
35622
36009
|
saveToken({
|
|
@@ -35639,14 +36026,17 @@ function startHost(opts) {
|
|
|
35639
36026
|
token: spec.token,
|
|
35640
36027
|
...launchRun(spec),
|
|
35641
36028
|
onExit: () => {
|
|
35642
|
-
evict(runs,
|
|
36029
|
+
evict(runs, key3, run);
|
|
35643
36030
|
goneAt.set(slot, Date.now());
|
|
35644
36031
|
opts.log(`\u2716 ${label} ended`);
|
|
35645
36032
|
},
|
|
36033
|
+
onFull: (session) => {
|
|
36034
|
+
updateSlot(slot, { full_session: session });
|
|
36035
|
+
},
|
|
35646
36036
|
name: label,
|
|
35647
36037
|
log
|
|
35648
36038
|
});
|
|
35649
|
-
runs.set(
|
|
36039
|
+
runs.set(key3, { run, label, token: spec.token });
|
|
35650
36040
|
void heartbeat(void 0, { token: spec.token }).catch(() => {
|
|
35651
36041
|
});
|
|
35652
36042
|
void refreshIdentities();
|
|
@@ -35698,9 +36088,9 @@ function startHost(opts) {
|
|
|
35698
36088
|
let lastHolders = /* @__PURE__ */ new Map();
|
|
35699
36089
|
async function wakeSlot(slot, { presence, holders }, cause = "sweep") {
|
|
35700
36090
|
{
|
|
35701
|
-
const
|
|
36091
|
+
const key3 = runKey(slot);
|
|
35702
36092
|
if (slot === "Desktop" || isRevoked(slot)) return;
|
|
35703
|
-
const live = runs.get(
|
|
36093
|
+
const live = runs.get(key3);
|
|
35704
36094
|
if (live) {
|
|
35705
36095
|
const theirs = (localHolderPids().get(slot) ?? []).map((p) => p.pid).filter((pid) => !descendsFrom(pid, process.pid));
|
|
35706
36096
|
if (theirs.length) {
|
|
@@ -35735,6 +36125,11 @@ function startHost(opts) {
|
|
|
35735
36125
|
}
|
|
35736
36126
|
const identity = slotIdentity(slot);
|
|
35737
36127
|
const owner = !identity.harness || identity.harness === "claude" ? ownerSession(slot) : null;
|
|
36128
|
+
const resumes = owner?.sessionId ?? identity.sessionId;
|
|
36129
|
+
if (resumes && identity.fullSession === resumes) {
|
|
36130
|
+
skip(`has a full conversation (${resumes.slice(0, 8)}) \u2014 not resuming it; its Goals go to the dead-agent handoff`);
|
|
36131
|
+
return;
|
|
36132
|
+
}
|
|
35738
36133
|
const read = async () => {
|
|
35739
36134
|
const got = await waitingWork(token, identity.sessionId ?? owner?.sessionId);
|
|
35740
36135
|
if (!("skip" in got)) return got;
|
|
@@ -35775,7 +36170,7 @@ function startHost(opts) {
|
|
|
35775
36170
|
}
|
|
35776
36171
|
found ??= await read() ?? void 0;
|
|
35777
36172
|
if (!found) return;
|
|
35778
|
-
if (runs.has(
|
|
36173
|
+
if (runs.has(key3)) {
|
|
35779
36174
|
skip("was started by the wake that read it first");
|
|
35780
36175
|
return;
|
|
35781
36176
|
}
|
|
@@ -35791,14 +36186,17 @@ function startHost(opts) {
|
|
|
35791
36186
|
// A dead run must not squat the slot — evict so the next wake can respawn. Only ITS entry:
|
|
35792
36187
|
// a run that is no longer the slot's must not take the live one's place away with it.
|
|
35793
36188
|
onExit: () => {
|
|
35794
|
-
evict(runs,
|
|
36189
|
+
evict(runs, key3, run);
|
|
35795
36190
|
goneAt.set(slot, Date.now());
|
|
35796
36191
|
opts.log(`\u2716 ${label} ended`);
|
|
35797
36192
|
},
|
|
36193
|
+
onFull: (session) => {
|
|
36194
|
+
updateSlot(slot, { full_session: session });
|
|
36195
|
+
},
|
|
35798
36196
|
name: label,
|
|
35799
36197
|
log
|
|
35800
36198
|
});
|
|
35801
|
-
runs.set(
|
|
36199
|
+
runs.set(key3, { run, label, token });
|
|
35802
36200
|
void heartbeat(void 0, { token }).catch(() => {
|
|
35803
36201
|
});
|
|
35804
36202
|
const woke = `\u25B6 ${owner ? "resumed" : "woke"} ${label} (${harness}) \u2014 ${found.waiting} was waiting, in ${workspace}${decided.why === "gone" ? " (its process here ended; its last heartbeat was not waited out)" : taking}`;
|
|
@@ -35851,17 +36249,17 @@ function startHost(opts) {
|
|
|
35851
36249
|
void heartbeat(void 0, { token, activity: { lines: lines2, at: (/* @__PURE__ */ new Date()).toISOString() } }).catch(() => {
|
|
35852
36250
|
});
|
|
35853
36251
|
};
|
|
35854
|
-
for (const [
|
|
36252
|
+
for (const [key3, r] of runs) {
|
|
35855
36253
|
if (!r.token) continue;
|
|
35856
36254
|
const lines2 = r.run.tail();
|
|
35857
|
-
const was = published.get(
|
|
36255
|
+
const was = published.get(key3);
|
|
35858
36256
|
if (was && sameTail(was.lines, lines2)) continue;
|
|
35859
|
-
published.set(
|
|
36257
|
+
published.set(key3, { token: r.token, lines: lines2 });
|
|
35860
36258
|
publishTail(r.token, lines2);
|
|
35861
36259
|
}
|
|
35862
|
-
for (const [
|
|
35863
|
-
if (runs.has(
|
|
35864
|
-
published.delete(
|
|
36260
|
+
for (const [key3, was] of published) {
|
|
36261
|
+
if (runs.has(key3)) continue;
|
|
36262
|
+
published.delete(key3);
|
|
35865
36263
|
if (was.lines.length > 0) publishTail(was.token, []);
|
|
35866
36264
|
}
|
|
35867
36265
|
};
|
|
@@ -35892,25 +36290,25 @@ function startHost(opts) {
|
|
|
35892
36290
|
})));
|
|
35893
36291
|
};
|
|
35894
36292
|
const api = {
|
|
35895
|
-
sessions: () => [...runs.entries()].map(([
|
|
36293
|
+
sessions: () => [...runs.entries()].map(([id3, r]) => [id3, r.label]),
|
|
35896
36294
|
// Every identity this machine holds, plus what it's doing right now. Slots are the
|
|
35897
36295
|
// roster (hatched agents, the terminal tools, claimed sessions); a run makes one of
|
|
35898
36296
|
// them live, and a run mid-turn makes it working.
|
|
35899
36297
|
roster: () => {
|
|
35900
36298
|
const live = new Map([...runs.values()].map((r) => [r.label, r.run]));
|
|
35901
36299
|
const names2 = /* @__PURE__ */ new Map();
|
|
35902
|
-
for (const
|
|
36300
|
+
for (const key3 of listSlots()) if (key3 !== "Desktop" && !isRevoked(key3)) names2.set(slotName(key3) ?? key3, key3);
|
|
35903
36301
|
for (const label of live.keys()) if (!names2.has(label)) names2.set(label, null);
|
|
35904
36302
|
return [...names2.entries()].map(([name, slot]) => {
|
|
35905
|
-
const
|
|
36303
|
+
const id3 = slot ? slotIdentity(slot) : { voice: null, tokenId: null };
|
|
35906
36304
|
return {
|
|
35907
36305
|
name,
|
|
35908
36306
|
// The slot key rides along so the window's agent page can speak AS this agent —
|
|
35909
36307
|
// its pending reads (`checkReplies`, the same pure read the sweep does) need the
|
|
35910
36308
|
// slot's own token, and the display name is not a key.
|
|
35911
36309
|
slot,
|
|
35912
|
-
tokenId:
|
|
35913
|
-
voice:
|
|
36310
|
+
tokenId: id3.tokenId,
|
|
36311
|
+
voice: id3.voice,
|
|
35914
36312
|
// RUNNING IS ABOUT THE IDENTITY, NOT ABOUT US (owner, 2026-09-14). This was
|
|
35915
36313
|
// `live.has(name)` — "this host spawned it and it has not exited" — which is a fact
|
|
35916
36314
|
// about our own process table, not about the agent. An ordinary terminal session
|
|
@@ -35918,7 +36316,7 @@ function startHost(opts) {
|
|
|
35918
36316
|
// sessions we started ourselves. The server already knows: `last_seen_at` on the
|
|
35919
36317
|
// agent's own token, the same evidence `wakeAction` stands back for. So: a run we
|
|
35920
36318
|
// hold, OR a process the server heard from inside `PRESENCE_FRESH_MS`.
|
|
35921
|
-
running: live.has(name) || !!slot && lastHolders.has(slot) || !!
|
|
36319
|
+
running: live.has(name) || !!slot && lastHolders.has(slot) || !!id3.tokenId && Date.now() - (lastPresence.get(id3.tokenId) ?? 0) < PRESENCE_FRESH_MS,
|
|
35922
36320
|
// `working` stays ours alone — it means a run WE hold is mid-turn, which is the only
|
|
35923
36321
|
// thing a tail can tell us. A process we did not spawn has no tail here to read.
|
|
35924
36322
|
working: live.get(name)?.working() ?? false
|
|
@@ -36042,18 +36440,11 @@ function forwardCodexThreadId() {
|
|
|
36042
36440
|
const cfg = join11(process.env.CODEX_HOME || join11(homedir10(), ".codex"), "config.toml");
|
|
36043
36441
|
if (!existsSync5(cfg)) return;
|
|
36044
36442
|
const text = readFileSync7(cfg, "utf8");
|
|
36045
|
-
const
|
|
36046
|
-
|
|
36047
|
-
if (at < 0) return;
|
|
36048
|
-
const block2 = text.slice(at + head.length, (() => {
|
|
36049
|
-
const n = text.indexOf("\n[", at + head.length);
|
|
36050
|
-
return n < 0 ? text.length : n;
|
|
36051
|
-
})());
|
|
36052
|
-
if (/^\s*env_vars\s*=/m.test(block2)) return;
|
|
36053
|
-
writeFileSync5(cfg, text.slice(0, at + head.length) + `env_vars = [${CODEX_ENV.map((name) => JSON.stringify(name)).join(", ")}]
|
|
36054
|
-
` + text.slice(at + head.length));
|
|
36443
|
+
const updated = withCodexEnv(text);
|
|
36444
|
+
if (updated !== null && updated !== text) writeFileSync5(cfg, updated);
|
|
36055
36445
|
}
|
|
36056
36446
|
async function main() {
|
|
36447
|
+
setClient(`harness@${VERSION}`);
|
|
36057
36448
|
const parsed = parseArgs(process.argv.slice(2));
|
|
36058
36449
|
if ("error" in parsed) {
|
|
36059
36450
|
console.error(`paigy-harness: ${parsed.error}`);
|