@ours.network/cowork 1.1.3 → 1.1.4
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/daemon.js +244 -173
- package/docs/07-messaging-history.md +8 -0
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -18,9 +18,9 @@ var __export = (target, all) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __copyProps = (to, from, except, desc) => {
|
|
20
20
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let
|
|
22
|
-
if (!__hasOwnProp.call(to,
|
|
23
|
-
__defProp(to,
|
|
21
|
+
for (let key2 of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
23
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
24
24
|
}
|
|
25
25
|
return to;
|
|
26
26
|
};
|
|
@@ -69,9 +69,9 @@ var init_util = __esm({
|
|
|
69
69
|
};
|
|
70
70
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
71
71
|
const keys = [];
|
|
72
|
-
for (const
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(object,
|
|
74
|
-
keys.push(
|
|
72
|
+
for (const key2 in object) {
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(object, key2)) {
|
|
74
|
+
keys.push(key2);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return keys;
|
|
@@ -496,10 +496,10 @@ var init_parseUtil = __esm({
|
|
|
496
496
|
static async mergeObjectAsync(status, pairs) {
|
|
497
497
|
const syncPairs = [];
|
|
498
498
|
for (const pair of pairs) {
|
|
499
|
-
const
|
|
499
|
+
const key2 = await pair.key;
|
|
500
500
|
const value = await pair.value;
|
|
501
501
|
syncPairs.push({
|
|
502
|
-
key,
|
|
502
|
+
key: key2,
|
|
503
503
|
value
|
|
504
504
|
});
|
|
505
505
|
}
|
|
@@ -508,17 +508,17 @@ var init_parseUtil = __esm({
|
|
|
508
508
|
static mergeObjectSync(status, pairs) {
|
|
509
509
|
const finalObject = {};
|
|
510
510
|
for (const pair of pairs) {
|
|
511
|
-
const { key, value } = pair;
|
|
512
|
-
if (
|
|
511
|
+
const { key: key2, value } = pair;
|
|
512
|
+
if (key2.status === "aborted")
|
|
513
513
|
return INVALID;
|
|
514
514
|
if (value.status === "aborted")
|
|
515
515
|
return INVALID;
|
|
516
|
-
if (
|
|
516
|
+
if (key2.status === "dirty")
|
|
517
517
|
status.dirty();
|
|
518
518
|
if (value.status === "dirty")
|
|
519
519
|
status.dirty();
|
|
520
|
-
if (
|
|
521
|
-
finalObject[
|
|
520
|
+
if (key2.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
521
|
+
finalObject[key2.value] = value.value;
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
return { status: status.value, value: finalObject };
|
|
@@ -650,9 +650,9 @@ function floatSafeRemainder(val, step) {
|
|
|
650
650
|
function deepPartialify(schema) {
|
|
651
651
|
if (schema instanceof ZodObject) {
|
|
652
652
|
const newShape = {};
|
|
653
|
-
for (const
|
|
654
|
-
const fieldSchema = schema.shape[
|
|
655
|
-
newShape[
|
|
653
|
+
for (const key2 in schema.shape) {
|
|
654
|
+
const fieldSchema = schema.shape[key2];
|
|
655
|
+
newShape[key2] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
656
656
|
}
|
|
657
657
|
return new ZodObject({
|
|
658
658
|
...schema._def,
|
|
@@ -680,14 +680,14 @@ function mergeValues(a, b) {
|
|
|
680
680
|
return { valid: true, data: a };
|
|
681
681
|
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
682
682
|
const bKeys = util.objectKeys(b);
|
|
683
|
-
const sharedKeys = util.objectKeys(a).filter((
|
|
683
|
+
const sharedKeys = util.objectKeys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
|
|
684
684
|
const newObj = { ...a, ...b };
|
|
685
|
-
for (const
|
|
686
|
-
const sharedValue = mergeValues(a[
|
|
685
|
+
for (const key2 of sharedKeys) {
|
|
686
|
+
const sharedValue = mergeValues(a[key2], b[key2]);
|
|
687
687
|
if (!sharedValue.valid) {
|
|
688
688
|
return { valid: false };
|
|
689
689
|
}
|
|
690
|
-
newObj[
|
|
690
|
+
newObj[key2] = sharedValue.data;
|
|
691
691
|
}
|
|
692
692
|
return { valid: true, data: newObj };
|
|
693
693
|
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
@@ -754,12 +754,12 @@ var init_types = __esm({
|
|
|
754
754
|
init_parseUtil();
|
|
755
755
|
init_util();
|
|
756
756
|
ParseInputLazyPath = class {
|
|
757
|
-
constructor(parent, value, path,
|
|
757
|
+
constructor(parent, value, path, key2) {
|
|
758
758
|
this._cachedPath = [];
|
|
759
759
|
this.parent = parent;
|
|
760
760
|
this.data = value;
|
|
761
761
|
this._path = path;
|
|
762
|
-
this._key =
|
|
762
|
+
this._key = key2;
|
|
763
763
|
}
|
|
764
764
|
get path() {
|
|
765
765
|
if (!this._cachedPath.length) {
|
|
@@ -2437,29 +2437,29 @@ var init_types = __esm({
|
|
|
2437
2437
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2438
2438
|
const extraKeys = [];
|
|
2439
2439
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
2440
|
-
for (const
|
|
2441
|
-
if (!shapeKeys.includes(
|
|
2442
|
-
extraKeys.push(
|
|
2440
|
+
for (const key2 in ctx.data) {
|
|
2441
|
+
if (!shapeKeys.includes(key2)) {
|
|
2442
|
+
extraKeys.push(key2);
|
|
2443
2443
|
}
|
|
2444
2444
|
}
|
|
2445
2445
|
}
|
|
2446
2446
|
const pairs = [];
|
|
2447
|
-
for (const
|
|
2448
|
-
const keyValidator = shape[
|
|
2449
|
-
const value = ctx.data[
|
|
2447
|
+
for (const key2 of shapeKeys) {
|
|
2448
|
+
const keyValidator = shape[key2];
|
|
2449
|
+
const value = ctx.data[key2];
|
|
2450
2450
|
pairs.push({
|
|
2451
|
-
key: { status: "valid", value:
|
|
2452
|
-
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path,
|
|
2453
|
-
alwaysSet:
|
|
2451
|
+
key: { status: "valid", value: key2 },
|
|
2452
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key2)),
|
|
2453
|
+
alwaysSet: key2 in ctx.data
|
|
2454
2454
|
});
|
|
2455
2455
|
}
|
|
2456
2456
|
if (this._def.catchall instanceof ZodNever) {
|
|
2457
2457
|
const unknownKeys = this._def.unknownKeys;
|
|
2458
2458
|
if (unknownKeys === "passthrough") {
|
|
2459
|
-
for (const
|
|
2459
|
+
for (const key2 of extraKeys) {
|
|
2460
2460
|
pairs.push({
|
|
2461
|
-
key: { status: "valid", value:
|
|
2462
|
-
value: { status: "valid", value: ctx.data[
|
|
2461
|
+
key: { status: "valid", value: key2 },
|
|
2462
|
+
value: { status: "valid", value: ctx.data[key2] }
|
|
2463
2463
|
});
|
|
2464
2464
|
}
|
|
2465
2465
|
} else if (unknownKeys === "strict") {
|
|
@@ -2476,15 +2476,15 @@ var init_types = __esm({
|
|
|
2476
2476
|
}
|
|
2477
2477
|
} else {
|
|
2478
2478
|
const catchall = this._def.catchall;
|
|
2479
|
-
for (const
|
|
2480
|
-
const value = ctx.data[
|
|
2479
|
+
for (const key2 of extraKeys) {
|
|
2480
|
+
const value = ctx.data[key2];
|
|
2481
2481
|
pairs.push({
|
|
2482
|
-
key: { status: "valid", value:
|
|
2482
|
+
key: { status: "valid", value: key2 },
|
|
2483
2483
|
value: catchall._parse(
|
|
2484
|
-
new ParseInputLazyPath(ctx, value, ctx.path,
|
|
2484
|
+
new ParseInputLazyPath(ctx, value, ctx.path, key2)
|
|
2485
2485
|
//, ctx.child(key), value, getParsedType(value)
|
|
2486
2486
|
),
|
|
2487
|
-
alwaysSet:
|
|
2487
|
+
alwaysSet: key2 in ctx.data
|
|
2488
2488
|
});
|
|
2489
2489
|
}
|
|
2490
2490
|
}
|
|
@@ -2492,10 +2492,10 @@ var init_types = __esm({
|
|
|
2492
2492
|
return Promise.resolve().then(async () => {
|
|
2493
2493
|
const syncPairs = [];
|
|
2494
2494
|
for (const pair of pairs) {
|
|
2495
|
-
const
|
|
2495
|
+
const key2 = await pair.key;
|
|
2496
2496
|
const value = await pair.value;
|
|
2497
2497
|
syncPairs.push({
|
|
2498
|
-
key,
|
|
2498
|
+
key: key2,
|
|
2499
2499
|
value,
|
|
2500
2500
|
alwaysSet: pair.alwaysSet
|
|
2501
2501
|
});
|
|
@@ -2620,8 +2620,8 @@ var init_types = __esm({
|
|
|
2620
2620
|
// }) as any;
|
|
2621
2621
|
// return merged;
|
|
2622
2622
|
// }
|
|
2623
|
-
setKey(
|
|
2624
|
-
return this.augment({ [
|
|
2623
|
+
setKey(key2, schema) {
|
|
2624
|
+
return this.augment({ [key2]: schema });
|
|
2625
2625
|
}
|
|
2626
2626
|
// merge<Incoming extends AnyZodObject>(
|
|
2627
2627
|
// merging: Incoming
|
|
@@ -2652,9 +2652,9 @@ var init_types = __esm({
|
|
|
2652
2652
|
}
|
|
2653
2653
|
pick(mask) {
|
|
2654
2654
|
const shape = {};
|
|
2655
|
-
for (const
|
|
2656
|
-
if (mask[
|
|
2657
|
-
shape[
|
|
2655
|
+
for (const key2 of util.objectKeys(mask)) {
|
|
2656
|
+
if (mask[key2] && this.shape[key2]) {
|
|
2657
|
+
shape[key2] = this.shape[key2];
|
|
2658
2658
|
}
|
|
2659
2659
|
}
|
|
2660
2660
|
return new _ZodObject({
|
|
@@ -2664,9 +2664,9 @@ var init_types = __esm({
|
|
|
2664
2664
|
}
|
|
2665
2665
|
omit(mask) {
|
|
2666
2666
|
const shape = {};
|
|
2667
|
-
for (const
|
|
2668
|
-
if (!mask[
|
|
2669
|
-
shape[
|
|
2667
|
+
for (const key2 of util.objectKeys(this.shape)) {
|
|
2668
|
+
if (!mask[key2]) {
|
|
2669
|
+
shape[key2] = this.shape[key2];
|
|
2670
2670
|
}
|
|
2671
2671
|
}
|
|
2672
2672
|
return new _ZodObject({
|
|
@@ -2682,12 +2682,12 @@ var init_types = __esm({
|
|
|
2682
2682
|
}
|
|
2683
2683
|
partial(mask) {
|
|
2684
2684
|
const newShape = {};
|
|
2685
|
-
for (const
|
|
2686
|
-
const fieldSchema = this.shape[
|
|
2687
|
-
if (mask && !mask[
|
|
2688
|
-
newShape[
|
|
2685
|
+
for (const key2 of util.objectKeys(this.shape)) {
|
|
2686
|
+
const fieldSchema = this.shape[key2];
|
|
2687
|
+
if (mask && !mask[key2]) {
|
|
2688
|
+
newShape[key2] = fieldSchema;
|
|
2689
2689
|
} else {
|
|
2690
|
-
newShape[
|
|
2690
|
+
newShape[key2] = fieldSchema.optional();
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
2693
|
return new _ZodObject({
|
|
@@ -2697,16 +2697,16 @@ var init_types = __esm({
|
|
|
2697
2697
|
}
|
|
2698
2698
|
required(mask) {
|
|
2699
2699
|
const newShape = {};
|
|
2700
|
-
for (const
|
|
2701
|
-
if (mask && !mask[
|
|
2702
|
-
newShape[
|
|
2700
|
+
for (const key2 of util.objectKeys(this.shape)) {
|
|
2701
|
+
if (mask && !mask[key2]) {
|
|
2702
|
+
newShape[key2] = this.shape[key2];
|
|
2703
2703
|
} else {
|
|
2704
|
-
const fieldSchema = this.shape[
|
|
2704
|
+
const fieldSchema = this.shape[key2];
|
|
2705
2705
|
let newField = fieldSchema;
|
|
2706
2706
|
while (newField instanceof ZodOptional) {
|
|
2707
2707
|
newField = newField._def.innerType;
|
|
2708
2708
|
}
|
|
2709
|
-
newShape[
|
|
2709
|
+
newShape[key2] = newField;
|
|
2710
2710
|
}
|
|
2711
2711
|
}
|
|
2712
2712
|
return new _ZodObject({
|
|
@@ -3083,11 +3083,11 @@ var init_types = __esm({
|
|
|
3083
3083
|
const pairs = [];
|
|
3084
3084
|
const keyType = this._def.keyType;
|
|
3085
3085
|
const valueType = this._def.valueType;
|
|
3086
|
-
for (const
|
|
3086
|
+
for (const key2 in ctx.data) {
|
|
3087
3087
|
pairs.push({
|
|
3088
|
-
key: keyType._parse(new ParseInputLazyPath(ctx,
|
|
3089
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[
|
|
3090
|
-
alwaysSet:
|
|
3088
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, key2)),
|
|
3089
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key2], ctx.path, key2)),
|
|
3090
|
+
alwaysSet: key2 in ctx.data
|
|
3091
3091
|
});
|
|
3092
3092
|
}
|
|
3093
3093
|
if (ctx.common.async) {
|
|
@@ -3135,9 +3135,9 @@ var init_types = __esm({
|
|
|
3135
3135
|
}
|
|
3136
3136
|
const keyType = this._def.keyType;
|
|
3137
3137
|
const valueType = this._def.valueType;
|
|
3138
|
-
const pairs = [...ctx.data.entries()].map(([
|
|
3138
|
+
const pairs = [...ctx.data.entries()].map(([key2, value], index) => {
|
|
3139
3139
|
return {
|
|
3140
|
-
key: keyType._parse(new ParseInputLazyPath(ctx,
|
|
3140
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, [index, "key"])),
|
|
3141
3141
|
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
3142
3142
|
};
|
|
3143
3143
|
});
|
|
@@ -3145,30 +3145,30 @@ var init_types = __esm({
|
|
|
3145
3145
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3146
3146
|
return Promise.resolve().then(async () => {
|
|
3147
3147
|
for (const pair of pairs) {
|
|
3148
|
-
const
|
|
3148
|
+
const key2 = await pair.key;
|
|
3149
3149
|
const value = await pair.value;
|
|
3150
|
-
if (
|
|
3150
|
+
if (key2.status === "aborted" || value.status === "aborted") {
|
|
3151
3151
|
return INVALID;
|
|
3152
3152
|
}
|
|
3153
|
-
if (
|
|
3153
|
+
if (key2.status === "dirty" || value.status === "dirty") {
|
|
3154
3154
|
status.dirty();
|
|
3155
3155
|
}
|
|
3156
|
-
finalMap.set(
|
|
3156
|
+
finalMap.set(key2.value, value.value);
|
|
3157
3157
|
}
|
|
3158
3158
|
return { status: status.value, value: finalMap };
|
|
3159
3159
|
});
|
|
3160
3160
|
} else {
|
|
3161
3161
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3162
3162
|
for (const pair of pairs) {
|
|
3163
|
-
const
|
|
3163
|
+
const key2 = pair.key;
|
|
3164
3164
|
const value = pair.value;
|
|
3165
|
-
if (
|
|
3165
|
+
if (key2.status === "aborted" || value.status === "aborted") {
|
|
3166
3166
|
return INVALID;
|
|
3167
3167
|
}
|
|
3168
|
-
if (
|
|
3168
|
+
if (key2.status === "dirty" || value.status === "dirty") {
|
|
3169
3169
|
status.dirty();
|
|
3170
3170
|
}
|
|
3171
|
-
finalMap.set(
|
|
3171
|
+
finalMap.set(key2.value, value.value);
|
|
3172
3172
|
}
|
|
3173
3173
|
return { status: status.value, value: finalMap };
|
|
3174
3174
|
}
|
|
@@ -4275,15 +4275,15 @@ var require_code = __commonJS({
|
|
|
4275
4275
|
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
4276
4276
|
}
|
|
4277
4277
|
exports.safeStringify = safeStringify;
|
|
4278
|
-
function getProperty(
|
|
4279
|
-
return typeof
|
|
4278
|
+
function getProperty(key2) {
|
|
4279
|
+
return typeof key2 == "string" && exports.IDENTIFIER.test(key2) ? new _Code(`.${key2}`) : _`[${key2}]`;
|
|
4280
4280
|
}
|
|
4281
4281
|
exports.getProperty = getProperty;
|
|
4282
|
-
function getEsmExportName(
|
|
4283
|
-
if (typeof
|
|
4284
|
-
return new _Code(`${
|
|
4282
|
+
function getEsmExportName(key2) {
|
|
4283
|
+
if (typeof key2 == "string" && exports.IDENTIFIER.test(key2)) {
|
|
4284
|
+
return new _Code(`${key2}`);
|
|
4285
4285
|
}
|
|
4286
|
-
throw new Error(`CodeGen: invalid export name: ${
|
|
4286
|
+
throw new Error(`CodeGen: invalid export name: ${key2}, use explicit $id name mapping`);
|
|
4287
4287
|
}
|
|
4288
4288
|
exports.getEsmExportName = getEsmExportName;
|
|
4289
4289
|
function regexpCode(rx) {
|
|
@@ -4910,11 +4910,11 @@ var require_codegen = __commonJS({
|
|
|
4910
4910
|
// returns code for object literal for the passed argument list of key-value pairs
|
|
4911
4911
|
object(...keyValues) {
|
|
4912
4912
|
const code = ["{"];
|
|
4913
|
-
for (const [
|
|
4913
|
+
for (const [key2, value] of keyValues) {
|
|
4914
4914
|
if (code.length > 1)
|
|
4915
4915
|
code.push(",");
|
|
4916
|
-
code.push(
|
|
4917
|
-
if (
|
|
4916
|
+
code.push(key2);
|
|
4917
|
+
if (key2 !== value || this.opts.es5) {
|
|
4918
4918
|
code.push(":");
|
|
4919
4919
|
(0, code_1.addCodeArg)(code, value);
|
|
4920
4920
|
}
|
|
@@ -5189,17 +5189,17 @@ var require_util = __commonJS({
|
|
|
5189
5189
|
if (typeof schema === "boolean")
|
|
5190
5190
|
return;
|
|
5191
5191
|
const rules = self.RULES.keywords;
|
|
5192
|
-
for (const
|
|
5193
|
-
if (!rules[
|
|
5194
|
-
checkStrictMode(it, `unknown keyword: "${
|
|
5192
|
+
for (const key2 in schema) {
|
|
5193
|
+
if (!rules[key2])
|
|
5194
|
+
checkStrictMode(it, `unknown keyword: "${key2}"`);
|
|
5195
5195
|
}
|
|
5196
5196
|
}
|
|
5197
5197
|
exports.checkUnknownRules = checkUnknownRules;
|
|
5198
5198
|
function schemaHasRules(schema, rules) {
|
|
5199
5199
|
if (typeof schema == "boolean")
|
|
5200
5200
|
return !schema;
|
|
5201
|
-
for (const
|
|
5202
|
-
if (rules[
|
|
5201
|
+
for (const key2 in schema)
|
|
5202
|
+
if (rules[key2])
|
|
5203
5203
|
return true;
|
|
5204
5204
|
return false;
|
|
5205
5205
|
}
|
|
@@ -5207,8 +5207,8 @@ var require_util = __commonJS({
|
|
|
5207
5207
|
function schemaHasRulesButRef(schema, RULES) {
|
|
5208
5208
|
if (typeof schema == "boolean")
|
|
5209
5209
|
return !schema;
|
|
5210
|
-
for (const
|
|
5211
|
-
if (
|
|
5210
|
+
for (const key2 in schema)
|
|
5211
|
+
if (key2 !== "$ref" && RULES.all[key2])
|
|
5212
5212
|
return true;
|
|
5213
5213
|
return false;
|
|
5214
5214
|
}
|
|
@@ -5786,8 +5786,8 @@ var require_defaults = __commonJS({
|
|
|
5786
5786
|
function assignDefaults(it, ty) {
|
|
5787
5787
|
const { properties, items } = it.schema;
|
|
5788
5788
|
if (ty === "object" && properties) {
|
|
5789
|
-
for (const
|
|
5790
|
-
assignDefault(it,
|
|
5789
|
+
for (const key2 in properties) {
|
|
5790
|
+
assignDefault(it, key2, properties[key2].default);
|
|
5791
5791
|
}
|
|
5792
5792
|
} else if (ty === "array" && Array.isArray(items)) {
|
|
5793
5793
|
items.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
@@ -6171,8 +6171,8 @@ var require_fast_deep_equal = __commonJS({
|
|
|
6171
6171
|
for (i = length; i-- !== 0; )
|
|
6172
6172
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
6173
6173
|
for (i = length; i-- !== 0; ) {
|
|
6174
|
-
var
|
|
6175
|
-
if (!equal(a[
|
|
6174
|
+
var key2 = keys[i];
|
|
6175
|
+
if (!equal(a[key2], b[key2])) return false;
|
|
6176
6176
|
}
|
|
6177
6177
|
return true;
|
|
6178
6178
|
}
|
|
@@ -6244,20 +6244,20 @@ var require_json_schema_traverse = __commonJS({
|
|
|
6244
6244
|
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
6245
6245
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
6246
6246
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
6247
|
-
for (var
|
|
6248
|
-
var sch = schema[
|
|
6247
|
+
for (var key2 in schema) {
|
|
6248
|
+
var sch = schema[key2];
|
|
6249
6249
|
if (Array.isArray(sch)) {
|
|
6250
|
-
if (
|
|
6250
|
+
if (key2 in traverse.arrayKeywords) {
|
|
6251
6251
|
for (var i = 0; i < sch.length; i++)
|
|
6252
|
-
_traverse(opts, pre, post, sch[i], jsonPtr + "/" +
|
|
6252
|
+
_traverse(opts, pre, post, sch[i], jsonPtr + "/" + key2 + "/" + i, rootSchema, jsonPtr, key2, schema, i);
|
|
6253
6253
|
}
|
|
6254
|
-
} else if (
|
|
6254
|
+
} else if (key2 in traverse.propsKeywords) {
|
|
6255
6255
|
if (sch && typeof sch == "object") {
|
|
6256
6256
|
for (var prop in sch)
|
|
6257
|
-
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" +
|
|
6257
|
+
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key2 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key2, schema, prop);
|
|
6258
6258
|
}
|
|
6259
|
-
} else if (
|
|
6260
|
-
_traverse(opts, pre, post, sch, jsonPtr + "/" +
|
|
6259
|
+
} else if (key2 in traverse.keywords || opts.allKeys && !(key2 in traverse.skipKeywords)) {
|
|
6260
|
+
_traverse(opts, pre, post, sch, jsonPtr + "/" + key2, rootSchema, jsonPtr, key2, schema);
|
|
6261
6261
|
}
|
|
6262
6262
|
}
|
|
6263
6263
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
@@ -6314,10 +6314,10 @@ var require_resolve = __commonJS({
|
|
|
6314
6314
|
"$dynamicAnchor"
|
|
6315
6315
|
]);
|
|
6316
6316
|
function hasRef(schema) {
|
|
6317
|
-
for (const
|
|
6318
|
-
if (REF_KEYWORDS.has(
|
|
6317
|
+
for (const key2 in schema) {
|
|
6318
|
+
if (REF_KEYWORDS.has(key2))
|
|
6319
6319
|
return true;
|
|
6320
|
-
const sch = schema[
|
|
6320
|
+
const sch = schema[key2];
|
|
6321
6321
|
if (Array.isArray(sch) && sch.some(hasRef))
|
|
6322
6322
|
return true;
|
|
6323
6323
|
if (typeof sch == "object" && hasRef(sch))
|
|
@@ -6327,14 +6327,14 @@ var require_resolve = __commonJS({
|
|
|
6327
6327
|
}
|
|
6328
6328
|
function countKeys(schema) {
|
|
6329
6329
|
let count = 0;
|
|
6330
|
-
for (const
|
|
6331
|
-
if (
|
|
6330
|
+
for (const key2 in schema) {
|
|
6331
|
+
if (key2 === "$ref")
|
|
6332
6332
|
return Infinity;
|
|
6333
6333
|
count++;
|
|
6334
|
-
if (SIMPLE_INLINED.has(
|
|
6334
|
+
if (SIMPLE_INLINED.has(key2))
|
|
6335
6335
|
continue;
|
|
6336
|
-
if (typeof schema[
|
|
6337
|
-
(0, util_1.eachItem)(schema[
|
|
6336
|
+
if (typeof schema[key2] == "object") {
|
|
6337
|
+
(0, util_1.eachItem)(schema[key2], (sch) => count += countKeys(sch));
|
|
6338
6338
|
}
|
|
6339
6339
|
if (count === Infinity)
|
|
6340
6340
|
return Infinity;
|
|
@@ -6523,8 +6523,8 @@ var require_validate = __commonJS({
|
|
|
6523
6523
|
function schemaCxtHasRules({ schema, self }) {
|
|
6524
6524
|
if (typeof schema == "boolean")
|
|
6525
6525
|
return !schema;
|
|
6526
|
-
for (const
|
|
6527
|
-
if (self.RULES.all[
|
|
6526
|
+
for (const key2 in schema)
|
|
6527
|
+
if (self.RULES.all[key2])
|
|
6528
6528
|
return true;
|
|
6529
6529
|
return false;
|
|
6530
6530
|
}
|
|
@@ -8562,7 +8562,7 @@ var require_core = __commonJS({
|
|
|
8562
8562
|
}
|
|
8563
8563
|
}
|
|
8564
8564
|
// Adds schema to the instance
|
|
8565
|
-
addSchema(schema,
|
|
8565
|
+
addSchema(schema, key2, _meta, _validateSchema = this.opts.validateSchema) {
|
|
8566
8566
|
if (Array.isArray(schema)) {
|
|
8567
8567
|
for (const sch of schema)
|
|
8568
8568
|
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
@@ -8576,15 +8576,15 @@ var require_core = __commonJS({
|
|
|
8576
8576
|
throw new Error(`schema ${schemaId} must be string`);
|
|
8577
8577
|
}
|
|
8578
8578
|
}
|
|
8579
|
-
|
|
8580
|
-
this._checkUnique(
|
|
8581
|
-
this.schemas[
|
|
8579
|
+
key2 = (0, resolve_1.normalizeId)(key2 || id);
|
|
8580
|
+
this._checkUnique(key2);
|
|
8581
|
+
this.schemas[key2] = this._addSchema(schema, _meta, key2, _validateSchema, true);
|
|
8582
8582
|
return this;
|
|
8583
8583
|
}
|
|
8584
8584
|
// Add schema that will be used to validate other schemas
|
|
8585
8585
|
// options in META_IGNORE_OPTIONS are alway set to false
|
|
8586
|
-
addMetaSchema(schema,
|
|
8587
|
-
this.addSchema(schema,
|
|
8586
|
+
addMetaSchema(schema, key2, _validateSchema = this.opts.validateSchema) {
|
|
8587
|
+
this.addSchema(schema, key2, true, _validateSchema);
|
|
8588
8588
|
return this;
|
|
8589
8589
|
}
|
|
8590
8590
|
// Validate schema against its meta-schema
|
|
@@ -8740,14 +8740,14 @@ var require_core = __commonJS({
|
|
|
8740
8740
|
let keywords = metaSchema;
|
|
8741
8741
|
for (const seg of segments)
|
|
8742
8742
|
keywords = keywords[seg];
|
|
8743
|
-
for (const
|
|
8744
|
-
const rule = rules[
|
|
8743
|
+
for (const key2 in rules) {
|
|
8744
|
+
const rule = rules[key2];
|
|
8745
8745
|
if (typeof rule != "object")
|
|
8746
8746
|
continue;
|
|
8747
8747
|
const { $data } = rule.definition;
|
|
8748
|
-
const schema = keywords[
|
|
8748
|
+
const schema = keywords[key2];
|
|
8749
8749
|
if ($data && schema)
|
|
8750
|
-
keywords[
|
|
8750
|
+
keywords[key2] = schemaOrData(schema);
|
|
8751
8751
|
}
|
|
8752
8752
|
}
|
|
8753
8753
|
return metaSchema;
|
|
@@ -8820,10 +8820,10 @@ var require_core = __commonJS({
|
|
|
8820
8820
|
Ajv2.MissingRefError = ref_error_1.default;
|
|
8821
8821
|
exports.default = Ajv2;
|
|
8822
8822
|
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
8823
|
-
for (const
|
|
8824
|
-
const opt =
|
|
8823
|
+
for (const key2 in checkOpts) {
|
|
8824
|
+
const opt = key2;
|
|
8825
8825
|
if (opt in options)
|
|
8826
|
-
this.logger[log](`${msg}: option ${
|
|
8826
|
+
this.logger[log](`${msg}: option ${key2}. ${checkOpts[opt]}`);
|
|
8827
8827
|
}
|
|
8828
8828
|
}
|
|
8829
8829
|
function getSchEnv(keyRef) {
|
|
@@ -8837,8 +8837,8 @@ var require_core = __commonJS({
|
|
|
8837
8837
|
if (Array.isArray(optsSchemas))
|
|
8838
8838
|
this.addSchema(optsSchemas);
|
|
8839
8839
|
else
|
|
8840
|
-
for (const
|
|
8841
|
-
this.addSchema(optsSchemas[
|
|
8840
|
+
for (const key2 in optsSchemas)
|
|
8841
|
+
this.addSchema(optsSchemas[key2], key2);
|
|
8842
8842
|
}
|
|
8843
8843
|
function addInitialFormats() {
|
|
8844
8844
|
for (const name in this.opts.formats) {
|
|
@@ -9886,11 +9886,11 @@ var require_dependencies = __commonJS({
|
|
|
9886
9886
|
function splitDependencies({ schema }) {
|
|
9887
9887
|
const propertyDeps = {};
|
|
9888
9888
|
const schemaDeps = {};
|
|
9889
|
-
for (const
|
|
9890
|
-
if (
|
|
9889
|
+
for (const key2 in schema) {
|
|
9890
|
+
if (key2 === "__proto__")
|
|
9891
9891
|
continue;
|
|
9892
|
-
const deps = Array.isArray(schema[
|
|
9893
|
-
deps[
|
|
9892
|
+
const deps = Array.isArray(schema[key2]) ? propertyDeps : schemaDeps;
|
|
9893
|
+
deps[key2] = schema[key2];
|
|
9894
9894
|
}
|
|
9895
9895
|
return [propertyDeps, schemaDeps];
|
|
9896
9896
|
}
|
|
@@ -9967,13 +9967,13 @@ var require_propertyNames = __commonJS({
|
|
|
9967
9967
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
9968
9968
|
return;
|
|
9969
9969
|
const valid = gen.name("valid");
|
|
9970
|
-
gen.forIn("key", data, (
|
|
9971
|
-
cxt.setParams({ propertyName:
|
|
9970
|
+
gen.forIn("key", data, (key2) => {
|
|
9971
|
+
cxt.setParams({ propertyName: key2 });
|
|
9972
9972
|
cxt.subschema({
|
|
9973
9973
|
keyword: "propertyNames",
|
|
9974
|
-
data:
|
|
9974
|
+
data: key2,
|
|
9975
9975
|
dataTypes: ["string"],
|
|
9976
|
-
propertyName:
|
|
9976
|
+
propertyName: key2,
|
|
9977
9977
|
compositeRule: true
|
|
9978
9978
|
}, valid);
|
|
9979
9979
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
@@ -10022,38 +10022,38 @@ var require_additionalProperties = __commonJS({
|
|
|
10022
10022
|
checkAdditionalProperties();
|
|
10023
10023
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
10024
10024
|
function checkAdditionalProperties() {
|
|
10025
|
-
gen.forIn("key", data, (
|
|
10025
|
+
gen.forIn("key", data, (key2) => {
|
|
10026
10026
|
if (!props.length && !patProps.length)
|
|
10027
|
-
additionalPropertyCode(
|
|
10027
|
+
additionalPropertyCode(key2);
|
|
10028
10028
|
else
|
|
10029
|
-
gen.if(isAdditional(
|
|
10029
|
+
gen.if(isAdditional(key2), () => additionalPropertyCode(key2));
|
|
10030
10030
|
});
|
|
10031
10031
|
}
|
|
10032
|
-
function isAdditional(
|
|
10032
|
+
function isAdditional(key2) {
|
|
10033
10033
|
let definedProp;
|
|
10034
10034
|
if (props.length > 8) {
|
|
10035
10035
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
10036
|
-
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema,
|
|
10036
|
+
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key2);
|
|
10037
10037
|
} else if (props.length) {
|
|
10038
|
-
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${
|
|
10038
|
+
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key2} === ${p}`));
|
|
10039
10039
|
} else {
|
|
10040
10040
|
definedProp = codegen_1.nil;
|
|
10041
10041
|
}
|
|
10042
10042
|
if (patProps.length) {
|
|
10043
|
-
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${
|
|
10043
|
+
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key2})`));
|
|
10044
10044
|
}
|
|
10045
10045
|
return (0, codegen_1.not)(definedProp);
|
|
10046
10046
|
}
|
|
10047
|
-
function deleteAdditional(
|
|
10048
|
-
gen.code((0, codegen_1._)`delete ${data}[${
|
|
10047
|
+
function deleteAdditional(key2) {
|
|
10048
|
+
gen.code((0, codegen_1._)`delete ${data}[${key2}]`);
|
|
10049
10049
|
}
|
|
10050
|
-
function additionalPropertyCode(
|
|
10050
|
+
function additionalPropertyCode(key2) {
|
|
10051
10051
|
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
|
|
10052
|
-
deleteAdditional(
|
|
10052
|
+
deleteAdditional(key2);
|
|
10053
10053
|
return;
|
|
10054
10054
|
}
|
|
10055
10055
|
if (schema === false) {
|
|
10056
|
-
cxt.setParams({ additionalProperty:
|
|
10056
|
+
cxt.setParams({ additionalProperty: key2 });
|
|
10057
10057
|
cxt.error();
|
|
10058
10058
|
if (!allErrors)
|
|
10059
10059
|
gen.break();
|
|
@@ -10062,22 +10062,22 @@ var require_additionalProperties = __commonJS({
|
|
|
10062
10062
|
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
|
10063
10063
|
const valid = gen.name("valid");
|
|
10064
10064
|
if (opts.removeAdditional === "failing") {
|
|
10065
|
-
applyAdditionalSchema(
|
|
10065
|
+
applyAdditionalSchema(key2, valid, false);
|
|
10066
10066
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
10067
10067
|
cxt.reset();
|
|
10068
|
-
deleteAdditional(
|
|
10068
|
+
deleteAdditional(key2);
|
|
10069
10069
|
});
|
|
10070
10070
|
} else {
|
|
10071
|
-
applyAdditionalSchema(
|
|
10071
|
+
applyAdditionalSchema(key2, valid);
|
|
10072
10072
|
if (!allErrors)
|
|
10073
10073
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
10074
10074
|
}
|
|
10075
10075
|
}
|
|
10076
10076
|
}
|
|
10077
|
-
function applyAdditionalSchema(
|
|
10077
|
+
function applyAdditionalSchema(key2, valid, errors) {
|
|
10078
10078
|
const subschema = {
|
|
10079
10079
|
keyword: "additionalProperties",
|
|
10080
|
-
dataProp:
|
|
10080
|
+
dataProp: key2,
|
|
10081
10081
|
dataPropType: util_1.Type.Str
|
|
10082
10082
|
};
|
|
10083
10083
|
if (errors === false) {
|
|
@@ -10202,19 +10202,19 @@ var require_patternProperties = __commonJS({
|
|
|
10202
10202
|
}
|
|
10203
10203
|
}
|
|
10204
10204
|
function validateProperties(pat) {
|
|
10205
|
-
gen.forIn("key", data, (
|
|
10206
|
-
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${
|
|
10205
|
+
gen.forIn("key", data, (key2) => {
|
|
10206
|
+
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key2})`, () => {
|
|
10207
10207
|
const alwaysValid = alwaysValidPatterns.includes(pat);
|
|
10208
10208
|
if (!alwaysValid) {
|
|
10209
10209
|
cxt.subschema({
|
|
10210
10210
|
keyword: "patternProperties",
|
|
10211
10211
|
schemaProp: pat,
|
|
10212
|
-
dataProp:
|
|
10212
|
+
dataProp: key2,
|
|
10213
10213
|
dataPropType: util_2.Type.Str
|
|
10214
10214
|
}, valid);
|
|
10215
10215
|
}
|
|
10216
10216
|
if (it.opts.unevaluated && props !== true) {
|
|
10217
|
-
gen.assign((0, codegen_1._)`${props}[${
|
|
10217
|
+
gen.assign((0, codegen_1._)`${props}[${key2}]`, true);
|
|
10218
10218
|
} else if (!alwaysValid && !it.allErrors) {
|
|
10219
10219
|
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
10220
10220
|
}
|
|
@@ -11120,8 +11120,8 @@ var init_consumer_commands = __esm({
|
|
|
11120
11120
|
const visit = (value, depth = 0) => {
|
|
11121
11121
|
if (depth > 16) throw new Error("consumer input schema is too deeply nested");
|
|
11122
11122
|
if (!value || typeof value !== "object") return;
|
|
11123
|
-
for (const [
|
|
11124
|
-
if (["$ref", "$id", "$async", "pattern", "patternProperties", "format"].includes(
|
|
11123
|
+
for (const [key2, child] of Object.entries(value)) {
|
|
11124
|
+
if (["$ref", "$id", "$async", "pattern", "patternProperties", "format"].includes(key2)) {
|
|
11125
11125
|
throw new Error("consumer input schema contains an unsupported keyword");
|
|
11126
11126
|
}
|
|
11127
11127
|
visit(child, depth + 1);
|
|
@@ -11275,7 +11275,7 @@ function rejectRemovedEnvironment(env) {
|
|
|
11275
11275
|
}
|
|
11276
11276
|
function rejectRemovedConfig(value, path) {
|
|
11277
11277
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
11278
|
-
const removed = ["brokerUrl", "daemon"].filter((
|
|
11278
|
+
const removed = ["brokerUrl", "daemon"].filter((key2) => Object.hasOwn(value, key2));
|
|
11279
11279
|
if (removed.length === 0) return;
|
|
11280
11280
|
throw new CoworkConfigError(
|
|
11281
11281
|
`cowork config at ${path} contains removed ${removed.join(" and ")} ${removed.length === 1 ? "key" : "keys"}: ours-cowork now attaches only to the shared ours daemon. Remove those keys and configure the daemon with @ours.network/cli.`
|
|
@@ -12240,15 +12240,15 @@ var init_contracts = __esm({
|
|
|
12240
12240
|
}
|
|
12241
12241
|
const seenCommandGrants = /* @__PURE__ */ new Set();
|
|
12242
12242
|
for (const [index, grant] of room.command_grants.entries()) {
|
|
12243
|
-
const
|
|
12244
|
-
if (seenCommandGrants.has(
|
|
12243
|
+
const key2 = `${grant.caller_cid}\0${grant.command}`;
|
|
12244
|
+
if (seenCommandGrants.has(key2)) {
|
|
12245
12245
|
context.addIssue({
|
|
12246
12246
|
code: external_exports.ZodIssueCode.custom,
|
|
12247
12247
|
path: ["command_grants", index],
|
|
12248
12248
|
message: "runtime command grants must be unique by caller CID and command"
|
|
12249
12249
|
});
|
|
12250
12250
|
}
|
|
12251
|
-
seenCommandGrants.add(
|
|
12251
|
+
seenCommandGrants.add(key2);
|
|
12252
12252
|
if (!room.seats.some((seat) => seat.state === "active" && seat.identity === grant.caller_cid)) {
|
|
12253
12253
|
context.addIssue({
|
|
12254
12254
|
code: external_exports.ZodIssueCode.custom,
|
|
@@ -14010,6 +14010,70 @@ var init_ulid = __esm({
|
|
|
14010
14010
|
}
|
|
14011
14011
|
});
|
|
14012
14012
|
|
|
14013
|
+
// src/reply-threading.ts
|
|
14014
|
+
async function readReplyRows(store, roomId) {
|
|
14015
|
+
const rows = [];
|
|
14016
|
+
let after = 0;
|
|
14017
|
+
for (; ; ) {
|
|
14018
|
+
const page = await store.read(roomId, { after, limit: 64 });
|
|
14019
|
+
if (page.length === 0) return rows;
|
|
14020
|
+
const last = page[page.length - 1];
|
|
14021
|
+
if (last.seq <= after) throw new Error("reply archive cursor did not advance");
|
|
14022
|
+
for (const r of page) {
|
|
14023
|
+
if (r.room_id !== roomId) throw new Error("reply archive room mismatch");
|
|
14024
|
+
if (r.kind === "message") rows.push({ ...r, text: "" });
|
|
14025
|
+
else if (r.kind === "file") rows.push({ ...r, data_base64: "" });
|
|
14026
|
+
else if (r.kind === "relay_intent" || r.kind === "relay_result") rows.push(r);
|
|
14027
|
+
}
|
|
14028
|
+
after = last.seq;
|
|
14029
|
+
}
|
|
14030
|
+
}
|
|
14031
|
+
function selectReply(rows, roomId, child, recipientCid) {
|
|
14032
|
+
if (child.room_id !== roomId) throw new Error("reply child room mismatch");
|
|
14033
|
+
const incoming = child.source_reply_to?.wire_id;
|
|
14034
|
+
if (!nonempty(incoming)) return { state: "none" };
|
|
14035
|
+
const local = rows.filter((r) => r.room_id === roomId);
|
|
14036
|
+
const items = local.filter((r) => r.kind === "message" || r.kind === "file");
|
|
14037
|
+
const intents = local.filter((r) => r.kind === "relay_intent");
|
|
14038
|
+
const results = local.filter((r) => r.kind === "relay_result");
|
|
14039
|
+
const copies = (parent2, cid) => results.filter((result) => {
|
|
14040
|
+
if (result.status !== "queued" || result.recipient_identity !== cid || key(result) !== key(parent2) || !parent2.recipient_identities.includes(cid)) return false;
|
|
14041
|
+
const matches = intents.filter((intent2) => intent2.record_id === result.intent_record_id);
|
|
14042
|
+
if (matches.length !== 1) return false;
|
|
14043
|
+
const intent = matches[0];
|
|
14044
|
+
return key(intent) === key(parent2) && intent.recipient_identity === cid && parent2.seq < intent.seq && intent.seq < result.seq;
|
|
14045
|
+
}).sort((a, b) => a.seq - b.seq);
|
|
14046
|
+
const wires = (r, parent2) => [r.wire_id, ...parent2.kind === "file" ? [r.metadata_wire_id] : []].filter(nonempty);
|
|
14047
|
+
const ownersFor = (wireId2, cid) => items.filter((item) => item.author.identity === cid && item.source_wire_id === wireId2 || copies(item, cid).some((result) => wires(result, item).includes(wireId2)));
|
|
14048
|
+
const candidates = items.filter((parent2) => parent2.author.identity === child.author.identity && parent2.source_wire_id === incoming || copies(parent2, child.author.identity).some((result) => wires(result, parent2).includes(incoming)));
|
|
14049
|
+
if (candidates.length === 0) return { state: "unknown_parent" };
|
|
14050
|
+
if (candidates.length !== 1) return { state: "ambiguous_parent" };
|
|
14051
|
+
const parent = candidates[0];
|
|
14052
|
+
if (parent.seq >= child.seq) return { state: "unknown_parent" };
|
|
14053
|
+
const parentKey = key(parent);
|
|
14054
|
+
if (items.filter((item) => key(item) === parentKey).length !== 1) {
|
|
14055
|
+
return { state: "ambiguous_parent" };
|
|
14056
|
+
}
|
|
14057
|
+
const recipientCopies = copies(parent, recipientCid);
|
|
14058
|
+
const sourceWire = parent.author.identity === recipientCid && nonempty(parent.source_wire_id) ? parent.source_wire_id : void 0;
|
|
14059
|
+
const sourceOwners = sourceWire === void 0 ? [] : ownersFor(sourceWire, recipientCid);
|
|
14060
|
+
const wireId = sourceOwners.length === 1 && key(sourceOwners[0]) === parentKey ? sourceWire : recipientCopies.map((copy) => wires(copy, parent)[0]).find(nonempty);
|
|
14061
|
+
if (!nonempty(wireId)) return { state: "missing_copy", parentKey };
|
|
14062
|
+
const owners = ownersFor(wireId, recipientCid);
|
|
14063
|
+
if (owners.length !== 1 || key(owners[0]) !== parentKey) {
|
|
14064
|
+
return { state: "ambiguous_parent", parentKey };
|
|
14065
|
+
}
|
|
14066
|
+
return { state: "linked", parentKey, replyTo: { wire_id: wireId } };
|
|
14067
|
+
}
|
|
14068
|
+
var key, nonempty;
|
|
14069
|
+
var init_reply_threading = __esm({
|
|
14070
|
+
"src/reply-threading.ts"() {
|
|
14071
|
+
"use strict";
|
|
14072
|
+
key = (r) => r.message_id === void 0 === (r.file_id === void 0) ? void 0 : r.message_id === void 0 ? `file:${r.file_id}` : `message:${r.message_id}`;
|
|
14073
|
+
nonempty = (value) => typeof value === "string" && value.length > 0;
|
|
14074
|
+
}
|
|
14075
|
+
});
|
|
14076
|
+
|
|
14013
14077
|
// src/intake.ts
|
|
14014
14078
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
14015
14079
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -14018,8 +14082,8 @@ function canonicalJson(value) {
|
|
|
14018
14082
|
if (encoded === void 0) throw new TypeError("canonical JSON value is not serializable");
|
|
14019
14083
|
return encoded;
|
|
14020
14084
|
}
|
|
14021
|
-
async function sendRoomBody(packet, recipientIdentity, unsigned) {
|
|
14022
|
-
return packet.send(recipientIdentity, canonicalJson(unsigned));
|
|
14085
|
+
async function sendRoomBody(packet, recipientIdentity, unsigned, replyTo) {
|
|
14086
|
+
return packet.send(recipientIdentity, canonicalJson(unsigned), replyTo);
|
|
14023
14087
|
}
|
|
14024
14088
|
function sameReply2(stored, observed) {
|
|
14025
14089
|
if (stored === void 0 || observed == null) return stored === void 0 && observed == null;
|
|
@@ -14044,8 +14108,8 @@ function canonicalValue(value) {
|
|
|
14044
14108
|
if (value !== null && typeof value === "object") {
|
|
14045
14109
|
const input = value;
|
|
14046
14110
|
const output = {};
|
|
14047
|
-
for (const
|
|
14048
|
-
if (input[
|
|
14111
|
+
for (const key2 of Object.keys(input).sort()) {
|
|
14112
|
+
if (input[key2] !== void 0) output[key2] = canonicalValue(input[key2]);
|
|
14049
14113
|
}
|
|
14050
14114
|
return output;
|
|
14051
14115
|
}
|
|
@@ -14073,6 +14137,7 @@ var init_intake = __esm({
|
|
|
14073
14137
|
init_zod();
|
|
14074
14138
|
init_contracts();
|
|
14075
14139
|
init_ulid();
|
|
14140
|
+
init_reply_threading();
|
|
14076
14141
|
JOURNAL_WORK_BATCH_SIZE = 64;
|
|
14077
14142
|
INTAKE_BATCH_SIZE = 32;
|
|
14078
14143
|
IntakePump = class {
|
|
@@ -14445,6 +14510,10 @@ var init_intake = __esm({
|
|
|
14445
14510
|
if (skipped.kind !== "relay_result") throw new Error("storage returned the wrong relay result kind");
|
|
14446
14511
|
continue;
|
|
14447
14512
|
}
|
|
14513
|
+
const source = message ?? file;
|
|
14514
|
+
const replyRows = source.source_reply_to === void 0 ? [] : await readReplyRows(this.store, roomId);
|
|
14515
|
+
const decision = selectReply(replyRows, roomId, source, intent.recipient_identity);
|
|
14516
|
+
const replyTo = decision.replyTo;
|
|
14448
14517
|
if (file !== void 0) {
|
|
14449
14518
|
const uploader = file.author_alias?.alias ?? file.author.display_name;
|
|
14450
14519
|
const notice = await sendRoomBody(packet, intent.recipient_identity, {
|
|
@@ -14460,7 +14529,7 @@ var init_intake = __esm({
|
|
|
14460
14529
|
},
|
|
14461
14530
|
text: `${uploader} sent a file`,
|
|
14462
14531
|
at: file.at
|
|
14463
|
-
});
|
|
14532
|
+
}, replyTo);
|
|
14464
14533
|
if (notice.status === "send_failed") {
|
|
14465
14534
|
const failed = await this.store.append(roomId, {
|
|
14466
14535
|
version: 1,
|
|
@@ -14479,7 +14548,8 @@ var init_intake = __esm({
|
|
|
14479
14548
|
intent.recipient_identity,
|
|
14480
14549
|
file.filename,
|
|
14481
14550
|
file.mime,
|
|
14482
|
-
Buffer.from(file.data_base64, "base64")
|
|
14551
|
+
Buffer.from(file.data_base64, "base64"),
|
|
14552
|
+
replyTo
|
|
14483
14553
|
);
|
|
14484
14554
|
const appended2 = await this.store.append(roomId, {
|
|
14485
14555
|
version: 1,
|
|
@@ -14514,7 +14584,7 @@ var init_intake = __esm({
|
|
|
14514
14584
|
...message.briefing_version === void 0 ? {} : { briefing_version: message.briefing_version },
|
|
14515
14585
|
...message.membership === void 0 ? {} : { membership: message.membership }
|
|
14516
14586
|
};
|
|
14517
|
-
const outcome = await sendRoomBody(packet, intent.recipient_identity, unsigned);
|
|
14587
|
+
const outcome = await sendRoomBody(packet, intent.recipient_identity, unsigned, replyTo);
|
|
14518
14588
|
const appended = await this.store.append(roomId, {
|
|
14519
14589
|
version: 1,
|
|
14520
14590
|
kind: "relay_result",
|
|
@@ -15868,6 +15938,7 @@ var init_service = __esm({
|
|
|
15868
15938
|
recipient_identities: _recipients,
|
|
15869
15939
|
source_msg_id: _sourceMsg,
|
|
15870
15940
|
source_wire_id: _sourceWire,
|
|
15941
|
+
source_reply_to: _sourceReplyTo,
|
|
15871
15942
|
...rest
|
|
15872
15943
|
} = record;
|
|
15873
15944
|
return {
|
|
@@ -16729,7 +16800,7 @@ var init_storage = __esm({
|
|
|
16729
16800
|
"SELECT recipient_identity FROM relay_intent_work WHERE record_seq = ? ORDER BY recipient_identity LIMIT ?"
|
|
16730
16801
|
).all(recordSeq, limit).map((row) => row.recipient_identity)));
|
|
16731
16802
|
}
|
|
16732
|
-
async briefingDeliveryTimes(roomId,
|
|
16803
|
+
async briefingDeliveryTimes(roomId, key2, recipientIdentities) {
|
|
16733
16804
|
const id = this.roomId(roomId);
|
|
16734
16805
|
if (recipientIdentities.length === 0) return /* @__PURE__ */ new Map();
|
|
16735
16806
|
return this.mutex(id, () => this.withDatabase(id, (db) => {
|
|
@@ -16743,9 +16814,9 @@ var init_storage = __esm({
|
|
|
16743
16814
|
for (const recipient of recipientIdentities) {
|
|
16744
16815
|
const row = lookup.get(
|
|
16745
16816
|
recipient,
|
|
16746
|
-
|
|
16747
|
-
|
|
16748
|
-
|
|
16817
|
+
key2.category,
|
|
16818
|
+
key2.briefingRole ?? null,
|
|
16819
|
+
key2.briefingVersion
|
|
16749
16820
|
);
|
|
16750
16821
|
if (row) deliveries.set(recipient, row.at);
|
|
16751
16822
|
}
|
|
@@ -18052,7 +18123,7 @@ function isIntakeNotification(event) {
|
|
|
18052
18123
|
function createDaemonControlRoutes(control) {
|
|
18053
18124
|
if (!/^[0-9a-f]{32}$/.test(control.session)) throw new TypeError("invalid daemon control session");
|
|
18054
18125
|
const requireExact = (params2, keys) => {
|
|
18055
|
-
if (Object.keys(params2).length !== keys.length || keys.some((
|
|
18126
|
+
if (Object.keys(params2).length !== keys.length || keys.some((key2) => !Object.hasOwn(params2, key2))) {
|
|
18056
18127
|
throw new TypeError("invalid daemon control parameters");
|
|
18057
18128
|
}
|
|
18058
18129
|
};
|
|
@@ -56,6 +56,14 @@ In an anonymous room, the notice text names only the room-scoped alias; it inclu
|
|
|
56
56
|
|
|
57
57
|
Cowork history records include messages, files, and the durable relay intent/result trail used for restart recovery. This application archive is distinct from the shared daemon's per-identity `history.sqlite3` and immutable blob store; neither is a substitute backup for the other.
|
|
58
58
|
|
|
59
|
+
## Reply threading
|
|
60
|
+
|
|
61
|
+
A reply is broadcast to the other active room participants, with no sender echo. The parent author receives a reference to their original source message or file; other participants receive a reference to their own recorded room copy. Multiple recorded copies remain aliases of one logical original. For files, both the metadata notice and binary copy can identify that original.
|
|
62
|
+
|
|
63
|
+
Cowork derives these relationships from its existing archive. If a parent or a recipient's copy cannot be resolved, it delivers the answer without a transport parent and retains the incoming source reference. It does not replay history or scan SDK history to repair links. Queued records do not guarantee that a recipient still has the parent, and a wire lost before result persistence can remain unresolved. Existing retry behavior can create distinct transport copies.
|
|
64
|
+
|
|
65
|
+
Reply translation changes transport metadata only. Room JSON bodies and version-one archive formats remain unchanged; incoming sentence references are retained but translated outgoing references use only the selected wire ID. Existing history views retain their logical-record/audit separation; reading history does not send messages. Ordinary clients can use their existing native reply handling without implementing Cowork mapping logic.
|
|
66
|
+
|
|
59
67
|
The web console projects participant and room-authored messages plus the briefing into Communication. Relay, file, recovery, close, and failure records are excluded from chat and shown in Events; Archive retains the complete ordered record stream, including archived file bytes. Messages appear only after the authoritative history refresh observes them.
|
|
60
68
|
|
|
61
69
|
Version one polls rather than receiving pushed updates: the room list refreshes every five seconds, while the selected room, participants, and history refresh every two seconds. Polling pauses in a hidden tab, coalesces overlap, and refreshes after confirmed mutations. CLI history remains the fallback when a browser is unavailable.
|