@peers-app/peers-sdk 0.27.2 → 0.27.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/contract-proxy.d.ts +7 -0
- package/dist/contracts/contract-proxy.js +19 -2
- package/dist/contracts/create-local-consumer.js +16 -1
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/system/index.d.ts +2 -0
- package/dist/contracts/system/index.js +2 -0
- package/dist/contracts/system/invites-contract.js +2 -1
- package/dist/contracts/system/sync-check-contract.d.ts +97 -0
- package/dist/contracts/system/sync-check-contract.js +115 -0
- package/dist/contracts/tool-arguments.d.ts +15 -0
- package/dist/contracts/tool-arguments.js +41 -0
- package/dist/contracts/tool-catalog-service.js +2 -12
- package/dist/data/change-tracking.d.ts +40 -0
- package/dist/data/change-tracking.js +89 -0
- package/dist/data/orm/types.d.ts +24 -7
- package/dist/data/orm/types.js +97 -24
- package/dist/data/persistent-vars.d.ts +5 -0
- package/dist/data/persistent-vars.js +24 -6
- package/dist/define/manifest.js +6 -34
- package/dist/package-loader/package-loader.js +27 -22
- package/dist/system-ids.d.ts +5 -0
- package/dist/system-ids.js +6 -1
- package/package.json +4 -2
- package/dist/context/user-context-identity.test.d.ts +0 -1
- package/dist/context/user-context-identity.test.js +0 -220
- package/dist/contracts/__tests__/action-dispatch.test.d.ts +0 -1
- package/dist/contracts/__tests__/action-dispatch.test.js +0 -319
- package/dist/contracts/__tests__/also-implements.test.d.ts +0 -1
- package/dist/contracts/__tests__/also-implements.test.js +0 -110
- package/dist/contracts/__tests__/builder.test.d.ts +0 -1
- package/dist/contracts/__tests__/builder.test.js +0 -669
- package/dist/contracts/__tests__/contract-events.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-events.test.js +0 -199
- package/dist/contracts/__tests__/contract-observables.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-observables.test.js +0 -290
- package/dist/contracts/__tests__/contract-provider-router.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-provider-router.test.js +0 -315
- package/dist/contracts/__tests__/contract-proxy.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-proxy.test.js +0 -657
- package/dist/contracts/__tests__/contract-resolvers.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-resolvers.test.js +0 -758
- package/dist/contracts/__tests__/contract-subscription-lifecycle.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-subscription-lifecycle.test.js +0 -353
- package/dist/contracts/__tests__/contract-table-events.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-table-events.test.js +0 -209
- package/dist/contracts/__tests__/contract-transport.test.d.ts +0 -1
- package/dist/contracts/__tests__/contract-transport.test.js +0 -163
- package/dist/contracts/__tests__/extract.test.d.ts +0 -1
- package/dist/contracts/__tests__/extract.test.js +0 -145
- package/dist/contracts/__tests__/frozen-contracts.test.d.ts +0 -1
- package/dist/contracts/__tests__/frozen-contracts.test.js +0 -191
- package/dist/contracts/__tests__/generic-tool-dispatch.test.d.ts +0 -1
- package/dist/contracts/__tests__/generic-tool-dispatch.test.js +0 -130
- package/dist/contracts/__tests__/host-contract-client.test.d.ts +0 -1
- package/dist/contracts/__tests__/host-contract-client.test.js +0 -793
- package/dist/contracts/__tests__/host-contract-consumer.test.d.ts +0 -1
- package/dist/contracts/__tests__/host-contract-consumer.test.js +0 -163
- package/dist/contracts/__tests__/host-contract-transport.test.d.ts +0 -1
- package/dist/contracts/__tests__/host-contract-transport.test.js +0 -66
- package/dist/contracts/__tests__/integration.test.d.ts +0 -1
- package/dist/contracts/__tests__/integration.test.js +0 -348
- package/dist/contracts/__tests__/legacy-removal.test.d.ts +0 -1
- package/dist/contracts/__tests__/legacy-removal.test.js +0 -128
- package/dist/contracts/__tests__/persistent-registry.test.d.ts +0 -1
- package/dist/contracts/__tests__/persistent-registry.test.js +0 -109
- package/dist/contracts/__tests__/playground.test.d.ts +0 -1
- package/dist/contracts/__tests__/playground.test.js +0 -216
- package/dist/contracts/__tests__/registry.test.d.ts +0 -1
- package/dist/contracts/__tests__/registry.test.js +0 -238
- package/dist/contracts/__tests__/remote-contract-transport.test.d.ts +0 -1
- package/dist/contracts/__tests__/remote-contract-transport.test.js +0 -119
- package/dist/contracts/__tests__/system-contracts.test.d.ts +0 -1
- package/dist/contracts/__tests__/system-contracts.test.js +0 -247
- package/dist/contracts/__tests__/target-dispatch.d.ts +0 -11
- package/dist/contracts/__tests__/target-dispatch.js +0 -24
- package/dist/contracts/__tests__/tool-catalog-inventory.test.d.ts +0 -1
- package/dist/contracts/__tests__/tool-catalog-inventory.test.js +0 -44
- package/dist/contracts/__tests__/tool-catalog-service.test.d.ts +0 -1
- package/dist/contracts/__tests__/tool-catalog-service.test.js +0 -482
- package/dist/contracts/__tests__/tool-catalog.test.d.ts +0 -1
- package/dist/contracts/__tests__/tool-catalog.test.js +0 -1199
- package/dist/contracts/__tests__/validate.test.d.ts +0 -1
- package/dist/contracts/__tests__/validate.test.js +0 -991
- package/dist/contracts/__tests__/workflow-context.test.d.ts +0 -1
- package/dist/contracts/__tests__/workflow-context.test.js +0 -50
- package/dist/data/access-level.test.d.ts +0 -1
- package/dist/data/access-level.test.js +0 -53
- package/dist/data/change-tracking.test.d.ts +0 -1
- package/dist/data/change-tracking.test.js +0 -62
- package/dist/data/files/files.test.d.ts +0 -1
- package/dist/data/files/files.test.js +0 -770
- package/dist/data/group-members.test.d.ts +0 -1
- package/dist/data/group-members.test.js +0 -336
- package/dist/data/group-share.test.d.ts +0 -1
- package/dist/data/group-share.test.js +0 -110
- package/dist/data/groups.test.d.ts +0 -1
- package/dist/data/groups.test.js +0 -153
- package/dist/data/orm/cursor.test.d.ts +0 -1
- package/dist/data/orm/cursor.test.js +0 -314
- package/dist/data/orm/data-query.mongo.test.d.ts +0 -1
- package/dist/data/orm/data-query.mongo.test.js +0 -367
- package/dist/data/orm/data-query.sqlite.test.d.ts +0 -1
- package/dist/data/orm/data-query.sqlite.test.js +0 -365
- package/dist/data/orm/data-query.test.d.ts +0 -1
- package/dist/data/orm/data-query.test.js +0 -545
- package/dist/data/orm/dependency-injection.test.d.ts +0 -1
- package/dist/data/orm/dependency-injection.test.js +0 -171
- package/dist/data/orm/event-registry.test.d.ts +0 -1
- package/dist/data/orm/event-registry.test.js +0 -44
- package/dist/data/orm/multi-cursors.test.d.ts +0 -1
- package/dist/data/orm/multi-cursors.test.js +0 -463
- package/dist/data/orm/sql.data-source.test.d.ts +0 -1
- package/dist/data/orm/sql.data-source.test.js +0 -731
- package/dist/data/orm/table-container-events.test.d.ts +0 -1
- package/dist/data/orm/table-container-events.test.js +0 -101
- package/dist/data/orm/table-container.test.d.ts +0 -1
- package/dist/data/orm/table-container.test.js +0 -273
- package/dist/data/orm/table.event-source.test.d.ts +0 -1
- package/dist/data/orm/table.event-source.test.js +0 -331
- package/dist/data/orm/types.test.d.ts +0 -1
- package/dist/data/orm/types.test.js +0 -409
- package/dist/data/package-table-identity.test.d.ts +0 -1
- package/dist/data/package-table-identity.test.js +0 -46
- package/dist/data/package-version-permissions.test.d.ts +0 -1
- package/dist/data/package-version-permissions.test.js +0 -107
- package/dist/data/package-version-resolver.test.d.ts +0 -4
- package/dist/data/package-version-resolver.test.js +0 -543
- package/dist/data/package-versions.test.d.ts +0 -1
- package/dist/data/package-versions.test.js +0 -227
- package/dist/data/persistent-vars.conflict.test.d.ts +0 -1
- package/dist/data/persistent-vars.conflict.test.js +0 -126
- package/dist/data/persistent-vars.migration.test.d.ts +0 -1
- package/dist/data/persistent-vars.migration.test.js +0 -133
- package/dist/data/persistent-vars.package-scope.test.d.ts +0 -1
- package/dist/data/persistent-vars.package-scope.test.js +0 -27
- package/dist/data/sync-recovery-queue.test.d.ts +0 -1
- package/dist/data/sync-recovery-queue.test.js +0 -215
- package/dist/data/table-signing.test.d.ts +0 -1
- package/dist/data/table-signing.test.js +0 -118
- package/dist/data/tool-access.test.d.ts +0 -1
- package/dist/data/tool-access.test.js +0 -166
- package/dist/data/user-permissions.test.d.ts +0 -1
- package/dist/data/user-permissions.test.js +0 -305
- package/dist/data/user-trust-levels.test.d.ts +0 -1
- package/dist/data/user-trust-levels.test.js +0 -37
- package/dist/define/also-implements.test.d.ts +0 -1
- package/dist/define/also-implements.test.js +0 -123
- package/dist/define/declare-contract.test.d.ts +0 -1
- package/dist/define/declare-contract.test.js +0 -573
- package/dist/define/define.test.d.ts +0 -1
- package/dist/define/define.test.js +0 -1010
- package/dist/define/empty-fields.test.d.ts +0 -1
- package/dist/define/empty-fields.test.js +0 -55
- package/dist/define/events-observables.test.d.ts +0 -1
- package/dist/define/events-observables.test.js +0 -1013
- package/dist/define/serve-members.test.d.ts +0 -1
- package/dist/define/serve-members.test.js +0 -630
- package/dist/define/vars.test.d.ts +0 -1
- package/dist/define/vars.test.js +0 -39
- package/dist/device/binary-peer-connection-v2.test.d.ts +0 -1
- package/dist/device/binary-peer-connection-v2.test.js +0 -730
- package/dist/device/binary-peer-connection.test.d.ts +0 -1
- package/dist/device/binary-peer-connection.test.js +0 -184
- package/dist/device/connection.test.d.ts +0 -1
- package/dist/device/connection.test.js +0 -613
- package/dist/device/device-election.test.d.ts +0 -1
- package/dist/device/device-election.test.js +0 -516
- package/dist/device/device.test.d.ts +0 -1
- package/dist/device/device.test.js +0 -243
- package/dist/device/frame-cipher.test.d.ts +0 -1
- package/dist/device/frame-cipher.test.js +0 -219
- package/dist/device/get-trust-level-fn.test.d.ts +0 -1
- package/dist/device/get-trust-level-fn.test.js +0 -685
- package/dist/device/streamed-socket.test.d.ts +0 -1
- package/dist/device/streamed-socket.test.js +0 -216
- package/dist/device/tx-encoding.test.d.ts +0 -1
- package/dist/device/tx-encoding.test.js +0 -295
- package/dist/device-pairing/cpace.test.d.ts +0 -1
- package/dist/device-pairing/cpace.test.js +0 -116
- package/dist/device-pairing/device-pairing.test.d.ts +0 -1
- package/dist/device-pairing/device-pairing.test.js +0 -211
- package/dist/hlc.test.d.ts +0 -1
- package/dist/hlc.test.js +0 -45
- package/dist/host-credentials.test.d.ts +0 -1
- package/dist/host-credentials.test.js +0 -88
- package/dist/identity/account-email.test.d.ts +0 -1
- package/dist/identity/account-email.test.js +0 -59
- package/dist/identity/anchor-document.test.d.ts +0 -1
- package/dist/identity/anchor-document.test.js +0 -16
- package/dist/identity/anchor-resolution.test.d.ts +0 -1
- package/dist/identity/anchor-resolution.test.js +0 -130
- package/dist/identity/key-change.test.d.ts +0 -1
- package/dist/identity/key-change.test.js +0 -811
- package/dist/invites/group-approval.test.d.ts +0 -1
- package/dist/invites/group-approval.test.js +0 -223
- package/dist/invites/invite-token.test.d.ts +0 -1
- package/dist/invites/invite-token.test.js +0 -123
- package/dist/keys.test.d.ts +0 -1
- package/dist/keys.test.js +0 -336
- package/dist/logging/console-logger.test.d.ts +0 -1
- package/dist/logging/console-logger.test.js +0 -300
- package/dist/logging/console-logs.table.test.d.ts +0 -1
- package/dist/logging/console-logs.table.test.js +0 -156
- package/dist/observable.test.d.ts +0 -1
- package/dist/observable.test.js +0 -309
- package/dist/package-build/build-package.test.d.ts +0 -1
- package/dist/package-build/build-package.test.js +0 -204
- package/dist/package-build/contract-add.test.d.ts +0 -1
- package/dist/package-build/contract-add.test.js +0 -467
- package/dist/package-build/freeze-contracts.test.d.ts +0 -1
- package/dist/package-build/freeze-contracts.test.js +0 -355
- package/dist/package-installer/package-author-signing.test.d.ts +0 -1
- package/dist/package-installer/package-author-signing.test.js +0 -200
- package/dist/package-installer/package-cloner.test.d.ts +0 -1
- package/dist/package-installer/package-cloner.test.js +0 -278
- package/dist/package-installer/package-creator.test.d.ts +0 -1
- package/dist/package-installer/package-creator.test.js +0 -908
- package/dist/package-installer/package-dev-tools.test.d.ts +0 -1
- package/dist/package-installer/package-dev-tools.test.js +0 -64
- package/dist/package-installer/package-installer.test.d.ts +0 -1
- package/dist/package-installer/package-installer.test.js +0 -882
- package/dist/package-installer/package-propagation.test.d.ts +0 -1
- package/dist/package-installer/package-propagation.test.js +0 -1269
- package/dist/package-installer/package-publisher.test.d.ts +0 -1
- package/dist/package-installer/package-publisher.test.js +0 -153
- package/dist/package-installer/package-remote-checker.test.d.ts +0 -1
- package/dist/package-installer/package-remote-checker.test.js +0 -334
- package/dist/package-installer/package-seed-installer.test.d.ts +0 -1
- package/dist/package-installer/package-seed-installer.test.js +0 -123
- package/dist/package-installer/package-tarball.test.d.ts +0 -1
- package/dist/package-installer/package-tarball.test.js +0 -75
- package/dist/package-installer/peers-core-installer.test.d.ts +0 -1
- package/dist/package-installer/peers-core-installer.test.js +0 -49
- package/dist/package-installer/peers-core-trust-anchor.test.d.ts +0 -1
- package/dist/package-installer/peers-core-trust-anchor.test.js +0 -155
- package/dist/package-loader/contract-package-loader.test.d.ts +0 -1
- package/dist/package-loader/contract-package-loader.test.js +0 -274
- package/dist/package-loader/host-authority-loading.test.d.ts +0 -1
- package/dist/package-loader/host-authority-loading.test.js +0 -104
- package/dist/package-loader/host-dispatch-policy.test.d.ts +0 -1
- package/dist/package-loader/host-dispatch-policy.test.js +0 -56
- package/dist/package-loader/isolated-artifact.test.d.ts +0 -1
- package/dist/package-loader/isolated-artifact.test.js +0 -688
- package/dist/package-loader/isolated-persistent-var-gateway.test.d.ts +0 -1
- package/dist/package-loader/isolated-persistent-var-gateway.test.js +0 -56
- package/dist/package-loader/isolated-table-gateway.test.d.ts +0 -1
- package/dist/package-loader/isolated-table-gateway.test.js +0 -633
- package/dist/package-loader/package-loader.test.d.ts +0 -1
- package/dist/package-loader/package-loader.test.js +0 -1764
- package/dist/package-loader/resolve-consumed-contracts.test.d.ts +0 -1
- package/dist/package-loader/resolve-consumed-contracts.test.js +0 -166
- package/dist/serial-json.compat.test.d.ts +0 -1
- package/dist/serial-json.compat.test.js +0 -369
- package/dist/serial-json.test.d.ts +0 -1
- package/dist/serial-json.test.js +0 -401
- package/dist/testing/mock-host-contract.test.d.ts +0 -1
- package/dist/testing/mock-host-contract.test.js +0 -782
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -232
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../index");
|
|
4
|
-
const systemIds = require("../../system-ids");
|
|
5
|
-
const system_ids_1 = require("../../system-ids");
|
|
6
|
-
const system_contracts_1 = require("../system-contracts");
|
|
7
|
-
const tool_catalog_identity_1 = require("../tool-catalog-identity");
|
|
8
|
-
const tool_catalog_migrations_1 = require("../tool-catalog-migrations");
|
|
9
|
-
test("every reviewed alias is valid and the workflow migration leaves no unresolved tools", () => {
|
|
10
|
-
for (const entry of tool_catalog_migrations_1.toolCatalogMigrations) {
|
|
11
|
-
expect((0, tool_catalog_identity_1.isCatalogToolId)(entry.toolId)).toBe(true);
|
|
12
|
-
expect((0, tool_catalog_migrations_1.resolveLegacyToolId)(entry.toolId)).toEqual({
|
|
13
|
-
contractId: entry.contractId,
|
|
14
|
-
version: entry.version,
|
|
15
|
-
toolName: entry.toolName,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
for (const [id, contractId, toolName] of [
|
|
19
|
-
["000peers0tool00000runner1", system_ids_1.hostToolsContractId, "default_assistant_runner"],
|
|
20
|
-
["000peers0tool00toolsearch", system_ids_1.hostToolsContractId, "tool-search"],
|
|
21
|
-
["000peers0tool0000000dircd", system_ids_1.desktopToolsContractId, "cd"],
|
|
22
|
-
["000peers0tool000000notify", system_ids_1.desktopToolsContractId, "send-notification"],
|
|
23
|
-
])
|
|
24
|
-
expect((0, tool_catalog_migrations_1.resolveLegacyToolId)(id)).toEqual({ contractId, version: 1, toolName });
|
|
25
|
-
});
|
|
26
|
-
test("all system aliases name declared members and every system ID map is reviewed", () => {
|
|
27
|
-
for (const alias of tool_catalog_migrations_1.toolCatalogMigrations) {
|
|
28
|
-
if (!(0, system_contracts_1.isSystemContractId)(alias.contractId))
|
|
29
|
-
continue;
|
|
30
|
-
const system = (0, system_contracts_1.listSystemContracts)().find((entry) => {
|
|
31
|
-
const definition = entry.getDefinition();
|
|
32
|
-
return definition.contractId === alias.contractId && definition.version === alias.version;
|
|
33
|
-
});
|
|
34
|
-
expect(system).toBeDefined();
|
|
35
|
-
expect(system?.getDefinition().tools.some((tool) => tool.name === alias.toolName)).toBe(true);
|
|
36
|
-
}
|
|
37
|
-
for (const [name, ids] of Object.entries(systemIds)) {
|
|
38
|
-
if (!name.endsWith("ToolIds"))
|
|
39
|
-
continue;
|
|
40
|
-
for (const toolId of Object.values(ids))
|
|
41
|
-
expect((0, tool_catalog_migrations_1.resolveLegacyToolId)(toolId)).toBeDefined();
|
|
42
|
-
}
|
|
43
|
-
expect((0, tool_catalog_migrations_1.resolveLegacyToolId)("00mh0wlipkdbeaw8imptsk001")).toBeUndefined();
|
|
44
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../../index";
|
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../index");
|
|
4
|
-
const tools_1 = require("../../data/tools");
|
|
5
|
-
const system_ids_1 = require("../../system-ids");
|
|
6
|
-
const field_type_1 = require("../../types/field-type");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const contract_provider_router_1 = require("../contract-provider-router");
|
|
9
|
-
const contract_resolvers_1 = require("../contract-resolvers");
|
|
10
|
-
const registry_1 = require("../registry");
|
|
11
|
-
const tool_catalog_identity_1 = require("../tool-catalog-identity");
|
|
12
|
-
const tool_catalog_service_1 = require("../tool-catalog-service");
|
|
13
|
-
function fixture() {
|
|
14
|
-
const target = { contractId: (0, utils_1.newid)(), version: 1, toolName: "run" };
|
|
15
|
-
const provider = (0, utils_1.newid)();
|
|
16
|
-
const registry = new registry_1.ContractRegistry();
|
|
17
|
-
const definition = {
|
|
18
|
-
contractId: target.contractId,
|
|
19
|
-
version: 1,
|
|
20
|
-
devTag: "dev",
|
|
21
|
-
name: "Test",
|
|
22
|
-
description: "",
|
|
23
|
-
tables: [],
|
|
24
|
-
observables: [],
|
|
25
|
-
events: [],
|
|
26
|
-
tools: [
|
|
27
|
-
{
|
|
28
|
-
name: "run",
|
|
29
|
-
usageDescription: "run",
|
|
30
|
-
inputFields: [{ name: "value", type: field_type_1.FieldType.string }],
|
|
31
|
-
outputFields: [],
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
};
|
|
35
|
-
const row = {
|
|
36
|
-
toolId: (0, tool_catalog_identity_1.deriveToolCatalogId)(target),
|
|
37
|
-
name: "run",
|
|
38
|
-
usageDescription: "run",
|
|
39
|
-
code: "",
|
|
40
|
-
inputSchema: { type: tools_1.IOSchemaType.none, fields: [] },
|
|
41
|
-
outputSchema: { type: tools_1.IOSchemaType.none, fields: [] },
|
|
42
|
-
contractId: target.contractId,
|
|
43
|
-
contractVersion: 1,
|
|
44
|
-
toolName: "run",
|
|
45
|
-
catalogState: "resolved",
|
|
46
|
-
catalogIdentity: "deterministic",
|
|
47
|
-
};
|
|
48
|
-
const rows = new Map([[row.toolId, row]]);
|
|
49
|
-
const table = {
|
|
50
|
-
get: jest.fn(async (id) => rows.get(id)),
|
|
51
|
-
list: jest.fn(async (filter = {}, opts = {}) => [...rows.values()]
|
|
52
|
-
.filter((r) => (!filter.name || r.name === filter.name) &&
|
|
53
|
-
(!opts.textSearch || r.name.includes(opts.textSearch)))
|
|
54
|
-
.slice(0, opts.pageSize)),
|
|
55
|
-
};
|
|
56
|
-
const endpoint = {
|
|
57
|
-
handleCall: jest.fn(async () => "ok"),
|
|
58
|
-
dispose: jest.fn(),
|
|
59
|
-
};
|
|
60
|
-
const loader = {
|
|
61
|
-
catalogReady: Promise.resolve(),
|
|
62
|
-
contractRegistry: registry,
|
|
63
|
-
toolCatalog: { assertTargetUsable: jest.fn(async () => { }) },
|
|
64
|
-
resolveContractEndpoint: jest.fn(async (_request, _options) => endpoint),
|
|
65
|
-
isolatedRuntime: {
|
|
66
|
-
isInstalled: jest.fn(() => false),
|
|
67
|
-
getEffectiveToolLevel: jest.fn(() => 40),
|
|
68
|
-
resolveEndpoint: jest.fn(),
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
const dataContext = {
|
|
72
|
-
dataContextId: (0, utils_1.newid)(),
|
|
73
|
-
tableContainer: {
|
|
74
|
-
getTable: (meta) => (meta.name === "Tools" ? table : { get: async () => undefined }),
|
|
75
|
-
},
|
|
76
|
-
packageLoader: loader,
|
|
77
|
-
};
|
|
78
|
-
const userId = (0, utils_1.newid)();
|
|
79
|
-
Object.assign(dataContext, {
|
|
80
|
-
userContext: {
|
|
81
|
-
userId,
|
|
82
|
-
loadingPromise: Promise.resolve(),
|
|
83
|
-
getDataContext: () => dataContext,
|
|
84
|
-
userDataContext: dataContext,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
const context = { callerUserId: userId, localUserId: userId, dataContext };
|
|
88
|
-
const host = (packageId = provider, version = 1, accessLevel = 40) => {
|
|
89
|
-
(0, contract_resolvers_1.stagePackageContractResolvers)(dataContext, packageId, () => (0, contract_resolvers_1.registerContractResolver)(target.contractId, version, () => ({
|
|
90
|
-
contractId: target.contractId,
|
|
91
|
-
version,
|
|
92
|
-
tools: { run: { tool: { ...row, accessLevel }, toolFn: () => "ok" } },
|
|
93
|
-
}), { providerPackageId: packageId }))();
|
|
94
|
-
};
|
|
95
|
-
const install = () => {
|
|
96
|
-
expect(registry.register(provider, definition).valid).toBe(true);
|
|
97
|
-
host();
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
target,
|
|
101
|
-
provider,
|
|
102
|
-
registry,
|
|
103
|
-
definition,
|
|
104
|
-
row,
|
|
105
|
-
rows,
|
|
106
|
-
table,
|
|
107
|
-
endpoint,
|
|
108
|
-
loader,
|
|
109
|
-
dataContext,
|
|
110
|
-
context,
|
|
111
|
-
host,
|
|
112
|
-
install,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
test("classifies missing providers, missing members, quarantine, missing implementations and removed legacy execution", async () => {
|
|
116
|
-
const f = fixture();
|
|
117
|
-
const describe = () => (0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row);
|
|
118
|
-
expect(describe().availability.reason).toBe("no-provider");
|
|
119
|
-
f.registry.register(f.provider, f.definition);
|
|
120
|
-
expect(describe().availability.reason).toBe("no-implementation");
|
|
121
|
-
f.host();
|
|
122
|
-
expect(describe().availability.dispatch).toBe("contract");
|
|
123
|
-
f.definition.tools = [];
|
|
124
|
-
expect(describe().availability.reason).toBe("member-removed");
|
|
125
|
-
f.row.catalogState = "quarantined";
|
|
126
|
-
expect(describe().availability.reason).toBe("quarantined");
|
|
127
|
-
f.row.contractId = (0, utils_1.newid)();
|
|
128
|
-
expect(describe().availability.reason).toBe("invalid-identity");
|
|
129
|
-
const legacy = {
|
|
130
|
-
...f.row,
|
|
131
|
-
toolId: (0, utils_1.newid)(),
|
|
132
|
-
contractId: undefined,
|
|
133
|
-
contractVersion: undefined,
|
|
134
|
-
toolName: undefined,
|
|
135
|
-
catalogIdentity: undefined,
|
|
136
|
-
catalogState: "unresolved",
|
|
137
|
-
};
|
|
138
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, legacy).availability.reason).toBe("legacy-execution-removed");
|
|
139
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, legacy).availability.message).toContain("contract resolver");
|
|
140
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, { ...legacy, packageId: f.provider }).availability).toMatchObject({
|
|
141
|
-
dispatch: "unavailable",
|
|
142
|
-
reason: "legacy-package-upgrade-required",
|
|
143
|
-
message: expect.stringContaining(f.provider),
|
|
144
|
-
});
|
|
145
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, legacy).availability.dispatch).toBe("unavailable");
|
|
146
|
-
});
|
|
147
|
-
test("projects aliases including the shipped Scheduler ID and groups equal name matches", async () => {
|
|
148
|
-
const f = fixture();
|
|
149
|
-
const alias = {
|
|
150
|
-
...f.row,
|
|
151
|
-
toolId: "00muxgugn661g0qmpuwafrmsi4",
|
|
152
|
-
contractId: system_ids_1.schedulerContractId,
|
|
153
|
-
toolName: "list",
|
|
154
|
-
catalogIdentity: "legacy-alias",
|
|
155
|
-
};
|
|
156
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, alias).aliases).toEqual([alias.toolId]);
|
|
157
|
-
f.rows.clear();
|
|
158
|
-
const aliases = ["00muxoa8xeet2lpi8bdq55q03", "00muxob3hbo3f6g49mipy1hyt"];
|
|
159
|
-
for (const toolId of aliases)
|
|
160
|
-
f.rows.set(toolId, {
|
|
161
|
-
...alias,
|
|
162
|
-
toolId,
|
|
163
|
-
contractId: "00muxgugn6xvs8f2r80ru205t",
|
|
164
|
-
toolName: "invoke",
|
|
165
|
-
name: "invoke",
|
|
166
|
-
});
|
|
167
|
-
expect((await (0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: "invoke" }))?.aliases).toEqual(aliases);
|
|
168
|
-
});
|
|
169
|
-
test.each([
|
|
170
|
-
"authority",
|
|
171
|
-
"assistantId",
|
|
172
|
-
"workflowVars",
|
|
173
|
-
"callerPackageId",
|
|
174
|
-
])("rejects payload key %s", async (key) => {
|
|
175
|
-
const f = fixture();
|
|
176
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, [key]: { userAccessLevel: 100 } }, f.context)).rejects.toThrow("Unexpected invokeTool input key");
|
|
177
|
-
expect(f.loader.resolveContractEndpoint).not.toHaveBeenCalled();
|
|
178
|
-
});
|
|
179
|
-
test.each([
|
|
180
|
-
{ callerPackageId: system_ids_1.peersSystemPackageId },
|
|
181
|
-
{ callerDeviceId: (0, utils_1.newid)() },
|
|
182
|
-
{ callerUserId: undefined, localUserId: undefined },
|
|
183
|
-
{ dataContext: {} },
|
|
184
|
-
])("rejects unauthenticated, package, device and cross-context callers: %j", async (override) => {
|
|
185
|
-
const f = fixture();
|
|
186
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId }, {
|
|
187
|
-
...f.context,
|
|
188
|
-
...override,
|
|
189
|
-
})).rejects.toThrow();
|
|
190
|
-
expect(f.loader.resolveContractEndpoint).not.toHaveBeenCalled();
|
|
191
|
-
});
|
|
192
|
-
test("validates arguments, converts dates, and forwards original nested objects and unknown fields", async () => {
|
|
193
|
-
const f = fixture();
|
|
194
|
-
f.install();
|
|
195
|
-
const invoke = (args) => (0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, args }, f.context);
|
|
196
|
-
for (const args of [undefined, [], null, "bad", { value: 4 }])
|
|
197
|
-
await expect(invoke(args)).rejects.toThrow();
|
|
198
|
-
f.definition.tools[0].inputFields.push({ name: "when", type: field_type_1.FieldType.Date }, { name: "object", type: field_type_1.FieldType.object }, { name: "defaulted", type: field_type_1.FieldType.string, defaultValue: "default" });
|
|
199
|
-
const object = { nested: "retained" };
|
|
200
|
-
const args = { value: "hello", when: "2026-10-16", object, extra: 1 };
|
|
201
|
-
await expect(invoke(args)).resolves.toBe("ok");
|
|
202
|
-
const forwarded = f.endpoint.handleCall.mock.calls[0][0].args[0];
|
|
203
|
-
expect(forwarded).toEqual({ ...args, when: new Date(args.when) });
|
|
204
|
-
expect(forwarded.object).toBe(object);
|
|
205
|
-
expect(forwarded).not.toHaveProperty("defaulted");
|
|
206
|
-
await expect(invoke({ ...args, defaulted: null })).resolves.toBe("ok");
|
|
207
|
-
expect(f.endpoint.handleCall.mock.calls[1][0].args[0]).not.toHaveProperty("defaulted");
|
|
208
|
-
expect(args.when).toBe("2026-10-16");
|
|
209
|
-
await expect(invoke({ ...args, when: "not-a-date" })).rejects.toThrow("argument validation");
|
|
210
|
-
expect(f.endpoint.dispose).toHaveBeenCalledTimes(2);
|
|
211
|
-
});
|
|
212
|
-
test("selects strict, preferred and fallback providers and observes active changes under the same ID", async () => {
|
|
213
|
-
const f = fixture();
|
|
214
|
-
f.install();
|
|
215
|
-
const second = (0, utils_1.newid)();
|
|
216
|
-
f.registry.register(second, f.definition);
|
|
217
|
-
f.host(second);
|
|
218
|
-
const invoke = (input = {}) => (0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, args: { value: "ok" }, ...input }, f.context);
|
|
219
|
-
await expect(invoke({ providerPackageId: (0, utils_1.newid)() })).rejects.toThrow("Strict provider selection");
|
|
220
|
-
await invoke({ providerPackageId: second });
|
|
221
|
-
expect(f.loader.resolveContractEndpoint.mock.calls.at(-1)?.[0]).toMatchObject({
|
|
222
|
-
providerPackageId: second,
|
|
223
|
-
});
|
|
224
|
-
await invoke({ providerPackageId: (0, utils_1.newid)(), fallbackToDefaultProvider: true });
|
|
225
|
-
expect(f.loader.resolveContractEndpoint.mock.calls.at(-1)?.[0]).toMatchObject({
|
|
226
|
-
providerPackageId: f.provider,
|
|
227
|
-
});
|
|
228
|
-
f.registry.setActiveProvider(f.target.contractId, 1, second);
|
|
229
|
-
await invoke();
|
|
230
|
-
expect(f.loader.resolveContractEndpoint.mock.calls.at(-1)?.[0]).toMatchObject({
|
|
231
|
-
providerPackageId: second,
|
|
232
|
-
context: f.context,
|
|
233
|
-
});
|
|
234
|
-
expect(f.endpoint.handleCall).toHaveBeenLastCalledWith(expect.objectContaining({ args: [{ value: "ok" }] }), f.context);
|
|
235
|
-
});
|
|
236
|
-
test("host alsoImplements validates the requested v1 schema and resolves v2 code", async () => {
|
|
237
|
-
const f = fixture();
|
|
238
|
-
f.registry.register((0, utils_1.newid)(), f.definition);
|
|
239
|
-
const newer = {
|
|
240
|
-
...f.definition,
|
|
241
|
-
version: 2,
|
|
242
|
-
tools: [
|
|
243
|
-
{
|
|
244
|
-
...f.definition.tools[0],
|
|
245
|
-
inputFields: [
|
|
246
|
-
...f.definition.tools[0].inputFields,
|
|
247
|
-
{ name: "new", type: field_type_1.FieldType.number, optional: true },
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
};
|
|
252
|
-
expect(f.registry.register(f.provider, newer, [{ contractId: f.target.contractId, version: 1 }]).valid).toBe(true);
|
|
253
|
-
f.registry.setActiveProvider(f.target.contractId, 1, f.provider);
|
|
254
|
-
f.host(f.provider, 2);
|
|
255
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row).provider?.implementation?.version).toBe(2);
|
|
256
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, args: { value: "v1", new: "not a v2 number" } }, f.context)).resolves.toBe("ok");
|
|
257
|
-
// By name, the v1 row and the v2 row run the same tool: the v2 row is chosen, not "ambiguous".
|
|
258
|
-
const v2Target = { ...f.target, version: 2 };
|
|
259
|
-
const v2Row = {
|
|
260
|
-
...f.row,
|
|
261
|
-
toolId: (0, tool_catalog_identity_1.deriveToolCatalogId)(v2Target),
|
|
262
|
-
contractVersion: 2,
|
|
263
|
-
};
|
|
264
|
-
f.rows.set(v2Row.toolId, v2Row);
|
|
265
|
-
await expect((0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: "run", runnableOnly: true })).resolves.toMatchObject({ toolId: v2Row.toolId });
|
|
266
|
-
});
|
|
267
|
-
test("name lookup keeps aliases ambiguous when the implementing version selects another provider", async () => {
|
|
268
|
-
const f = fixture();
|
|
269
|
-
const newer = { ...f.definition, version: 2 };
|
|
270
|
-
expect(f.registry.register(f.provider, newer, [
|
|
271
|
-
{ contractId: f.target.contractId, version: 1, definition: f.definition },
|
|
272
|
-
]).valid).toBe(true);
|
|
273
|
-
f.host(f.provider, 2);
|
|
274
|
-
const other = (0, utils_1.newid)();
|
|
275
|
-
expect(f.registry.register(other, newer).valid).toBe(true);
|
|
276
|
-
f.host(other, 2);
|
|
277
|
-
expect(f.registry.setActiveProvider(f.target.contractId, 2, other)).toBe(true);
|
|
278
|
-
const v2Row = {
|
|
279
|
-
...f.row,
|
|
280
|
-
toolId: (0, tool_catalog_identity_1.deriveToolCatalogId)({ ...f.target, version: 2 }),
|
|
281
|
-
contractVersion: 2,
|
|
282
|
-
};
|
|
283
|
-
f.rows.set(v2Row.toolId, v2Row);
|
|
284
|
-
await expect((0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: "run", runnableOnly: true })).rejects.toThrow('Ambiguous tool "run": matched 2 tools');
|
|
285
|
-
for (const [row, provider] of [
|
|
286
|
-
[f.row, f.provider],
|
|
287
|
-
[v2Row, other],
|
|
288
|
-
]) {
|
|
289
|
-
await expect((0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: row.toolId, runnableOnly: true })).resolves.toMatchObject({ provider: { activePackageId: provider } });
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
test("rejects self targets, unresolved and quarantined rows, and never uses legacy invocation", async () => {
|
|
293
|
-
const f = fixture();
|
|
294
|
-
for (const row of [
|
|
295
|
-
{ ...f.row, catalogState: "quarantined" },
|
|
296
|
-
{
|
|
297
|
-
...f.row,
|
|
298
|
-
toolId: (0, utils_1.newid)(),
|
|
299
|
-
contractId: undefined,
|
|
300
|
-
contractVersion: undefined,
|
|
301
|
-
toolName: undefined,
|
|
302
|
-
catalogIdentity: undefined,
|
|
303
|
-
catalogState: "unresolved",
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
...f.row,
|
|
307
|
-
toolId: (0, tool_catalog_identity_1.deriveToolCatalogId)({
|
|
308
|
-
contractId: system_ids_1.toolCatalogContractId,
|
|
309
|
-
version: 1,
|
|
310
|
-
toolName: "invokeTool",
|
|
311
|
-
}),
|
|
312
|
-
contractId: system_ids_1.toolCatalogContractId,
|
|
313
|
-
toolName: "invokeTool",
|
|
314
|
-
},
|
|
315
|
-
]) {
|
|
316
|
-
f.rows.set(row.toolId, row);
|
|
317
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: row.toolId }, f.context)).rejects.toThrow();
|
|
318
|
-
}
|
|
319
|
-
f.rows.set(f.row.toolId, f.row);
|
|
320
|
-
f.registry.register(f.provider, f.definition);
|
|
321
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, args: { value: "ok" } }, f.context)).rejects.toThrow("no-implementation");
|
|
322
|
-
expect(f.loader.resolveContractEndpoint).not.toHaveBeenCalled();
|
|
323
|
-
});
|
|
324
|
-
test.each([
|
|
325
|
-
"own",
|
|
326
|
-
"downstream",
|
|
327
|
-
"failure",
|
|
328
|
-
"twice",
|
|
329
|
-
])("disposes endpoints and retries only its own first retirement: %s", async (mode) => {
|
|
330
|
-
const f = fixture();
|
|
331
|
-
f.install();
|
|
332
|
-
const next = { handleCall: jest.fn(async () => "next"), dispose: jest.fn() };
|
|
333
|
-
const replacement = (0, utils_1.newid)();
|
|
334
|
-
f.registry.register(replacement, f.definition);
|
|
335
|
-
f.host(replacement);
|
|
336
|
-
if (mode === "own")
|
|
337
|
-
f.loader.resolveContractEndpoint.mockImplementationOnce(async () => {
|
|
338
|
-
f.registry.setActiveProvider(f.target.contractId, 1, replacement);
|
|
339
|
-
return f.endpoint;
|
|
340
|
-
});
|
|
341
|
-
if (mode !== "own")
|
|
342
|
-
f.loader.resolveContractEndpoint.mockResolvedValueOnce(f.endpoint);
|
|
343
|
-
f.loader.resolveContractEndpoint.mockResolvedValueOnce(next);
|
|
344
|
-
f.endpoint.handleCall.mockRejectedValueOnce(mode === "failure"
|
|
345
|
-
? new Error("failed")
|
|
346
|
-
: new contract_provider_router_1.RetiredContractProviderEndpointError(mode === "downstream" ? next : f.endpoint));
|
|
347
|
-
if (mode === "twice")
|
|
348
|
-
next.handleCall.mockRejectedValueOnce(new contract_provider_router_1.RetiredContractProviderEndpointError(next));
|
|
349
|
-
const invoking = (0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: f.row.toolId, args: { value: "ok" } }, f.context);
|
|
350
|
-
if (mode === "own") {
|
|
351
|
-
await expect(invoking).resolves.toBe("next");
|
|
352
|
-
expect(f.loader.resolveContractEndpoint.mock.calls.at(-1)?.[0].providerPackageId).toBe(replacement);
|
|
353
|
-
}
|
|
354
|
-
else
|
|
355
|
-
await expect(invoking).rejects.toThrow();
|
|
356
|
-
expect(f.endpoint.dispose).toHaveBeenCalledTimes(1);
|
|
357
|
-
expect(f.loader.resolveContractEndpoint).toHaveBeenCalledTimes(mode === "own" || mode === "twice" ? 2 : 1);
|
|
358
|
-
expect(next.dispose).toHaveBeenCalledTimes(mode === "own" || mode === "twice" ? 1 : 0);
|
|
359
|
-
});
|
|
360
|
-
test("waits for readiness, bounds discovery, and projects live access without resolving an endpoint", async () => {
|
|
361
|
-
const f = fixture();
|
|
362
|
-
f.install();
|
|
363
|
-
await (0, tool_catalog_service_1.listToolCatalogEntries)(f.dataContext, { limit: 900, query: "ru" });
|
|
364
|
-
expect(f.table.list).toHaveBeenCalledWith({}, { pageSize: 500, textSearch: "ru" });
|
|
365
|
-
expect((await (0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: f.row.toolId }, f.context))?.access).toEqual({ accessLevel: 40, callerAccessLevel: 100, allowed: true });
|
|
366
|
-
f.loader.isolatedRuntime.isInstalled.mockReturnValue(true);
|
|
367
|
-
expect((await (0, tool_catalog_service_1.findToolCatalogEntry)(f.dataContext, { toolIdOrName: "run" }, f.context))?.access
|
|
368
|
-
?.accessLevel).toBe(40);
|
|
369
|
-
expect(f.loader.isolatedRuntime.resolveEndpoint).not.toHaveBeenCalled();
|
|
370
|
-
expect(f.loader.resolveContractEndpoint).not.toHaveBeenCalled();
|
|
371
|
-
let ready;
|
|
372
|
-
f.loader.catalogReady = new Promise((resolve) => {
|
|
373
|
-
ready = resolve;
|
|
374
|
-
});
|
|
375
|
-
f.table.list.mockClear();
|
|
376
|
-
const pending = (0, tool_catalog_service_1.listToolCatalogEntries)(f.dataContext);
|
|
377
|
-
await Promise.resolve();
|
|
378
|
-
expect(f.table.list).not.toHaveBeenCalled();
|
|
379
|
-
ready();
|
|
380
|
-
await pending;
|
|
381
|
-
});
|
|
382
|
-
test("an old bundle declaring a member without a resolver reports no implementation", () => {
|
|
383
|
-
const f = fixture();
|
|
384
|
-
f.registry.register(f.provider, f.definition);
|
|
385
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row).availability).toEqual({
|
|
386
|
-
dispatch: "unavailable",
|
|
387
|
-
reason: "no-implementation",
|
|
388
|
-
message: expect.stringContaining(`Provider ${f.provider} declares run but registers no implementation`),
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
test("workflow requirement is projected and enforced in the matching host context", async () => {
|
|
392
|
-
const f = fixture();
|
|
393
|
-
f.definition.tools[0].requiresWorkflowRun = true;
|
|
394
|
-
f.install();
|
|
395
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row)).toMatchObject({
|
|
396
|
-
workflowInvocable: true,
|
|
397
|
-
availability: { requiresWorkflowRun: true },
|
|
398
|
-
});
|
|
399
|
-
const input = { toolId: f.row.toolId, args: { value: "x" } };
|
|
400
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, f.context)).rejects.toThrow("requires a host workflow");
|
|
401
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, {
|
|
402
|
-
...f.context,
|
|
403
|
-
workflow: { dataContextId: "elsewhere" },
|
|
404
|
-
})).rejects.toThrow("does not match");
|
|
405
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, {
|
|
406
|
-
...f.context,
|
|
407
|
-
workflow: { dataContextId: f.dataContext.dataContextId },
|
|
408
|
-
})).resolves.toBe("ok");
|
|
409
|
-
});
|
|
410
|
-
test("remote catalog callers require host opt-in and retain identity; local-only targets reject", async () => {
|
|
411
|
-
const f = fixture();
|
|
412
|
-
f.install();
|
|
413
|
-
const remote = { ...f.context, callerDeviceId: (0, utils_1.newid)(), callerUserId: (0, utils_1.newid)() };
|
|
414
|
-
const input = { toolId: f.row.toolId, args: { value: "x" } };
|
|
415
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, remote)).rejects.toThrow("local user");
|
|
416
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, remote, { allowRemoteCaller: true })).resolves.toBe("ok");
|
|
417
|
-
expect(f.endpoint.handleCall).toHaveBeenCalledWith(expect.anything(), remote);
|
|
418
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, { ...remote, callerPackageId: (0, utils_1.newid)() }, { allowRemoteCaller: true })).rejects.toThrow("local user");
|
|
419
|
-
const { hostToolsContractId, getHostToolsContractDefinition } = require("../../index");
|
|
420
|
-
const { toolCatalogIds } = require("../tool-catalog-migrations");
|
|
421
|
-
const target = { contractId: hostToolsContractId, version: 1, toolName: "create-group" };
|
|
422
|
-
const row = {
|
|
423
|
-
...f.row,
|
|
424
|
-
toolId: toolCatalogIds(target)[0],
|
|
425
|
-
contractId: target.contractId,
|
|
426
|
-
toolName: target.toolName,
|
|
427
|
-
catalogIdentity: "legacy-alias",
|
|
428
|
-
};
|
|
429
|
-
f.rows.set(row.toolId, row);
|
|
430
|
-
f.registry.register(system_ids_1.peersSystemPackageId, getHostToolsContractDefinition());
|
|
431
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, { toolId: row.toolId }, remote, {
|
|
432
|
-
allowRemoteCaller: true,
|
|
433
|
-
})).rejects.toThrow("local-only");
|
|
434
|
-
});
|
|
435
|
-
test("workflow invocability excludes administrative systems and unavailable tools", () => {
|
|
436
|
-
const f = fixture();
|
|
437
|
-
f.install();
|
|
438
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row).workflowInvocable).toBe(true);
|
|
439
|
-
f.registry.unregister(f.provider);
|
|
440
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, f.row).workflowInvocable).toBe(false);
|
|
441
|
-
const sdk = require("../../index");
|
|
442
|
-
const ids = require("../tool-catalog-migrations");
|
|
443
|
-
for (const [definition, name, allowed] of [
|
|
444
|
-
[sdk.getHostToolsContractDefinition(), "tool-search", true],
|
|
445
|
-
[sdk.getToolAccessControlContractDefinition(), "approve", false],
|
|
446
|
-
[sdk.getIdentityContractDefinition(), "signIn", false],
|
|
447
|
-
]) {
|
|
448
|
-
f.registry.register(system_ids_1.peersSystemPackageId, definition);
|
|
449
|
-
const target = { contractId: definition.contractId, version: 1, toolName: name };
|
|
450
|
-
const row = {
|
|
451
|
-
...f.row,
|
|
452
|
-
toolId: ids.toolCatalogIds(target)[0],
|
|
453
|
-
contractId: target.contractId,
|
|
454
|
-
toolName: name,
|
|
455
|
-
catalogIdentity: "legacy-alias",
|
|
456
|
-
};
|
|
457
|
-
f.loader.isolatedRuntime.isInstalled.mockReturnValue(true);
|
|
458
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, row).workflowInvocable).toBe(allowed);
|
|
459
|
-
}
|
|
460
|
-
const legacy = {
|
|
461
|
-
...f.row,
|
|
462
|
-
toolId: (0, utils_1.newid)(),
|
|
463
|
-
contractId: undefined,
|
|
464
|
-
contractVersion: undefined,
|
|
465
|
-
toolName: undefined,
|
|
466
|
-
catalogState: "unresolved",
|
|
467
|
-
catalogIdentity: undefined,
|
|
468
|
-
};
|
|
469
|
-
expect((0, tool_catalog_service_1.describeToolCatalogRow)(f.dataContext, legacy).workflowInvocable).toBe(false);
|
|
470
|
-
});
|
|
471
|
-
test("workflow admission rejects a newly raised provider level and strips workflow from isolates", async () => {
|
|
472
|
-
const f = fixture();
|
|
473
|
-
f.install();
|
|
474
|
-
const context = { ...f.context, workflow: { dataContextId: f.dataContext.dataContextId } };
|
|
475
|
-
const input = { toolId: f.row.toolId, args: { value: "x" } };
|
|
476
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, context, { maxAccessLevel: 20 })).rejects.toThrow("exceeds the authorized");
|
|
477
|
-
f.loader.isolatedRuntime.isInstalled.mockReturnValue(true);
|
|
478
|
-
await (0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, context, { maxAccessLevel: 40 });
|
|
479
|
-
expect(f.loader.resolveContractEndpoint.mock.calls[0][0].context.workflow).toBeUndefined();
|
|
480
|
-
expect(f.endpoint.handleCall.mock.calls[0][1].workflow).toBeUndefined();
|
|
481
|
-
await expect((0, tool_catalog_service_1.invokeToolCatalogTool)(f.dataContext, input, { ...f.context, callerUserId: undefined, callerDeviceId: (0, utils_1.newid)() }, { allowRemoteCaller: true })).rejects.toThrow("caller user identity");
|
|
482
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../../index";
|