@segmentstream/ontology 0.125.0 → 0.127.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/CHANGELOG.md +20 -0
- package/dist/analyze.js +4 -17
- package/dist/app-feedback.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/manifest.d.ts +405 -9
- package/dist/manifest.js +29 -2
- package/dist/migrate/model.d.ts +230 -6
- package/dist/service/caller-where.d.ts +19 -0
- package/dist/service/caller-where.js +126 -0
- package/dist/service/mcp/find-input.js +2 -1
- package/dist/service/mcp/server.js +11 -4
- package/dist/service/schemas.d.ts +56 -0
- package/dist/service/webhooks.d.ts +22 -6
- package/dist/service/webhooks.js +131 -50
- package/dist/service/workflows.js +8 -6
- package/dist/webhooks.d.ts +105 -2
- package/dist/webhooks.js +293 -2
- package/dist/workflow.d.ts +10 -5
- package/dist/workflows.d.ts +1 -1
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
|
@@ -94,6 +94,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
|
|
|
94
94
|
* `roles` whose people's private chats the agent registers as `agent_chat` records of kind
|
|
95
95
|
* `private`, and in `takeover.channels` the channels whose chats staff may take over from the
|
|
96
96
|
* agent. Older readers ignore it, register none and let none be taken over.
|
|
97
|
+
* Within version 15, a webhook trigger's `signature` may have scheme `hmac` and carry the provider's
|
|
98
|
+
* format, written only when declared. Older readers present the scheme and ignore the format; an
|
|
99
|
+
* older publication check refuses the scheme.
|
|
97
100
|
*/
|
|
98
101
|
export const MANIFEST_VERSION = 15;
|
|
99
102
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -338,13 +341,37 @@ export const ActionTriggerManifest = Schema.Struct({
|
|
|
338
341
|
* scheme against the named workspace secret; without it, the URL ends in a derived token.
|
|
339
342
|
* `verification` opts into a registration handshake; `headers` lists the request headers the
|
|
340
343
|
* delivery carries; `connection` names the connection whose provider sends to it. Optional
|
|
341
|
-
* settings are written only when declared.
|
|
344
|
+
* settings are written only when declared. A signature of scheme `hmac` carries its format:
|
|
345
|
+
* `algorithm`, `encoding`, `key`, `signatures`, `timestamp` and `message`.
|
|
342
346
|
*/
|
|
343
347
|
export const WebhookTriggerManifest = Schema.Struct({
|
|
344
348
|
kind: Schema.Literal("webhook"),
|
|
345
349
|
name: Schema.String,
|
|
346
350
|
description: Schema.String,
|
|
347
|
-
signature: Schema.optionalKey(Schema.Struct({
|
|
351
|
+
signature: Schema.optionalKey(Schema.Struct({
|
|
352
|
+
scheme: Schema.String,
|
|
353
|
+
secret: Schema.String,
|
|
354
|
+
algorithm: Schema.optionalKey(Schema.String),
|
|
355
|
+
encoding: Schema.optionalKey(Schema.String),
|
|
356
|
+
key: Schema.optionalKey(Schema.Struct({ decode: Schema.String, prefix: Schema.optionalKey(Schema.String) })),
|
|
357
|
+
signatures: Schema.optionalKey(Schema.Struct({
|
|
358
|
+
header: Schema.String,
|
|
359
|
+
prefix: Schema.optionalKey(Schema.String),
|
|
360
|
+
entries: Schema.optionalKey(Schema.Struct({ separator: Schema.String, assign: Schema.String, name: Schema.String })),
|
|
361
|
+
})),
|
|
362
|
+
timestamp: Schema.optionalKey(Schema.Struct({
|
|
363
|
+
header: Schema.optionalKey(Schema.String),
|
|
364
|
+
entry: Schema.optionalKey(Schema.String),
|
|
365
|
+
unit: Schema.optionalKey(Schema.String),
|
|
366
|
+
tolerance: Schema.optionalKey(Schema.Number),
|
|
367
|
+
})),
|
|
368
|
+
message: Schema.optionalKey(Schema.Array(Schema.Union([
|
|
369
|
+
Schema.String,
|
|
370
|
+
Schema.Struct({ body: Schema.Literal(true) }),
|
|
371
|
+
Schema.Struct({ header: Schema.String }),
|
|
372
|
+
Schema.Struct({ timestamp: Schema.Literal(true) }),
|
|
373
|
+
]))),
|
|
374
|
+
})),
|
|
348
375
|
verification: Schema.optionalKey(Schema.Struct({ scheme: Schema.String, verifyToken: Schema.String })),
|
|
349
376
|
headers: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
350
377
|
/** The key of the connection whose provider sends to the webhook, when declared. */
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -416,8 +416,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
416
416
|
};
|
|
417
417
|
} | undefined;
|
|
418
418
|
readonly attribution?: {
|
|
419
|
-
readonly template?: string | undefined;
|
|
420
419
|
readonly separator?: string | undefined;
|
|
420
|
+
readonly template?: string | undefined;
|
|
421
421
|
} | undefined;
|
|
422
422
|
} | undefined;
|
|
423
423
|
readonly workflows?: readonly {
|
|
@@ -449,6 +449,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
449
449
|
readonly signature?: {
|
|
450
450
|
readonly scheme: string;
|
|
451
451
|
readonly secret: string;
|
|
452
|
+
readonly message?: readonly (string | {
|
|
453
|
+
readonly body: true;
|
|
454
|
+
} | {
|
|
455
|
+
readonly header: string;
|
|
456
|
+
} | {
|
|
457
|
+
readonly timestamp: true;
|
|
458
|
+
})[] | undefined;
|
|
459
|
+
readonly key?: {
|
|
460
|
+
readonly decode: string;
|
|
461
|
+
readonly prefix?: string | undefined;
|
|
462
|
+
} | undefined;
|
|
463
|
+
readonly timestamp?: {
|
|
464
|
+
readonly unit?: string | undefined;
|
|
465
|
+
readonly entry?: string | undefined;
|
|
466
|
+
readonly tolerance?: number | undefined;
|
|
467
|
+
readonly header?: string | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
readonly algorithm?: string | undefined;
|
|
470
|
+
readonly encoding?: string | undefined;
|
|
471
|
+
readonly signatures?: {
|
|
472
|
+
readonly header: string;
|
|
473
|
+
readonly entries?: {
|
|
474
|
+
readonly separator: string;
|
|
475
|
+
readonly assign: string;
|
|
476
|
+
readonly name: string;
|
|
477
|
+
} | undefined;
|
|
478
|
+
readonly prefix?: string | undefined;
|
|
479
|
+
} | undefined;
|
|
452
480
|
} | undefined;
|
|
453
481
|
readonly verification?: {
|
|
454
482
|
readonly scheme: string;
|
|
@@ -736,8 +764,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
736
764
|
};
|
|
737
765
|
} | undefined;
|
|
738
766
|
readonly attribution?: {
|
|
739
|
-
readonly template?: string | undefined;
|
|
740
767
|
readonly separator?: string | undefined;
|
|
768
|
+
readonly template?: string | undefined;
|
|
741
769
|
} | undefined;
|
|
742
770
|
} | undefined;
|
|
743
771
|
readonly workflows?: readonly {
|
|
@@ -769,6 +797,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
769
797
|
readonly signature?: {
|
|
770
798
|
readonly scheme: string;
|
|
771
799
|
readonly secret: string;
|
|
800
|
+
readonly message?: readonly (string | {
|
|
801
|
+
readonly body: true;
|
|
802
|
+
} | {
|
|
803
|
+
readonly header: string;
|
|
804
|
+
} | {
|
|
805
|
+
readonly timestamp: true;
|
|
806
|
+
})[] | undefined;
|
|
807
|
+
readonly key?: {
|
|
808
|
+
readonly decode: string;
|
|
809
|
+
readonly prefix?: string | undefined;
|
|
810
|
+
} | undefined;
|
|
811
|
+
readonly timestamp?: {
|
|
812
|
+
readonly unit?: string | undefined;
|
|
813
|
+
readonly entry?: string | undefined;
|
|
814
|
+
readonly tolerance?: number | undefined;
|
|
815
|
+
readonly header?: string | undefined;
|
|
816
|
+
} | undefined;
|
|
817
|
+
readonly algorithm?: string | undefined;
|
|
818
|
+
readonly encoding?: string | undefined;
|
|
819
|
+
readonly signatures?: {
|
|
820
|
+
readonly header: string;
|
|
821
|
+
readonly entries?: {
|
|
822
|
+
readonly separator: string;
|
|
823
|
+
readonly assign: string;
|
|
824
|
+
readonly name: string;
|
|
825
|
+
} | undefined;
|
|
826
|
+
readonly prefix?: string | undefined;
|
|
827
|
+
} | undefined;
|
|
772
828
|
} | undefined;
|
|
773
829
|
readonly verification?: {
|
|
774
830
|
readonly scheme: string;
|
|
@@ -1056,8 +1112,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1056
1112
|
};
|
|
1057
1113
|
} | undefined;
|
|
1058
1114
|
readonly attribution?: {
|
|
1059
|
-
readonly template?: string | undefined;
|
|
1060
1115
|
readonly separator?: string | undefined;
|
|
1116
|
+
readonly template?: string | undefined;
|
|
1061
1117
|
} | undefined;
|
|
1062
1118
|
} | undefined;
|
|
1063
1119
|
readonly workflows?: readonly {
|
|
@@ -1091,6 +1147,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1091
1147
|
readonly signature?: {
|
|
1092
1148
|
readonly scheme: string;
|
|
1093
1149
|
readonly secret: string;
|
|
1150
|
+
readonly message?: readonly (string | {
|
|
1151
|
+
readonly body: true;
|
|
1152
|
+
} | {
|
|
1153
|
+
readonly header: string;
|
|
1154
|
+
} | {
|
|
1155
|
+
readonly timestamp: true;
|
|
1156
|
+
})[] | undefined;
|
|
1157
|
+
readonly key?: {
|
|
1158
|
+
readonly decode: string;
|
|
1159
|
+
readonly prefix?: string | undefined;
|
|
1160
|
+
} | undefined;
|
|
1161
|
+
readonly timestamp?: {
|
|
1162
|
+
readonly unit?: string | undefined;
|
|
1163
|
+
readonly entry?: string | undefined;
|
|
1164
|
+
readonly tolerance?: number | undefined;
|
|
1165
|
+
readonly header?: string | undefined;
|
|
1166
|
+
} | undefined;
|
|
1167
|
+
readonly algorithm?: string | undefined;
|
|
1168
|
+
readonly encoding?: string | undefined;
|
|
1169
|
+
readonly signatures?: {
|
|
1170
|
+
readonly header: string;
|
|
1171
|
+
readonly entries?: {
|
|
1172
|
+
readonly separator: string;
|
|
1173
|
+
readonly assign: string;
|
|
1174
|
+
readonly name: string;
|
|
1175
|
+
} | undefined;
|
|
1176
|
+
readonly prefix?: string | undefined;
|
|
1177
|
+
} | undefined;
|
|
1094
1178
|
} | undefined;
|
|
1095
1179
|
readonly verification?: {
|
|
1096
1180
|
readonly scheme: string;
|
|
@@ -1376,8 +1460,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1376
1460
|
};
|
|
1377
1461
|
} | undefined;
|
|
1378
1462
|
readonly attribution?: {
|
|
1379
|
-
readonly template?: string | undefined;
|
|
1380
1463
|
readonly separator?: string | undefined;
|
|
1464
|
+
readonly template?: string | undefined;
|
|
1381
1465
|
} | undefined;
|
|
1382
1466
|
} | undefined;
|
|
1383
1467
|
readonly workflows?: readonly {
|
|
@@ -1411,6 +1495,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1411
1495
|
readonly signature?: {
|
|
1412
1496
|
readonly scheme: string;
|
|
1413
1497
|
readonly secret: string;
|
|
1498
|
+
readonly message?: readonly (string | {
|
|
1499
|
+
readonly body: true;
|
|
1500
|
+
} | {
|
|
1501
|
+
readonly header: string;
|
|
1502
|
+
} | {
|
|
1503
|
+
readonly timestamp: true;
|
|
1504
|
+
})[] | undefined;
|
|
1505
|
+
readonly key?: {
|
|
1506
|
+
readonly decode: string;
|
|
1507
|
+
readonly prefix?: string | undefined;
|
|
1508
|
+
} | undefined;
|
|
1509
|
+
readonly timestamp?: {
|
|
1510
|
+
readonly unit?: string | undefined;
|
|
1511
|
+
readonly entry?: string | undefined;
|
|
1512
|
+
readonly tolerance?: number | undefined;
|
|
1513
|
+
readonly header?: string | undefined;
|
|
1514
|
+
} | undefined;
|
|
1515
|
+
readonly algorithm?: string | undefined;
|
|
1516
|
+
readonly encoding?: string | undefined;
|
|
1517
|
+
readonly signatures?: {
|
|
1518
|
+
readonly header: string;
|
|
1519
|
+
readonly entries?: {
|
|
1520
|
+
readonly separator: string;
|
|
1521
|
+
readonly assign: string;
|
|
1522
|
+
readonly name: string;
|
|
1523
|
+
} | undefined;
|
|
1524
|
+
readonly prefix?: string | undefined;
|
|
1525
|
+
} | undefined;
|
|
1414
1526
|
} | undefined;
|
|
1415
1527
|
readonly verification?: {
|
|
1416
1528
|
readonly scheme: string;
|
|
@@ -1846,6 +1958,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1846
1958
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
1847
1959
|
readonly scheme: Schema.String;
|
|
1848
1960
|
readonly secret: Schema.String;
|
|
1961
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
1962
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
1963
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
1964
|
+
readonly decode: Schema.String;
|
|
1965
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
1966
|
+
}>>;
|
|
1967
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
1968
|
+
readonly header: Schema.String;
|
|
1969
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
1970
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
1971
|
+
readonly separator: Schema.String;
|
|
1972
|
+
readonly assign: Schema.String;
|
|
1973
|
+
readonly name: Schema.String;
|
|
1974
|
+
}>>;
|
|
1975
|
+
}>>;
|
|
1976
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
1977
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
1978
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
1979
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
1980
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
1981
|
+
}>>;
|
|
1982
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
1983
|
+
readonly body: Schema.Literal<true>;
|
|
1984
|
+
}>, Schema.Struct<{
|
|
1985
|
+
readonly header: Schema.String;
|
|
1986
|
+
}>, Schema.Struct<{
|
|
1987
|
+
readonly timestamp: Schema.Literal<true>;
|
|
1988
|
+
}>]>>>;
|
|
1849
1989
|
}>>;
|
|
1850
1990
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
1851
1991
|
readonly scheme: Schema.String;
|
|
@@ -2162,6 +2302,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2162
2302
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
2163
2303
|
readonly scheme: Schema.String;
|
|
2164
2304
|
readonly secret: Schema.String;
|
|
2305
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
2306
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
2307
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
2308
|
+
readonly decode: Schema.String;
|
|
2309
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
2310
|
+
}>>;
|
|
2311
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
2312
|
+
readonly header: Schema.String;
|
|
2313
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
2314
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
2315
|
+
readonly separator: Schema.String;
|
|
2316
|
+
readonly assign: Schema.String;
|
|
2317
|
+
readonly name: Schema.String;
|
|
2318
|
+
}>>;
|
|
2319
|
+
}>>;
|
|
2320
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
2321
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
2322
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
2323
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
2324
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
2325
|
+
}>>;
|
|
2326
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
2327
|
+
readonly body: Schema.Literal<true>;
|
|
2328
|
+
}>, Schema.Struct<{
|
|
2329
|
+
readonly header: Schema.String;
|
|
2330
|
+
}>, Schema.Struct<{
|
|
2331
|
+
readonly timestamp: Schema.Literal<true>;
|
|
2332
|
+
}>]>>>;
|
|
2165
2333
|
}>>;
|
|
2166
2334
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
2167
2335
|
readonly scheme: Schema.String;
|
|
@@ -2341,8 +2509,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2341
2509
|
};
|
|
2342
2510
|
} | undefined;
|
|
2343
2511
|
readonly attribution?: {
|
|
2344
|
-
readonly template?: string | undefined;
|
|
2345
2512
|
readonly separator?: string | undefined;
|
|
2513
|
+
readonly template?: string | undefined;
|
|
2346
2514
|
} | undefined;
|
|
2347
2515
|
} | undefined;
|
|
2348
2516
|
readonly workflows?: readonly {
|
|
@@ -2374,6 +2542,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2374
2542
|
readonly signature?: {
|
|
2375
2543
|
readonly scheme: string;
|
|
2376
2544
|
readonly secret: string;
|
|
2545
|
+
readonly message?: readonly (string | {
|
|
2546
|
+
readonly body: true;
|
|
2547
|
+
} | {
|
|
2548
|
+
readonly header: string;
|
|
2549
|
+
} | {
|
|
2550
|
+
readonly timestamp: true;
|
|
2551
|
+
})[] | undefined;
|
|
2552
|
+
readonly key?: {
|
|
2553
|
+
readonly decode: string;
|
|
2554
|
+
readonly prefix?: string | undefined;
|
|
2555
|
+
} | undefined;
|
|
2556
|
+
readonly timestamp?: {
|
|
2557
|
+
readonly unit?: string | undefined;
|
|
2558
|
+
readonly entry?: string | undefined;
|
|
2559
|
+
readonly tolerance?: number | undefined;
|
|
2560
|
+
readonly header?: string | undefined;
|
|
2561
|
+
} | undefined;
|
|
2562
|
+
readonly algorithm?: string | undefined;
|
|
2563
|
+
readonly encoding?: string | undefined;
|
|
2564
|
+
readonly signatures?: {
|
|
2565
|
+
readonly header: string;
|
|
2566
|
+
readonly entries?: {
|
|
2567
|
+
readonly separator: string;
|
|
2568
|
+
readonly assign: string;
|
|
2569
|
+
readonly name: string;
|
|
2570
|
+
} | undefined;
|
|
2571
|
+
readonly prefix?: string | undefined;
|
|
2572
|
+
} | undefined;
|
|
2377
2573
|
} | undefined;
|
|
2378
2574
|
readonly verification?: {
|
|
2379
2575
|
readonly scheme: string;
|
|
@@ -2661,8 +2857,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2661
2857
|
};
|
|
2662
2858
|
} | undefined;
|
|
2663
2859
|
readonly attribution?: {
|
|
2664
|
-
readonly template?: string | undefined;
|
|
2665
2860
|
readonly separator?: string | undefined;
|
|
2861
|
+
readonly template?: string | undefined;
|
|
2666
2862
|
} | undefined;
|
|
2667
2863
|
} | undefined;
|
|
2668
2864
|
readonly workflows?: readonly {
|
|
@@ -2694,6 +2890,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2694
2890
|
readonly signature?: {
|
|
2695
2891
|
readonly scheme: string;
|
|
2696
2892
|
readonly secret: string;
|
|
2893
|
+
readonly message?: readonly (string | {
|
|
2894
|
+
readonly body: true;
|
|
2895
|
+
} | {
|
|
2896
|
+
readonly header: string;
|
|
2897
|
+
} | {
|
|
2898
|
+
readonly timestamp: true;
|
|
2899
|
+
})[] | undefined;
|
|
2900
|
+
readonly key?: {
|
|
2901
|
+
readonly decode: string;
|
|
2902
|
+
readonly prefix?: string | undefined;
|
|
2903
|
+
} | undefined;
|
|
2904
|
+
readonly timestamp?: {
|
|
2905
|
+
readonly unit?: string | undefined;
|
|
2906
|
+
readonly entry?: string | undefined;
|
|
2907
|
+
readonly tolerance?: number | undefined;
|
|
2908
|
+
readonly header?: string | undefined;
|
|
2909
|
+
} | undefined;
|
|
2910
|
+
readonly algorithm?: string | undefined;
|
|
2911
|
+
readonly encoding?: string | undefined;
|
|
2912
|
+
readonly signatures?: {
|
|
2913
|
+
readonly header: string;
|
|
2914
|
+
readonly entries?: {
|
|
2915
|
+
readonly separator: string;
|
|
2916
|
+
readonly assign: string;
|
|
2917
|
+
readonly name: string;
|
|
2918
|
+
} | undefined;
|
|
2919
|
+
readonly prefix?: string | undefined;
|
|
2920
|
+
} | undefined;
|
|
2697
2921
|
} | undefined;
|
|
2698
2922
|
readonly verification?: {
|
|
2699
2923
|
readonly scheme: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OntologyManifest } from "../manifest.js";
|
|
2
|
+
/**
|
|
3
|
+
* `{ "$me": [] }` in the `where` of a find, as a role scope writes the caller: the caller's user id.
|
|
4
|
+
* A to-one relationship compared with it, bare or with `eq`, `ne` or `in`, reads its
|
|
5
|
+
* `<relationship>_id` key (`{ "reporter": { "$me": [] } }` is `{ "reporter_id": "<id>" }`), so the
|
|
6
|
+
* filter reads no `user` record and needs no `user:read`. Any other value it stands in is the id
|
|
7
|
+
* itself, such as `{ "created_by": { "$me": [] } }`. A path from it is a role scope's only: it is
|
|
8
|
+
* refused, since a find compares values, not the sets a path reaches.
|
|
9
|
+
*
|
|
10
|
+
* Runs on the arguments as sent, before the query schema decodes them, and returns a `where`
|
|
11
|
+
* without markers unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveCallerInWhere(manifest: OntologyManifest, entity: string, where: unknown, callerId: string): {
|
|
14
|
+
readonly where: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
readonly refused: ReadonlyArray<string | number>;
|
|
17
|
+
};
|
|
18
|
+
/** The message of a refused path from `me` in a find. */
|
|
19
|
+
export declare const CALLER_PATH_REFUSED = "A find compares with { \"$me\": [] }, the caller's user id; paths from it are for role scopes.";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { mePathOf } from "../me.js";
|
|
2
|
+
import { FILTER_OPERATORS, findEntityManifest, MANY_QUANTIFIERS, queryFields, queryLinks, } from "../query.js";
|
|
3
|
+
/**
|
|
4
|
+
* `{ "$me": [] }` in the `where` of a find, as a role scope writes the caller: the caller's user id.
|
|
5
|
+
* A to-one relationship compared with it, bare or with `eq`, `ne` or `in`, reads its
|
|
6
|
+
* `<relationship>_id` key (`{ "reporter": { "$me": [] } }` is `{ "reporter_id": "<id>" }`), so the
|
|
7
|
+
* filter reads no `user` record and needs no `user:read`. Any other value it stands in is the id
|
|
8
|
+
* itself, such as `{ "created_by": { "$me": [] } }`. A path from it is a role scope's only: it is
|
|
9
|
+
* refused, since a find compares values, not the sets a path reaches.
|
|
10
|
+
*
|
|
11
|
+
* Runs on the arguments as sent, before the query schema decodes them, and returns a `where`
|
|
12
|
+
* without markers unchanged.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveCallerInWhere(manifest, entity, where, callerId) {
|
|
15
|
+
if (!holdsMarker(where)) {
|
|
16
|
+
return { where };
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
return { where: resolveWhere(manifest, entity, where, callerId, ["where"]) };
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof PathRefused) {
|
|
23
|
+
return { refused: error.path };
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** The message of a refused path from `me` in a find. */
|
|
29
|
+
export const CALLER_PATH_REFUSED = 'A find compares with { "$me": [] }, the caller\'s user id; paths from it are for role scopes.';
|
|
30
|
+
class PathRefused extends Error {
|
|
31
|
+
path;
|
|
32
|
+
constructor(path) {
|
|
33
|
+
super(CALLER_PATH_REFUSED);
|
|
34
|
+
this.path = path;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const OPERATORS = new Set(FILTER_OPERATORS);
|
|
38
|
+
const QUANTIFIERS = new Set(MANY_QUANTIFIERS);
|
|
39
|
+
function isPlainObject(value) {
|
|
40
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
}
|
|
42
|
+
function holdsMarker(value) {
|
|
43
|
+
if (mePathOf(value) !== undefined) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
return value.some(holdsMarker);
|
|
48
|
+
}
|
|
49
|
+
return isPlainObject(value) && Object.values(value).some(holdsMarker);
|
|
50
|
+
}
|
|
51
|
+
/** A bare `me` or an object of operators comparing with it: what a key field takes. */
|
|
52
|
+
function comparesCaller(condition) {
|
|
53
|
+
if (mePathOf(condition) !== undefined) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return (isPlainObject(condition) &&
|
|
57
|
+
Object.keys(condition).length > 0 &&
|
|
58
|
+
Object.keys(condition).every((key) => OPERATORS.has(key)) &&
|
|
59
|
+
holdsMarker(condition));
|
|
60
|
+
}
|
|
61
|
+
function resolveValue(value, callerId, path) {
|
|
62
|
+
const hops = mePathOf(value);
|
|
63
|
+
if (hops !== undefined) {
|
|
64
|
+
if (hops.length > 0) {
|
|
65
|
+
throw new PathRefused(path);
|
|
66
|
+
}
|
|
67
|
+
return callerId;
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
return value.map((item, index) => resolveValue(item, callerId, [...path, index]));
|
|
71
|
+
}
|
|
72
|
+
if (isPlainObject(value)) {
|
|
73
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
74
|
+
key,
|
|
75
|
+
resolveValue(item, callerId, [...path, key]),
|
|
76
|
+
]));
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
function resolveWhere(manifest, entityName, where, callerId, path) {
|
|
81
|
+
const entity = findEntityManifest(manifest, entityName);
|
|
82
|
+
if (entity === undefined || !isPlainObject(where) || mePathOf(where) !== undefined) {
|
|
83
|
+
return where;
|
|
84
|
+
}
|
|
85
|
+
const keys = new Set(queryFields(entity).map((field) => field.name));
|
|
86
|
+
const links = new Map(queryLinks(manifest, entityName, true).map((link) => [link.name, link]));
|
|
87
|
+
const entries = [];
|
|
88
|
+
for (const [key, condition] of Object.entries(where)) {
|
|
89
|
+
const at = [...path, key];
|
|
90
|
+
const link = links.get(key);
|
|
91
|
+
if ((key === "and" || key === "or") && Array.isArray(condition)) {
|
|
92
|
+
entries.push([
|
|
93
|
+
key,
|
|
94
|
+
condition.map((sub, index) => resolveWhere(manifest, entityName, sub, callerId, [...at, index])),
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
else if (key === "not") {
|
|
98
|
+
entries.push([key, resolveWhere(manifest, entityName, condition, callerId, at)]);
|
|
99
|
+
}
|
|
100
|
+
else if (link === undefined || !holdsMarker(condition)) {
|
|
101
|
+
entries.push([key, resolveValue(condition, callerId, at)]);
|
|
102
|
+
}
|
|
103
|
+
else if (link.cardinality === "one" && keys.has(`${key}_id`) && comparesCaller(condition)) {
|
|
104
|
+
entries.push([`${key}_id`, resolveValue(condition, callerId, at)]);
|
|
105
|
+
}
|
|
106
|
+
else if (link.cardinality === "many" &&
|
|
107
|
+
isPlainObject(condition) &&
|
|
108
|
+
Object.keys(condition).every((quantifier) => QUANTIFIERS.has(quantifier))) {
|
|
109
|
+
entries.push([
|
|
110
|
+
key,
|
|
111
|
+
Object.fromEntries(Object.entries(condition).map(([quantifier, sub]) => [
|
|
112
|
+
quantifier,
|
|
113
|
+
resolveWhere(manifest, link.target, sub, callerId, [...at, quantifier]),
|
|
114
|
+
])),
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
entries.push([key, resolveWhere(manifest, link.target, condition, callerId, at)]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const names = entries.map(([key]) => key);
|
|
122
|
+
// `{ reporter: me, reporter_id: … }` names the key twice: both conditions must hold.
|
|
123
|
+
return new Set(names).size === names.length
|
|
124
|
+
? Object.fromEntries(entries)
|
|
125
|
+
: { and: entries.map(([key, condition]) => ({ [key]: condition })) };
|
|
126
|
+
}
|
|
@@ -52,7 +52,8 @@ export const FIND_CONDITIONS = "where: a field takes a bare value (eq), null (is
|
|
|
52
52
|
"dates and timestamps also gt, gte, lt, lte and between [from, to], which includes both ends. " +
|
|
53
53
|
"ne also matches empty values. Dates are YYYY-MM-DD. A relationship takes conditions on its " +
|
|
54
54
|
"target's fields, one level deep; a to-many one wraps them in some, none or every. and and or " +
|
|
55
|
-
|
|
55
|
+
'take lists of conditions; not takes one. {"$me": []} is the caller\'s user id, also for a ' +
|
|
56
|
+
'to-one relationship: {"owner": {"$me": []}}. Unknown fields and operators are refused.';
|
|
56
57
|
// Clients that shorten schema descriptions keep this first sentence.
|
|
57
58
|
const WHERE_DESCRIPTION = "Operators: eq, ne, in, is_null; text contains, starts_with; ordered gt, gte, lt, lte, " +
|
|
58
59
|
"between. All conditions must hold; the tool description has the rules.";
|
|
@@ -8,6 +8,7 @@ import { encodeManifest } from "../../manifest.js";
|
|
|
8
8
|
import { describeError, SCOPE_MISMATCH } from "../metric-query-platform.js";
|
|
9
9
|
import { gatewayCredential, gatewayDecisions } from "../decisions.js";
|
|
10
10
|
import { CurrentPrincipal, withPrincipal } from "../authentication.js";
|
|
11
|
+
import { CALLER_PATH_REFUSED, resolveCallerInWhere } from "../caller-where.js";
|
|
11
12
|
import { currentCaller } from "../caller-context.js";
|
|
12
13
|
import { requireRuntimeOperation, runtimeManifest } from "./runtime-policy.js";
|
|
13
14
|
import { CONFIRMATION_PREVIEW_METHOD, previewLocale, withoutConfirmation } from "./confirmation.js";
|
|
@@ -427,7 +428,13 @@ function runTool(server, tool, args, request, preview) {
|
|
|
427
428
|
return structured(yield* chats.history(yield* decodeArguments(ChatHistory, args), identityToken(request)));
|
|
428
429
|
case "find": {
|
|
429
430
|
const schemas = built.schemas.get(target.planned.name);
|
|
430
|
-
const
|
|
431
|
+
const resolved = resolveCallerInWhere(built.plan.ontology.manifest, target.planned.name, args.where, (yield* CurrentPrincipal).id);
|
|
432
|
+
if ("refused" in resolved) {
|
|
433
|
+
return yield* new InvalidArguments({
|
|
434
|
+
issues: [{ path: resolved.refused, message: CALLER_PATH_REFUSED }],
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
const query = (yield* decodeArguments(schemas.query, args.where === undefined ? args : { ...args, where: resolved.where }));
|
|
431
438
|
const page = yield* operations.find(target.planned, toQuery(query));
|
|
432
439
|
return structured(yield* encoded(schemas.findResult, page));
|
|
433
440
|
}
|
|
@@ -627,8 +634,8 @@ export const FEEDBACK_INSTRUCTIONS = "Feedback: this app accepts feedback for it
|
|
|
627
634
|
"something works badly or asks for something new. Do not offer what you can do yourself; offer " +
|
|
628
635
|
"once per problem. Before submitting, look for the user's open app_feedback with the same " +
|
|
629
636
|
"subject. Submit with app_feedback_submit only after the user agrees to the title and summary you " +
|
|
630
|
-
"show in their language. When the user asks about their feedback, read only their own
|
|
631
|
-
|
|
637
|
+
"show in their language. When the user asks about their feedback, read only their own, since " +
|
|
638
|
+
'builders can read everyone\'s: app_feedback_find with where {"reporter": {"$me": []}}. Tell ' +
|
|
632
639
|
"them the builders' response, then call app_feedback_acknowledge with its responded_at.";
|
|
633
640
|
export const AUTOMATIC_FAILURE_REPORT_INSTRUCTIONS = "Feedback: During requested work, this workspace preauthorizes minimal technical failure reports. " +
|
|
634
641
|
"Automatically record unexpected or persistent tool/connection failures through app_feedback_submit; " +
|
|
@@ -638,7 +645,7 @@ export const AUTOMATIC_FAILURE_REPORT_INSTRUCTIONS = "Feedback: During requested
|
|
|
638
645
|
"and never claim it was recorded before a successful submission or existing-item read. " +
|
|
639
646
|
"Feature/change requests and sharing task contents or files still require the member's agreement " +
|
|
640
647
|
"to the title and summary. Asked about their feedback, read only the caller's own items " +
|
|
641
|
-
"
|
|
648
|
+
'(where {"reporter": {"$me": []}}) and acknowledge only the response you relayed.';
|
|
642
649
|
/**
|
|
643
650
|
* Fixed guidance keeps initialization independent of ontology size: the feedback paragraph depends
|
|
644
651
|
* only on whether the caller may run `app_feedback_submit`.
|
|
@@ -586,6 +586,34 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
586
586
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
587
587
|
readonly scheme: Schema.String;
|
|
588
588
|
readonly secret: Schema.String;
|
|
589
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
590
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
591
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
592
|
+
readonly decode: Schema.String;
|
|
593
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
594
|
+
}>>;
|
|
595
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
596
|
+
readonly header: Schema.String;
|
|
597
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
598
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
599
|
+
readonly separator: Schema.String;
|
|
600
|
+
readonly assign: Schema.String;
|
|
601
|
+
readonly name: Schema.String;
|
|
602
|
+
}>>;
|
|
603
|
+
}>>;
|
|
604
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
605
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
606
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
607
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
608
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
609
|
+
}>>;
|
|
610
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
611
|
+
readonly body: Schema.Literal<true>;
|
|
612
|
+
}>, Schema.Struct<{
|
|
613
|
+
readonly header: Schema.String;
|
|
614
|
+
}>, Schema.Struct<{
|
|
615
|
+
readonly timestamp: Schema.Literal<true>;
|
|
616
|
+
}>]>>>;
|
|
589
617
|
}>>;
|
|
590
618
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
591
619
|
readonly scheme: Schema.String;
|
|
@@ -915,6 +943,34 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
915
943
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
916
944
|
readonly scheme: Schema.String;
|
|
917
945
|
readonly secret: Schema.String;
|
|
946
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
947
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
948
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
949
|
+
readonly decode: Schema.String;
|
|
950
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
951
|
+
}>>;
|
|
952
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
953
|
+
readonly header: Schema.String;
|
|
954
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
955
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
956
|
+
readonly separator: Schema.String;
|
|
957
|
+
readonly assign: Schema.String;
|
|
958
|
+
readonly name: Schema.String;
|
|
959
|
+
}>>;
|
|
960
|
+
}>>;
|
|
961
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
962
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
963
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
964
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
965
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
966
|
+
}>>;
|
|
967
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
968
|
+
readonly body: Schema.Literal<true>;
|
|
969
|
+
}>, Schema.Struct<{
|
|
970
|
+
readonly header: Schema.String;
|
|
971
|
+
}>, Schema.Struct<{
|
|
972
|
+
readonly timestamp: Schema.Literal<true>;
|
|
973
|
+
}>]>>>;
|
|
918
974
|
}>>;
|
|
919
975
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
920
976
|
readonly scheme: Schema.String;
|