@itphx/synth-shared 0.7.3 → 0.8.3

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 (113) hide show
  1. package/dist/config/defaults.d.ts +0 -1
  2. package/dist/config/defaults.js +44 -1
  3. package/dist/config/index.d.ts +0 -1
  4. package/dist/config/index.js +0 -1
  5. package/dist/config/loader.d.ts +2 -1
  6. package/dist/config/loader.js +10 -6
  7. package/dist/config/merge.d.ts +0 -1
  8. package/dist/config/merge.js +0 -1
  9. package/dist/config/resolve.d.ts +35 -7
  10. package/dist/config/resolve.js +98 -19
  11. package/dist/config/types.d.ts +711 -79
  12. package/dist/config/types.js +138 -2
  13. package/dist/i18n/index.d.ts +1 -2
  14. package/dist/i18n/index.js +116 -1
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +3 -3
  17. package/dist/interfaces/index.d.ts +0 -1
  18. package/dist/interfaces/index.js +0 -1
  19. package/dist/model-metadata.d.ts +0 -1
  20. package/dist/model-metadata.js +0 -1
  21. package/dist/protocols/index.d.ts +0 -1
  22. package/dist/protocols/index.js +0 -1
  23. package/dist/schemas/index.d.ts +558 -25
  24. package/dist/schemas/index.js +244 -8
  25. package/dist/skills/frontmatter.d.ts +20 -0
  26. package/dist/skills/frontmatter.js +69 -0
  27. package/dist/types/commands.d.ts +127 -0
  28. package/dist/types/commands.js +10 -0
  29. package/dist/types/index.d.ts +137 -13
  30. package/dist/types/index.js +68 -6
  31. package/dist/types/permission.d.ts +5 -5
  32. package/dist/types/permission.js +0 -1
  33. package/dist/types/skills.d.ts +135 -0
  34. package/dist/types/skills.js +17 -0
  35. package/dist/types/tools.d.ts +0 -1
  36. package/dist/types/tools.js +0 -1
  37. package/dist/utils/glob.d.ts +0 -1
  38. package/dist/utils/glob.js +0 -1
  39. package/dist/utils/index.d.ts +1 -1
  40. package/dist/utils/index.js +2 -1
  41. package/dist/utils/workspace.d.ts +13 -0
  42. package/dist/utils/workspace.js +34 -0
  43. package/dist/version.d.ts +1 -2
  44. package/dist/version.js +1 -2
  45. package/package.json +2 -2
  46. package/dist/config/defaults.d.ts.map +0 -1
  47. package/dist/config/defaults.js.map +0 -1
  48. package/dist/config/defaults.test.d.ts +0 -2
  49. package/dist/config/defaults.test.d.ts.map +0 -1
  50. package/dist/config/defaults.test.js +0 -66
  51. package/dist/config/defaults.test.js.map +0 -1
  52. package/dist/config/index.d.ts.map +0 -1
  53. package/dist/config/index.js.map +0 -1
  54. package/dist/config/loader.d.ts.map +0 -1
  55. package/dist/config/loader.js.map +0 -1
  56. package/dist/config/loader.test.d.ts +0 -2
  57. package/dist/config/loader.test.d.ts.map +0 -1
  58. package/dist/config/loader.test.js +0 -43
  59. package/dist/config/loader.test.js.map +0 -1
  60. package/dist/config/merge.d.ts.map +0 -1
  61. package/dist/config/merge.js.map +0 -1
  62. package/dist/config/merge.test.d.ts +0 -2
  63. package/dist/config/merge.test.d.ts.map +0 -1
  64. package/dist/config/merge.test.js +0 -49
  65. package/dist/config/merge.test.js.map +0 -1
  66. package/dist/config/resolve.d.ts.map +0 -1
  67. package/dist/config/resolve.js.map +0 -1
  68. package/dist/config/resolve.test.d.ts +0 -2
  69. package/dist/config/resolve.test.d.ts.map +0 -1
  70. package/dist/config/resolve.test.js +0 -81
  71. package/dist/config/resolve.test.js.map +0 -1
  72. package/dist/config/types.d.ts.map +0 -1
  73. package/dist/config/types.js.map +0 -1
  74. package/dist/config/types.test.d.ts +0 -2
  75. package/dist/config/types.test.d.ts.map +0 -1
  76. package/dist/config/types.test.js +0 -63
  77. package/dist/config/types.test.js.map +0 -1
  78. package/dist/i18n/index.d.ts.map +0 -1
  79. package/dist/i18n/index.js.map +0 -1
  80. package/dist/i18n/index.test.d.ts +0 -2
  81. package/dist/i18n/index.test.d.ts.map +0 -1
  82. package/dist/i18n/index.test.js +0 -41
  83. package/dist/i18n/index.test.js.map +0 -1
  84. package/dist/index.d.ts.map +0 -1
  85. package/dist/index.js.map +0 -1
  86. package/dist/interfaces/index.d.ts.map +0 -1
  87. package/dist/interfaces/index.js.map +0 -1
  88. package/dist/model-metadata.d.ts.map +0 -1
  89. package/dist/model-metadata.js.map +0 -1
  90. package/dist/model-metadata.test.d.ts +0 -2
  91. package/dist/model-metadata.test.d.ts.map +0 -1
  92. package/dist/model-metadata.test.js +0 -53
  93. package/dist/model-metadata.test.js.map +0 -1
  94. package/dist/protocols/index.d.ts.map +0 -1
  95. package/dist/protocols/index.js.map +0 -1
  96. package/dist/schemas/index.d.ts.map +0 -1
  97. package/dist/schemas/index.js.map +0 -1
  98. package/dist/types/index.d.ts.map +0 -1
  99. package/dist/types/index.js.map +0 -1
  100. package/dist/types/permission.d.ts.map +0 -1
  101. package/dist/types/permission.js.map +0 -1
  102. package/dist/types/tools.d.ts.map +0 -1
  103. package/dist/types/tools.js.map +0 -1
  104. package/dist/utils/glob.d.ts.map +0 -1
  105. package/dist/utils/glob.js.map +0 -1
  106. package/dist/utils/index.d.ts.map +0 -1
  107. package/dist/utils/index.js.map +0 -1
  108. package/dist/utils/index.test.d.ts +0 -2
  109. package/dist/utils/index.test.d.ts.map +0 -1
  110. package/dist/utils/index.test.js +0 -150
  111. package/dist/utils/index.test.js.map +0 -1
  112. package/dist/version.d.ts.map +0 -1
  113. package/dist/version.js.map +0 -1
