@rlarua/agentteams-cli 0.0.1

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 (50) hide show
  1. package/README.md +428 -0
  2. package/dist/commands/agentConfig.d.ts +4 -0
  3. package/dist/commands/agentConfig.d.ts.map +1 -0
  4. package/dist/commands/agentConfig.js +34 -0
  5. package/dist/commands/agentConfig.js.map +1 -0
  6. package/dist/commands/convention.d.ts +4 -0
  7. package/dist/commands/convention.d.ts.map +1 -0
  8. package/dist/commands/convention.js +106 -0
  9. package/dist/commands/convention.js.map +1 -0
  10. package/dist/commands/dependency.d.ts +4 -0
  11. package/dist/commands/dependency.d.ts.map +1 -0
  12. package/dist/commands/dependency.js +34 -0
  13. package/dist/commands/dependency.js.map +1 -0
  14. package/dist/commands/index.d.ts +2 -0
  15. package/dist/commands/index.d.ts.map +1 -0
  16. package/dist/commands/index.js +295 -0
  17. package/dist/commands/index.js.map +1 -0
  18. package/dist/commands/init.d.ts +16 -0
  19. package/dist/commands/init.d.ts.map +1 -0
  20. package/dist/commands/init.js +77 -0
  21. package/dist/commands/init.js.map +1 -0
  22. package/dist/index.d.ts +3 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +206 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/types/index.d.ts +236 -0
  27. package/dist/types/index.d.ts.map +1 -0
  28. package/dist/types/index.js +6 -0
  29. package/dist/types/index.js.map +1 -0
  30. package/dist/utils/authServer.d.ts +22 -0
  31. package/dist/utils/authServer.d.ts.map +1 -0
  32. package/dist/utils/authServer.js +167 -0
  33. package/dist/utils/authServer.js.map +1 -0
  34. package/dist/utils/config.d.ts +31 -0
  35. package/dist/utils/config.d.ts.map +1 -0
  36. package/dist/utils/config.js +113 -0
  37. package/dist/utils/config.js.map +1 -0
  38. package/dist/utils/env.d.ts +7 -0
  39. package/dist/utils/env.d.ts.map +1 -0
  40. package/dist/utils/env.js +19 -0
  41. package/dist/utils/env.js.map +1 -0
  42. package/dist/utils/errors.d.ts +2 -0
  43. package/dist/utils/errors.d.ts.map +1 -0
  44. package/dist/utils/errors.js +33 -0
  45. package/dist/utils/errors.js.map +1 -0
  46. package/dist/utils/formatter.d.ts +2 -0
  47. package/dist/utils/formatter.d.ts.map +1 -0
  48. package/dist/utils/formatter.js +45 -0
  49. package/dist/utils/formatter.js.map +1 -0
  50. package/package.json +39 -0
