@lumenflow/cli 3.17.7 → 3.18.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 (46) hide show
  1. package/dist/init-detection.js +5 -3
  2. package/dist/init-detection.js.map +1 -1
  3. package/dist/init-templates.js +4 -4
  4. package/dist/init-templates.js.map +1 -1
  5. package/dist/initiative-plan.js +1 -1
  6. package/dist/initiative-plan.js.map +1 -1
  7. package/dist/pre-commit-check.js +1 -1
  8. package/dist/pre-commit-check.js.map +1 -1
  9. package/dist/wu-edit-operations.js +4 -0
  10. package/dist/wu-edit-operations.js.map +1 -1
  11. package/dist/wu-edit-validators.js +4 -0
  12. package/dist/wu-edit-validators.js.map +1 -1
  13. package/dist/wu-edit.js +11 -0
  14. package/dist/wu-edit.js.map +1 -1
  15. package/dist/wu-spawn-strategy-resolver.js +13 -1
  16. package/dist/wu-spawn-strategy-resolver.js.map +1 -1
  17. package/package.json +8 -8
  18. package/packs/agent-runtime/.turbo/turbo-build.log +4 -0
  19. package/packs/agent-runtime/README.md +147 -0
  20. package/packs/agent-runtime/capability-factory.ts +104 -0
  21. package/packs/agent-runtime/config.schema.json +87 -0
  22. package/packs/agent-runtime/constants.ts +21 -0
  23. package/packs/agent-runtime/index.ts +11 -0
  24. package/packs/agent-runtime/manifest.ts +207 -0
  25. package/packs/agent-runtime/manifest.yaml +193 -0
  26. package/packs/agent-runtime/orchestration.ts +1787 -0
  27. package/packs/agent-runtime/pack-registration.ts +110 -0
  28. package/packs/agent-runtime/package.json +57 -0
  29. package/packs/agent-runtime/policy-factory.ts +165 -0
  30. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +793 -0
  31. package/packs/agent-runtime/tool-impl/index.ts +5 -0
  32. package/packs/agent-runtime/tool-impl/provider-adapters.ts +1245 -0
  33. package/packs/agent-runtime/tools/index.ts +4 -0
  34. package/packs/agent-runtime/tools/types.ts +47 -0
  35. package/packs/agent-runtime/tsconfig.json +20 -0
  36. package/packs/agent-runtime/types.ts +128 -0
  37. package/packs/agent-runtime/vitest.config.ts +11 -0
  38. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  39. package/packs/sidekick/package.json +1 -1
  40. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  41. package/packs/software-delivery/package.json +1 -1
  42. package/templates/core/.lumenflow/rules/wu-workflow.md.template +1 -1
  43. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +2 -2
  44. package/templates/core/ai/onboarding/quick-ref-commands.md.template +1 -1
  45. package/templates/core/ai/onboarding/starting-prompt.md.template +1 -1
  46. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
