@ours.network/cowork 0.3.6 → 0.4.0
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
CHANGED
|
@@ -861,8 +861,8 @@ var init_parseUtil = __esm({
|
|
|
861
861
|
"node_modules/zod/v3/helpers/parseUtil.js"() {
|
|
862
862
|
init_errors();
|
|
863
863
|
init_en();
|
|
864
|
-
makeIssue = (
|
|
865
|
-
const { data, path, errorMaps, issueData } =
|
|
864
|
+
makeIssue = (params2) => {
|
|
865
|
+
const { data, path, errorMaps, issueData } = params2;
|
|
866
866
|
const fullPath = [...path, ...issueData.path || []];
|
|
867
867
|
const fullIssue = {
|
|
868
868
|
...issueData,
|
|
@@ -971,17 +971,17 @@ var init_errorUtil = __esm({
|
|
|
971
971
|
});
|
|
972
972
|
|
|
973
973
|
// node_modules/zod/v3/types.js
|
|
974
|
-
function processCreateParams(
|
|
975
|
-
if (!
|
|
974
|
+
function processCreateParams(params2) {
|
|
975
|
+
if (!params2)
|
|
976
976
|
return {};
|
|
977
|
-
const { errorMap: errorMap2, invalid_type_error, required_error, description } =
|
|
977
|
+
const { errorMap: errorMap2, invalid_type_error, required_error, description } = params2;
|
|
978
978
|
if (errorMap2 && (invalid_type_error || required_error)) {
|
|
979
979
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
980
980
|
}
|
|
981
981
|
if (errorMap2)
|
|
982
982
|
return { errorMap: errorMap2, description };
|
|
983
983
|
const customMap = (iss, ctx) => {
|
|
984
|
-
const { message } =
|
|
984
|
+
const { message } = params2;
|
|
985
985
|
if (iss.code === "invalid_enum_value") {
|
|
986
986
|
return { message: message ?? ctx.defaultError };
|
|
987
987
|
}
|
|
@@ -1128,15 +1128,15 @@ function mergeValues(a, b) {
|
|
|
1128
1128
|
return { valid: false };
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
function createZodEnum(values,
|
|
1131
|
+
function createZodEnum(values, params2) {
|
|
1132
1132
|
return new ZodEnum({
|
|
1133
1133
|
values,
|
|
1134
1134
|
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
1135
|
-
...processCreateParams(
|
|
1135
|
+
...processCreateParams(params2)
|
|
1136
1136
|
});
|
|
1137
1137
|
}
|
|
1138
|
-
function cleanParams(
|
|
1139
|
-
const p = typeof
|
|
1138
|
+
function cleanParams(params2, data) {
|
|
1139
|
+
const p = typeof params2 === "function" ? params2(data) : typeof params2 === "string" ? { message: params2 } : params2;
|
|
1140
1140
|
const p2 = typeof p === "string" ? { message: p } : p;
|
|
1141
1141
|
return p2;
|
|
1142
1142
|
}
|
|
@@ -1147,16 +1147,16 @@ function custom(check, _params = {}, fatal) {
|
|
|
1147
1147
|
if (r instanceof Promise) {
|
|
1148
1148
|
return r.then((r2) => {
|
|
1149
1149
|
if (!r2) {
|
|
1150
|
-
const
|
|
1151
|
-
const _fatal =
|
|
1152
|
-
ctx.addIssue({ code: "custom", ...
|
|
1150
|
+
const params2 = cleanParams(_params, data);
|
|
1151
|
+
const _fatal = params2.fatal ?? fatal ?? true;
|
|
1152
|
+
ctx.addIssue({ code: "custom", ...params2, fatal: _fatal });
|
|
1153
1153
|
}
|
|
1154
1154
|
});
|
|
1155
1155
|
}
|
|
1156
1156
|
if (!r) {
|
|
1157
|
-
const
|
|
1158
|
-
const _fatal =
|
|
1159
|
-
ctx.addIssue({ code: "custom", ...
|
|
1157
|
+
const params2 = cleanParams(_params, data);
|
|
1158
|
+
const _fatal = params2.fatal ?? fatal ?? true;
|
|
1159
|
+
ctx.addIssue({ code: "custom", ...params2, fatal: _fatal });
|
|
1160
1160
|
}
|
|
1161
1161
|
return;
|
|
1162
1162
|
});
|
|
@@ -1249,20 +1249,20 @@ var init_types = __esm({
|
|
|
1249
1249
|
const result = this._parse(input);
|
|
1250
1250
|
return Promise.resolve(result);
|
|
1251
1251
|
}
|
|
1252
|
-
parse(data,
|
|
1253
|
-
const result = this.safeParse(data,
|
|
1252
|
+
parse(data, params2) {
|
|
1253
|
+
const result = this.safeParse(data, params2);
|
|
1254
1254
|
if (result.success)
|
|
1255
1255
|
return result.data;
|
|
1256
1256
|
throw result.error;
|
|
1257
1257
|
}
|
|
1258
|
-
safeParse(data,
|
|
1258
|
+
safeParse(data, params2) {
|
|
1259
1259
|
const ctx = {
|
|
1260
1260
|
common: {
|
|
1261
1261
|
issues: [],
|
|
1262
|
-
async:
|
|
1263
|
-
contextualErrorMap:
|
|
1262
|
+
async: params2?.async ?? false,
|
|
1263
|
+
contextualErrorMap: params2?.errorMap
|
|
1264
1264
|
},
|
|
1265
|
-
path:
|
|
1265
|
+
path: params2?.path || [],
|
|
1266
1266
|
schemaErrorMap: this._def.errorMap,
|
|
1267
1267
|
parent: null,
|
|
1268
1268
|
data,
|
|
@@ -1307,20 +1307,20 @@ var init_types = __esm({
|
|
|
1307
1307
|
issues: ctx.common.issues
|
|
1308
1308
|
});
|
|
1309
1309
|
}
|
|
1310
|
-
async parseAsync(data,
|
|
1311
|
-
const result = await this.safeParseAsync(data,
|
|
1310
|
+
async parseAsync(data, params2) {
|
|
1311
|
+
const result = await this.safeParseAsync(data, params2);
|
|
1312
1312
|
if (result.success)
|
|
1313
1313
|
return result.data;
|
|
1314
1314
|
throw result.error;
|
|
1315
1315
|
}
|
|
1316
|
-
async safeParseAsync(data,
|
|
1316
|
+
async safeParseAsync(data, params2) {
|
|
1317
1317
|
const ctx = {
|
|
1318
1318
|
common: {
|
|
1319
1319
|
issues: [],
|
|
1320
|
-
contextualErrorMap:
|
|
1320
|
+
contextualErrorMap: params2?.errorMap,
|
|
1321
1321
|
async: true
|
|
1322
1322
|
},
|
|
1323
|
-
path:
|
|
1323
|
+
path: params2?.path || [],
|
|
1324
1324
|
schemaErrorMap: this._def.errorMap,
|
|
1325
1325
|
parent: null,
|
|
1326
1326
|
data,
|
|
@@ -2046,12 +2046,12 @@ var init_types = __esm({
|
|
|
2046
2046
|
return max;
|
|
2047
2047
|
}
|
|
2048
2048
|
};
|
|
2049
|
-
ZodString.create = (
|
|
2049
|
+
ZodString.create = (params2) => {
|
|
2050
2050
|
return new ZodString({
|
|
2051
2051
|
checks: [],
|
|
2052
2052
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
2053
|
-
coerce:
|
|
2054
|
-
...processCreateParams(
|
|
2053
|
+
coerce: params2?.coerce ?? false,
|
|
2054
|
+
...processCreateParams(params2)
|
|
2055
2055
|
});
|
|
2056
2056
|
};
|
|
2057
2057
|
ZodNumber = class _ZodNumber extends ZodType {
|
|
@@ -2278,12 +2278,12 @@ var init_types = __esm({
|
|
|
2278
2278
|
return Number.isFinite(min) && Number.isFinite(max);
|
|
2279
2279
|
}
|
|
2280
2280
|
};
|
|
2281
|
-
ZodNumber.create = (
|
|
2281
|
+
ZodNumber.create = (params2) => {
|
|
2282
2282
|
return new ZodNumber({
|
|
2283
2283
|
checks: [],
|
|
2284
2284
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
2285
|
-
coerce:
|
|
2286
|
-
...processCreateParams(
|
|
2285
|
+
coerce: params2?.coerce || false,
|
|
2286
|
+
...processCreateParams(params2)
|
|
2287
2287
|
});
|
|
2288
2288
|
};
|
|
2289
2289
|
ZodBigInt = class _ZodBigInt extends ZodType {
|
|
@@ -2450,12 +2450,12 @@ var init_types = __esm({
|
|
|
2450
2450
|
return max;
|
|
2451
2451
|
}
|
|
2452
2452
|
};
|
|
2453
|
-
ZodBigInt.create = (
|
|
2453
|
+
ZodBigInt.create = (params2) => {
|
|
2454
2454
|
return new ZodBigInt({
|
|
2455
2455
|
checks: [],
|
|
2456
2456
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
2457
|
-
coerce:
|
|
2458
|
-
...processCreateParams(
|
|
2457
|
+
coerce: params2?.coerce ?? false,
|
|
2458
|
+
...processCreateParams(params2)
|
|
2459
2459
|
});
|
|
2460
2460
|
};
|
|
2461
2461
|
ZodBoolean = class extends ZodType {
|
|
@@ -2476,11 +2476,11 @@ var init_types = __esm({
|
|
|
2476
2476
|
return OK(input.data);
|
|
2477
2477
|
}
|
|
2478
2478
|
};
|
|
2479
|
-
ZodBoolean.create = (
|
|
2479
|
+
ZodBoolean.create = (params2) => {
|
|
2480
2480
|
return new ZodBoolean({
|
|
2481
2481
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
2482
|
-
coerce:
|
|
2483
|
-
...processCreateParams(
|
|
2482
|
+
coerce: params2?.coerce || false,
|
|
2483
|
+
...processCreateParams(params2)
|
|
2484
2484
|
});
|
|
2485
2485
|
};
|
|
2486
2486
|
ZodDate = class _ZodDate extends ZodType {
|
|
@@ -2584,12 +2584,12 @@ var init_types = __esm({
|
|
|
2584
2584
|
return max != null ? new Date(max) : null;
|
|
2585
2585
|
}
|
|
2586
2586
|
};
|
|
2587
|
-
ZodDate.create = (
|
|
2587
|
+
ZodDate.create = (params2) => {
|
|
2588
2588
|
return new ZodDate({
|
|
2589
2589
|
checks: [],
|
|
2590
|
-
coerce:
|
|
2590
|
+
coerce: params2?.coerce || false,
|
|
2591
2591
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
2592
|
-
...processCreateParams(
|
|
2592
|
+
...processCreateParams(params2)
|
|
2593
2593
|
});
|
|
2594
2594
|
};
|
|
2595
2595
|
ZodSymbol = class extends ZodType {
|
|
@@ -2607,10 +2607,10 @@ var init_types = __esm({
|
|
|
2607
2607
|
return OK(input.data);
|
|
2608
2608
|
}
|
|
2609
2609
|
};
|
|
2610
|
-
ZodSymbol.create = (
|
|
2610
|
+
ZodSymbol.create = (params2) => {
|
|
2611
2611
|
return new ZodSymbol({
|
|
2612
2612
|
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
2613
|
-
...processCreateParams(
|
|
2613
|
+
...processCreateParams(params2)
|
|
2614
2614
|
});
|
|
2615
2615
|
};
|
|
2616
2616
|
ZodUndefined = class extends ZodType {
|
|
@@ -2628,10 +2628,10 @@ var init_types = __esm({
|
|
|
2628
2628
|
return OK(input.data);
|
|
2629
2629
|
}
|
|
2630
2630
|
};
|
|
2631
|
-
ZodUndefined.create = (
|
|
2631
|
+
ZodUndefined.create = (params2) => {
|
|
2632
2632
|
return new ZodUndefined({
|
|
2633
2633
|
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
2634
|
-
...processCreateParams(
|
|
2634
|
+
...processCreateParams(params2)
|
|
2635
2635
|
});
|
|
2636
2636
|
};
|
|
2637
2637
|
ZodNull = class extends ZodType {
|
|
@@ -2649,10 +2649,10 @@ var init_types = __esm({
|
|
|
2649
2649
|
return OK(input.data);
|
|
2650
2650
|
}
|
|
2651
2651
|
};
|
|
2652
|
-
ZodNull.create = (
|
|
2652
|
+
ZodNull.create = (params2) => {
|
|
2653
2653
|
return new ZodNull({
|
|
2654
2654
|
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
2655
|
-
...processCreateParams(
|
|
2655
|
+
...processCreateParams(params2)
|
|
2656
2656
|
});
|
|
2657
2657
|
};
|
|
2658
2658
|
ZodAny = class extends ZodType {
|
|
@@ -2664,10 +2664,10 @@ var init_types = __esm({
|
|
|
2664
2664
|
return OK(input.data);
|
|
2665
2665
|
}
|
|
2666
2666
|
};
|
|
2667
|
-
ZodAny.create = (
|
|
2667
|
+
ZodAny.create = (params2) => {
|
|
2668
2668
|
return new ZodAny({
|
|
2669
2669
|
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
2670
|
-
...processCreateParams(
|
|
2670
|
+
...processCreateParams(params2)
|
|
2671
2671
|
});
|
|
2672
2672
|
};
|
|
2673
2673
|
ZodUnknown = class extends ZodType {
|
|
@@ -2679,10 +2679,10 @@ var init_types = __esm({
|
|
|
2679
2679
|
return OK(input.data);
|
|
2680
2680
|
}
|
|
2681
2681
|
};
|
|
2682
|
-
ZodUnknown.create = (
|
|
2682
|
+
ZodUnknown.create = (params2) => {
|
|
2683
2683
|
return new ZodUnknown({
|
|
2684
2684
|
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
2685
|
-
...processCreateParams(
|
|
2685
|
+
...processCreateParams(params2)
|
|
2686
2686
|
});
|
|
2687
2687
|
};
|
|
2688
2688
|
ZodNever = class extends ZodType {
|
|
@@ -2696,10 +2696,10 @@ var init_types = __esm({
|
|
|
2696
2696
|
return INVALID;
|
|
2697
2697
|
}
|
|
2698
2698
|
};
|
|
2699
|
-
ZodNever.create = (
|
|
2699
|
+
ZodNever.create = (params2) => {
|
|
2700
2700
|
return new ZodNever({
|
|
2701
2701
|
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
2702
|
-
...processCreateParams(
|
|
2702
|
+
...processCreateParams(params2)
|
|
2703
2703
|
});
|
|
2704
2704
|
};
|
|
2705
2705
|
ZodVoid = class extends ZodType {
|
|
@@ -2717,10 +2717,10 @@ var init_types = __esm({
|
|
|
2717
2717
|
return OK(input.data);
|
|
2718
2718
|
}
|
|
2719
2719
|
};
|
|
2720
|
-
ZodVoid.create = (
|
|
2720
|
+
ZodVoid.create = (params2) => {
|
|
2721
2721
|
return new ZodVoid({
|
|
2722
2722
|
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
2723
|
-
...processCreateParams(
|
|
2723
|
+
...processCreateParams(params2)
|
|
2724
2724
|
});
|
|
2725
2725
|
};
|
|
2726
2726
|
ZodArray = class _ZodArray extends ZodType {
|
|
@@ -2814,14 +2814,14 @@ var init_types = __esm({
|
|
|
2814
2814
|
return this.min(1, message);
|
|
2815
2815
|
}
|
|
2816
2816
|
};
|
|
2817
|
-
ZodArray.create = (schema,
|
|
2817
|
+
ZodArray.create = (schema, params2) => {
|
|
2818
2818
|
return new ZodArray({
|
|
2819
2819
|
type: schema,
|
|
2820
2820
|
minLength: null,
|
|
2821
2821
|
maxLength: null,
|
|
2822
2822
|
exactLength: null,
|
|
2823
2823
|
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
2824
|
-
...processCreateParams(
|
|
2824
|
+
...processCreateParams(params2)
|
|
2825
2825
|
});
|
|
2826
2826
|
};
|
|
2827
2827
|
ZodObject = class _ZodObject extends ZodType {
|
|
@@ -3135,31 +3135,31 @@ var init_types = __esm({
|
|
|
3135
3135
|
return createZodEnum(util.objectKeys(this.shape));
|
|
3136
3136
|
}
|
|
3137
3137
|
};
|
|
3138
|
-
ZodObject.create = (shape,
|
|
3138
|
+
ZodObject.create = (shape, params2) => {
|
|
3139
3139
|
return new ZodObject({
|
|
3140
3140
|
shape: () => shape,
|
|
3141
3141
|
unknownKeys: "strip",
|
|
3142
3142
|
catchall: ZodNever.create(),
|
|
3143
3143
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3144
|
-
...processCreateParams(
|
|
3144
|
+
...processCreateParams(params2)
|
|
3145
3145
|
});
|
|
3146
3146
|
};
|
|
3147
|
-
ZodObject.strictCreate = (shape,
|
|
3147
|
+
ZodObject.strictCreate = (shape, params2) => {
|
|
3148
3148
|
return new ZodObject({
|
|
3149
3149
|
shape: () => shape,
|
|
3150
3150
|
unknownKeys: "strict",
|
|
3151
3151
|
catchall: ZodNever.create(),
|
|
3152
3152
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3153
|
-
...processCreateParams(
|
|
3153
|
+
...processCreateParams(params2)
|
|
3154
3154
|
});
|
|
3155
3155
|
};
|
|
3156
|
-
ZodObject.lazycreate = (shape,
|
|
3156
|
+
ZodObject.lazycreate = (shape, params2) => {
|
|
3157
3157
|
return new ZodObject({
|
|
3158
3158
|
shape,
|
|
3159
3159
|
unknownKeys: "strip",
|
|
3160
3160
|
catchall: ZodNever.create(),
|
|
3161
3161
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3162
|
-
...processCreateParams(
|
|
3162
|
+
...processCreateParams(params2)
|
|
3163
3163
|
});
|
|
3164
3164
|
};
|
|
3165
3165
|
ZodUnion = class extends ZodType {
|
|
@@ -3246,11 +3246,11 @@ var init_types = __esm({
|
|
|
3246
3246
|
return this._def.options;
|
|
3247
3247
|
}
|
|
3248
3248
|
};
|
|
3249
|
-
ZodUnion.create = (types,
|
|
3249
|
+
ZodUnion.create = (types, params2) => {
|
|
3250
3250
|
return new ZodUnion({
|
|
3251
3251
|
options: types,
|
|
3252
3252
|
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
3253
|
-
...processCreateParams(
|
|
3253
|
+
...processCreateParams(params2)
|
|
3254
3254
|
});
|
|
3255
3255
|
};
|
|
3256
3256
|
getDiscriminator = (type) => {
|
|
@@ -3337,7 +3337,7 @@ var init_types = __esm({
|
|
|
3337
3337
|
* @param types an array of object schemas
|
|
3338
3338
|
* @param params
|
|
3339
3339
|
*/
|
|
3340
|
-
static create(discriminator, options,
|
|
3340
|
+
static create(discriminator, options, params2) {
|
|
3341
3341
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
3342
3342
|
for (const type of options) {
|
|
3343
3343
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
@@ -3356,7 +3356,7 @@ var init_types = __esm({
|
|
|
3356
3356
|
discriminator,
|
|
3357
3357
|
options,
|
|
3358
3358
|
optionsMap,
|
|
3359
|
-
...processCreateParams(
|
|
3359
|
+
...processCreateParams(params2)
|
|
3360
3360
|
});
|
|
3361
3361
|
}
|
|
3362
3362
|
};
|
|
@@ -3405,12 +3405,12 @@ var init_types = __esm({
|
|
|
3405
3405
|
}
|
|
3406
3406
|
}
|
|
3407
3407
|
};
|
|
3408
|
-
ZodIntersection.create = (left, right,
|
|
3408
|
+
ZodIntersection.create = (left, right, params2) => {
|
|
3409
3409
|
return new ZodIntersection({
|
|
3410
3410
|
left,
|
|
3411
3411
|
right,
|
|
3412
3412
|
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
3413
|
-
...processCreateParams(
|
|
3413
|
+
...processCreateParams(params2)
|
|
3414
3414
|
});
|
|
3415
3415
|
};
|
|
3416
3416
|
ZodTuple = class _ZodTuple extends ZodType {
|
|
@@ -3469,7 +3469,7 @@ var init_types = __esm({
|
|
|
3469
3469
|
});
|
|
3470
3470
|
}
|
|
3471
3471
|
};
|
|
3472
|
-
ZodTuple.create = (schemas,
|
|
3472
|
+
ZodTuple.create = (schemas, params2) => {
|
|
3473
3473
|
if (!Array.isArray(schemas)) {
|
|
3474
3474
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
3475
3475
|
}
|
|
@@ -3477,7 +3477,7 @@ var init_types = __esm({
|
|
|
3477
3477
|
items: schemas,
|
|
3478
3478
|
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
3479
3479
|
rest: null,
|
|
3480
|
-
...processCreateParams(
|
|
3480
|
+
...processCreateParams(params2)
|
|
3481
3481
|
});
|
|
3482
3482
|
};
|
|
3483
3483
|
ZodRecord = class _ZodRecord extends ZodType {
|
|
@@ -3591,12 +3591,12 @@ var init_types = __esm({
|
|
|
3591
3591
|
}
|
|
3592
3592
|
}
|
|
3593
3593
|
};
|
|
3594
|
-
ZodMap.create = (keyType, valueType,
|
|
3594
|
+
ZodMap.create = (keyType, valueType, params2) => {
|
|
3595
3595
|
return new ZodMap({
|
|
3596
3596
|
valueType,
|
|
3597
3597
|
keyType,
|
|
3598
3598
|
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
3599
|
-
...processCreateParams(
|
|
3599
|
+
...processCreateParams(params2)
|
|
3600
3600
|
});
|
|
3601
3601
|
};
|
|
3602
3602
|
ZodSet = class _ZodSet extends ZodType {
|
|
@@ -3675,13 +3675,13 @@ var init_types = __esm({
|
|
|
3675
3675
|
return this.min(1, message);
|
|
3676
3676
|
}
|
|
3677
3677
|
};
|
|
3678
|
-
ZodSet.create = (valueType,
|
|
3678
|
+
ZodSet.create = (valueType, params2) => {
|
|
3679
3679
|
return new ZodSet({
|
|
3680
3680
|
valueType,
|
|
3681
3681
|
minSize: null,
|
|
3682
3682
|
maxSize: null,
|
|
3683
3683
|
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
3684
|
-
...processCreateParams(
|
|
3684
|
+
...processCreateParams(params2)
|
|
3685
3685
|
});
|
|
3686
3686
|
};
|
|
3687
3687
|
ZodFunction = class _ZodFunction extends ZodType {
|
|
@@ -3721,18 +3721,18 @@ var init_types = __esm({
|
|
|
3721
3721
|
}
|
|
3722
3722
|
});
|
|
3723
3723
|
}
|
|
3724
|
-
const
|
|
3724
|
+
const params2 = { errorMap: ctx.common.contextualErrorMap };
|
|
3725
3725
|
const fn = ctx.data;
|
|
3726
3726
|
if (this._def.returns instanceof ZodPromise) {
|
|
3727
3727
|
const me = this;
|
|
3728
3728
|
return OK(async function(...args) {
|
|
3729
3729
|
const error = new ZodError([]);
|
|
3730
|
-
const parsedArgs = await me._def.args.parseAsync(args,
|
|
3730
|
+
const parsedArgs = await me._def.args.parseAsync(args, params2).catch((e) => {
|
|
3731
3731
|
error.addIssue(makeArgsIssue(args, e));
|
|
3732
3732
|
throw error;
|
|
3733
3733
|
});
|
|
3734
3734
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3735
|
-
const parsedReturns = await me._def.returns._def.type.parseAsync(result,
|
|
3735
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params2).catch((e) => {
|
|
3736
3736
|
error.addIssue(makeReturnsIssue(result, e));
|
|
3737
3737
|
throw error;
|
|
3738
3738
|
});
|
|
@@ -3741,12 +3741,12 @@ var init_types = __esm({
|
|
|
3741
3741
|
} else {
|
|
3742
3742
|
const me = this;
|
|
3743
3743
|
return OK(function(...args) {
|
|
3744
|
-
const parsedArgs = me._def.args.safeParse(args,
|
|
3744
|
+
const parsedArgs = me._def.args.safeParse(args, params2);
|
|
3745
3745
|
if (!parsedArgs.success) {
|
|
3746
3746
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3747
3747
|
}
|
|
3748
3748
|
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3749
|
-
const parsedReturns = me._def.returns.safeParse(result,
|
|
3749
|
+
const parsedReturns = me._def.returns.safeParse(result, params2);
|
|
3750
3750
|
if (!parsedReturns.success) {
|
|
3751
3751
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3752
3752
|
}
|
|
@@ -3780,12 +3780,12 @@ var init_types = __esm({
|
|
|
3780
3780
|
const validatedFunc = this.parse(func);
|
|
3781
3781
|
return validatedFunc;
|
|
3782
3782
|
}
|
|
3783
|
-
static create(args, returns,
|
|
3783
|
+
static create(args, returns, params2) {
|
|
3784
3784
|
return new _ZodFunction({
|
|
3785
3785
|
args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
3786
3786
|
returns: returns || ZodUnknown.create(),
|
|
3787
3787
|
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
3788
|
-
...processCreateParams(
|
|
3788
|
+
...processCreateParams(params2)
|
|
3789
3789
|
});
|
|
3790
3790
|
}
|
|
3791
3791
|
};
|
|
@@ -3799,11 +3799,11 @@ var init_types = __esm({
|
|
|
3799
3799
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3800
3800
|
}
|
|
3801
3801
|
};
|
|
3802
|
-
ZodLazy.create = (getter,
|
|
3802
|
+
ZodLazy.create = (getter, params2) => {
|
|
3803
3803
|
return new ZodLazy({
|
|
3804
3804
|
getter,
|
|
3805
3805
|
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
3806
|
-
...processCreateParams(
|
|
3806
|
+
...processCreateParams(params2)
|
|
3807
3807
|
});
|
|
3808
3808
|
};
|
|
3809
3809
|
ZodLiteral = class extends ZodType {
|
|
@@ -3823,11 +3823,11 @@ var init_types = __esm({
|
|
|
3823
3823
|
return this._def.value;
|
|
3824
3824
|
}
|
|
3825
3825
|
};
|
|
3826
|
-
ZodLiteral.create = (value,
|
|
3826
|
+
ZodLiteral.create = (value, params2) => {
|
|
3827
3827
|
return new ZodLiteral({
|
|
3828
3828
|
value,
|
|
3829
3829
|
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
3830
|
-
...processCreateParams(
|
|
3830
|
+
...processCreateParams(params2)
|
|
3831
3831
|
});
|
|
3832
3832
|
};
|
|
3833
3833
|
ZodEnum = class _ZodEnum extends ZodType {
|
|
@@ -3926,11 +3926,11 @@ var init_types = __esm({
|
|
|
3926
3926
|
return this._def.values;
|
|
3927
3927
|
}
|
|
3928
3928
|
};
|
|
3929
|
-
ZodNativeEnum.create = (values,
|
|
3929
|
+
ZodNativeEnum.create = (values, params2) => {
|
|
3930
3930
|
return new ZodNativeEnum({
|
|
3931
3931
|
values,
|
|
3932
3932
|
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
3933
|
-
...processCreateParams(
|
|
3933
|
+
...processCreateParams(params2)
|
|
3934
3934
|
});
|
|
3935
3935
|
};
|
|
3936
3936
|
ZodPromise = class extends ZodType {
|
|
@@ -3956,11 +3956,11 @@ var init_types = __esm({
|
|
|
3956
3956
|
}));
|
|
3957
3957
|
}
|
|
3958
3958
|
};
|
|
3959
|
-
ZodPromise.create = (schema,
|
|
3959
|
+
ZodPromise.create = (schema, params2) => {
|
|
3960
3960
|
return new ZodPromise({
|
|
3961
3961
|
type: schema,
|
|
3962
3962
|
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
3963
|
-
...processCreateParams(
|
|
3963
|
+
...processCreateParams(params2)
|
|
3964
3964
|
});
|
|
3965
3965
|
};
|
|
3966
3966
|
ZodEffects = class extends ZodType {
|
|
@@ -4086,20 +4086,20 @@ var init_types = __esm({
|
|
|
4086
4086
|
util.assertNever(effect);
|
|
4087
4087
|
}
|
|
4088
4088
|
};
|
|
4089
|
-
ZodEffects.create = (schema, effect,
|
|
4089
|
+
ZodEffects.create = (schema, effect, params2) => {
|
|
4090
4090
|
return new ZodEffects({
|
|
4091
4091
|
schema,
|
|
4092
4092
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
4093
4093
|
effect,
|
|
4094
|
-
...processCreateParams(
|
|
4094
|
+
...processCreateParams(params2)
|
|
4095
4095
|
});
|
|
4096
4096
|
};
|
|
4097
|
-
ZodEffects.createWithPreprocess = (preprocess, schema,
|
|
4097
|
+
ZodEffects.createWithPreprocess = (preprocess, schema, params2) => {
|
|
4098
4098
|
return new ZodEffects({
|
|
4099
4099
|
schema,
|
|
4100
4100
|
effect: { type: "preprocess", transform: preprocess },
|
|
4101
4101
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
4102
|
-
...processCreateParams(
|
|
4102
|
+
...processCreateParams(params2)
|
|
4103
4103
|
});
|
|
4104
4104
|
};
|
|
4105
4105
|
ZodOptional = class extends ZodType {
|
|
@@ -4114,11 +4114,11 @@ var init_types = __esm({
|
|
|
4114
4114
|
return this._def.innerType;
|
|
4115
4115
|
}
|
|
4116
4116
|
};
|
|
4117
|
-
ZodOptional.create = (type,
|
|
4117
|
+
ZodOptional.create = (type, params2) => {
|
|
4118
4118
|
return new ZodOptional({
|
|
4119
4119
|
innerType: type,
|
|
4120
4120
|
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
4121
|
-
...processCreateParams(
|
|
4121
|
+
...processCreateParams(params2)
|
|
4122
4122
|
});
|
|
4123
4123
|
};
|
|
4124
4124
|
ZodNullable = class extends ZodType {
|
|
@@ -4133,11 +4133,11 @@ var init_types = __esm({
|
|
|
4133
4133
|
return this._def.innerType;
|
|
4134
4134
|
}
|
|
4135
4135
|
};
|
|
4136
|
-
ZodNullable.create = (type,
|
|
4136
|
+
ZodNullable.create = (type, params2) => {
|
|
4137
4137
|
return new ZodNullable({
|
|
4138
4138
|
innerType: type,
|
|
4139
4139
|
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
4140
|
-
...processCreateParams(
|
|
4140
|
+
...processCreateParams(params2)
|
|
4141
4141
|
});
|
|
4142
4142
|
};
|
|
4143
4143
|
ZodDefault = class extends ZodType {
|
|
@@ -4157,12 +4157,12 @@ var init_types = __esm({
|
|
|
4157
4157
|
return this._def.innerType;
|
|
4158
4158
|
}
|
|
4159
4159
|
};
|
|
4160
|
-
ZodDefault.create = (type,
|
|
4160
|
+
ZodDefault.create = (type, params2) => {
|
|
4161
4161
|
return new ZodDefault({
|
|
4162
4162
|
innerType: type,
|
|
4163
4163
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
4164
|
-
defaultValue: typeof
|
|
4165
|
-
...processCreateParams(
|
|
4164
|
+
defaultValue: typeof params2.default === "function" ? params2.default : () => params2.default,
|
|
4165
|
+
...processCreateParams(params2)
|
|
4166
4166
|
});
|
|
4167
4167
|
};
|
|
4168
4168
|
ZodCatch = class extends ZodType {
|
|
@@ -4210,12 +4210,12 @@ var init_types = __esm({
|
|
|
4210
4210
|
return this._def.innerType;
|
|
4211
4211
|
}
|
|
4212
4212
|
};
|
|
4213
|
-
ZodCatch.create = (type,
|
|
4213
|
+
ZodCatch.create = (type, params2) => {
|
|
4214
4214
|
return new ZodCatch({
|
|
4215
4215
|
innerType: type,
|
|
4216
4216
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
4217
|
-
catchValue: typeof
|
|
4218
|
-
...processCreateParams(
|
|
4217
|
+
catchValue: typeof params2.catch === "function" ? params2.catch : () => params2.catch,
|
|
4218
|
+
...processCreateParams(params2)
|
|
4219
4219
|
});
|
|
4220
4220
|
};
|
|
4221
4221
|
ZodNaN = class extends ZodType {
|
|
@@ -4233,10 +4233,10 @@ var init_types = __esm({
|
|
|
4233
4233
|
return { status: "valid", value: input.data };
|
|
4234
4234
|
}
|
|
4235
4235
|
};
|
|
4236
|
-
ZodNaN.create = (
|
|
4236
|
+
ZodNaN.create = (params2) => {
|
|
4237
4237
|
return new ZodNaN({
|
|
4238
4238
|
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
4239
|
-
...processCreateParams(
|
|
4239
|
+
...processCreateParams(params2)
|
|
4240
4240
|
});
|
|
4241
4241
|
};
|
|
4242
4242
|
BRAND = Symbol("zod_brand");
|
|
@@ -4324,11 +4324,11 @@ var init_types = __esm({
|
|
|
4324
4324
|
return this._def.innerType;
|
|
4325
4325
|
}
|
|
4326
4326
|
};
|
|
4327
|
-
ZodReadonly.create = (type,
|
|
4327
|
+
ZodReadonly.create = (type, params2) => {
|
|
4328
4328
|
return new ZodReadonly({
|
|
4329
4329
|
innerType: type,
|
|
4330
4330
|
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
4331
|
-
...processCreateParams(
|
|
4331
|
+
...processCreateParams(params2)
|
|
4332
4332
|
});
|
|
4333
4333
|
};
|
|
4334
4334
|
late = {
|
|
@@ -4372,9 +4372,9 @@ var init_types = __esm({
|
|
|
4372
4372
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
4373
4373
|
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
4374
4374
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
4375
|
-
instanceOfType = (cls,
|
|
4375
|
+
instanceOfType = (cls, params2 = {
|
|
4376
4376
|
message: `Input not instance of ${cls.name}`
|
|
4377
|
-
}) => custom((data) => data instanceof cls,
|
|
4377
|
+
}) => custom((data) => data instanceof cls, params2);
|
|
4378
4378
|
stringType = ZodString.create;
|
|
4379
4379
|
numberType = ZodNumber.create;
|
|
4380
4380
|
nanType = ZodNaN.create;
|
|
@@ -8611,6 +8611,716 @@ var init_storage = __esm({
|
|
|
8611
8611
|
}
|
|
8612
8612
|
});
|
|
8613
8613
|
|
|
8614
|
+
// src/openapi.ts
|
|
8615
|
+
function params(properties, required) {
|
|
8616
|
+
return { type: "object", additionalProperties: false, properties, required: [...required] };
|
|
8617
|
+
}
|
|
8618
|
+
function schemaBaseName(method) {
|
|
8619
|
+
return method.split(".").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
8620
|
+
}
|
|
8621
|
+
function errorResponseSpec(description, codes) {
|
|
8622
|
+
return {
|
|
8623
|
+
description,
|
|
8624
|
+
content: {
|
|
8625
|
+
"application/json": {
|
|
8626
|
+
schema: { $ref: "#/components/schemas/RpcErrorResponse" },
|
|
8627
|
+
example: {
|
|
8628
|
+
version: 1,
|
|
8629
|
+
id: "req-1",
|
|
8630
|
+
error: { code: codes[0], message: "see the daemon response for detail" }
|
|
8631
|
+
}
|
|
8632
|
+
}
|
|
8633
|
+
}
|
|
8634
|
+
};
|
|
8635
|
+
}
|
|
8636
|
+
function documentResponseSpec(description, mediaType) {
|
|
8637
|
+
return { description, content: { [mediaType]: { schema: { type: "string" } } } };
|
|
8638
|
+
}
|
|
8639
|
+
function buildOpenApiDocument() {
|
|
8640
|
+
const schemas = {
|
|
8641
|
+
RpcId: {
|
|
8642
|
+
description: "Caller-chosen correlation id echoed in the response.",
|
|
8643
|
+
oneOf: [
|
|
8644
|
+
{ type: "string", minLength: 1, maxLength: 256 },
|
|
8645
|
+
{ type: "integer", minimum: 0 }
|
|
8646
|
+
]
|
|
8647
|
+
},
|
|
8648
|
+
RpcError: {
|
|
8649
|
+
type: "object",
|
|
8650
|
+
additionalProperties: false,
|
|
8651
|
+
required: ["code", "message"],
|
|
8652
|
+
properties: {
|
|
8653
|
+
code: {
|
|
8654
|
+
type: "string",
|
|
8655
|
+
enum: RPC_ERROR_CODES.map(([code]) => code),
|
|
8656
|
+
description: RPC_ERROR_CODES.map(([code, text]) => `\`${code}\`: ${text}`).join(" ")
|
|
8657
|
+
},
|
|
8658
|
+
message: { type: "string", description: "Human-readable detail. Not machine-parsed." }
|
|
8659
|
+
}
|
|
8660
|
+
},
|
|
8661
|
+
RpcSuccessResponse: {
|
|
8662
|
+
type: "object",
|
|
8663
|
+
additionalProperties: false,
|
|
8664
|
+
required: ["version", "id", "result"],
|
|
8665
|
+
properties: {
|
|
8666
|
+
version: { type: "integer", const: 1 },
|
|
8667
|
+
id: { $ref: "#/components/schemas/RpcId" },
|
|
8668
|
+
result: {
|
|
8669
|
+
description: "Method-specific result. See the individual method descriptions."
|
|
8670
|
+
}
|
|
8671
|
+
}
|
|
8672
|
+
},
|
|
8673
|
+
RpcErrorResponse: {
|
|
8674
|
+
type: "object",
|
|
8675
|
+
additionalProperties: false,
|
|
8676
|
+
required: ["version", "id", "error"],
|
|
8677
|
+
properties: {
|
|
8678
|
+
version: { type: "integer", const: 1 },
|
|
8679
|
+
id: {
|
|
8680
|
+
description: "The request id, or null when it could not be recovered from the body.",
|
|
8681
|
+
oneOf: [{ $ref: "#/components/schemas/RpcId" }, { type: "null" }]
|
|
8682
|
+
},
|
|
8683
|
+
error: { $ref: "#/components/schemas/RpcError" }
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8686
|
+
};
|
|
8687
|
+
const requestSchemaNames = [];
|
|
8688
|
+
const discriminatorMapping = {};
|
|
8689
|
+
for (const entry of ROOM_RPC_METHODS) {
|
|
8690
|
+
const base = schemaBaseName(entry.method);
|
|
8691
|
+
const paramsName = `${base}Params`;
|
|
8692
|
+
const requestName = `${base}Request`;
|
|
8693
|
+
schemas[paramsName] = { ...entry.params, description: `Parameters for \`${entry.method}\`.` };
|
|
8694
|
+
schemas[requestName] = {
|
|
8695
|
+
type: "object",
|
|
8696
|
+
additionalProperties: false,
|
|
8697
|
+
required: ["version", "id", "method", "params"],
|
|
8698
|
+
title: entry.summary,
|
|
8699
|
+
description: `${entry.description}
|
|
8700
|
+
|
|
8701
|
+
Result: ${entry.result}`,
|
|
8702
|
+
properties: {
|
|
8703
|
+
version: { type: "integer", const: 1 },
|
|
8704
|
+
id: { $ref: "#/components/schemas/RpcId" },
|
|
8705
|
+
method: { type: "string", const: entry.method },
|
|
8706
|
+
params: { $ref: `#/components/schemas/${paramsName}` }
|
|
8707
|
+
},
|
|
8708
|
+
examples: [{ version: 1, id: "req-1", method: entry.method, params: entry.example }]
|
|
8709
|
+
};
|
|
8710
|
+
requestSchemaNames.push(requestName);
|
|
8711
|
+
discriminatorMapping[entry.method] = `#/components/schemas/${requestName}`;
|
|
8712
|
+
}
|
|
8713
|
+
return {
|
|
8714
|
+
openapi: "3.1.0",
|
|
8715
|
+
info: {
|
|
8716
|
+
title: "ours-cowork room management API",
|
|
8717
|
+
version: API_VERSION,
|
|
8718
|
+
summary: "Loopback REST control surface for cowork mission rooms.",
|
|
8719
|
+
description: [
|
|
8720
|
+
'Every room-management operation is carried by a single REST route, `POST /rpc`, using the versioned RPC envelope `{ "version": 1, "id": ..., "method": ..., "params": ... }`. The `method` field selects the operation; the request schemas below are discriminated on it.',
|
|
8721
|
+
"",
|
|
8722
|
+
"The listener binds `127.0.0.1` only and has no authentication, so it accepts requests whose `Host` header is `127.0.0.1:<port>` or `localhost:<port>`, rejects cross-site fetches, and must not be exposed to other hosts through forwarding or a proxy.",
|
|
8723
|
+
"",
|
|
8724
|
+
"Requests must declare `Content-Type: application/json` and stay within 1 MiB. Operations that need an invite secret are not served here: they are reachable only over the daemon's private Unix socket."
|
|
8725
|
+
].join("\n"),
|
|
8726
|
+
license: { name: "FSL-1.1-Apache-2.0" }
|
|
8727
|
+
},
|
|
8728
|
+
servers: [{ url: "/", description: "This cowork daemon, on its loopback REST port." }],
|
|
8729
|
+
tags: [
|
|
8730
|
+
{ name: "rooms", description: "Room management over the RPC envelope." },
|
|
8731
|
+
{ name: "documentation", description: "The API description and its browser UI." }
|
|
8732
|
+
],
|
|
8733
|
+
paths: {
|
|
8734
|
+
[RPC_PATH]: {
|
|
8735
|
+
post: {
|
|
8736
|
+
tags: ["rooms"],
|
|
8737
|
+
operationId: "roomManagementRpc",
|
|
8738
|
+
summary: "Invoke a room-management method",
|
|
8739
|
+
description: "Dispatches one room-management method. The HTTP status reflects the envelope outcome: 200 on success, 404 when the method is not served over REST, 500 on an internal failure, and 400 for every other error code \u2014 including `not_found`.",
|
|
8740
|
+
requestBody: {
|
|
8741
|
+
required: true,
|
|
8742
|
+
content: {
|
|
8743
|
+
"application/json": {
|
|
8744
|
+
schema: {
|
|
8745
|
+
oneOf: requestSchemaNames.map((name) => ({ $ref: `#/components/schemas/${name}` })),
|
|
8746
|
+
discriminator: { propertyName: "method", mapping: discriminatorMapping }
|
|
8747
|
+
}
|
|
8748
|
+
}
|
|
8749
|
+
}
|
|
8750
|
+
},
|
|
8751
|
+
responses: {
|
|
8752
|
+
200: {
|
|
8753
|
+
description: "The method completed. `result` is method-specific.",
|
|
8754
|
+
content: {
|
|
8755
|
+
"application/json": {
|
|
8756
|
+
schema: { $ref: "#/components/schemas/RpcSuccessResponse" }
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
},
|
|
8760
|
+
400: errorResponseSpec(
|
|
8761
|
+
"The envelope, parameters, or room state rejected the call.",
|
|
8762
|
+
[
|
|
8763
|
+
"invalid_params",
|
|
8764
|
+
"invalid_json",
|
|
8765
|
+
"invalid_request",
|
|
8766
|
+
"not_found",
|
|
8767
|
+
"invalid_state",
|
|
8768
|
+
"shutting_down"
|
|
8769
|
+
]
|
|
8770
|
+
),
|
|
8771
|
+
403: errorResponseSpec(
|
|
8772
|
+
"The Host header was not a loopback console authority, the Origin did not match it, or the fetch was cross-site.",
|
|
8773
|
+
["forbidden"]
|
|
8774
|
+
),
|
|
8775
|
+
404: errorResponseSpec(
|
|
8776
|
+
"The method is not part of the REST route table.",
|
|
8777
|
+
["method_not_found"]
|
|
8778
|
+
),
|
|
8779
|
+
413: errorResponseSpec("The request body exceeded 1 MiB.", ["request_too_large"]),
|
|
8780
|
+
415: errorResponseSpec(
|
|
8781
|
+
"The request did not declare `application/json`.",
|
|
8782
|
+
["unsupported_media_type"]
|
|
8783
|
+
),
|
|
8784
|
+
500: errorResponseSpec("The daemon failed to complete the operation.", ["internal"])
|
|
8785
|
+
}
|
|
8786
|
+
}
|
|
8787
|
+
},
|
|
8788
|
+
[OPENAPI_DOCUMENT_PATH]: {
|
|
8789
|
+
get: {
|
|
8790
|
+
tags: ["documentation"],
|
|
8791
|
+
operationId: "getOpenApiDocument",
|
|
8792
|
+
summary: "Fetch this OpenAPI document",
|
|
8793
|
+
description: "Returns the OpenAPI 3.1 description of the room-management REST API.",
|
|
8794
|
+
responses: {
|
|
8795
|
+
200: {
|
|
8796
|
+
description: "The OpenAPI document.",
|
|
8797
|
+
content: { "application/json": { schema: { type: "object" } } }
|
|
8798
|
+
}
|
|
8799
|
+
}
|
|
8800
|
+
}
|
|
8801
|
+
},
|
|
8802
|
+
[API_DOCS_PATH]: {
|
|
8803
|
+
get: {
|
|
8804
|
+
tags: ["documentation"],
|
|
8805
|
+
operationId: "getApiDocsPage",
|
|
8806
|
+
summary: "Open the API documentation UI",
|
|
8807
|
+
description: `Serves the browser UI that renders \`${OPENAPI_DOCUMENT_PATH}\`.`,
|
|
8808
|
+
responses: { 200: documentResponseSpec("The documentation page.", "text/html") }
|
|
8809
|
+
}
|
|
8810
|
+
},
|
|
8811
|
+
[API_DOCS_SCRIPT_PATH]: {
|
|
8812
|
+
get: {
|
|
8813
|
+
tags: ["documentation"],
|
|
8814
|
+
operationId: "getApiDocsScript",
|
|
8815
|
+
summary: "Fetch the documentation UI script",
|
|
8816
|
+
responses: { 200: documentResponseSpec("The UI script.", "text/javascript") }
|
|
8817
|
+
}
|
|
8818
|
+
},
|
|
8819
|
+
[API_DOCS_STYLESHEET_PATH]: {
|
|
8820
|
+
get: {
|
|
8821
|
+
tags: ["documentation"],
|
|
8822
|
+
operationId: "getApiDocsStylesheet",
|
|
8823
|
+
summary: "Fetch the documentation UI stylesheet",
|
|
8824
|
+
responses: { 200: documentResponseSpec("The UI stylesheet.", "text/css") }
|
|
8825
|
+
}
|
|
8826
|
+
}
|
|
8827
|
+
},
|
|
8828
|
+
components: { schemas }
|
|
8829
|
+
};
|
|
8830
|
+
}
|
|
8831
|
+
function apiDocsAsset(pathname) {
|
|
8832
|
+
switch (pathname) {
|
|
8833
|
+
case OPENAPI_DOCUMENT_PATH:
|
|
8834
|
+
return {
|
|
8835
|
+
body: `${JSON.stringify(buildOpenApiDocument(), null, 2)}
|
|
8836
|
+
`,
|
|
8837
|
+
contentType: "application/json; charset=utf-8"
|
|
8838
|
+
};
|
|
8839
|
+
case API_DOCS_PATH:
|
|
8840
|
+
return { body: DOCS_PAGE, contentType: "text/html; charset=utf-8" };
|
|
8841
|
+
case API_DOCS_SCRIPT_PATH:
|
|
8842
|
+
return { body: DOCS_SCRIPT, contentType: "text/javascript; charset=utf-8" };
|
|
8843
|
+
case API_DOCS_STYLESHEET_PATH:
|
|
8844
|
+
return { body: DOCS_STYLESHEET, contentType: "text/css; charset=utf-8" };
|
|
8845
|
+
default:
|
|
8846
|
+
return void 0;
|
|
8847
|
+
}
|
|
8848
|
+
}
|
|
8849
|
+
var RPC_PATH, OPENAPI_DOCUMENT_PATH, API_DOCS_PATH, API_DOCS_SCRIPT_PATH, API_DOCS_STYLESHEET_PATH, API_VERSION, EXAMPLE_ROOM_ID, roomIdProperty, roleProperty, missionTextProperty, roomNameProperty, inviteModeProperty, notifyProperty, ROOM_RPC_METHODS, RPC_ERROR_CODES, DOCS_PAGE, DOCS_STYLESHEET, DOCS_SCRIPT;
|
|
8850
|
+
var init_openapi = __esm({
|
|
8851
|
+
"src/openapi.ts"() {
|
|
8852
|
+
"use strict";
|
|
8853
|
+
RPC_PATH = "/rpc";
|
|
8854
|
+
OPENAPI_DOCUMENT_PATH = "/openapi.json";
|
|
8855
|
+
API_DOCS_PATH = "/docs";
|
|
8856
|
+
API_DOCS_SCRIPT_PATH = "/docs/ui.js";
|
|
8857
|
+
API_DOCS_STYLESHEET_PATH = "/docs/ui.css";
|
|
8858
|
+
API_VERSION = "1";
|
|
8859
|
+
EXAMPLE_ROOM_ID = "01jd7q4h9m2v8xk3znbc5regty";
|
|
8860
|
+
roomIdProperty = {
|
|
8861
|
+
type: "string",
|
|
8862
|
+
pattern: "^[0-7][0-9a-hjkmnp-tv-z]{25}$",
|
|
8863
|
+
description: "26-character lowercase Crockford ULID identifying the room."
|
|
8864
|
+
};
|
|
8865
|
+
roleProperty = {
|
|
8866
|
+
type: "string",
|
|
8867
|
+
description: "Invite role. At most 256 UTF-8 bytes."
|
|
8868
|
+
};
|
|
8869
|
+
missionTextProperty = (what) => ({
|
|
8870
|
+
type: "string",
|
|
8871
|
+
description: `${what}. At most 262144 UTF-8 bytes.`
|
|
8872
|
+
});
|
|
8873
|
+
roomNameProperty = {
|
|
8874
|
+
type: "string",
|
|
8875
|
+
description: "Friendly room name: 1-64 Unicode characters after trimming and NFC normalization, with no Unicode control or format characters. Duplicates are allowed."
|
|
8876
|
+
};
|
|
8877
|
+
inviteModeProperty = {
|
|
8878
|
+
type: "string",
|
|
8879
|
+
enum: ["one_time", "public"],
|
|
8880
|
+
description: "Invitation mode. `one_time` requires `min_accepts` to be 1."
|
|
8881
|
+
};
|
|
8882
|
+
notifyProperty = {
|
|
8883
|
+
type: "boolean",
|
|
8884
|
+
description: "Announce the membership change to the room. Defaults to the room's quiet setting."
|
|
8885
|
+
};
|
|
8886
|
+
ROOM_RPC_METHODS = [
|
|
8887
|
+
{
|
|
8888
|
+
method: "room.create",
|
|
8889
|
+
summary: "Create a room",
|
|
8890
|
+
description: "Provisions a room, its durable metadata, and its room packet. The room stays in the provisioning state until its invitation requirements are satisfied.",
|
|
8891
|
+
params: params({
|
|
8892
|
+
name: roomNameProperty,
|
|
8893
|
+
goal: missionTextProperty("Mission goal"),
|
|
8894
|
+
briefing: missionTextProperty("Mission briefing"),
|
|
8895
|
+
anonymous: {
|
|
8896
|
+
type: "boolean",
|
|
8897
|
+
description: "Project participants under aliases instead of contact identities."
|
|
8898
|
+
},
|
|
8899
|
+
quiet_membership: {
|
|
8900
|
+
type: "boolean",
|
|
8901
|
+
description: "Suppress membership announcements for this room by default."
|
|
8902
|
+
}
|
|
8903
|
+
}, ["goal", "briefing"]),
|
|
8904
|
+
result: "The created room record, including `room_id`, `room_name`, `state`, mission, invites, and seats.",
|
|
8905
|
+
example: { goal: "Ship the release", briefing: "Coordinate the 1.0 cut.", name: "Release" }
|
|
8906
|
+
},
|
|
8907
|
+
{
|
|
8908
|
+
method: "room.settings",
|
|
8909
|
+
summary: "Update room settings",
|
|
8910
|
+
description: "Updates mutable room settings. At least one setting besides `room_id` is required; omitted settings are left unchanged.",
|
|
8911
|
+
params: params({
|
|
8912
|
+
room_id: roomIdProperty,
|
|
8913
|
+
name: roomNameProperty,
|
|
8914
|
+
goal: missionTextProperty("Replacement mission goal"),
|
|
8915
|
+
briefing: missionTextProperty("Replacement mission briefing"),
|
|
8916
|
+
status: { type: "string", minLength: 1, description: "Operator status line." },
|
|
8917
|
+
quiet_membership: {
|
|
8918
|
+
type: "boolean",
|
|
8919
|
+
description: "Suppress membership announcements for this room."
|
|
8920
|
+
}
|
|
8921
|
+
}, ["room_id"]),
|
|
8922
|
+
result: "The updated room record.",
|
|
8923
|
+
example: { room_id: EXAMPLE_ROOM_ID, name: "Release cut" }
|
|
8924
|
+
},
|
|
8925
|
+
{
|
|
8926
|
+
method: "room.briefing.role.set",
|
|
8927
|
+
summary: "Set a role briefing",
|
|
8928
|
+
description: "Creates or replaces the briefing for one role and bumps its briefing version.",
|
|
8929
|
+
params: params({
|
|
8930
|
+
room_id: roomIdProperty,
|
|
8931
|
+
role: roleProperty,
|
|
8932
|
+
text: missionTextProperty("Role briefing text")
|
|
8933
|
+
}, ["room_id", "role", "text"]),
|
|
8934
|
+
result: "The updated room record with the stored role briefing.",
|
|
8935
|
+
example: { room_id: EXAMPLE_ROOM_ID, role: "Reviewer", text: "Review every merge request." }
|
|
8936
|
+
},
|
|
8937
|
+
{
|
|
8938
|
+
method: "room.briefing.role.delete",
|
|
8939
|
+
summary: "Delete a role briefing",
|
|
8940
|
+
description: "Removes the briefing for one role.",
|
|
8941
|
+
params: params({ room_id: roomIdProperty, role: roleProperty }, ["room_id", "role"]),
|
|
8942
|
+
result: "The updated room record without the removed role briefing.",
|
|
8943
|
+
example: { room_id: EXAMPLE_ROOM_ID, role: "Reviewer" }
|
|
8944
|
+
},
|
|
8945
|
+
{
|
|
8946
|
+
method: "room.invite",
|
|
8947
|
+
summary: "Mint an invitation requirement",
|
|
8948
|
+
description: "Mints one invitation requirement and returns its receipt. The invite secret is returned once in `blob` and is never stored in room metadata or replayed by any later call.",
|
|
8949
|
+
params: params({
|
|
8950
|
+
room_id: roomIdProperty,
|
|
8951
|
+
mode: inviteModeProperty,
|
|
8952
|
+
role: roleProperty,
|
|
8953
|
+
min_accepts: {
|
|
8954
|
+
type: "integer",
|
|
8955
|
+
minimum: 1,
|
|
8956
|
+
description: "Acceptances required before the requirement is satisfied. Must be 1 for `one_time` invites."
|
|
8957
|
+
}
|
|
8958
|
+
}, ["room_id", "mode", "min_accepts"]),
|
|
8959
|
+
result: "An invite receipt: `room_id`, the recorded `invite`, the one-shot `blob` secret, and `reusable`.",
|
|
8960
|
+
example: { room_id: EXAMPLE_ROOM_ID, mode: "one_time", role: "Reviewer", min_accepts: 1 }
|
|
8961
|
+
},
|
|
8962
|
+
{
|
|
8963
|
+
method: "room.participant.remove",
|
|
8964
|
+
summary: "Remove a participant",
|
|
8965
|
+
description: "Removes one participant seat, bumps the membership epoch, and severs the contact. The receipt reports what actually happened, including retained key material.",
|
|
8966
|
+
params: params({
|
|
8967
|
+
room_id: roomIdProperty,
|
|
8968
|
+
participant: {
|
|
8969
|
+
type: "string",
|
|
8970
|
+
minLength: 1,
|
|
8971
|
+
description: "Participant id, identity, display name, or alias."
|
|
8972
|
+
},
|
|
8973
|
+
notify: notifyProperty
|
|
8974
|
+
}, ["room_id", "participant"]),
|
|
8975
|
+
result: "A removal receipt with `participant_id`, `epoch`, `status`, `notified`, and `key_material_retained`.",
|
|
8976
|
+
example: { room_id: EXAMPLE_ROOM_ID, participant: "Reviewer-1", notify: true }
|
|
8977
|
+
},
|
|
8978
|
+
{
|
|
8979
|
+
method: "room.participant.replace",
|
|
8980
|
+
summary: "Replace a participant",
|
|
8981
|
+
description: "Removes one participant seat and mints a replacement invitation requirement in the same operation.",
|
|
8982
|
+
params: params({
|
|
8983
|
+
room_id: roomIdProperty,
|
|
8984
|
+
participant: {
|
|
8985
|
+
type: "string",
|
|
8986
|
+
minLength: 1,
|
|
8987
|
+
description: "Participant id, identity, display name, or alias."
|
|
8988
|
+
},
|
|
8989
|
+
notify: notifyProperty,
|
|
8990
|
+
mode: inviteModeProperty,
|
|
8991
|
+
min_accepts: {
|
|
8992
|
+
type: "integer",
|
|
8993
|
+
minimum: 1,
|
|
8994
|
+
description: "Acceptances required for the replacement invitation requirement."
|
|
8995
|
+
}
|
|
8996
|
+
}, ["room_id", "participant"]),
|
|
8997
|
+
result: "An invite receipt for the replacement, extended with the `removal` receipt.",
|
|
8998
|
+
example: { room_id: EXAMPLE_ROOM_ID, participant: "Reviewer-1", mode: "one_time" }
|
|
8999
|
+
},
|
|
9000
|
+
{
|
|
9001
|
+
method: "room.revoke",
|
|
9002
|
+
summary: "Revoke an invitation requirement",
|
|
9003
|
+
description: "Revokes one live invitation requirement so it can no longer admit a seat.",
|
|
9004
|
+
params: params({
|
|
9005
|
+
room_id: roomIdProperty,
|
|
9006
|
+
invite_id: { type: "string", minLength: 1, description: "Recorded invite identifier." }
|
|
9007
|
+
}, ["room_id", "invite_id"]),
|
|
9008
|
+
result: "The updated room record with the invite marked revoked.",
|
|
9009
|
+
example: { room_id: EXAMPLE_ROOM_ID, invite_id: "inv-01" }
|
|
9010
|
+
},
|
|
9011
|
+
{
|
|
9012
|
+
method: "room.recover",
|
|
9013
|
+
summary: "Recover unusable invitations",
|
|
9014
|
+
description: "Mints recovery invitations for requirements whose secret can no longer admit a seat. Each recovery must be confirmed before it replaces the original.",
|
|
9015
|
+
params: params({ room_id: roomIdProperty }, ["room_id"]),
|
|
9016
|
+
result: "The list of recovery invite receipts, each carrying `recovery_of`.",
|
|
9017
|
+
example: { room_id: EXAMPLE_ROOM_ID }
|
|
9018
|
+
},
|
|
9019
|
+
{
|
|
9020
|
+
method: "room.recover.confirm",
|
|
9021
|
+
summary: "Confirm a recovery invitation",
|
|
9022
|
+
description: "Confirms that a recovery invitation was handed over, retiring the invitation requirement it recovers.",
|
|
9023
|
+
params: params({
|
|
9024
|
+
room_id: roomIdProperty,
|
|
9025
|
+
recovery_of: { type: "string", minLength: 1, description: "Invite id being recovered." },
|
|
9026
|
+
invite_id: { type: "string", minLength: 1, description: "Recovery invite id to confirm." }
|
|
9027
|
+
}, ["room_id", "recovery_of", "invite_id"]),
|
|
9028
|
+
result: "The updated room record with the confirmed recovery.",
|
|
9029
|
+
example: { room_id: EXAMPLE_ROOM_ID, recovery_of: "inv-01", invite_id: "inv-02" }
|
|
9030
|
+
},
|
|
9031
|
+
{
|
|
9032
|
+
method: "room.list",
|
|
9033
|
+
summary: "List rooms",
|
|
9034
|
+
description: "Lists every room held on this host. Takes no parameters.",
|
|
9035
|
+
params: params({}, []),
|
|
9036
|
+
result: "An array of room records.",
|
|
9037
|
+
example: {}
|
|
9038
|
+
},
|
|
9039
|
+
{
|
|
9040
|
+
method: "room.show",
|
|
9041
|
+
summary: "Show one room",
|
|
9042
|
+
description: "Returns the complete durable record for one room.",
|
|
9043
|
+
params: params({ room_id: roomIdProperty }, ["room_id"]),
|
|
9044
|
+
result: "The room record.",
|
|
9045
|
+
example: { room_id: EXAMPLE_ROOM_ID }
|
|
9046
|
+
},
|
|
9047
|
+
{
|
|
9048
|
+
method: "room.participants",
|
|
9049
|
+
summary: "List participants",
|
|
9050
|
+
description: "Returns the room's seats, including pending, active, and removed states.",
|
|
9051
|
+
params: params({ room_id: roomIdProperty }, ["room_id"]),
|
|
9052
|
+
result: "An array of seat records.",
|
|
9053
|
+
example: { room_id: EXAMPLE_ROOM_ID }
|
|
9054
|
+
},
|
|
9055
|
+
{
|
|
9056
|
+
method: "room.history",
|
|
9057
|
+
summary: "Read room history",
|
|
9058
|
+
description: "Reads one page of the room's ordered communication archive. The operator view returns every record kind; the participant view returns message records only, with routing identities removed and authors reduced to alias form in anonymous rooms.",
|
|
9059
|
+
params: params({
|
|
9060
|
+
room_id: roomIdProperty,
|
|
9061
|
+
after: {
|
|
9062
|
+
type: "integer",
|
|
9063
|
+
minimum: 0,
|
|
9064
|
+
description: "Return records with a sequence number greater than this value."
|
|
9065
|
+
},
|
|
9066
|
+
limit: { type: "integer", minimum: 1, description: "Maximum number of records to return." },
|
|
9067
|
+
view: {
|
|
9068
|
+
type: "string",
|
|
9069
|
+
enum: ["operator", "participant"],
|
|
9070
|
+
description: "History projection. Defaults to the operator view."
|
|
9071
|
+
}
|
|
9072
|
+
}, ["room_id"]),
|
|
9073
|
+
result: "An array of communication records, byte-bounded to one page.",
|
|
9074
|
+
example: { room_id: EXAMPLE_ROOM_ID, after: 0, limit: 50, view: "operator" }
|
|
9075
|
+
},
|
|
9076
|
+
{
|
|
9077
|
+
method: "room.message",
|
|
9078
|
+
summary: "Post an operator message",
|
|
9079
|
+
description: "Appends an operator message to the room archive and relays it to active seats. Authorship is assigned by the daemon.",
|
|
9080
|
+
params: params({
|
|
9081
|
+
room_id: roomIdProperty,
|
|
9082
|
+
text: missionTextProperty("Message text")
|
|
9083
|
+
}, ["room_id", "text"]),
|
|
9084
|
+
result: "The appended message record with its `seq` and `record_id`.",
|
|
9085
|
+
example: { room_id: EXAMPLE_ROOM_ID, text: "Standup at 10:00." }
|
|
9086
|
+
},
|
|
9087
|
+
{
|
|
9088
|
+
method: "room.close",
|
|
9089
|
+
summary: "Close a room",
|
|
9090
|
+
description: "Closes the room forward-only. The plaintext local archive is left in place.",
|
|
9091
|
+
params: params({ room_id: roomIdProperty }, ["room_id"]),
|
|
9092
|
+
result: "The closed room record.",
|
|
9093
|
+
example: { room_id: EXAMPLE_ROOM_ID }
|
|
9094
|
+
},
|
|
9095
|
+
{
|
|
9096
|
+
method: "room.delete",
|
|
9097
|
+
summary: "Delete a room",
|
|
9098
|
+
description: "Removes this host's local room state after the room is closed. The scope is this host only.",
|
|
9099
|
+
params: params({
|
|
9100
|
+
room_id: roomIdProperty,
|
|
9101
|
+
confirm: { type: "boolean", const: true, description: "Must be `true`." }
|
|
9102
|
+
}, ["room_id", "confirm"]),
|
|
9103
|
+
result: 'A delete receipt: `{ "version": 1, "room_id": "...", "deleted": true, "scope": "this_host" }`.',
|
|
9104
|
+
example: { room_id: EXAMPLE_ROOM_ID, confirm: true }
|
|
9105
|
+
}
|
|
9106
|
+
];
|
|
9107
|
+
RPC_ERROR_CODES = [
|
|
9108
|
+
["invalid_json", "The request body was not valid JSON."],
|
|
9109
|
+
["invalid_request", "The RPC envelope did not match the strict envelope schema."],
|
|
9110
|
+
["invalid_params", "The `params` object failed method validation."],
|
|
9111
|
+
["not_found", "The referenced room or record does not exist."],
|
|
9112
|
+
["invalid_state", "The room is not in a state that permits the operation."],
|
|
9113
|
+
["shutting_down", "The daemon stopped accepting work."],
|
|
9114
|
+
["method_not_found", "The method is not served over REST."],
|
|
9115
|
+
["unsupported_media_type", "The request did not declare `application/json`."],
|
|
9116
|
+
["forbidden", "The request origin or Host header was not the loopback console origin."],
|
|
9117
|
+
["request_too_large", "The request body exceeded 1 MiB."],
|
|
9118
|
+
["internal", "The daemon failed to complete the operation."]
|
|
9119
|
+
];
|
|
9120
|
+
DOCS_PAGE = `<!DOCTYPE html>
|
|
9121
|
+
<html lang="en">
|
|
9122
|
+
<head>
|
|
9123
|
+
<meta charset="utf-8">
|
|
9124
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9125
|
+
<title>ours-cowork room management API</title>
|
|
9126
|
+
<link rel="stylesheet" href="${API_DOCS_STYLESHEET_PATH}">
|
|
9127
|
+
</head>
|
|
9128
|
+
<body>
|
|
9129
|
+
<main id="api-docs" data-document="${OPENAPI_DOCUMENT_PATH}" data-rpc="${RPC_PATH}">
|
|
9130
|
+
<p class="loading">Loading <code>${OPENAPI_DOCUMENT_PATH}</code>…</p>
|
|
9131
|
+
</main>
|
|
9132
|
+
<script src="${API_DOCS_SCRIPT_PATH}"></script>
|
|
9133
|
+
</body>
|
|
9134
|
+
</html>
|
|
9135
|
+
`;
|
|
9136
|
+
DOCS_STYLESHEET = `:root { color-scheme: light dark; --line: #8883; --accent: #2563eb; }
|
|
9137
|
+
* { box-sizing: border-box; }
|
|
9138
|
+
body { margin: 0; font: 15px/1.5 ui-sans-serif, system-ui, sans-serif; }
|
|
9139
|
+
main { margin: 0 auto; max-width: 60rem; padding: 2rem 1.25rem 4rem; }
|
|
9140
|
+
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
|
|
9141
|
+
h2 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
|
|
9142
|
+
code, pre, textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
|
|
9143
|
+
pre { background: #8881; border-radius: 6px; margin: 0; overflow-x: auto; padding: .6rem .75rem; }
|
|
9144
|
+
.subtitle { color: #8889; margin: 0 0 1rem; }
|
|
9145
|
+
.intro { border-left: 3px solid var(--accent); padding-left: .9rem; white-space: pre-wrap; }
|
|
9146
|
+
.route { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .5rem; padding: .6rem .8rem; }
|
|
9147
|
+
.verb { background: var(--accent); border-radius: 4px; color: #fff; font-size: .72rem;
|
|
9148
|
+
font-weight: 700; letter-spacing: .04em; margin-right: .5rem; padding: .12rem .4rem; }
|
|
9149
|
+
details.method { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .5rem; }
|
|
9150
|
+
details.method > summary { cursor: pointer; padding: .6rem .8rem; }
|
|
9151
|
+
details.method[open] > summary { border-bottom: 1px solid var(--line); }
|
|
9152
|
+
summary .name { font-family: ui-monospace, monospace; font-weight: 600; }
|
|
9153
|
+
summary .summary-text { color: #8889; margin-left: .6rem; }
|
|
9154
|
+
.body { padding: .8rem; }
|
|
9155
|
+
.description { margin: 0 0 .8rem; white-space: pre-wrap; }
|
|
9156
|
+
table { border-collapse: collapse; margin-bottom: .8rem; width: 100%; }
|
|
9157
|
+
th, td { border-bottom: 1px solid var(--line); padding: .35rem .5rem; text-align: left;
|
|
9158
|
+
vertical-align: top; }
|
|
9159
|
+
th { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
|
|
9160
|
+
td.param { font-family: ui-monospace, monospace; white-space: nowrap; }
|
|
9161
|
+
.required { color: #b91c1c; font-size: .75rem; margin-left: .3rem; }
|
|
9162
|
+
textarea { border: 1px solid var(--line); border-radius: 6px; padding: .5rem; width: 100%; }
|
|
9163
|
+
button { background: var(--accent); border: 0; border-radius: 6px; color: #fff; cursor: pointer;
|
|
9164
|
+
font: inherit; margin: .5rem 0; padding: .4rem 1rem; }
|
|
9165
|
+
.status { font-weight: 600; margin: .5rem 0 .35rem; }
|
|
9166
|
+
.status.failed { color: #b91c1c; }
|
|
9167
|
+
.error { color: #b91c1c; }
|
|
9168
|
+
`;
|
|
9169
|
+
DOCS_SCRIPT = `'use strict';
|
|
9170
|
+
(function () {
|
|
9171
|
+
var root = document.getElementById('api-docs');
|
|
9172
|
+
var documentUrl = root.dataset.document;
|
|
9173
|
+
var rpcUrl = root.dataset.rpc;
|
|
9174
|
+
|
|
9175
|
+
function element(tag, className, text) {
|
|
9176
|
+
var node = document.createElement(tag);
|
|
9177
|
+
if (className) node.className = className;
|
|
9178
|
+
if (text !== undefined) node.textContent = text;
|
|
9179
|
+
return node;
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
function resolveRef(spec, ref) {
|
|
9183
|
+
return ref.replace(/^#\\//, '').split('/').reduce(function (node, part) {
|
|
9184
|
+
return node === undefined ? undefined : node[part];
|
|
9185
|
+
}, spec);
|
|
9186
|
+
}
|
|
9187
|
+
|
|
9188
|
+
function typeLabel(schema) {
|
|
9189
|
+
if (!schema) return 'any';
|
|
9190
|
+
if (schema.const !== undefined) return JSON.stringify(schema.const);
|
|
9191
|
+
if (schema.enum) return schema.enum.map(function (value) { return JSON.stringify(value); }).join(' | ');
|
|
9192
|
+
return schema.type || 'any';
|
|
9193
|
+
}
|
|
9194
|
+
|
|
9195
|
+
function parameterTable(schema) {
|
|
9196
|
+
var properties = (schema && schema.properties) || {};
|
|
9197
|
+
var names = Object.keys(properties);
|
|
9198
|
+
if (names.length === 0) return element('p', 'description', 'No parameters.');
|
|
9199
|
+
var required = (schema && schema.required) || [];
|
|
9200
|
+
var table = document.createElement('table');
|
|
9201
|
+
var head = table.insertRow();
|
|
9202
|
+
['Parameter', 'Type', 'Description'].forEach(function (label) {
|
|
9203
|
+
head.appendChild(element('th', null, label));
|
|
9204
|
+
});
|
|
9205
|
+
names.forEach(function (name) {
|
|
9206
|
+
var property = properties[name];
|
|
9207
|
+
var row = table.insertRow();
|
|
9208
|
+
var cell = element('td', 'param', name);
|
|
9209
|
+
if (required.indexOf(name) >= 0) cell.appendChild(element('span', 'required', 'required'));
|
|
9210
|
+
row.appendChild(cell);
|
|
9211
|
+
row.appendChild(element('td', null, typeLabel(property)));
|
|
9212
|
+
row.appendChild(element('td', null, property.description || ''));
|
|
9213
|
+
});
|
|
9214
|
+
return table;
|
|
9215
|
+
}
|
|
9216
|
+
|
|
9217
|
+
function tryItPanel(example) {
|
|
9218
|
+
var panel = document.createElement('div');
|
|
9219
|
+
var input = document.createElement('textarea');
|
|
9220
|
+
input.rows = Math.min(14, JSON.stringify(example, null, 2).split('\\n').length + 1);
|
|
9221
|
+
input.value = JSON.stringify(example, null, 2);
|
|
9222
|
+
input.setAttribute('aria-label', 'Request body');
|
|
9223
|
+
var send = element('button', null, 'Send request');
|
|
9224
|
+
var output = document.createElement('div');
|
|
9225
|
+
send.addEventListener('click', function () {
|
|
9226
|
+
var body = input.value;
|
|
9227
|
+
try { JSON.parse(body); } catch (error) {
|
|
9228
|
+
output.textContent = '';
|
|
9229
|
+
output.appendChild(element('p', 'status failed', 'Request body is not valid JSON.'));
|
|
9230
|
+
return;
|
|
9231
|
+
}
|
|
9232
|
+
send.disabled = true;
|
|
9233
|
+
output.textContent = '';
|
|
9234
|
+
output.appendChild(element('p', 'status', 'Sending\\u2026'));
|
|
9235
|
+
fetch(rpcUrl, {
|
|
9236
|
+
method: 'POST',
|
|
9237
|
+
headers: { 'content-type': 'application/json' },
|
|
9238
|
+
body: body,
|
|
9239
|
+
}).then(function (response) {
|
|
9240
|
+
return response.text().then(function (text) { return { status: response.status, text: text }; });
|
|
9241
|
+
}).then(function (result) {
|
|
9242
|
+
var pretty = result.text;
|
|
9243
|
+
try { pretty = JSON.stringify(JSON.parse(result.text), null, 2); } catch (error) { /* raw */ }
|
|
9244
|
+
output.textContent = '';
|
|
9245
|
+
output.appendChild(element(
|
|
9246
|
+
'p',
|
|
9247
|
+
result.status === 200 ? 'status' : 'status failed',
|
|
9248
|
+
'HTTP ' + result.status
|
|
9249
|
+
));
|
|
9250
|
+
output.appendChild(element('pre', null, pretty));
|
|
9251
|
+
}).catch(function (error) {
|
|
9252
|
+
output.textContent = '';
|
|
9253
|
+
output.appendChild(element('p', 'status failed', 'Request failed: ' + error));
|
|
9254
|
+
}).then(function () { send.disabled = false; });
|
|
9255
|
+
});
|
|
9256
|
+
panel.appendChild(element('h3', null, 'Try it'));
|
|
9257
|
+
panel.appendChild(input);
|
|
9258
|
+
panel.appendChild(send);
|
|
9259
|
+
panel.appendChild(output);
|
|
9260
|
+
return panel;
|
|
9261
|
+
}
|
|
9262
|
+
|
|
9263
|
+
function methodPanel(spec, ref) {
|
|
9264
|
+
var schema = resolveRef(spec, ref);
|
|
9265
|
+
var method = schema.properties.method.const;
|
|
9266
|
+
var panel = element('details', 'method');
|
|
9267
|
+
var summary = document.createElement('summary');
|
|
9268
|
+
summary.appendChild(element('span', 'name', method));
|
|
9269
|
+
summary.appendChild(element('span', 'summary-text', schema.title || ''));
|
|
9270
|
+
panel.appendChild(summary);
|
|
9271
|
+
var body = element('div', 'body');
|
|
9272
|
+
body.appendChild(element('p', 'description', schema.description || ''));
|
|
9273
|
+
body.appendChild(parameterTable(resolveRef(spec, schema.properties.params.$ref)));
|
|
9274
|
+
body.appendChild(tryItPanel((schema.examples && schema.examples[0]) || {
|
|
9275
|
+
version: 1, id: 'req-1', method: method, params: {},
|
|
9276
|
+
}));
|
|
9277
|
+
panel.appendChild(body);
|
|
9278
|
+
return panel;
|
|
9279
|
+
}
|
|
9280
|
+
|
|
9281
|
+
function renderRoutes(spec) {
|
|
9282
|
+
var section = document.createDocumentFragment();
|
|
9283
|
+
Object.keys(spec.paths).forEach(function (path) {
|
|
9284
|
+
Object.keys(spec.paths[path]).forEach(function (verb) {
|
|
9285
|
+
var operation = spec.paths[path][verb];
|
|
9286
|
+
var route = element('div', 'route');
|
|
9287
|
+
var heading = document.createElement('div');
|
|
9288
|
+
heading.appendChild(element('span', 'verb', verb.toUpperCase()));
|
|
9289
|
+
heading.appendChild(element('code', null, path));
|
|
9290
|
+
route.appendChild(heading);
|
|
9291
|
+
route.appendChild(element('p', 'description', operation.summary || ''));
|
|
9292
|
+
section.appendChild(route);
|
|
9293
|
+
});
|
|
9294
|
+
});
|
|
9295
|
+
return section;
|
|
9296
|
+
}
|
|
9297
|
+
|
|
9298
|
+
function render(spec) {
|
|
9299
|
+
root.textContent = '';
|
|
9300
|
+
root.appendChild(element('h1', null, spec.info.title));
|
|
9301
|
+
root.appendChild(element('p', 'subtitle', 'API version ' + spec.info.version + ' \\u00b7 OpenAPI ' + spec.openapi));
|
|
9302
|
+
root.appendChild(element('p', 'intro', spec.info.description || ''));
|
|
9303
|
+
root.appendChild(element('h2', null, 'Routes'));
|
|
9304
|
+
root.appendChild(renderRoutes(spec));
|
|
9305
|
+
root.appendChild(element('h2', null, 'Room management methods'));
|
|
9306
|
+
var alternatives = spec.paths[rpcUrl].post.requestBody.content['application/json'].schema.oneOf;
|
|
9307
|
+
alternatives.forEach(function (alternative) {
|
|
9308
|
+
root.appendChild(methodPanel(spec, alternative.$ref));
|
|
9309
|
+
});
|
|
9310
|
+
}
|
|
9311
|
+
|
|
9312
|
+
fetch(documentUrl).then(function (response) {
|
|
9313
|
+
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
9314
|
+
return response.json();
|
|
9315
|
+
}).then(render).catch(function (error) {
|
|
9316
|
+
root.textContent = '';
|
|
9317
|
+
root.appendChild(element('p', 'error', 'Could not load ' + documentUrl + ': ' + error));
|
|
9318
|
+
});
|
|
9319
|
+
}());
|
|
9320
|
+
`;
|
|
9321
|
+
}
|
|
9322
|
+
});
|
|
9323
|
+
|
|
8614
9324
|
// src/web.ts
|
|
8615
9325
|
import * as nodeFs4 from "node:fs";
|
|
8616
9326
|
import { extname, join as join5 } from "node:path";
|
|
@@ -8777,8 +9487,8 @@ import * as nodeFs5 from "node:fs";
|
|
|
8777
9487
|
import { basename, dirname as dirname5, join as join6 } from "node:path";
|
|
8778
9488
|
function createServiceRoutes(service) {
|
|
8779
9489
|
return {
|
|
8780
|
-
"room.create": { auth: true, run: (
|
|
8781
|
-
"room.settings": { auth: true, run: (
|
|
9490
|
+
"room.create": { auth: true, run: (params2) => service.createRoom(params2) },
|
|
9491
|
+
"room.settings": { auth: true, run: (params2) => {
|
|
8782
9492
|
const { room_id, ...input } = external_exports.object({
|
|
8783
9493
|
room_id: external_exports.string(),
|
|
8784
9494
|
name: external_exports.unknown().optional(),
|
|
@@ -8786,68 +9496,68 @@ function createServiceRoutes(service) {
|
|
|
8786
9496
|
briefing: external_exports.unknown().optional(),
|
|
8787
9497
|
status: external_exports.unknown().optional(),
|
|
8788
9498
|
quiet_membership: external_exports.unknown().optional()
|
|
8789
|
-
}).strict().parse(
|
|
9499
|
+
}).strict().parse(params2);
|
|
8790
9500
|
return service.updateRoom(room_id, input);
|
|
8791
9501
|
} },
|
|
8792
|
-
"room.briefing.role.set": { auth: true, run: (
|
|
8793
|
-
const { room_id, ...input } = RoleBriefingSetParams.parse(
|
|
9502
|
+
"room.briefing.role.set": { auth: true, run: (params2) => {
|
|
9503
|
+
const { room_id, ...input } = RoleBriefingSetParams.parse(params2);
|
|
8794
9504
|
return service.setRoleBriefing(room_id, input);
|
|
8795
9505
|
} },
|
|
8796
|
-
"room.briefing.role.delete": { auth: true, run: (
|
|
8797
|
-
const { room_id, ...input } = RoleBriefingDeleteParams.parse(
|
|
9506
|
+
"room.briefing.role.delete": { auth: true, run: (params2) => {
|
|
9507
|
+
const { room_id, ...input } = RoleBriefingDeleteParams.parse(params2);
|
|
8798
9508
|
return service.deleteRoleBriefing(room_id, input);
|
|
8799
9509
|
} },
|
|
8800
|
-
"room.invite": { auth: true, run: (
|
|
9510
|
+
"room.invite": { auth: true, run: (params2) => {
|
|
8801
9511
|
const { room_id, ...input } = external_exports.object({
|
|
8802
9512
|
room_id: external_exports.string(),
|
|
8803
9513
|
mode: external_exports.unknown(),
|
|
8804
9514
|
role: external_exports.unknown().optional(),
|
|
8805
9515
|
min_accepts: external_exports.unknown()
|
|
8806
|
-
}).strict().parse(
|
|
9516
|
+
}).strict().parse(params2);
|
|
8807
9517
|
return service.createInvite(room_id, input);
|
|
8808
9518
|
} },
|
|
8809
|
-
"room.participant.remove": { auth: true, run: (
|
|
8810
|
-
const { room_id, ...input } = ParticipantRemoveParams.parse(
|
|
9519
|
+
"room.participant.remove": { auth: true, run: (params2) => {
|
|
9520
|
+
const { room_id, ...input } = ParticipantRemoveParams.parse(params2);
|
|
8811
9521
|
return service.removeParticipant(room_id, input);
|
|
8812
9522
|
} },
|
|
8813
|
-
"room.participant.replace": { auth: true, run: (
|
|
8814
|
-
const { room_id, ...input } = ParticipantReplaceParams.parse(
|
|
9523
|
+
"room.participant.replace": { auth: true, run: (params2) => {
|
|
9524
|
+
const { room_id, ...input } = ParticipantReplaceParams.parse(params2);
|
|
8815
9525
|
return service.replaceParticipant(room_id, input);
|
|
8816
9526
|
} },
|
|
8817
|
-
"room.revoke": { auth: true, run: (
|
|
8818
|
-
const value = InviteRevokeParams.parse(
|
|
9527
|
+
"room.revoke": { auth: true, run: (params2) => {
|
|
9528
|
+
const value = InviteRevokeParams.parse(params2);
|
|
8819
9529
|
return service.revokeInvite(value.room_id, value.invite_id);
|
|
8820
9530
|
} },
|
|
8821
|
-
"room.recover": { auth: true, run: (
|
|
8822
|
-
"room.recover.confirm": { auth: true, run: (
|
|
8823
|
-
const value = RecoverConfirmParams.parse(
|
|
9531
|
+
"room.recover": { auth: true, run: (params2) => service.recoverInvites(RoomIdParams.parse(params2).room_id) },
|
|
9532
|
+
"room.recover.confirm": { auth: true, run: (params2) => {
|
|
9533
|
+
const value = RecoverConfirmParams.parse(params2);
|
|
8824
9534
|
return service.confirmRecoveredInvite(value.room_id, value.recovery_of, value.invite_id);
|
|
8825
9535
|
} },
|
|
8826
|
-
"room.list": { auth: true, run: (
|
|
8827
|
-
external_exports.object({}).strict().parse(
|
|
9536
|
+
"room.list": { auth: true, run: (params2) => {
|
|
9537
|
+
external_exports.object({}).strict().parse(params2);
|
|
8828
9538
|
return service.listRooms();
|
|
8829
9539
|
} },
|
|
8830
|
-
"room.show": { auth: true, run: (
|
|
8831
|
-
"room.participants": { auth: true, run: (
|
|
8832
|
-
"room.history": { auth: true, run: (
|
|
8833
|
-
const { room_id, ...options } = HistoryParams.parse(
|
|
9540
|
+
"room.show": { auth: true, run: (params2) => service.showRoom(RoomIdParams.parse(params2).room_id) },
|
|
9541
|
+
"room.participants": { auth: true, run: (params2) => service.participants(RoomIdParams.parse(params2).room_id) },
|
|
9542
|
+
"room.history": { auth: true, run: (params2) => {
|
|
9543
|
+
const { room_id, ...options } = HistoryParams.parse(params2);
|
|
8834
9544
|
return service.history(room_id, options);
|
|
8835
9545
|
} },
|
|
8836
|
-
"room.message": { auth: true, run: (
|
|
8837
|
-
const { room_id, ...input } = external_exports.object({ room_id: external_exports.string(), text: external_exports.unknown() }).strict().parse(
|
|
9546
|
+
"room.message": { auth: true, run: (params2) => {
|
|
9547
|
+
const { room_id, ...input } = external_exports.object({ room_id: external_exports.string(), text: external_exports.unknown() }).strict().parse(params2);
|
|
8838
9548
|
return service.postMessage(room_id, input);
|
|
8839
9549
|
} },
|
|
8840
|
-
"room.close": { auth: true, run: (
|
|
8841
|
-
"room.delete": { auth: true, run: (
|
|
8842
|
-
const { room_id, ...input } = external_exports.object({ room_id: external_exports.string(), confirm: external_exports.unknown() }).strict().parse(
|
|
9550
|
+
"room.close": { auth: true, run: (params2) => service.closeRoom(RoomIdParams.parse(params2).room_id) },
|
|
9551
|
+
"room.delete": { auth: true, run: (params2) => {
|
|
9552
|
+
const { room_id, ...input } = external_exports.object({ room_id: external_exports.string(), confirm: external_exports.unknown() }).strict().parse(params2);
|
|
8843
9553
|
return service.deleteRoom(room_id, input);
|
|
8844
9554
|
} }
|
|
8845
9555
|
};
|
|
8846
9556
|
}
|
|
8847
9557
|
function createPrivateServiceRoutes(service) {
|
|
8848
9558
|
return {
|
|
8849
|
-
"room.accept": { auth: true, run: (
|
|
8850
|
-
const { room_id, ...input } = ExternalInviteAcceptParams.parse(
|
|
9559
|
+
"room.accept": { auth: true, run: (params2) => {
|
|
9560
|
+
const { room_id, ...input } = ExternalInviteAcceptParams.parse(params2);
|
|
8851
9561
|
return service.acceptExternalInvite(room_id, input);
|
|
8852
9562
|
} }
|
|
8853
9563
|
};
|
|
@@ -8867,6 +9577,23 @@ function isJsonMediaType(value) {
|
|
|
8867
9577
|
const mediaType = value.split(";", 1)[0]?.trim().toLowerCase();
|
|
8868
9578
|
return mediaType === "application/json" || mediaType?.startsWith("application/") === true && mediaType.endsWith("+json");
|
|
8869
9579
|
}
|
|
9580
|
+
async function serveApiDocs(request, response) {
|
|
9581
|
+
const pathname = safePathname(request.url);
|
|
9582
|
+
if (pathname === void 0) return false;
|
|
9583
|
+
const asset = apiDocsAsset(pathname);
|
|
9584
|
+
if (!asset) return false;
|
|
9585
|
+
const body = Buffer.from(asset.body, "utf8");
|
|
9586
|
+
response.writeHead(200, {
|
|
9587
|
+
"content-type": asset.contentType,
|
|
9588
|
+
"content-length": body.length,
|
|
9589
|
+
"cache-control": "no-cache",
|
|
9590
|
+
"content-security-policy": CONTENT_SECURITY_POLICY,
|
|
9591
|
+
"x-content-type-options": "nosniff"
|
|
9592
|
+
});
|
|
9593
|
+
response.end(body);
|
|
9594
|
+
await responseFinished2(response);
|
|
9595
|
+
return true;
|
|
9596
|
+
}
|
|
8870
9597
|
function sendJson(response, status, value) {
|
|
8871
9598
|
const body = Buffer.from(JSON.stringify(value), "utf8");
|
|
8872
9599
|
response.writeHead(status, {
|
|
@@ -8984,6 +9711,7 @@ var init_transports = __esm({
|
|
|
8984
9711
|
"src/transports.ts"() {
|
|
8985
9712
|
"use strict";
|
|
8986
9713
|
init_zod();
|
|
9714
|
+
init_openapi();
|
|
8987
9715
|
init_web();
|
|
8988
9716
|
MAX_REQUEST_BYTES = 1024 * 1024;
|
|
8989
9717
|
HTTP_HEADERS_TIMEOUT_MS = 5e3;
|
|
@@ -9250,6 +9978,7 @@ var init_transports = __esm({
|
|
|
9250
9978
|
if (request.url !== "/rpc") {
|
|
9251
9979
|
if (request.method === "GET") {
|
|
9252
9980
|
activateResponse();
|
|
9981
|
+
if (await serveApiDocs(request, response)) return;
|
|
9253
9982
|
if (await this.staticHandler(request, response)) return;
|
|
9254
9983
|
}
|
|
9255
9984
|
activateResponse();
|
|
@@ -9514,16 +10243,16 @@ function isIntakeNotification(event) {
|
|
|
9514
10243
|
}
|
|
9515
10244
|
function createDaemonControlRoutes(control) {
|
|
9516
10245
|
if (!/^[0-9a-f]{32}$/.test(control.session)) throw new TypeError("invalid daemon control session");
|
|
9517
|
-
const requireExact = (
|
|
9518
|
-
if (Object.keys(
|
|
10246
|
+
const requireExact = (params2, keys) => {
|
|
10247
|
+
if (Object.keys(params2).length !== keys.length || keys.some((key) => !Object.hasOwn(params2, key))) {
|
|
9519
10248
|
throw new TypeError("invalid daemon control parameters");
|
|
9520
10249
|
}
|
|
9521
10250
|
};
|
|
9522
10251
|
return {
|
|
9523
10252
|
"daemon.status": {
|
|
9524
10253
|
auth: true,
|
|
9525
|
-
run(
|
|
9526
|
-
requireExact(
|
|
10254
|
+
run(params2) {
|
|
10255
|
+
requireExact(params2, []);
|
|
9527
10256
|
return {
|
|
9528
10257
|
version: 1,
|
|
9529
10258
|
protocol: "cowork-supervisor-control",
|
|
@@ -9534,9 +10263,9 @@ function createDaemonControlRoutes(control) {
|
|
|
9534
10263
|
},
|
|
9535
10264
|
"daemon.shutdown": {
|
|
9536
10265
|
auth: true,
|
|
9537
|
-
async run(
|
|
9538
|
-
requireExact(
|
|
9539
|
-
if (
|
|
10266
|
+
async run(params2) {
|
|
10267
|
+
requireExact(params2, ["session"]);
|
|
10268
|
+
if (params2.session !== control.session) throw new TypeError("daemon control session changed");
|
|
9540
10269
|
if (!await control.requestSupervisorShutdown()) throw new Error("supervisor IPC rejected shutdown request");
|
|
9541
10270
|
return { accepted: true, session: control.session };
|
|
9542
10271
|
}
|