newo 3.4.2 → 3.6.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.
- package/.env.example +5 -0
- package/CHANGELOG.md +21 -0
- package/dist/api.d.ts +18 -0
- package/dist/api.js +28 -0
- package/dist/cli/commands/export.d.ts +3 -0
- package/dist/cli/commands/export.js +62 -0
- package/dist/cli/commands/help.js +54 -42
- package/dist/cli/commands/pull.js +38 -14
- package/dist/cli/commands/push.js +32 -32
- package/dist/cli/commands/status.js +46 -7
- package/dist/cli-new/bootstrap.d.ts +7 -1
- package/dist/cli-new/bootstrap.js +11 -5
- package/dist/cli-new/di/tokens.d.ts +1 -0
- package/dist/cli-new/di/tokens.js +1 -0
- package/dist/cli.js +4 -0
- package/dist/domain/strategies/sync/ProjectSyncStrategy.d.ts +5 -0
- package/dist/domain/strategies/sync/ProjectSyncStrategy.js +97 -8
- package/dist/domain/strategies/sync/V2ProjectSyncStrategy.d.ts +80 -0
- package/dist/domain/strategies/sync/V2ProjectSyncStrategy.js +725 -0
- package/dist/env.d.ts +1 -0
- package/dist/env.js +1 -0
- package/dist/format/detect.d.ts +14 -0
- package/dist/format/detect.js +105 -0
- package/dist/format/extensions.d.ts +26 -0
- package/dist/format/extensions.js +45 -0
- package/dist/format/index.d.ts +11 -0
- package/dist/format/index.js +11 -0
- package/dist/format/paths-v2.d.ts +31 -0
- package/dist/format/paths-v2.js +104 -0
- package/dist/format/types.d.ts +28 -0
- package/dist/format/types.js +21 -0
- package/dist/format/v2-yaml.d.ts +143 -0
- package/dist/format/v2-yaml.js +222 -0
- package/dist/format/yaml-patch.d.ts +14 -0
- package/dist/format/yaml-patch.js +184 -0
- package/dist/fsutil.d.ts +10 -0
- package/dist/fsutil.js +25 -0
- package/dist/sync/attributes.js +3 -3
- package/dist/sync/skill-files.js +2 -2
- package/dist/types.d.ts +5 -0
- package/package.json +1 -1
- package/src/api.ts +64 -0
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/help.ts +54 -42
- package/src/cli/commands/pull.ts +46 -15
- package/src/cli/commands/push.ts +38 -31
- package/src/cli/commands/status.ts +59 -9
- package/src/cli-new/bootstrap.ts +19 -7
- package/src/cli-new/di/tokens.ts +1 -0
- package/src/cli.ts +5 -0
- package/src/domain/strategies/sync/ProjectSyncStrategy.ts +122 -8
- package/src/domain/strategies/sync/V2ProjectSyncStrategy.ts +1007 -0
- package/src/env.ts +2 -0
- package/src/format/detect.ts +123 -0
- package/src/format/extensions.ts +61 -0
- package/src/format/index.ts +66 -0
- package/src/format/paths-v2.ts +207 -0
- package/src/format/types.ts +40 -0
- package/src/format/v2-yaml.ts +345 -0
- package/src/format/yaml-patch.ts +208 -0
- package/src/fsutil.ts +37 -0
- package/src/sync/attributes.ts +3 -3
- package/src/sync/skill-files.ts +2 -2
- package/src/types.ts +6 -0
package/dist/env.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface ValidatedEnv {
|
|
|
10
10
|
readonly NEWO_REFRESH_TOKEN: string | undefined;
|
|
11
11
|
readonly NEWO_REFRESH_URL: string | undefined;
|
|
12
12
|
readonly NEWO_DEFAULT_CUSTOMER: string | undefined;
|
|
13
|
+
readonly NEWO_FORMAT: string | undefined;
|
|
13
14
|
readonly [key: string]: string | undefined;
|
|
14
15
|
}
|
|
15
16
|
/**
|
package/dist/env.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FormatVersion, type FormatConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Detect format from existing filesystem structure for a customer
|
|
4
|
+
* Returns null if the customer directory doesn't exist or is empty
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectFormatFromFilesystem(customerIdn: string): FormatVersion | null;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the format version for a customer using the full resolution chain
|
|
9
|
+
*
|
|
10
|
+
* @param customerIdn - Customer identifier
|
|
11
|
+
* @param explicitFormat - Optional --format flag value
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveFormat(customerIdn: string, explicitFormat?: string): FormatConfig;
|
|
14
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format detection and resolution
|
|
3
|
+
*
|
|
4
|
+
* Resolution chain per customer (highest to lowest priority):
|
|
5
|
+
* 1. Explicit --format flag (per-command override)
|
|
6
|
+
* 2. Filesystem auto-detect (for EXISTING customers):
|
|
7
|
+
* - import_version.txt present -> newo_v2
|
|
8
|
+
* - projects/ directory present -> cli_v1
|
|
9
|
+
* 3. NEWO_FORMAT env var (only for NEW customers where nothing exists locally)
|
|
10
|
+
* 4. Default: cli_v1
|
|
11
|
+
*/
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { NEWO_CUSTOMERS_DIR } from '../fsutil.js';
|
|
15
|
+
import { VALID_FORMATS } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Detect format from existing filesystem structure for a customer
|
|
18
|
+
* Returns null if the customer directory doesn't exist or is empty
|
|
19
|
+
*/
|
|
20
|
+
export function detectFormatFromFilesystem(customerIdn) {
|
|
21
|
+
const customerDir = path.join(NEWO_CUSTOMERS_DIR, customerIdn);
|
|
22
|
+
if (!fs.existsSync(customerDir)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// Check for V2 marker: import_version.txt
|
|
26
|
+
const importVersionFile = path.join(customerDir, 'import_version.txt');
|
|
27
|
+
if (fs.existsSync(importVersionFile)) {
|
|
28
|
+
return 'newo_v2';
|
|
29
|
+
}
|
|
30
|
+
// Check for V1 marker: projects/ directory
|
|
31
|
+
const projectsDir = path.join(customerDir, 'projects');
|
|
32
|
+
if (fs.existsSync(projectsDir)) {
|
|
33
|
+
return 'cli_v1';
|
|
34
|
+
}
|
|
35
|
+
// Check one level down for import_version.txt (V2 exports sometimes have a wrapper dir)
|
|
36
|
+
try {
|
|
37
|
+
const entries = fs.readdirSync(customerDir, { withFileTypes: true });
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
const nestedImportVersion = path.join(customerDir, entry.name, 'import_version.txt');
|
|
41
|
+
if (fs.existsSync(nestedImportVersion)) {
|
|
42
|
+
return 'newo_v2';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Ignore read errors
|
|
49
|
+
}
|
|
50
|
+
// Directory exists but no format markers found - could be empty or only has attributes
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get format from NEWO_FORMAT environment variable
|
|
55
|
+
*/
|
|
56
|
+
function getEnvFormat() {
|
|
57
|
+
const envFormat = process.env['NEWO_FORMAT']?.trim().toLowerCase();
|
|
58
|
+
if (!envFormat)
|
|
59
|
+
return null;
|
|
60
|
+
if (VALID_FORMATS.includes(envFormat)) {
|
|
61
|
+
return envFormat;
|
|
62
|
+
}
|
|
63
|
+
console.warn(`Warning: Invalid NEWO_FORMAT="${envFormat}". Valid values: ${VALID_FORMATS.join(', ')}. Using default.`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate an explicit format string from --format flag
|
|
68
|
+
*/
|
|
69
|
+
function validateExplicitFormat(format) {
|
|
70
|
+
const normalized = format.trim().toLowerCase();
|
|
71
|
+
if (VALID_FORMATS.includes(normalized)) {
|
|
72
|
+
return normalized;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the format version for a customer using the full resolution chain
|
|
78
|
+
*
|
|
79
|
+
* @param customerIdn - Customer identifier
|
|
80
|
+
* @param explicitFormat - Optional --format flag value
|
|
81
|
+
*/
|
|
82
|
+
export function resolveFormat(customerIdn, explicitFormat) {
|
|
83
|
+
// 1. Explicit --format flag takes highest priority
|
|
84
|
+
if (explicitFormat) {
|
|
85
|
+
const validated = validateExplicitFormat(explicitFormat);
|
|
86
|
+
if (validated) {
|
|
87
|
+
return { version: validated, source: 'explicit-flag' };
|
|
88
|
+
}
|
|
89
|
+
console.error(`Invalid format "${explicitFormat}". Valid values: ${VALID_FORMATS.join(', ')}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
// 2. Filesystem auto-detect for existing customers
|
|
93
|
+
const detected = detectFormatFromFilesystem(customerIdn);
|
|
94
|
+
if (detected) {
|
|
95
|
+
return { version: detected, source: 'auto-detected' };
|
|
96
|
+
}
|
|
97
|
+
// 3. NEWO_FORMAT env var (for new customers only)
|
|
98
|
+
const envFormat = getEnvFormat();
|
|
99
|
+
if (envFormat) {
|
|
100
|
+
return { version: envFormat, source: 'env-var' };
|
|
101
|
+
}
|
|
102
|
+
// 4. Default: cli_v1
|
|
103
|
+
return { version: 'cli_v1', source: 'default' };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format-aware file extension mapping
|
|
3
|
+
*
|
|
4
|
+
* Handles the extension differences between cli_v1 and newo_v2:
|
|
5
|
+
* cli_v1: guidance -> .guidance, nsl -> .jinja
|
|
6
|
+
* newo_v2: guidance -> .nslg, nsl -> .nsl
|
|
7
|
+
*/
|
|
8
|
+
import type { RunnerType } from '../types.js';
|
|
9
|
+
import { type FormatVersion } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get file extension for a runner type in a specific format
|
|
12
|
+
*/
|
|
13
|
+
export declare function getExtensionForFormat(runnerType: RunnerType, format: FormatVersion): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get runner type from file extension (works for all 4 extensions)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getRunnerTypeFromExtension(ext: string): RunnerType;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a filename is a recognized script file (any format)
|
|
20
|
+
*/
|
|
21
|
+
export declare function isScriptFile(filename: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Infer format version from a file extension
|
|
24
|
+
*/
|
|
25
|
+
export declare function getFormatFromExtension(ext: string): FormatVersion;
|
|
26
|
+
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CLI_V1_EXTENSIONS, NEWO_V2_EXTENSIONS, ALL_SCRIPT_EXTENSIONS, } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get file extension for a runner type in a specific format
|
|
4
|
+
*/
|
|
5
|
+
export function getExtensionForFormat(runnerType, format) {
|
|
6
|
+
const map = format === 'newo_v2' ? NEWO_V2_EXTENSIONS : CLI_V1_EXTENSIONS;
|
|
7
|
+
const ext = map[runnerType];
|
|
8
|
+
return ext ?? CLI_V1_EXTENSIONS.guidance;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get runner type from file extension (works for all 4 extensions)
|
|
12
|
+
*/
|
|
13
|
+
export function getRunnerTypeFromExtension(ext) {
|
|
14
|
+
const normalized = ext.startsWith('.') ? ext : `.${ext}`;
|
|
15
|
+
switch (normalized) {
|
|
16
|
+
case '.guidance':
|
|
17
|
+
case '.nslg':
|
|
18
|
+
return 'guidance';
|
|
19
|
+
case '.jinja':
|
|
20
|
+
case '.nsl':
|
|
21
|
+
return 'nsl';
|
|
22
|
+
default:
|
|
23
|
+
return 'guidance';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if a filename is a recognized script file (any format)
|
|
28
|
+
*/
|
|
29
|
+
export function isScriptFile(filename) {
|
|
30
|
+
const ext = filename.lastIndexOf('.') >= 0
|
|
31
|
+
? filename.slice(filename.lastIndexOf('.'))
|
|
32
|
+
: '';
|
|
33
|
+
return ALL_SCRIPT_EXTENSIONS.includes(ext.toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Infer format version from a file extension
|
|
37
|
+
*/
|
|
38
|
+
export function getFormatFromExtension(ext) {
|
|
39
|
+
const normalized = ext.startsWith('.') ? ext : `.${ext}`;
|
|
40
|
+
if (normalized === '.nsl' || normalized === '.nslg') {
|
|
41
|
+
return 'newo_v2';
|
|
42
|
+
}
|
|
43
|
+
return 'cli_v1';
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=extensions.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format module - handles cli_v1 and newo_v2 format differences
|
|
3
|
+
*/
|
|
4
|
+
export { type FormatVersion, type FormatConfig, CLI_V1_EXTENSIONS, NEWO_V2_EXTENSIONS, ALL_SCRIPT_EXTENSIONS, V2_IMPORT_VERSION, VALID_FORMATS, } from './types.js';
|
|
5
|
+
export { getExtensionForFormat, getRunnerTypeFromExtension, isScriptFile, getFormatFromExtension, } from './extensions.js';
|
|
6
|
+
export { detectFormatFromFilesystem, resolveFormat, } from './detect.js';
|
|
7
|
+
export { v2CustomerDir, v2ProjectDir, v2AgentDir, v2FlowDir, v2SkillsDir, v2SkillScriptPath, v2FlowYamlPath, v2ProjectYamlPath, v2AgentYamlPath, v2ImportVersionPath, v2AkbDir, v2AkbPath, v2CustomerAttributesPath, v2ProjectAttributesPath, v2LibraryDir, v2LibraryYamlPath, v2LibrarySkillsDir, v2LibrarySkillScriptPath, } from './paths-v2.js';
|
|
8
|
+
export { patchYamlToPyyaml } from './yaml-patch.js';
|
|
9
|
+
export { v2LibrarySkillRelativePath } from './paths-v2.js';
|
|
10
|
+
export { type V2FlowDefinition, type V2InlineSkill, type V2FlowEvent, type V2StateField, type V2ProjectMeta, type V2AgentMeta, type V2LibraryDefinition, parseV2FlowYaml, generateV2FlowYaml, parseV2ProjectYaml, generateV2ProjectYaml, parseV2AgentYaml, generateV2AgentYaml, parseV2LibraryYaml, generateV2LibraryYaml, } from './v2-yaml.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format module - handles cli_v1 and newo_v2 format differences
|
|
3
|
+
*/
|
|
4
|
+
export { CLI_V1_EXTENSIONS, NEWO_V2_EXTENSIONS, ALL_SCRIPT_EXTENSIONS, V2_IMPORT_VERSION, VALID_FORMATS, } from './types.js';
|
|
5
|
+
export { getExtensionForFormat, getRunnerTypeFromExtension, isScriptFile, getFormatFromExtension, } from './extensions.js';
|
|
6
|
+
export { detectFormatFromFilesystem, resolveFormat, } from './detect.js';
|
|
7
|
+
export { v2CustomerDir, v2ProjectDir, v2AgentDir, v2FlowDir, v2SkillsDir, v2SkillScriptPath, v2FlowYamlPath, v2ProjectYamlPath, v2AgentYamlPath, v2ImportVersionPath, v2AkbDir, v2AkbPath, v2CustomerAttributesPath, v2ProjectAttributesPath, v2LibraryDir, v2LibraryYamlPath, v2LibrarySkillsDir, v2LibrarySkillScriptPath, } from './paths-v2.js';
|
|
8
|
+
export { patchYamlToPyyaml } from './yaml-patch.js';
|
|
9
|
+
export { v2LibrarySkillRelativePath } from './paths-v2.js';
|
|
10
|
+
export { parseV2FlowYaml, generateV2FlowYaml, parseV2ProjectYaml, generateV2ProjectYaml, parseV2AgentYaml, generateV2AgentYaml, parseV2LibraryYaml, generateV2LibraryYaml, } from './v2-yaml.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RunnerType } from '../types.js';
|
|
2
|
+
export declare function v2CustomerDir(customerIdn: string): string;
|
|
3
|
+
export declare function v2ImportVersionPath(customerIdn: string): string;
|
|
4
|
+
export declare function v2CustomerAttributesPath(customerIdn: string): string;
|
|
5
|
+
export declare function v2AkbDir(customerIdn: string): string;
|
|
6
|
+
export declare function v2AkbPath(customerIdn: string, agentIdn: string): string;
|
|
7
|
+
export declare function v2ProjectDir(customerIdn: string, projectIdn: string): string;
|
|
8
|
+
export declare function v2ProjectYamlPath(customerIdn: string, projectIdn: string): string;
|
|
9
|
+
export declare function v2ProjectAttributesPath(customerIdn: string, projectIdn: string): string;
|
|
10
|
+
export declare function v2AgentDir(customerIdn: string, projectIdn: string, agentIdn: string): string;
|
|
11
|
+
export declare function v2AgentYamlPath(customerIdn: string, projectIdn: string, agentIdn: string): string;
|
|
12
|
+
export declare function v2FlowDir(customerIdn: string, projectIdn: string, agentIdn: string, flowIdn: string): string;
|
|
13
|
+
export declare function v2FlowYamlPath(customerIdn: string, projectIdn: string, agentIdn: string, flowIdn: string): string;
|
|
14
|
+
export declare function v2SkillsDir(customerIdn: string, projectIdn: string, agentIdn: string, flowIdn: string): string;
|
|
15
|
+
export declare function v2SkillScriptPath(customerIdn: string, projectIdn: string, agentIdn: string, flowIdn: string, skillIdn: string, runnerType: RunnerType): string;
|
|
16
|
+
/**
|
|
17
|
+
* Build the relative prompt_script path as it appears in V2 flow YAML
|
|
18
|
+
* e.g., "flows/MainFlow/skills/GreetingSkill.nsl"
|
|
19
|
+
*/
|
|
20
|
+
export declare function v2SkillRelativePath(flowIdn: string, skillIdn: string, runnerType: RunnerType): string;
|
|
21
|
+
export declare function v2LibraryDir(customerIdn: string, projectIdn: string, libraryIdn: string): string;
|
|
22
|
+
export declare function v2LibraryYamlPath(customerIdn: string, projectIdn: string, libraryIdn: string): string;
|
|
23
|
+
export declare function v2LibrarySkillsDir(customerIdn: string, projectIdn: string, libraryIdn: string): string;
|
|
24
|
+
export declare function v2LibrarySkillScriptPath(customerIdn: string, projectIdn: string, libraryIdn: string, skillIdn: string, runnerType: RunnerType): string;
|
|
25
|
+
/**
|
|
26
|
+
* Build relative prompt_script path for library skill in V2 YAML
|
|
27
|
+
* The V2 export includes the project prefix:
|
|
28
|
+
* e.g., "naf/libraries/testLib/skills/utilSkill.nsl"
|
|
29
|
+
*/
|
|
30
|
+
export declare function v2LibrarySkillRelativePath(projectIdn: string, libraryIdn: string, skillIdn: string, runnerType: RunnerType): string;
|
|
31
|
+
//# sourceMappingURL=paths-v2.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2 (newo_v2) path utilities
|
|
3
|
+
*
|
|
4
|
+
* Generates paths for the NEWO platform export format:
|
|
5
|
+
* newo_customers/{cust}/
|
|
6
|
+
* import_version.txt
|
|
7
|
+
* attributes.yaml
|
|
8
|
+
* akb/{AgentIdn}.yaml
|
|
9
|
+
* {ProjectIdn}/
|
|
10
|
+
* {project_idn}.yaml
|
|
11
|
+
* attributes.yaml
|
|
12
|
+
* agents/{AgentIdn}/
|
|
13
|
+
* agent.yaml
|
|
14
|
+
* flows/{FlowIdn}/
|
|
15
|
+
* {FlowIdn}.yaml
|
|
16
|
+
* skills/{SkillIdn}.nsl|.nslg
|
|
17
|
+
* libraries/{LibIdn}/
|
|
18
|
+
* {lib_idn}.yaml
|
|
19
|
+
* skills/{SkillIdn}.nsl|.nslg
|
|
20
|
+
*/
|
|
21
|
+
import path from 'path';
|
|
22
|
+
import { NEWO_CUSTOMERS_DIR } from '../fsutil.js';
|
|
23
|
+
import { getExtensionForFormat } from './extensions.js';
|
|
24
|
+
// ── Customer level ──
|
|
25
|
+
export function v2CustomerDir(customerIdn) {
|
|
26
|
+
return path.posix.join(NEWO_CUSTOMERS_DIR, customerIdn);
|
|
27
|
+
}
|
|
28
|
+
export function v2ImportVersionPath(customerIdn) {
|
|
29
|
+
return path.posix.join(v2CustomerDir(customerIdn), 'import_version.txt');
|
|
30
|
+
}
|
|
31
|
+
export function v2CustomerAttributesPath(customerIdn) {
|
|
32
|
+
return path.posix.join(v2CustomerDir(customerIdn), 'attributes.yaml');
|
|
33
|
+
}
|
|
34
|
+
// ── AKB level ──
|
|
35
|
+
export function v2AkbDir(customerIdn) {
|
|
36
|
+
return path.posix.join(v2CustomerDir(customerIdn), 'akb');
|
|
37
|
+
}
|
|
38
|
+
export function v2AkbPath(customerIdn, agentIdn) {
|
|
39
|
+
return path.posix.join(v2AkbDir(customerIdn), `${agentIdn}.yaml`);
|
|
40
|
+
}
|
|
41
|
+
// ── Project level ──
|
|
42
|
+
export function v2ProjectDir(customerIdn, projectIdn) {
|
|
43
|
+
return path.posix.join(v2CustomerDir(customerIdn), projectIdn);
|
|
44
|
+
}
|
|
45
|
+
export function v2ProjectYamlPath(customerIdn, projectIdn) {
|
|
46
|
+
return path.posix.join(v2ProjectDir(customerIdn, projectIdn), `${projectIdn}.yaml`);
|
|
47
|
+
}
|
|
48
|
+
export function v2ProjectAttributesPath(customerIdn, projectIdn) {
|
|
49
|
+
return path.posix.join(v2ProjectDir(customerIdn, projectIdn), 'attributes.yaml');
|
|
50
|
+
}
|
|
51
|
+
// ── Agent level ──
|
|
52
|
+
export function v2AgentDir(customerIdn, projectIdn, agentIdn) {
|
|
53
|
+
return path.posix.join(v2ProjectDir(customerIdn, projectIdn), 'agents', agentIdn);
|
|
54
|
+
}
|
|
55
|
+
export function v2AgentYamlPath(customerIdn, projectIdn, agentIdn) {
|
|
56
|
+
return path.posix.join(v2AgentDir(customerIdn, projectIdn, agentIdn), 'agent.yaml');
|
|
57
|
+
}
|
|
58
|
+
// ── Flow level ──
|
|
59
|
+
export function v2FlowDir(customerIdn, projectIdn, agentIdn, flowIdn) {
|
|
60
|
+
return path.posix.join(v2AgentDir(customerIdn, projectIdn, agentIdn), 'flows', flowIdn);
|
|
61
|
+
}
|
|
62
|
+
export function v2FlowYamlPath(customerIdn, projectIdn, agentIdn, flowIdn) {
|
|
63
|
+
return path.posix.join(v2FlowDir(customerIdn, projectIdn, agentIdn, flowIdn), `${flowIdn}.yaml`);
|
|
64
|
+
}
|
|
65
|
+
// ── Skill level ──
|
|
66
|
+
export function v2SkillsDir(customerIdn, projectIdn, agentIdn, flowIdn) {
|
|
67
|
+
return path.posix.join(v2FlowDir(customerIdn, projectIdn, agentIdn, flowIdn), 'skills');
|
|
68
|
+
}
|
|
69
|
+
export function v2SkillScriptPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn, runnerType) {
|
|
70
|
+
const ext = getExtensionForFormat(runnerType, 'newo_v2');
|
|
71
|
+
return path.posix.join(v2SkillsDir(customerIdn, projectIdn, agentIdn, flowIdn), `${skillIdn}${ext}`);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the relative prompt_script path as it appears in V2 flow YAML
|
|
75
|
+
* e.g., "flows/MainFlow/skills/GreetingSkill.nsl"
|
|
76
|
+
*/
|
|
77
|
+
export function v2SkillRelativePath(flowIdn, skillIdn, runnerType) {
|
|
78
|
+
const ext = getExtensionForFormat(runnerType, 'newo_v2');
|
|
79
|
+
return `flows/${flowIdn}/skills/${skillIdn}${ext}`;
|
|
80
|
+
}
|
|
81
|
+
// ── Library level ──
|
|
82
|
+
export function v2LibraryDir(customerIdn, projectIdn, libraryIdn) {
|
|
83
|
+
return path.posix.join(v2ProjectDir(customerIdn, projectIdn), 'libraries', libraryIdn);
|
|
84
|
+
}
|
|
85
|
+
export function v2LibraryYamlPath(customerIdn, projectIdn, libraryIdn) {
|
|
86
|
+
return path.posix.join(v2LibraryDir(customerIdn, projectIdn, libraryIdn), `${libraryIdn}.yaml`);
|
|
87
|
+
}
|
|
88
|
+
export function v2LibrarySkillsDir(customerIdn, projectIdn, libraryIdn) {
|
|
89
|
+
return path.posix.join(v2LibraryDir(customerIdn, projectIdn, libraryIdn), 'skills');
|
|
90
|
+
}
|
|
91
|
+
export function v2LibrarySkillScriptPath(customerIdn, projectIdn, libraryIdn, skillIdn, runnerType) {
|
|
92
|
+
const ext = getExtensionForFormat(runnerType, 'newo_v2');
|
|
93
|
+
return path.posix.join(v2LibrarySkillsDir(customerIdn, projectIdn, libraryIdn), `${skillIdn}${ext}`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build relative prompt_script path for library skill in V2 YAML
|
|
97
|
+
* The V2 export includes the project prefix:
|
|
98
|
+
* e.g., "naf/libraries/testLib/skills/utilSkill.nsl"
|
|
99
|
+
*/
|
|
100
|
+
export function v2LibrarySkillRelativePath(projectIdn, libraryIdn, skillIdn, runnerType) {
|
|
101
|
+
const ext = getExtensionForFormat(runnerType, 'newo_v2');
|
|
102
|
+
return `${projectIdn}/libraries/${libraryIdn}/skills/${skillIdn}${ext}`;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=paths-v2.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format version types and constants
|
|
3
|
+
*
|
|
4
|
+
* Defines the two supported project formats:
|
|
5
|
+
* - cli_v1: Native CLI format (full feature support, per-entity metadata)
|
|
6
|
+
* - newo_v2: NEWO platform export format (compatible with platform UI exports)
|
|
7
|
+
*/
|
|
8
|
+
import type { RunnerType } from '../types.js';
|
|
9
|
+
export type FormatVersion = 'cli_v1' | 'newo_v2';
|
|
10
|
+
export interface FormatConfig {
|
|
11
|
+
version: FormatVersion;
|
|
12
|
+
source: 'explicit-flag' | 'env-var' | 'auto-detected' | 'default';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extension mapping per format
|
|
16
|
+
*
|
|
17
|
+
* cli_v1: guidance -> .guidance, nsl -> .jinja
|
|
18
|
+
* newo_v2: guidance -> .nslg, nsl -> .nsl
|
|
19
|
+
*/
|
|
20
|
+
export declare const CLI_V1_EXTENSIONS: Record<RunnerType, string>;
|
|
21
|
+
export declare const NEWO_V2_EXTENSIONS: Record<RunnerType, string>;
|
|
22
|
+
/** All recognized script file extensions across both formats */
|
|
23
|
+
export declare const ALL_SCRIPT_EXTENSIONS: readonly [".guidance", ".jinja", ".nsl", ".nslg"];
|
|
24
|
+
/** V2 import version marker content */
|
|
25
|
+
export declare const V2_IMPORT_VERSION = "v2.0.0";
|
|
26
|
+
/** Valid format values for CLI flag and env var validation */
|
|
27
|
+
export declare const VALID_FORMATS: readonly FormatVersion[];
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension mapping per format
|
|
3
|
+
*
|
|
4
|
+
* cli_v1: guidance -> .guidance, nsl -> .jinja
|
|
5
|
+
* newo_v2: guidance -> .nslg, nsl -> .nsl
|
|
6
|
+
*/
|
|
7
|
+
export const CLI_V1_EXTENSIONS = {
|
|
8
|
+
guidance: '.guidance',
|
|
9
|
+
nsl: '.jinja',
|
|
10
|
+
};
|
|
11
|
+
export const NEWO_V2_EXTENSIONS = {
|
|
12
|
+
guidance: '.nslg',
|
|
13
|
+
nsl: '.nsl',
|
|
14
|
+
};
|
|
15
|
+
/** All recognized script file extensions across both formats */
|
|
16
|
+
export const ALL_SCRIPT_EXTENSIONS = ['.guidance', '.jinja', '.nsl', '.nslg'];
|
|
17
|
+
/** V2 import version marker content */
|
|
18
|
+
export const V2_IMPORT_VERSION = 'v2.0.0';
|
|
19
|
+
/** Valid format values for CLI flag and env var validation */
|
|
20
|
+
export const VALID_FORMATS = ['cli_v1', 'newo_v2'];
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export interface V2InlineSkill {
|
|
2
|
+
title: string;
|
|
3
|
+
idn: string;
|
|
4
|
+
prompt_script: string;
|
|
5
|
+
runner_type: string;
|
|
6
|
+
model: {
|
|
7
|
+
model_idn: string;
|
|
8
|
+
provider_idn: string;
|
|
9
|
+
};
|
|
10
|
+
parameters: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
default_value: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface V2FlowEvent {
|
|
16
|
+
idn: string;
|
|
17
|
+
skill_selector: string;
|
|
18
|
+
skill_idn: string | null;
|
|
19
|
+
state_idn: string | null;
|
|
20
|
+
integration_idn: string | null;
|
|
21
|
+
connector_idn: string | null;
|
|
22
|
+
interrupt_mode: string;
|
|
23
|
+
}
|
|
24
|
+
export interface V2StateField {
|
|
25
|
+
title: string;
|
|
26
|
+
idn: string;
|
|
27
|
+
default_value: string;
|
|
28
|
+
scope: string;
|
|
29
|
+
}
|
|
30
|
+
export interface V2FlowDefinition {
|
|
31
|
+
title: string;
|
|
32
|
+
idn: string;
|
|
33
|
+
description: string | null;
|
|
34
|
+
agent_id: string | null;
|
|
35
|
+
skills: V2InlineSkill[];
|
|
36
|
+
events: V2FlowEvent[];
|
|
37
|
+
state_fields: V2StateField[];
|
|
38
|
+
default_runner_type: string;
|
|
39
|
+
default_provider_idn: string;
|
|
40
|
+
default_model_idn: string;
|
|
41
|
+
publication_type: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface V2ProjectMeta {
|
|
44
|
+
idn: string;
|
|
45
|
+
name: string;
|
|
46
|
+
version: string;
|
|
47
|
+
description: string;
|
|
48
|
+
is_auto_update_enabled: boolean;
|
|
49
|
+
registry: string;
|
|
50
|
+
registry_item_idn: string;
|
|
51
|
+
}
|
|
52
|
+
export interface V2AgentMeta {
|
|
53
|
+
idn: string;
|
|
54
|
+
title: string | null;
|
|
55
|
+
description: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface V2LibraryDefinition {
|
|
58
|
+
title: string;
|
|
59
|
+
idn: string;
|
|
60
|
+
description: string | null;
|
|
61
|
+
skills: V2InlineSkill[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sort skills in V2 export order (case-sensitive ASCII sort within groups):
|
|
65
|
+
* 1. CamelCase (public) - case-sensitive alphabetically
|
|
66
|
+
* 2. _prefixed (private) - case-sensitive alphabetically
|
|
67
|
+
* 3. snake_case - case-sensitive alphabetically
|
|
68
|
+
*/
|
|
69
|
+
export declare function sortV2Skills<T extends {
|
|
70
|
+
idn: string;
|
|
71
|
+
}>(skills: T[]): T[];
|
|
72
|
+
/**
|
|
73
|
+
* Sort parameters alphabetically by name (case-sensitive, V2 export order)
|
|
74
|
+
*/
|
|
75
|
+
export declare function sortV2Parameters<T extends {
|
|
76
|
+
name: string;
|
|
77
|
+
}>(params: T[]): T[];
|
|
78
|
+
export declare function parseV2FlowYaml(filePath: string): Promise<V2FlowDefinition>;
|
|
79
|
+
/**
|
|
80
|
+
* Generate V2 flow YAML content from API data
|
|
81
|
+
*
|
|
82
|
+
* Produces the exact format found in the reference V2 export:
|
|
83
|
+
* title, idn, description, agent_id, skills[], events[], state_fields[],
|
|
84
|
+
* default_runner_type, default_provider_idn, default_model_idn, publication_type
|
|
85
|
+
*/
|
|
86
|
+
export declare function generateV2FlowYaml(flowIdn: string, flowTitle: string, flowDescription: string | null, defaultRunnerType: string, defaultProviderIdn: string, defaultModelIdn: string, skills: V2InlineSkill[], events: V2FlowEvent[], stateFields: V2StateField[]): string;
|
|
87
|
+
export declare function parseV2ProjectYaml(filePath: string): Promise<V2ProjectMeta>;
|
|
88
|
+
/**
|
|
89
|
+
* Generate V2 project YAML
|
|
90
|
+
*
|
|
91
|
+
* Format:
|
|
92
|
+
* project:
|
|
93
|
+
* idn: naf
|
|
94
|
+
* name: naf
|
|
95
|
+
* version: 4.1.0
|
|
96
|
+
* description: ""
|
|
97
|
+
* is_auto_update_enabled: true
|
|
98
|
+
* registry: production
|
|
99
|
+
* registry_item_idn: naf
|
|
100
|
+
*/
|
|
101
|
+
export declare function generateV2ProjectYaml(meta: V2ProjectMeta): string;
|
|
102
|
+
export declare function parseV2AgentYaml(filePath: string): Promise<V2AgentMeta>;
|
|
103
|
+
/**
|
|
104
|
+
* Generate V2 agent YAML
|
|
105
|
+
*
|
|
106
|
+
* Format:
|
|
107
|
+
* agent:
|
|
108
|
+
* idn: TaskManager
|
|
109
|
+
* title: TaskManager
|
|
110
|
+
* description: null
|
|
111
|
+
*
|
|
112
|
+
* V2 export preserves description exactly as provided (null stays null, "" stays "")
|
|
113
|
+
*/
|
|
114
|
+
export declare function generateV2AgentYaml(meta: V2AgentMeta): string;
|
|
115
|
+
export declare function parseV2LibraryYaml(filePath: string): Promise<V2LibraryDefinition>;
|
|
116
|
+
/**
|
|
117
|
+
* Generate V2 library YAML
|
|
118
|
+
*
|
|
119
|
+
* Format:
|
|
120
|
+
* title: Test Library
|
|
121
|
+
* idn: testLib
|
|
122
|
+
* description: Shared utility library
|
|
123
|
+
* skills:
|
|
124
|
+
* - idn: utilSkill
|
|
125
|
+
* ...
|
|
126
|
+
*/
|
|
127
|
+
export declare function generateV2LibraryYaml(lib: V2LibraryDefinition): string;
|
|
128
|
+
/**
|
|
129
|
+
* Build a V2InlineSkill entry from API skill data
|
|
130
|
+
*/
|
|
131
|
+
export declare function buildV2InlineSkill(skillIdn: string, skillTitle: string, runnerType: string, modelIdn: string, providerIdn: string, parameters: Array<{
|
|
132
|
+
name: string;
|
|
133
|
+
default_value: string;
|
|
134
|
+
}>, promptScriptRelPath: string): V2InlineSkill;
|
|
135
|
+
/**
|
|
136
|
+
* Build a V2FlowEvent entry from API event data
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildV2FlowEvent(eventIdn: string, skillSelector: string, skillIdn: string | null, stateIdn: string | null, integrationIdn: string | null, connectorIdn: string | null, interruptMode: string): V2FlowEvent;
|
|
139
|
+
/**
|
|
140
|
+
* Build a V2StateField entry from API state data
|
|
141
|
+
*/
|
|
142
|
+
export declare function buildV2StateField(stateIdn: string, stateTitle: string, defaultValue: string, scope: string): V2StateField;
|
|
143
|
+
//# sourceMappingURL=v2-yaml.d.ts.map
|