@@ -0,0 +1,110 @@
1
+ // Copyright (c) 2026 Hellmai Ltd
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+
4
+ import { createHash } from 'node:crypto';
5
+ import { readdir, readFile } from 'node:fs/promises';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { AGENT_RUNTIME_MANIFEST } from './manifest.js';
9
+ import { AGENT_RUNTIME_MANIFEST_FILE_NAME, SHA256_ALGORITHM, UTF8_ENCODING } from './constants.js';
10
+ import type { AgentRuntimePackManifest } from './manifest.js';
11
+
12
+ const NULL_BYTE_BUFFER = Buffer.from([0]);
13
+ const DEFAULT_EXCLUSIONS = ['node_modules/', '.git/', 'dist/', '.DS_Store'] as const;
14
+
15
+ function getDefaultPackRoot(): string {
16
+ return path.dirname(fileURLToPath(import.meta.url));
17
+ }
18
+
19
+ function normalizeRelativePath(root: string, absolutePath: string): string {
20
+ return path.relative(root, absolutePath).split(path.sep).join('/');
21
+ }
22
+
23
+ function shouldExclude(relativePath: string, exclusions: readonly string[]): boolean {
24
+ return exclusions.some((excluded) => {
25
+ if (excluded.endsWith('/')) {
26
+ return relativePath.startsWith(excluded);
27
+ }
28
+ return relativePath === excluded || relativePath.endsWith(`/${excluded}`);
29
+ });
30
+ }
31
+
32
+ async function collectFilesRecursive(root: string, directory: string): Promise<string[]> {
33
+ const entries = await readdir(directory, { withFileTypes: true });
34
+ const sortedEntries = [...entries].sort((left, right) => left.name.localeCompare(right.name));
35
+ const files: string[] = [];
36
+
37
+ for (const entry of sortedEntries) {
38
+ const absolutePath = path.join(directory, entry.name);
39
+ const relativePath = normalizeRelativePath(root, absolutePath);
40
+ if (entry.isDirectory()) {
41
+ files.push(...(await collectFilesRecursive(root, absolutePath)));
42
+ continue;
43
+ }
44
+ files.push(relativePath);
45
+ }
46
+
47
+ return files;
48
+ }
49
+
50
+ async function listPackFiles(packRoot: string, exclusions: readonly string[]): Promise<string[]> {
51
+ const absoluteRoot = path.resolve(packRoot);
52
+ const allFiles = await collectFilesRecursive(absoluteRoot, absoluteRoot);
53
+ return allFiles.filter((relativePath) => !shouldExclude(relativePath, exclusions)).sort();
54
+ }
55
+
56
+ export async function computeAgentRuntimePackIntegrity(
57
+ packRoot = getDefaultPackRoot(),
58
+ exclusions: readonly string[] = DEFAULT_EXCLUSIONS,
59
+ ): Promise<`sha256:${string}`> {
60
+ const absoluteRoot = path.resolve(packRoot);
61
+ const files = await listPackFiles(absoluteRoot, exclusions);
62
+ const digestChunks: Buffer[] = [];
63
+
64
+ for (const relativePath of files) {
65
+ const fileContents = await readFile(path.join(absoluteRoot, relativePath));
66
+ const fileHash = createHash(SHA256_ALGORITHM).update(fileContents).digest('hex');
67
+ digestChunks.push(Buffer.from(relativePath, UTF8_ENCODING));
68
+ digestChunks.push(NULL_BYTE_BUFFER);
69
+ digestChunks.push(Buffer.from(fileHash, UTF8_ENCODING));
70
+ digestChunks.push(NULL_BYTE_BUFFER);
71
+ }
72
+
73
+ const combinedDigest = createHash(SHA256_ALGORITHM)
74
+ .update(digestChunks.length === 0 ? Buffer.alloc(0) : Buffer.concat(digestChunks))
75
+ .digest('hex');
76
+
77
+ return `sha256:${combinedDigest}`;
78
+ }
79
+
80
+ export async function loadAgentRuntimeManifest(
81
+ packRoot = getDefaultPackRoot(),
82
+ ): Promise<AgentRuntimePackManifest> {
83
+ const manifestPath = path.join(path.resolve(packRoot), AGENT_RUNTIME_MANIFEST_FILE_NAME);
84
+ await readFile(manifestPath, UTF8_ENCODING);
85
+ return structuredClone(AGENT_RUNTIME_MANIFEST);
86
+ }
87
+
88
+ export interface RegisteredAgentRuntimePack {
89
+ manifest: AgentRuntimePackManifest;
90
+ packRoot: string;
91
+ manifestPath: string;
92
+ integrity: `sha256:${string}`;
93
+ }
94
+
95
+ export async function registerAgentRuntimePack(options?: {
96
+ packRoot?: string;
97
+ exclusions?: readonly string[];
98
+ }): Promise<RegisteredAgentRuntimePack> {
99
+ const packRoot = path.resolve(options?.packRoot ?? getDefaultPackRoot());
100
+ const exclusions = options?.exclusions ?? DEFAULT_EXCLUSIONS;
101
+ const manifest = await loadAgentRuntimeManifest(packRoot);
102
+ const integrity = await computeAgentRuntimePackIntegrity(packRoot, exclusions);
103
+
104
+ return {
105
+ manifest,
106
+ packRoot,
107
+ manifestPath: path.join(packRoot, AGENT_RUNTIME_MANIFEST_FILE_NAME),
108
+ integrity,
109
+ };
110
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@lumenflow/packs-agent-runtime",
3
+ "version": "3.18.0",
4
+ "description": "Agent runtime pack scaffold for LumenFlow — governed model-turn execution, pack config, and provider capability baselines",
5
+ "keywords": [
6
+ "lumenflow",
7
+ "pack",
8
+ "agent-runtime",
9
+ "orchestration",
10
+ "policy"
11
+ ],
12
+ "homepage": "https://github.com/hellmai/lumenflow-dev",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/hellmai/lumenflow-dev.git",
16
+ "directory": "packages/@lumenflow/packs/agent-runtime"
17
+ },
18
+ "license": "AGPL-3.0-only",
19
+ "author": {
20
+ "name": "HellmAI",
21
+ "url": "https://hellm.ai"
22
+ },
23
+ "type": "module",
24
+ "exports": {
25
+ ".": "./dist/index.js",
26
+ "./tools": "./dist/tools/index.js",
27
+ "./tool-impl": "./dist/tool-impl/index.js"
28
+ },
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist",
33
+ "manifest.yaml",
34
+ "config.schema.json",
35
+ "LICENSE.md",
36
+ "README.md"
37
+ ],
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "clean": "rm -rf dist *.tgz",
41
+ "test": "vitest run",
42
+ "typecheck": "tsc --noEmit"
43
+ },
44
+ "dependencies": {
45
+ "@lumenflow/kernel": "workspace:^"
46
+ },
47
+ "devDependencies": {
48
+ "typescript": "^5.9.3",
49
+ "vitest": "^4.0.18"
50
+ },
51
+ "engines": {
52
+ "node": ">=22"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
+ }
@@ -0,0 +1,165 @@
1
+ // Copyright (c) 2026 Hellmai Ltd
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+
4
+ import { POLICY_TRIGGERS, type PackPolicyFactory, type PolicyRule } from '@lumenflow/kernel';
5
+ import {
6
+ AGENT_RUNTIME_AGENT_INTENT_METADATA_KEY,
7
+ AGENT_RUNTIME_POLICY_ID_PREFIX,
8
+ } from './constants.js';
9
+ import type { AgentRuntimeIntentConfig, AgentRuntimePackConfig } from './types.js';
10
+
11
+ interface NormalizedIntentRule {
12
+ allowTools: Set<string>;
13
+ approvalRequiredTools: Set<string>;
14
+ }
15
+
16
+ type NormalizedIntentRuleMap = Map<string, NormalizedIntentRule>;
17
+
18
+ export const createAgentRuntimePolicyFactory: PackPolicyFactory = async (input) => {
19
+ const intentRules = normalizeIntentRules(input.packConfig);
20
+ if (intentRules.size === 0) {
21
+ return [];
22
+ }
23
+
24
+ const rules: PolicyRule[] = [
25
+ {
26
+ id: `${AGENT_RUNTIME_POLICY_ID_PREFIX}.intent-approval`,
27
+ trigger: POLICY_TRIGGERS.ON_TOOL_REQUEST,
28
+ decision: 'approval_required',
29
+ reason: 'The classified agent intent requires approval before this tool may run.',
30
+ when: (context) => matchesApprovalRequiredIntent(context, intentRules),
31
+ },
32
+ {
33
+ id: `${AGENT_RUNTIME_POLICY_ID_PREFIX}.intent-deny`,
34
+ trigger: POLICY_TRIGGERS.ON_TOOL_REQUEST,
35
+ decision: 'deny',
36
+ reason: 'The classified agent intent does not permit this tool.',
37
+ when: (context) => matchesDeniedIntent(context, intentRules),
38
+ },
39
+ ];
40
+
41
+ return rules;
42
+ };
43
+
44
+ function normalizeIntentRules(packConfig: unknown): NormalizedIntentRuleMap {
45
+ const config = asRecord(packConfig);
46
+ const intents = asRecord(config?.intents);
47
+ if (!intents) {
48
+ return new Map();
49
+ }
50
+
51
+ const normalized = new Map<string, NormalizedIntentRule>();
52
+ for (const [intentId, candidate] of Object.entries(intents)) {
53
+ const parsed = normalizeIntentConfig(intentId, candidate);
54
+ normalized.set(intentId, parsed);
55
+ }
56
+ return normalized;
57
+ }
58
+
59
+ function normalizeIntentConfig(intentId: string, value: unknown): NormalizedIntentRule {
60
+ const config = asRecord(value);
61
+ if (!config) {
62
+ throw new Error(`agent_runtime.intents.${intentId} must be an object.`);
63
+ }
64
+
65
+ const allowTools = normalizeToolList(
66
+ config.allow_tools,
67
+ `agent_runtime.intents.${intentId}.allow_tools`,
68
+ );
69
+ const approvalRequiredTools = normalizeToolList(
70
+ config.approval_required_tools,
71
+ `agent_runtime.intents.${intentId}.approval_required_tools`,
72
+ true,
73
+ );
74
+
75
+ return {
76
+ allowTools: new Set([...allowTools, ...approvalRequiredTools]),
77
+ approvalRequiredTools: new Set(approvalRequiredTools),
78
+ };
79
+ }
80
+
81
+ function normalizeToolList(value: unknown, fieldName: string, optional = false): string[] {
82
+ if (value === undefined && optional) {
83
+ return [];
84
+ }
85
+ if (
86
+ !Array.isArray(value) ||
87
+ value.some((entry) => typeof entry !== 'string' || entry.trim().length === 0)
88
+ ) {
89
+ throw new Error(`${fieldName} must be an array of non-empty strings.`);
90
+ }
91
+
92
+ return value.map((entry) => entry.trim());
93
+ }
94
+
95
+ function matchesApprovalRequiredIntent(
96
+ context: Parameters<NonNullable<PolicyRule['when']>>[0],
97
+ intentRules: NormalizedIntentRuleMap,
98
+ ): boolean {
99
+ const toolName = readCandidateToolName(context);
100
+ if (!toolName) {
101
+ return false;
102
+ }
103
+
104
+ const intentRule = resolveIntentRule(context, intentRules);
105
+ return intentRule?.approvalRequiredTools.has(toolName) ?? false;
106
+ }
107
+
108
+ function matchesDeniedIntent(
109
+ context: Parameters<NonNullable<PolicyRule['when']>>[0],
110
+ intentRules: NormalizedIntentRuleMap,
111
+ ): boolean {
112
+ const toolName = readCandidateToolName(context);
113
+ if (!toolName) {
114
+ return false;
115
+ }
116
+
117
+ const intentRule = resolveIntentRule(context, intentRules);
118
+ if (!intentRule) {
119
+ return false;
120
+ }
121
+
122
+ return !intentRule.allowTools.has(toolName);
123
+ }
124
+
125
+ function resolveIntentRule(
126
+ context: Parameters<NonNullable<PolicyRule['when']>>[0],
127
+ intentRules: NormalizedIntentRuleMap,
128
+ ): NormalizedIntentRule | null {
129
+ const intent = readAgentIntent(context);
130
+ if (!intent) {
131
+ return null;
132
+ }
133
+
134
+ return (
135
+ intentRules.get(intent) ?? {
136
+ allowTools: new Set<string>(),
137
+ approvalRequiredTools: new Set<string>(),
138
+ }
139
+ );
140
+ }
141
+
142
+ function readAgentIntent(context: Parameters<NonNullable<PolicyRule['when']>>[0]): string | null {
143
+ const executionMetadata = asRecord(context.execution_metadata);
144
+ const candidate = executionMetadata?.[AGENT_RUNTIME_AGENT_INTENT_METADATA_KEY];
145
+ return typeof candidate === 'string' && candidate.trim().length > 0 ? candidate.trim() : null;
146
+ }
147
+
148
+ function readCandidateToolName(
149
+ context: Parameters<NonNullable<PolicyRule['when']>>[0],
150
+ ): string | null {
151
+ if (typeof context.tool_name !== 'string' || context.tool_name.trim().length === 0) {
152
+ return null;
153
+ }
154
+
155
+ const toolName = context.tool_name.trim();
156
+ return toolName === 'agent:execute-turn' ? null : toolName;
157
+ }
158
+
159
+ function asRecord(value: unknown): Record<string, unknown> | null {
160
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
161
+ ? (value as Record<string, unknown>)
162
+ : null;
163
+ }
164
+
165
+ export type { AgentRuntimeIntentConfig, AgentRuntimePackConfig };