@@ -1,3 +1,2 @@
1
1
  import type { SynthConfig } from './types.js';
2
2
  export declare const defaultConfig: SynthConfig;
3
- //# sourceMappingURL=defaults.d.ts.map
@@ -10,6 +10,7 @@ export const defaultConfig = {
10
10
  dataDir: '/var/synth/data',
11
11
  workspacesRoot: '',
12
12
  defaultWorkspace: '',
13
+ workspaceOutsideRoot: '',
13
14
  },
14
15
  auth: {
15
16
  debugMode: false,
@@ -92,6 +93,47 @@ export const defaultConfig = {
92
93
  tools: [],
93
94
  },
94
95
  },
96
+ skills: {
97
+ paths: [],
98
+ urls: [],
99
+ trustedProjectDirs: [],
100
+ inlineShell: false,
101
+ toolsets: {},
102
+ },
103
+ commands: {
104
+ paths: [],
105
+ bundlesPath: 'skill-bundles',
106
+ conflict: {
107
+ mode: 'bundle-wins',
108
+ namespacePrefix: false,
109
+ },
110
+ maxArgumentsLength: 10_000,
111
+ maxRenderedBytes: 200_000,
112
+ },
113
+ instructions: {
114
+ enabled: true,
115
+ claudeCompat: true,
116
+ contextCompat: false,
117
+ headRatio: 0.7,
118
+ tailRatio: 0.2,
119
+ windowRatio: 0.06,
120
+ minChars: 20_000,
121
+ maxCharsCeiling: 500_000,
122
+ lazy: {
123
+ enabled: true,
124
+ maxAncestors: 5,
125
+ maxChars: 8_000,
126
+ excludeDirs: ['node_modules', '.git', 'vendor', 'dist', 'build', '.next', 'coverage', 'tmp', '.cache'],
127
+ },
128
+ fetch: {
129
+ timeoutMs: 5_000,
130
+ cacheTtlSec: 3_600,
131
+ maxBytes: 262_144,
132
+ },
133
+ sources: [],
134
+ excludeProjects: [],
135
+ allowInstallTreeFallback: false,
136
+ },
95
137
  router: {
96
138
  enabled: true,
97
139
  strategy: 'auto',
@@ -169,6 +211,7 @@ export const defaultConfig = {
169
211
  protectedPaths: {
170
212
  enabled: true,
171
213
  },
214
+ // Пусто — core использует файл {dataDir}/secrets/master.key (AD-076).
215
+ secretKey: '',
172
216
  },
173
217
  };