@@ -0,0 +1,236 @@
1
+ /**
2
+ * CLI Type Definitions
3
+ * Defines all TypeScript types used across the CLI application
4
+ */
5
+ /**
6
+ * CLI Configuration stored in .agentteams/config.json
7
+ * Contains credentials and project context for API communication
8
+ */
9
+ export interface Config {
10
+ /** Team ID from AgentTeams */
11
+ teamId: string;
12
+ /** Project ID from AgentTeams */
13
+ projectId: string;
14
+ /** Agent name (e.g., "claude-main", "opencode-agent") */
15
+ agentName: string;
16
+ /** API Key for authentication (stored securely) */
17
+ apiKey: string;
18
+ /** API URL (e.g., "http://localhost:3001") */
19
+ apiUrl: string;
20
+ }
21
+ /**
22
+ * OAuth callback result from web authorization flow
23
+ * Extends Config with additional metadata from OAuth callback
24
+ */
25
+ export interface AuthResult extends Config {
26
+ /** Agent config ID from API */
27
+ configId: string;
28
+ /** Agent environment (CLAUDE_CODE, OPENCODE, CODEX) */
29
+ environment: AgentEnvironment;
30
+ /** Convention file content and metadata */
31
+ convention: ConventionFile;
32
+ }
33
+ /**
34
+ * Convention file structure returned from API
35
+ * Contains the convention markdown content and filename
36
+ */
37
+ export interface ConventionFile {
38
+ /** Filename of the convention (e.g., "CLAUDE.md", "AGENTS.md") */
39
+ fileName: string;
40
+ /** Full markdown content of the convention */
41
+ content: string;
42
+ }
43
+ /** Supported agent environments */
44
+ export type AgentEnvironment = "CLAUDE_CODE" | "OPENCODE" | "CODEX";
45
+ /**
46
+ * Agent configuration from API
47
+ * Represents a registered agent in the system
48
+ */
49
+ export interface AgentConfig {
50
+ /** Unique identifier */
51
+ id: string;
52
+ /** Agent name */
53
+ name: string;
54
+ /** Environment type */
55
+ environment: AgentEnvironment;
56
+ /** Creation timestamp (ISO 8601) */
57
+ createdAt: string;
58
+ /** Last update timestamp (ISO 8601) */
59
+ updatedAt: string;
60
+ /** Soft delete timestamp (ISO 8601 or null) */
61
+ deletedAt: string | null;
62
+ /** Whether API key has been generated */
63
+ hasApiKey?: boolean;
64
+ }
65
+ /**
66
+ * Task from API
67
+ * Represents a work item or assignment
68
+ */
69
+ export interface Task {
70
+ /** Unique identifier */
71
+ id: string;
72
+ /** Associated plan ID */
73
+ planId: string;
74
+ /** Task title */
75
+ title: string;
76
+ /** Detailed description */
77
+ description: string;
78
+ /** Current status (e.g., "PENDING", "IN_PROGRESS", "DONE") */
79
+ status: string;
80
+ /** ID of assigned agent/user (null if unassigned) */
81
+ assignedTo: string | null;
82
+ /** Priority level (e.g., "LOW", "MEDIUM", "HIGH") */
83
+ priority: string;
84
+ /** ID of user who created the task */
85
+ createdBy: string;
86
+ /** Creation timestamp (ISO 8601) */
87
+ createdAt: string;
88
+ /** Last update timestamp (ISO 8601) */
89
+ updatedAt: string;
90
+ /** Soft delete timestamp (ISO 8601 or null) */
91
+ deletedAt: string | null;
92
+ }
93
+ /**
94
+ * Task dependency relationship
95
+ * Represents blocking/dependent relationships between tasks
96
+ */
97
+ export interface TaskDependency {
98
+ /** Unique identifier */
99
+ id: string;
100
+ /** ID of task that depends on another */
101
+ dependentTaskId: string;
102
+ /** ID of task that blocks the dependent */
103
+ blockingTaskId: string;
104
+ /** Creation timestamp (ISO 8601) */
105
+ createdAt: string;
106
+ }
107
+ /**
108
+ * Task dependencies container
109
+ * Groups blocking and dependent tasks for a given task
110
+ */
111
+ export interface TaskDependencies {
112
+ /** Tasks that block the current task */
113
+ blocking: Task[];
114
+ /** Tasks that depend on the current task */
115
+ dependents: Task[];
116
+ }
117
+ /**
118
+ * Comment on a task
119
+ * Represents feedback, notes, or status updates
120
+ */
121
+ export interface Comment {
122
+ /** Unique identifier */
123
+ id: string;
124
+ /** Associated task ID */
125
+ taskId: string;
126
+ /** Author identifier */
127
+ author: string;
128
+ /** Comment type (e.g., "NOTE", "FEEDBACK", "STATUS_UPDATE") */
129
+ type: string;
130
+ /** Comment content (markdown supported) */
131
+ content: string;
132
+ /** List of affected file paths */
133
+ affectedFiles: string[];
134
+ /** Creation timestamp (ISO 8601) */
135
+ createdAt: string;
136
+ /** Last update timestamp (ISO 8601) */
137
+ updatedAt: string;
138
+ /** Soft delete timestamp (ISO 8601 or null) */
139
+ deletedAt: string | null;
140
+ }
141
+ /**
142
+ * Completion report for task or work session
143
+ * Captures metrics and details about completed work
144
+ */
145
+ export interface CompletionReport {
146
+ /** Unique identifier */
147
+ id: string;
148
+ /** Project ID */
149
+ projectId: string;
150
+ /** Associated task ID (null if not task-specific) */
151
+ taskId: string | null;
152
+ /** Report title */
153
+ title: string;
154
+ /** Report content (markdown supported) */
155
+ content: string;
156
+ /** Report type (e.g., "TASK_COMPLETION", "SESSION_SUMMARY") */
157
+ reportType: string;
158
+ /** Git commit hash (null if not applicable) */
159
+ commitHash: string | null;
160
+ /** Git commit range start (null if not applicable) */
161
+ commitStart: string | null;
162
+ /** Git commit range end (null if not applicable) */
163
+ commitEnd: string | null;
164
+ /** Git branch name (null if not applicable) */
165
+ branchName: string | null;
166
+ /** Pull request ID (null if not applicable) */
167
+ pullRequestId: string | null;
168
+ /** Duration in seconds (null if not tracked) */
169
+ durationSeconds: number | null;
170
+ /** Number of files modified (null if not tracked) */
171
+ filesModified: number | null;
172
+ /** Number of lines added (null if not tracked) */
173
+ linesAdded: number | null;
174
+ /** Number of lines deleted (null if not tracked) */
175
+ linesDeleted: number | null;
176
+ /** Report status (e.g., "DRAFT", "SUBMITTED", "REVIEWED") */
177
+ status: string;
178
+ /** Quality score 0-100 (null if not scored) */
179
+ qualityScore: number | null;
180
+ /** ID of user who created the report */
181
+ createdBy: string;
182
+ /** Creation timestamp (ISO 8601) */
183
+ createdAt: string;
184
+ /** Last update timestamp (ISO 8601) */
185
+ updatedAt: string;
186
+ /** Soft delete timestamp (ISO 8601 or null) */
187
+ deletedAt: string | null;
188
+ }
189
+ /**
190
+ * Generic API response envelope for single resource
191
+ */
192
+ export interface ApiResponse<T> {
193
+ /** Response data */
194
+ data: T;
195
+ }
196
+ /**
197
+ * Generic API response envelope for list of resources
198
+ */
199
+ export interface ApiListResponse<T> {
200
+ /** Array of resources */
201
+ data: T[];
202
+ /** Total count of resources (for pagination) */
203
+ total?: number;
204
+ /** Current page number (for pagination) */
205
+ page?: number;
206
+ /** Items per page (for pagination) */
207
+ limit?: number;
208
+ }
209
+ /**
210
+ * API error response
211
+ */
212
+ export interface ApiError {
213
+ /** HTTP status code */
214
+ statusCode: number;
215
+ /** Error type/name */
216
+ error: string;
217
+ /** Human-readable error message */
218
+ message: string;
219
+ }
220
+ /**
221
+ * Common CLI output format options
222
+ */
223
+ export type OutputFormat = "json" | "text";
224
+ /**
225
+ * CLI command context
226
+ * Passed to all command handlers
227
+ */
228
+ export interface CliContext {
229
+ /** Loaded configuration */
230
+ config: Config;
231
+ /** Output format preference */
232
+ format: OutputFormat;
233
+ /** Verbose logging enabled */
234
+ verbose?: boolean;
235
+ }
236
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM;IACxC,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAA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AC;IACd,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * CLI Type Definitions
3
+ * Defines all TypeScript types used across the CLI application
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,22 @@
1
+ import { type Server } from 'node:http';
2
+ export type AuthResult = {
3
+ teamId: string;
4
+ projectId: string;
5
+ agentName: string;
6
+ apiKey: string;
7
+ apiUrl: string;
8
+ configId: number;
9
+ environment: string;
10
+ convention: {
11
+ fileName: string;
12
+ content: string;
13
+ };
14
+ };
15
+ type AuthServerResult = {
16
+ server: Server;
17
+ waitForCallback: () => Promise<AuthResult>;
18
+ port: number;
19
+ };
20
+ export declare function startLocalAuthServer(): AuthServerResult;
21
+ export {};
22
+ //# sourceMappingURL=authServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authServer.d.ts","sourceRoot":"","sources":["../../src/utils/authServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAYtD,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwFF,wBAAgB,oBAAoB,IAAI,gBAAgB,CAmHvD"}
@@ -0,0 +1,167 @@
1
+ import { createRequire } from 'node:module';
2
+ import { createServer } from 'node:http';
3
+ import { execFileSync } from 'node:child_process';
4
+ const require = createRequire(import.meta.url);
5
+ const expressModule = require('express');
6
+ const express = expressModule.default ?? expressModule;
7
+ const DEFAULT_OAUTH_PORT = 7777;
8
+ const OAUTH_PORT_MIN = 7777;
9
+ const OAUTH_PORT_MAX = 7790;
10
+ const CALLBACK_TIMEOUT_MS = 60_000;
11
+ function parsePort(value) {
12
+ if (!value) {
13
+ return null;
14
+ }
15
+ const parsedPort = Number.parseInt(value, 10);
16
+ if (Number.isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65535) {
17
+ return null;
18
+ }
19
+ return parsedPort;
20
+ }
21
+ function buildCandidatePorts() {
22
+ const requestedPort = parsePort(process.env.AGENTTEAMS_OAUTH_PORT) ?? DEFAULT_OAUTH_PORT;
23
+ const rangePorts = [];
24
+ for (let port = OAUTH_PORT_MIN; port <= OAUTH_PORT_MAX; port += 1) {
25
+ rangePorts.push(port);
26
+ }
27
+ const uniquePorts = new Set();
28
+ uniquePorts.add(requestedPort);
29
+ for (const port of rangePorts) {
30
+ uniquePorts.add(port);
31
+ }
32
+ return Array.from(uniquePorts.values());
33
+ }
34
+ function isPortAvailableSync(port) {
35
+ const checkScript = [
36
+ 'const net = require("node:net");',
37
+ 'const port = Number(process.argv[1]);',
38
+ 'const server = net.createServer();',
39
+ 'server.once("error", () => process.exit(1));',
40
+ 'server.listen(port, () => {',
41
+ ' server.close(() => process.exit(0));',
42
+ '});',
43
+ ].join(' ');
44
+ try {
45
+ execFileSync(process.execPath, ['-e', checkScript, String(port)], { stdio: 'ignore' });
46
+ return true;
47
+ }
48
+ catch {
49
+ return false;
50
+ }
51
+ }
52
+ function findAvailablePortSync() {
53
+ const candidatePorts = buildCandidatePorts();
54
+ for (const candidatePort of candidatePorts) {
55
+ if (isPortAvailableSync(candidatePort)) {
56
+ return candidatePort;
57
+ }
58
+ }
59
+ throw new Error(`No available OAuth callback port found in ${OAUTH_PORT_MIN}-${OAUTH_PORT_MAX} and requested AGENTTEAMS_OAUTH_PORT.`);
60
+ }
61
+ function isAuthResult(value) {
62
+ if (!value || typeof value !== 'object') {
63
+ return false;
64
+ }
65
+ const candidate = value;
66
+ const convention = candidate.convention;
67
+ return (typeof candidate.teamId === 'string' &&
68
+ typeof candidate.projectId === 'string' &&
69
+ typeof candidate.agentName === 'string' &&
70
+ typeof candidate.apiKey === 'string' &&
71
+ typeof candidate.apiUrl === 'string' &&
72
+ typeof candidate.configId === 'number' &&
73
+ typeof candidate.environment === 'string' &&
74
+ !!convention &&
75
+ typeof convention.fileName === 'string' &&
76
+ typeof convention.content === 'string');
77
+ }
78
+ export function startLocalAuthServer() {
79
+ const port = findAvailablePortSync();
80
+ const app = express();
81
+ app.use(express.json());
82
+ let settled = false;
83
+ let timeoutHandle = null;
84
+ let isWaiting = false;
85
+ let resolveCallback;
86
+ let rejectCallback;
87
+ const callbackPromise = new Promise((resolve, reject) => {
88
+ resolveCallback = resolve;
89
+ rejectCallback = reject;
90
+ });
91
+ const server = createServer(app);
92
+ const stopServer = () => {
93
+ if (!server.listening) {
94
+ return;
95
+ }
96
+ server.close();
97
+ };
98
+ const clearTimeoutHandle = () => {
99
+ if (!timeoutHandle) {
100
+ return;
101
+ }
102
+ clearTimeout(timeoutHandle);
103
+ timeoutHandle = null;
104
+ };
105
+ const resolveAuth = (payload) => {
106
+ if (settled) {
107
+ return;
108
+ }
109
+ settled = true;
110
+ clearTimeoutHandle();
111
+ resolveCallback?.(payload);
112
+ stopServer();
113
+ };
114
+ const rejectAuth = (error) => {
115
+ if (settled) {
116
+ return;
117
+ }
118
+ settled = true;
119
+ clearTimeoutHandle();
120
+ rejectCallback?.(error);
121
+ stopServer();
122
+ };
123
+ app.post('/callback', (request, response) => {
124
+ if (settled) {
125
+ response.status(409).json({ message: 'OAuth callback already processed.' });
126
+ return;
127
+ }
128
+ const payload = request.body;
129
+ if (!isAuthResult(payload)) {
130
+ response.status(400).json({ message: 'Invalid OAuth callback payload.' });
131
+ return;
132
+ }
133
+ response.status(200).json({ success: true });
134
+ resolveAuth(payload);
135
+ });
136
+ server.once('error', (error) => {
137
+ rejectAuth(new Error(error.code === 'EADDRINUSE'
138
+ ? `OAuth callback port ${port} is already in use.`
139
+ : `OAuth callback server failed: ${error.message}`));
140
+ });
141
+ server.once('close', () => {
142
+ if (!settled && isWaiting) {
143
+ rejectAuth(new Error('OAuth callback server closed before receiving callback.'));
144
+ return;
145
+ }
146
+ if (!settled) {
147
+ settled = true;
148
+ clearTimeoutHandle();
149
+ }
150
+ });
151
+ server.listen(port, 'localhost');
152
+ const waitForCallback = () => {
153
+ if (!isWaiting) {
154
+ isWaiting = true;
155
+ timeoutHandle = setTimeout(() => {
156
+ rejectAuth(new Error('OAuth callback timed out after 60 seconds.'));
157
+ }, CALLBACK_TIMEOUT_MS);
158
+ }
159
+ return callbackPromise;
160
+ };
161
+ return {
162
+ server,
163
+ waitForCallback,
164
+ port,
165
+ };
166
+ }
167
+ //# sourceMappingURL=authServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authServer.js","sourceRoot":"","sources":["../../src/utils/authServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;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,qBAAqB;YAClD,CAAC,CAAC,iCAAiC,KAAK,CAAC,OAAO,EAAE,CACrD,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;QACxB,IAAI,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;YAC1B,UAAU,CAAC,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC,CAAC;YACjF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,CAAC;YACf,kBAAkB,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEjC,MAAM,eAAe,GAAG,GAAwB,EAAE;QAChD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,GAAG,IAAI,CAAC;YACjB,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC9B,UAAU,CAAC,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC,CAAC;YACtE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO;QACL,MAAM;QACN,eAAe;QACf,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Config } from "../types/index.js";
2
+ /**
3
+ * Find the nearest .agentteams/config.json by walking up from startDir to root.
4
+ *
5
+ * @param startDir - Directory to start searching from
6
+ * @returns Absolute path to config.json, or null if not found
7
+ */
8
+ export declare function findProjectConfig(startDir: string): string | null;
9
+ /**
10
+ * Load configuration with priority-based merging.
11
+ *
12
+ * Priority (highest → lowest):
13
+ * 1. CLI options (passed as argument)
14
+ * 2. Environment variables (AGENTTEAMS_*)
15
+ * 3. Project config (.agentteams/config.json in nearest ancestor)
16
+ * 4. Global config (~/.agentteams/config.json)
17
+ *
18
+ * @param options - CLI argument overrides (highest priority)
19
+ * @returns Merged Config if all required fields are present, otherwise null
20
+ */
21
+ export declare function loadConfig(options?: Partial<Config>): Config | null;
22
+ /**
23
+ * Save configuration to a JSON file.
24
+ * Creates parent directories if they don't exist.
25
+ *
26
+ * @param configPath - Absolute path to write the config file
27
+ * @param config - Configuration object to persist
28
+ * @throws Error if write fails
29
+ */
30
+ export declare function saveConfig(configPath: string, config: Config): void;
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAsChD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAajE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAgCnE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAQnE"}
@@ -0,0 +1,113 @@
1
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
2
+ import { join, dirname, resolve } from "node:path";
3
+ import { homedir } from "node:os";
4
+ const CONFIG_DIR = ".agentteams";
5
+ const CONFIG_FILE = "config.json";
6
+ function readConfigFile(filePath) {
7
+ try {
8
+ if (!existsSync(filePath))
9
+ return null;
10
+ const raw = readFileSync(filePath, "utf-8");
11
+ return JSON.parse(raw);
12
+ }
13
+ catch {
14
+ return null;
15
+ }
16
+ }
17
+ /**
18
+ * Load config values from environment variables.
19
+ * Only includes fields that have corresponding env vars set.
20
+ *
21
+ * Mapping:
22
+ * AGENTTEAMS_API_KEY → apiKey
23
+ * AGENTTEAMS_API_URL → apiUrl
24
+ * AGENTTEAMS_TEAM_ID → teamId
25
+ * AGENTTEAMS_PROJECT_ID → projectId
26
+ * AGENTTEAMS_AGENT_NAME → agentName
27
+ */
28
+ function loadEnvConfig() {
29
+ const env = {};
30
+ if (process.env.AGENTTEAMS_API_KEY)
31
+ env.apiKey = process.env.AGENTTEAMS_API_KEY;
32
+ if (process.env.AGENTTEAMS_API_URL)
33
+ env.apiUrl = process.env.AGENTTEAMS_API_URL;
34
+ if (process.env.AGENTTEAMS_TEAM_ID)
35
+ env.teamId = process.env.AGENTTEAMS_TEAM_ID;
36
+ if (process.env.AGENTTEAMS_PROJECT_ID)
37
+ env.projectId = process.env.AGENTTEAMS_PROJECT_ID;
38
+ if (process.env.AGENTTEAMS_AGENT_NAME)
39
+ env.agentName = process.env.AGENTTEAMS_AGENT_NAME;
40
+ return env;
41
+ }
42
+ /**
43
+ * Find the nearest .agentteams/config.json by walking up from startDir to root.
44
+ *
45
+ * @param startDir - Directory to start searching from
46
+ * @returns Absolute path to config.json, or null if not found
47
+ */
48
+ export function findProjectConfig(startDir) {
49
+ let current = resolve(startDir);
50
+ while (true) {
51
+ const candidate = join(current, CONFIG_DIR, CONFIG_FILE);
52
+ if (existsSync(candidate))
53
+ return candidate;
54
+ const parent = dirname(current);
55
+ if (parent === current)
56
+ break; // reached filesystem root
57
+ current = parent;
58
+ }
59
+ return null;
60
+ }
61
+ /**
62
+ * Load configuration with priority-based merging.
63
+ *
64
+ * Priority (highest → lowest):
65
+ * 1. CLI options (passed as argument)
66
+ * 2. Environment variables (AGENTTEAMS_*)
67
+ * 3. Project config (.agentteams/config.json in nearest ancestor)
68
+ * 4. Global config (~/.agentteams/config.json)
69
+ *
70
+ * @param options - CLI argument overrides (highest priority)
71
+ * @returns Merged Config if all required fields are present, otherwise null
72
+ */
73
+ export function loadConfig(options) {
74
+ const globalPath = join(homedir(), CONFIG_DIR, CONFIG_FILE);
75
+ const globalConfig = readConfigFile(globalPath) ?? {};
76
+ const projectPath = findProjectConfig(process.cwd());
77
+ const projectConfig = projectPath ? (readConfigFile(projectPath) ?? {}) : {};
78
+ const envConfig = loadEnvConfig();
79
+ const cliOptions = options ?? {};
80
+ const merged = {
81
+ ...globalConfig,
82
+ ...projectConfig,
83
+ ...envConfig,
84
+ ...cliOptions,
85
+ };
86
+ const requiredFields = [
87
+ "teamId",
88
+ "projectId",
89
+ "agentName",
90
+ "apiKey",
91
+ "apiUrl",
92
+ ];
93
+ const hasAllFields = requiredFields.every((field) => typeof merged[field] === "string" && merged[field].length > 0);
94
+ if (!hasAllFields)
95
+ return null;
96
+ return merged;
97
+ }
98
+ /**
99
+ * Save configuration to a JSON file.
100
+ * Creates parent directories if they don't exist.
101
+ *
102
+ * @param configPath - Absolute path to write the config file
103
+ * @param config - Configuration object to persist
104
+ * @throws Error if write fails
105
+ */
106
+ export function saveConfig(configPath, config) {
107
+ const dir = dirname(configPath);
108
+ if (!existsSync(dir)) {
109
+ mkdirSync(dir, { recursive: true });
110
+ }
111
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
112
+ }
113
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,MAAM,UAAU,GAAG,aAAa,CAAC;AACjC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;QACvC,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC5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E,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function validateEnv(): void;
2
+ export declare function normalizeUrl(url: string): string;
3
+ export declare function getApiConfig(): {
4
+ apiKey: string;
5
+ apiUrl: string;
6
+ };
7
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,IAAI,CAQlC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,YAAY;;;EAO3B"}
@@ -0,0 +1,19 @@
1
+ export function validateEnv() {
2
+ if (!process.env.AGENTTEAMS_API_KEY) {
3
+ throw new Error('AGENTTEAMS_API_KEY environment variable is required');
4
+ }
5
+ if (!process.env.AGENTTEAMS_API_URL) {
6
+ throw new Error('AGENTTEAMS_API_URL environment variable is required');
7
+ }
8
+ }
9
+ export function normalizeUrl(url) {
10
+ return url.endsWith('/') ? url.slice(0, -1) : url;
11
+ }
12
+ export function getApiConfig() {
13
+ validateEnv();
14
+ return {
15
+ apiKey: process.env.AGENTTEAMS_API_KEY,
16
+ apiUrl: normalizeUrl(process.env.AGENTTEAMS_API_URL),
17
+ };
18
+ }
19
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,WAAW,EAAE,CAAC;IAEd,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAmB;QACvC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC;KACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function handleError(error: unknown): string;
2
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiClD"}