@jini-ai/devops 0.6.22 → 0.7.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/checks/coverage/disk.js +2 -2
  3. package/dist/checks/coverage/floors.js +2 -2
  4. package/dist/checks/coverage/lcov.d.ts +15 -1
  5. package/dist/checks/coverage/lcov.js +77 -7
  6. package/dist/core/export-failure-summary.d.ts +9 -2
  7. package/dist/deploy/config-contracts.d.ts +82 -0
  8. package/dist/deploy/config-contracts.js +7 -0
  9. package/dist/deploy/config-descriptors.d.ts +47 -0
  10. package/dist/deploy/config-descriptors.js +92 -0
  11. package/dist/deploy/index.d.ts +12 -0
  12. package/dist/deploy/index.js +12 -0
  13. package/dist/deploy/ops-contracts.d.ts +168 -0
  14. package/dist/deploy/ops-contracts.js +2 -0
  15. package/dist/deploy/ops-descriptors.d.ts +23 -0
  16. package/dist/deploy/ops-descriptors.js +77 -0
  17. package/dist/deploy/ops-registry.d.ts +7 -0
  18. package/dist/deploy/ops-registry.js +15 -0
  19. package/dist/deploy/ops-runner.d.ts +103 -0
  20. package/dist/deploy/ops-runner.js +343 -0
  21. package/dist/deploy/ops-secret-card.d.ts +13 -0
  22. package/dist/deploy/ops-secret-card.js +62 -0
  23. package/dist/deploy/ops-secrets.d.ts +74 -0
  24. package/dist/deploy/ops-secrets.js +221 -0
  25. package/dist/deploy/ops-tool-contracts.d.ts +223 -0
  26. package/dist/deploy/ops-tool-contracts.js +2 -0
  27. package/dist/deploy/ops-tools.d.ts +8 -0
  28. package/dist/deploy/ops-tools.js +117 -0
  29. package/dist/deploy/target-contracts.d.ts +231 -0
  30. package/dist/deploy/target-contracts.js +2 -0
  31. package/dist/deploy/target-descriptors.d.ts +23 -0
  32. package/dist/deploy/target-descriptors.js +273 -0
  33. package/dist/local-dev/node-runtime.d.ts +3 -1
  34. package/dist/local-dev/node-runtime.js +4 -4
  35. package/dist/static-export/contracts.d.ts +3 -0
  36. package/dist/static-export/runner.js +2 -1
  37. package/package.json +6 -6