174
- //# sourceMappingURL=defaults.js.map
@@ -3,4 +3,3 @@ export * from './defaults.js';
3
3
  export * from './loader.js';
4
4
  export * from './merge.js';
5
5
  export * from './resolve.js';
6
- //# sourceMappingURL=index.d.ts.map
@@ -3,4 +3,3 @@ export * from './defaults.js';
3
3
  export * from './loader.js';
4
4
  export * from './merge.js';
5
5
  export * from './resolve.js';
6
- //# sourceMappingURL=index.js.map
@@ -1,7 +1,8 @@
1
1
  import { type SynthConfig } from './types.js';
2
2
  export interface LoadConfigOptions {
3
3
  configPath?: string;
4
+ /** AD-079: home-каталог — конфиг резолвится как `<home>/config.yaml`, если path не задан. */
5
+ home?: string;
4
6
  overrides?: Partial<SynthConfig>;
5
7
  }
6
8
  export declare function loadConfig(options?: LoadConfigOptions): Promise<SynthConfig>;
7
- //# sourceMappingURL=loader.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
2
3
  import { load as parseYaml } from 'js-yaml';
3
4
  import { synthConfigSchema } from './types.js';
4
5
  import { defaultConfig } from './defaults.js';
@@ -9,18 +10,22 @@ const CONFIG_SEARCH_PATHS = [
9
10
  ];
10
11
  const USER_CONFIG_DIR = '.config/synth';
11
12
  const SYSTEM_CONFIG_PATH = '/etc/synth/config.yaml';
