@a5c-ai/babysitter-sdk 0.0.170 → 0.0.171
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/dist/cli/commands/configure.d.ts +124 -0
- package/dist/cli/commands/configure.d.ts.map +1 -0
- package/dist/cli/commands/configure.js +514 -0
- package/dist/cli/commands/health.d.ts +89 -0
- package/dist/cli/commands/health.d.ts.map +1 -0
- package/dist/cli/commands/health.js +579 -0
- package/dist/cli/commands/hookLog.d.ts +15 -0
- package/dist/cli/commands/hookLog.d.ts.map +1 -0
- package/dist/cli/commands/hookLog.js +288 -0
- package/dist/cli/commands/hookRun.d.ts +19 -0
- package/dist/cli/commands/hookRun.d.ts.map +1 -0
- package/dist/cli/commands/hookRun.js +64 -0
- package/dist/cli/commands/profile.d.ts +26 -0
- package/dist/cli/commands/profile.d.ts.map +1 -0
- package/dist/cli/commands/profile.js +213 -0
- package/dist/cli/commands/runExecuteTasks.d.ts +42 -0
- package/dist/cli/commands/runExecuteTasks.d.ts.map +1 -0
- package/dist/cli/commands/runExecuteTasks.js +377 -0
- package/dist/cli/commands/runIterate.d.ts +2 -1
- package/dist/cli/commands/runIterate.d.ts.map +1 -1
- package/dist/cli/commands/runIterate.js +152 -8
- package/dist/cli/commands/session.d.ts +97 -0
- package/dist/cli/commands/session.d.ts.map +1 -0
- package/dist/cli/commands/session.js +926 -0
- package/dist/cli/commands/skill.d.ts +136 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +997 -0
- package/dist/cli/completionProof.d.ts +4 -0
- package/dist/cli/completionProof.d.ts.map +1 -0
- package/dist/cli/{completionSecret.js → completionProof.js} +7 -7
- package/dist/cli/main.d.ts +15 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +653 -27
- package/dist/cli/resolveInputPath.d.ts +61 -0
- package/dist/cli/resolveInputPath.d.ts.map +1 -0
- package/dist/cli/resolveInputPath.js +188 -0
- package/dist/config/defaults.d.ts +165 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +281 -0
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +35 -0
- package/dist/harness/claudeCode.d.ts +15 -0
- package/dist/harness/claudeCode.d.ts.map +1 -0
- package/dist/harness/claudeCode.js +772 -0
- package/dist/harness/index.d.ts +5 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +14 -0
- package/dist/harness/nullAdapter.d.ts +9 -0
- package/dist/harness/nullAdapter.d.ts.map +1 -0
- package/dist/harness/nullAdapter.js +46 -0
- package/dist/harness/registry.d.ts +35 -0
- package/dist/harness/registry.d.ts.map +1 -0
- package/dist/harness/registry.js +79 -0
- package/dist/harness/types.d.ts +60 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +10 -0
- package/dist/hooks/dispatcher.d.ts +3 -0
- package/dist/hooks/dispatcher.d.ts.map +1 -1
- package/dist/hooks/dispatcher.js +10 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/profiles/index.d.ts +25 -0
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/index.js +40 -0
- package/dist/profiles/projectProfile.d.ts +73 -0
- package/dist/profiles/projectProfile.d.ts.map +1 -0
- package/dist/profiles/projectProfile.js +747 -0
- package/dist/profiles/types.d.ts +586 -0
- package/dist/profiles/types.d.ts.map +1 -0
- package/dist/profiles/types.js +36 -0
- package/dist/profiles/userProfile.d.ts +73 -0
- package/dist/profiles/userProfile.d.ts.map +1 -0
- package/dist/profiles/userProfile.js +547 -0
- package/dist/runtime/constants.d.ts +1 -1
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/createRun.d.ts.map +1 -1
- package/dist/runtime/createRun.js +7 -3
- package/dist/runtime/exceptions.d.ts +186 -3
- package/dist/runtime/exceptions.d.ts.map +1 -1
- package/dist/runtime/exceptions.js +416 -15
- package/dist/runtime/orchestrateIteration.d.ts.map +1 -1
- package/dist/runtime/orchestrateIteration.js +7 -0
- package/dist/runtime/replay/effectIndex.d.ts.map +1 -1
- package/dist/runtime/replay/effectIndex.js +3 -4
- package/dist/runtime/types.d.ts +1 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +30 -0
- package/dist/session/parse.d.ts +45 -0
- package/dist/session/parse.d.ts.map +1 -0
- package/dist/session/parse.js +159 -0
- package/dist/session/types.d.ts +194 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +45 -0
- package/dist/session/write.d.ts +50 -0
- package/dist/session/write.d.ts.map +1 -0
- package/dist/session/write.js +196 -0
- package/dist/storage/createRunDir.d.ts.map +1 -1
- package/dist/storage/createRunDir.js +1 -0
- package/dist/storage/paths.d.ts +5 -1
- package/dist/storage/paths.d.ts.map +1 -1
- package/dist/storage/paths.js +6 -1
- package/dist/storage/types.d.ts +3 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/tasks/kinds/index.d.ts.map +1 -1
- package/dist/tasks/kinds/index.js +6 -1
- package/dist/testing/runHarness.d.ts.map +1 -1
- package/dist/testing/runHarness.js +5 -1
- package/package.json +5 -7
- package/dist/cli/completionSecret.d.ts +0 -4
- package/dist/cli/completionSecret.d.ts.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* configure command - Display and validate SDK configuration
|
|
3
|
+
*
|
|
4
|
+
* This command provides utilities to:
|
|
5
|
+
* - Display current effective configuration (merged defaults + env)
|
|
6
|
+
* - Validate current configuration
|
|
7
|
+
* - Show important paths (runs dir, etc.)
|
|
8
|
+
*
|
|
9
|
+
* Subcommands:
|
|
10
|
+
* - configure show - Display current effective configuration
|
|
11
|
+
* - configure validate - Validate current configuration
|
|
12
|
+
* - configure paths - Show important paths
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Options for the configure command
|
|
16
|
+
*/
|
|
17
|
+
export interface ConfigureOptions {
|
|
18
|
+
/** Output in JSON format for machine consumption */
|
|
19
|
+
json?: boolean;
|
|
20
|
+
/** Show only default values (ignore env overrides) */
|
|
21
|
+
defaultsOnly?: boolean;
|
|
22
|
+
/** Working directory (defaults to cwd) */
|
|
23
|
+
cwd?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration value with source information
|
|
27
|
+
*/
|
|
28
|
+
export interface ConfigValue {
|
|
29
|
+
/** Configuration key name */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Current effective value */
|
|
32
|
+
value: unknown;
|
|
33
|
+
/** Source of the value: "default" or "env" */
|
|
34
|
+
source: "default" | "env";
|
|
35
|
+
/** Environment variable name that can override this value */
|
|
36
|
+
envVar?: string;
|
|
37
|
+
/** Documentation link for this configuration option */
|
|
38
|
+
docLink: string;
|
|
39
|
+
/** Human-readable description */
|
|
40
|
+
description: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of the configure show subcommand
|
|
44
|
+
*/
|
|
45
|
+
export interface ConfigureShowResult {
|
|
46
|
+
/** All configuration values with their sources */
|
|
47
|
+
values: ConfigValue[];
|
|
48
|
+
/** Timestamp of when the configuration was read */
|
|
49
|
+
timestamp: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Result of the configure validate subcommand
|
|
53
|
+
*/
|
|
54
|
+
export interface ConfigureValidateResult {
|
|
55
|
+
/** Whether the configuration is valid */
|
|
56
|
+
valid: boolean;
|
|
57
|
+
/** Validation errors */
|
|
58
|
+
errors: string[];
|
|
59
|
+
/** Validation warnings */
|
|
60
|
+
warnings: string[];
|
|
61
|
+
/** Timestamp of when the validation was performed */
|
|
62
|
+
timestamp: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Path information
|
|
66
|
+
*/
|
|
67
|
+
export interface PathInfo {
|
|
68
|
+
/** Name of the path */
|
|
69
|
+
name: string;
|
|
70
|
+
/** Absolute path value */
|
|
71
|
+
path: string;
|
|
72
|
+
/** Whether the path exists */
|
|
73
|
+
exists: boolean;
|
|
74
|
+
/** Description of what the path is used for */
|
|
75
|
+
description: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Result of the configure paths subcommand
|
|
79
|
+
*/
|
|
80
|
+
export interface ConfigurePathsResult {
|
|
81
|
+
/** All important paths */
|
|
82
|
+
paths: PathInfo[];
|
|
83
|
+
/** Timestamp of when the paths were resolved */
|
|
84
|
+
timestamp: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Execute the "configure show" subcommand
|
|
88
|
+
*/
|
|
89
|
+
export declare function configureShow(options: ConfigureOptions): ConfigureShowResult;
|
|
90
|
+
/**
|
|
91
|
+
* Execute the "configure validate" subcommand
|
|
92
|
+
*/
|
|
93
|
+
export declare function configureValidate(options: ConfigureOptions): ConfigureValidateResult;
|
|
94
|
+
/**
|
|
95
|
+
* Execute the "configure paths" subcommand
|
|
96
|
+
*/
|
|
97
|
+
export declare function configurePaths(options: ConfigureOptions): Promise<ConfigurePathsResult>;
|
|
98
|
+
/**
|
|
99
|
+
* CLI entry point for the configure command
|
|
100
|
+
*
|
|
101
|
+
* @param args - Subcommand arguments (e.g., ["show"], ["validate"], ["paths"])
|
|
102
|
+
* @param options - Parsed CLI options
|
|
103
|
+
* @returns Exit code (0 for success, 1 for failure)
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* // Show current configuration
|
|
108
|
+
* await handleConfigureCommand(["show"], {});
|
|
109
|
+
*
|
|
110
|
+
* // Show configuration in JSON format
|
|
111
|
+
* await handleConfigureCommand(["show"], { json: true });
|
|
112
|
+
*
|
|
113
|
+
* // Show only default values
|
|
114
|
+
* await handleConfigureCommand(["show"], { defaultsOnly: true });
|
|
115
|
+
*
|
|
116
|
+
* // Validate configuration
|
|
117
|
+
* await handleConfigureCommand(["validate"], {});
|
|
118
|
+
*
|
|
119
|
+
* // Show paths
|
|
120
|
+
* await handleConfigureCommand(["paths"], {});
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function handleConfigureCommand(args: string[], options: ConfigureOptions): Promise<number>;
|
|
124
|
+
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/configure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,8CAA8C;IAC9C,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;IAC1B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,wBAAwB;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAsKD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAc5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,uBAAuB,CAWpF;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAkD7F;AAuKD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CAgEjB"}
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* configure command - Display and validate SDK configuration
|
|
4
|
+
*
|
|
5
|
+
* This command provides utilities to:
|
|
6
|
+
* - Display current effective configuration (merged defaults + env)
|
|
7
|
+
* - Validate current configuration
|
|
8
|
+
* - Show important paths (runs dir, etc.)
|
|
9
|
+
*
|
|
10
|
+
* Subcommands:
|
|
11
|
+
* - configure show - Display current effective configuration
|
|
12
|
+
* - configure validate - Validate current configuration
|
|
13
|
+
* - configure paths - Show important paths
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.configureShow = configureShow;
|
|
50
|
+
exports.configureValidate = configureValidate;
|
|
51
|
+
exports.configurePaths = configurePaths;
|
|
52
|
+
exports.handleConfigureCommand = handleConfigureCommand;
|
|
53
|
+
const path = __importStar(require("node:path"));
|
|
54
|
+
const defaults_1 = require("../../config/defaults");
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Color Utilities
|
|
57
|
+
// ============================================================================
|
|
58
|
+
/**
|
|
59
|
+
* ANSI color codes for terminal output
|
|
60
|
+
*/
|
|
61
|
+
const COLORS = {
|
|
62
|
+
reset: "\x1b[0m",
|
|
63
|
+
green: "\x1b[32m",
|
|
64
|
+
red: "\x1b[31m",
|
|
65
|
+
yellow: "\x1b[33m",
|
|
66
|
+
cyan: "\x1b[36m",
|
|
67
|
+
dim: "\x1b[2m",
|
|
68
|
+
bold: "\x1b[1m",
|
|
69
|
+
blue: "\x1b[34m",
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Checks if stdout supports colors
|
|
73
|
+
*/
|
|
74
|
+
function supportsColors() {
|
|
75
|
+
if (process.env.NO_COLOR !== undefined) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (process.env.FORCE_COLOR !== undefined) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (process.stdout && typeof process.stdout.isTTY === "boolean") {
|
|
82
|
+
return process.stdout.isTTY;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Documentation Links
|
|
88
|
+
// ============================================================================
|
|
89
|
+
const DOC_BASE_URL = "https://docs.a5c.ai/sdk/config";
|
|
90
|
+
/**
|
|
91
|
+
* Documentation links for each configuration option
|
|
92
|
+
*/
|
|
93
|
+
const DOC_LINKS = {
|
|
94
|
+
runsDir: `${DOC_BASE_URL}#runs-dir`,
|
|
95
|
+
maxIterations: `${DOC_BASE_URL}#max-iterations`,
|
|
96
|
+
qualityThreshold: `${DOC_BASE_URL}#quality-threshold`,
|
|
97
|
+
timeout: `${DOC_BASE_URL}#timeout`,
|
|
98
|
+
logLevel: `${DOC_BASE_URL}#log-level`,
|
|
99
|
+
allowSecretLogs: `${DOC_BASE_URL}#allow-secret-logs`,
|
|
100
|
+
hookTimeout: `${DOC_BASE_URL}#hook-timeout`,
|
|
101
|
+
nodeTaskTimeout: `${DOC_BASE_URL}#node-task-timeout`,
|
|
102
|
+
clockStepMs: `${DOC_BASE_URL}#clock-step-ms`,
|
|
103
|
+
clockStartMs: `${DOC_BASE_URL}#clock-start-ms`,
|
|
104
|
+
layoutVersion: `${DOC_BASE_URL}#layout-version`,
|
|
105
|
+
largeResultPreviewLimit: `${DOC_BASE_URL}#large-result-preview-limit`,
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Descriptions for each configuration option
|
|
109
|
+
*/
|
|
110
|
+
const DESCRIPTIONS = {
|
|
111
|
+
runsDir: "Directory where run state is stored",
|
|
112
|
+
maxIterations: "Maximum iterations before run terminates",
|
|
113
|
+
qualityThreshold: "Quality threshold percentage (0-100)",
|
|
114
|
+
timeout: "Default task timeout in milliseconds",
|
|
115
|
+
logLevel: "Minimum log level for output",
|
|
116
|
+
allowSecretLogs: "Allow logging of sensitive values",
|
|
117
|
+
hookTimeout: "Hook execution timeout in milliseconds",
|
|
118
|
+
nodeTaskTimeout: "Node task execution timeout in milliseconds",
|
|
119
|
+
clockStepMs: "Clock step interval for testing (ms)",
|
|
120
|
+
clockStartMs: "Clock start epoch for testing (ms)",
|
|
121
|
+
layoutVersion: "Storage layout version identifier",
|
|
122
|
+
largeResultPreviewLimit: "Max size for inline result preview (bytes)",
|
|
123
|
+
};
|
|
124
|
+
// ============================================================================
|
|
125
|
+
// Helper Functions
|
|
126
|
+
// ============================================================================
|
|
127
|
+
/**
|
|
128
|
+
* Get the environment variable name for a config key, if any
|
|
129
|
+
*/
|
|
130
|
+
function getEnvVarForKey(key) {
|
|
131
|
+
const envVarMap = {
|
|
132
|
+
runsDir: "RUNS_DIR",
|
|
133
|
+
maxIterations: "MAX_ITERATIONS",
|
|
134
|
+
qualityThreshold: "QUALITY_THRESHOLD",
|
|
135
|
+
timeout: "TIMEOUT",
|
|
136
|
+
logLevel: "LOG_LEVEL",
|
|
137
|
+
allowSecretLogs: "ALLOW_SECRET_LOGS",
|
|
138
|
+
hookTimeout: "HOOK_TIMEOUT",
|
|
139
|
+
nodeTaskTimeout: "NODE_TASK_TIMEOUT",
|
|
140
|
+
};
|
|
141
|
+
const envVarKey = envVarMap[key];
|
|
142
|
+
if (envVarKey) {
|
|
143
|
+
return defaults_1.CONFIG_ENV_VARS[envVarKey];
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Determine if a config value came from an environment variable
|
|
149
|
+
*/
|
|
150
|
+
function getValueSource(key) {
|
|
151
|
+
const envVar = getEnvVarForKey(key);
|
|
152
|
+
if (envVar && process.env[envVar] !== undefined) {
|
|
153
|
+
return "env";
|
|
154
|
+
}
|
|
155
|
+
return "default";
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Format a value for display
|
|
159
|
+
*/
|
|
160
|
+
function formatValue(value) {
|
|
161
|
+
if (typeof value === "string") {
|
|
162
|
+
return `"${value}"`;
|
|
163
|
+
}
|
|
164
|
+
if (typeof value === "boolean") {
|
|
165
|
+
return value ? "true" : "false";
|
|
166
|
+
}
|
|
167
|
+
if (typeof value === "number") {
|
|
168
|
+
return value.toLocaleString();
|
|
169
|
+
}
|
|
170
|
+
return String(value);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Calculate column widths for table display
|
|
174
|
+
*/
|
|
175
|
+
function calculateColumnWidths(rows) {
|
|
176
|
+
if (rows.length === 0)
|
|
177
|
+
return [];
|
|
178
|
+
const numCols = rows[0].length;
|
|
179
|
+
const widths = new Array(numCols).fill(0);
|
|
180
|
+
// eslint-disable-next-line no-control-regex
|
|
181
|
+
const ansiRegex = /\x1b\[[0-9;]*m/g;
|
|
182
|
+
for (const row of rows) {
|
|
183
|
+
for (let i = 0; i < row.length; i++) {
|
|
184
|
+
// Strip ANSI codes for width calculation
|
|
185
|
+
const stripped = row[i].replace(ansiRegex, "");
|
|
186
|
+
widths[i] = Math.max(widths[i], stripped.length);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return widths;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Pad a string to a specific width, accounting for ANSI codes
|
|
193
|
+
*/
|
|
194
|
+
function padString(str, width) {
|
|
195
|
+
// eslint-disable-next-line no-control-regex
|
|
196
|
+
const stripped = str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
197
|
+
const padding = width - stripped.length;
|
|
198
|
+
return str + " ".repeat(Math.max(0, padding));
|
|
199
|
+
}
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// Subcommand Implementations
|
|
202
|
+
// ============================================================================
|
|
203
|
+
/**
|
|
204
|
+
* Execute the "configure show" subcommand
|
|
205
|
+
*/
|
|
206
|
+
function configureShow(options) {
|
|
207
|
+
const config = options.defaultsOnly ? defaults_1.DEFAULTS : (0, defaults_1.getConfig)();
|
|
208
|
+
const timestamp = new Date().toISOString();
|
|
209
|
+
const values = Object.keys(config).map((key) => ({
|
|
210
|
+
key,
|
|
211
|
+
value: config[key],
|
|
212
|
+
source: options.defaultsOnly ? "default" : getValueSource(key),
|
|
213
|
+
envVar: getEnvVarForKey(key),
|
|
214
|
+
docLink: DOC_LINKS[key],
|
|
215
|
+
description: DESCRIPTIONS[key],
|
|
216
|
+
}));
|
|
217
|
+
return { values, timestamp };
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Execute the "configure validate" subcommand
|
|
221
|
+
*/
|
|
222
|
+
function configureValidate(options) {
|
|
223
|
+
const config = options.defaultsOnly ? defaults_1.DEFAULTS : (0, defaults_1.getConfig)();
|
|
224
|
+
const result = (0, defaults_1.validateConfig)(config);
|
|
225
|
+
const timestamp = new Date().toISOString();
|
|
226
|
+
return {
|
|
227
|
+
valid: result.valid,
|
|
228
|
+
errors: result.errors,
|
|
229
|
+
warnings: result.warnings,
|
|
230
|
+
timestamp,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Execute the "configure paths" subcommand
|
|
235
|
+
*/
|
|
236
|
+
async function configurePaths(options) {
|
|
237
|
+
const cwd = options.cwd ?? process.cwd();
|
|
238
|
+
const config = options.defaultsOnly ? defaults_1.DEFAULTS : (0, defaults_1.getConfig)();
|
|
239
|
+
const timestamp = new Date().toISOString();
|
|
240
|
+
const { promises: fs } = await Promise.resolve().then(() => __importStar(require("node:fs")));
|
|
241
|
+
const pathInfos = [
|
|
242
|
+
{
|
|
243
|
+
name: "runsDir",
|
|
244
|
+
relativePath: config.runsDir,
|
|
245
|
+
description: "Directory where run state and journals are stored",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "a5cDir",
|
|
249
|
+
relativePath: ".a5c",
|
|
250
|
+
description: "Root directory for babysitter data",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "hooksDir",
|
|
254
|
+
relativePath: ".a5c/hooks",
|
|
255
|
+
description: "Directory for runtime hook scripts",
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "processesDir",
|
|
259
|
+
relativePath: ".a5c/processes",
|
|
260
|
+
description: "Directory for process definitions",
|
|
261
|
+
},
|
|
262
|
+
];
|
|
263
|
+
const paths = await Promise.all(pathInfos.map(async (info) => {
|
|
264
|
+
const absolutePath = path.resolve(cwd, info.relativePath);
|
|
265
|
+
let exists = false;
|
|
266
|
+
try {
|
|
267
|
+
await fs.access(absolutePath);
|
|
268
|
+
exists = true;
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
exists = false;
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
name: info.name,
|
|
275
|
+
path: absolutePath,
|
|
276
|
+
exists,
|
|
277
|
+
description: info.description,
|
|
278
|
+
};
|
|
279
|
+
}));
|
|
280
|
+
return { paths, timestamp };
|
|
281
|
+
}
|
|
282
|
+
// ============================================================================
|
|
283
|
+
// Output Formatting
|
|
284
|
+
// ============================================================================
|
|
285
|
+
/**
|
|
286
|
+
* Output configuration values as a formatted table
|
|
287
|
+
*/
|
|
288
|
+
function outputShowTable(result, useColors) {
|
|
289
|
+
console.log("");
|
|
290
|
+
const header = useColors
|
|
291
|
+
? `${COLORS.bold}${COLORS.cyan}Babysitter SDK Configuration${COLORS.reset}`
|
|
292
|
+
: "Babysitter SDK Configuration";
|
|
293
|
+
console.log(header);
|
|
294
|
+
console.log("");
|
|
295
|
+
// Prepare table rows
|
|
296
|
+
const headers = ["Setting", "Value", "Source"];
|
|
297
|
+
const rows = [headers];
|
|
298
|
+
for (const item of result.values) {
|
|
299
|
+
const valueStr = formatValue(item.value);
|
|
300
|
+
const sourceStr = item.source === "env"
|
|
301
|
+
? useColors
|
|
302
|
+
? `${COLORS.green}env${COLORS.reset}`
|
|
303
|
+
: "env"
|
|
304
|
+
: useColors
|
|
305
|
+
? `${COLORS.dim}default${COLORS.reset}`
|
|
306
|
+
: "default";
|
|
307
|
+
rows.push([item.key, valueStr, sourceStr]);
|
|
308
|
+
}
|
|
309
|
+
// Calculate column widths
|
|
310
|
+
const widths = calculateColumnWidths(rows);
|
|
311
|
+
// Print header
|
|
312
|
+
const headerRow = headers.map((h, i) => padString(useColors ? `${COLORS.bold}${h}${COLORS.reset}` : h, widths[i]));
|
|
313
|
+
console.log(" " + headerRow.join(" "));
|
|
314
|
+
// Print separator
|
|
315
|
+
const separator = widths.map((w) => "-".repeat(w)).join(" ");
|
|
316
|
+
console.log(" " + (useColors ? `${COLORS.dim}${separator}${COLORS.reset}` : separator));
|
|
317
|
+
// Print data rows
|
|
318
|
+
for (let i = 1; i < rows.length; i++) {
|
|
319
|
+
const row = rows[i].map((cell, j) => padString(cell, widths[j]));
|
|
320
|
+
console.log(" " + row.join(" "));
|
|
321
|
+
}
|
|
322
|
+
console.log("");
|
|
323
|
+
// Print environment variable hints
|
|
324
|
+
const envOverridden = result.values.filter((v) => v.source === "env");
|
|
325
|
+
if (envOverridden.length > 0) {
|
|
326
|
+
const envHeader = useColors
|
|
327
|
+
? `${COLORS.cyan}Environment Overrides:${COLORS.reset}`
|
|
328
|
+
: "Environment Overrides:";
|
|
329
|
+
console.log(envHeader);
|
|
330
|
+
for (const item of envOverridden) {
|
|
331
|
+
console.log(` ${item.envVar} = ${formatValue(item.value)}`);
|
|
332
|
+
}
|
|
333
|
+
console.log("");
|
|
334
|
+
}
|
|
335
|
+
// Print doc link hint
|
|
336
|
+
const docHint = useColors
|
|
337
|
+
? `${COLORS.dim}Documentation: ${DOC_BASE_URL}${COLORS.reset}`
|
|
338
|
+
: `Documentation: ${DOC_BASE_URL}`;
|
|
339
|
+
console.log(docHint);
|
|
340
|
+
console.log("");
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Output validation results
|
|
344
|
+
*/
|
|
345
|
+
function outputValidateResult(result, useColors) {
|
|
346
|
+
console.log("");
|
|
347
|
+
const statusIcon = result.valid
|
|
348
|
+
? useColors
|
|
349
|
+
? `${COLORS.green}\u2713${COLORS.reset}`
|
|
350
|
+
: "[PASS]"
|
|
351
|
+
: useColors
|
|
352
|
+
? `${COLORS.red}\u2717${COLORS.reset}`
|
|
353
|
+
: "[FAIL]";
|
|
354
|
+
const statusText = result.valid ? "Configuration is valid" : "Configuration has errors";
|
|
355
|
+
const header = useColors
|
|
356
|
+
? `${COLORS.bold}${statusIcon} ${statusText}${COLORS.reset}`
|
|
357
|
+
: `${statusIcon} ${statusText}`;
|
|
358
|
+
console.log(header);
|
|
359
|
+
console.log("");
|
|
360
|
+
if (result.errors.length > 0) {
|
|
361
|
+
const errHeader = useColors
|
|
362
|
+
? `${COLORS.red}${COLORS.bold}Errors:${COLORS.reset}`
|
|
363
|
+
: "Errors:";
|
|
364
|
+
console.log(errHeader);
|
|
365
|
+
for (const err of result.errors) {
|
|
366
|
+
const bullet = useColors ? `${COLORS.red}\u2022${COLORS.reset}` : "-";
|
|
367
|
+
console.log(` ${bullet} ${err}`);
|
|
368
|
+
}
|
|
369
|
+
console.log("");
|
|
370
|
+
}
|
|
371
|
+
if (result.warnings.length > 0) {
|
|
372
|
+
const warnHeader = useColors
|
|
373
|
+
? `${COLORS.yellow}${COLORS.bold}Warnings:${COLORS.reset}`
|
|
374
|
+
: "Warnings:";
|
|
375
|
+
console.log(warnHeader);
|
|
376
|
+
for (const warn of result.warnings) {
|
|
377
|
+
const bullet = useColors ? `${COLORS.yellow}\u2022${COLORS.reset}` : "-";
|
|
378
|
+
console.log(` ${bullet} ${warn}`);
|
|
379
|
+
}
|
|
380
|
+
console.log("");
|
|
381
|
+
}
|
|
382
|
+
if (result.valid && result.warnings.length === 0) {
|
|
383
|
+
const msg = useColors
|
|
384
|
+
? `${COLORS.dim}All configuration values are within valid ranges.${COLORS.reset}`
|
|
385
|
+
: "All configuration values are within valid ranges.";
|
|
386
|
+
console.log(msg);
|
|
387
|
+
console.log("");
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Output path information
|
|
392
|
+
*/
|
|
393
|
+
function outputPathsResult(result, useColors) {
|
|
394
|
+
console.log("");
|
|
395
|
+
const header = useColors
|
|
396
|
+
? `${COLORS.bold}${COLORS.cyan}Babysitter SDK Paths${COLORS.reset}`
|
|
397
|
+
: "Babysitter SDK Paths";
|
|
398
|
+
console.log(header);
|
|
399
|
+
console.log("");
|
|
400
|
+
for (const pathInfo of result.paths) {
|
|
401
|
+
const existsIcon = pathInfo.exists
|
|
402
|
+
? useColors
|
|
403
|
+
? `${COLORS.green}\u2713${COLORS.reset}`
|
|
404
|
+
: "[EXISTS]"
|
|
405
|
+
: useColors
|
|
406
|
+
? `${COLORS.yellow}\u2717${COLORS.reset}`
|
|
407
|
+
: "[MISSING]";
|
|
408
|
+
const nameStr = useColors
|
|
409
|
+
? `${COLORS.bold}${pathInfo.name}${COLORS.reset}`
|
|
410
|
+
: pathInfo.name;
|
|
411
|
+
console.log(` ${existsIcon} ${nameStr}`);
|
|
412
|
+
console.log(` Path: ${pathInfo.path}`);
|
|
413
|
+
const descStr = useColors
|
|
414
|
+
? `${COLORS.dim}${pathInfo.description}${COLORS.reset}`
|
|
415
|
+
: pathInfo.description;
|
|
416
|
+
console.log(` ${descStr}`);
|
|
417
|
+
console.log("");
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// ============================================================================
|
|
421
|
+
// Main Command Handler
|
|
422
|
+
// ============================================================================
|
|
423
|
+
/**
|
|
424
|
+
* CLI entry point for the configure command
|
|
425
|
+
*
|
|
426
|
+
* @param args - Subcommand arguments (e.g., ["show"], ["validate"], ["paths"])
|
|
427
|
+
* @param options - Parsed CLI options
|
|
428
|
+
* @returns Exit code (0 for success, 1 for failure)
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* // Show current configuration
|
|
433
|
+
* await handleConfigureCommand(["show"], {});
|
|
434
|
+
*
|
|
435
|
+
* // Show configuration in JSON format
|
|
436
|
+
* await handleConfigureCommand(["show"], { json: true });
|
|
437
|
+
*
|
|
438
|
+
* // Show only default values
|
|
439
|
+
* await handleConfigureCommand(["show"], { defaultsOnly: true });
|
|
440
|
+
*
|
|
441
|
+
* // Validate configuration
|
|
442
|
+
* await handleConfigureCommand(["validate"], {});
|
|
443
|
+
*
|
|
444
|
+
* // Show paths
|
|
445
|
+
* await handleConfigureCommand(["paths"], {});
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
async function handleConfigureCommand(args, options) {
|
|
449
|
+
const subcommand = args[0] ?? "show";
|
|
450
|
+
const useColors = !options.json && supportsColors();
|
|
451
|
+
try {
|
|
452
|
+
switch (subcommand) {
|
|
453
|
+
case "show": {
|
|
454
|
+
const result = configureShow(options);
|
|
455
|
+
if (options.json) {
|
|
456
|
+
console.log(JSON.stringify(result, null, 2));
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
outputShowTable(result, useColors);
|
|
460
|
+
}
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
case "validate": {
|
|
464
|
+
const result = configureValidate(options);
|
|
465
|
+
if (options.json) {
|
|
466
|
+
console.log(JSON.stringify(result, null, 2));
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
outputValidateResult(result, useColors);
|
|
470
|
+
}
|
|
471
|
+
return result.valid ? 0 : 1;
|
|
472
|
+
}
|
|
473
|
+
case "paths": {
|
|
474
|
+
const result = await configurePaths(options);
|
|
475
|
+
if (options.json) {
|
|
476
|
+
console.log(JSON.stringify(result, null, 2));
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
outputPathsResult(result, useColors);
|
|
480
|
+
}
|
|
481
|
+
return 0;
|
|
482
|
+
}
|
|
483
|
+
default: {
|
|
484
|
+
const errorMsg = `Unknown subcommand: ${subcommand}`;
|
|
485
|
+
if (options.json) {
|
|
486
|
+
console.log(JSON.stringify({ error: errorMsg }, null, 2));
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
console.error(useColors ? `${COLORS.red}Error:${COLORS.reset} ${errorMsg}` : `Error: ${errorMsg}`);
|
|
490
|
+
console.error("");
|
|
491
|
+
console.error("Available subcommands:");
|
|
492
|
+
console.error(" show Display current effective configuration");
|
|
493
|
+
console.error(" validate Validate current configuration");
|
|
494
|
+
console.error(" paths Show important paths");
|
|
495
|
+
console.error("");
|
|
496
|
+
console.error("Options:");
|
|
497
|
+
console.error(" --json Output in JSON format");
|
|
498
|
+
console.error(" --defaults-only Show only default values (ignore env overrides)");
|
|
499
|
+
}
|
|
500
|
+
return 1;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
506
|
+
if (options.json) {
|
|
507
|
+
console.log(JSON.stringify({ error: errorMsg }, null, 2));
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
console.error(useColors ? `${COLORS.red}Error:${COLORS.reset} ${errorMsg}` : `Error: ${errorMsg}`);
|
|
511
|
+
}
|
|
512
|
+
return 1;
|
|
513
|
+
}
|
|
514
|
+
}
|