@lumenflow/cli 5.5.0 → 5.7.12
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 +42 -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/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 +255 -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/lumenflow-setup.js +144 -0
- package/dist/lumenflow-setup.js.map +1 -0
- package/dist/lumenflow-upgrade.js +2 -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 -0
- 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-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 +41 -7
- 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 -11
- 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 +197 -47
- 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,104 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
import type { PackCapabilityFactory } from '@lumenflow/kernel';
|
|
5
|
-
import { AGENT_RUNTIME_TOOL_NAMES } from './types.js';
|
|
6
|
-
import type { AgentRuntimeModelProfileConfig, AgentRuntimePackConfig } from './types.js';
|
|
7
|
-
|
|
8
|
-
export const createAgentRuntimeCapabilityFactory: PackCapabilityFactory = async (input) => {
|
|
9
|
-
if (input.tool.name !== AGENT_RUNTIME_TOOL_NAMES.EXECUTE_TURN) {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const packConfig = normalizePackConfig(input.packConfig);
|
|
14
|
-
if (!packConfig) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const requiredEnv = new Set<string>();
|
|
19
|
-
const providerHosts = new Set<string>();
|
|
20
|
-
|
|
21
|
-
for (const [profileName, profile] of Object.entries(packConfig.models)) {
|
|
22
|
-
requiredEnv.add(profile.api_key_env);
|
|
23
|
-
if (profile.base_url_env) {
|
|
24
|
-
requiredEnv.add(profile.base_url_env);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const resolvedBaseUrl = resolveProfileBaseUrl(profileName, profile);
|
|
28
|
-
if (!resolvedBaseUrl) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
providerHosts.add(toNetworkAllowlistEntry(profileName, resolvedBaseUrl));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...(requiredEnv.size > 0 ? { required_env: [...requiredEnv].sort() } : {}),
|
|
36
|
-
...(providerHosts.size > 0
|
|
37
|
-
? {
|
|
38
|
-
required_scopes: [
|
|
39
|
-
{
|
|
40
|
-
type: 'network' as const,
|
|
41
|
-
posture: 'allowlist' as const,
|
|
42
|
-
allowlist_entries: [...providerHosts].sort(),
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}
|
|
46
|
-
: {}),
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function normalizePackConfig(value: unknown): AgentRuntimePackConfig | null {
|
|
51
|
-
if (!isRecord(value) || !isRecord(value.models)) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return value as unknown as AgentRuntimePackConfig;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function resolveProfileBaseUrl(
|
|
59
|
-
profileName: string,
|
|
60
|
-
profile: AgentRuntimeModelProfileConfig,
|
|
61
|
-
): string | null {
|
|
62
|
-
if (typeof profile.base_url === 'string' && profile.base_url.trim().length > 0) {
|
|
63
|
-
return profile.base_url.trim();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!profile.base_url_env) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const environmentValue = process.env[profile.base_url_env];
|
|
71
|
-
if (typeof environmentValue !== 'string' || environmentValue.trim().length === 0) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`agent_runtime.models.${profileName}.base_url_env references "${profile.base_url_env}" but it is not set.`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return environmentValue.trim();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function toNetworkAllowlistEntry(profileName: string, baseUrl: string): string {
|
|
81
|
-
let parsed: URL;
|
|
82
|
-
try {
|
|
83
|
-
parsed = new URL(baseUrl);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
throw new Error(
|
|
86
|
-
`agent_runtime.models.${profileName} must resolve to a valid absolute base URL, got "${baseUrl}".`,
|
|
87
|
-
{ cause: error },
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const port =
|
|
92
|
-
parsed.port || (parsed.protocol === 'https:' ? '443' : parsed.protocol === 'http:' ? '80' : '');
|
|
93
|
-
if (!port) {
|
|
94
|
-
throw new Error(
|
|
95
|
-
`agent_runtime.models.${profileName} uses protocol "${parsed.protocol}" without an explicit port.`,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return `${parsed.hostname}:${port}`;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
103
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
104
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
export const AGENT_RUNTIME_PACK_ID = 'agent-runtime' as const;
|
|
5
|
-
export const AGENT_RUNTIME_PACK_VERSION = '0.1.0' as const;
|
|
6
|
-
export const AGENT_RUNTIME_DOMAIN = AGENT_RUNTIME_PACK_ID;
|
|
7
|
-
export const AGENT_RUNTIME_CONFIG_KEY = 'agent_runtime' as const;
|
|
8
|
-
export const AGENT_RUNTIME_POLICY_ID_PREFIX = `${AGENT_RUNTIME_PACK_ID}.policy` as const;
|
|
9
|
-
export const AGENT_RUNTIME_MANIFEST_FILE_NAME = 'manifest.yaml' as const;
|
|
10
|
-
export const AGENT_RUNTIME_CONFIG_SCHEMA_FILE = 'config.schema.json' as const;
|
|
11
|
-
export const SHA256_ALGORITHM = 'sha256' as const;
|
|
12
|
-
export const UTF8_ENCODING = 'utf8' as const;
|
|
13
|
-
export const AGENT_RUNTIME_STORAGE_PATTERN = '.agent-runtime/**' as const;
|
|
14
|
-
export const AGENT_RUNTIME_API_KEY_ENV = 'AGENT_RUNTIME_API_KEY' as const;
|
|
15
|
-
export const AGENT_RUNTIME_BASE_URL_ENV = 'AGENT_RUNTIME_BASE_URL' as const;
|
|
16
|
-
export const AGENT_RUNTIME_STATIC_PROVIDER_ALLOWLIST = ['model-provider.invalid:443'] as const;
|
|
17
|
-
export const AGENT_RUNTIME_STATIC_PROVIDER_URLS = ['https://model-provider.invalid/'] as const;
|
|
18
|
-
export const AGENT_RUNTIME_AGENT_INTENT_METADATA_KEY = 'agent_intent' as const;
|
|
19
|
-
export const AGENT_RUNTIME_AGENT_TURN_INDEX_METADATA_KEY = 'agent_turn_index' as const;
|
|
20
|
-
export const AGENT_RUNTIME_AGENT_TOOL_CALL_COUNT_METADATA_KEY = 'agent_tool_call_count' as const;
|
|
21
|
-
export const AGENT_RUNTIME_AGENT_WORKFLOW_NODE_ID_METADATA_KEY = 'agent_workflow_node_id' as const;
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Delegation Registry Schema (ADR-014 follow-up, WU-2763)
|
|
6
|
-
*
|
|
7
|
-
* Canonical delegation schema and helpers for agent-runtime coordination
|
|
8
|
-
* records. Core now re-exports this module as a compatibility shim.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import crypto from 'node:crypto';
|
|
12
|
-
import { z } from 'zod';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Delegation status values.
|
|
16
|
-
*/
|
|
17
|
-
const DELEGATION_STATUS_COMPLETED = 'completed';
|
|
18
|
-
|
|
19
|
-
export const DelegationStatus = {
|
|
20
|
-
PENDING: 'pending',
|
|
21
|
-
COMPLETED: DELEGATION_STATUS_COMPLETED,
|
|
22
|
-
TIMEOUT: 'timeout',
|
|
23
|
-
CRASHED: 'crashed',
|
|
24
|
-
ESCALATED: 'escalated',
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
/** Type for delegation status values */
|
|
28
|
-
export type DelegationStatusValue = (typeof DelegationStatus)[keyof typeof DelegationStatus];
|
|
29
|
-
|
|
30
|
-
/** Array of valid delegation statuses */
|
|
31
|
-
export const DELEGATION_STATUSES = [
|
|
32
|
-
DelegationStatus.PENDING,
|
|
33
|
-
DelegationStatus.COMPLETED,
|
|
34
|
-
DelegationStatus.TIMEOUT,
|
|
35
|
-
DelegationStatus.CRASHED,
|
|
36
|
-
DelegationStatus.ESCALATED,
|
|
37
|
-
] as const;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Optional delegation intent source values.
|
|
41
|
-
*/
|
|
42
|
-
export const DelegationIntent = {
|
|
43
|
-
DELEGATION: 'delegation',
|
|
44
|
-
LEGACY_SPAWN: 'legacy-spawn',
|
|
45
|
-
} as const;
|
|
46
|
-
|
|
47
|
-
/** Type for delegation intent values */
|
|
48
|
-
export type DelegationIntentValue = (typeof DelegationIntent)[keyof typeof DelegationIntent];
|
|
49
|
-
|
|
50
|
-
/** Array of valid delegation intent values */
|
|
51
|
-
export const DELEGATION_INTENTS = [
|
|
52
|
-
DelegationIntent.DELEGATION,
|
|
53
|
-
DelegationIntent.LEGACY_SPAWN,
|
|
54
|
-
] as const;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Regex patterns for delegation validation.
|
|
58
|
-
*/
|
|
59
|
-
export const DELEGATION_PATTERNS = {
|
|
60
|
-
DELEGATION_ID: /^dlg-[0-9a-f]{4}$/,
|
|
61
|
-
WU_ID: /^WU-\d+$/,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Delegation schema version discriminator (WU-2753, ADR-014 extension 1).
|
|
66
|
-
*
|
|
67
|
-
* v1 records have no `schemaVersion` field (legacy compat path).
|
|
68
|
-
* v2 records stamp `schemaVersion: 'v2'` and MUST carry the four ADR-014
|
|
69
|
-
* axes: requested_role, actual_role, capabilities, ownership_scope.
|
|
70
|
-
*
|
|
71
|
-
* Agent-runtime owns the role metadata contract as opaque strings. The
|
|
72
|
-
* software-delivery pack still owns the canonical vocabulary.
|
|
73
|
-
*/
|
|
74
|
-
export const DELEGATION_SCHEMA_VERSION_V2 = 'v2' as const;
|
|
75
|
-
|
|
76
|
-
/** Known delegation schema versions (extensible by additive pack updates). */
|
|
77
|
-
export const DELEGATION_SCHEMA_VERSIONS = [DELEGATION_SCHEMA_VERSION_V2] as const;
|
|
78
|
-
|
|
79
|
-
/** Type union for delegation schema version values. */
|
|
80
|
-
export type DelegationSchemaVersion = (typeof DELEGATION_SCHEMA_VERSIONS)[number];
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Error messages for schema validation.
|
|
84
|
-
*/
|
|
85
|
-
const ERROR_MESSAGES = {
|
|
86
|
-
DELEGATION_ID: 'Delegation ID must match pattern dlg-XXXX (e.g., dlg-a1b2)',
|
|
87
|
-
WU_ID: 'WU ID must match pattern WU-XXX (e.g., WU-1000)',
|
|
88
|
-
LANE_REQUIRED: 'Lane is required',
|
|
89
|
-
STATUS: `Status must be one of: ${DELEGATION_STATUSES.join(', ')}`,
|
|
90
|
-
INTENT: `Intent must be one of: ${DELEGATION_INTENTS.join(', ')}`,
|
|
91
|
-
TIMESTAMP_REQUIRED: 'Timestamp is required',
|
|
92
|
-
PICKUP_BY_REQUIRED: 'pickedUpBy must be a non-empty string when pickup is recorded',
|
|
93
|
-
BRIEF_HASH: 'briefAttestation.promptHash must be a 64-character lowercase sha256 hex digest',
|
|
94
|
-
BRIEF_ALGORITHM: 'briefAttestation.algorithm must be sha256',
|
|
95
|
-
BRIEF_CLIENT_REQUIRED: 'briefAttestation.clientName must be a non-empty string',
|
|
96
|
-
} as const;
|
|
97
|
-
|
|
98
|
-
const SHA256_HEX_256_REGEX = /^[a-f0-9]{64}$/;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Optional wu:brief prompt attestation captured by wu:delegate.
|
|
102
|
-
*/
|
|
103
|
-
export const DelegationBriefAttestationSchema = z.object({
|
|
104
|
-
algorithm: z.literal('sha256', { error: ERROR_MESSAGES.BRIEF_ALGORITHM }),
|
|
105
|
-
promptHash: z.string().regex(SHA256_HEX_256_REGEX, { message: ERROR_MESSAGES.BRIEF_HASH }),
|
|
106
|
-
promptLength: z.number().int().nonnegative(),
|
|
107
|
-
generatedAt: z.string().datetime({ message: ERROR_MESSAGES.TIMESTAMP_REQUIRED }),
|
|
108
|
-
clientName: z.string().min(1, { message: ERROR_MESSAGES.BRIEF_CLIENT_REQUIRED }),
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* ADR-014 role descriptor — agent-runtime carries opaque strings; the
|
|
113
|
-
* software-delivery pack owns the AgentLifecycleRole vocabulary.
|
|
114
|
-
*/
|
|
115
|
-
export const DelegationRoleDescriptorSchema = z.object({
|
|
116
|
-
lifecycle_role: z.string().min(1, { message: 'lifecycle_role must be non-empty' }),
|
|
117
|
-
specialty_profile: z.string().min(1, { message: 'specialty_profile must be non-empty' }),
|
|
118
|
-
role_alias: z.string().min(1).optional(),
|
|
119
|
-
capabilities: z.array(z.string()),
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* ADR-014 ownership scope for agent coordination.
|
|
124
|
-
*/
|
|
125
|
-
export const DelegationOwnershipScopeSchema = z.object({
|
|
126
|
-
initiative_id: z.string().min(1).optional(),
|
|
127
|
-
wu_ids: z.array(z.string().min(1)).optional(),
|
|
128
|
-
lane: z.string().min(1).optional(),
|
|
129
|
-
responsibility_kinds: z.array(z.string().min(1)),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Delegation event base schema (shared by v1-compat and v2).
|
|
134
|
-
*/
|
|
135
|
-
const DelegationEventBaseSchema = z.object({
|
|
136
|
-
id: z.string().regex(DELEGATION_PATTERNS.DELEGATION_ID, {
|
|
137
|
-
message: ERROR_MESSAGES.DELEGATION_ID,
|
|
138
|
-
}),
|
|
139
|
-
parentWuId: z.string().regex(DELEGATION_PATTERNS.WU_ID, { message: ERROR_MESSAGES.WU_ID }),
|
|
140
|
-
targetWuId: z.string().regex(DELEGATION_PATTERNS.WU_ID, { message: ERROR_MESSAGES.WU_ID }),
|
|
141
|
-
lane: z.string().min(1, { message: ERROR_MESSAGES.LANE_REQUIRED }),
|
|
142
|
-
intent: z.enum(DELEGATION_INTENTS, { error: ERROR_MESSAGES.INTENT }).optional(),
|
|
143
|
-
delegatedAt: z.string().datetime({ message: ERROR_MESSAGES.TIMESTAMP_REQUIRED }),
|
|
144
|
-
status: z.enum(DELEGATION_STATUSES, { error: ERROR_MESSAGES.STATUS }),
|
|
145
|
-
completedAt: z.string().datetime().nullable(),
|
|
146
|
-
pickedUpAt: z.string().datetime().optional(),
|
|
147
|
-
pickedUpBy: z.string().min(1, { message: ERROR_MESSAGES.PICKUP_BY_REQUIRED }).optional(),
|
|
148
|
-
briefAttestation: DelegationBriefAttestationSchema.optional(),
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Legacy v1-compat delegation event schema.
|
|
153
|
-
*/
|
|
154
|
-
const DelegationEventV1Schema = DelegationEventBaseSchema.extend({
|
|
155
|
-
schemaVersion: z.undefined().optional(),
|
|
156
|
-
requested_role: DelegationRoleDescriptorSchema.optional(),
|
|
157
|
-
actual_role: DelegationRoleDescriptorSchema.optional(),
|
|
158
|
-
capabilities: z.array(z.string()).optional(),
|
|
159
|
-
ownership_scope: DelegationOwnershipScopeSchema.optional(),
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* v2 delegation event schema (WU-2753, ADR-014 extension 1).
|
|
164
|
-
*/
|
|
165
|
-
const DelegationEventV2Schema = DelegationEventBaseSchema.extend({
|
|
166
|
-
schemaVersion: z.literal(DELEGATION_SCHEMA_VERSION_V2),
|
|
167
|
-
requested_role: DelegationRoleDescriptorSchema,
|
|
168
|
-
actual_role: DelegationRoleDescriptorSchema,
|
|
169
|
-
capabilities: z.array(z.string()),
|
|
170
|
-
ownership_scope: DelegationOwnershipScopeSchema,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Delegation event schema — discriminated union across v1-compat and v2.
|
|
175
|
-
*/
|
|
176
|
-
export const DelegationEventSchema = z.union([DelegationEventV2Schema, DelegationEventV1Schema]);
|
|
177
|
-
|
|
178
|
-
/** TypeScript type inferred from schema */
|
|
179
|
-
export type DelegationEvent = z.infer<typeof DelegationEventSchema>;
|
|
180
|
-
export type DelegationEventV1 = z.infer<typeof DelegationEventV1Schema>;
|
|
181
|
-
export type DelegationEventV2 = z.infer<typeof DelegationEventV2Schema>;
|
|
182
|
-
export type DelegationBriefAttestation = z.infer<typeof DelegationBriefAttestationSchema>;
|
|
183
|
-
export type DelegationRoleDescriptor = z.infer<typeof DelegationRoleDescriptorSchema>;
|
|
184
|
-
export type DelegationOwnershipScope = z.infer<typeof DelegationOwnershipScopeSchema>;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Bundle of the four ADR-014 axes that launch receipts and wu:delegate emit
|
|
188
|
-
* on every new delegation (WU-2753).
|
|
189
|
-
*/
|
|
190
|
-
export interface DelegationRoleContract {
|
|
191
|
-
requested_role: DelegationRoleDescriptor;
|
|
192
|
-
actual_role: DelegationRoleDescriptor;
|
|
193
|
-
capabilities: string[];
|
|
194
|
-
ownership_scope: DelegationOwnershipScope;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Validates delegation event data against schema.
|
|
199
|
-
*/
|
|
200
|
-
export function validateDelegationEvent(data: unknown) {
|
|
201
|
-
return DelegationEventSchema.safeParse(data);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Returns true if the delegation event carries the v2 role contract.
|
|
206
|
-
*/
|
|
207
|
-
export function isV2DelegationEvent(event: DelegationEvent): event is DelegationEventV2 {
|
|
208
|
-
return event.schemaVersion === DELEGATION_SCHEMA_VERSION_V2;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Generates a unique delegation ID.
|
|
213
|
-
*/
|
|
214
|
-
export function generateDelegationId(parentWuId: string, targetWuId: string): string {
|
|
215
|
-
const timestamp = Date.now().toString();
|
|
216
|
-
const randomBytes = crypto.randomBytes(4).toString('hex');
|
|
217
|
-
const input = `${parentWuId}:${targetWuId}:${timestamp}:${randomBytes}`;
|
|
218
|
-
const hash = crypto.createHash('sha256').update(input).digest('hex');
|
|
219
|
-
return `dlg-${hash.slice(0, 4)}`;
|
|
220
|
-
}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Delegation Registry Store (ADR-014 follow-up, WU-2763)
|
|
6
|
-
*
|
|
7
|
-
* Event-sourced state store for tracking sub-agent delegations.
|
|
8
|
-
* Stores events in .lumenflow/state/delegation-registry.jsonl (append-only, git-friendly).
|
|
9
|
-
*
|
|
10
|
-
* Core now re-exports this module as a compatibility shim.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import fs from 'node:fs/promises';
|
|
14
|
-
import path from 'node:path';
|
|
15
|
-
import { createError, ErrorCodes } from '@lumenflow/kernel/primitives/error-handler';
|
|
16
|
-
import {
|
|
17
|
-
validateDelegationEvent,
|
|
18
|
-
generateDelegationId,
|
|
19
|
-
DelegationStatus,
|
|
20
|
-
DELEGATION_SCHEMA_VERSION_V2,
|
|
21
|
-
type DelegationEvent,
|
|
22
|
-
type DelegationBriefAttestation,
|
|
23
|
-
type DelegationIntentValue,
|
|
24
|
-
type DelegationRoleContract,
|
|
25
|
-
} from './delegation-registry-schema.js';
|
|
26
|
-
|
|
27
|
-
interface ValidationIssueLike {
|
|
28
|
-
path: PropertyKey[];
|
|
29
|
-
message: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Delegation registry file name constant */
|
|
33
|
-
export const DELEGATION_REGISTRY_FILE_NAME = 'delegation-registry.jsonl';
|
|
34
|
-
|
|
35
|
-
function formatValidationIssues(issues: readonly ValidationIssueLike[]): string {
|
|
36
|
-
return issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join(', ');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Delegation Registry Store class
|
|
41
|
-
*/
|
|
42
|
-
export class DelegationRegistryStore {
|
|
43
|
-
private readonly baseDir: string;
|
|
44
|
-
private readonly registryFilePath: string;
|
|
45
|
-
private readonly delegations: Map<string, DelegationEvent>;
|
|
46
|
-
private readonly byParent: Map<string, string[]>;
|
|
47
|
-
private readonly byTarget: Map<string, string>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param {string} baseDir - Directory containing .lumenflow/state/
|
|
51
|
-
*/
|
|
52
|
-
constructor(baseDir: string) {
|
|
53
|
-
this.baseDir = baseDir;
|
|
54
|
-
this.registryFilePath = path.join(baseDir, DELEGATION_REGISTRY_FILE_NAME);
|
|
55
|
-
this.delegations = new Map();
|
|
56
|
-
this.byParent = new Map();
|
|
57
|
-
this.byTarget = new Map();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Loads and replays events from JSONL file into current state.
|
|
62
|
-
*/
|
|
63
|
-
async load(): Promise<void> {
|
|
64
|
-
this.delegations.clear();
|
|
65
|
-
this.byParent.clear();
|
|
66
|
-
this.byTarget.clear();
|
|
67
|
-
|
|
68
|
-
let content: string;
|
|
69
|
-
try {
|
|
70
|
-
content = await fs.readFile(this.registryFilePath, 'utf-8');
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const lines = content.split('\n');
|
|
79
|
-
for (let i = 0; i < lines.length; i++) {
|
|
80
|
-
const rawLine = lines[i];
|
|
81
|
-
if (typeof rawLine !== 'string') {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const line = rawLine.trim();
|
|
85
|
-
if (!line) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let parsed;
|
|
90
|
-
try {
|
|
91
|
-
parsed = JSON.parse(line);
|
|
92
|
-
} catch (error) {
|
|
93
|
-
throw createError(
|
|
94
|
-
ErrorCodes.PARSE_ERROR,
|
|
95
|
-
`Malformed JSON on line ${i + 1}: ${error.message}`,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const validation = validateDelegationEvent(parsed);
|
|
100
|
-
if (!validation.success) {
|
|
101
|
-
throw createError(
|
|
102
|
-
ErrorCodes.VALIDATION_ERROR,
|
|
103
|
-
`Validation error on line ${i + 1}: ${formatValidationIssues(validation.error.issues)}`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.applyEvent(validation.data);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Applies an event to the in-memory state.
|
|
113
|
-
*/
|
|
114
|
-
private applyEvent(event: DelegationEvent): void {
|
|
115
|
-
const { id, parentWuId, targetWuId } = event;
|
|
116
|
-
this.delegations.set(id, event);
|
|
117
|
-
|
|
118
|
-
if (!this.byParent.has(parentWuId)) {
|
|
119
|
-
this.byParent.set(parentWuId, []);
|
|
120
|
-
}
|
|
121
|
-
const parentDelegations = this.byParent.get(parentWuId);
|
|
122
|
-
if (!parentDelegations) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (!parentDelegations.includes(id)) {
|
|
126
|
-
parentDelegations.push(id);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
this.byTarget.set(targetWuId, id);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Appends an event to the registry file.
|
|
134
|
-
*/
|
|
135
|
-
private async appendEvent(event: DelegationEvent): Promise<void> {
|
|
136
|
-
const validation = validateDelegationEvent(event);
|
|
137
|
-
if (!validation.success) {
|
|
138
|
-
throw createError(
|
|
139
|
-
ErrorCodes.VALIDATION_ERROR,
|
|
140
|
-
`Validation error: ${formatValidationIssues(validation.error.issues)}`,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
await fs.mkdir(this.baseDir, { recursive: true });
|
|
145
|
-
await fs.appendFile(this.registryFilePath, JSON.stringify(event) + '\n', 'utf-8');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Records a new delegation event with pending status.
|
|
150
|
-
*/
|
|
151
|
-
async record(
|
|
152
|
-
parentWuId: string,
|
|
153
|
-
targetWuId: string,
|
|
154
|
-
lane: string,
|
|
155
|
-
intent?: DelegationIntentValue,
|
|
156
|
-
briefAttestation?: DelegationBriefAttestation,
|
|
157
|
-
delegationId?: string,
|
|
158
|
-
roleContract?: DelegationRoleContract,
|
|
159
|
-
): Promise<string> {
|
|
160
|
-
const id = delegationId ?? generateDelegationId(parentWuId, targetWuId);
|
|
161
|
-
|
|
162
|
-
const event: DelegationEvent = {
|
|
163
|
-
id,
|
|
164
|
-
parentWuId,
|
|
165
|
-
targetWuId,
|
|
166
|
-
lane,
|
|
167
|
-
...(intent ? { intent } : {}),
|
|
168
|
-
delegatedAt: new Date().toISOString(),
|
|
169
|
-
status: DelegationStatus.PENDING,
|
|
170
|
-
completedAt: null,
|
|
171
|
-
...(briefAttestation ? { briefAttestation } : {}),
|
|
172
|
-
...(roleContract
|
|
173
|
-
? {
|
|
174
|
-
schemaVersion: DELEGATION_SCHEMA_VERSION_V2,
|
|
175
|
-
requested_role: roleContract.requested_role,
|
|
176
|
-
actual_role: roleContract.actual_role,
|
|
177
|
-
capabilities: roleContract.capabilities,
|
|
178
|
-
ownership_scope: roleContract.ownership_scope,
|
|
179
|
-
}
|
|
180
|
-
: {}),
|
|
181
|
-
} as DelegationEvent;
|
|
182
|
-
|
|
183
|
-
await this.appendEvent(event);
|
|
184
|
-
this.applyEvent(event);
|
|
185
|
-
return id;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Updates the status of a delegation.
|
|
190
|
-
*/
|
|
191
|
-
async updateStatus(delegationId: string, status: string): Promise<void> {
|
|
192
|
-
const existing = this.delegations.get(delegationId);
|
|
193
|
-
if (!existing) {
|
|
194
|
-
throw createError(ErrorCodes.DELEGATION_NOT_FOUND, `Delegation ID ${delegationId} not found`);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const event: DelegationEvent = {
|
|
198
|
-
...existing,
|
|
199
|
-
status: status as DelegationEvent['status'],
|
|
200
|
-
completedAt: new Date().toISOString(),
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
await this.appendEvent(event);
|
|
204
|
-
this.applyEvent(event);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Records claim-time pickup evidence for a delegation entry.
|
|
209
|
-
*/
|
|
210
|
-
async recordPickup(delegationId: string, pickedUpBy: string, pickedUpAt?: string): Promise<void> {
|
|
211
|
-
const existing = this.delegations.get(delegationId);
|
|
212
|
-
if (!existing) {
|
|
213
|
-
throw createError(ErrorCodes.DELEGATION_NOT_FOUND, `Delegation ID ${delegationId} not found`);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const event: DelegationEvent = {
|
|
217
|
-
...existing,
|
|
218
|
-
pickedUpBy,
|
|
219
|
-
pickedUpAt: pickedUpAt ?? new Date().toISOString(),
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
await this.appendEvent(event);
|
|
223
|
-
this.applyEvent(event);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Gets all delegations for a parent WU.
|
|
228
|
-
*/
|
|
229
|
-
getByParent(parentWuId: string): DelegationEvent[] {
|
|
230
|
-
const delegationIds = this.byParent.get(parentWuId) ?? [];
|
|
231
|
-
return delegationIds
|
|
232
|
-
.map((id) => this.delegations.get(id))
|
|
233
|
-
.filter((event): event is DelegationEvent => event !== undefined);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Gets delegation for a target WU.
|
|
238
|
-
*/
|
|
239
|
-
getByTarget(targetWuId: string): DelegationEvent | null {
|
|
240
|
-
const delegationId = this.byTarget.get(targetWuId);
|
|
241
|
-
if (!delegationId) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
return this.delegations.get(delegationId) ?? null;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Gets all pending delegations.
|
|
249
|
-
*/
|
|
250
|
-
getPendingDelegations(): DelegationEvent[] {
|
|
251
|
-
return Array.from(this.delegations.values()).filter(
|
|
252
|
-
(delegation) => delegation.status === DelegationStatus.PENDING,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Gets all delegations as an array.
|
|
258
|
-
*/
|
|
259
|
-
getAllDelegations(): DelegationEvent[] {
|
|
260
|
-
return Array.from(this.delegations.values());
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Gets delegation by ID.
|
|
265
|
-
*/
|
|
266
|
-
getById(delegationId: string): DelegationEvent | null {
|
|
267
|
-
return this.delegations.get(delegationId) ?? null;
|
|
268
|
-
}
|
|
269
|
-
}
|