12
- function searchPaths(explicitPath) {
13
+ function searchPaths(explicitPath, home) {
13
14
  if (explicitPath)
14
15
  return [explicitPath];
16
+ // AD-079: при заданном home конфиг ищется строго в <home>/config.yaml
17
+ // (home приоритетнее cwd/XDG-цепочки).
18
+ if (home)
19
+ return [join(home, 'config.yaml')];
15
20
  const paths = [];
16
- const home = process.env.HOME || process.env.USERPROFILE || '';
21
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '';
17
22
  // CWD
18
23
  for (const name of CONFIG_SEARCH_PATHS) {
19
24
  paths.push(name);
20
25
  }
21
26
  // ~/.config/synth/config.yaml
22
- if (home) {
23
- paths.push(`${home}/${USER_CONFIG_DIR}/config.yaml`);
27
+ if (homeDir) {
28
+ paths.push(`${homeDir}/${USER_CONFIG_DIR}/config.yaml`);
24
29
  }
25
30
  // /etc/synth/config.yaml
26
31
  paths.push(SYSTEM_CONFIG_PATH);
@@ -40,7 +45,7 @@ export async function loadConfig(options = {}) {
40
45
  // findConfigPath). Без этого dev-запуск backend с cwd=synth/ не читал
41
46
  // packages/backend/config.yaml (mcp.servers) и seed реестра был пустым.
42
47
  const explicitPath = options.configPath ?? process.env.SYNTH_CONFIG;
43
- const paths = searchPaths(explicitPath);
48
+ const paths = searchPaths(explicitPath, options.home);
44
49
  let fileConfig = {};
45
50
  for (const path of paths) {
46
51
  const parsed = await tryReadYaml(path);
@@ -59,4 +64,3 @@ export async function loadConfig(options = {}) {
59
64
  }
60
65
  return parsed.data;
61
66
  }
62
- //# sourceMappingURL=loader.js.map
@@ -1,2 +1 @@
1
1
  export declare function deepMerge(a: Record<string, unknown>, b: Record<string, unknown>): Record<string, unknown>;
2
- //# sourceMappingURL=merge.d.ts.map
@@ -18,4 +18,3 @@ export function deepMerge(a, b) {
18
18
  }
19
19
  return result;
20
20
  }
21
- //# sourceMappingURL=merge.js.map
@@ -1,18 +1,46 @@
1
1
  import type { SynthConfig } from './types.js';
2
+ import type { WorkspaceOutsideRootPolicy } from '../types/index.js';
2
3
  export type DeployMode = 'user' | 'docker' | 'server' | 'dev';
3
4
  export declare function resolveDeployMode(): DeployMode;
4
- export declare function resolveDataDir(config: SynthConfig, env?: NodeJS.ProcessEnv): string;
5
- export declare function findConfigPath(): string | null;
6
- export declare function defaultConfigPath(mode?: DeployMode): string;
5
+ /**
6
+ * AD-079: базовый home-каталог локального инстанса. Приоритет: явный флаг
7
+ * (`explicitHome`) > env `SYNTH_HOME` > null (XDG-дефолты). Возвращает
8
+ * абсолютный путь либо null.
9
+ */
10
+ export declare function resolveHome(explicitHome?: string | null, env?: NodeJS.ProcessEnv): string | null;
11
+ export declare function resolveDataDir(config: SynthConfig, env?: NodeJS.ProcessEnv, home?: string | null): string;
12
+ export declare function findConfigPath(home?: string | null): string | null;
13
+ export declare function defaultConfigPath(mode?: DeployMode, home?: string | null): string;
7
14
  export declare function ensureConfigFile(targetPath: string): Promise<void>;
8
- export declare function ensureFirstRun(dataDirOverride?: string, configPathOverride?: string): Promise<{
15
+ export declare function ensureFirstRun(dataDirOverride?: string, configPathOverride?: string, home?: string | null): Promise<{
9
16
  dataDir: string;
10
17
  configPath: string | null;
11
18
  mode: DeployMode;
12
19
  }>;
13
20
  export declare function resolvePort(config: SynthConfig, envKey: string, configFallback: number, env?: NodeJS.ProcessEnv): number;
14
- export declare function resolveWorkspacesRoot(config: SynthConfig, env?: NodeJS.ProcessEnv): string;
15
- export declare function resolveDefaultWorkspace(config: SynthConfig, env?: NodeJS.ProcessEnv): string;
21
+ export declare function resolveWorkspacesRoot(config: SynthConfig, env?: NodeJS.ProcessEnv, home?: string | null): string;
22
+ export declare function resolveDefaultWorkspace(config: SynthConfig, env?: NodeJS.ProcessEnv, home?: string | null): string;
23
+ /**
24
+ * AD-079: путь к реестру профилей серверов. При заданном home — плоская
25
+ * раскладка `<home>/profiles.json`, иначе XDG-дефолт `~/.config/synth/profiles.json`.
26
+ */
27
+ export declare function resolveProfilesPath(home?: string | null): string;
28
+ /**
29
+ * AD-079: путь к файлу credentials. При заданном home — плоская раскладка
30
+ * `<home>/credentials.json`, иначе XDG-дефолт `~/.config/synth/credentials.json`.
31
+ */
32
+ export declare function resolveCredentialsPath(home?: string | null): string;
33
+ /**
34
+ * AD-075: эффективная политика для абсолютного workspace вне `workspacesRoot`
35
+ * (приоритет: env `SYNTH_WORKSPACE_OUTSIDE_ROOT` > `config.storage.workspaceOutsideRoot` > `''`).
36
+ * `''` — политика не задана; потребитель подставляет `confirm`.
37
+ */
38
+ export declare function resolveWorkspaceOutsideRootPolicy(config: SynthConfig, env?: NodeJS.ProcessEnv): WorkspaceOutsideRootPolicy | '';
39
+ /**
40
+ * AD-076: мастер-ключ шифрования секретов at-rest (SSH-ключи, AES-256-GCM).
41
+ * Приоритет: env `SYNTH_SECRET_KEY` > `config.security.secretKey` > `''`
42
+ * (пусто — core использует файл `{dataDir}/secrets/master.key`).
43
+ */
44
+ export declare function resolveSecretKey(config: SynthConfig, env?: NodeJS.ProcessEnv): string;
16
45
  export declare function ensureDataDir(dataDir: string): Promise<void>;
17
46
  export declare function createDefaultConfig(targetPath: string): Promise<void>;
18
- //# sourceMappingURL=resolve.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { mkdir, writeFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
3
+ import { join, resolve } from 'node:path';
4
4
  import { dump as dumpYaml } from 'js-yaml';
5
5
  import { defaultConfig } from './defaults.js';
6
6
  const DATA_SUBDIRS = [
@@ -38,13 +38,31 @@ export function resolveDeployMode() {
38
38
  return 'dev';
39
39
  return 'user';
40
40
  }
41
- export function resolveDataDir(config, env) {
41
+ /**
42
+ * AD-079: базовый home-каталог локального инстанса. Приоритет: явный флаг
43
+ * (`explicitHome`) > env `SYNTH_HOME` > null (XDG-дефолты). Возвращает
44
+ * абсолютный путь либо null.
45
+ */
46
+ export function resolveHome(explicitHome, env) {
47
+ const raw = explicitHome ?? (env ?? process.env).SYNTH_HOME;
48
+ if (!raw)
49
+ return null;
50
+ return resolve(raw);
51
+ }
52
+ export function resolveDataDir(config, env, home) {
53
+ // AD-075: нормализуем к абсолютному пути — относительный dataDir ломает
54
+ // containment-проверки FS (root остаётся относительным, target — абсолютным).
42
55
  const envVar = (env ?? process.env).SYNTH_DATA_DIR;
43
56
  if (envVar)
44
- return envVar;
57
+ return resolve(envVar);
45
58
  if (config.storage.dataDir && config.storage.dataDir !== defaultConfig.storage.dataDir) {
46
- return config.storage.dataDir;
59
+ return resolve(config.storage.dataDir);
47
60
  }
61
+ // AD-079: home-каталог задаёт плоскую раскладку (<home>/data) и приоритетнее
62
+ // mode-дефолтов, но ниже явных SYNTH_DATA_DIR/config.storage.dataDir.
63
+ const h = resolveHome(home, env);
64
+ if (h)
65
+ return join(h, 'data');
48
66
  const mode = resolveDeployMode();
49
67
  switch (mode) {
50
68
  case 'user': return join(homeDir(), '.local', 'share', 'synth');
@@ -52,10 +70,17 @@ export function resolveDataDir(config, env) {
52
70
  default: return '/var/synth/data';
53
71
  }
54
72
  }
55
- export function findConfigPath() {
73
+ export function findConfigPath(home) {
56
74
  const explicit = process.env.SYNTH_CONFIG;
57
75
  if (explicit)
58
76
  return explicit;
77
+ // AD-079: при заданном home конфиг — строго <home>/config.yaml (приоритетнее
78
+ // cwd/XDG); отсутствие файла не откатывается к дефолтам.
79
+ const h = resolveHome(home);
80
+ if (h) {
81
+ const homePath = join(h, 'config.yaml');
82
+ return existsSync(homePath) ? homePath : null;
83
+ }
59
84
  const cwd = process.cwd();
60
85
  const localNames = ['synth.config.yaml', 'config.yaml'];
61
86
  for (const name of localNames) {
@@ -81,7 +106,11 @@ export function findConfigPath() {
81
106
  }
82
107
  }
83
108
  }
84
- export function defaultConfigPath(mode) {
109
+ export function defaultConfigPath(mode, home) {
110
+ // AD-079: home задаёт плоскую раскладку (<home>/config.yaml) независимо от mode.
111
+ const h = resolveHome(home);
112
+ if (h)
113
+ return join(h, 'config.yaml');
85
114
  const m = mode ?? resolveDeployMode();
86
115
  switch (m) {
87
116
  case 'user': return join(homeDir(), '.config', 'synth', 'config.yaml');
@@ -101,10 +130,14 @@ export async function ensureConfigFile(targetPath) {
101
130
  });
102
131
  await writeFile(targetPath, yaml, 'utf-8');
103
132
  }
104
- export async function ensureFirstRun(dataDirOverride, configPathOverride) {
133
+ export async function ensureFirstRun(dataDirOverride, configPathOverride, home) {
105
134
  const mode = resolveDeployMode();
106
- const dataDir = dataDirOverride ?? resolveDataDir(defaultConfig);
107
- const configPath = configPathOverride ?? defaultConfigPath(mode);
135
+ // AD-079: home задаёт плоскую раскладку (<home>/config.yaml, <home>/data).
136
+ const h = resolveHome(home);
137
+ // AD-075: относительный --data-dir абсолютизируем на CLI-границе (иначе
138
+ // containment-проверки FS получают относительный root и абсолютный target).
139
+ const dataDir = resolve(dataDirOverride ?? resolveDataDir(defaultConfig, undefined, h));
140
+ const configPath = configPathOverride ?? defaultConfigPath(mode, h);
108
141
  if (mode !== 'docker') {
109
142
  await ensureDataDir(dataDir);
110
143
  }
@@ -113,7 +146,7 @@ export async function ensureFirstRun(dataDirOverride, configPathOverride) {
113
146
  await ensureConfigFile(configPath);
114
147
  }
115
148
  }
116
- const foundPath = findConfigPath();
149
+ const foundPath = findConfigPath(h);
117
150
  if (mode === 'user' || mode === 'dev') {
118
151
  console.log(` режим: ${mode}`);
119
152
  console.log(` данные: ${dataDir}`);
@@ -130,24 +163,71 @@ export function resolvePort(config, envKey, configFallback, env) {
130
163
  }
131
164
  return configFallback;
132
165
  }
133
- export function resolveWorkspacesRoot(config, env) {
166
+ export function resolveWorkspacesRoot(config, env, home) {
134
167
  const envVal = (env ?? process.env).SYNTH_WORKSPACES_ROOT;
135
168
  if (envVal)
136
- return envVal;
169
+ return resolve(envVal);
137
170
  if (config.storage.workspacesRoot)
138
- return config.storage.workspacesRoot;
139
- const dataDir = resolveDataDir(config, env);
171
+ return resolve(config.storage.workspacesRoot);
172
+ const dataDir = resolveDataDir(config, env, home);
140
173
  return `${dataDir}/workspaces`;
141
174
  }
142
- export function resolveDefaultWorkspace(config, env) {
175
+ export function resolveDefaultWorkspace(config, env, home) {
143
176
  const envVal = (env ?? process.env).SYNTH_DEFAULT_WORKSPACE;
144
177
  if (envVal)
145
- return envVal;
178
+ return resolve(envVal);
146
179
  if (config.storage.defaultWorkspace)
147
- return config.storage.defaultWorkspace;
148
- const dataDir = resolveDataDir(config, env);
180
+ return resolve(config.storage.defaultWorkspace);
181
+ const dataDir = resolveDataDir(config, env, home);
149
182
  return join(dataDir, 'workspaces', 'default');
150
183
  }
184
+ /**
185
+ * AD-079: путь к реестру профилей серверов. При заданном home — плоская
186
+ * раскладка `<home>/profiles.json`, иначе XDG-дефолт `~/.config/synth/profiles.json`.
187
+ */
188
+ export function resolveProfilesPath(home) {
189
+ const h = resolveHome(home);
190
+ if (h)
191
+ return join(h, 'profiles.json');
192
+ return join(homeDir(), '.config', 'synth', 'profiles.json');
193
+ }
194
+ /**
195
+ * AD-079: путь к файлу credentials. При заданном home — плоская раскладка
196
+ * `<home>/credentials.json`, иначе XDG-дефолт `~/.config/synth/credentials.json`.
197
+ */
198
+ export function resolveCredentialsPath(home) {
199
+ const h = resolveHome(home);
200
+ if (h)
201
+ return join(h, 'credentials.json');
202
+ return join(homeDir(), '.config', 'synth', 'credentials.json');
203
+ }
204
+ /**
205
+ * AD-075: эффективная политика для абсолютного workspace вне `workspacesRoot`
206
+ * (приоритет: env `SYNTH_WORKSPACE_OUTSIDE_ROOT` > `config.storage.workspaceOutsideRoot` > `''`).
207
+ * `''` — политика не задана; потребитель подставляет `confirm`.
208
+ */
209
+ export function resolveWorkspaceOutsideRootPolicy(config, env) {
210
+ const envVal = (env ?? process.env).SYNTH_WORKSPACE_OUTSIDE_ROOT;
211
+ if (envVal === 'confirm' || envVal === 'deny')
212
+ return envVal;
213
+ const cfgVal = config.storage.workspaceOutsideRoot;
214
+ if (cfgVal === 'confirm' || cfgVal === 'deny')
215
+ return cfgVal;
216
+ return '';
217
+ }
218
+ /**
219
+ * AD-076: мастер-ключ шифрования секретов at-rest (SSH-ключи, AES-256-GCM).
220
+ * Приоритет: env `SYNTH_SECRET_KEY` > `config.security.secretKey` > `''`
221
+ * (пусто — core использует файл `{dataDir}/secrets/master.key`).
222
+ */
223
+ export function resolveSecretKey(config, env) {
224
+ const envVal = (env ?? process.env).SYNTH_SECRET_KEY;
225
+ if (envVal)
226
+ return envVal;
227
+ if (config.security.secretKey)
228
+ return config.security.secretKey;
229
+ return '';
230
+ }
151
231
  export async function ensureDataDir(dataDir) {
152
232
  await mkdir(dataDir, { recursive: true });
153
233
  for (const subdir of DATA_SUBDIRS) {
@@ -163,4 +243,3 @@ export async function createDefaultConfig(targetPath) {
163
243
  });
164
244
  await writeFile(targetPath, yaml, 'utf-8');
165
245
  }
166
- //# sourceMappingURL=resolve.js.map