@peers-app/peers-sdk 0.26.3 → 0.26.5

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 (47) hide show
  1. package/dist/contracts/__tests__/contract-resolvers.test.js +24 -0
  2. package/dist/contracts/__tests__/legacy-removal.test.js +38 -0
  3. package/dist/contracts/__tests__/remote-contract-transport.test.js +23 -32
  4. package/dist/contracts/__tests__/system-contracts.test.js +80 -0
  5. package/dist/contracts/contract-resolvers.d.ts +1 -1
  6. package/dist/contracts/contract-resolvers.js +3 -2
  7. package/dist/contracts/create-local-consumer.d.ts +2 -1
  8. package/dist/contracts/create-local-consumer.js +1 -1
  9. package/dist/contracts/index.d.ts +2 -0
  10. package/dist/contracts/index.js +2 -0
  11. package/dist/contracts/remote-contract-transport.d.ts +3 -3
  12. package/dist/contracts/remote-contract-transport.js +19 -17
  13. package/dist/contracts/system/host-shell-contract.d.ts +191 -0
  14. package/dist/contracts/system/host-shell-contract.js +190 -0
  15. package/dist/contracts/system/index.d.ts +4 -0
  16. package/dist/contracts/system/index.js +4 -0
  17. package/dist/contracts/system/packages-contract.d.ts +257 -0
  18. package/dist/contracts/system/packages-contract.js +213 -0
  19. package/dist/data/create-group.d.ts +1 -1
  20. package/dist/data/create-group.js +1 -1
  21. package/dist/data/package-version-resolver.d.ts +8 -2
  22. package/dist/data/package-version-resolver.js +28 -2
  23. package/dist/data/package-version-resolver.test.js +42 -0
  24. package/dist/package-installer/package-author-signer.d.ts +19 -0
  25. package/dist/package-installer/package-author-signer.js +24 -0
  26. package/dist/package-installer/package-creator.d.ts +1 -7
  27. package/dist/package-installer/package-creator.js +0 -12
  28. package/dist/package-installer/package-creator.test.js +0 -16
  29. package/dist/package-installer/package-installer.d.ts +5 -0
  30. package/dist/package-installer/package-installer.js +60 -37
  31. package/dist/package-installer/package-installer.test.js +129 -0
  32. package/dist/package-installer/types.d.ts +5 -11
  33. package/dist/package-loader/index.d.ts +1 -0
  34. package/dist/package-loader/index.js +1 -0
  35. package/dist/package-loader/isolated-runtime.d.ts +18 -0
  36. package/dist/package-loader/package-loader.d.ts +67 -4
  37. package/dist/package-loader/package-loader.js +300 -52
  38. package/dist/package-loader/package-loader.test.js +413 -1
  39. package/dist/package-loader/package-runtime-state.d.ts +112 -0
  40. package/dist/package-loader/package-runtime-state.js +18 -0
  41. package/dist/package-loader/resolve-consumed-contracts.js +5 -4
  42. package/dist/package-loader/resolve-consumed-contracts.test.js +1 -1
  43. package/dist/rpc-types.d.ts +0 -121
  44. package/dist/rpc-types.js +0 -39
  45. package/dist/system-ids.d.ts +13 -0
  46. package/dist/system-ids.js +14 -1
  47. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HOST_OPEN_URL_SCHEMES = exports.HOST_SHELL_CONTRACT_VERSION = void 0;