@@ -0,0 +1,231 @@
1
+ import type { DescriptorI18n } from '@jini-ai/core/text';
2
+ import type { ArtifactStorePort } from '../core/artifact-store.js';
3
+ import type { DeployPublishInput, DeployPublishOptions, DeployTarget, DeployPublishResult, DeployError, UnknownRecord } from '../core/deploy-types.js';
4
+ import type { DeployTargetModule as DevopsDeployTargetModule, DeployHostKit as DevopsDeployHostKit, DeployTargetCreateContext as DevopsCreateContext, DeployCredentialCheckContext as DevopsCheckContext, SigV4ClientOptions } from './host-kit.js';
5
+ /**
6
+ * @file The contract a deploy-target MODULE shipped inside an Agent Plugin is written against, and
7
+ * the descriptor shapes its `deploy-targets` contribution file declares.
8
+ *
9
+ * Hosts are dependency-injected: a host loads a plugin's module, hands it a
10
+ * {@link PluginDeployHostKit}, and gets back a plain {@link DeployTarget}. The installed plugin ABI
11
+ * stays positional; the host kit adapts its helper calls to this package's object APIs. The form
12
+ * types a host's preview passes through are type parameters, so this package names no form model.
13
+ */
14
+ /** Compatibility types for the standalone modules already installed on disk. */
15
+ type LegacyReachabilityOptions = Omit<NonNullable<Parameters<DevopsDeployHostKit["checkDeploymentUrl"]>[1]>, "detectProtected"> & {
16
+ detectProtected?: (resp: Response, body: string) => boolean;
17
+ };
18
+ type LegacyWaitOptions = Omit<NonNullable<Parameters<DevopsDeployHostKit["waitForReachableDeploymentUrl"]>[1]>, "detectProtected"> & LegacyReachabilityOptions;
19
+ export interface PluginSigV4Client {
20
+ fetch(input: string, init?: RequestInit): Promise<Response>;
21
+ sign(input: string, init?: RequestInit): Promise<Request>;
22
+ }
23
+ export interface PluginDeployHostKit {
24
+ /** Optional newer plugin ports; installed older modules keep their existing ABI. */
25
+ now?(): number;
26
+ probeContent?(required: {
27
+ readonly url: string;
28
+ readonly expected: string;
29
+ }, optional?: Record<string, never>): Promise<boolean>;
30
+ fetch(url: string, init: RequestInit, options: {
31
+ readonly timeoutMs: number;
32
+ }): Promise<Response>;
33
+ readonly timeouts: DevopsDeployHostKit["timeouts"];
34
+ sleep(ms: number): Promise<void>;
35
+ checkDeploymentUrl(url: unknown, options?: LegacyReachabilityOptions): ReturnType<DevopsDeployHostKit["checkDeploymentUrl"]>;
36
+ waitForReachableDeploymentUrl(urls: unknown[], options?: LegacyWaitOptions): ReturnType<DevopsDeployHostKit["waitForReachableDeploymentUrl"]>;
37
+ normalizeDeploymentUrl(url: unknown): string;
38
+ safeDnsLabel(raw: unknown): string;
39
+ safeProjectLabel(raw: unknown, maxLength: number): string;
40
+ redirectGuardInit(init: RequestInit): RequestInit;
41
+ assertNotRedirected(resp: Response, providerLabel: string): void;
42
+ createSigV4Client(options: SigV4ClientOptions): PluginSigV4Client;
43
+ readonly DeployError: new (message: string, status?: number, details?: DeployError["details"]) => DeployError;
44
+ }
45
+ export type PluginDeployTargetCreateContext = Omit<DevopsCreateContext, "kit"> & {
46
+ readonly kit: PluginDeployHostKit;
47
+ };
48
+ export type PluginDeployCredentialCheckContext = Omit<DevopsCheckContext, "kit"> & {
49
+ readonly kit: PluginDeployHostKit;
50
+ };
51
+ /** Installed modules receive publish options, including security headers, in their first object.
52
+ * The static-publish boundary adapts devops' separate options object to this installed ABI. */
53
+ export type HostDeployPublishInput = DeployPublishInput & DeployPublishOptions;
54
+ /** The installed plugin ABI; the host adapts its publish and checkReachability methods to the
55
+ * current devops port. `checkReachability` stays positional (`url`) because every installed,
56
+ * content-addressed module on disk was written that way; devops' port takes `{ url }`. */
57
+ export interface HostDeployTarget extends Omit<DeployTarget, "publish" | "checkReachability"> {
58
+ publish(input: HostDeployPublishInput): Promise<DeployPublishResult>;
59
+ checkReachability(url: string): ReturnType<DeployTarget["checkReachability"]>;
60
+ }
61
+ /**
62
+ * A deploy-target module's default export: devops' {@link DevopsDeployTargetModule} plus two
63
+ * host-only extras. Only `create` is required; the rest have host defaults (no config errors, no
64
+ * base path, no summary rows, no credential check, no hosting steps).
65
+ */
66
+ export interface PluginDeployTargetModule<TForm = unknown, TFormSubmissions = unknown> extends Omit<DevopsDeployTargetModule, "create" | "createArtifactStore" | "validateConfig" | "basePath" | "verifyCredential"> {
67
+ /** Authenticated read-only provider inspection. Never uploads or provisions infrastructure.
68
+ * `formDestination` lists the site's active forms (no receiver key) so a host whose deployment
69
+ * carries the selected co-hosted receiver (the "co-hosted receiver add-on",
70
+ * `features/form-destinations/`) can preview its storage. The publish counterpart is
71
+ * `metadata.formDestination` (forms plus the receiver key). */
72
+ preview?(required: PluginDeployTargetCreateContext & {
73
+ readonly projectName: string;
74
+ readonly formDestination?: {
75
+ readonly forms: readonly TForm[];
76
+ };
77
+ }, optional?: Record<string, never>): Promise<DeployTargetInspection<TFormSubmissions>>;
78
+ readonly defaultForNewDestination?: boolean;
79
+ /** A new capability may require explicit compatibility instead of inheriting an old vendor ID. */
80
+ acceptsCredential?(required: {
81
+ readonly worksFor: readonly string[];
82
+ }, optional?: Record<string, never>): boolean;
83
+ readonly defaultCredentialWorksFor?: readonly string[];
84
+ /** Exact remote identity, projected through descriptor-allowlisted history fields. */
85
+ destinationConfig?(required: {
86
+ readonly providerMetadata?: Readonly<Record<string, unknown>>;
87
+ }, optional?: Record<string, never>): Readonly<Record<string, string>>;
88
+ /** Separate single-object lifecycle; never enters static publish's cleanup manifest. */
89
+ createArtifactStore?(required: PluginDeployTargetCreateContext, optional?: Record<string, never>): ArtifactStorePort;
90
+ create(context: PluginDeployTargetCreateContext): HostDeployTarget;
91
+ validateConfig?(config: UnknownRecord): string | null;
92
+ basePath?(config: UnknownRecord): string | undefined;
93
+ verifyCredential?(context: PluginDeployCredentialCheckContext): ReturnType<NonNullable<DevopsDeployTargetModule["verifyCredential"]>>;
94
+ /** The confirmation/outcome card rows for `config`, when the host reads better than one row per
95
+ * config field (a repository as `owner/repo`, for example). */
96
+ summarize?(config: UnknownRecord): readonly {
97
+ readonly label: string;
98
+ readonly value: string;
99
+ }[];
100
+ /** Steps the person applies in their own host console before the site is reachable (making a
101
+ * storage bucket public, for example). Pure: no request, no credential. `fields` are the non-secret
102
+ * credential fields the agent passed. Throws a plain `Error` with a person-facing message for a
103
+ * missing field. */
104
+ hostingSetup?(input: {
105
+ readonly fields: Readonly<Record<string, string>>;
106
+ }): DeployHostingSetup;
107
+ }
108
+ /** Plugin-owned inspection data; opaque vendor facts remain outside Jini's generic port. */
109
+ export interface DeployTargetInspection<TFormSubmissions = unknown> {
110
+ readonly resourceName: string;
111
+ readonly targetId: string;
112
+ readonly hostingChanges: readonly Readonly<Record<string, unknown>>[];
113
+ readonly domains?: {
114
+ readonly inventoryStatus: "complete" | "unknown";
115
+ readonly fingerprint?: string;
116
+ readonly message: string;
117
+ readonly errorCode?: string;
118
+ readonly hostnames: readonly Readonly<Record<string, unknown>>[];
119
+ readonly changes: readonly Readonly<Record<string, unknown>>[];
120
+ };
121
+ /** Present when the site has active forms: whether they will be received, and what that changes.
122
+ * The co-hosted receiver add-on reports it from the host's own preview; core answers it otherwise. */
123
+ readonly formSubmissions?: TFormSubmissions;
124
+ }
125
+ /** A module's hosting-setup answer, relayed to the person as prose plus copyable `consoleJson`. */
126
+ export interface DeployHostingSetup {
127
+ /** Which flavour of the host the steps are for, when the module tells them apart. */
128
+ readonly provider?: string;
129
+ readonly steps: readonly {
130
+ readonly title: string;
131
+ readonly description: string;
132
+ readonly consoleJson?: string;
133
+ }[];
134
+ /** Relayed verbatim when non-empty. */
135
+ readonly warning: string;
136
+ }
137
+ /** One entry of a plugin's `deploy-targets` contribution file. `id` is byte-identical to the legacy provider
138
+ * id for existing hosts: sealed credentials and publish history rows are keyed by it. */
139
+ export interface DeployTargetDescriptor {
140
+ readonly id: string;
141
+ readonly label: string;
142
+ /** Plugin-relative path of the `.mjs` module. */
143
+ readonly module: string;
144
+ /** Per-publish settings the person supplies (a repository, a team), in display order. Read from a
145
+ * publish request under the same names; values are strings. Empty when the host needs none. */
146
+ readonly configFields: readonly DeployTargetFieldSpec[];
147
+ /** What the publish form calls the per-publish project name for this host (a commit message, a
148
+ * site name). Absent: the generic "Project name". */
149
+ readonly projectName?: DeployTargetProjectNameCopy;
150
+ /** The server-environment credential fallback. Absent when the host has none. */
151
+ readonly env?: DeployTargetEnvFallback;
152
+ /** What a saved connection for this host holds. Absent when the host takes no saved credential. */
153
+ readonly credential?: DeployTargetCredentialSpec;
154
+ /** Translations of this target's own person-facing text, keyed by locale then by the English
155
+ * string (`features/agent-plugins/descriptor-i18n.ts`). Absent: English only. */
156
+ readonly i18n?: DescriptorI18n;
157
+ }
158
+ /**
159
+ * A host's saved credential: flat string fields, sealed as one JSON object together with its
160
+ * `providerId` (the target id). `tokenField` names the required field that becomes the resolved
161
+ * credential's `token`; every other field is handed to the module under its own name.
162
+ */
163
+ export interface DeployTargetCredentialSpec {
164
+ /** The account/company the credential authenticates to (`vendor_credential_sets.vendor_id`). */
165
+ readonly vendorId: string;
166
+ /** The name a credential-check message uses ("GitHub accepted this credential."). Defaults to the
167
+ * target's `label`. */
168
+ readonly vendorLabel?: string;
169
+ /** The module's `verifyCredential` can return an `accountLabel`, so a saved row without one is
170
+ * worth re-checking in the background. */
171
+ readonly yieldsAccountLabel?: true;
172
+ /** Shown above the credential form's fields (what to have ready before filling it in). */
173
+ readonly help?: string;
174
+ /** The same guidance written for the person; the admin shows it over {@link help} when present. */
175
+ readonly userHelp?: string;
176
+ /** The host's own page for creating the credential (https), linked from the credential form. */
177
+ readonly tokenPageUrl?: string;
178
+ readonly tokenField: string;
179
+ readonly fields: readonly DeployTargetFieldSpec[];
180
+ }
181
+ /** What the publish form's project-name field means for one host. */
182
+ export interface DeployTargetProjectNameCopy {
183
+ readonly label: string;
184
+ readonly help?: string;
185
+ }
186
+ /** One named string field a person fills in. */
187
+ export interface DeployTargetFieldSpec {
188
+ readonly name: string;
189
+ readonly label: string;
190
+ readonly required: boolean;
191
+ readonly help?: string;
192
+ /** The help a PERSON sees in the admin form, when it should read differently from `help` (which
193
+ * the agent sees as the field's hint). Absent = the form shows `help`. */
194
+ readonly userHelp?: string;
195
+ /** Never echoed back once saved (credential fields only). */
196
+ readonly secret?: true;
197
+ }
198
+ /** Where an env-configured install finds a target's credential: the first set `tokenVars` entry
199
+ * is the token, and each `fields` entry names the env var that supplies that extra credential field
200
+ * (all required). */
201
+ export interface DeployTargetEnvFallback {
202
+ readonly tokenVars: readonly string[];
203
+ readonly fields?: Readonly<Record<string, string>>;
204
+ }
205
+ export interface LoadedDeployTarget<TForm = unknown, TFormSubmissions = unknown> {
206
+ readonly descriptor: DeployTargetDescriptor;
207
+ readonly pluginId: string;
208
+ readonly module: PluginDeployTargetModule<TForm, TFormSubmissions>;
209
+ }
210
+ export interface DeployTargetRegistry<TForm = unknown, TFormSubmissions = unknown> {
211
+ get(targetId: string): LoadedDeployTarget<TForm, TFormSubmissions> | undefined;
212
+ list(): readonly LoadedDeployTarget<TForm, TFormSubmissions>[];
213
+ /** Log-safe, one sentence per plugin or target that was NOT loaded, and why. */
214
+ readonly refusals: readonly string[];
215
+ }
216
+ /** Installed metadata is independent of activation, credential configuration and executable code. */
217
+ export interface InstalledDeployTarget {
218
+ readonly descriptor: DeployTargetDescriptor;
219
+ readonly pluginId: string;
220
+ /** null means the activation record could not be read; never interpret it as consent. */
221
+ readonly enabled: boolean | null;
222
+ }
223
+ export interface InstalledDeployTargetInventory {
224
+ readonly items: readonly InstalledDeployTarget[];
225
+ readonly refusals: readonly string[];
226
+ }
227
+ export type LoadInstalledDeployTargets = (required: {
228
+ readonly workspaceId: string;
229
+ }, optional?: Record<string, never>) => Promise<InstalledDeployTargetInventory>;
230
+ export {};
231
+ //# sourceMappingURL=target-contracts.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=target-contracts.js.map
@@ -0,0 +1,23 @@
1
+ import type { DeployTargetDescriptor, PluginDeployTargetModule } from './target-contracts.js';
2
+ type ParseResult = {
3
+ readonly ok: true;
4
+ readonly descriptors: readonly DeployTargetDescriptor[];
5
+ } | {
6
+ readonly ok: false;
7
+ readonly reason: string;
8
+ };
9
+ /** Validate the default export after Jini's contained import. @complexity O(1). */
10
+ export declare function asDeployTargetModule<TForm = unknown, TFormSubmissions = unknown>({ exported: candidate }: {
11
+ readonly exported: unknown;
12
+ }, _optional?: Record<string, never>): PluginDeployTargetModule<TForm, TFormSubmissions> | string;
13
+ /**
14
+ * Parses a plugin's {@link DEPLOY_TARGETS_FILENAME}. Pure (exported for its own tests). Unknown keys are ignored so later slices
15
+ * can add credential/config field specs without breaking an older host.
16
+ *
17
+ * @complexity O(t) in the declared target count.
18
+ */
19
+ export declare function parseDeployTargetsFile({ raw }: {
20
+ readonly raw: string;
21
+ }, _optional?: Record<string, never>): ParseResult;
22
+ export {};
23
+ //# sourceMappingURL=target-descriptors.d.ts.map
@@ -0,0 +1,273 @@
1
+ import path from 'node:path';
2
+ import { parseDescriptorI18n } from '@jini-ai/core/text';
3
+ /**
4
+ * @file The pure parser for a plugin's `deploy-targets` contribution file, and the module contract
5
+ * each declared target's default export must meet. No filesystem access, no import: the host reads
6
+ * the file, imports the module through its own trust gates, and hands both here.
7
+ */
8
+ /** Same shape as today's provider ids: lowercase, hyphenated (e.g. `s3-compatible`). */
9
+ const TARGET_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
10
+ const MAX_TARGET_ID_LENGTH = 64;
11
+ const MAX_LABEL_LENGTH = 100;
12
+ /** Validate the default export after Jini's contained import. @complexity O(1). */
13
+ export function asDeployTargetModule({ exported: candidate }, _optional = {}) {
14
+ if (!isPlainObject(candidate) || typeof candidate.create !== "function")
15
+ return "its module has no create() function";
16
+ return candidate;
17
+ }
18
+ /**
19
+ * Parses a plugin's {@link DEPLOY_TARGETS_FILENAME}. Pure (exported for its own tests). Unknown keys are ignored so later slices
20
+ * can add credential/config field specs without breaking an older host.
21
+ *
22
+ * @complexity O(t) in the declared target count.
23
+ */
24
+ export function parseDeployTargetsFile({ raw }, _optional = {}) {
25
+ let value;
26
+ try {
27
+ value = JSON.parse(raw);
28
+ }
29
+ catch {
30
+ return { ok: false, reason: "not valid JSON" };
31
+ }
32
+ if (!isPlainObject(value) || value.schemaVersion !== 1)
33
+ return { ok: false, reason: "schemaVersion must be 1" };
34
+ if (!Array.isArray(value.targets))
35
+ return { ok: false, reason: "targets must be an array" };
36
+ const descriptors = [];
37
+ const seen = new Set();
38
+ for (const [index, entry] of value.targets.entries()) {
39
+ const result = parseDescriptor(entry, `targets[${index}]`);
40
+ if (typeof result === "string")
41
+ return { ok: false, reason: result };
42
+ if (seen.has(result.id))
43
+ return { ok: false, reason: `targets[${index}].id '${result.id}' is declared twice` };
44
+ seen.add(result.id);
45
+ descriptors.push(result);
46
+ }
47
+ return { ok: true, descriptors };
48
+ }
49
+ /** One descriptor entry, or the reason it is invalid. @complexity O(f) declared fields. */
50
+ function parseDescriptor(entry, at) {
51
+ if (!isPlainObject(entry))
52
+ return `${at} must be an object`;
53
+ const { id, label, module } = entry;
54
+ if (!isTargetId({ value: id }))
55
+ return `${at}.id must be a lowercase hyphenated id`;
56
+ if (!isLabel(label))
57
+ return `${at}.label must be a non-empty string`;
58
+ if (!isRelativeModulePath({ value: module }))
59
+ return `${at}.module must be a relative path ending in .mjs`;
60
+ const settings = parseDescriptorSettings({ entry, at });
61
+ if (typeof settings === "string")
62
+ return settings;
63
+ const projectName = parseProjectNameCopy(entry.projectName, `${at}.projectName`);
64
+ if (typeof projectName === "string")
65
+ return projectName;
66
+ const i18n = parseDescriptorI18n({ value: entry.i18n, at: `${at}.i18n` });
67
+ if (typeof i18n === "string")
68
+ return i18n;
69
+ const { configFields, ...optionalSettings } = settings;
70
+ return {
71
+ id: id,
72
+ label,
73
+ module: module,
74
+ configFields,
75
+ ...(projectName !== undefined ? { projectName } : {}),
76
+ ...optionalSettings,
77
+ ...(i18n !== undefined ? { i18n } : {}),
78
+ };
79
+ }
80
+ /** A target's `projectName` copy (absent = the generic "Project name"), or the reason it is invalid. @complexity O(1). */
81
+ function parseProjectNameCopy(value, at) {
82
+ if (value === undefined)
83
+ return undefined;
84
+ if (!isPlainObject(value) || !isLabel(value.label))
85
+ return `${at}.label must be a non-empty string`;
86
+ const { label, help } = value;
87
+ if (help !== undefined && (typeof help !== "string" || help.length > MAX_HELP_LENGTH))
88
+ return `${at}.help must be a string of at most ${MAX_HELP_LENGTH} characters`;
89
+ return { label, ...(help !== undefined ? { help } : {}) };
90
+ }
91
+ /** An absolute https URL, the only kind a credential form links out to. @complexity O(n) in its length. */
92
+ function isHttpsUrl(value) {
93
+ if (typeof value !== "string" || value.length > 500)
94
+ return false;
95
+ try {
96
+ return new URL(value).protocol === "https:";
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ }
102
+ /** A saved connection's own discriminant, so a credential field of that name would be ambiguous. */
103
+ const RESERVED_CREDENTIAL_FIELD_NAMES = new Set(["providerId"]);
104
+ /** A target's `credential` block (absent = no saved credential), or the reason it is invalid. @complexity O(f). */
105
+ function parseCredentialSpec(value, at) {
106
+ if (value === undefined)
107
+ return undefined;
108
+ if (!isPlainObject(value))
109
+ return `${at} must be an object`;
110
+ const { vendorId, vendorLabel, yieldsAccountLabel } = value;
111
+ if (!isTargetId({ value: vendorId }))
112
+ return `${at}.vendorId must be a lowercase hyphenated id`;
113
+ if (vendorLabel !== undefined && !isLabel(vendorLabel))
114
+ return `${at}.vendorLabel must be a non-empty string`;
115
+ if (!isOptionalBoolean({ value: yieldsAccountLabel }))
116
+ return `${at}.yieldsAccountLabel must be a boolean`;
117
+ const details = parseCredentialDetails({ value, at });
118
+ if (typeof details === "string")
119
+ return details;
120
+ return {
121
+ vendorId: vendorId,
122
+ ...(vendorLabel !== undefined ? { vendorLabel } : {}),
123
+ ...(yieldsAccountLabel === true ? { yieldsAccountLabel: true } : {}),
124
+ ...details,
125
+ };
126
+ }
127
+ /** Keys a publish request already uses for itself, so a config field of that name would be ambiguous. */
128
+ const RESERVED_FIELD_NAMES = new Set(["target", "projectName", "credentialId"]);
129
+ const FIELD_NAME_PATTERN = /^[a-z][A-Za-z0-9]{0,63}$/;
130
+ const ENV_VAR_PATTERN = /^[A-Z][A-Z0-9_]{0,127}$/;
131
+ const MAX_FIELDS = 16;
132
+ const MAX_HELP_LENGTH = 500;
133
+ /** A target's `config` list (absent = none), or the reason it is invalid. @complexity O(f). */
134
+ function parseConfigFields(value, at) {
135
+ if (value === undefined)
136
+ return [];
137
+ const fields = parseFieldList(value, at, RESERVED_FIELD_NAMES);
138
+ if (typeof fields === "string")
139
+ return fields;
140
+ const secretAt = fields.findIndex((field) => field.secret === true);
141
+ return secretAt === -1 ? fields : `${at}[${secretAt}] is marked secret; config is passed in the clear, so declare it under credential.fields`;
142
+ }
143
+ /** A list of uniquely named field specs, or the reason it is invalid. @complexity O(f²), f <= {@link MAX_FIELDS}. */
144
+ function parseFieldList(value, at, reserved) {
145
+ if (!Array.isArray(value) || value.length > MAX_FIELDS)
146
+ return `${at} must be an array of at most ${MAX_FIELDS} fields`;
147
+ const fields = [];
148
+ for (const [index, entry] of value.entries()) {
149
+ const field = parseFieldSpec(entry, `${at}[${index}]`, reserved);
150
+ if (typeof field === "string")
151
+ return field;
152
+ if (fields.some((seen) => seen.name === field.name))
153
+ return `${at}[${index}].name '${field.name}' is declared twice`;
154
+ fields.push(field);
155
+ }
156
+ return fields;
157
+ }
158
+ /** One field spec, or the reason it is invalid. @complexity O(1). */
159
+ function parseFieldSpec(entry, at, reserved) {
160
+ if (!isPlainObject(entry))
161
+ return `${at} must be an object`;
162
+ const { name, label, required, secret } = entry;
163
+ if (typeof name !== "string" || !FIELD_NAME_PATTERN.test(name))
164
+ return `${at}.name must be a camelCase identifier`;
165
+ if (reserved.has(name))
166
+ return `${at}.name '${name}' is reserved`;
167
+ if (!isLabel(label))
168
+ return `${at}.label must be a non-empty string`;
169
+ if (!isOptionalBoolean({ value: required }))
170
+ return `${at}.required must be a boolean`;
171
+ if (!isOptionalBoolean({ value: secret }))
172
+ return `${at}.secret must be a boolean`;
173
+ const copy = parseHelpCopy({ value: entry, at });
174
+ if (typeof copy === "string")
175
+ return copy;
176
+ return {
177
+ name,
178
+ label,
179
+ required: required === true,
180
+ ...copy,
181
+ ...(secret === true ? { secret: true } : {}),
182
+ };
183
+ }
184
+ /** A target's `env` block (absent = no env fallback), or the reason it is invalid. @complexity O(v). */
185
+ function parseEnvFallback(value, at) {
186
+ if (value === undefined)
187
+ return undefined;
188
+ if (!isPlainObject(value))
189
+ return `${at} must be an object`;
190
+ const { tokenVars, fields } = value;
191
+ if (!Array.isArray(tokenVars) || tokenVars.length === 0 || tokenVars.length > MAX_FIELDS || !tokenVars.every(isEnvVarName)) {
192
+ return `${at}.tokenVars must be a non-empty array of env var names`;
193
+ }
194
+ if (fields === undefined)
195
+ return { tokenVars };
196
+ const parsedFields = parseEnvFields({ fields, at });
197
+ if (typeof parsedFields === "string")
198
+ return parsedFields;
199
+ return { tokenVars, fields: parsedFields };
200
+ }
201
+ function isLabel(value) {
202
+ return typeof value === "string" && value.trim() !== "" && value.length <= MAX_LABEL_LENGTH;
203
+ }
204
+ function isEnvVarName(value) {
205
+ return typeof value === "string" && ENV_VAR_PATTERN.test(value);
206
+ }
207
+ function isPlainObject(value) {
208
+ return typeof value === "object" && value !== null && !Array.isArray(value);
209
+ }
210
+ /** The same deploy-target id contract applies to the target and its credential vendor. */
211
+ function isTargetId({ value }, _optional = {}) {
212
+ return typeof value === "string" && value.length <= MAX_TARGET_ID_LENGTH && TARGET_ID_PATTERN.test(value);
213
+ }
214
+ /** Lexical module validation; the contribution loader still enforces containment on disk. */
215
+ function isRelativeModulePath({ value }, _optional = {}) {
216
+ return typeof value === "string" && value.endsWith(".mjs") && !path.posix.isAbsolute(value);
217
+ }
218
+ function isOptionalBoolean({ value }, _optional = {}) {
219
+ return value === undefined || typeof value === "boolean";
220
+ }
221
+ /** Shared descriptor help bounds and omission semantics for fields and credentials. */
222
+ function parseHelpCopy({ value, at }, _optional = {}) {
223
+ const { help, userHelp } = value;
224
+ if (help !== undefined && (typeof help !== "string" || help.length > MAX_HELP_LENGTH))
225
+ return `${at}.help must be a string of at most ${MAX_HELP_LENGTH} characters`;
226
+ if (userHelp !== undefined && (typeof userHelp !== "string" || userHelp.length > MAX_HELP_LENGTH))
227
+ return `${at}.userHelp must be a string of at most ${MAX_HELP_LENGTH} characters`;
228
+ return {
229
+ ...(help !== undefined ? { help } : {}),
230
+ ...(userHelp !== undefined ? { userHelp } : {}),
231
+ };
232
+ }
233
+ /** Credential guidance and fields, validated after vendor identity in the original refusal order. */
234
+ function parseCredentialDetails({ value, at }, _optional = {}) {
235
+ const copy = parseHelpCopy({ value, at });
236
+ if (typeof copy === "string")
237
+ return copy;
238
+ const { tokenPageUrl, tokenField = "token" } = value;
239
+ if (tokenPageUrl !== undefined && !isHttpsUrl(tokenPageUrl))
240
+ return `${at}.tokenPageUrl must be an https URL`;
241
+ const fields = parseFieldList(value.fields, `${at}.fields`, RESERVED_CREDENTIAL_FIELD_NAMES);
242
+ if (typeof fields === "string")
243
+ return fields;
244
+ if (typeof tokenField !== "string" || !fields.some((field) => field.name === tokenField && field.required))
245
+ return `${at}.tokenField '${String(tokenField)}' must name a required field`;
246
+ return { ...copy, ...(tokenPageUrl !== undefined ? { tokenPageUrl } : {}), tokenField, fields };
247
+ }
248
+ /** The bounded field-to-environment mapping, separate from the ordered token fallback list. */
249
+ function parseEnvFields({ fields, at }, _optional = {}) {
250
+ const entries = isPlainObject(fields) ? Object.entries(fields) : [];
251
+ if (!isPlainObject(fields) || entries.length > MAX_FIELDS || !entries.every(([name, envVar]) => FIELD_NAME_PATTERN.test(name) && isEnvVarName(envVar))) {
252
+ return `${at}.fields must map field names to env var names`;
253
+ }
254
+ return Object.fromEntries(entries);
255
+ }
256
+ /** Publish inputs share their validation order, while presentation copy is parsed afterwards. */
257
+ function parseDescriptorSettings({ entry, at }, _optional = {}) {
258
+ const configFields = parseConfigFields(entry.config, `${at}.config`);
259
+ if (typeof configFields === "string")
260
+ return configFields;
261
+ const env = parseEnvFallback(entry.env, `${at}.env`);
262
+ if (typeof env === "string")
263
+ return env;
264
+ const credential = parseCredentialSpec(entry.credential, `${at}.credential`);
265
+ if (typeof credential === "string")
266
+ return credential;
267
+ return {
268
+ configFields,
269
+ ...(env !== undefined ? { env } : {}),
270
+ ...(credential !== undefined ? { credential } : {}),
271
+ };
272
+ }
273
+ //# sourceMappingURL=target-descriptors.js.map
@@ -8,14 +8,16 @@ interface RuntimeOptions {
8
8
  }) => string;
