@peers-app/peers-sdk 0.26.5 → 0.27.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 +3 -1
- package/bin/peers-package.js +13 -0
- package/define/package.json +4 -0
- package/dist/contracts/__tests__/action-dispatch.test.js +56 -76
- package/dist/contracts/__tests__/also-implements.test.d.ts +1 -0
- package/dist/contracts/__tests__/also-implements.test.js +110 -0
- package/dist/contracts/__tests__/builder.test.js +45 -0
- package/dist/contracts/__tests__/contract-resolvers.test.js +134 -4
- package/dist/contracts/__tests__/frozen-contracts.test.d.ts +1 -0
- package/dist/contracts/__tests__/frozen-contracts.test.js +191 -0
- package/dist/contracts/__tests__/generic-tool-dispatch.test.js +13 -56
- package/dist/contracts/__tests__/host-contract-client.test.d.ts +1 -0
- package/dist/contracts/__tests__/host-contract-client.test.js +793 -0
- package/dist/contracts/__tests__/host-contract-transport.test.js +15 -0
- package/dist/contracts/__tests__/registry.test.js +68 -0
- package/dist/contracts/__tests__/target-dispatch.d.ts +11 -0
- package/dist/contracts/__tests__/target-dispatch.js +24 -0
- package/dist/contracts/__tests__/tool-catalog-service.test.js +37 -1
- package/dist/contracts/__tests__/tool-catalog.test.js +12 -3
- package/dist/contracts/__tests__/validate.test.js +177 -7
- package/dist/contracts/__tests__/workflow-context.test.js +0 -11
- package/dist/contracts/builder.d.ts +16 -2
- package/dist/contracts/builder.js +44 -3
- package/dist/contracts/contract-definition-schema.d.ts +251 -0
- package/dist/contracts/contract-definition-schema.js +48 -0
- package/dist/contracts/contract-provider-router.d.ts +2 -0
- package/dist/contracts/contract-provider-router.js +5 -2
- package/dist/contracts/contract-proxy.d.ts +52 -18
- package/dist/contracts/contract-proxy.js +144 -203
- package/dist/contracts/contract-resolvers.d.ts +6 -4
- package/dist/contracts/contract-resolvers.js +32 -9
- package/dist/contracts/frozen-contracts.d.ts +59 -0
- package/dist/contracts/frozen-contracts.js +86 -0
- package/dist/contracts/host-contract-client.d.ts +134 -0
- package/dist/contracts/host-contract-client.js +396 -0
- package/dist/contracts/host-contract-transport.d.ts +2 -0
- package/dist/contracts/host-contract-transport.js +8 -0
- package/dist/contracts/index.d.ts +6 -4
- package/dist/contracts/index.js +11 -5
- package/dist/contracts/registry.d.ts +31 -1
- package/dist/contracts/registry.js +100 -6
- package/dist/contracts/system/contract-catalog-contract.d.ts +61 -6
- package/dist/contracts/system/contract-catalog-contract.js +17 -5
- package/dist/contracts/tool-catalog-service.js +26 -6
- package/dist/contracts/tool-catalog.d.ts +1 -1
- package/dist/contracts/tool-catalog.js +4 -1
- package/dist/contracts/types.d.ts +32 -2
- package/dist/contracts/validate.d.ts +16 -1
- package/dist/contracts/validate.js +139 -25
- package/dist/data/change-tracking.d.ts +17 -5
- package/dist/data/change-tracking.js +22 -6
- package/dist/data/change-tracking.test.d.ts +1 -0
- package/dist/data/change-tracking.test.js +62 -0
- package/dist/data/group-members.d.ts +6 -1
- package/dist/data/group-members.js +12 -4
- package/dist/data/groups.d.ts +6 -1
- package/dist/data/groups.js +12 -4
- package/dist/data/orm/sql.data-source.d.ts +9 -0
- package/dist/data/orm/sql.data-source.js +47 -2
- package/dist/data/orm/sql.data-source.test.js +142 -0
- package/dist/data/orm/table-container.js +9 -9
- package/dist/data/orm/table-container.test.js +44 -0
- package/dist/data/orm/types.d.ts +41 -1
- package/dist/data/orm/types.js +159 -28
- package/dist/data/orm/types.test.js +129 -0
- package/dist/data/package-versions.d.ts +5 -1
- package/dist/data/package-versions.js +11 -4
- package/dist/data/packages.d.ts +7 -1
- package/dist/data/packages.js +13 -4
- package/dist/data/peer-types.d.ts +8 -62
- package/dist/data/persistent-vars.d.ts +4 -1
- package/dist/data/persistent-vars.js +7 -2
- package/dist/data/table-signing.test.d.ts +1 -0
- package/dist/data/table-signing.test.js +118 -0
- package/dist/data/tools.d.ts +29 -221
- package/dist/data/users.d.ts +1 -2
- package/dist/data/users.js +8 -5
- package/dist/define/also-implements.test.d.ts +1 -0
- package/dist/define/also-implements.test.js +123 -0
- package/dist/define/context.d.ts +77 -0
- package/dist/define/context.js +2 -0
- package/dist/define/contract-ref.d.ts +177 -0
- package/dist/define/contract-ref.js +67 -0
- package/dist/define/declare-contract.d.ts +167 -0
- package/dist/define/declare-contract.js +220 -0
- package/dist/define/declare-contract.test.d.ts +1 -0
- package/dist/define/declare-contract.test.js +573 -0
- package/dist/define/define-package.d.ts +203 -0
- package/dist/define/define-package.js +289 -0
- package/dist/define/define.test.d.ts +1 -0
- package/dist/define/define.test.js +1010 -0
- package/dist/define/empty-fields.d.ts +15 -0
- package/dist/define/empty-fields.js +134 -0
- package/dist/define/empty-fields.test.d.ts +1 -0
- package/dist/define/empty-fields.test.js +55 -0
- package/dist/define/events-observables.test.d.ts +1 -0
- package/dist/define/events-observables.test.js +1013 -0
- package/dist/define/events.d.ts +81 -0
- package/dist/define/events.js +81 -0
- package/dist/define/generated-field.d.ts +20 -0
- package/dist/define/generated-field.js +25 -0
- package/dist/define/index.d.ts +28 -0
- package/dist/define/index.js +62 -0
- package/dist/define/lazy-members.d.ts +8 -0
- package/dist/define/lazy-members.js +38 -0
- package/dist/define/manifest.d.ts +63 -0
- package/dist/define/manifest.js +653 -0
- package/dist/define/observables.d.ts +146 -0
- package/dist/define/observables.js +187 -0
- package/dist/define/serve-members.d.ts +21 -0
- package/dist/define/serve-members.js +152 -0
- package/dist/define/serve-members.test.d.ts +1 -0
- package/dist/define/serve-members.test.js +630 -0
- package/dist/define/serve.d.ts +22 -0
- package/dist/define/serve.js +58 -0
- package/dist/define/system-contracts.d.ts +41 -0
- package/dist/define/system-contracts.js +21 -0
- package/dist/define/table-handle.d.ts +13 -0
- package/dist/define/table-handle.js +36 -0
- package/dist/define/table.d.ts +128 -0
- package/dist/define/table.js +122 -0
- package/dist/define/tool.d.ts +129 -0
- package/dist/define/tool.js +91 -0
- package/dist/define/vars.d.ts +82 -0
- package/dist/define/vars.js +256 -0
- package/dist/define/vars.test.d.ts +1 -0
- package/dist/define/vars.test.js +39 -0
- package/dist/define/wire-value.d.ts +12 -0
- package/dist/define/wire-value.js +76 -0
- package/dist/define/worker-state.d.ts +15 -0
- package/dist/define/worker-state.js +45 -0
- package/dist/device/tx-encoding.test.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/observable.d.ts +42 -2
- package/dist/observable.js +25 -7
- package/dist/package-build/build-package.d.ts +60 -0
- package/dist/package-build/build-package.js +312 -0
- package/dist/package-build/build-package.test.d.ts +1 -0
- package/dist/package-build/build-package.test.js +204 -0
- package/dist/package-build/cli.d.ts +7 -0
- package/dist/package-build/cli.js +218 -0
- package/dist/package-build/contract-add.d.ts +35 -0
- package/dist/package-build/contract-add.js +97 -0
- package/dist/package-build/contract-add.test.d.ts +1 -0
- package/dist/package-build/contract-add.test.js +467 -0
- package/dist/package-build/contract-source.d.ts +59 -0
- package/dist/package-build/contract-source.js +471 -0
- package/dist/package-build/freeze-contracts.d.ts +56 -0
- package/dist/package-build/freeze-contracts.js +198 -0
- package/dist/package-build/freeze-contracts.test.d.ts +1 -0
- package/dist/package-build/freeze-contracts.test.js +355 -0
- package/dist/package-installer/package-creator.d.ts +4 -0
- package/dist/package-installer/package-creator.js +57 -16
- package/dist/package-installer/package-creator.test.js +86 -0
- package/dist/package-loader/contract-members.d.ts +53 -0
- package/dist/package-loader/contract-members.js +31 -0
- package/dist/package-loader/contract-package-loader.js +5 -1
- package/dist/package-loader/contract-package-loader.test.js +11 -0
- package/dist/package-loader/host-authority-loading.test.js +9 -5
- package/dist/package-loader/index.d.ts +1 -0
- package/dist/package-loader/index.js +1 -0
- package/dist/package-loader/isolated-artifact.d.ts +80 -17
- package/dist/package-loader/isolated-artifact.js +257 -51
- package/dist/package-loader/isolated-artifact.test.js +294 -21
- package/dist/package-loader/isolated-runtime.d.ts +22 -7
- package/dist/package-loader/isolated-table-gateway.js +30 -11
- package/dist/package-loader/isolated-table-gateway.test.js +243 -0
- package/dist/package-loader/package-loader.d.ts +8 -1
- package/dist/package-loader/package-loader.js +39 -20
- package/dist/package-loader/package-loader.test.js +47 -0
- package/dist/peer-id.d.ts +25 -0
- package/dist/peer-id.js +99 -0
- package/dist/serial-json.compat.test.d.ts +1 -0
- package/dist/serial-json.compat.test.js +369 -0
- package/dist/serial-json.d.ts +41 -5
- package/dist/serial-json.js +216 -157
- package/dist/serial-json.oracle.d.ts +21 -0
- package/dist/serial-json.oracle.js +222 -0
- package/dist/serial-json.test.js +315 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/mock-host-contract.d.ts +123 -0
- package/dist/testing/mock-host-contract.js +434 -0
- package/dist/testing/mock-host-contract.test.d.ts +1 -0
- package/dist/testing/mock-host-contract.test.js +782 -0
- package/dist/types/field-type.d.ts +35 -18
- package/dist/types/field-type.js +4 -1
- package/dist/types/zod-types.d.ts +9 -0
- package/dist/types/zod-types.js +8 -2
- package/dist/utils.d.ts +1 -25
- package/dist/utils.js +10 -90
- package/package.json +9 -2
- package/testing/package.json +4 -0
|
@@ -2,19 +2,21 @@ export * from "./action-dispatch";
|
|
|
2
2
|
export { ContractBuilder, definePackage, PackageBuilder } from "./builder";
|
|
3
3
|
export { type ContractCallAuthorizer, type ContractProviderEndpointResolver, type ContractProviderPackageResolver, createContractProviderRouter, type IAuthorizedContractRoute, type IContractProviderEndpointRequest, type IContractProviderRouter, type IContractProviderRouterOptions, RetiredContractProviderEndpointError, } from "./contract-provider-router";
|
|
4
4
|
export { ContractProviders, ContractProvidersTable, contractProvidersMetaData, contractProvidersSchema, type IContractProviderRecord, } from "./contract-providers.table";
|
|
5
|
-
export {
|
|
5
|
+
export { CONTRACT_CALL_RPC, type ContractMemberType, type ContractNotificationSink, type ContractPermissionCheck, type ContractToolDispatch, createContractConsumer, createContractProvider, createContractProviderEndpoint, createContractProviderSession, createRemoteContractConsumer, type IContractCall, type IContractCallContext, type IContractConsumer, type IContractConsumerBase, type IContractNotification, type IContractProviderEndpoint, type IContractProviderEndpointOptions, type IContractProviderSession, type IContractProviderSessionOptions, type IContractResolution, type IContractSubscription, type IContractTableProxy, type IContractToolContext, type IContractToolImplementation, type IContractToolTarget, type ITableProxy, requireWorkflowRunContext, sameUserContractPermissionCheck, } from "./contract-proxy";
|
|
6
6
|
export { authorizeRemoteContractCall, type ContractRemoteIdentity, type ContractResolver, createLocalUserContextContractProviderRouter, createUserContextContractProviderRouter, getContractResolver, handleContractCall, type IContractResolverRegistrationOptions, type ILocalContractVariableRequest, isLocalOnlyContractId, isSelfTrustedContractCaller, type LocalContractVariableResolver, registerContractResolver, verifyRemoteContractIdentity, } from "./contract-resolvers";
|
|
7
7
|
export { CONTRACT_NOTIFY_CHANNEL, CONTRACT_REQUEST_CHANNEL, connectionContractTransport, type IContractTransport, type IDuplexEmitter, inProcessTransportPair, } from "./contract-transport";
|
|
8
8
|
export { Contracts, ContractsTable, contractsMetaData, contractsSchema, type IContractRecord, } from "./contracts.table";
|
|
9
9
|
export { createLocalContractConsumer } from "./create-local-consumer";
|
|
10
10
|
export { extractTableShape, extractToolShape, type IExtractableTableDef, type IExtractableToolInstance, setSchemaToFieldsFn, } from "./extract";
|
|
11
|
+
export { checkFrozenContracts, describeFrozenContractChanges, FROZEN_CONTRACTS_FILE, freezeContracts, type IFrozenContract, type IFrozenContractChange, type IFrozenContracts, type IFrozenContractsCheck, } from "./frozen-contracts";
|
|
12
|
+
export { hostContract, type IHostContractClient, type IHostContractEvent, type IHostContractOptions, type IHostContractTable, type IHostSubscribeOptions, } from "./host-contract-client";
|
|
11
13
|
export { hostContractConsumer, type IHostContractConsumer, type IHostContractConsumerOptions, } from "./host-contract-consumer";
|
|
12
14
|
export { getHostContractTransport, type HostContractTransportListener, registerHostContractTransport, subscribeHostContractTransport, waitForHostContractTransport, } from "./host-contract-transport";
|
|
13
15
|
export { PersistentContractRegistry } from "./persistent-registry";
|
|
14
16
|
export { ContractRegistry, type IContractProviderRegistration } from "./registry";
|
|
15
17
|
export { createRemoteContractEndpoint, getRemoteContractTransportFactory, type IRemoteContractHost, type IRemoteContractTarget, type RemoteContractTransportFactory, resolveRemoteTargetEndpoint, setRemoteContractTransportFactory, } from "./remote-contract-transport";
|
|
16
18
|
export * from "./system/app-updates-contract";
|
|
17
|
-
export { CONTRACT_CATALOG_VERSION, contractCatalogProviderPackageId, getContractCatalogDefinition, type IContractCatalogConsumer, type IContractProviderInfo, type IListContractProvidersInput, } from "./system/contract-catalog-contract";
|
|
19
|
+
export { CONTRACT_CATALOG_VERSION, contractCatalogProviderPackageId, getContractCatalogDefinition, type IContractCatalogConsumer, type IContractDefinitionWithPolicy, type IContractProviderInfo, type IContractToolPolicy, type IExposedContractInfo, type IExposedToolInfo, type IGetContractDefinitionInput, type IListContractProvidersInput, } from "./system/contract-catalog-contract";
|
|
18
20
|
export * from "./system/desktop-tools-contract";
|
|
19
21
|
export { DEVICE_OPERATIONS_CONTRACT_VERSION, DEVICE_OPERATIONS_MAX_QUERY_LENGTH, DEVICE_OPERATIONS_MAX_RESULT_BYTES, DEVICE_OPERATIONS_MAX_ROWS, DEVICE_OPERATIONS_MAX_TOOLS, type DeviceOperationCapability, deviceOperationsProviderPackageId, deviceOperationsToolIds, getDeviceOperationsContractDefinition, type IDeviceDatabaseQueryInput, type IDeviceDatabaseQueryResult, type IDeviceOperationStatus, type IDeviceToolListInput, type IDeviceToolLookupInput, type IDeviceToolLookupResult, type IDeviceToolRunInput, } from "./system/device-operations-contract";
|
|
20
22
|
export * from "./system/host-shell-contract";
|
|
@@ -34,6 +36,6 @@ export * from "./tool-catalog";
|
|
|
34
36
|
export * from "./tool-catalog-identity";
|
|
35
37
|
export * from "./tool-catalog-migrations";
|
|
36
38
|
export * from "./tool-catalog-service";
|
|
37
|
-
export type { IAlsoImplementsDeclaration, IConsumedContract, IConsumedContractHandle, IConsumedContractOptions, IContractDefinition, IContractEvent, IContractObservable, IContractTable, IContractTool, IPackageDefinitionResult, IRemoteContract, IRemoteContractConsumer, IRemoteContractHandle, IResolvedContract, IValidationError, IValidationResult, } from "./types";
|
|
39
|
+
export type { IAlsoImplementsDeclaration, IConsumedContract, IConsumedContractHandle, IConsumedContractOptions, IContractDefinition, IContractEvent, IContractObservable, IContractTable, IContractTool, IExposedContract, IPackageDefinitionResult, IRemoteContract, IRemoteContractConsumer, IRemoteContractHandle, IResolvedContract, IValidationError, IValidationResult, } from "./types";
|
|
38
40
|
export { contractKey } from "./types";
|
|
39
|
-
export { validateAlsoImplements, validateImmutability, validateProviderSatisfiesContract, } from "./validate";
|
|
41
|
+
export { contractShapeChanges, validateAlsoImplements, validateImmutability, validateProviderSatisfiesContract, } from "./validate";
|
package/dist/contracts/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.validateProviderSatisfiesContract = exports.validateImmutability = void 0;
|
|
17
|
+
exports.ContractRegistry = exports.PersistentContractRegistry = exports.waitForHostContractTransport = exports.subscribeHostContractTransport = exports.registerHostContractTransport = exports.getHostContractTransport = exports.hostContractConsumer = exports.hostContract = exports.freezeContracts = exports.FROZEN_CONTRACTS_FILE = exports.describeFrozenContractChanges = exports.checkFrozenContracts = exports.setSchemaToFieldsFn = exports.extractToolShape = exports.extractTableShape = exports.createLocalContractConsumer = exports.contractsSchema = exports.contractsMetaData = exports.ContractsTable = exports.Contracts = exports.inProcessTransportPair = exports.connectionContractTransport = exports.CONTRACT_REQUEST_CHANNEL = exports.CONTRACT_NOTIFY_CHANNEL = exports.verifyRemoteContractIdentity = exports.registerContractResolver = exports.isSelfTrustedContractCaller = exports.isLocalOnlyContractId = exports.handleContractCall = exports.getContractResolver = exports.createUserContextContractProviderRouter = exports.createLocalUserContextContractProviderRouter = exports.authorizeRemoteContractCall = exports.sameUserContractPermissionCheck = exports.requireWorkflowRunContext = exports.createRemoteContractConsumer = exports.createContractProviderSession = exports.createContractProviderEndpoint = exports.createContractProvider = exports.createContractConsumer = exports.CONTRACT_CALL_RPC = exports.contractProvidersSchema = exports.contractProvidersMetaData = exports.ContractProvidersTable = exports.ContractProviders = exports.RetiredContractProviderEndpointError = exports.createContractProviderRouter = exports.PackageBuilder = exports.definePackage = exports.ContractBuilder = void 0;
|
|
18
|
+
exports.listSystemContracts = exports.isSystemContractId = exports.installSystemContracts = exports.TOOL_ACCESS_CONTROL_CONTRACT_VERSION = exports.getToolAccessControlContractDefinition = exports.schedulerProviderPackageId = exports.SCHEDULER_MAX_DELAY_MS = exports.SCHEDULER_CONTRACT_VERSION = exports.getSchedulerContractDefinition = exports.resolveLogsContract = exports.LOGS_CONTRACT_VERSION = exports.getLogsContractDefinition = exports.localFoldersProviderPackageId = exports.LOCAL_FOLDERS_RESERVED_DIR = exports.LOCAL_FOLDERS_READ_RANGE_MAX = exports.LOCAL_FOLDERS_JOB_TTL_MS = exports.LOCAL_FOLDERS_HAVE_BATCH = exports.LOCAL_FOLDERS_GETBLOCKS_MAX_BYTES = exports.LOCAL_FOLDERS_GETBLOCKS_MAX_BLOCKS = exports.LOCAL_FOLDERS_CONTRACT_VERSION = exports.LOCAL_FOLDERS_CHUNK_MIN = exports.LOCAL_FOLDERS_CHUNK_MAX = exports.LOCAL_FOLDERS_CHUNK_AVG = exports.LOCAL_FOLDERS_ASSEMBLE_STALL_MS = exports.getLocalFoldersContractDefinition = exports.INVITES_CONTRACT_VERSION = exports.getInvitesContractDefinition = exports.IDENTITY_CONTRACT_VERSION = exports.getIdentityContractDefinition = exports.httpProviderPackageId = exports.HTTP_MAX_TIMEOUT_MS = exports.HTTP_MAX_BODY_BYTES = exports.HTTP_DEFAULT_TIMEOUT_MS = exports.HTTP_CONTRACT_VERSION = exports.getHttpContractDefinition = exports.getDeviceOperationsContractDefinition = exports.deviceOperationsToolIds = exports.deviceOperationsProviderPackageId = exports.DEVICE_OPERATIONS_MAX_TOOLS = exports.DEVICE_OPERATIONS_MAX_ROWS = exports.DEVICE_OPERATIONS_MAX_RESULT_BYTES = exports.DEVICE_OPERATIONS_MAX_QUERY_LENGTH = exports.DEVICE_OPERATIONS_CONTRACT_VERSION = exports.getContractCatalogDefinition = exports.contractCatalogProviderPackageId = exports.CONTRACT_CATALOG_VERSION = exports.setRemoteContractTransportFactory = exports.resolveRemoteTargetEndpoint = exports.getRemoteContractTransportFactory = exports.createRemoteContractEndpoint = void 0;
|
|
19
|
+
exports.validateProviderSatisfiesContract = exports.validateImmutability = exports.validateAlsoImplements = exports.contractShapeChanges = exports.contractKey = exports.registerSystemContract = void 0;
|
|
20
20
|
__exportStar(require("./action-dispatch"), exports);
|
|
21
21
|
var builder_1 = require("./builder");
|
|
22
22
|
Object.defineProperty(exports, "ContractBuilder", { enumerable: true, get: function () { return builder_1.ContractBuilder; } });
|
|
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "ContractProvidersTable", { enumerable: true, get
|
|
|
31
31
|
Object.defineProperty(exports, "contractProvidersMetaData", { enumerable: true, get: function () { return contract_providers_table_1.contractProvidersMetaData; } });
|
|
32
32
|
Object.defineProperty(exports, "contractProvidersSchema", { enumerable: true, get: function () { return contract_providers_table_1.contractProvidersSchema; } });
|
|
33
33
|
var contract_proxy_1 = require("./contract-proxy");
|
|
34
|
-
Object.defineProperty(exports, "authorizedContractActionNames", { enumerable: true, get: function () { return contract_proxy_1.authorizedContractActionNames; } });
|
|
35
34
|
Object.defineProperty(exports, "CONTRACT_CALL_RPC", { enumerable: true, get: function () { return contract_proxy_1.CONTRACT_CALL_RPC; } });
|
|
36
35
|
Object.defineProperty(exports, "createContractConsumer", { enumerable: true, get: function () { return contract_proxy_1.createContractConsumer; } });
|
|
37
36
|
Object.defineProperty(exports, "createContractProvider", { enumerable: true, get: function () { return contract_proxy_1.createContractProvider; } });
|
|
@@ -40,7 +39,6 @@ Object.defineProperty(exports, "createContractProviderSession", { enumerable: tr
|
|
|
40
39
|
Object.defineProperty(exports, "createRemoteContractConsumer", { enumerable: true, get: function () { return contract_proxy_1.createRemoteContractConsumer; } });
|
|
41
40
|
Object.defineProperty(exports, "requireWorkflowRunContext", { enumerable: true, get: function () { return contract_proxy_1.requireWorkflowRunContext; } });
|
|
42
41
|
Object.defineProperty(exports, "sameUserContractPermissionCheck", { enumerable: true, get: function () { return contract_proxy_1.sameUserContractPermissionCheck; } });
|
|
43
|
-
Object.defineProperty(exports, "validateContractActions", { enumerable: true, get: function () { return contract_proxy_1.validateContractActions; } });
|
|
44
42
|
var contract_resolvers_1 = require("./contract-resolvers");
|
|
45
43
|
Object.defineProperty(exports, "authorizeRemoteContractCall", { enumerable: true, get: function () { return contract_resolvers_1.authorizeRemoteContractCall; } });
|
|
46
44
|
Object.defineProperty(exports, "createLocalUserContextContractProviderRouter", { enumerable: true, get: function () { return contract_resolvers_1.createLocalUserContextContractProviderRouter; } });
|
|
@@ -67,6 +65,13 @@ var extract_1 = require("./extract");
|
|
|
67
65
|
Object.defineProperty(exports, "extractTableShape", { enumerable: true, get: function () { return extract_1.extractTableShape; } });
|
|
68
66
|
Object.defineProperty(exports, "extractToolShape", { enumerable: true, get: function () { return extract_1.extractToolShape; } });
|
|
69
67
|
Object.defineProperty(exports, "setSchemaToFieldsFn", { enumerable: true, get: function () { return extract_1.setSchemaToFieldsFn; } });
|
|
68
|
+
var frozen_contracts_1 = require("./frozen-contracts");
|
|
69
|
+
Object.defineProperty(exports, "checkFrozenContracts", { enumerable: true, get: function () { return frozen_contracts_1.checkFrozenContracts; } });
|
|
70
|
+
Object.defineProperty(exports, "describeFrozenContractChanges", { enumerable: true, get: function () { return frozen_contracts_1.describeFrozenContractChanges; } });
|
|
71
|
+
Object.defineProperty(exports, "FROZEN_CONTRACTS_FILE", { enumerable: true, get: function () { return frozen_contracts_1.FROZEN_CONTRACTS_FILE; } });
|
|
72
|
+
Object.defineProperty(exports, "freezeContracts", { enumerable: true, get: function () { return frozen_contracts_1.freezeContracts; } });
|
|
73
|
+
var host_contract_client_1 = require("./host-contract-client");
|
|
74
|
+
Object.defineProperty(exports, "hostContract", { enumerable: true, get: function () { return host_contract_client_1.hostContract; } });
|
|
70
75
|
var host_contract_consumer_1 = require("./host-contract-consumer");
|
|
71
76
|
Object.defineProperty(exports, "hostContractConsumer", { enumerable: true, get: function () { return host_contract_consumer_1.hostContractConsumer; } });
|
|
72
77
|
var host_contract_transport_1 = require("./host-contract-transport");
|
|
@@ -154,6 +159,7 @@ __exportStar(require("./tool-catalog-service"), exports);
|
|
|
154
159
|
var types_1 = require("./types");
|
|
155
160
|
Object.defineProperty(exports, "contractKey", { enumerable: true, get: function () { return types_1.contractKey; } });
|
|
156
161
|
var validate_1 = require("./validate");
|
|
162
|
+
Object.defineProperty(exports, "contractShapeChanges", { enumerable: true, get: function () { return validate_1.contractShapeChanges; } });
|
|
157
163
|
Object.defineProperty(exports, "validateAlsoImplements", { enumerable: true, get: function () { return validate_1.validateAlsoImplements; } });
|
|
158
164
|
Object.defineProperty(exports, "validateImmutability", { enumerable: true, get: function () { return validate_1.validateImmutability; } });
|
|
159
165
|
Object.defineProperty(exports, "validateProviderSatisfiesContract", { enumerable: true, get: function () { return validate_1.validateProviderSatisfiesContract; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolCatalog } from "./tool-catalog";
|
|
2
|
-
import type { IAlsoImplementsDeclaration, IConsumedContract, IContractDefinition, IValidationResult } from "./types";
|
|
2
|
+
import type { IAlsoImplementsDeclaration, IConsumedContract, IContractDefinition, IExposedContract, IValidationResult } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* One contract-provider registration in an atomic
|
|
5
5
|
* {@link ContractRegistry.registerBatch} operation.
|
|
@@ -9,6 +9,11 @@ export interface IContractProviderRegistration {
|
|
|
9
9
|
definition: IContractDefinition;
|
|
10
10
|
/** Older contract shapes this implementation also satisfies. */
|
|
11
11
|
alsoImplements?: IAlsoImplementsDeclaration[];
|
|
12
|
+
/**
|
|
13
|
+
* Other contracts in the same batch whose tools this contract's consumers may call on this
|
|
14
|
+
* provider. Not part of the contract's shape.
|
|
15
|
+
*/
|
|
16
|
+
exposes?: IExposedContract[];
|
|
12
17
|
}
|
|
13
18
|
/**
|
|
14
19
|
* Per-group contract registry. Maps contract identities (contractId + version)
|
|
@@ -106,6 +111,24 @@ export declare class ContractRegistry {
|
|
|
106
111
|
contractId: string;
|
|
107
112
|
version: number;
|
|
108
113
|
} | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* The contracts one provider exposes through its implementation of a contract: their tools
|
|
116
|
+
* are callable on that provider by the contract's consumers. Empty when it exposes none.
|
|
117
|
+
*
|
|
118
|
+
* @param contractId - The hub contract's id.
|
|
119
|
+
* @param version - The hub contract's version.
|
|
120
|
+
* @param providerPackageId - A registered provider of it.
|
|
121
|
+
*/
|
|
122
|
+
getExposedContracts(contractId: string, version: number, providerPackageId: string): IExposedContract[];
|
|
123
|
+
/**
|
|
124
|
+
* The definition one provider registered for a contract version, which may differ from the
|
|
125
|
+
* latest registration's while the contract is dev.
|
|
126
|
+
*
|
|
127
|
+
* @param contractId - Contract id.
|
|
128
|
+
* @param version - Contract version.
|
|
129
|
+
* @param providerPackageId - A registered provider of it.
|
|
130
|
+
*/
|
|
131
|
+
getProviderDefinition(contractId: string, version: number, providerPackageId: string): IContractDefinition | undefined;
|
|
109
132
|
/**
|
|
110
133
|
* Pick a provider for a consumed-contract declaration.
|
|
111
134
|
*
|
|
@@ -139,3 +162,10 @@ export declare class ContractRegistry {
|
|
|
139
162
|
missing: IConsumedContract[];
|
|
140
163
|
};
|
|
141
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* The target definition an `alsoImplements` declaration carries for `version`, if any.
|
|
167
|
+
*
|
|
168
|
+
* @param declaration - The declaration.
|
|
169
|
+
* @param version - The target version being registered.
|
|
170
|
+
*/
|
|
171
|
+
export declare function carriedDefinition(declaration: IAlsoImplementsDeclaration, version: number): IContractDefinition | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContractRegistry = void 0;
|
|
4
|
+
exports.carriedDefinition = carriedDefinition;
|
|
4
5
|
const types_1 = require("./types");
|
|
5
6
|
const validate_1 = require("./validate");
|
|
6
7
|
/**
|
|
@@ -120,6 +121,60 @@ class ContractRegistry {
|
|
|
120
121
|
}
|
|
121
122
|
candidateDefinitions.set(key, definition);
|
|
122
123
|
}
|
|
124
|
+
for (const { definition, exposes = [] } of registrations) {
|
|
125
|
+
const key = (0, types_1.contractKey)(definition.contractId, definition.version);
|
|
126
|
+
const exposed = new Set();
|
|
127
|
+
for (const target of exposes) {
|
|
128
|
+
const targetKey = (0, types_1.contractKey)(target.contractId, target.version);
|
|
129
|
+
const problem = targetKey === key
|
|
130
|
+
? "can't expose itself"
|
|
131
|
+
: exposed.has(targetKey)
|
|
132
|
+
? `exposes ${targetKey} twice`
|
|
133
|
+
: !batchKeys.has(targetKey)
|
|
134
|
+
? `exposes ${targetKey}, which provider ${providerPackageId} doesn't provide`
|
|
135
|
+
: undefined;
|
|
136
|
+
if (problem) {
|
|
137
|
+
return {
|
|
138
|
+
valid: false,
|
|
139
|
+
errors: [{ kind: "contract", name: key, message: `Contract ${key} ${problem}` }],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exposed.add(targetKey);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// A target the registry doesn't have comes from the definition the provider carries; one it
|
|
146
|
+
// has frozen must match what the provider carries.
|
|
147
|
+
for (const { alsoImplements = [] } of registrations) {
|
|
148
|
+
for (const { contractId, version, definition: carried } of alsoImplements) {
|
|
149
|
+
if (!carried)
|
|
150
|
+
continue;
|
|
151
|
+
const key = (0, types_1.contractKey)(contractId, version);
|
|
152
|
+
const mismatch = typeof version !== "number" ||
|
|
153
|
+
carried.contractId !== contractId ||
|
|
154
|
+
carried.version !== version;
|
|
155
|
+
if (mismatch) {
|
|
156
|
+
return {
|
|
157
|
+
valid: false,
|
|
158
|
+
errors: [
|
|
159
|
+
{
|
|
160
|
+
kind: "contract",
|
|
161
|
+
name: key,
|
|
162
|
+
message: `alsoImplements carries a definition that isn't ${contractId} v${String(version)}`,
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const existing = candidateDefinitions.get(key);
|
|
168
|
+
if (!existing) {
|
|
169
|
+
candidateDefinitions.set(key, carried);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const immutability = (0, validate_1.validateImmutability)(existing, carried);
|
|
173
|
+
if (!immutability.valid) {
|
|
174
|
+
return immutability;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
123
178
|
for (const { definition, alsoImplements = [] } of registrations) {
|
|
124
179
|
if (alsoImplements.length === 0) {
|
|
125
180
|
continue;
|
|
@@ -133,10 +188,10 @@ class ContractRegistry {
|
|
|
133
188
|
}
|
|
134
189
|
commitRegistrations(providerPackageId, registrations) {
|
|
135
190
|
const explicitKeys = new Set(registrations.map(({ definition }) => (0, types_1.contractKey)(definition.contractId, definition.version)));
|
|
136
|
-
for (const { definition } of registrations) {
|
|
137
|
-
this.commitProvider(providerPackageId, definition, definition);
|
|
191
|
+
for (const { definition, exposes = [] } of registrations) {
|
|
192
|
+
this.commitProvider(providerPackageId, definition, definition, exposes);
|
|
138
193
|
}
|
|
139
|
-
for (const { definition, alsoImplements = [] } of registrations) {
|
|
194
|
+
for (const { definition, alsoImplements = [], exposes = [] } of registrations) {
|
|
140
195
|
for (const declaration of alsoImplements) {
|
|
141
196
|
const declaredVersion = declaration.version;
|
|
142
197
|
const versions = typeof declaredVersion === "number"
|
|
@@ -147,15 +202,15 @@ class ContractRegistry {
|
|
|
147
202
|
if (explicitKeys.has(key)) {
|
|
148
203
|
continue;
|
|
149
204
|
}
|
|
150
|
-
const target = this.definitions.get(key);
|
|
205
|
+
const target = this.definitions.get(key) ?? carriedDefinition(declaration, version);
|
|
151
206
|
if (target) {
|
|
152
|
-
this.commitProvider(providerPackageId, target, definition);
|
|
207
|
+
this.commitProvider(providerPackageId, target, definition, exposes);
|
|
153
208
|
}
|
|
154
209
|
}
|
|
155
210
|
}
|
|
156
211
|
}
|
|
157
212
|
}
|
|
158
|
-
commitProvider(providerPackageId, definition, implementation) {
|
|
213
|
+
commitProvider(providerPackageId, definition, implementation, exposes) {
|
|
159
214
|
const key = (0, types_1.contractKey)(definition.contractId, definition.version);
|
|
160
215
|
this.definitions.set(key, definition);
|
|
161
216
|
const provider = {
|
|
@@ -163,6 +218,7 @@ class ContractRegistry {
|
|
|
163
218
|
definition,
|
|
164
219
|
implementationContractId: implementation.contractId,
|
|
165
220
|
implementationVersion: implementation.version,
|
|
221
|
+
exposes: exposes.map(({ contractId, version }) => ({ contractId, version })),
|
|
166
222
|
};
|
|
167
223
|
const providers = this.allProviders.get(key) ?? [];
|
|
168
224
|
const existingIdx = providers.findIndex((item) => item.providerPackageId === providerPackageId);
|
|
@@ -238,6 +294,29 @@ class ContractRegistry {
|
|
|
238
294
|
}
|
|
239
295
|
: undefined;
|
|
240
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The contracts one provider exposes through its implementation of a contract: their tools
|
|
299
|
+
* are callable on that provider by the contract's consumers. Empty when it exposes none.
|
|
300
|
+
*
|
|
301
|
+
* @param contractId - The hub contract's id.
|
|
302
|
+
* @param version - The hub contract's version.
|
|
303
|
+
* @param providerPackageId - A registered provider of it.
|
|
304
|
+
*/
|
|
305
|
+
getExposedContracts(contractId, version, providerPackageId) {
|
|
306
|
+
const provider = (this.allProviders.get((0, types_1.contractKey)(contractId, version)) ?? []).find((candidate) => candidate.providerPackageId === providerPackageId);
|
|
307
|
+
return (provider?.exposes ?? []).map((exposed) => ({ ...exposed }));
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The definition one provider registered for a contract version, which may differ from the
|
|
311
|
+
* latest registration's while the contract is dev.
|
|
312
|
+
*
|
|
313
|
+
* @param contractId - Contract id.
|
|
314
|
+
* @param version - Contract version.
|
|
315
|
+
* @param providerPackageId - A registered provider of it.
|
|
316
|
+
*/
|
|
317
|
+
getProviderDefinition(contractId, version, providerPackageId) {
|
|
318
|
+
return (this.allProviders.get((0, types_1.contractKey)(contractId, version)) ?? []).find((candidate) => candidate.providerPackageId === providerPackageId)?.definition;
|
|
319
|
+
}
|
|
241
320
|
/**
|
|
242
321
|
* Pick a provider for a consumed-contract declaration.
|
|
243
322
|
*
|
|
@@ -337,3 +416,18 @@ class ContractRegistry {
|
|
|
337
416
|
}
|
|
338
417
|
}
|
|
339
418
|
exports.ContractRegistry = ContractRegistry;
|
|
419
|
+
/**
|
|
420
|
+
* The target definition an `alsoImplements` declaration carries for `version`, if any.
|
|
421
|
+
*
|
|
422
|
+
* @param declaration - The declaration.
|
|
423
|
+
* @param version - The target version being registered.
|
|
424
|
+
*/
|
|
425
|
+
function carriedDefinition(declaration, version) {
|
|
426
|
+
const carried = declaration.definition;
|
|
427
|
+
return carried &&
|
|
428
|
+
carried.contractId === declaration.contractId &&
|
|
429
|
+
carried.version === version &&
|
|
430
|
+
declaration.version === version
|
|
431
|
+
? carried
|
|
432
|
+
: undefined;
|
|
433
|
+
}
|
|
@@ -11,30 +11,85 @@ export interface IContractProviderInfo {
|
|
|
11
11
|
name: string;
|
|
12
12
|
/** True when this package is the active provider for the contract version. */
|
|
13
13
|
active: boolean;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The contracts this provider exposes through the listed contract, when it's a hub's: their
|
|
16
|
+
* tools are callable on this provider by the listed contract's consumers. Each lists only the
|
|
17
|
+
* tools this caller may run.
|
|
18
|
+
*/
|
|
19
|
+
exposes?: IExposedContractInfo[];
|
|
20
|
+
}
|
|
21
|
+
/** A contract one provider exposes through a hub's contract, as {@link IContractProviderInfo} lists it. */
|
|
22
|
+
export interface IExposedContractInfo {
|
|
23
|
+
/** The exposed contract's id. */
|
|
24
|
+
contractId: string;
|
|
25
|
+
/** Its version. */
|
|
26
|
+
version: number;
|
|
27
|
+
/** Its name. */
|
|
28
|
+
name: string;
|
|
29
|
+
/** What it's for. */
|
|
30
|
+
description?: string;
|
|
31
|
+
/** Its tools this caller may run on the provider, in the contract's order. */
|
|
32
|
+
tools: IExposedToolInfo[];
|
|
33
|
+
}
|
|
34
|
+
/** One tool on an exposed contract that the caller may run. */
|
|
35
|
+
export interface IExposedToolInfo {
|
|
36
|
+
/** The tool's name, for `contractRef(contractId, version)(ctx, { providerPackageId }).tools[name]`. */
|
|
37
|
+
name: string;
|
|
38
|
+
/** What it does: the tool's usage description. */
|
|
39
|
+
description: string;
|
|
40
|
+
/** The level a caller needs to run it on this provider. */
|
|
41
|
+
accessLevel: number;
|
|
42
|
+
/** JSON Schema for its arguments. */
|
|
43
|
+
inputSchema: Record<string, unknown>;
|
|
16
44
|
}
|
|
17
45
|
/** Input for listing providers of one contract version. */
|
|
18
46
|
export interface IListContractProvidersInput {
|
|
19
47
|
contractId: string;
|
|
20
48
|
version: number;
|
|
21
49
|
}
|
|
50
|
+
/** Input for reading one registered contract version's definition. */
|
|
51
|
+
export interface IGetContractDefinitionInput {
|
|
52
|
+
contractId: string;
|
|
53
|
+
version: number;
|
|
54
|
+
}
|
|
55
|
+
/** One tool's policy on a contract's active provider. */
|
|
56
|
+
export interface IContractToolPolicy {
|
|
57
|
+
/** The tool's name. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** The level a caller needs. */
|
|
60
|
+
accessLevel?: number;
|
|
61
|
+
/** Whether the tool keeps the caller's level for its outgoing calls. */
|
|
62
|
+
authorityPropagation?: "cap" | "preserve";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A registered contract definition, with each tool's policy on the active provider (which the
|
|
66
|
+
* definition itself doesn't carry): what `peers-package contract add` generates a declaration
|
|
67
|
+
* from.
|
|
68
|
+
*/
|
|
69
|
+
export interface IContractDefinitionWithPolicy {
|
|
70
|
+
/** The registered definition. */
|
|
71
|
+
definition: IContractDefinition;
|
|
72
|
+
/** Each tool's policy, where the Runtime knows it. */
|
|
73
|
+
tools?: IContractToolPolicy[];
|
|
74
|
+
}
|
|
22
75
|
/**
|
|
23
76
|
* Consumer shape for the System Contract Catalog.
|
|
24
77
|
*
|
|
25
|
-
* Hub packages use this to discover every provider of a shared contract
|
|
78
|
+
* Hub packages use this to discover every provider of a shared contract; package authors and
|
|
79
|
+
* agents read a contract's definition with it.
|
|
26
80
|
*/
|
|
27
81
|
export interface IContractCatalogConsumer extends IContractConsumerBase {
|
|
28
82
|
tools: {
|
|
29
83
|
listContractProviders(input: IListContractProvidersInput): Promise<{
|
|
30
84
|
providers: IContractProviderInfo[];
|
|
31
85
|
}>;
|
|
86
|
+
getContractDefinition(input: IGetContractDefinitionInput): Promise<IContractDefinitionWithPolicy>;
|
|
32
87
|
};
|
|
33
88
|
}
|
|
34
89
|
/**
|
|
35
|
-
* Return the local-only catalog contract
|
|
90
|
+
* Return the local-only catalog contract for discovering providers and reading definitions.
|
|
36
91
|
*
|
|
37
|
-
* The active provider remains the default for ordinary calls.
|
|
38
|
-
*
|
|
92
|
+
* The active provider remains the default for ordinary calls. Consumers can discover every
|
|
93
|
+
* registered provider; authors can read a definition with its active provider's tool policy.
|
|
39
94
|
*/
|
|
40
95
|
export declare function getContractCatalogDefinition(): IContractDefinition;
|
|
@@ -12,10 +12,10 @@ exports.contractCatalogProviderPackageId = system_ids_1.peersSystemPackageId;
|
|
|
12
12
|
const field = (name, type, description, opts = {}) => ({ name, type, description, ...opts });
|
|
13
13
|
let definition;
|
|
14
14
|
/**
|
|
15
|
-
* Return the local-only catalog contract
|
|
15
|
+
* Return the local-only catalog contract for discovering providers and reading definitions.
|
|
16
16
|
*
|
|
17
|
-
* The active provider remains the default for ordinary calls.
|
|
18
|
-
*
|
|
17
|
+
* The active provider remains the default for ordinary calls. Consumers can discover every
|
|
18
|
+
* registered provider; authors can read a definition with its active provider's tool policy.
|
|
19
19
|
*/
|
|
20
20
|
function getContractCatalogDefinition() {
|
|
21
21
|
definition ??= {
|
|
@@ -23,7 +23,7 @@ function getContractCatalogDefinition() {
|
|
|
23
23
|
version: exports.CONTRACT_CATALOG_VERSION,
|
|
24
24
|
devTag: "dev",
|
|
25
25
|
name: "System Contract Catalog",
|
|
26
|
-
description: "Lists
|
|
26
|
+
description: "Lists registered contract providers and returns contract definitions with active tool policy.",
|
|
27
27
|
tables: [],
|
|
28
28
|
tools: [
|
|
29
29
|
{
|
|
@@ -34,7 +34,19 @@ function getContractCatalogDefinition() {
|
|
|
34
34
|
field("version", field_type_1.FieldType.number, "Contract version."),
|
|
35
35
|
],
|
|
36
36
|
outputFields: [
|
|
37
|
-
field("providers", field_type_1.FieldType.object, "Registered providers in registration order, with packageId, name, and
|
|
37
|
+
field("providers", field_type_1.FieldType.object, "Registered providers in registration order, with packageId, name, active, and the contracts each exposes through this one.", { isArray: true }),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "getContractDefinition",
|
|
42
|
+
usageDescription: "Return a registered contract version's definition, with each tool's access level on its active provider. Save the result and run `peers-package contract add <file>` to generate a declaration of the contract.",
|
|
43
|
+
inputFields: [
|
|
44
|
+
field("contractId", field_type_1.FieldType.id, "Contract to read."),
|
|
45
|
+
field("version", field_type_1.FieldType.number, "Contract version."),
|
|
46
|
+
],
|
|
47
|
+
outputFields: [
|
|
48
|
+
field("definition", field_type_1.FieldType.object, "The registered definition, in Peers IR."),
|
|
49
|
+
field("tools", field_type_1.FieldType.object, "Each tool's name, accessLevel, and authorityPropagation on the active provider.", { isArray: true, optional: true }),
|
|
38
50
|
],
|
|
39
51
|
},
|
|
40
52
|
],
|
|
@@ -124,13 +124,32 @@ async function findToolCatalogEntry(dataContext, input, callerContext) {
|
|
|
124
124
|
const entries = rows
|
|
125
125
|
.map((row) => describeToolCatalogRow(dataContext, row))
|
|
126
126
|
.filter((entry) => !input.runnableOnly || entry.availability.dispatch !== "unavailable");
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
// A version a provider also implements runs the same tool as the version implementing it
|
|
128
|
+
// only when both select that provider. Count them once and choose its implementing row.
|
|
129
|
+
const ranTool = (entry) => {
|
|
130
|
+
const implementation = entry.provider?.implementation;
|
|
131
|
+
return entry.target && implementation
|
|
132
|
+
? JSON.stringify([
|
|
133
|
+
entry.provider?.activePackageId,
|
|
134
|
+
(0, tool_catalog_identity_1.toolCatalogTargetKey)({ ...entry.target, ...implementation }),
|
|
135
|
+
])
|
|
136
|
+
: entry.target
|
|
137
|
+
? (0, tool_catalog_identity_1.toolCatalogTargetKey)(entry.target)
|
|
138
|
+
: entry.toolId;
|
|
139
|
+
};
|
|
140
|
+
const implementing = (entry) => !entry.provider?.implementation ||
|
|
141
|
+
(entry.target?.contractId === entry.provider.implementation.contractId &&
|
|
142
|
+
entry.target?.version === entry.provider.implementation.version);
|
|
143
|
+
const groups = new Map();
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
const key = ranTool(entry);
|
|
146
|
+
const chosen = groups.get(key);
|
|
147
|
+
if (!chosen || (!implementing(chosen) && implementing(entry)))
|
|
148
|
+
groups.set(key, entry);
|
|
149
|
+
}
|
|
131
150
|
if (groups.size > 1)
|
|
132
151
|
throw new Error(`Ambiguous tool "${input.toolIdOrName}": matched ${groups.size} tools (${entries.map((entry) => entry.toolId).join(", ")}); use a tool ID`);
|
|
133
|
-
return
|
|
152
|
+
return groups.values().next().value;
|
|
134
153
|
};
|
|
135
154
|
const entry = exact
|
|
136
155
|
? describeToolCatalogRow(dataContext, exact)
|
|
@@ -241,7 +260,8 @@ async function invokeToolCatalogTool(dataContext, input, context, opts = {}) {
|
|
|
241
260
|
}
|
|
242
261
|
const source = input.args === undefined ? {} : input.args;
|
|
243
262
|
requirePlainObject(source, "Tool args");
|
|
244
|
-
|
|
263
|
+
// An optional argument that is null (as models often send) or undefined is left out.
|
|
264
|
+
const args = (0, types_1.withoutEmptyFields)(tool.inputFields, { ...source });
|
|
245
265
|
for (const field of tool.inputFields)
|
|
246
266
|
if (field.type === field_type_1.FieldType.Date && !field.isArray && typeof args[field.name] === "string")
|
|
247
267
|
args[field.name] = new Date(args[field.name]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataContext } from "../context/data-context";
|
|
2
2
|
import { type ITool } from "../data/tools";
|
|
3
|
-
import type
|
|
3
|
+
import { type ContractRegistry, type IContractProviderRegistration } from "./registry";
|
|
4
4
|
import { type ToolCatalogTarget } from "./tool-catalog-identity";
|
|
5
5
|
/** Supplemental metadata keyed by a declared public contract member, never by executable IDs. */
|
|
6
6
|
export type IToolCatalogMetadata = ToolCatalogTarget & Pick<Partial<ITool>, "isAssistantRunner" | "configSchema" | "detailedDescription">;
|
|
@@ -6,6 +6,7 @@ exports.retainToolCatalogFields = retainToolCatalogFields;
|
|
|
6
6
|
exports.validateToolCatalogWrite = validateToolCatalogWrite;
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
8
|
const tools_1 = require("../data/tools");
|
|
9
|
+
const registry_1 = require("./registry");
|
|
9
10
|
const system_contracts_1 = require("./system-contracts");
|
|
10
11
|
const tool_catalog_identity_1 = require("./tool-catalog-identity");
|
|
11
12
|
const tool_catalog_migrations_1 = require("./tool-catalog-migrations");
|
|
@@ -357,7 +358,9 @@ class ToolCatalog {
|
|
|
357
358
|
const to = typeof range === "number" ? range : range.to;
|
|
358
359
|
for (let version = from; version <= to; version++) {
|
|
359
360
|
const key = `${declaration.contractId}@${version}`;
|
|
360
|
-
const definition = definitions.get(key) ??
|
|
361
|
+
const definition = definitions.get(key) ??
|
|
362
|
+
this.registry.getDefinition(declaration.contractId, version) ??
|
|
363
|
+
(0, registry_1.carriedDefinition)(declaration, version);
|
|
361
364
|
if (!definition)
|
|
362
365
|
throw new Error(`Missing alsoImplements definition: ${key}`);
|
|
363
366
|
definitions.set(key, definition);
|
|
@@ -2,7 +2,7 @@ import type { Table } from "../data/orm/table";
|
|
|
2
2
|
import type { ITableDefinition } from "../data/orm/table-definitions.type";
|
|
3
3
|
import type { Event } from "../events";
|
|
4
4
|
import type { Observable } from "../observable";
|
|
5
|
-
import type { FieldType, IField } from "../types/field-type";
|
|
5
|
+
import type { FieldType, IField, IFieldShape } from "../types/field-type";
|
|
6
6
|
import type { IContractConsumer, IContractConsumerBase, IContractToolImplementation } from "./contract-proxy";
|
|
7
7
|
import type { IToolCatalogMetadata } from "./tool-catalog";
|
|
8
8
|
/**
|
|
@@ -52,14 +52,25 @@ export interface IContractTool {
|
|
|
52
52
|
* account) are never gated by this value. Policy only — not part of shape validation.
|
|
53
53
|
*/
|
|
54
54
|
remoteAccessLevel?: number;
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Host-only invocation policy, not part of shape validation: requires an in-process workflow.
|
|
57
|
+
*/
|
|
56
58
|
requiresWorkflowRun?: boolean;
|
|
57
59
|
}
|
|
58
60
|
/** Observable value exposed by a contract. */
|
|
59
61
|
export interface IContractObservable {
|
|
60
62
|
name: string;
|
|
61
63
|
description: string;
|
|
64
|
+
/** The value's type, which the Runtime checks values against. */
|
|
62
65
|
valueType: FieldType;
|
|
66
|
+
/**
|
|
67
|
+
* The value's full shape (nested fields and enum values), when the provider declared a schema.
|
|
68
|
+
* It describes; the provider's schema enforces. It follows field rules, so it can differ from
|
|
69
|
+
* `valueType`: an array of strings is `{ type: "string", isArray: true }` (its `valueType` is
|
|
70
|
+
* `object`), and a value that may be null is `optional` (a nullable object's `valueType` is
|
|
71
|
+
* `any`).
|
|
72
|
+
*/
|
|
73
|
+
value?: IFieldShape;
|
|
63
74
|
writable: boolean;
|
|
64
75
|
}
|
|
65
76
|
/**
|
|
@@ -181,6 +192,20 @@ export interface IAlsoImplementsDeclaration {
|
|
|
181
192
|
from: number;
|
|
182
193
|
to: number;
|
|
183
194
|
};
|
|
195
|
+
/**
|
|
196
|
+
* The target's definition, carried by the provider (a single version only). The registry
|
|
197
|
+
* registers it when it has no definition of the target, so the alias survives a cold start
|
|
198
|
+
* without another package providing the target; a frozen registered definition must match it.
|
|
199
|
+
*/
|
|
200
|
+
definition?: IContractDefinition;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Another contract a provider exposes through its implementation of a hub contract: the hub
|
|
204
|
+
* contract's consumers may call that contract's tools on this provider without consuming it.
|
|
205
|
+
*/
|
|
206
|
+
export interface IExposedContract {
|
|
207
|
+
contractId: string;
|
|
208
|
+
version: number;
|
|
184
209
|
}
|
|
185
210
|
/** The result of calling `definePackage()`. */
|
|
186
211
|
export interface IPackageDefinitionResult {
|
|
@@ -199,6 +224,11 @@ export interface IPackageDefinitionResult {
|
|
|
199
224
|
remotes?: IRemoteContract[];
|
|
200
225
|
/** `alsoImplements` declarations keyed by the owning contractId+version. */
|
|
201
226
|
alsoImplements: Map<string, IAlsoImplementsDeclaration[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Contracts each hub implementation exposes, keyed by the hub contract's contractId+version.
|
|
229
|
+
* Optional so bundles built with an older SDK still load.
|
|
230
|
+
*/
|
|
231
|
+
exposes?: Map<string, IExposedContract[]>;
|
|
202
232
|
/** Package-level items not part of any contract. */
|
|
203
233
|
assistants: unknown[];
|
|
204
234
|
appNavs: unknown[];
|
|
@@ -5,12 +5,27 @@ import type { IAlsoImplementsDeclaration, IContractDefinition, IValidationResult
|
|
|
5
5
|
* observables, and events must be present with compatible shapes.
|
|
6
6
|
*/
|
|
7
7
|
export declare function validateProviderSatisfiesContract(impl: IContractDefinition, contract: IContractDefinition): IValidationResult;
|
|
8
|
+
/**
|
|
9
|
+
* What changed between two shapes of one contract version, member by member: a table, tool,
|
|
10
|
+
* observable, or event that was added, removed, or changed. Empty when the shapes match.
|
|
11
|
+
* Descriptions and tool policy are ignored, as in {@link validateImmutability}.
|
|
12
|
+
*
|
|
13
|
+
* @param existing - The frozen shape.
|
|
14
|
+
* @param incoming - The shape to compare with it.
|
|
15
|
+
* @returns One line per changed member, such as `tool add-item changed`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function contractShapeChanges(existing: Pick<IContractDefinition, "tables" | "tools" | "observables" | "events">, incoming: Pick<IContractDefinition, "tables" | "tools" | "observables" | "events">): string[];
|
|
8
18
|
/**
|
|
9
19
|
* Validate that a frozen (stable) contract definition has not been modified.
|
|
10
20
|
* If the existing definition has no `devTag` it is frozen; the incoming
|
|
11
|
-
* definition must
|
|
21
|
+
* definition must have the same shape and also be stable.
|
|
12
22
|
* Dev contracts (`devTag: "dev"`) may change freely but cannot be registered
|
|
13
23
|
* once a stable version exists for that contract+version.
|
|
24
|
+
*
|
|
25
|
+
* Descriptions may change on a frozen version (to point callers at a newer one, say), and so
|
|
26
|
+
* may a tool's policy (`remoteAccessLevel`, `requiresWorkflowRun`); member, field, and key order
|
|
27
|
+
* don't matter. IR keys added later (`fields`, `enumValues`, and an
|
|
28
|
+
* observable's `value`) are compared only when both definitions have them.
|
|
14
29
|
*/
|
|
15
30
|
export declare function validateImmutability(existing: IContractDefinition, incoming: IContractDefinition): IValidationResult;
|
|
16
31
|
/**
|