4
+ exports.classifyHostOpenTarget = classifyHostOpenTarget;
5
+ exports.getHostShellContractDefinition = getHostShellContractDefinition;
6
+ const system_ids_1 = require("../../system-ids");
7
+ const field_type_1 = require("../../types/field-type");
8
+ const system_contracts_1 = require("../system-contracts");
9
+ /** Version of the built-in System Host Shell contract. */
10
+ exports.HOST_SHELL_CONTRACT_VERSION = 1;
11
+ /** URL schemes `open` hands to the browser or mail client; any other scheme is refused. */
12
+ exports.HOST_OPEN_URL_SCHEMES = ["http", "https", "mailto"];
13
+ /**
14
+ * Decide how `open` handles a target. `http`, `https`, and `mailto` links go to the browser;
15
+ * any other URL scheme (`file:`, `javascript:`, custom app schemes, …) is refused; everything
16
+ * else is a local path (`~` is expanded by the host). Windows drive paths are paths.
17
+ *
18
+ * @param target - What the caller asked to open.
19
+ * @throws When the target is empty or uses a scheme that is not allowed.
20
+ */
21
+ function classifyHostOpenTarget(target) {
22
+ const trimmed = typeof target === "string" ? target.trim() : "";
23
+ if (!trimmed)
24
+ throw new Error("open requires a target");
25
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(trimmed)?.[1]?.toLowerCase();
26
+ if (!scheme || /^[a-z]:[\\/]/i.test(trimmed))
27
+ return { kind: "path", path: trimmed };
28
+ if (!exports.HOST_OPEN_URL_SCHEMES.includes(scheme)) {
29
+ throw new Error(`open refuses ${scheme}: links; only ${exports.HOST_OPEN_URL_SCHEMES.join(", ")} links or local paths`);
30
+ }
31
+ return { kind: "browser", url: trimmed };
32
+ }
33
+ const field = (name, type, description, opts = {}) => ({ name, type, description, ...opts });
34
+ const actionResultFields = [
35
+ field("success", field_type_1.FieldType.boolean, "Whether the action was performed."),
36
+ field("error", field_type_1.FieldType.string, "Why it was not.", { optional: true }),
37
+ ];
38
+ const selectorField = field("selector", field_type_1.FieldType.string, "CSS selector, as `inspectUI` lists it.");
39
+ let definition;
40
+ /**
41
+ * Return the System Host Shell contract shape.
42
+ *
43
+ * Tools carry no `remoteAccessLevel`, so only callers this device trusts as `Self` (the
44
+ * user's own devices and users explicitly granted Self) can reach them remotely; group
45
+ * members, Admins included, are refused. Package code and workflows are refused everywhere.
46
+ * `quitApp` and `restartApp` from another device also need the device's "Allow my other
47
+ * devices to update and restart this device" setting. Tools the host cannot perform throw
48
+ * `System Host Shell <tool> is not supported on this host (...)`; `getCapabilities` reports
49
+ * support up front.
50
+ */
51
+ function getHostShellContractDefinition() {
52
+ definition ??= {
53
+ contractId: system_ids_1.hostShellContractId,
54
+ version: exports.HOST_SHELL_CONTRACT_VERSION,
55
+ devTag: "dev",
56
+ name: "System Host Shell",
57
+ description: "The app's window and shell: inspect, drive, and screenshot the UI; quit and restart; open links, folders, and the editor; copy to the clipboard.",
58
+ tables: [],
59
+ tools: [
60
+ {
61
+ name: "getCapabilities",
62
+ usageDescription: "Report which System Host Shell tools this host supports.",
63
+ inputFields: [],
64
+ outputFields: [field("capabilities", field_type_1.FieldType.object, "Supported tool groups.")],
65
+ },
66
+ {
67
+ name: "inspectUI",
68
+ usageDescription: "Return the UI window's URL, route, visible text, and interactive elements with selectors.",
69
+ inputFields: [
70
+ field("includeRects", field_type_1.FieldType.boolean, "Include element positions and sizes.", {
71
+ optional: true,
72
+ }),
73
+ ],
74
+ outputFields: [
75
+ field("url", field_type_1.FieldType.string, "Page URL."),
76
+ field("title", field_type_1.FieldType.string, "Document title."),
77
+ field("route", field_type_1.FieldType.string, "In-app route.", { optional: true }),
78
+ field("text", field_type_1.FieldType.string, "Visible text."),
79
+ field("elements", field_type_1.FieldType.object, "Interactive elements.", { isArray: true }),
80
+ ],
81
+ },
82
+ {
83
+ name: "clickUI",
84
+ usageDescription: "Click the UI element matching a CSS selector.",
85
+ inputFields: [selectorField],
86
+ outputFields: actionResultFields,
87
+ },
88
+ {
89
+ name: "setUIText",
90
+ usageDescription: "Type text into the UI input matching a CSS selector.",
91
+ inputFields: [
92
+ selectorField,
93
+ field("text", field_type_1.FieldType.string, "Text to type."),
94
+ field("clear", field_type_1.FieldType.boolean, "Clear the input first.", { optional: true }),
95
+ field("pressEnter", field_type_1.FieldType.boolean, "Press Enter afterwards.", { optional: true }),
96
+ ],
97
+ outputFields: actionResultFields,
98
+ },
99
+ {
100
+ name: "scrollUI",
101
+ usageDescription: "Scroll a UI element, or the page, by a direction or offsets.",
102
+ inputFields: [
103
+ field("selector", field_type_1.FieldType.string, "Element to scroll; the page when omitted.", {
104
+ optional: true,
105
+ }),
106
+ field("x", field_type_1.FieldType.number, "Horizontal offset in pixels.", { optional: true }),
107
+ field("y", field_type_1.FieldType.number, "Vertical offset in pixels.", { optional: true }),
108
+ field("direction", field_type_1.FieldType.string, "up, down, left, or right.", { optional: true }),
109
+ field("amount", field_type_1.FieldType.number, "Pixels to scroll in direction (default 300).", {
110
+ optional: true,
111
+ }),
112
+ ],
113
+ outputFields: actionResultFields,
114
+ },
115
+ {
116
+ name: "reloadUI",
117
+ usageDescription: "Reload the UI window.",
118
+ inputFields: [
119
+ field("ignoreCache", field_type_1.FieldType.boolean, "Bypass the HTTP cache.", { optional: true }),
120
+ ],
121
+ outputFields: [field("reloaded", field_type_1.FieldType.boolean, "Whether a reload started.")],
122
+ },
123
+ {
124
+ name: "screenshot",
125
+ usageDescription: "Capture the UI window as a PNG or JPEG image (base64).",
126
+ inputFields: [
127
+ field("format", field_type_1.FieldType.string, "png (default) or jpeg.", { optional: true }),
128
+ field("maxWidth", field_type_1.FieldType.number, "Scale down to at most this many pixels wide.", {
129
+ optional: true,
130
+ }),
131
+ ],
132
+ outputFields: [
133
+ field("mimeType", field_type_1.FieldType.string, "image/png or image/jpeg."),
134
+ field("width", field_type_1.FieldType.number, "Width in pixels."),
135
+ field("height", field_type_1.FieldType.number, "Height in pixels."),
136
+ field("data", field_type_1.FieldType.string, "Base64-encoded image."),
137
+ ],
138
+ },
139
+ {
140
+ name: "quitApp",
141
+ usageDescription: "Quit the app.",
142
+ inputFields: [],
143
+ outputFields: [field("quitting", field_type_1.FieldType.boolean, "Whether the app is quitting.")],
144
+ },
145
+ {
146
+ name: "restartApp",
147
+ usageDescription: "Restart the app.",
148
+ inputFields: [],
149
+ outputFields: [field("restarting", field_type_1.FieldType.boolean, "Whether the app is restarting.")],
150
+ },
151
+ {
152
+ name: "open",
153
+ usageDescription: "Open an http, https, or mailto link in the browser, or a local file or folder with the OS.",
154
+ inputFields: [field("target", field_type_1.FieldType.string, "Link or local path (~ allowed).")],
155
+ outputFields: [field("opened", field_type_1.FieldType.string, "browser or path.")],
156
+ },
157
+ {
158
+ name: "openInEditor",
159
+ usageDescription: "Open a folder in a code editor, or with the OS when none is found.",
160
+ inputFields: [field("path", field_type_1.FieldType.string, "Folder or file (~ allowed).")],
161
+ outputFields: [field("editor", field_type_1.FieldType.string, "What opened it.")],
162
+ },
163
+ {
164
+ name: "copyVariableToClipboard",
165
+ usageDescription: "Copy a persistent variable's value to the system clipboard; secret values are cleared again shortly after.",
166
+ inputFields: [
167
+ field("persistentVarId", field_type_1.FieldType.id, "Variable to copy."),
168
+ field("groupId", field_type_1.FieldType.id, "Group that holds it; personal when omitted.", {
169
+ optional: true,
170
+ }),
171
+ ],
172
+ outputFields: [
173
+ field("copied", field_type_1.FieldType.boolean, "Whether the value was copied."),
174
+ field("clearsAfterMs", field_type_1.FieldType.number, "When a secret is cleared again.", {
175
+ optional: true,
176
+ }),
177
+ ],
178
+ },
179
+ ],
180
+ observables: [],
181
+ events: [],
182
+ };
183
+ return definition;
184
+ }
185
+ (0, system_contracts_1.registerSystemContract)({
186
+ providerPackageId: system_ids_1.peersSystemPackageId,
187
+ contractId: system_ids_1.hostShellContractId,
188
+ version: exports.HOST_SHELL_CONTRACT_VERSION,
189
+ getDefinition: getHostShellContractDefinition,
190
+ });
@@ -5,19 +5,23 @@
5
5
  import "./app-updates-contract";
