ptbk 0.119.0-21 → 0.119.0-26
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 +16 -9
- package/dist/browser/browser.d.ts +50 -36
- package/dist/browser/browser.js +162 -118
- package/dist/browser/browser.js.map +1 -1
- package/dist/browser/fleet.d.ts +59 -0
- package/dist/browser/fleet.js +148 -0
- package/dist/browser/fleet.js.map +1 -0
- package/dist/browser/recording.js +2 -2
- package/dist/browser/recording.js.map +1 -1
- package/dist/chats/conversation.d.ts +1 -1
- package/dist/chats/conversation.js +8 -6
- package/dist/chats/conversation.js.map +1 -1
- package/dist/chats/local.js +5 -5
- package/dist/chats/local.js.map +1 -1
- package/dist/cli/commands/add.js +1 -1
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/boilerplates.js +1 -1
- package/dist/cli/commands/boilerplates.js.map +1 -1
- package/dist/cli/commands/find.js +1 -1
- package/dist/cli/commands/find.js.map +1 -1
- package/dist/cli/commands/fix.js +9 -4
- package/dist/cli/commands/fix.js.map +1 -1
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.js +279 -118
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/migrate.js +1 -1
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands/ping.js +20 -12
- package/dist/cli/commands/ping.js.map +1 -1
- package/dist/cli/commands/plan.js +20 -12
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/recover.js +1 -1
- package/dist/cli/commands/recover.js.map +1 -1
- package/dist/cli/commands/restart.js +6 -5
- package/dist/cli/commands/restart.js.map +1 -1
- package/dist/cli/commands/run.js +26 -15
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/start.js +11 -7
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/tool.d.ts +19 -0
- package/dist/cli/commands/tool.js +320 -0
- package/dist/cli/commands/tool.js.map +1 -0
- package/dist/cli/commands/verify.js +1 -1
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/common.d.ts +7 -1
- package/dist/cli/common.js +37 -20
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/compatibility.d.ts +8 -0
- package/dist/cli/compatibility.js +32 -0
- package/dist/cli/compatibility.js.map +1 -0
- package/dist/cli/parser.js +7 -3
- package/dist/cli/parser.js.map +1 -1
- package/dist/cli/registry.js +182 -7
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli/service-view.js +1 -1
- package/dist/cli/service-view.js.map +1 -1
- package/dist/cli/sources.js +2 -0
- package/dist/cli/sources.js.map +1 -1
- package/dist/cli/spec.js +8 -6
- package/dist/cli/spec.js.map +1 -1
- package/dist/common/naming.d.ts +53 -0
- package/dist/common/naming.js +90 -0
- package/dist/common/naming.js.map +1 -0
- package/dist/engine/agenda.d.ts +70 -9
- package/dist/engine/agenda.js +294 -61
- package/dist/engine/agenda.js.map +1 -1
- package/dist/engine/executor.d.ts +5 -0
- package/dist/engine/executor.js +24 -11
- package/dist/engine/executor.js.map +1 -1
- package/dist/engine/harnesses.d.ts +82 -18
- package/dist/engine/harnesses.js +191 -39
- package/dist/engine/harnesses.js.map +1 -1
- package/dist/engine/preview.js +2 -2
- package/dist/engine/preview.js.map +1 -1
- package/dist/engine/routing.d.ts +10 -0
- package/dist/engine/routing.js +67 -28
- package/dist/engine/routing.js.map +1 -1
- package/dist/engine/snapshot.d.ts +107 -7
- package/dist/engine/state.d.ts +4 -2
- package/dist/engine/state.js.map +1 -1
- package/dist/engine/sync.d.ts +96 -0
- package/dist/engine/sync.js +199 -0
- package/dist/engine/sync.js.map +1 -0
- package/dist/engine/team.d.ts +1 -0
- package/dist/engine/team.js +12 -8
- package/dist/engine/team.js.map +1 -1
- package/dist/expert/_main.md +96 -67
- package/dist/expert/agents/_index.md +10 -7
- package/dist/expert/agents/core-agents.md +4 -2
- package/dist/expert/agents/fixer.md +15 -12
- package/dist/expert/cli/acceptance.md +96 -78
- package/dist/expert/cli/api.md +26 -14
- package/dist/expert/cli/autonomous-operation.md +17 -19
- package/dist/expert/cli/browser.md +24 -24
- package/dist/expert/cli/checks.md +18 -10
- package/dist/expert/cli/cli.md +48 -41
- package/dist/expert/cli/configuration-migrations.md +43 -0
- package/dist/expert/cli/configuration.md +24 -14
- package/dist/expert/cli/controls.md +23 -11
- package/dist/expert/cli/dashboard-details.md +28 -10
- package/dist/expert/cli/dashboard-layout.md +15 -15
- package/dist/expert/cli/dashboard.md +8 -10
- package/dist/expert/cli/environment.md +33 -0
- package/dist/expert/cli/execution.md +10 -8
- package/dist/expert/cli/git-persistence.md +27 -21
- package/dist/expert/cli/git-preflight.md +8 -4
- package/dist/expert/cli/git-synchronization.md +32 -6
- package/dist/expert/cli/harness-plugins.md +12 -12
- package/dist/expert/cli/harnesses.md +22 -16
- package/dist/expert/cli/initialization-ui.md +14 -14
- package/dist/expert/cli/initialization.md +31 -21
- package/dist/expert/cli/installation.md +6 -0
- package/dist/expert/cli/isolation.md +5 -3
- package/dist/expert/cli/releasing.md +17 -3
- package/dist/expert/cli/retries.md +10 -8
- package/dist/expert/cli/run.md +7 -5
- package/dist/expert/cli/start.md +21 -15
- package/dist/expert/cli/status-view.md +15 -17
- package/dist/expert/cli/synchronization-setup.md +24 -0
- package/dist/expert/cli/terminal.md +14 -16
- package/dist/expert/cli/tool-management.md +60 -0
- package/dist/expert/cli/tool-runtime.md +35 -0
- package/dist/expert/cli/tools-migration.md +50 -0
- package/dist/expert/cli/tools.md +73 -0
- package/dist/expert/cli/trace-configuration.md +9 -11
- package/dist/expert/cli/updates.md +7 -7
- package/dist/expert/cli/windows-installer.md +67 -0
- package/dist/expert/cli/workspace.md +2 -0
- package/dist/expert/coding-standards/_index.md +11 -0
- package/dist/expert/coding-standards/naming.md +30 -0
- package/dist/expert/coding-standards/shared-logic.md +27 -0
- package/dist/expert/concepts/automatic-repair.md +33 -0
- package/dist/expert/concepts/engine-and-project.md +7 -5
- package/dist/expert/dictionary.md +18 -18
- package/dist/harness/plugins/claude-code/index.js +4 -2
- package/dist/harness/plugins/claude-code/index.js.map +1 -1
- package/dist/harness/plugins/cline/index.js +1 -0
- package/dist/harness/plugins/cline/index.js.map +1 -1
- package/dist/harness/plugins/gemini/index.js +2 -0
- package/dist/harness/plugins/gemini/index.js.map +1 -1
- package/dist/harness/plugins/github-copilot/index.js +1 -0
- package/dist/harness/plugins/github-copilot/index.js.map +1 -1
- package/dist/harness/plugins/openai-codex/index.js +13 -9
- package/dist/harness/plugins/openai-codex/index.js.map +1 -1
- package/dist/harness/plugins/opencode/index.js +1 -0
- package/dist/harness/plugins/opencode/index.js.map +1 -1
- package/dist/harness/plugins/qwen-code/index.js +1 -0
- package/dist/harness/plugins/qwen-code/index.js.map +1 -1
- package/dist/harness/types.d.ts +16 -5
- package/dist/project/config.d.ts +135 -48
- package/dist/project/config.js +331 -119
- package/dist/project/config.js.map +1 -1
- package/dist/project/configuration.d.ts +43 -0
- package/dist/project/configuration.js +165 -0
- package/dist/project/configuration.js.map +1 -0
- package/dist/project/defaults.d.ts +4 -2
- package/dist/project/defaults.js +10 -5
- package/dist/project/defaults.js.map +1 -1
- package/dist/project/git.d.ts +28 -0
- package/dist/project/git.js +81 -0
- package/dist/project/git.js.map +1 -1
- package/dist/project/migrations.d.ts +96 -0
- package/dist/project/migrations.js +301 -0
- package/dist/project/migrations.js.map +1 -0
- package/dist/project/publication.d.ts +57 -0
- package/dist/project/publication.js +117 -0
- package/dist/project/publication.js.map +1 -0
- package/dist/project/readiness.d.ts +14 -5
- package/dist/project/readiness.js +23 -22
- package/dist/project/readiness.js.map +1 -1
- package/dist/project/setup.js +2 -0
- package/dist/project/setup.js.map +1 -1
- package/dist/service/actions.d.ts +12 -4
- package/dist/service/actions.js +32 -2
- package/dist/service/actions.js.map +1 -1
- package/dist/service/control.d.ts +1 -1
- package/dist/service/control.js +1 -1
- package/dist/service/host.d.ts +5 -2
- package/dist/service/host.js +26 -16
- package/dist/service/host.js.map +1 -1
- package/dist/service/http.js +7 -2
- package/dist/service/http.js.map +1 -1
- package/dist/service/launcher.d.ts +2 -1
- package/dist/service/launcher.js +1 -0
- package/dist/service/launcher.js.map +1 -1
- package/dist/service/records.d.ts +3 -0
- package/dist/service/records.js +1 -1
- package/dist/service/records.js.map +1 -1
- package/dist/service/spa/app.css +39 -0
- package/dist/service/spa/app.js +242 -39
- package/dist/service/worker.js +1 -0
- package/dist/service/worker.js.map +1 -1
- package/dist/tools/environment.d.ts +122 -0
- package/dist/tools/environment.js +199 -0
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/model.d.ts +180 -0
- package/dist/tools/model.js +111 -0
- package/dist/tools/model.js.map +1 -0
- package/dist/tools/normalize.d.ts +51 -0
- package/dist/tools/normalize.js +321 -0
- package/dist/tools/normalize.js.map +1 -0
- package/dist/tools/operations.d.ts +198 -0
- package/dist/tools/operations.js +378 -0
- package/dist/tools/operations.js.map +1 -0
- package/dist/tools/readiness.d.ts +72 -0
- package/dist/tools/readiness.js +160 -0
- package/dist/tools/readiness.js.map +1 -0
- package/dist/ui/dashboard.d.ts +3 -0
- package/dist/ui/dashboard.js +173 -2
- package/dist/ui/dashboard.js.map +1 -1
- package/dist/ui/details.d.ts +35 -1
- package/dist/ui/details.js +103 -2
- package/dist/ui/details.js.map +1 -1
- package/dist/ui/secret.d.ts +8 -0
- package/dist/ui/secret.js +41 -0
- package/dist/ui/secret.js.map +1 -0
- package/dist/ui/status-view.d.ts +1 -0
- package/dist/ui/status-view.js +33 -8
- package/dist/ui/status-view.js.map +1 -1
- package/dist/ui/tool-forms.d.ts +24 -0
- package/dist/ui/tool-forms.js +133 -0
- package/dist/ui/tool-forms.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { PtbkError } from '../common/errors.js';
|
|
3
|
+
import { readTextIfExists, writeFileAtomic } from '../common/fs.js';
|
|
4
|
+
import { ENVIRONMENT_NAME } from '../common/naming.js';
|
|
5
|
+
import { formatIsoWithOffset, systemTimeZone } from '../common/time.js';
|
|
6
|
+
/**
|
|
7
|
+
* The bounded environment-reference notation `${{ env.NAME }}` (optional whitespace inside the delimiters). It is not
|
|
8
|
+
* an expression language: nothing else is evaluated.
|
|
9
|
+
*/
|
|
10
|
+
const REFERENCE_PATTERN = /^\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}$/;
|
|
11
|
+
/**
|
|
12
|
+
* Parses an environment reference; returns the variable name, or `undefined` when the value is not a reference.
|
|
13
|
+
*
|
|
14
|
+
* @private environment references
|
|
15
|
+
*/
|
|
16
|
+
export function parseEnvironmentReference(value) {
|
|
17
|
+
if (typeof value !== 'string')
|
|
18
|
+
return undefined;
|
|
19
|
+
return REFERENCE_PATTERN.exec(value.trim())?.[1];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Canonical reference text of a variable name.
|
|
23
|
+
*
|
|
24
|
+
* @private environment references
|
|
25
|
+
*/
|
|
26
|
+
export function environmentReference(name) {
|
|
27
|
+
if (!ENVIRONMENT_NAME.test(name))
|
|
28
|
+
throw new PtbkError(`"${name}" is not a valid environment-variable name.`, { kind: 'usage', next: ['Use letters, digits and underscores, not starting with a digit.'] });
|
|
29
|
+
return `\${{ env.${name} }}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Path of the project's ignored local environment file.
|
|
33
|
+
*
|
|
34
|
+
* @private environment references
|
|
35
|
+
*/
|
|
36
|
+
export function dotEnvPath(projectRoot) {
|
|
37
|
+
return join(projectRoot, '.env');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pattern of an active assignment (`NAME=value` or `export NAME=value`).
|
|
41
|
+
*/
|
|
42
|
+
const ASSIGNMENT_PATTERN = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;
|
|
43
|
+
/**
|
|
44
|
+
* Unquotes an assignment value (single/double quotes; an unquoted value ends at an inline ` #` comment).
|
|
45
|
+
*/
|
|
46
|
+
function assignmentValue(raw) {
|
|
47
|
+
const value = raw.trim();
|
|
48
|
+
if (value.length >= 2 && ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'")))) {
|
|
49
|
+
const inner = value.slice(1, -1);
|
|
50
|
+
return value.startsWith('"') ? inner.replace(/\\n/g, '\n').replace(/\\"/g, '"').replace(/\\\\/g, '\\') : inner;
|
|
51
|
+
}
|
|
52
|
+
return value.replace(/\s+#.*$/, '');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reads the project's `.env` without executing it.
|
|
56
|
+
*
|
|
57
|
+
* @private environment references
|
|
58
|
+
*/
|
|
59
|
+
export async function readDotEnv(projectRoot) {
|
|
60
|
+
const text = await readTextIfExists(dotEnvPath(projectRoot));
|
|
61
|
+
if (text === undefined)
|
|
62
|
+
return { exists: false, text: '', assignments: [] };
|
|
63
|
+
const assignments = [];
|
|
64
|
+
text.split(/\r?\n/).forEach((line, index) => {
|
|
65
|
+
const match = ASSIGNMENT_PATTERN.exec(line);
|
|
66
|
+
if (match)
|
|
67
|
+
assignments.push({ line: index, name: match[1], value: assignmentValue(match[2] ?? '') });
|
|
68
|
+
});
|
|
69
|
+
return { exists: true, text, assignments };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolves a variable: an explicitly supplied process-environment value takes precedence over the project's `.env`.
|
|
73
|
+
* Duplicate active `.env` assignments with different values are ambiguous (never guessed).
|
|
74
|
+
*
|
|
75
|
+
* @private environment references
|
|
76
|
+
*/
|
|
77
|
+
export function resolveVariable(name, env, dotEnv) {
|
|
78
|
+
const fromProcess = env[name];
|
|
79
|
+
if (fromProcess !== undefined && fromProcess !== '')
|
|
80
|
+
return { name, source: 'environment', value: fromProcess };
|
|
81
|
+
const assignments = dotEnv.assignments.filter((assignment) => assignment.name === name);
|
|
82
|
+
if (new Set(assignments.map((assignment) => assignment.value)).size > 1)
|
|
83
|
+
return { name, source: 'ambiguous' };
|
|
84
|
+
const value = assignments[0]?.value;
|
|
85
|
+
if (value !== undefined && value !== '')
|
|
86
|
+
return { name, source: '.env', value };
|
|
87
|
+
return { name, source: 'missing' };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Human description of where a credential comes from, without its value.
|
|
91
|
+
*
|
|
92
|
+
* @private environment references
|
|
93
|
+
*/
|
|
94
|
+
export function describeCredentialSource(resolved) {
|
|
95
|
+
switch (resolved.source) {
|
|
96
|
+
case 'environment':
|
|
97
|
+
return `${resolved.name} from the process environment`;
|
|
98
|
+
case '.env':
|
|
99
|
+
return `${resolved.name} from the project's .env`;
|
|
100
|
+
case 'ambiguous':
|
|
101
|
+
return `${resolved.name} is assigned several different values in .env (repair needed)`;
|
|
102
|
+
case 'missing':
|
|
103
|
+
return `${resolved.name} is not set (process environment or .env)`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Quotes a value for `.env` when needed.
|
|
108
|
+
*/
|
|
109
|
+
function quoteValue(value) {
|
|
110
|
+
if (/[\r\n]/.test(value))
|
|
111
|
+
throw new PtbkError('Secret values must be a single line.', { kind: 'usage' });
|
|
112
|
+
return /^[A-Za-z0-9_./:@+=,-]*$/.test(value) ? value : `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Applies changes to the project's `.env` non-destructively: every engine-authored addition, replacement and
|
|
116
|
+
* retirement gets an adjacent timestamped comment with its reason; old assignments are commented out, never deleted;
|
|
117
|
+
* unrelated lines, comments and newline conventions stay intact; a repeated identical edit is a no-op.
|
|
118
|
+
*
|
|
119
|
+
* Secret values never appear in the returned notes.
|
|
120
|
+
*
|
|
121
|
+
* @private environment references
|
|
122
|
+
*/
|
|
123
|
+
export async function editDotEnv(projectRoot, changes, audit) {
|
|
124
|
+
const path = dotEnvPath(projectRoot);
|
|
125
|
+
const original = (await readTextIfExists(path)) ?? '';
|
|
126
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
127
|
+
const lines = original === '' ? [] : original.split(/\r?\n/);
|
|
128
|
+
const trailingNewline = original === '' || original.endsWith('\n');
|
|
129
|
+
if (lines.length && lines[lines.length - 1] === '')
|
|
130
|
+
lines.pop();
|
|
131
|
+
const stamp = formatIsoWithOffset(Date.now(), audit.timeZone ?? systemTimeZone());
|
|
132
|
+
const comment = (action) => `# ${stamp} ptbk: ${action} — ${audit.reason} (${audit.operation})`.replace(/[\r\n]+/g, ' ');
|
|
133
|
+
const notes = [];
|
|
134
|
+
let changed = false;
|
|
135
|
+
for (const change of changes) {
|
|
136
|
+
if (!ENVIRONMENT_NAME.test(change.name))
|
|
137
|
+
throw new PtbkError(`"${change.name}" is not a valid environment-variable name.`, { kind: 'usage' });
|
|
138
|
+
const active = lines.map((line, index) => ({ index, match: ASSIGNMENT_PATTERN.exec(line) })).filter((entry) => entry.match?.[1] === change.name);
|
|
139
|
+
if (new Set(active.map((entry) => assignmentValue(entry.match[2] ?? ''))).size > 1) {
|
|
140
|
+
throw new PtbkError(`.env assigns ${change.name} several times with different values.`, {
|
|
141
|
+
kind: 'conflict',
|
|
142
|
+
reason: 'The effective value is ambiguous, so ptbk does not choose a destructive interpretation.',
|
|
143
|
+
effect: 'Nothing was changed in .env or ptbk.json.',
|
|
144
|
+
next: [`Keep exactly one active ${change.name}= line in .env (comment out the others), then retry.`],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (change.kind === 'set') {
|
|
148
|
+
const current = active[0] ? assignmentValue(active[0].match[2] ?? '') : undefined;
|
|
149
|
+
if (current === change.value) {
|
|
150
|
+
notes.push(`${change.name} already holds this value in .env (unchanged).`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const assignment = `${change.name}=${quoteValue(change.value)}`;
|
|
154
|
+
if (active.length) {
|
|
155
|
+
// Replace in place: the old assignment stays, commented out with its explanation, followed by the new one.
|
|
156
|
+
const first = active[0].index;
|
|
157
|
+
const replacement = [comment('commented out the previous value (replaced below)'), `# ${lines[first]}`, comment('added'), assignment];
|
|
158
|
+
for (const entry of active.slice(1).reverse())
|
|
159
|
+
lines.splice(entry.index, 1, comment('commented out a duplicate of the same value'), `# ${lines[entry.index]}`);
|
|
160
|
+
lines.splice(first, 1, ...replacement);
|
|
161
|
+
notes.push(`Replaced ${change.name} in .env (the previous assignment is kept commented out).`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
if (lines.length && lines[lines.length - 1].trim() !== '')
|
|
165
|
+
lines.push('');
|
|
166
|
+
lines.push(comment('added'), assignment);
|
|
167
|
+
notes.push(`Added ${change.name} to .env.`);
|
|
168
|
+
}
|
|
169
|
+
changed = true;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (!active.length)
|
|
173
|
+
continue;
|
|
174
|
+
for (const entry of [...active].reverse())
|
|
175
|
+
lines.splice(entry.index, 1, comment('commented out (no remaining consumer)'), `# ${lines[entry.index]}`);
|
|
176
|
+
notes.push(`Retired ${change.name} in .env (commented out, not deleted).`);
|
|
177
|
+
changed = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!changed)
|
|
181
|
+
return { changed: false, notes };
|
|
182
|
+
const text = `${lines.join(newline)}${trailingNewline || lines.length ? newline : ''}`;
|
|
183
|
+
await writeFileAtomic(path, text, { mode: 0o600 });
|
|
184
|
+
return { changed: true, notes };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Whether an active `.env` assignment was added by ptbk (preceded by its audit comment), which is the only case where
|
|
188
|
+
* proven non-use may retire it.
|
|
189
|
+
*
|
|
190
|
+
* @private environment references
|
|
191
|
+
*/
|
|
192
|
+
export function isEngineManagedAssignment(dotEnv, name) {
|
|
193
|
+
const lines = dotEnv.text.split(/\r?\n/);
|
|
194
|
+
const assignment = dotEnv.assignments.find((entry) => entry.name === name);
|
|
195
|
+
if (!assignment || assignment.line === 0)
|
|
196
|
+
return false;
|
|
197
|
+
return /^# .* ptbk: added — /.test(lines[assignment.line - 1] ?? '');
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/tools/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,iDAAiD,CAAC;AAE5E;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC7C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,IAAI,IAAI,6CAA6C,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,iEAAiE,CAAC,EAAE,CAAC,CAAC;IAC3M,OAAO,YAAY,IAAI,KAAK,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,WAAmB;IAC1C,OAAO,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC;AAqBD;;GAEG;AACH,MAAM,kBA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MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACvF,MAAM,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAc,EAAE,IAAY;IAClE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC3E,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported reasoning/effort selectors (internal spelling; saved canonically as `LOW` … `MAX`).
|
|
3
|
+
*
|
|
4
|
+
* @private shared tool contract
|
|
5
|
+
*/
|
|
6
|
+
export declare const THINKING_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
7
|
+
/**
|
|
8
|
+
* One reasoning/effort selector.
|
|
9
|
+
*
|
|
10
|
+
* @private shared tool contract
|
|
11
|
+
*/
|
|
12
|
+
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Tool categories of `ptbk.json.tools` (fixed enum values).
|
|
15
|
+
*
|
|
16
|
+
* @private shared tool contract
|
|
17
|
+
*/
|
|
18
|
+
export declare const TOOL_TYPES: readonly ["BROWSER", "HARNESS"];
|
|
19
|
+
/**
|
|
20
|
+
* One tool category.
|
|
21
|
+
*
|
|
22
|
+
* @private shared tool contract
|
|
23
|
+
*/
|
|
24
|
+
export type ToolType = (typeof TOOL_TYPES)[number];
|
|
25
|
+
/**
|
|
26
|
+
* Supported browser adapters. `CHROME` uses Google Chrome and, when it is absent, another installed
|
|
27
|
+
* Chrome-compatible browser; `CHROMIUM` and `EDGE` select exactly that browser.
|
|
28
|
+
*
|
|
29
|
+
* @private shared tool contract
|
|
30
|
+
*/
|
|
31
|
+
export declare const BROWSER_VARIANTS: readonly ["CHROME", "CHROMIUM", "EDGE"];
|
|
32
|
+
/**
|
|
33
|
+
* One browser adapter.
|
|
34
|
+
*
|
|
35
|
+
* @private shared tool contract
|
|
36
|
+
*/
|
|
37
|
+
export type BrowserVariant = (typeof BROWSER_VARIANTS)[number];
|
|
38
|
+
/**
|
|
39
|
+
* Supported harness adapters (canonical variants of the harness plugins).
|
|
40
|
+
*
|
|
41
|
+
* @private shared tool contract
|
|
42
|
+
*/
|
|
43
|
+
export declare const HARNESS_VARIANTS: readonly ["OPENAI_CODEX", "CLAUDE_CODE", "GITHUB_COPILOT", "CLINE", "OPENCODE", "GEMINI", "QWEN_CODE"];
|
|
44
|
+
/**
|
|
45
|
+
* One harness adapter.
|
|
46
|
+
*
|
|
47
|
+
* @private shared tool contract
|
|
48
|
+
*/
|
|
49
|
+
export type HarnessVariant = (typeof HARNESS_VARIANTS)[number];
|
|
50
|
+
/**
|
|
51
|
+
* Where a browser tool's profile comes from.
|
|
52
|
+
*
|
|
53
|
+
* - `MANAGED_GLOBAL`: the dedicated Promptbook profile of this OS user (default)
|
|
54
|
+
* - `PROJECT`: an isolated profile in the project's ignored `.ptbk/`
|
|
55
|
+
* - `USER_EXISTING`: the user's ordinary Chrome profile, explicitly selected
|
|
56
|
+
* - `CUSTOM`: an explicit existing profile path
|
|
57
|
+
*
|
|
58
|
+
* @private shared tool contract
|
|
59
|
+
*/
|
|
60
|
+
export declare const PROFILE_SOURCES: readonly ["MANAGED_GLOBAL", "PROJECT", "USER_EXISTING", "CUSTOM"];
|
|
61
|
+
/**
|
|
62
|
+
* One browser profile source.
|
|
63
|
+
*
|
|
64
|
+
* @private shared tool contract
|
|
65
|
+
*/
|
|
66
|
+
export type ProfileSource = (typeof PROFILE_SOURCES)[number];
|
|
67
|
+
/**
|
|
68
|
+
* How a harness instance authenticates: its native account/subscription context or an explicit API key.
|
|
69
|
+
*
|
|
70
|
+
* @private shared tool contract
|
|
71
|
+
*/
|
|
72
|
+
export declare const AUTHENTICATION_MODES: readonly ["NATIVE", "API_KEY"];
|
|
73
|
+
/**
|
|
74
|
+
* One authentication mode.
|
|
75
|
+
*
|
|
76
|
+
* @private shared tool contract
|
|
77
|
+
*/
|
|
78
|
+
export type AuthenticationMode = (typeof AUTHENTICATION_MODES)[number];
|
|
79
|
+
/**
|
|
80
|
+
* Fields every tool record shares.
|
|
81
|
+
*
|
|
82
|
+
* @private shared tool contract
|
|
83
|
+
*/
|
|
84
|
+
type ToolCommon = {
|
|
85
|
+
/** User-editable kebab-case identifier, unique across the project's tools. */
|
|
86
|
+
readonly name: string;
|
|
87
|
+
/** Optional free text (never normalized). */
|
|
88
|
+
readonly description?: string;
|
|
89
|
+
/** Whether the instance is available for new selections (configuration and credentials are retained either way). */
|
|
90
|
+
readonly isEnabled: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* A named browser/profile context.
|
|
94
|
+
*
|
|
95
|
+
* @private shared tool contract
|
|
96
|
+
*/
|
|
97
|
+
export type BrowserToolRecord = ToolCommon & {
|
|
98
|
+
readonly type: 'BROWSER';
|
|
99
|
+
readonly variant: BrowserVariant;
|
|
100
|
+
/** Profile source and, where appropriate, its path (required for CUSTOM). */
|
|
101
|
+
readonly profile: {
|
|
102
|
+
readonly source: ProfileSource;
|
|
103
|
+
readonly path?: string;
|
|
104
|
+
};
|
|
105
|
+
/** Headless mode (independent of the profile source). */
|
|
106
|
+
readonly isHeadless: boolean;
|
|
107
|
+
/** Explicit Chrome-compatible executable (non-secret). */
|
|
108
|
+
readonly executable?: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* A named harness instance (one authentication context of a globally installed integration).
|
|
112
|
+
*
|
|
113
|
+
* @private shared tool contract
|
|
114
|
+
*/
|
|
115
|
+
export type HarnessToolRecord = ToolCommon & {
|
|
116
|
+
readonly type: 'HARNESS';
|
|
117
|
+
readonly variant: HarnessVariant;
|
|
118
|
+
readonly authentication: AuthenticationMode;
|
|
119
|
+
/** `${{ env.NAME }}` reference only (active for API_KEY, inactive metadata for NATIVE). */
|
|
120
|
+
readonly apiKey?: string;
|
|
121
|
+
/** Non-secret reference to a distinct adapter-supported native login context. */
|
|
122
|
+
readonly accountProfile?: string;
|
|
123
|
+
/** Preferred model (provider identifier). */
|
|
124
|
+
readonly model?: string;
|
|
125
|
+
/** Preferred thinking level. */
|
|
126
|
+
readonly thinkingLevel?: ThinkingLevel;
|
|
127
|
+
/** Explicitly known models (supplements the integration's catalog). */
|
|
128
|
+
readonly models?: readonly string[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* One typed tool record of `ptbk.json.tools`.
|
|
132
|
+
*
|
|
133
|
+
* @private shared tool contract
|
|
134
|
+
*/
|
|
135
|
+
export type ToolRecord = BrowserToolRecord | HarnessToolRecord;
|
|
136
|
+
/**
|
|
137
|
+
* Canonical fields of each tool type, in their saved order (used for tolerant key matching and serialization).
|
|
138
|
+
*
|
|
139
|
+
* @private shared tool contract
|
|
140
|
+
*/
|
|
141
|
+
export declare const TOOL_FIELDS: Readonly<Record<ToolType, readonly string[]>>;
|
|
142
|
+
/**
|
|
143
|
+
* Variants of one tool type.
|
|
144
|
+
*
|
|
145
|
+
* @private shared tool contract
|
|
146
|
+
*/
|
|
147
|
+
export declare function variantsOf(type: ToolType): readonly string[];
|
|
148
|
+
/**
|
|
149
|
+
* Internal plugin identifier of a harness variant (`OPENAI_CODEX` → `openai-codex`).
|
|
150
|
+
*
|
|
151
|
+
* @private shared tool contract
|
|
152
|
+
*/
|
|
153
|
+
export declare function harnessPluginId(variant: HarnessVariant): string;
|
|
154
|
+
/**
|
|
155
|
+
* Harness variant of an internal plugin identifier (`openai-codex` → `OPENAI_CODEX`), if supported.
|
|
156
|
+
*
|
|
157
|
+
* @private shared tool contract
|
|
158
|
+
*/
|
|
159
|
+
export declare function harnessVariantOf(pluginId: string): HarnessVariant | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Human label of a tool type.
|
|
162
|
+
*
|
|
163
|
+
* @private shared tool contract
|
|
164
|
+
*/
|
|
165
|
+
export declare function toolTypeLabel(type: ToolType): string;
|
|
166
|
+
/**
|
|
167
|
+
* Human description of a browser profile source.
|
|
168
|
+
*
|
|
169
|
+
* @private shared tool contract
|
|
170
|
+
*/
|
|
171
|
+
export declare function describeProfileSource(source: ProfileSource, path?: string): string;
|
|
172
|
+
/**
|
|
173
|
+
* Enabled tools of one type in array order.
|
|
174
|
+
*
|
|
175
|
+
* @private shared tool contract
|
|
176
|
+
*/
|
|
177
|
+
export declare function enabledToolsOf<T extends ToolType>(tools: readonly ToolRecord[], type: T): Array<Extract<ToolRecord, {
|
|
178
|
+
type: T;
|
|
179
|
+
}>>;
|
|
180
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { canonicalEnumValue } from '../common/naming.js';
|
|
2
|
+
/**
|
|
3
|
+
* Supported reasoning/effort selectors (internal spelling; saved canonically as `LOW` … `MAX`).
|
|
4
|
+
*
|
|
5
|
+
* @private shared tool contract
|
|
6
|
+
*/
|
|
7
|
+
export const THINKING_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
8
|
+
/**
|
|
9
|
+
* Tool categories of `ptbk.json.tools` (fixed enum values).
|
|
10
|
+
*
|
|
11
|
+
* @private shared tool contract
|
|
12
|
+
*/
|
|
13
|
+
export const TOOL_TYPES = ['BROWSER', 'HARNESS'];
|
|
14
|
+
/**
|
|
15
|
+
* Supported browser adapters. `CHROME` uses Google Chrome and, when it is absent, another installed
|
|
16
|
+
* Chrome-compatible browser; `CHROMIUM` and `EDGE` select exactly that browser.
|
|
17
|
+
*
|
|
18
|
+
* @private shared tool contract
|
|
19
|
+
*/
|
|
20
|
+
export const BROWSER_VARIANTS = ['CHROME', 'CHROMIUM', 'EDGE'];
|
|
21
|
+
/**
|
|
22
|
+
* Supported harness adapters (canonical variants of the harness plugins).
|
|
23
|
+
*
|
|
24
|
+
* @private shared tool contract
|
|
25
|
+
*/
|
|
26
|
+
export const HARNESS_VARIANTS = ['OPENAI_CODEX', 'CLAUDE_CODE', 'GITHUB_COPILOT', 'CLINE', 'OPENCODE', 'GEMINI', 'QWEN_CODE'];
|
|
27
|
+
/**
|
|
28
|
+
* Where a browser tool's profile comes from.
|
|
29
|
+
*
|
|
30
|
+
* - `MANAGED_GLOBAL`: the dedicated Promptbook profile of this OS user (default)
|
|
31
|
+
* - `PROJECT`: an isolated profile in the project's ignored `.ptbk/`
|
|
32
|
+
* - `USER_EXISTING`: the user's ordinary Chrome profile, explicitly selected
|
|
33
|
+
* - `CUSTOM`: an explicit existing profile path
|
|
34
|
+
*
|
|
35
|
+
* @private shared tool contract
|
|
36
|
+
*/
|
|
37
|
+
export const PROFILE_SOURCES = ['MANAGED_GLOBAL', 'PROJECT', 'USER_EXISTING', 'CUSTOM'];
|
|
38
|
+
/**
|
|
39
|
+
* How a harness instance authenticates: its native account/subscription context or an explicit API key.
|
|
40
|
+
*
|
|
41
|
+
* @private shared tool contract
|
|
42
|
+
*/
|
|
43
|
+
export const AUTHENTICATION_MODES = ['NATIVE', 'API_KEY'];
|
|
44
|
+
/**
|
|
45
|
+
* Canonical fields of each tool type, in their saved order (used for tolerant key matching and serialization).
|
|
46
|
+
*
|
|
47
|
+
* @private shared tool contract
|
|
48
|
+
*/
|
|
49
|
+
export const TOOL_FIELDS = {
|
|
50
|
+
BROWSER: ['type', 'variant', 'name', 'description', 'isEnabled', 'profile', 'isHeadless', 'executable'],
|
|
51
|
+
HARNESS: ['type', 'variant', 'name', 'description', 'isEnabled', 'authentication', 'apiKey', 'accountProfile', 'model', 'thinkingLevel', 'models'],
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Variants of one tool type.
|
|
55
|
+
*
|
|
56
|
+
* @private shared tool contract
|
|
57
|
+
*/
|
|
58
|
+
export function variantsOf(type) {
|
|
59
|
+
return type === 'BROWSER' ? BROWSER_VARIANTS : HARNESS_VARIANTS;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Internal plugin identifier of a harness variant (`OPENAI_CODEX` → `openai-codex`).
|
|
63
|
+
*
|
|
64
|
+
* @private shared tool contract
|
|
65
|
+
*/
|
|
66
|
+
export function harnessPluginId(variant) {
|
|
67
|
+
return variant.toLowerCase().replace(/_/g, '-');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Harness variant of an internal plugin identifier (`openai-codex` → `OPENAI_CODEX`), if supported.
|
|
71
|
+
*
|
|
72
|
+
* @private shared tool contract
|
|
73
|
+
*/
|
|
74
|
+
export function harnessVariantOf(pluginId) {
|
|
75
|
+
const variant = canonicalEnumValue(pluginId);
|
|
76
|
+
return HARNESS_VARIANTS.includes(variant) ? variant : undefined;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Human label of a tool type.
|
|
80
|
+
*
|
|
81
|
+
* @private shared tool contract
|
|
82
|
+
*/
|
|
83
|
+
export function toolTypeLabel(type) {
|
|
84
|
+
return type === 'BROWSER' ? 'browser' : 'harness';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Human description of a browser profile source.
|
|
88
|
+
*
|
|
89
|
+
* @private shared tool contract
|
|
90
|
+
*/
|
|
91
|
+
export function describeProfileSource(source, path) {
|
|
92
|
+
switch (source) {
|
|
93
|
+
case 'MANAGED_GLOBAL':
|
|
94
|
+
return 'dedicated Promptbook profile shared by your projects';
|
|
95
|
+
case 'PROJECT':
|
|
96
|
+
return 'isolated project profile';
|
|
97
|
+
case 'USER_EXISTING':
|
|
98
|
+
return 'your existing Chrome profile';
|
|
99
|
+
case 'CUSTOM':
|
|
100
|
+
return `custom profile ${path ?? '(path missing)'}`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Enabled tools of one type in array order.
|
|
105
|
+
*
|
|
106
|
+
* @private shared tool contract
|
|
107
|
+
*/
|
|
108
|
+
export function enabledToolsOf(tools, type) {
|
|
109
|
+
return tools.filter((tool) => tool.type === type && tool.isEnabled);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/tools/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AASlF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,CAAU,CAAC;AAS1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAU,CAAC;AASxE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AASvI;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,CAAU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K,gBAAgB;YACjB,OAAO,sDAAsD,CAAC;QAClE,KAAK,SAAS;YACV,OAAO,0BAA0B,CAAC;QACtC,KAAK,eAAe;YAChB,OAAO,8BAA8B,CAAC;QAC1C,KAAK,QAAQ;YACT,OAAO,kBAAkB,IAAI,IAAI,gBAAgB,EAAE,CAAC;IAC5D,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAqB,KAA4B,EAAE,IAAO;IACpF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAA4C,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAClH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ToolRecord } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* One deterministic correction of a noncanonical spelling (never contains secret values).
|
|
4
|
+
*
|
|
5
|
+
* @private tool normalization
|
|
6
|
+
*/
|
|
7
|
+
export type ConfigCorrection = {
|
|
8
|
+
/** Location such as `tools[0].variant`. */
|
|
9
|
+
readonly location: string;
|
|
10
|
+
/** Original spelling. */
|
|
11
|
+
readonly from: string;
|
|
12
|
+
/** Canonical spelling. */
|
|
13
|
+
readonly to: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A problem that canonicalization cannot resolve deterministically (handed to automatic repair).
|
|
17
|
+
*
|
|
18
|
+
* @private tool normalization
|
|
19
|
+
*/
|
|
20
|
+
export type ConfigProblem = {
|
|
21
|
+
/** Location such as `ptbk.json › tools[1].name`. */
|
|
22
|
+
readonly location: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly severity: 'error' | 'warning';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Result of parsing `ptbk.json.tools`.
|
|
28
|
+
*
|
|
29
|
+
* @private tool normalization
|
|
30
|
+
*/
|
|
31
|
+
export type ParsedTools = {
|
|
32
|
+
/** Valid typed records in array order (invalid or colliding entries are excluded, never guessed). */
|
|
33
|
+
readonly tools: readonly ToolRecord[];
|
|
34
|
+
/** The raw array with deterministic corrections applied (unknown fields and invalid entries preserved). */
|
|
35
|
+
readonly canonical: readonly unknown[];
|
|
36
|
+
readonly corrections: readonly ConfigCorrection[];
|
|
37
|
+
readonly problems: readonly ConfigProblem[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Parses and canonicalizes `ptbk.json.tools`: tolerant known keys, enum values and tool names; typed validation of
|
|
41
|
+
* each variant's fields; collisions, unknown variants and inline secrets become problems instead of guesses.
|
|
42
|
+
*
|
|
43
|
+
* @private tool normalization
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseTools(raw: unknown): ParsedTools;
|
|
46
|
+
/**
|
|
47
|
+
* Serializes a typed record canonically, keeping unknown extension fields of its previous raw entry.
|
|
48
|
+
*
|
|
49
|
+
* @private tool normalization
|
|
50
|
+
*/
|
|
51
|
+
export declare function serializeTool(record: ToolRecord, previous?: Readonly<Record<string, unknown>>): Record<string, unknown>;
|