@peers-app/peers-sdk 0.25.17 → 0.25.19

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.
Files changed (53) hide show
  1. package/README.md +9 -1
  2. package/dist/contracts/__tests__/action-dispatch.test.d.ts +1 -0
  3. package/dist/contracts/__tests__/action-dispatch.test.js +339 -0
  4. package/dist/contracts/__tests__/contract-proxy.test.js +24 -1
  5. package/dist/contracts/__tests__/contract-resolvers.test.js +3 -0
  6. package/dist/contracts/__tests__/generic-tool-dispatch.test.d.ts +1 -0
  7. package/dist/contracts/__tests__/generic-tool-dispatch.test.js +173 -0
  8. package/dist/contracts/action-dispatch.d.ts +12 -0
  9. package/dist/contracts/action-dispatch.js +73 -0
  10. package/dist/contracts/contract-provider-router.d.ts +16 -2
  11. package/dist/contracts/contract-provider-router.js +11 -1
  12. package/dist/contracts/contract-providers.table.d.ts +2 -2
  13. package/dist/contracts/contract-proxy.d.ts +58 -0
  14. package/dist/contracts/contract-proxy.js +163 -19
  15. package/dist/contracts/contract-resolvers.js +12 -1
  16. package/dist/contracts/index.d.ts +5 -1
  17. package/dist/contracts/index.js +21 -2
  18. package/dist/contracts/system/contract-catalog-contract.d.ts +40 -0
  19. package/dist/contracts/system/contract-catalog-contract.js +51 -0
  20. package/dist/contracts/system/http-contract.d.ts +80 -0
  21. package/dist/contracts/system/http-contract.js +93 -0
  22. package/dist/contracts/system/index.d.ts +3 -0
  23. package/dist/contracts/system/index.js +3 -0
  24. package/dist/contracts/system/scheduler-contract.d.ts +54 -0
  25. package/dist/contracts/system/scheduler-contract.js +70 -0
  26. package/dist/data/messages.d.ts +3 -3
  27. package/dist/data/package-versions.d.ts +10 -10
  28. package/dist/data/tool-access-approvals.d.ts +3 -3
  29. package/dist/data/tool-access.d.ts +3 -1
  30. package/dist/data/tool-access.js +5 -2
  31. package/dist/data/tool-access.test.js +7 -0
  32. package/dist/data/tools.d.ts +7 -3
  33. package/dist/data/tools.js +7 -1
  34. package/dist/invites/invite-messages.d.ts +2 -2
  35. package/dist/package-loader/host-authority-loading.test.d.ts +1 -0
  36. package/dist/package-loader/host-authority-loading.test.js +87 -0
  37. package/dist/package-loader/host-dispatch-policy.test.d.ts +1 -0
  38. package/dist/package-loader/host-dispatch-policy.test.js +56 -0
  39. package/dist/package-loader/index.d.ts +1 -0
  40. package/dist/package-loader/index.js +1 -0
  41. package/dist/package-loader/isolated-artifact.d.ts +53 -2
  42. package/dist/package-loader/isolated-artifact.js +118 -4
  43. package/dist/package-loader/isolated-artifact.test.js +63 -0
  44. package/dist/package-loader/isolated-persistent-var-gateway.js +19 -0
  45. package/dist/package-loader/isolated-runtime.d.ts +43 -1
  46. package/dist/package-loader/package-loader.d.ts +2 -0
  47. package/dist/package-loader/package-loader.js +64 -0
  48. package/dist/package-loader/package-loader.test.js +50 -2
  49. package/dist/package-loader/package-network-policy.d.ts +52 -0
  50. package/dist/package-loader/package-network-policy.js +62 -0
  51. package/dist/system-ids.d.ts +31 -0
  52. package/dist/system-ids.js +32 -1
  53. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ import type { IContractConsumerBase } from "../contract-proxy";