6
6
  import "./contract-catalog-contract";
7
7
  import "./device-operations-contract";
8
+ import "./host-shell-contract";
8
9
  import "./http-contract";
9
10
  import "./identity-contract";
10
11
  import "./invites-contract";
11
12
  import "./logs-contract";
12
13
  import "./network-contracts";
14
+ import "./packages-contract";
13
15
  import "./scheduler-contract";
14
16
  import "./tool-access-control-contract";
15
17
  export * from "./app-updates-contract";
16
18
  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";
19
+ export * from "./host-shell-contract";
17
20
  export { getIdentityContractDefinition, IDENTITY_CONTRACT_VERSION, type IIdentityConsumer, type IIdentityKeyInfo, type IIdentityRegistryKey, type IIdentityRotateKeyInput, type IIdentityRotateKeyResult, type IIdentitySessionInfo, } from "./identity-contract";
18
21
  export { getInvitesContractDefinition, type IAcceptInviteResult, type ICreatedInvite, type IInvitePreview, type IInvitesConsumer, INVITES_CONTRACT_VERSION, } from "./invites-contract";
19
22
  export { getLogsContractDefinition, type ILogsConsumer, LOGS_CONTRACT_VERSION, resolveLogsContract, } from "./logs-contract";
20
23
  export * from "./network-contracts";
