@lumenflow/cli 5.5.0 → 5.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -40
- package/dist/db-journal-recover.js +400 -0
- package/dist/db-journal-recover.js.map +1 -0
- package/dist/docs-sync.js +8 -3
- package/dist/docs-sync.js.map +1 -1
- package/dist/doctor.js +11 -0
- package/dist/doctor.js.map +1 -1
- package/dist/gate-defaults.js +37 -0
- package/dist/gate-defaults.js.map +1 -1
- package/dist/gates/monolithic-file-contention-guard.js +167 -0
- package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
- package/dist/gates/prod-migration-drift.js +207 -0
- package/dist/gates/prod-migration-drift.js.map +1 -0
- package/dist/gates/test-over-deletion-guard.js +280 -0
- package/dist/gates/test-over-deletion-guard.js.map +1 -0
- package/dist/gates-runners.js +44 -3
- package/dist/gates-runners.js.map +1 -1
- package/dist/gates.js +3 -2
- package/dist/gates.js.map +1 -1
- package/dist/hooks/config-resolver.js +16 -1
- package/dist/hooks/config-resolver.js.map +1 -1
- package/dist/hooks/dirty-guard.js +43 -2
- package/dist/hooks/dirty-guard.js.map +1 -1
- package/dist/hooks/git-status-parser.js +22 -8
- package/dist/hooks/git-status-parser.js.map +1 -1
- package/dist/init-templates.js +241 -0
- package/dist/init-templates.js.map +1 -1
- package/dist/init.js +122 -16
- package/dist/init.js.map +1 -1
- package/dist/lumenflow-setup.js +144 -0
- package/dist/lumenflow-setup.js.map +1 -0
- package/dist/lumenflow-upgrade.js +43 -1
- package/dist/lumenflow-upgrade.js.map +1 -1
- package/dist/mem-create.js +10 -1
- package/dist/mem-create.js.map +1 -1
- package/dist/mem-signal.js +21 -4
- package/dist/mem-signal.js.map +1 -1
- package/dist/orchestrate-initiative.js +28 -3
- package/dist/orchestrate-initiative.js.map +1 -1
- package/dist/public-manifest.js +17 -7
- package/dist/public-manifest.js.map +1 -1
- package/dist/release.js +53 -18
- package/dist/release.js.map +1 -1
- package/dist/wu-done-gates.js +13 -9
- package/dist/wu-done-gates.js.map +1 -1
- package/dist/wu-done.js +14 -2
- package/dist/wu-done.js.map +1 -1
- package/dist/wu-edit-operations.js +74 -0
- package/dist/wu-edit-operations.js.map +1 -1
- package/dist/wu-edit-validators.js +58 -0
- package/dist/wu-edit-validators.js.map +1 -1
- package/dist/wu-edit.js +106 -4
- package/dist/wu-edit.js.map +1 -1
- package/dist/wu-prep.js +57 -9
- package/dist/wu-prep.js.map +1 -1
- package/dist/wu-recover.js +6 -0
- package/dist/wu-recover.js.map +1 -1
- package/dist/wu-release.js +120 -2
- package/dist/wu-release.js.map +1 -1
- package/dist/wu-sizing-validation.js +47 -17
- package/dist/wu-sizing-validation.js.map +1 -1
- package/dist/wu-status.js +33 -0
- package/dist/wu-status.js.map +1 -1
- package/package.json +13 -12
- package/packs/agent-runtime/package.json +1 -1
- package/packs/sidekick/package.json +1 -1
- package/packs/software-delivery/package.json +1 -1
- package/templates/core/AGENTS.md.template +67 -3
- package/templates/core/LUMENFLOW.md.template +196 -47
- package/dist/distribution-preflight.js +0 -230
- package/dist/distribution-preflight.js.map +0 -1
- package/packs/agent-runtime/agent-heartbeat.ts +0 -163
- package/packs/agent-runtime/auto-session-integration.ts +0 -888
- package/packs/agent-runtime/capability-factory.ts +0 -104
- package/packs/agent-runtime/constants.ts +0 -21
- package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
- package/packs/agent-runtime/delegation-registry-store.ts +0 -269
- package/packs/agent-runtime/delegation-tree.ts +0 -328
- package/packs/agent-runtime/index.ts +0 -20
- package/packs/agent-runtime/manifest.ts +0 -348
- package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
- package/packs/agent-runtime/orchestration.ts +0 -2027
- package/packs/agent-runtime/pack-registration.ts +0 -110
- package/packs/agent-runtime/policy-factory.ts +0 -165
- package/packs/agent-runtime/remote-controls/index.ts +0 -7
- package/packs/agent-runtime/remote-controls/operations.ts +0 -405
- package/packs/agent-runtime/remote-controls/port.ts +0 -48
- package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
- package/packs/agent-runtime/remote-controls/types.ts +0 -105
- package/packs/agent-runtime/session-schema.ts +0 -467
- package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
- package/packs/agent-runtime/tool-impl/index.ts +0 -6
- package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
- package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
- package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
- package/packs/agent-runtime/tools/index.ts +0 -4
- package/packs/agent-runtime/tools/types.ts +0 -47
- package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
- package/packs/agent-runtime/types.ts +0 -128
- package/packs/agent-runtime/vitest.config.ts +0 -11
- package/packs/sidekick/channel-ingress.ts +0 -137
- package/packs/sidekick/constants.ts +0 -10
- package/packs/sidekick/index.ts +0 -8
- package/packs/sidekick/manifest-schema.ts +0 -49
- package/packs/sidekick/manifest.ts +0 -512
- package/packs/sidekick/pack-registration.ts +0 -110
- package/packs/sidekick/policy-factory.ts +0 -38
- package/packs/sidekick/sidekick-events.ts +0 -694
- package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
- package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
- package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
- package/packs/sidekick/src/domain/channel.types.ts +0 -64
- package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
- package/packs/sidekick/src/routines/commit.ts +0 -74
- package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
- package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
- package/packs/sidekick/tool-impl/index.ts +0 -29
- package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
- package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
- package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
- package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
- package/packs/sidekick/tool-impl/shared.ts +0 -125
- package/packs/sidekick/tool-impl/storage.ts +0 -325
- package/packs/sidekick/tool-impl/system-tools.ts +0 -160
- package/packs/sidekick/tool-impl/task-tools.ts +0 -506
- package/packs/sidekick/tools/channel-tools.ts +0 -53
- package/packs/sidekick/tools/index.ts +0 -9
- package/packs/sidekick/tools/memory-tools.ts +0 -53
- package/packs/sidekick/tools/routine-tools.ts +0 -53
- package/packs/sidekick/tools/system-tools.ts +0 -47
- package/packs/sidekick/tools/task-tools.ts +0 -61
- package/packs/sidekick/tools/types.ts +0 -57
- package/packs/sidekick/vitest.config.ts +0 -11
- package/packs/software-delivery/constants.ts +0 -10
- package/packs/software-delivery/extensions.ts +0 -140
- package/packs/software-delivery/gate-policies.ts +0 -134
- package/packs/software-delivery/index.ts +0 -8
- package/packs/software-delivery/manifest-schema.ts +0 -268
- package/packs/software-delivery/manifest.ts +0 -657
- package/packs/software-delivery/pack-registration.ts +0 -113
- package/packs/software-delivery/src/commands/index.ts +0 -5
- package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
- package/packs/software-delivery/src/config/env-accessors.ts +0 -66
- package/packs/software-delivery/src/config/index.ts +0 -8
- package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
- package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
- package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
- package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
- package/packs/software-delivery/src/constants/client-ids.ts +0 -19
- package/packs/software-delivery/src/constants/config-contract.ts +0 -7
- package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
- package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
- package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
- package/packs/software-delivery/src/constants/index.ts +0 -29
- package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
- package/packs/software-delivery/src/constants/object-guards.ts +0 -12
- package/packs/software-delivery/src/constants/section-headings.ts +0 -107
- package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
- package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
- package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
- package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
- package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
- package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
- package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
- package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
- package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
- package/packs/software-delivery/src/domain/index.ts +0 -5
- package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
- package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
- package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
- package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
- package/packs/software-delivery/src/methodology/index.ts +0 -6
- package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
- package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
- package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
- package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
- package/packs/software-delivery/src/policy/gates-config.ts +0 -300
- package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
- package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
- package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
- package/packs/software-delivery/src/policy/index.ts +0 -22
- package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
- package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
- package/packs/software-delivery/src/ports/config.ports.ts +0 -90
- package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
- package/packs/software-delivery/src/ports/index.ts +0 -10
- package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
- package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
- package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
- package/packs/software-delivery/src/primitives/index.ts +0 -5
- package/packs/software-delivery/src/runtime/index.ts +0 -6
- package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
- package/packs/software-delivery/src/sandbox/index.ts +0 -10
- package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
- package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
- package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
- package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
- package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
- package/packs/software-delivery/src/schemas/index.ts +0 -5
- package/packs/software-delivery/src/state/date-utils.ts +0 -158
- package/packs/software-delivery/src/state/index.ts +0 -15
- package/packs/software-delivery/src/state/state-machine.ts +0 -119
- package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
- package/packs/software-delivery/src/state/wu-paths.ts +0 -381
- package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
- package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
- package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
- package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
- package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
- package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
- package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
- package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
- package/packs/software-delivery/tool-impl/index.ts +0 -15
- package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
- package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
- package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
- package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
- package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
- package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
- package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
- package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
- package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
- package/packs/software-delivery/tools/delegation-tools.ts +0 -23
- package/packs/software-delivery/tools/git-tools.ts +0 -55
- package/packs/software-delivery/tools/index.ts +0 -8
- package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
- package/packs/software-delivery/tools/types.ts +0 -71
- package/packs/software-delivery/tools/worktree-tools.ts +0 -49
- package/packs/software-delivery/vitest.config.ts +0 -11
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
TOOL_PERMISSIONS,
|
|
6
|
-
TOOL_SCOPE_ACCESS,
|
|
7
|
-
TOOL_SCOPE_TYPES,
|
|
8
|
-
type PathScope,
|
|
9
|
-
type ToolPermission,
|
|
10
|
-
} from './tools/types.js';
|
|
11
|
-
|
|
12
|
-
interface Parser<T> {
|
|
13
|
-
parse(input: unknown): T;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const MANIFEST_POLICY_TRIGGERS = {
|
|
17
|
-
ON_TOOL_REQUEST: 'on_tool_request',
|
|
18
|
-
ON_CLAIM: 'on_claim',
|
|
19
|
-
ON_COMPLETION: 'on_completion',
|
|
20
|
-
ON_EVIDENCE_ADDED: 'on_evidence_added',
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
export type ManifestPolicyTrigger =
|
|
24
|
-
(typeof MANIFEST_POLICY_TRIGGERS)[keyof typeof MANIFEST_POLICY_TRIGGERS];
|
|
25
|
-
|
|
26
|
-
export const MANIFEST_POLICY_DECISIONS = {
|
|
27
|
-
ALLOW: 'allow',
|
|
28
|
-
DENY: 'deny',
|
|
29
|
-
} as const;
|
|
30
|
-
|
|
31
|
-
export type ManifestPolicyDecision =
|
|
32
|
-
(typeof MANIFEST_POLICY_DECISIONS)[keyof typeof MANIFEST_POLICY_DECISIONS];
|
|
33
|
-
|
|
34
|
-
export interface SoftwareDeliveryManifestTool {
|
|
35
|
-
name: string;
|
|
36
|
-
entry: string;
|
|
37
|
-
permission: ToolPermission;
|
|
38
|
-
required_scopes: PathScope[];
|
|
39
|
-
internal_only?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* WU-2729 (INIT-060 Phase 2, ADR-013 §3): approval-surface identifiers the
|
|
42
|
-
* tool must present to callers before runtime dispatch. Empty array means
|
|
43
|
-
* no approval gate; undefined means the tool does not declare approval
|
|
44
|
-
* metadata (treated the same as empty by the discovery surface).
|
|
45
|
-
*/
|
|
46
|
-
required_approvals?: string[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface SoftwareDeliveryManifestPolicy {
|
|
50
|
-
id: string;
|
|
51
|
-
trigger: ManifestPolicyTrigger;
|
|
52
|
-
decision: ManifestPolicyDecision;
|
|
53
|
-
reason?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface SoftwareDeliveryPackManifest {
|
|
57
|
-
id: string;
|
|
58
|
-
version: string;
|
|
59
|
-
config_key?: string;
|
|
60
|
-
config_schema?: string;
|
|
61
|
-
task_types: string[];
|
|
62
|
-
tools: SoftwareDeliveryManifestTool[];
|
|
63
|
-
policies: SoftwareDeliveryManifestPolicy[];
|
|
64
|
-
evidence_types: string[];
|
|
65
|
-
state_aliases: Record<string, string>;
|
|
66
|
-
lane_templates: Array<{ id: string }>;
|
|
67
|
-
/** WU-2718 (INIT-060 WU-1, ADR-013). */
|
|
68
|
-
emitted_event_kinds: string[];
|
|
69
|
-
subscribed_event_kinds: string[];
|
|
70
|
-
required_approvals: string[];
|
|
71
|
-
surfaces_required: string[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function asRecord(input: unknown, label: string): Record<string, unknown> {
|
|
75
|
-
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
76
|
-
throw new Error(`${label} must be an object.`);
|
|
77
|
-
}
|
|
78
|
-
return input as Record<string, unknown>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function parseNonEmptyString(value: unknown, label: string): string {
|
|
82
|
-
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
83
|
-
throw new Error(`${label} must be a non-empty string.`);
|
|
84
|
-
}
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function parseStringArray(value: unknown, label: string): string[] {
|
|
89
|
-
if (!Array.isArray(value)) {
|
|
90
|
-
throw new Error(`${label} must be an array.`);
|
|
91
|
-
}
|
|
92
|
-
return value.map((entry, index) => parseNonEmptyString(entry, `${label}[${index}]`));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isSemver(value: string): boolean {
|
|
96
|
-
let core = value;
|
|
97
|
-
const prereleaseIndex = core.indexOf('-');
|
|
98
|
-
if (prereleaseIndex >= 0) {
|
|
99
|
-
core = core.slice(0, prereleaseIndex);
|
|
100
|
-
}
|
|
101
|
-
const metadataIndex = core.indexOf('+');
|
|
102
|
-
if (metadataIndex >= 0) {
|
|
103
|
-
core = core.slice(0, metadataIndex);
|
|
104
|
-
}
|
|
105
|
-
const parts = core.split('.');
|
|
106
|
-
if (parts.length !== 3) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return parts.every(
|
|
110
|
-
(part) => part.length > 0 && [...part].every((char) => char >= '0' && char <= '9'),
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const ALLOWED_POLICY_TRIGGERS = new Set<string>(Object.values(MANIFEST_POLICY_TRIGGERS));
|
|
115
|
-
const ALLOWED_POLICY_DECISIONS = new Set<string>(Object.values(MANIFEST_POLICY_DECISIONS));
|
|
116
|
-
const ALLOWED_TOOL_PERMISSIONS = new Set<string>(Object.values(TOOL_PERMISSIONS));
|
|
117
|
-
|
|
118
|
-
function parsePathScope(input: unknown, label: string): PathScope {
|
|
119
|
-
const scope = asRecord(input, label);
|
|
120
|
-
const type = parseNonEmptyString(scope.type, `${label}.type`);
|
|
121
|
-
const pattern = parseNonEmptyString(scope.pattern, `${label}.pattern`);
|
|
122
|
-
const access = parseNonEmptyString(scope.access, `${label}.access`);
|
|
123
|
-
|
|
124
|
-
if (type !== TOOL_SCOPE_TYPES.PATH) {
|
|
125
|
-
throw new Error(`${label}.type must be "${TOOL_SCOPE_TYPES.PATH}".`);
|
|
126
|
-
}
|
|
127
|
-
if (access !== TOOL_SCOPE_ACCESS.READ && access !== TOOL_SCOPE_ACCESS.WRITE) {
|
|
128
|
-
throw new Error(
|
|
129
|
-
`${label}.access must be "${TOOL_SCOPE_ACCESS.READ}" or "${TOOL_SCOPE_ACCESS.WRITE}".`,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
type: TOOL_SCOPE_TYPES.PATH,
|
|
135
|
-
pattern,
|
|
136
|
-
access,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function parseRequiredScopes(value: unknown, label: string): PathScope[] {
|
|
141
|
-
if (!Array.isArray(value) || value.length === 0) {
|
|
142
|
-
throw new Error(`${label} must be a non-empty array.`);
|
|
143
|
-
}
|
|
144
|
-
return value.map((entry, index) => parsePathScope(entry, `${label}[${index}]`));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function parsePolicy(input: unknown, index: number): SoftwareDeliveryManifestPolicy {
|
|
148
|
-
const policy = asRecord(input, `policies[${index}]`);
|
|
149
|
-
const trigger = parseNonEmptyString(policy.trigger, `policies[${index}].trigger`);
|
|
150
|
-
const decision = parseNonEmptyString(policy.decision, `policies[${index}].decision`);
|
|
151
|
-
|
|
152
|
-
if (!ALLOWED_POLICY_TRIGGERS.has(trigger)) {
|
|
153
|
-
throw new Error(`policies[${index}].trigger is invalid.`);
|
|
154
|
-
}
|
|
155
|
-
if (!ALLOWED_POLICY_DECISIONS.has(decision)) {
|
|
156
|
-
throw new Error(`policies[${index}].decision is invalid.`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
id: parseNonEmptyString(policy.id, `policies[${index}].id`),
|
|
161
|
-
trigger: trigger as ManifestPolicyTrigger,
|
|
162
|
-
decision: decision as ManifestPolicyDecision,
|
|
163
|
-
reason:
|
|
164
|
-
policy.reason === undefined
|
|
165
|
-
? undefined
|
|
166
|
-
: parseNonEmptyString(policy.reason, `policies[${index}].reason`),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function parseTool(input: unknown, index: number): SoftwareDeliveryManifestTool {
|
|
171
|
-
const tool = asRecord(input, `tools[${index}]`);
|
|
172
|
-
const permission =
|
|
173
|
-
tool.permission === undefined
|
|
174
|
-
? TOOL_PERMISSIONS.READ
|
|
175
|
-
: parseNonEmptyString(tool.permission, `tools[${index}].permission`);
|
|
176
|
-
|
|
177
|
-
if (!ALLOWED_TOOL_PERMISSIONS.has(permission)) {
|
|
178
|
-
throw new Error(`tools[${index}].permission is invalid.`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// WU-2729: optional per-tool required_approvals list.
|
|
182
|
-
const parsedApprovals =
|
|
183
|
-
tool.required_approvals === undefined
|
|
184
|
-
? undefined
|
|
185
|
-
: parseStringArray(tool.required_approvals, `tools[${index}].required_approvals`);
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
name: parseNonEmptyString(tool.name, `tools[${index}].name`),
|
|
189
|
-
entry: parseNonEmptyString(tool.entry, `tools[${index}].entry`),
|
|
190
|
-
permission: permission as ToolPermission,
|
|
191
|
-
required_scopes: parseRequiredScopes(tool.required_scopes, `tools[${index}].required_scopes`),
|
|
192
|
-
internal_only:
|
|
193
|
-
tool.internal_only === undefined
|
|
194
|
-
? undefined
|
|
195
|
-
: (() => {
|
|
196
|
-
if (typeof tool.internal_only !== 'boolean') {
|
|
197
|
-
throw new Error(`tools[${index}].internal_only must be boolean.`);
|
|
198
|
-
}
|
|
199
|
-
return tool.internal_only;
|
|
200
|
-
})(),
|
|
201
|
-
...(parsedApprovals === undefined ? {} : { required_approvals: parsedApprovals }),
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function parseStateAliases(input: unknown): Record<string, string> {
|
|
206
|
-
const aliases = asRecord(input ?? {}, 'state_aliases');
|
|
207
|
-
const parsed: Record<string, string> = {};
|
|
208
|
-
for (const [key, value] of Object.entries(aliases)) {
|
|
209
|
-
parsed[parseNonEmptyString(key, 'state_aliases key')] = parseNonEmptyString(
|
|
210
|
-
value,
|
|
211
|
-
`state_aliases.${key}`,
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
return parsed;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export const SoftwareDeliveryManifestSchema: Parser<SoftwareDeliveryPackManifest> = {
|
|
218
|
-
parse(input: unknown): SoftwareDeliveryPackManifest {
|
|
219
|
-
const manifest = asRecord(input, 'manifest');
|
|
220
|
-
const version = parseNonEmptyString(manifest.version, 'version');
|
|
221
|
-
if (!isSemver(version)) {
|
|
222
|
-
throw new Error('version must be semver.');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const taskTypes = parseStringArray(manifest.task_types, 'task_types');
|
|
226
|
-
if (taskTypes.length === 0) {
|
|
227
|
-
throw new Error('task_types must include at least one item.');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const toolsValue = manifest.tools ?? [];
|
|
231
|
-
if (!Array.isArray(toolsValue)) {
|
|
232
|
-
throw new Error('tools must be an array.');
|
|
233
|
-
}
|
|
234
|
-
const policiesValue = manifest.policies ?? [];
|
|
235
|
-
if (!Array.isArray(policiesValue)) {
|
|
236
|
-
throw new Error('policies must be an array.');
|
|
237
|
-
}
|
|
238
|
-
const laneTemplatesValue = manifest.lane_templates ?? [];
|
|
239
|
-
if (!Array.isArray(laneTemplatesValue)) {
|
|
240
|
-
throw new Error('lane_templates must be an array.');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
id: parseNonEmptyString(manifest.id, 'id'),
|
|
245
|
-
version,
|
|
246
|
-
task_types: taskTypes,
|
|
247
|
-
tools: toolsValue.map((tool, index) => parseTool(tool, index)),
|
|
248
|
-
policies: policiesValue.map((policy, index) => parsePolicy(policy, index)),
|
|
249
|
-
evidence_types: parseStringArray(manifest.evidence_types ?? [], 'evidence_types'),
|
|
250
|
-
state_aliases: parseStateAliases(manifest.state_aliases),
|
|
251
|
-
lane_templates: laneTemplatesValue.map((laneTemplate, index) => {
|
|
252
|
-
const entry = asRecord(laneTemplate, `lane_templates[${index}]`);
|
|
253
|
-
return { id: parseNonEmptyString(entry.id, `lane_templates[${index}].id`) };
|
|
254
|
-
}),
|
|
255
|
-
// WU-2718 (INIT-060 WU-1, ADR-013): manifest extension fields.
|
|
256
|
-
emitted_event_kinds: parseStringArray(
|
|
257
|
-
manifest.emitted_event_kinds ?? [],
|
|
258
|
-
'emitted_event_kinds',
|
|
259
|
-
),
|
|
260
|
-
subscribed_event_kinds: parseStringArray(
|
|
261
|
-
manifest.subscribed_event_kinds ?? [],
|
|
262
|
-
'subscribed_event_kinds',
|
|
263
|
-
),
|
|
264
|
-
required_approvals: parseStringArray(manifest.required_approvals ?? [], 'required_approvals'),
|
|
265
|
-
surfaces_required: parseStringArray(manifest.surfaces_required ?? [], 'surfaces_required'),
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
};
|