2
+ import type { IContractDefinition } from "../types";
3
+ /** Version of the built-in System Contract Catalog. */
4
+ export declare const CONTRACT_CATALOG_VERSION = 1;
5
+ /** Package id of the System Contract Catalog provider. */
6
+ export declare const contractCatalogProviderPackageId = "000peers0system0000000001";
7
+ /** One registered provider of a contract version. */
8
+ export interface IContractProviderInfo {
9
+ packageId: string;
10
+ /** Display name from the Packages row, or the package id for the system provider. */
11
+ name: string;
12
+ /** True when this package is the active provider for the contract version. */
13
+ active: boolean;
14
+ /** Executable package selectors for this trusted turn. Missing metadata grants no actions. */
15
+ authorizedActions?: string[];
16
+ }
17
+ /** Input for listing providers of one contract version. */
18
+ export interface IListContractProvidersInput {
19
+ contractId: string;
20
+ version: number;
21
+ }
22
+ /**
23
+ * Consumer shape for the System Contract Catalog.
24
+ *
25
+ * Hub packages use this to discover every provider of a shared contract.
26
+ */
27
+ export interface IContractCatalogConsumer extends IContractConsumerBase {
28
+ tools: {
29
+ listContractProviders(input: IListContractProvidersInput): Promise<{
30
+ providers: IContractProviderInfo[];
31
+ }>;
32
+ };
33
+ }
34
+ /**
35
+ * Return the local-only catalog contract that lists providers of another contract.
36
+ *
37
+ * The active provider remains the default for ordinary calls. This tool exists so a
38
+ * consumer can address every registered provider, not only the active one.
39
+ */
40
+ export declare function getContractCatalogDefinition(): IContractDefinition;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contractCatalogProviderPackageId = exports.CONTRACT_CATALOG_VERSION = void 0;
4
+ exports.getContractCatalogDefinition = getContractCatalogDefinition;
5
+ const system_ids_1 = require("../../system-ids");
6
+ const field_type_1 = require("../../types/field-type");
7
+ const system_contracts_1 = require("../system-contracts");
8
+ /** Version of the built-in System Contract Catalog. */
9
+ exports.CONTRACT_CATALOG_VERSION = 1;
10
+ /** Package id of the System Contract Catalog provider. */
11
+ exports.contractCatalogProviderPackageId = system_ids_1.peersSystemPackageId;
12
+ const field = (name, type, description, opts = {}) => ({ name, type, description, ...opts });
13
+ let definition;
14
+ /**
15
+ * Return the local-only catalog contract that lists providers of another contract.
16
+ *
17
+ * The active provider remains the default for ordinary calls. This tool exists so a
18
+ * consumer can address every registered provider, not only the active one.
19
+ */
20
+ function getContractCatalogDefinition() {
21
+ definition ??= {
22
+ contractId: system_ids_1.contractCatalogContractId,
23
+ version: exports.CONTRACT_CATALOG_VERSION,
24
+ devTag: "dev",
25
+ name: "System Contract Catalog",
26
+ description: "Lists the packages registered as providers of a contract version.",
27
+ tables: [],
28
+ tools: [
29
+ {
30
+ name: "listContractProviders",
31
+ usageDescription: "List every package registered for a contract version, including inactive ones.",
32
+ inputFields: [
33
+ field("contractId", field_type_1.FieldType.id, "Contract to look up."),
34
+ field("version", field_type_1.FieldType.number, "Contract version."),
35
+ ],
36
+ outputFields: [
37
+ field("providers", field_type_1.FieldType.object, "Registered providers in registration order, with packageId, name, and active.", { isArray: true }),
38
+ ],
39
+ },
40
+ ],
41
+ observables: [],
42
+ events: [],
43
+ };
44
+ return definition;
45
+ }
46
+ (0, system_contracts_1.registerSystemContract)({
47
+ providerPackageId: exports.contractCatalogProviderPackageId,
48
+ contractId: system_ids_1.contractCatalogContractId,
49
+ version: exports.CONTRACT_CATALOG_VERSION,
50
+ getDefinition: getContractCatalogDefinition,
51
+ });
@@ -0,0 +1,80 @@
1
+ import type { IContractConsumerBase } from "../contract-proxy";
2
+ import type { IContractDefinition } from "../types";
3
+ /** Version of the built-in System HTTP contract. */
4
+ export declare const HTTP_CONTRACT_VERSION = 1;
5
+ /** Default request deadline when the caller omits `timeoutMs`. */
6
+ export declare const HTTP_DEFAULT_TIMEOUT_MS = 30000;
7
+ /** Longest request deadline System HTTP will honor. */
8
+ export declare const HTTP_MAX_TIMEOUT_MS = 120000;
9
+ /** Largest request or response body, in decoded bytes. */
10
+ export declare const HTTP_MAX_BODY_BYTES: number;
11
+ /** Package id of the System HTTP provider. */
12
+ export declare const httpProviderPackageId = "000peers0system0000000001";
13
+ /** One multipart part. Use `text` for a form field or `bodyBase64` for bytes. */
14
+ export interface IHttpMultipartPart {
15
+ name: string;
16
+ filename?: string;
17
+ contentType?: string;
18
+ /** UTF-8 form field. Used instead of `bodyBase64` when set. */
19
+ text?: string;
20
+ bodyBase64?: string;
21
+ }
22
+ /** Input for {@link IHttpConsumer tools.request}. */
23
+ export interface IHttpRequestInput {
24
+ requestId: string;
25
+ method: string;
26
+ url: string;
27
+ headers?: Record<string, string>;
28
+ body?: string;
29
+ bodyBase64?: string;
30
+ multipart?: IHttpMultipartPart[];
31
+ credentialRef?: string;
32
+ responseType?: "json" | "text" | "base64";
33
+ timeoutMs?: number;
34
+ }
35
+ /** Result of one System HTTP request. Non-2xx responses are returned, not thrown. */
36
+ export interface IHttpRequestResult {
37
+ status: number;
38
+ ok: boolean;
39
+ contentType: string;
40
+ body: unknown;
41
+ }
42
+ /** Input for cancelling an in-flight request owned by the calling package. */
43
+ export interface IHttpCancelInput {
44
+ requestId: string;
45
+ }
46
+ /** One credential declaration safe to show in the admin UI. The secret value is omitted. */
47
+ export interface IHttpCredentialInfo {
48
+ ref: string;
49
+ header: string;
50
+ secretVar: string;
51
+ scope: "user" | "device";
52
+ }
53
+ /** Network declaration for one package, as shown to the operator. */
54
+ export interface IHttpPolicyInfo {
55
+ allowedHosts: string[];
56
+ credentials: IHttpCredentialInfo[];
57
+ }
58
+ /**
59
+ * Consumer shape for System HTTP.
60
+ *
61
+ * Isolated packages call `request` and `cancel`. The Packages screen calls `describePolicy`.
62
+ */
63
+ export interface IHttpConsumer extends IContractConsumerBase {
64
+ tools: {
65
+ request(input: IHttpRequestInput): Promise<IHttpRequestResult>;
66
+ cancel(input: IHttpCancelInput): Promise<{
67
+ cancelled: boolean;
68
+ }>;
69
+ describePolicy(input: {
70
+ packageId: string;
71
+ }): Promise<IHttpPolicyInfo>;
72
+ };
73
+ }
74
+ /**
75
+ * Return the local-only System HTTP contract shape.
76
+ *
77
+ * The host performs `fetch`. Guests name an allowlisted URL and an optional
78
+ * credential ref; they never receive the secret or an open network.
79
+ */
80
+ export declare function getHttpContractDefinition(): IContractDefinition;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpProviderPackageId = exports.HTTP_MAX_BODY_BYTES = exports.HTTP_MAX_TIMEOUT_MS = exports.HTTP_DEFAULT_TIMEOUT_MS = exports.HTTP_CONTRACT_VERSION = void 0;
4
+ exports.getHttpContractDefinition = getHttpContractDefinition;
5
+ const system_ids_1 = require("../../system-ids");
6
+ const field_type_1 = require("../../types/field-type");
7
+ const system_contracts_1 = require("../system-contracts");
8
+ /** Version of the built-in System HTTP contract. */
9
+ exports.HTTP_CONTRACT_VERSION = 1;
10
+ /** Default request deadline when the caller omits `timeoutMs`. */
11
+ exports.HTTP_DEFAULT_TIMEOUT_MS = 30_000;
12
+ /** Longest request deadline System HTTP will honor. */
13
+ exports.HTTP_MAX_TIMEOUT_MS = 120_000;
14
+ /** Largest request or response body, in decoded bytes. */
15
+ exports.HTTP_MAX_BODY_BYTES = 8 * 1024 * 1024;
16
+ /** Package id of the System HTTP provider. */
17
+ exports.httpProviderPackageId = system_ids_1.peersSystemPackageId;
18
+ const field = (name, type, description, opts = {}) => ({ name, type, description, ...opts });
19
+ let definition;
20
+ /**
21
+ * Return the local-only System HTTP contract shape.
22
+ *
23
+ * The host performs `fetch`. Guests name an allowlisted URL and an optional
24
+ * credential ref; they never receive the secret or an open network.
25
+ */
26
+ function getHttpContractDefinition() {
27
+ definition ??= {
28
+ contractId: system_ids_1.httpContractId,
29
+ version: exports.HTTP_CONTRACT_VERSION,
30
+ devTag: "dev",
31
+ name: "System HTTP",
32
+ description: "Host-mediated HTTPS for isolated packages. Hosts must be declared on the package, and credentials are injected by reference.",
33
+ tables: [],
34
+ tools: [
35
+ {
36
+ name: "request",
37
+ usageDescription: "Perform one HTTPS request to a host this package declared. Non-2xx responses are returned.",
38
+ inputFields: [
39
+ field("requestId", field_type_1.FieldType.string, "Caller-chosen id used to cancel this request."),
40
+ field("method", field_type_1.FieldType.string, "HTTP method: GET, POST, PUT, PATCH, DELETE, or HEAD."),
41
+ field("url", field_type_1.FieldType.string, "Absolute https URL whose host is on this package's allowlist."),
42
+ field("headers", field_type_1.FieldType.object, "Optional request headers. Credential headers are overwritten.", {
43
+ optional: true,
44
+ }),
45
+ field("body", field_type_1.FieldType.string, "UTF-8 request body.", { optional: true }),
46
+ field("bodyBase64", field_type_1.FieldType.string, "Base64 request body. Used instead of body when set.", {
47
+ optional: true,
48
+ }),
49
+ field("multipart", field_type_1.FieldType.object, "Multipart parts with name and bodyBase64. Used instead of body when set.", { optional: true, isArray: true }),
50
+ field("credentialRef", field_type_1.FieldType.string, "Credential ref from this package's network declaration.", { optional: true }),
51
+ field("responseType", field_type_1.FieldType.string, 'How to decode the response: "json", "text", or "base64". Defaults to json.', { optional: true }),
52
+ field("timeoutMs", field_type_1.FieldType.number, `Deadline in milliseconds. Defaults to ${exports.HTTP_DEFAULT_TIMEOUT_MS} and is capped at ${exports.HTTP_MAX_TIMEOUT_MS}.`, { optional: true }),
53
+ ],
54
+ outputFields: [
55
+ field("status", field_type_1.FieldType.number, "HTTP status code."),
56
+ field("ok", field_type_1.FieldType.boolean, "True when the status is 2xx."),
57
+ field("contentType", field_type_1.FieldType.string, "Response Content-Type, or empty."),
58
+ field("body", field_type_1.FieldType.any, "Decoded response body."),
59
+ ],
60
+ },
61
+ {
62
+ name: "cancel",
63
+ usageDescription: "Abort one in-flight request started by this package.",
64
+ inputFields: [field("requestId", field_type_1.FieldType.string, "Id passed to request.")],
65
+ outputFields: [
66
+ field("cancelled", field_type_1.FieldType.boolean, "True when a matching request was aborted."),
67
+ ],
68
+ },
69
+ {
70
+ name: "describePolicy",
71
+ usageDescription: "Return the host allowlist and credential refs declared by a package. Secret values are omitted.",
72
+ inputFields: [
73
+ field("packageId", field_type_1.FieldType.id, "Package whose network declaration to read."),
74
+ ],
75
+ outputFields: [
76
+ field("allowedHosts", field_type_1.FieldType.string, "Hostnames the package may request.", {
77
+ isArray: true,
78
+ }),
79
+ field("credentials", field_type_1.FieldType.object, "Credential refs, headers, and logical secret names. Values are not included.", { isArray: true }),
80
+ ],
81
+ },
82
+ ],
83
+ observables: [],
84
+ events: [],
85
+ };
86
+ return definition;
87
+ }
88
+ (0, system_contracts_1.registerSystemContract)({
89
+ providerPackageId: exports.httpProviderPackageId,
90
+ contractId: system_ids_1.httpContractId,
91
+ version: exports.HTTP_CONTRACT_VERSION,
92
+ getDefinition: getHttpContractDefinition,
93
+ });
@@ -2,11 +2,14 @@
2
2
  * Built-in system contracts. Importing this barrel runs each module's