9
9
  usable?: (input: {
10
10
  command: string;
11
+ env: NodeJS.ProcessEnv;
11
12
  }) => boolean;
13
+ env?: NodeJS.ProcessEnv;
12
14
  }
13
15
  /** Select an installed desktop Node runtime, falling back without refusing boot.
14
16
  * Executables are returned separately from arguments: paths with spaces work on Windows too.
15
17
  * @returns Command and the minimal environment override; never mutates the caller's environment.
16
18
  * @complexity O(search roots), with one bounded 5s native probe per discovered binary.
17
19
  */
18
- export declare function selectNodeRuntime({ searchFrom, nodePath }: RuntimeInput, { resolveBinary, usable }?: RuntimeOptions): {
20
+ export declare function selectNodeRuntime({ searchFrom, nodePath }: RuntimeInput, { resolveBinary, usable, env }?: RuntimeOptions): {
19
21
  command: string;
20
22
  env: Record<string, string>;
21
23
  fallback: boolean;
@@ -9,9 +9,9 @@ function installedBinary({ directory }) {
9
9
  return binary;
10
10
  }
11
11
  /** Probe without opening a window; a fused-off or incomplete installation is not usable as Node. */
12
- function usableBinary({ command }) {
12
+ function usableBinary({ command, env }) {
13
13
  const result = spawnSync(command, ['-e', 'process.exit(process.versions.node ? 0 : 1)'], {
14
- env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' }, stdio: 'ignore', timeout: 5000, windowsHide: true,
14
+ env: { ...env, ELECTRON_RUN_AS_NODE: '1' }, stdio: 'ignore', timeout: 5000, windowsHide: true,
15
15
  });
16
16
  return result.status === 0;
17
17
  }
@@ -20,11 +20,11 @@ function usableBinary({ command }) {
20
20
  * @returns Command and the minimal environment override; never mutates the caller's environment.
21
21
  * @complexity O(search roots), with one bounded 5s native probe per discovered binary.
22
22
  */
23
- export function selectNodeRuntime({ searchFrom, nodePath }, { resolveBinary = installedBinary, usable = usableBinary } = {}) {
23
+ export function selectNodeRuntime({ searchFrom, nodePath }, { resolveBinary = installedBinary, usable = usableBinary, env = process.env } = {}) {
24
24
  for (const directory of searchFrom) {
25
25
  try {
26
26
  const command = resolveBinary({ directory });
27
- if (usable({ command }))
27
+ if (usable({ command, env }))
28
28
  return { command, env: { ELECTRON_RUN_AS_NODE: '1' }, fallback: false };
29
29
  }
30
30
  catch { /* An optional installation must never refuse local development. */ }
@@ -117,6 +117,9 @@ export interface ExportSiteArgs {
117
117
  assetSource: AssetSourcePort;
118
118
  themeLayout: ThemeLayoutPort;
119
119
  assetUrlPrefixes: readonly string[];
120
+ /** Explicit site-relative assets from declarations (including JSON), fetched through the same app.
121
+ * A deferred list runs once after app.open, allowing the host to expose its mounted runtime assets. */
122
+ assetUrls?: readonly string[] | (() => Promise<readonly string[]>);
120
123
  requestHeaders: Readonly<Record<string, string>>;
121
124
  security: {
122
125
  transformHtml(required: {
@@ -311,7 +311,8 @@ export async function exportSite(required, optional = {}) {
311
311
  try {
312
312
  const ctx = { args: required, baseUrl: sessionOrigin({ baseUrl: session.baseUrl }), basePath, timeoutMs };
313
313
  const routes = await writeRoutes(ctx, manifest.routes);
314
- const assets = await writeAssets(ctx, [...routes.assets]);
314
+ const explicitAssets = typeof required.assetUrls === 'function' ? await required.assetUrls() : required.assetUrls ?? [];
315
+ const assets = await writeAssets(ctx, [...routes.assets, ...explicitAssets]);
315
316
  return { outputDir: required.outputDir, routes: { succeeded: routes.succeeded, failed: routes.failed }, assets, skippedManifestEntries: [...manifest.skipped, ...routes.skipped],
316
317
  droppedReferences: droppedReferences({ routes: routes.succeeded, assets: assets.succeeded, basePath, baseUrl: ctx.baseUrl }),
317
318
  unreferencedThemeFiles: await unreferenced(ctx, manifest, assets.succeeded), ...(basePath ? { basePath, basePathRewriteWarning: BASE_PATH_REWRITE_WARNING } : {}) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/devops",
3
- "version": "0.6.22",
3
+ "version": "0.7.0",
4
4
  "description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -155,16 +155,16 @@
155
155
  "@vitest/coverage-v8": "^2.1.9",
156
156
  "undici": "^7.25.0",
157
157
  "parse5": "7.3.0",
158
- "@jini-ai/daemon": "0.6.22",
159
- "@jini-ai/platform": "^0.6.22",
160
- "@jini-ai/core": "^0.6.22"
158
+ "@jini-ai/core": "^0.7.0",
159
+ "@jini-ai/daemon": "0.7.0",
160
+ "@jini-ai/platform": "^0.7.0"
161
161
  },
162
162
  "dependencies": {
163
- "@jini-ai/core": "^0.6.22"
163
+ "@jini-ai/core": "^0.7.0"
164
164
  },
165
165
  "peerDependencies": {
166
166
  "typescript": "^5.6.0",
167
- "@jini-ai/platform": "^0.6.10",
167
+ "@jini-ai/platform": "^0.7.0",
168
168
  "undici": "^7.25.0",
169
169
  "parse5": "7.3.0",
170
170
  "electron": ">=30.0.0"