24
+ export * from "./packages-contract";
21
25
  export { getToolAccessControlContractDefinition, type IToolAccessControlConsumer, TOOL_ACCESS_CONTROL_CONTRACT_VERSION, } from "./tool-access-control-contract";
22
26
  import "./tool-catalog-contract";
23
27
  export * from "./desktop-tools-contract";
@@ -22,11 +22,13 @@ exports.TOOL_ACCESS_CONTROL_CONTRACT_VERSION = exports.getToolAccessControlContr
22
22
  require("./app-updates-contract");
23
23
  require("./contract-catalog-contract");
24
24
  require("./device-operations-contract");
25
+ require("./host-shell-contract");
25
26
  require("./http-contract");
26
27
  require("./identity-contract");
27
28
  require("./invites-contract");
28
29
  require("./logs-contract");
29
30
  require("./network-contracts");
31
+ require("./packages-contract");
30
32
  require("./scheduler-contract");
31
33
  require("./tool-access-control-contract");
32
34
  __exportStar(require("./app-updates-contract"), exports);
@@ -39,6 +41,7 @@ Object.defineProperty(exports, "DEVICE_OPERATIONS_MAX_TOOLS", { enumerable: true
39
41
  Object.defineProperty(exports, "deviceOperationsProviderPackageId", { enumerable: true, get: function () { return device_operations_contract_1.deviceOperationsProviderPackageId; } });
40
42
  Object.defineProperty(exports, "deviceOperationsToolIds", { enumerable: true, get: function () { return device_operations_contract_1.deviceOperationsToolIds; } });
41
43
  Object.defineProperty(exports, "getDeviceOperationsContractDefinition", { enumerable: true, get: function () { return device_operations_contract_1.getDeviceOperationsContractDefinition; } });
44
+ __exportStar(require("./host-shell-contract"), exports);
42
45
  var identity_contract_1 = require("./identity-contract");
43
46
  Object.defineProperty(exports, "getIdentityContractDefinition", { enumerable: true, get: function () { return identity_contract_1.getIdentityContractDefinition; } });
44
47
  Object.defineProperty(exports, "IDENTITY_CONTRACT_VERSION", { enumerable: true, get: function () { return identity_contract_1.IDENTITY_CONTRACT_VERSION; } });
@@ -50,6 +53,7 @@ Object.defineProperty(exports, "getLogsContractDefinition", { enumerable: true,
50
53
  Object.defineProperty(exports, "LOGS_CONTRACT_VERSION", { enumerable: true, get: function () { return logs_contract_1.LOGS_CONTRACT_VERSION; } });
51
54
  Object.defineProperty(exports, "resolveLogsContract", { enumerable: true, get: function () { return logs_contract_1.resolveLogsContract; } });
52
55
  __exportStar(require("./network-contracts"), exports);
56
+ __exportStar(require("./packages-contract"), exports);
53
57
  var tool_access_control_contract_1 = require("./tool-access-control-contract");
54
58
  Object.defineProperty(exports, "getToolAccessControlContractDefinition", { enumerable: true, get: function () { return tool_access_control_contract_1.getToolAccessControlContractDefinition; } });
55
59
  Object.defineProperty(exports, "TOOL_ACCESS_CONTROL_CONTRACT_VERSION", { enumerable: true, get: function () { return tool_access_control_contract_1.TOOL_ACCESS_CONTROL_CONTRACT_VERSION; } });
@@ -0,0 +1,257 @@
1
+ import type { Observable } from "../../observable";
2
+ import type { IPackageRunningVersion, IPackageRuntimeError, IPackageWorkerHealth, PackageRuntimeStates, PackageRuntimeStatus } from "../../package-loader/package-runtime-state";
3
+ import type { IContractConsumerBase } from "../contract-proxy";
4
+ import type { IContractDefinition } from "../types";
5
+ /** Version of the built-in System Packages contract. */
6
+ export declare const PACKAGES_CONTRACT_VERSION = 1;
7
+ /** What the host behind a System Packages provider can do. Unsupported tools throw. */
8
+ export interface IPackagesHostCapabilities {
9
+ /** The host can read package folders: import, create, clone, and reload from disk. */
10
+ fileSystem: boolean;
11
+ /** The host can create and link a remote repository (`linkRemoteRepo`). */
12
+ linkRemote: boolean;
13
+ /** The host can install the default packages into a context (`installDefaultPackages`). */
14
+ installDefaults: boolean;
15
+ /** The host can run isolated packages. */
16
+ isolatedRuntime: boolean;
17
+ }
18
+ /**
19
+ * Observed status of a package on this device.
20
+ *
21
+ * Adds two derived states to {@link PackageRuntimeStatus}:
22
+ * - `notLoaded` — a version is selected but this device has not attempted to load it.
23
+ * - `inactive` — no version is selected yet.
24
+ */
25
+ export type PackageObservedStatus = PackageRuntimeStatus | "notLoaded" | "inactive";
26
+ /** Observed runtime state of a package on the device that answered. */
27
+ export interface IPackageObservedRuntime {
28
+ /** Outcome of the most recent load attempt, or a derived state. */
29
+ status: PackageObservedStatus;
30
+ /** What is serving now; kept when a replacement fails. */
31
+ running?: IPackageRunningVersion;
32
+ /** Most recent load failure; cleared when a later load succeeds. */
33
+ lastError?: IPackageRuntimeError;
34
+ /** Explanation for `unavailable`, `unsupported`, `disabled`, `unloaded`, or derived states. */
35
+ reason?: string;
36
+ /** Isolated worker health, when the runtime reports it. */
37
+ worker?: IPackageWorkerHealth;
38
+ /** Epoch milliseconds of the last recorded change. */
39
+ updatedAt?: number;
40
+ }
41
+ /** Which version a package should run, from the group row and this device's preferences. */
42
+ export interface IPackageRequestedVersion {
43
+ /** Group-wide active version (`Packages.activePackageVersionId`). */
44
+ groupActivePackageVersionId?: string;
45
+ /** This device's override, when set. */
46
+ deviceActivePackageVersionId?: string;
47
+ /** The version this device should run: the device override, else the group version. */
48
+ effectivePackageVersionId?: string;
49
+ /** Semantic version of the effective version. */
50
+ version?: string;
51
+ /** Release channel of the effective version. */
52
+ versionTag?: string;
53
+ /** True when updates are pinned (device pin, or the group row when the device has no prefs). */
54
+ pinned: boolean;
55
+ /** Effective follow range (`patch`, `minor`, `latest`, ...). */
56
+ followRange?: string;
57
+ /** Effective release-channel policy (`stable`, `stable,beta`, `*`). */
58
+ followTags?: string;
59
+ }
60
+ /** One package in a data context, with its requested and observed state. */
61
+ export interface IPackageSummary {
62
+ /** Package id. */
63
+ packageId: string;
64
+ /** Display name. */
65
+ name: string;
66
+ /** Package description. */
67
+ description?: string;
68
+ /** True when the package is disabled for the group. */
69
+ disabled: boolean;
70
+ /** Source repository URL, when known. */
71
+ remoteRepo?: string;
72
+ /** Requested version selection. */
73
+ requested: IPackageRequestedVersion;
74
+ /** Observed runtime state on the answering device. */
75
+ runtime: IPackageObservedRuntime;
76
+ }
77
+ /** One stored version of a package. */
78
+ export interface IPackageVersionSummary {
79
+ /** PackageVersion record id. */
80
+ packageVersionId: string;
81
+ /** Semantic version. */
82
+ version: string;
83
+ /** Release channel (`dev`, `beta`, `stable`, ...). */
84
+ versionTag?: string;
85
+ /** Creation time, epoch milliseconds. */
86
+ createdAt?: number;
87
+ /** True when the version carries a package author signature. */
88
+ authorSigned: boolean;
89
+ }
90
+ /** A package with its stored versions and this device's source folder. */
91
+ export interface IPackageDetails extends IPackageSummary {
92
+ /** Source folder on this device, when the package is developed here. */
93
+ localPath?: string;
94
+ /** Stored versions, newest first. */
95
+ versions: IPackageVersionSummary[];
96
+ }
97
+ /** Result of a tool that adds, changes, or reloads one package. */
98
+ export interface IPackageOperationResult {
99
+ /** Package the operation applied to. */
100
+ packageId: string;
101
+ /** True when `createPackage` scaffolded a new package instead of importing an existing folder. */
102
+ created?: boolean;
103
+ /**
104
+ * Non-fatal problem the caller should show: for example a missing package template, or a
105
+ * reloaded dev build that reuses a released version number and should be bumped.
106
+ */
107
+ warning?: string;
108
+ /** The package after the operation. */
109
+ package: IPackageDetails;
110
+ }
111
+ /** Per-package outcome of `reloadAllPackages`. */
112
+ export interface IPackageReloadOutcome {
113
+ /** Package id. */
114
+ packageId: string;
115
+ /** Display name. */
116
+ name: string;
117
+ /** True when the package's bundles were read without error. */
118
+ ok: boolean;
119
+ /** True when the bundles changed on disk and the package was reloaded. */
120
+ changed?: boolean;
121
+ /** Failure message when `ok` is false. */
122
+ error?: string;
123
+ /** Non-fatal problem, such as a dev build that reuses a released version number. */
124
+ warning?: string;
125
+ }
126
+ /** Result of `reloadAllPackages`. */
127
+ export interface IReloadAllPackagesResult {
128
+ /** Why the host skipped the reload, when it did. */
129
+ skipped?: string;
130
+ /** One entry per package with a source folder on this device. */
131
+ results: IPackageReloadOutcome[];
132
+ }
133
+ /** Result of `promotePackageVersion`. */
134
+ export interface IPromotePackageVersionResult extends IPackageOperationResult {
135
+ /** Version that was promoted. */
136
+ packageVersionId: string;
137
+ /** Its version number. */
138
+ version: string;
139
+ /** Release channel it now carries. */
140
+ versionTag: string;
141
+ /** True when this device holds the package signing key and signed the promoted version. */
142
+ signed: boolean;
143
+ /**
144
+ * True when the version this device was running now matches the group's follow policy
145
+ * and was activated, for the group unless this device overrides group settings.
146
+ */
147
+ activated: boolean;
148
+ }
149
+ /**
150
+ * Release channels a version may be promoted to from its current tag: `dev` to `beta` or
151
+ * `stable`, and `beta` to `stable`. Missing or empty tags on legacy versions mean `dev`,
152
+ * matching the Versions screen. Promotion never demotes.
153
+ *
154
+ * @param versionTag - The version's current tag.
155
+ */
156
+ export declare function packageVersionPromotionTargets(versionTag: string | undefined): string[];
157
+ /**
158
+ * Whether user input names a remote repository for `clonePackage` (`http(s)://` or
159
+ * `git@host:`) rather than a local folder or package name. The host still validates the
160
+ * URL; this only routes input in the CLI and UI the same way.
161
+ *
162
+ * @param target - Input as typed.
163
+ */
164
+ export declare function isPackageRepositoryUrl(target: string): boolean;
165
+ /** Typed consumer proxy for System Packages v1. */
166
+ export interface IPackagesConsumer extends IContractConsumerBase {
167
+ tools: {
168
+ /** Report what this host supports. */
169
+ getCapabilities(): Promise<{
170
+ capabilities: IPackagesHostCapabilities;
171
+ }>;
172
+ /** List packages in the bound data context. */
173
+ listPackages(): Promise<{
174
+ packages: IPackageSummary[];
175
+ }>;
176
+ /** Return one package with its versions. Throws when the package is not installed. */
177
+ getPackage(input: {
178
+ packageId: string;
179
+ }): Promise<{
180
+ package: IPackageDetails;
181
+ }>;
182
+ /** Import an existing package folder. Throws when the folder does not exist. */
183
+ importPackage(input: {
184
+ path: string;
185
+ name?: string;
186
+ }): Promise<IPackageOperationResult>;
187
+ /** Scaffold a new package, or import the folder when it already exists. */
188
+ createPackage(input: {
189
+ name: string;
190
+ location?: string;
191
+ }): Promise<IPackageOperationResult>;
192
+ /** Clone, build, and import a package from a git URL. */
193
+ clonePackage(input: {
194
+ url: string;
195
+ }): Promise<IPackageOperationResult>;
196
+ /** Re-enable a package, or copy it here from another of the user's data contexts. */
197
+ installPackage(input: {
198
+ packageId: string;
199
+ fromDataContextId?: string;
200
+ }): Promise<IPackageOperationResult>;
201
+ /**
202
+ * Select a version for this device or the whole group, then load it here. With `device`
203
+ * scope and no `packageVersionId`, clear this device's override so it follows the group.
204
+ */
205
+ activatePackageVersion(input: {
206
+ packageId: string;
207
+ packageVersionId?: string;
208
+ scope?: "device" | "group";
209
+ }): Promise<IPackageOperationResult>;
210
+ /** Rebuild the dev version from disk when it changed, then force-reload the package. */
211
+ reloadPackage(input: {
212
+ packageId: string;
213
+ }): Promise<IPackageOperationResult>;
214
+ /** Re-read every package folder on this device and reload packages whose bundles changed. */
215
+ reloadAllPackages(): Promise<IReloadAllPackagesResult>;
216
+ /** Create and link a remote repository for a local package. */
217
+ linkRemoteRepo(input: {
218
+ packageId: string;
219
+ }): Promise<IPackageOperationResult>;
220
+ /** Remove a package from the group and unload it here. */
221
+ uninstallPackage(input: {
222
+ packageId: string;
223
+ }): Promise<{
224
+ packageId: string;
225
+ removed: boolean;
226
+ }>;
227
+ /**
228
+ * Promote a stored version to `beta` or `stable`: re-tag, re-sign with the package author
229
+ * key when this device has it, record the promotion in the version's history, and
230
+ * activate it when this device was running it and the group follows the new tag.
231
+ */
232
+ promotePackageVersion(input: {
233
+ packageVersionId: string;
234
+ versionTag: string;
235
+ }): Promise<IPromotePackageVersionResult>;
236
+ /** Install the default packages into the bound data context. */
237
+ installDefaultPackages(): Promise<{
238
+ installed: boolean;
239
+ }>;
240
+ };
241
+ observables: {
242
+ /** Live runtime state of the bound context's packages on this device. */
243
+ runtimeStates: Observable<PackageRuntimeStates>;
244
+ };
245
+ }
246
+ /**
247
+ * Return the System Packages contract shape.
248
+ *
249
+ * Tools carry no `remoteAccessLevel`, so only callers this device trusts as `Self` (the
250
+ * user's own devices and users explicitly granted Self) can reach them remotely; group
251
+ * members, Admins included, are refused. Package code and workflows are refused
252
+ * everywhere. The provider binds every call to the route's
253
+ * data context; a package's group is the data boundary. Tools the host cannot perform
254
+ * throw `System Packages <tool> is not supported on this host (...)`; `getCapabilities`
255
+ * reports support up front.
256
+ */
257
+ export declare function getPackagesContractDefinition(): IContractDefinition;