3
3
  * {@link registerSystemContract} side effect so the catalog is populated.
4
4
  */
5
+ import "./contract-catalog-contract";
5
6
  import "./device-operations-contract";
7
+ import "./http-contract";
6
8
  import "./identity-contract";
7
9
  import "./invites-contract";
8
10
  import "./logs-contract";
9
11
  import "./network-contracts";
12
+ import "./scheduler-contract";
10
13
  import "./tool-access-control-contract";
11
14
  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 "./device-operations-contract";
12
15
  export { getIdentityContractDefinition, IDENTITY_CONTRACT_VERSION, type IIdentityConsumer, type IIdentityKeyInfo, type IIdentityRegistryKey, type IIdentityRotateKeyInput, type IIdentityRotateKeyResult, type IIdentitySessionInfo, } from "./identity-contract";
@@ -19,11 +19,14 @@ exports.TOOL_ACCESS_CONTROL_CONTRACT_VERSION = exports.getToolAccessControlContr
19
19
  * Built-in system contracts. Importing this barrel runs each module's
20
20
  * {@link registerSystemContract} side effect so the catalog is populated.
21
21
  */
22
+ require("./contract-catalog-contract");
22
23
  require("./device-operations-contract");
24
+ require("./http-contract");
23
25
  require("./identity-contract");
