@segmentstream/ontology 0.96.0 → 0.97.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/README.md +11 -0
- package/dist/analyze.d.ts +8 -0
- package/dist/analyze.js +223 -14
- package/dist/bin/check.js +2 -0
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/manifest.d.ts +505 -2
- package/dist/manifest.js +55 -2
- package/dist/migrate/model.d.ts +272 -0
- package/dist/ontology.d.ts +3 -0
- package/dist/ontology.js +1 -0
- package/dist/service/catalog.js +10 -1
- package/dist/service/chat/envelope.d.ts +14 -14
- package/dist/service/connections.js +1 -0
- package/dist/service/discovery-search.d.ts +1 -1
- package/dist/service/mcp/server.js +13 -1
- package/dist/service/mcp/tools.d.ts +5 -0
- package/dist/service/mcp/tools.js +30 -0
- package/dist/service/operations.d.ts +3 -1
- package/dist/service/operations.js +3 -0
- package/dist/service/schemas.d.ts +62 -0
- package/dist/service/toolsets.d.ts +49 -0
- package/dist/service/toolsets.js +284 -0
- package/dist/toolset.d.ts +141 -0
- package/dist/toolset.js +154 -0
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
|
@@ -351,6 +351,23 @@ export const WorkflowManifest = Schema.Struct({
|
|
|
351
351
|
connections: Schema.Array(Schema.String),
|
|
352
352
|
triggers: Schema.Array(WorkflowTriggerManifest),
|
|
353
353
|
});
|
|
354
|
+
/**
|
|
355
|
+
* A provider's MCP tools the ontology serves, `defineOntology({ toolsets })`: the connection's MCP
|
|
356
|
+
* API, each tool's declared access and fixed values, and the action the catalog serves it as, whose
|
|
357
|
+
* `connections` is the toolset's connection. A toolset has no records.
|
|
358
|
+
*/
|
|
359
|
+
export const ToolsetManifest = Schema.Struct({
|
|
360
|
+
name: Schema.String,
|
|
361
|
+
description: Schema.String,
|
|
362
|
+
connection: Schema.String,
|
|
363
|
+
api: Schema.String,
|
|
364
|
+
tools: Schema.Array(Schema.Struct({
|
|
365
|
+
name: Schema.String,
|
|
366
|
+
access: Schema.Literals(["read", "write"]),
|
|
367
|
+
fixed: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Number, Schema.Boolean])),
|
|
368
|
+
})),
|
|
369
|
+
actions: Schema.Array(ActionManifest),
|
|
370
|
+
});
|
|
354
371
|
/** A workspace connection the ontology's actions call, by its key in `connections/connections.py`. */
|
|
355
372
|
export const ConnectionManifest = Schema.Struct({
|
|
356
373
|
key: Schema.String,
|
|
@@ -450,6 +467,11 @@ const OntologyManifestModel = Schema.Struct({
|
|
|
450
467
|
* The workflows, since version 9. Written only when there are some; absent reads as none.
|
|
451
468
|
*/
|
|
452
469
|
workflows: Schema.optionalKey(Schema.Array(WorkflowManifest)),
|
|
470
|
+
/**
|
|
471
|
+
* Provider MCP tools the ontology serves, within version 15. Written only when there are some;
|
|
472
|
+
* absent reads as none, and older readers ignore it.
|
|
473
|
+
*/
|
|
474
|
+
toolsets: Schema.optionalKey(Schema.Array(ToolsetManifest)),
|
|
453
475
|
});
|
|
454
476
|
/** A property in the snake_case wire spelling, for records that store definitions. */
|
|
455
477
|
export const PropertyManifestWire = PropertyManifest.pipe(Schema.encodeKeys({
|
|
@@ -731,6 +753,7 @@ function entityManifest(input) {
|
|
|
731
753
|
/** Builds the manifest of a resolved ontology that passed `check`. */
|
|
732
754
|
export function buildManifest(input) {
|
|
733
755
|
const connections = input.connections ?? [];
|
|
756
|
+
const toolsets = (input.toolsets ?? []).map(toolsetManifest);
|
|
734
757
|
const emails = input.emails ?? {};
|
|
735
758
|
const metrics = input.metrics ?? [];
|
|
736
759
|
const workflows = input.workflows ?? [];
|
|
@@ -794,12 +817,42 @@ export function buildManifest(input) {
|
|
|
794
817
|
: {}),
|
|
795
818
|
...(metrics.length > 0 ? { metrics } : {}),
|
|
796
819
|
...(workflows.length > 0 ? { workflows } : {}),
|
|
820
|
+
...(toolsets.length > 0 ? { toolsets } : {}),
|
|
797
821
|
};
|
|
798
822
|
return { ...body, hash: manifestHash(encodeManifest({ ...body, hash: "" })) };
|
|
799
823
|
}
|
|
800
|
-
/**
|
|
824
|
+
/** A checked toolset as the manifest lists it: its tools, and the action each is served as. */
|
|
825
|
+
export function toolsetManifest(resolved) {
|
|
826
|
+
return {
|
|
827
|
+
name: resolved.name,
|
|
828
|
+
description: resolved.description,
|
|
829
|
+
connection: resolved.connection,
|
|
830
|
+
api: resolved.api,
|
|
831
|
+
tools: resolved.tools.map((tool) => ({
|
|
832
|
+
name: tool.name,
|
|
833
|
+
access: tool.access,
|
|
834
|
+
fixed: { ...tool.fixed },
|
|
835
|
+
})),
|
|
836
|
+
actions: resolved.tools.map((tool) => ({
|
|
837
|
+
name: tool.name,
|
|
838
|
+
description: tool.description,
|
|
839
|
+
permission: tool.permission,
|
|
840
|
+
input: tool.inputSchema,
|
|
841
|
+
connections: [resolved.connection],
|
|
842
|
+
hints: {
|
|
843
|
+
readOnly: tool.hints.readOnly,
|
|
844
|
+
destructive: tool.hints.destructive,
|
|
845
|
+
idempotent: tool.hints.idempotent,
|
|
846
|
+
},
|
|
847
|
+
})),
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
/** The keys of every connection the manifest's actions and toolsets call, without duplicates. */
|
|
801
851
|
export function actionConnectionKeys(manifest) {
|
|
802
852
|
return [
|
|
803
|
-
...new Set(
|
|
853
|
+
...new Set([
|
|
854
|
+
...manifest.entities.flatMap((entity) => entity.actions.flatMap((candidate) => candidate.connections ?? [])),
|
|
855
|
+
...(manifest.toolsets ?? []).map((candidate) => candidate.connection),
|
|
856
|
+
]),
|
|
804
857
|
];
|
|
805
858
|
}
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -514,6 +514,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
514
514
|
readonly footer?: string | undefined;
|
|
515
515
|
};
|
|
516
516
|
} | undefined;
|
|
517
|
+
readonly toolsets?: readonly {
|
|
518
|
+
readonly name: string;
|
|
519
|
+
readonly description: string;
|
|
520
|
+
readonly connection: string;
|
|
521
|
+
readonly api: string;
|
|
522
|
+
readonly tools: readonly {
|
|
523
|
+
readonly name: string;
|
|
524
|
+
readonly access: "read" | "write";
|
|
525
|
+
readonly fixed: {
|
|
526
|
+
readonly [x: string]: string | number | boolean;
|
|
527
|
+
};
|
|
528
|
+
}[];
|
|
529
|
+
readonly actions: readonly {
|
|
530
|
+
readonly name: string;
|
|
531
|
+
readonly description: string;
|
|
532
|
+
readonly input: {
|
|
533
|
+
readonly [x: string]: Schema.Json;
|
|
534
|
+
};
|
|
535
|
+
readonly permission?: string | undefined;
|
|
536
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
537
|
+
readonly writes?: readonly string[] | undefined;
|
|
538
|
+
readonly connections?: readonly string[] | undefined;
|
|
539
|
+
readonly files?: readonly {
|
|
540
|
+
readonly entity: string;
|
|
541
|
+
readonly property: string;
|
|
542
|
+
}[] | undefined;
|
|
543
|
+
readonly hints?: {
|
|
544
|
+
readonly readOnly?: boolean | undefined;
|
|
545
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
546
|
+
readonly destructive?: boolean | undefined;
|
|
547
|
+
readonly irreversible?: boolean | undefined;
|
|
548
|
+
readonly idempotent?: boolean | undefined;
|
|
549
|
+
} | undefined;
|
|
550
|
+
}[];
|
|
551
|
+
}[] | undefined;
|
|
517
552
|
} | {
|
|
518
553
|
readonly version: number;
|
|
519
554
|
readonly hash: string;
|
|
@@ -747,6 +782,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
747
782
|
readonly footer?: string | undefined;
|
|
748
783
|
};
|
|
749
784
|
} | undefined;
|
|
785
|
+
readonly toolsets?: readonly {
|
|
786
|
+
readonly name: string;
|
|
787
|
+
readonly description: string;
|
|
788
|
+
readonly connection: string;
|
|
789
|
+
readonly api: string;
|
|
790
|
+
readonly tools: readonly {
|
|
791
|
+
readonly name: string;
|
|
792
|
+
readonly access: "read" | "write";
|
|
793
|
+
readonly fixed: {
|
|
794
|
+
readonly [x: string]: string | number | boolean;
|
|
795
|
+
};
|
|
796
|
+
}[];
|
|
797
|
+
readonly actions: readonly {
|
|
798
|
+
readonly name: string;
|
|
799
|
+
readonly description: string;
|
|
800
|
+
readonly input: {
|
|
801
|
+
readonly [x: string]: Schema.Json;
|
|
802
|
+
};
|
|
803
|
+
readonly permission?: string | undefined;
|
|
804
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
805
|
+
readonly writes?: readonly string[] | undefined;
|
|
806
|
+
readonly connections?: readonly string[] | undefined;
|
|
807
|
+
readonly files?: readonly {
|
|
808
|
+
readonly entity: string;
|
|
809
|
+
readonly property: string;
|
|
810
|
+
}[] | undefined;
|
|
811
|
+
readonly hints?: {
|
|
812
|
+
readonly readOnly?: boolean | undefined;
|
|
813
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
814
|
+
readonly destructive?: boolean | undefined;
|
|
815
|
+
readonly irreversible?: boolean | undefined;
|
|
816
|
+
readonly idempotent?: boolean | undefined;
|
|
817
|
+
} | undefined;
|
|
818
|
+
}[];
|
|
819
|
+
}[] | undefined;
|
|
750
820
|
}, {
|
|
751
821
|
readonly version: number;
|
|
752
822
|
readonly hash: string;
|
|
@@ -958,6 +1028,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
958
1028
|
readonly reply_to?: string | undefined;
|
|
959
1029
|
};
|
|
960
1030
|
} | undefined;
|
|
1031
|
+
readonly toolsets?: readonly {
|
|
1032
|
+
readonly name: string;
|
|
1033
|
+
readonly description: string;
|
|
1034
|
+
readonly connection: string;
|
|
1035
|
+
readonly api: string;
|
|
1036
|
+
readonly tools: readonly {
|
|
1037
|
+
readonly name: string;
|
|
1038
|
+
readonly access: "read" | "write";
|
|
1039
|
+
readonly fixed: {
|
|
1040
|
+
readonly [x: string]: string | number | boolean;
|
|
1041
|
+
};
|
|
1042
|
+
}[];
|
|
1043
|
+
readonly actions: readonly {
|
|
1044
|
+
readonly name: string;
|
|
1045
|
+
readonly description: string;
|
|
1046
|
+
readonly input: {
|
|
1047
|
+
readonly [x: string]: Schema.Json;
|
|
1048
|
+
};
|
|
1049
|
+
readonly permission?: string | undefined;
|
|
1050
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
1051
|
+
readonly writes?: readonly string[] | undefined;
|
|
1052
|
+
readonly connections?: readonly string[] | undefined;
|
|
1053
|
+
readonly files?: readonly {
|
|
1054
|
+
readonly entity: string;
|
|
1055
|
+
readonly property: string;
|
|
1056
|
+
}[] | undefined;
|
|
1057
|
+
readonly hints?: {
|
|
1058
|
+
readonly readOnly?: boolean | undefined;
|
|
1059
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
1060
|
+
readonly destructive?: boolean | undefined;
|
|
1061
|
+
readonly irreversible?: boolean | undefined;
|
|
1062
|
+
readonly idempotent?: boolean | undefined;
|
|
1063
|
+
} | undefined;
|
|
1064
|
+
}[];
|
|
1065
|
+
}[] | undefined;
|
|
961
1066
|
readonly sign_in?: {
|
|
962
1067
|
readonly policy: string;
|
|
963
1068
|
readonly browser?: {
|
|
@@ -1213,6 +1318,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1213
1318
|
readonly reply_to?: string | undefined;
|
|
1214
1319
|
};
|
|
1215
1320
|
} | undefined;
|
|
1321
|
+
readonly toolsets?: readonly {
|
|
1322
|
+
readonly name: string;
|
|
1323
|
+
readonly description: string;
|
|
1324
|
+
readonly connection: string;
|
|
1325
|
+
readonly api: string;
|
|
1326
|
+
readonly tools: readonly {
|
|
1327
|
+
readonly name: string;
|
|
1328
|
+
readonly access: "read" | "write";
|
|
1329
|
+
readonly fixed: {
|
|
1330
|
+
readonly [x: string]: string | number | boolean;
|
|
1331
|
+
};
|
|
1332
|
+
}[];
|
|
1333
|
+
readonly actions: readonly {
|
|
1334
|
+
readonly name: string;
|
|
1335
|
+
readonly description: string;
|
|
1336
|
+
readonly input: {
|
|
1337
|
+
readonly [x: string]: Schema.Json;
|
|
1338
|
+
};
|
|
1339
|
+
readonly permission?: string | undefined;
|
|
1340
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
1341
|
+
readonly writes?: readonly string[] | undefined;
|
|
1342
|
+
readonly connections?: readonly string[] | undefined;
|
|
1343
|
+
readonly files?: readonly {
|
|
1344
|
+
readonly entity: string;
|
|
1345
|
+
readonly property: string;
|
|
1346
|
+
}[] | undefined;
|
|
1347
|
+
readonly hints?: {
|
|
1348
|
+
readonly readOnly?: boolean | undefined;
|
|
1349
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
1350
|
+
readonly destructive?: boolean | undefined;
|
|
1351
|
+
readonly irreversible?: boolean | undefined;
|
|
1352
|
+
readonly idempotent?: boolean | undefined;
|
|
1353
|
+
} | undefined;
|
|
1354
|
+
}[];
|
|
1355
|
+
}[] | undefined;
|
|
1216
1356
|
}, readonly [Schema.Union<readonly [Schema.encodeKeys<Schema.Struct<{
|
|
1217
1357
|
readonly entities: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
1218
1358
|
readonly metrics: Schema.optionalKey<Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
@@ -1454,6 +1594,37 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1454
1594
|
readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1455
1595
|
}>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
|
|
1456
1596
|
}>>>;
|
|
1597
|
+
readonly toolsets: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
1598
|
+
readonly name: Schema.String;
|
|
1599
|
+
readonly description: Schema.String;
|
|
1600
|
+
readonly connection: Schema.String;
|
|
1601
|
+
readonly api: Schema.String;
|
|
1602
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
1603
|
+
readonly name: Schema.String;
|
|
1604
|
+
readonly access: Schema.Literals<readonly ["read", "write"]>;
|
|
1605
|
+
readonly fixed: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
1606
|
+
}>>;
|
|
1607
|
+
readonly actions: Schema.$Array<Schema.Struct<{
|
|
1608
|
+
readonly name: Schema.String;
|
|
1609
|
+
readonly description: Schema.String;
|
|
1610
|
+
readonly permission: Schema.optionalKey<Schema.String>;
|
|
1611
|
+
readonly input: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
1612
|
+
readonly retryOnDeadlock: Schema.optionalKey<Schema.Boolean>;
|
|
1613
|
+
readonly writes: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1614
|
+
readonly connections: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1615
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
1616
|
+
readonly entity: Schema.String;
|
|
1617
|
+
readonly property: Schema.String;
|
|
1618
|
+
}>>>;
|
|
1619
|
+
readonly hints: Schema.optionalKey<Schema.Struct<{
|
|
1620
|
+
readonly readOnly: Schema.optionalKey<Schema.Boolean>;
|
|
1621
|
+
readonly connectionsReadOnly: Schema.optionalKey<Schema.Boolean>;
|
|
1622
|
+
readonly destructive: Schema.optionalKey<Schema.Boolean>;
|
|
1623
|
+
readonly irreversible: Schema.optionalKey<Schema.Boolean>;
|
|
1624
|
+
readonly idempotent: Schema.optionalKey<Schema.Boolean>;
|
|
1625
|
+
}>>;
|
|
1626
|
+
}>>;
|
|
1627
|
+
}>>>;
|
|
1457
1628
|
}>, {
|
|
1458
1629
|
readonly signIn: "sign_in";
|
|
1459
1630
|
}>, Schema.Struct<{
|
|
@@ -1682,6 +1853,37 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1682
1853
|
readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1683
1854
|
}>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
|
|
1684
1855
|
}>>>;
|
|
1856
|
+
readonly toolsets: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
1857
|
+
readonly name: Schema.String;
|
|
1858
|
+
readonly description: Schema.String;
|
|
1859
|
+
readonly connection: Schema.String;
|
|
1860
|
+
readonly api: Schema.String;
|
|
1861
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
1862
|
+
readonly name: Schema.String;
|
|
1863
|
+
readonly access: Schema.Literals<readonly ["read", "write"]>;
|
|
1864
|
+
readonly fixed: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
1865
|
+
}>>;
|
|
1866
|
+
readonly actions: Schema.$Array<Schema.Struct<{
|
|
1867
|
+
readonly name: Schema.String;
|
|
1868
|
+
readonly description: Schema.String;
|
|
1869
|
+
readonly permission: Schema.optionalKey<Schema.String>;
|
|
1870
|
+
readonly input: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
1871
|
+
readonly retryOnDeadlock: Schema.optionalKey<Schema.Boolean>;
|
|
1872
|
+
readonly writes: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1873
|
+
readonly connections: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1874
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
1875
|
+
readonly entity: Schema.String;
|
|
1876
|
+
readonly property: Schema.String;
|
|
1877
|
+
}>>>;
|
|
1878
|
+
readonly hints: Schema.optionalKey<Schema.Struct<{
|
|
1879
|
+
readonly readOnly: Schema.optionalKey<Schema.Boolean>;
|
|
1880
|
+
readonly connectionsReadOnly: Schema.optionalKey<Schema.Boolean>;
|
|
1881
|
+
readonly destructive: Schema.optionalKey<Schema.Boolean>;
|
|
1882
|
+
readonly irreversible: Schema.optionalKey<Schema.Boolean>;
|
|
1883
|
+
readonly idempotent: Schema.optionalKey<Schema.Boolean>;
|
|
1884
|
+
}>>;
|
|
1885
|
+
}>>;
|
|
1886
|
+
}>>>;
|
|
1685
1887
|
}>]>], {
|
|
1686
1888
|
readonly version: number;
|
|
1687
1889
|
readonly hash: string;
|
|
@@ -1915,6 +2117,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1915
2117
|
readonly footer?: string | undefined;
|
|
1916
2118
|
};
|
|
1917
2119
|
} | undefined;
|
|
2120
|
+
readonly toolsets?: readonly {
|
|
2121
|
+
readonly name: string;
|
|
2122
|
+
readonly description: string;
|
|
2123
|
+
readonly connection: string;
|
|
2124
|
+
readonly api: string;
|
|
2125
|
+
readonly tools: readonly {
|
|
2126
|
+
readonly name: string;
|
|
2127
|
+
readonly access: "read" | "write";
|
|
2128
|
+
readonly fixed: {
|
|
2129
|
+
readonly [x: string]: string | number | boolean;
|
|
2130
|
+
};
|
|
2131
|
+
}[];
|
|
2132
|
+
readonly actions: readonly {
|
|
2133
|
+
readonly name: string;
|
|
2134
|
+
readonly description: string;
|
|
2135
|
+
readonly input: {
|
|
2136
|
+
readonly [x: string]: Schema.Json;
|
|
2137
|
+
};
|
|
2138
|
+
readonly permission?: string | undefined;
|
|
2139
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
2140
|
+
readonly writes?: readonly string[] | undefined;
|
|
2141
|
+
readonly connections?: readonly string[] | undefined;
|
|
2142
|
+
readonly files?: readonly {
|
|
2143
|
+
readonly entity: string;
|
|
2144
|
+
readonly property: string;
|
|
2145
|
+
}[] | undefined;
|
|
2146
|
+
readonly hints?: {
|
|
2147
|
+
readonly readOnly?: boolean | undefined;
|
|
2148
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
2149
|
+
readonly destructive?: boolean | undefined;
|
|
2150
|
+
readonly irreversible?: boolean | undefined;
|
|
2151
|
+
readonly idempotent?: boolean | undefined;
|
|
2152
|
+
} | undefined;
|
|
2153
|
+
}[];
|
|
2154
|
+
}[] | undefined;
|
|
1918
2155
|
} | {
|
|
1919
2156
|
readonly version: number;
|
|
1920
2157
|
readonly hash: string;
|
|
@@ -2148,6 +2385,41 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2148
2385
|
readonly footer?: string | undefined;
|
|
2149
2386
|
};
|
|
2150
2387
|
} | undefined;
|
|
2388
|
+
readonly toolsets?: readonly {
|
|
2389
|
+
readonly name: string;
|
|
2390
|
+
readonly description: string;
|
|
2391
|
+
readonly connection: string;
|
|
2392
|
+
readonly api: string;
|
|
2393
|
+
readonly tools: readonly {
|
|
2394
|
+
readonly name: string;
|
|
2395
|
+
readonly access: "read" | "write";
|
|
2396
|
+
readonly fixed: {
|
|
2397
|
+
readonly [x: string]: string | number | boolean;
|
|
2398
|
+
};
|
|
2399
|
+
}[];
|
|
2400
|
+
readonly actions: readonly {
|
|
2401
|
+
readonly name: string;
|
|
2402
|
+
readonly description: string;
|
|
2403
|
+
readonly input: {
|
|
2404
|
+
readonly [x: string]: Schema.Json;
|
|
2405
|
+
};
|
|
2406
|
+
readonly permission?: string | undefined;
|
|
2407
|
+
readonly retryOnDeadlock?: boolean | undefined;
|
|
2408
|
+
readonly writes?: readonly string[] | undefined;
|
|
2409
|
+
readonly connections?: readonly string[] | undefined;
|
|
2410
|
+
readonly files?: readonly {
|
|
2411
|
+
readonly entity: string;
|
|
2412
|
+
readonly property: string;
|
|
2413
|
+
}[] | undefined;
|
|
2414
|
+
readonly hints?: {
|
|
2415
|
+
readonly readOnly?: boolean | undefined;
|
|
2416
|
+
readonly connectionsReadOnly?: boolean | undefined;
|
|
2417
|
+
readonly destructive?: boolean | undefined;
|
|
2418
|
+
readonly irreversible?: boolean | undefined;
|
|
2419
|
+
readonly idempotent?: boolean | undefined;
|
|
2420
|
+
} | undefined;
|
|
2421
|
+
}[];
|
|
2422
|
+
}[] | undefined;
|
|
2151
2423
|
}>;
|
|
2152
2424
|
/** Non-transactional steps first, then the steps of the one transaction, in execution order. */
|
|
2153
2425
|
readonly steps: Schema.$Array<Schema.Struct<{
|
package/dist/ontology.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type OntologyManifest, type WorkflowManifest } from "./manifest.js";
|
|
|
5
5
|
import type { ModelMetrics } from "./metric.js";
|
|
6
6
|
import type { Role } from "./role.js";
|
|
7
7
|
import type { ResolvedSignInOptions } from "./sign-in.js";
|
|
8
|
+
import type { ResolvedToolset } from "./toolset.js";
|
|
8
9
|
/** A checked ontology: the resolved definitions and the manifest built from them. */
|
|
9
10
|
export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyArray<AnyEntity>, Metrics extends ModelMetrics = ModelMetrics> {
|
|
10
11
|
/** The definition as given to `defineOntology`. */
|
|
@@ -19,6 +20,8 @@ export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyAr
|
|
|
19
20
|
readonly connections: ReadonlyArray<ResolvedConnection>;
|
|
20
21
|
/** The workflows, with wire names and their triggers' input in wire form, as the manifest lists them. */
|
|
21
22
|
readonly workflows: ReadonlyArray<WorkflowManifest>;
|
|
23
|
+
/** The provider MCP tools the ontology serves, with wire names. */
|
|
24
|
+
readonly toolsets: ReadonlyArray<ResolvedToolset>;
|
|
22
25
|
readonly manifest: OntologyManifest;
|
|
23
26
|
/** Warning-level diagnostics; any error makes `defineOntology` throw. */
|
|
24
27
|
readonly warnings: ReadonlyArray<Diagnostic>;
|
package/dist/ontology.js
CHANGED
package/dist/service/catalog.js
CHANGED
|
@@ -10,11 +10,20 @@ export function catalogFor(manifest, permissions) {
|
|
|
10
10
|
if (permissions === undefined) {
|
|
11
11
|
return manifest;
|
|
12
12
|
}
|
|
13
|
-
const { metrics: declared, ...rest } = manifest;
|
|
13
|
+
const { metrics: declared, toolsets: served, ...rest } = manifest;
|
|
14
14
|
const metrics = declared === undefined ? [] : modelMetricsFor(manifest, permissions);
|
|
15
|
+
// A caller sees a toolset with the tools its permissions grant, and no toolset without one.
|
|
16
|
+
const toolsets = (served ?? []).flatMap((toolset) => {
|
|
17
|
+
const actions = toolset.actions.filter((action) => isAllowed(action.permission ?? `${toolset.name}:${action.name}`, { permissions }));
|
|
18
|
+
const names = new Set(actions.map((action) => action.name));
|
|
19
|
+
return actions.length === 0
|
|
20
|
+
? []
|
|
21
|
+
: [{ ...toolset, actions, tools: toolset.tools.filter((tool) => names.has(tool.name)) }];
|
|
22
|
+
});
|
|
15
23
|
return {
|
|
16
24
|
...rest,
|
|
17
25
|
...(metrics.length === 0 ? {} : { metrics }),
|
|
26
|
+
...(toolsets.length === 0 ? {} : { toolsets }),
|
|
18
27
|
entities: manifest.entities
|
|
19
28
|
.filter((entity) => entity.source === undefined ||
|
|
20
29
|
isAllowed(entity.permissions?.read ?? `${entity.name}:read`, { permissions }))
|
|
@@ -51,6 +51,13 @@ declare const CurrentChatCall_base: Context.ServiceClass<CurrentChatCall, "@segm
|
|
|
51
51
|
readonly chat_id: string;
|
|
52
52
|
readonly thread_id: string;
|
|
53
53
|
readonly message_id?: string | undefined;
|
|
54
|
+
readonly attachments?: readonly {
|
|
55
|
+
readonly kind: "photo" | "document" | "voice" | "audio" | "video" | "video_note" | "sticker" | "animation";
|
|
56
|
+
readonly file_id: string;
|
|
57
|
+
readonly staged_id: string;
|
|
58
|
+
readonly file_unique_id?: string | undefined;
|
|
59
|
+
readonly media_type?: string | undefined;
|
|
60
|
+
}[] | undefined;
|
|
54
61
|
readonly reply_to_message_id?: string | undefined;
|
|
55
62
|
readonly callback_query_id?: string | undefined;
|
|
56
63
|
readonly sender?: string | undefined;
|
|
@@ -60,13 +67,6 @@ declare const CurrentChatCall_base: Context.ServiceClass<CurrentChatCall, "@segm
|
|
|
60
67
|
readonly horizontal_accuracy?: number | undefined;
|
|
61
68
|
readonly live_period?: number | undefined;
|
|
62
69
|
} | undefined;
|
|
63
|
-
readonly attachments?: readonly {
|
|
64
|
-
readonly kind: "photo" | "document" | "voice" | "audio" | "video" | "video_note" | "sticker" | "animation";
|
|
65
|
-
readonly file_id: string;
|
|
66
|
-
readonly staged_id: string;
|
|
67
|
-
readonly file_unique_id?: string | undefined;
|
|
68
|
-
readonly media_type?: string | undefined;
|
|
69
|
-
}[] | undefined;
|
|
70
70
|
} | {
|
|
71
71
|
readonly kind: "group" | "private";
|
|
72
72
|
readonly provider: "whatsapp" | "slack";
|
|
@@ -103,6 +103,13 @@ export declare function consumeChatEnvelope(args: Readonly<Record<string, unknow
|
|
|
103
103
|
readonly chat_id: string;
|
|
104
104
|
readonly thread_id: string;
|
|
105
105
|
readonly message_id?: string | undefined;
|
|
106
|
+
readonly attachments?: readonly {
|
|
107
|
+
readonly kind: "photo" | "document" | "voice" | "audio" | "video" | "video_note" | "sticker" | "animation";
|
|
108
|
+
readonly file_id: string;
|
|
109
|
+
readonly staged_id: string;
|
|
110
|
+
readonly file_unique_id?: string | undefined;
|
|
111
|
+
readonly media_type?: string | undefined;
|
|
112
|
+
}[] | undefined;
|
|
106
113
|
readonly reply_to_message_id?: string | undefined;
|
|
107
114
|
readonly callback_query_id?: string | undefined;
|
|
108
115
|
readonly sender?: string | undefined;
|
|
@@ -112,13 +119,6 @@ export declare function consumeChatEnvelope(args: Readonly<Record<string, unknow
|
|
|
112
119
|
readonly horizontal_accuracy?: number | undefined;
|
|
113
120
|
readonly live_period?: number | undefined;
|
|
114
121
|
} | undefined;
|
|
115
|
-
readonly attachments?: readonly {
|
|
116
|
-
readonly kind: "photo" | "document" | "voice" | "audio" | "video" | "video_note" | "sticker" | "animation";
|
|
117
|
-
readonly file_id: string;
|
|
118
|
-
readonly staged_id: string;
|
|
119
|
-
readonly file_unique_id?: string | undefined;
|
|
120
|
-
readonly media_type?: string | undefined;
|
|
121
|
-
}[] | undefined;
|
|
122
122
|
} | {
|
|
123
123
|
readonly kind: "group" | "private";
|
|
124
124
|
readonly provider: "whatsapp" | "slack";
|
|
@@ -38,6 +38,7 @@ const REASONS = {
|
|
|
38
38
|
connection_response_too_large: "invalid_response",
|
|
39
39
|
invalid_connection: "invalid_request",
|
|
40
40
|
invalid_request: "invalid_request",
|
|
41
|
+
mcp_request_not_permitted: "invalid_request",
|
|
41
42
|
};
|
|
42
43
|
const MESSAGES = {
|
|
43
44
|
authorization_required: "Configure or authorize this connection in SegmentStream.",
|
|
@@ -23,8 +23,8 @@ export declare function searchDocuments(documents: ReadonlyArray<SearchDocument>
|
|
|
23
23
|
readonly summary_truncated: boolean;
|
|
24
24
|
readonly entity?: string | undefined;
|
|
25
25
|
readonly metrics?: readonly string[] | undefined;
|
|
26
|
-
readonly relevance?: number | undefined;
|
|
27
26
|
readonly tools?: readonly string[] | undefined;
|
|
27
|
+
readonly relevance?: number | undefined;
|
|
28
28
|
}[];
|
|
29
29
|
/** Bytewise canonical-name ordering is independent of a function instance's locale. */
|
|
30
30
|
export declare function compareRefs(left: string, right: string): number;
|
|
@@ -29,6 +29,7 @@ import { RequestId, errorBodyForWire, expectedFailure, internalError, isStorageF
|
|
|
29
29
|
import { publicOrigin } from "../oauth/protocol.js";
|
|
30
30
|
import { mcpChallenge, mcpResource } from "../oauth/server.js";
|
|
31
31
|
import { identityToken, makeOperations, toQuery } from "../operations.js";
|
|
32
|
+
import { resultText } from "../toolsets.js";
|
|
32
33
|
import { OntologyBackend } from "../runtime-contract.js";
|
|
33
34
|
import { WarehouseQueries } from "../warehouse-platform.js";
|
|
34
35
|
import { runtimeCredential } from "../runtime-identity.js";
|
|
@@ -453,6 +454,17 @@ function runTool(server, tool, args, request, preview) {
|
|
|
453
454
|
const { id, ...params } = yield* decodeArguments(HistoryArguments, args);
|
|
454
455
|
return structured(yield* encoded(HistoryPage, yield* operations.history(target.planned, id, params)));
|
|
455
456
|
}
|
|
457
|
+
case "toolset": {
|
|
458
|
+
// Every argument is the provider's: toolset tools take no action options.
|
|
459
|
+
const result = yield* operations.runToolsetTool(target.toolset, target.tool, {
|
|
460
|
+
input: args,
|
|
461
|
+
identityToken: identityToken(request),
|
|
462
|
+
});
|
|
463
|
+
return {
|
|
464
|
+
text: resultText(result),
|
|
465
|
+
structured: (result.structuredContent ?? { content: result.content }),
|
|
466
|
+
};
|
|
467
|
+
}
|
|
456
468
|
case "action": {
|
|
457
469
|
if (target.planned.name === "agent_chat" && target.action.name === "post_message") {
|
|
458
470
|
yield* decodeArguments(caller.kind === "runtime" ? RuntimeChatPostWire : ChatPostWire, args);
|
|
@@ -512,7 +524,7 @@ function callTool(server, params, request, preview) {
|
|
|
512
524
|
}
|
|
513
525
|
if (tool === undefined) {
|
|
514
526
|
const candidates = visibleTools(server.tools, principal, caller)
|
|
515
|
-
.filter((candidate) => candidate.target.kind === "action")
|
|
527
|
+
.filter((candidate) => candidate.target.kind === "action" || candidate.target.kind === "toolset")
|
|
516
528
|
.map((candidate) => candidate.name);
|
|
517
529
|
const suggestions = typeof call.name === "string" ? suggestNames(call.name, candidates) : [];
|
|
518
530
|
return {
|
|
@@ -6,6 +6,7 @@ import type { BuiltApi } from "../api.js";
|
|
|
6
6
|
import type { CallerContext } from "../caller-context.js";
|
|
7
7
|
import { type ConfirmationFacts } from "./confirmation.js";
|
|
8
8
|
import type { PlannedAction, PlannedEntity } from "../plan.js";
|
|
9
|
+
import type { ResolvedTool, ResolvedToolset } from "../../toolset.js";
|
|
9
10
|
/** How a tool behaves, as MCP's tool annotations say it. */
|
|
10
11
|
export interface McpToolAnnotations {
|
|
11
12
|
readonly readOnlyHint: boolean;
|
|
@@ -41,6 +42,10 @@ export type McpToolTarget = {
|
|
|
41
42
|
} | {
|
|
42
43
|
readonly kind: "member-file";
|
|
43
44
|
readonly operation: MemberFileOperation;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "toolset";
|
|
47
|
+
readonly toolset: ResolvedToolset;
|
|
48
|
+
readonly tool: ResolvedTool;
|
|
44
49
|
};
|
|
45
50
|
/** A tool of the ontology's MCP server, derived from the same plan as the HTTP routes. */
|
|
46
51
|
export interface McpTool {
|
|
@@ -17,6 +17,7 @@ import { ChatPostResult } from "../../chat.js";
|
|
|
17
17
|
import { actionDescription, requires } from "../descriptions.js";
|
|
18
18
|
import { DiscoverInput, DiscoverToolOutput } from "../discovery-schemas.js";
|
|
19
19
|
import { DIMENSIONS_LIMIT, hasMetrics, VALUES_DEFAULT, VALUES_LIMIT } from "./metric-tools.js";
|
|
20
|
+
import { isReadScoped } from "../toolsets.js";
|
|
20
21
|
import { NavigationInput, NavigationToolOutput } from "../navigation-schemas.js";
|
|
21
22
|
import { METRIC_QUERY_FILTER_OPERATORS, METRIC_QUERY_GRANULARITIES, METRIC_QUERY_LIMITS, METRIC_QUERY_PERIOD_UNITS, METRIC_QUERY_PERIODS, HistoryPage, MAXIMUM_TIMEZONE_LENGTH, Me, } from "../schemas.js";
|
|
22
23
|
const DEFS = "#/$defs/";
|
|
@@ -315,6 +316,31 @@ function actionTool(planned, plannedAction) {
|
|
|
315
316
|
target: { kind: "action", planned, action: plannedAction },
|
|
316
317
|
};
|
|
317
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* A provider's tool, as a toolset serves it: the workspace declares whether it only reads, so a
|
|
321
|
+
* read tool never needs confirmation and every other tool is external and is confirmed.
|
|
322
|
+
*/
|
|
323
|
+
function toolsetTool(toolset, tool) {
|
|
324
|
+
const schema = tool.inputSchema;
|
|
325
|
+
// A write tool is confirmed, so its calls carry the confirmation argument too.
|
|
326
|
+
const inputSchema = !tool.hints.readOnly && typeof schema.maxProperties === "number"
|
|
327
|
+
? { ...schema, maxProperties: schema.maxProperties + 1 }
|
|
328
|
+
: schema;
|
|
329
|
+
return {
|
|
330
|
+
name: tool.mcpName,
|
|
331
|
+
title: `${humanize(toolset.name)}: ${humanize(tool.name).toLowerCase()}`,
|
|
332
|
+
description: `${tool.description}\n\n${toolset.description}`,
|
|
333
|
+
inputSchema,
|
|
334
|
+
annotations: {
|
|
335
|
+
readOnlyHint: tool.hints.readOnly,
|
|
336
|
+
destructiveHint: tool.hints.destructive,
|
|
337
|
+
idempotentHint: tool.hints.idempotent,
|
|
338
|
+
openWorldHint: true,
|
|
339
|
+
},
|
|
340
|
+
permissions: [tool.permission],
|
|
341
|
+
target: { kind: "toolset", toolset, tool },
|
|
342
|
+
};
|
|
343
|
+
}
|
|
318
344
|
/** `discover` of an ontology that ranks entities by meaning with its decision model. */
|
|
319
345
|
const DISCOVER_BY_MEANING = "Find which entities a request concerns, ranked by meaning: pass as query the member's request " +
|
|
320
346
|
"in their words, and what you understand they want. Each match is an entity with its " +
|
|
@@ -719,6 +745,9 @@ export function mcpTools(built, conversations = false, storage = {}, navigation
|
|
|
719
745
|
}))
|
|
720
746
|
: [...reads, ...actions]));
|
|
721
747
|
}
|
|
748
|
+
for (const toolset of built.plan.ontology.toolsets ?? []) {
|
|
749
|
+
tools.push(...toolset.tools.map((tool) => toolsetTool(toolset, tool)));
|
|
750
|
+
}
|
|
722
751
|
const discover = tools.findIndex((tool) => tool.name === "discover");
|
|
723
752
|
// Word search duplicates the client's own tool search; ranking by meaning does not.
|
|
724
753
|
if (discover >= 0) {
|
|
@@ -920,6 +949,7 @@ export function mcpTools(built, conversations = false, storage = {}, navigation
|
|
|
920
949
|
export function visibleTools(tools, caller, provenance = { kind: "unverified" }) {
|
|
921
950
|
return tools.flatMap((tool) => {
|
|
922
951
|
if (!runtimeAllows(provenance, tool) ||
|
|
952
|
+
(tool.target.kind === "toolset" && isReadScoped(provenance)) ||
|
|
923
953
|
!tool.permissions.every((required) => isAllowed(required, caller))) {
|
|
924
954
|
return [];
|
|
925
955
|
}
|