24
26
  require("./invites-contract");
25
27
  require("./logs-contract");
26
28
  require("./network-contracts");
29
+ require("./scheduler-contract");
27
30
  require("./tool-access-control-contract");
28
31
  var device_operations_contract_1 = require("./device-operations-contract");
29
32
  Object.defineProperty(exports, "DEVICE_OPERATIONS_CONTRACT_VERSION", { enumerable: true, get: function () { return device_operations_contract_1.DEVICE_OPERATIONS_CONTRACT_VERSION; } });
@@ -0,0 +1,54 @@
1
+ import type { IContractConsumerBase } from "../contract-proxy";
2
+ import type { IContractDefinition } from "../types";
3
+ /** Version of the built-in System Scheduler contract. */
4
+ export declare const SCHEDULER_CONTRACT_VERSION = 1;
5
+ /** Package id of the System Scheduler provider. */
6
+ export declare const schedulerProviderPackageId = "000peers0system0000000001";
7
+ /** Furthest a schedule may sit in the future. */
8
+ export declare const SCHEDULER_MAX_DELAY_MS: number;
9
+ /** Input for scheduling a wake-up of the caller's own tool. */
10
+ export interface IScheduleInput {
11
+ /** Unix epoch milliseconds when the tool should run. */
12
+ at: number;
13
+ contractId: string;
14
+ version: number;
15
+ toolName: string;
16
+ payload?: unknown;
17
+ }
18
+ /** One device-local schedule owned by a package. */
19
+ export interface IScheduleInfo {
20
+ scheduleId: string;
21
+ packageId: string;
22
+ dataContextId: string;
23
+ contractId: string;
24
+ version: number;
25
+ toolName: string;
26
+ at: number;
27
+ }
28
+ /**
29
+ * Consumer shape for System Scheduler.
30
+ *
31
+ * Schedules are stored on this device only. Another device does not run them.
32
+ */
33
+ export interface ISchedulerConsumer extends IContractConsumerBase {
34
+ tools: {
35
+ schedule(input: IScheduleInput): Promise<{
36
+ scheduleId: string;
37
+ }>;
38
+ cancel(input: {
39
+ scheduleId: string;
40
+ }): Promise<{
41
+ cancelled: boolean;
42
+ }>;
43
+ list(): Promise<{
44
+ schedules: IScheduleInfo[];
45
+ }>;
46
+ };
47
+ }
48
+ /**
49
+ * Return the local-only System Scheduler contract shape.
50
+ *
51
+ * A package may schedule a tool that it provides. When `at` arrives, the host
52
+ * starts that package's worker if needed and runs the tool as Self.
53
+ */
54
+ export declare function getSchedulerContractDefinition(): IContractDefinition;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCHEDULER_MAX_DELAY_MS = exports.schedulerProviderPackageId = exports.SCHEDULER_CONTRACT_VERSION = void 0;
4
+ exports.getSchedulerContractDefinition = getSchedulerContractDefinition;
5
+ const system_ids_1 = require("../../system-ids");
6
+ const field_type_1 = require("../../types/field-type");
7
+ const system_contracts_1 = require("../system-contracts");
8
+ /** Version of the built-in System Scheduler contract. */
9
+ exports.SCHEDULER_CONTRACT_VERSION = 1;
10
+ /** Package id of the System Scheduler provider. */
11
+ exports.schedulerProviderPackageId = system_ids_1.peersSystemPackageId;
12
+ /** Furthest a schedule may sit in the future. */
13
+ exports.SCHEDULER_MAX_DELAY_MS = 366 * 24 * 60 * 60 * 1000;
14
+ const field = (name, type, description, opts = {}) => ({ name, type, description, ...opts });
15
+ let definition;
16
+ /**
17
+ * Return the local-only System Scheduler contract shape.
18
+ *
19
+ * A package may schedule a tool that it provides. When `at` arrives, the host
20
+ * starts that package's worker if needed and runs the tool as Self.
21
+ */
22
+ function getSchedulerContractDefinition() {
23
+ definition ??= {
24
+ contractId: system_ids_1.schedulerContractId,
25
+ version: exports.SCHEDULER_CONTRACT_VERSION,
26
+ devTag: "dev",
27
+ name: "System Scheduler",
28
+ description: "Device-local schedules that wake a package's own tool. Schedules do not sync to other devices.",
29
+ tables: [],
30
+ tools: [
31
+ {
32
+ name: "schedule",
33
+ usageDescription: "Run one of this package's tools at a future time on this device. Returns a scheduleId.",
34
+ inputFields: [
35
+ field("at", field_type_1.FieldType.number, "Unix epoch milliseconds when the tool should run."),
36
+ field("contractId", field_type_1.FieldType.id, "Contract this package provides."),
37
+ field("version", field_type_1.FieldType.number, "Contract version."),
38
+ field("toolName", field_type_1.FieldType.string, "Tool on that contract to run."),
39
+ field("payload", field_type_1.FieldType.any, "JSON value passed to the tool.", { optional: true }),
40
+ ],
41
+ outputFields: [field("scheduleId", field_type_1.FieldType.id, "Id to pass to cancel.")],
42
+ },
43
+ {
44
+ name: "cancel",
45
+ usageDescription: "Cancel a schedule this package created.",
46
+ inputFields: [field("scheduleId", field_type_1.FieldType.id, "Schedule to cancel.")],
47
+ outputFields: [
48
+ field("cancelled", field_type_1.FieldType.boolean, "True when the schedule existed and was removed."),
49
+ ],
50
+ },
51
+ {
52
+ name: "list",
53
+ usageDescription: "List schedules owned by the calling package on this device.",
54
+ inputFields: [],
55
+ outputFields: [
56
+ field("schedules", field_type_1.FieldType.object, "Schedules with scheduleId, contractId, version, toolName, and at.", { isArray: true }),
57
+ ],
58
+ },
59
+ ],
60
+ observables: [],
61
+ events: [],
62
+ };
63
+ return definition;
64
+ }
65
+ (0, system_contracts_1.registerSystemContract)({
66
+ providerPackageId: exports.schedulerProviderPackageId,
67
+ contractId: system_ids_1.schedulerContractId,
68
+ version: exports.SCHEDULER_CONTRACT_VERSION,
69
+ getDefinition: getSchedulerContractDefinition,
70
+ });
@@ -18,8 +18,8 @@ export declare const messageSchema: z.ZodObject<{
18
18
  channelId: string;
19
19
  messageId: string;
20
20
  assistantId?: string | undefined;
21
- vars?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
22
21
  messageParentId?: string | undefined;
22
+ vars?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
23
23
  editedAt?: Date | undefined;
24
24
  fileIds?: string[] | undefined;
25
25
  }, {
@@ -29,8 +29,8 @@ export declare const messageSchema: z.ZodObject<{
29
29
  channelId: string;
30
30
  messageId: string;
31
31
  assistantId?: string | undefined;
32
- vars?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
33
32
  messageParentId?: string | undefined;
33
+ vars?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
34
34
  editedAt?: Date | undefined;
35
35
  fileIds?: string[] | undefined;
36
36
  }>;
@@ -42,8 +42,8 @@ export declare function Messages(dataContext?: DataContext): import("..").Table<
42
42
  channelId: string;
43
43
  messageId: string;
44
44
  assistantId?: string | undefined;
45
- vars?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
46
45
  messageParentId?: string | undefined;
46
+ vars?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
47
47
  editedAt?: Date | undefined;
48
48
  fileIds?: string[] | undefined;
49
49
  }>;
@@ -66,17 +66,17 @@ declare const schema: z.ZodObject<{
66
66
  signature: string;
67
67
  by: string;
68
68
  }[] | undefined;
69
- versionTag?: string | undefined;
70
- routesBundleFileId?: string | undefined;
71
- routesBundleFileHash?: string | undefined;
72
- uiBundleFileId?: string | undefined;
73
- uiBundleFileHash?: string | undefined;
74
69
  appNavs?: {
75
70
  name: string;
76
71
  iconClassName: string;
77
72
  navigationPath: string;
78
73
  displayName?: string | undefined;
79
74
  }[] | undefined;
75
+ versionTag?: string | undefined;
76
+ routesBundleFileId?: string | undefined;
77
+ routesBundleFileHash?: string | undefined;
78
+ uiBundleFileId?: string | undefined;
79
+ uiBundleFileHash?: string | undefined;
80
80
  packageAuthorSignature?: string | undefined;
81
81
  }, {
82
82
  version: string;
@@ -94,17 +94,17 @@ declare const schema: z.ZodObject<{
94
94
  signature: string;
95
95
  by: string;
96
96
  }[] | undefined;
97
- versionTag?: string | undefined;
98
- routesBundleFileId?: string | undefined;
99
- routesBundleFileHash?: string | undefined;
100
- uiBundleFileId?: string | undefined;
101
- uiBundleFileHash?: string | undefined;
102
97
  appNavs?: {
103
98
  name: string;
104
99
  iconClassName: string;
105
100
  navigationPath: string;
106
101
  displayName?: string | undefined;
107
102
  }[] | undefined;
103
+ versionTag?: string | undefined;
104
+ routesBundleFileId?: string | undefined;
105
+ routesBundleFileHash?: string | undefined;
106
+ uiBundleFileId?: string | undefined;
107
+ uiBundleFileHash?: string | undefined;
108
108
  packageAuthorSignature?: string | undefined;
109
109
  }>;
110
110
  export type IPackageVersion = z.infer<typeof schema>;
@@ -52,8 +52,8 @@ export declare const toolAccessApprovalSchema: z.ZodObject<{
52
52
  dataContextId: string;
53
53
  createdAt: Date;
54
54
  expiresAt: Date;
55
- toolAccessApprovalId: string;
56
55
  toolName: string;
56
+ toolAccessApprovalId: string;
57
57
  argsHash: string;
58
58
  argsPreview: string;
59
59
  frozenArgs: {} & {
@@ -73,8 +73,8 @@ export declare const toolAccessApprovalSchema: z.ZodObject<{
73
73
  toolId: string;
74
74
  dataContextId: string;
75
75
  expiresAt: Date;
76
- toolAccessApprovalId: string;
77
76
  toolName: string;
77
+ toolAccessApprovalId: string;
78
78
  argsHash: string;
79
79
  frozenArgs: {} & {
80
80
  [k: string]: any;
@@ -108,8 +108,8 @@ export declare function ToolAccessApprovals(dataContext?: DataContext): import("
108
108
  dataContextId: string;
109
109
  createdAt: Date;
110
110
  expiresAt: Date;
111
- toolAccessApprovalId: string;
112
111
  toolName: string;
112
+ toolAccessApprovalId: string;
113
113
  argsHash: string;
114
114
  argsPreview: string;
115
115
  frozenArgs: {} & {
@@ -65,12 +65,14 @@ export declare function hashToolArgs(args: Record<string, unknown> | undefined):
65
65
  */
66
66
  export declare function annotateToolAccessDescription(usageDescription: string, accessLevel: unknown): string;
67
67
  /**
68
- * Return the fail-closed access level for a record that may omit the field.
68
+ * Resolve admission from record metadata. Omitted preservation-request tools enter at None;
69
+ * ordinary tools and Assistants retain the fail-closed Self default.
69
70
  *
70
71
  * @param record - Tool or Assistant-like object.
71
72
  */
72
73
  export declare function recordAccessLevel(record: {
73
74
  accessLevel?: unknown;
75
+ authorityPropagation?: unknown;
74
76
  } | undefined): number;
75
77
  /**
76
78
  * Choose the delegated Assistant ceiling for a run.
@@ -105,13 +105,16 @@ function annotateToolAccessDescription(usageDescription, accessLevel) {
105
105
  return `${usageDescription}\n\n${annotation}`;
106
106
  }
107
107
  /**
108
- * Return the fail-closed access level for a record that may omit the field.
108
+ * Resolve admission from record metadata. Omitted preservation-request tools enter at None;
109
+ * ordinary tools and Assistants retain the fail-closed Self default.
109
110
  *
110
111
  * @param record - Tool or Assistant-like object.
111
112
  */
112
113
  function recordAccessLevel(record) {
113
114
  return record?.accessLevel == null
114
- ? access_level_1.DEFAULT_ACCESS_LEVEL
115
+ ? record?.authorityPropagation === "preserve"
116
+ ? access_level_1.AccessLevel.None
117
+ : access_level_1.DEFAULT_ACCESS_LEVEL
115
118
  : (0, access_level_1.resolveAccessLevel)(record.accessLevel);
116
119
  }
117
120
  /**
@@ -59,6 +59,13 @@ describe("annotateToolAccessDescription", () => {
59
59
  expect((0, tool_access_1.annotateToolAccessDescription)(once, 40)).toBe(once);
60
60
  });
61
61
  });
62
+ test("legacy host admission and descriptions use the preservation request, not a grant", () => {
63
+ const tool = { authorityPropagation: "preserve" };
64
+ expect((0, tool_access_1.recordAccessLevel)(tool)).toBe(0);
65
+ expect((0, tool_access_1.annotateToolAccessDescription)("route", (0, tool_access_1.recordAccessLevel)(tool))).toContain("None (0)");
66
+ expect((0, tool_access_1.recordAccessLevel)({})).toBe(100);
67
+ expect((0, tool_access_1.recordAccessLevel)({ ...tool, accessLevel: 40 })).toBe(40);
68
+ });
62
69
  describe("recordAccessLevel", () => {
63
70
  it("defaults missing records to 100", () => {
64
71
  expect((0, tool_access_1.recordAccessLevel)(undefined)).toBe(100);
@@ -219,7 +219,8 @@ export declare const toolSchema: z.ZodObject<{
219
219
  codeRepository: z.ZodOptional<z.ZodString>;
220
220
  isAssistantRunner: z.ZodOptional<z.ZodBoolean>;
221
221
  packageId: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
222
- accessLevel: z.ZodDefault<z.ZodNumber>;
222
+ authorityPropagation: z.ZodOptional<z.ZodEnum<["cap", "preserve"]>>;
223
+ accessLevel: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
223
224
  remoteAccessLevel: z.ZodOptional<z.ZodNumber>;
224
225
  }, "strip", z.ZodTypeAny, {
225
226
  code: string;
@@ -250,7 +251,6 @@ export declare const toolSchema: z.ZodObject<{
250
251
  subType?: string | undefined;
251
252
  }[];
252
253
  };
253
- accessLevel: number;
254
254
  detailedDescription?: string | undefined;
255
255
  configSchema?: {
256
256
  type: IOSchemaType;
@@ -267,6 +267,8 @@ export declare const toolSchema: z.ZodObject<{
267
267
  codeRepository?: string | undefined;
268
268
  isAssistantRunner?: boolean | undefined;
269
269
  packageId?: string | undefined;
270
+ authorityPropagation?: "preserve" | "cap" | undefined;
271
+ accessLevel?: number | undefined;
270
272
  remoteAccessLevel?: number | undefined;
271
273
  }, {
272
274
  name: string;
@@ -313,6 +315,7 @@ export declare const toolSchema: z.ZodObject<{
313
315
  codeRepository?: string | undefined;
314
316
  isAssistantRunner?: boolean | undefined;
315
317
  packageId?: string | undefined;
318
+ authorityPropagation?: "preserve" | "cap" | undefined;
316
319
  accessLevel?: number | undefined;
317
320
  remoteAccessLevel?: number | undefined;
318
321
  }>;
@@ -359,7 +362,6 @@ export declare function Tools(dataContext?: DataContext): import("..").Table<{
359
362
  subType?: string | undefined;
360
363
  }[];
361
364
  };
362
- accessLevel: number;
363
365
  detailedDescription?: string | undefined;
364
366
  configSchema?: {
365
367
  type: IOSchemaType;
@@ -376,5 +378,7 @@ export declare function Tools(dataContext?: DataContext): import("..").Table<{
376
378
  codeRepository?: string | undefined;
377
379
  isAssistantRunner?: boolean | undefined;
378
380
  packageId?: string | undefined;
381
+ authorityPropagation?: "preserve" | "cap" | undefined;
382
+ accessLevel?: number | undefined;
379
383
  remoteAccessLevel?: number | undefined;
380
384
  }>;
@@ -48,7 +48,13 @@ exports.toolSchema = zod_1.z.object({
48
48
  .optional()
49
49
  .describe("Whether this tool is a model that can be used to run an assistant"),
50
50
  packageId: zod_types_1.zodPeerId.optional().describe("The package that installed this tool, if any"),
51
- accessLevel: access_level_1.accessLevelSchema.describe("Required access level (0-100) to run this tool. Unclassified tools default to 100 (Self)."),
51
+ authorityPropagation: zod_1.z
52
+ .enum(["cap", "preserve"])
53
+ .optional()
54
+ .describe("Declared outgoing authority behavior in strict dispatch. 'cap' (default) includes this tool's level in the outgoing ceiling; 'preserve' omits it and passes the caller's authority through."),
55
+ accessLevel: access_level_1.accessLevelSchema
56
+ .optional()
57
+ .describe("Admission level (0-100). Omitted 'preserve' tools enter at None (0); other omitted tools require Self (100)."),
52
58
  remoteAccessLevel: zod_1.z
53
59
  .number()
54
60
  .int()