teamshare-bridge 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/daemon.js +239 -8
- package/dist/bridge/daemon.js.map +1 -1
- package/dist/bridge/index.js +10 -0
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/local-server.d.ts +6 -1
- package/dist/bridge/local-server.js +24 -0
- package/dist/bridge/local-server.js.map +1 -1
- package/dist/bridge/protocol.js +33 -4
- package/dist/bridge/protocol.js.map +1 -1
- package/dist/bridge/spawn.d.ts +20 -4
- package/dist/bridge/spawn.js +93 -29
- package/dist/bridge/spawn.js.map +1 -1
- package/dist/cli/index.js +1102 -64
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/api.d.ts +203 -5
- package/dist/lib/api.js +144 -3
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/chat-reply.d.ts +22 -2
- package/dist/lib/chat-reply.js +139 -67
- package/dist/lib/chat-reply.js.map +1 -1
- package/dist/lib/config.d.ts +103 -0
- package/dist/lib/config.js +272 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/doc-reply.d.ts +11 -0
- package/dist/lib/doc-reply.js +18 -34
- package/dist/lib/doc-reply.js.map +1 -1
- package/dist/lib/harness.d.ts +38 -0
- package/dist/lib/harness.js +139 -0
- package/dist/lib/harness.js.map +1 -0
- package/dist/lib/llm.d.ts +30 -2
- package/dist/lib/llm.js +284 -30
- package/dist/lib/llm.js.map +1 -1
- package/dist/lib/lock.d.ts +1 -1
- package/dist/lib/models.d.ts +11 -0
- package/dist/lib/models.js +30 -1
- package/dist/lib/models.js.map +1 -1
- package/dist/lib/orchestrator/client.d.ts +27 -0
- package/dist/lib/orchestrator/client.js +135 -0
- package/dist/lib/orchestrator/client.js.map +1 -0
- package/dist/lib/orchestrator/index.d.ts +5 -0
- package/dist/lib/orchestrator/index.js +17 -0
- package/dist/lib/orchestrator/index.js.map +1 -0
- package/dist/lib/orchestrator/runner.d.ts +18 -0
- package/dist/lib/orchestrator/runner.js +177 -0
- package/dist/lib/orchestrator/runner.js.map +1 -0
- package/dist/lib/orchestrator/worktree.d.ts +43 -0
- package/dist/lib/orchestrator/worktree.js +243 -0
- package/dist/lib/orchestrator/worktree.js.map +1 -0
- package/dist/lib/session-stream.d.ts +1 -1
- package/dist/lib/skills.d.ts +21 -0
- package/dist/lib/skills.js +80 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/usage.d.ts +52 -0
- package/dist/lib/usage.js +69 -0
- package/dist/lib/usage.js.map +1 -0
- package/package.json +3 -1
- package/skills/teamshare-auth-rbac/SKILL.md +79 -0
- package/skills/teamshare-cdd/SKILL.md +145 -0
- package/skills/teamshare-modularity/SKILL.md +92 -0
- package/tools/usage_report.py +223 -0
package/dist/lib/models.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* three in sync (see the docs for the 3-step update process).
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DEFAULT_LLM_BASE_URL = exports.MODEL_PROVIDERS = exports.MODEL_BASE_URLS = void 0;
|
|
12
|
+
exports.DEFAULT_LLM_BASE_URL = exports.HARNESS_NATIVE_PROVIDERS = exports.MODEL_PROVIDERS = exports.MODEL_BASE_URLS = void 0;
|
|
13
13
|
exports.resolveModel = resolveModel;
|
|
14
|
+
exports.getHarnessFallbackModel = getHarnessFallbackModel;
|
|
14
15
|
exports.MODEL_BASE_URLS = {
|
|
15
16
|
gemini: 'https://generativelanguage.googleapis.com/v1beta/openai',
|
|
16
17
|
deepseek: 'https://api.deepseek.com',
|
|
@@ -21,11 +22,16 @@ exports.MODEL_BASE_URLS = {
|
|
|
21
22
|
};
|
|
22
23
|
/** Provider keys accepted by the catalog (for validation/docs). */
|
|
23
24
|
exports.MODEL_PROVIDERS = Object.keys(exports.MODEL_BASE_URLS);
|
|
25
|
+
/** Providers that are harness-native (only work via opencode/claude CLI, not --self). */
|
|
26
|
+
exports.HARNESS_NATIVE_PROVIDERS = new Set(['opencode-go']);
|
|
24
27
|
/** Default OpenAI-compatible base when nothing else is configured. */
|
|
25
28
|
exports.DEFAULT_LLM_BASE_URL = 'https://api.openai.com/v1';
|
|
29
|
+
/** Default model to use when opencode-go is detected but no agent setting exists. */
|
|
30
|
+
const OPENCODE_GO_DEFAULT = 'opencode-go:deepseek-v4-flash';
|
|
26
31
|
/**
|
|
27
32
|
* Resolves a model spec to (baseUrl, model):
|
|
28
33
|
* - `provider:model` (e.g. "gemini:gemini-2.5-flash") -> catalog base URL.
|
|
34
|
+
* - `opencode-go:*` -> harness-only flag (caller must use opencode harness, not --self).
|
|
29
35
|
* - Anything else (legacy "deepseek-chat") -> env LLM_BASE_URL default,
|
|
30
36
|
* preserving the pre-catalog behavior.
|
|
31
37
|
* Precedence for the base URL: LLM_BASE_URL env > catalog provider URL.
|
|
@@ -34,18 +40,41 @@ function resolveModel(spec, envBaseUrl) {
|
|
|
34
40
|
const colon = spec.indexOf(':');
|
|
35
41
|
const provider = colon > 0 ? spec.slice(0, colon) : '';
|
|
36
42
|
const modelId = colon > 0 ? spec.slice(colon + 1) : spec;
|
|
43
|
+
// Harness-native providers (opencode-go) cannot be used with --self.
|
|
44
|
+
// The caller must detect harnessOnly and use the opencode harness instead.
|
|
45
|
+
if (exports.HARNESS_NATIVE_PROVIDERS.has(provider)) {
|
|
46
|
+
return {
|
|
47
|
+
baseUrl: envBaseUrl ?? exports.DEFAULT_LLM_BASE_URL,
|
|
48
|
+
model: spec,
|
|
49
|
+
catalogued: true,
|
|
50
|
+
harnessOnly: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
37
53
|
const catalogUrl = exports.MODEL_BASE_URLS[provider];
|
|
38
54
|
if (catalogUrl) {
|
|
39
55
|
return {
|
|
40
56
|
baseUrl: envBaseUrl ?? catalogUrl,
|
|
41
57
|
model: modelId,
|
|
42
58
|
catalogued: true,
|
|
59
|
+
harnessOnly: false,
|
|
43
60
|
};
|
|
44
61
|
}
|
|
45
62
|
return {
|
|
46
63
|
baseUrl: envBaseUrl ?? exports.DEFAULT_LLM_BASE_URL,
|
|
47
64
|
model: spec,
|
|
48
65
|
catalogued: false,
|
|
66
|
+
harnessOnly: false,
|
|
49
67
|
};
|
|
50
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the fallback model for opencode-go providers.
|
|
71
|
+
* When opencode-go is detected and --self cannot be used,
|
|
72
|
+
* this returns the agent's configured model or the default harness model.
|
|
73
|
+
*/
|
|
74
|
+
function getHarnessFallbackModel(agentModel) {
|
|
75
|
+
if (agentModel && !exports.HARNESS_NATIVE_PROVIDERS.has(agentModel.split(':')[0])) {
|
|
76
|
+
return agentModel;
|
|
77
|
+
}
|
|
78
|
+
return OPENCODE_GO_DEFAULT;
|
|
79
|
+
}
|
|
51
80
|
//# sourceMappingURL=models.js.map
|
package/dist/lib/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/lib/models.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/lib/models.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA0CH,oCA+BC;AAOD,0DAKC;AAnFY,QAAA,eAAe,GAA2B;IACrD,MAAM,EAAE,yDAAyD;IACjE,QAAQ,EAAE,0BAA0B;IACpC,MAAM,EAAE,2BAA2B;IACnC,IAAI,EAAE,gCAAgC;IACtC,UAAU,EAAE,8BAA8B;IAC1C,OAAO,EAAE,2BAA2B;CACrC,CAAC;AAEF,mEAAmE;AACtD,QAAA,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC;AAE5D,yFAAyF;AAC5E,QAAA,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEjE,sEAAsE;AACzD,QAAA,oBAAoB,G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,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class OrchestratorClient {
|
|
2
|
+
private socket;
|
|
3
|
+
private readonly pending;
|
|
4
|
+
private readonly apiKey;
|
|
5
|
+
private readonly apiUrl;
|
|
6
|
+
constructor(apiKey: string, apiUrl: string);
|
|
7
|
+
/**
|
|
8
|
+
* Connect to the /orchestrator WS namespace.
|
|
9
|
+
*/
|
|
10
|
+
connect(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Disconnect from the WS.
|
|
13
|
+
*/
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Send a command and wait for the result.
|
|
17
|
+
*/
|
|
18
|
+
sendCommand(event: string, payload: Record<string, unknown>, timeoutMs?: number): Promise<Record<string, unknown>>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a pending command by its id.
|
|
21
|
+
*/
|
|
22
|
+
private resolvePending;
|
|
23
|
+
/**
|
|
24
|
+
* Check if connected.
|
|
25
|
+
*/
|
|
26
|
+
get connected(): boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrchestratorClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* OrchestratorClient: WS connection to the backend /orchestrator namespace.
|
|
6
|
+
* Receives commands (git, verify, worktree) and returns results.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the daemon.ts reconnect pattern for resilience.
|
|
9
|
+
*/
|
|
10
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
11
|
+
const config_1 = require("../config");
|
|
12
|
+
const log = {
|
|
13
|
+
info: (msg) => console.log(`[orchestrator-client] ${msg}`),
|
|
14
|
+
warn: (msg) => console.warn(`[orchestrator-client] ${msg}`),
|
|
15
|
+
error: (msg) => console.error(`[orchestrator-client] ${msg}`),
|
|
16
|
+
};
|
|
17
|
+
class OrchestratorClient {
|
|
18
|
+
socket = null;
|
|
19
|
+
pending = new Map();
|
|
20
|
+
apiKey;
|
|
21
|
+
apiUrl;
|
|
22
|
+
constructor(apiKey, apiUrl) {
|
|
23
|
+
this.apiKey = apiKey;
|
|
24
|
+
this.apiUrl = apiUrl;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Connect to the /orchestrator WS namespace.
|
|
28
|
+
*/
|
|
29
|
+
connect() {
|
|
30
|
+
const config = (0, config_1.loadConfig)();
|
|
31
|
+
const wsUrl = process.env.TEAMSHARE_WS_URL ?? 'ws://localhost:4000';
|
|
32
|
+
this.socket = (0, socket_io_client_1.io)(`${wsUrl}/orchestrator`, {
|
|
33
|
+
auth: { apiKey: this.apiKey },
|
|
34
|
+
transports: ['websocket'],
|
|
35
|
+
reconnection: true,
|
|
36
|
+
reconnectionDelay: 2000,
|
|
37
|
+
reconnectionDelayMax: 30000,
|
|
38
|
+
});
|
|
39
|
+
this.socket.on('connect', () => {
|
|
40
|
+
log.info('Connected to /orchestrator');
|
|
41
|
+
});
|
|
42
|
+
this.socket.on('disconnect', (reason) => {
|
|
43
|
+
log.warn(`Disconnected from /orchestrator: ${reason}`);
|
|
44
|
+
});
|
|
45
|
+
this.socket.on('connect_error', (err) => {
|
|
46
|
+
log.error(`Connection error: ${err.message}`);
|
|
47
|
+
});
|
|
48
|
+
// Register handlers for all result events
|
|
49
|
+
const resultEvents = [
|
|
50
|
+
'orchestrator:verify-result',
|
|
51
|
+
'orchestrator:worktree-created',
|
|
52
|
+
'orchestrator:worktree-removed',
|
|
53
|
+
'orchestrator:git-status-result',
|
|
54
|
+
'orchestrator:git-commit-result',
|
|
55
|
+
'orchestrator:git-merge-result',
|
|
56
|
+
'orchestrator:repo-context-result',
|
|
57
|
+
];
|
|
58
|
+
for (const event of resultEvents) {
|
|
59
|
+
this.socket.on(event, (data) => {
|
|
60
|
+
this.resolvePending(data.cmdId, data);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Progress events (not correlated to commands)
|
|
64
|
+
this.socket.on('orchestrator:progress', (data) => {
|
|
65
|
+
log.info(`Progress: ${data.taskId} - ${data.message}`);
|
|
66
|
+
});
|
|
67
|
+
// Agent capacity events
|
|
68
|
+
this.socket.on('orchestrator:agent-ready', (data) => {
|
|
69
|
+
log.info(`Agent ready: ${data.agentId}`);
|
|
70
|
+
});
|
|
71
|
+
this.socket.on('orchestrator:agent-busy', (data) => {
|
|
72
|
+
log.info(`Agent busy: ${data.agentId} on ${data.taskId}`);
|
|
73
|
+
});
|
|
74
|
+
this.socket.on('orchestrator:agent-idle', (data) => {
|
|
75
|
+
log.info(`Agent idle: ${data.agentId}`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Disconnect from the WS.
|
|
80
|
+
*/
|
|
81
|
+
disconnect() {
|
|
82
|
+
if (this.socket) {
|
|
83
|
+
this.socket.disconnect();
|
|
84
|
+
this.socket = null;
|
|
85
|
+
}
|
|
86
|
+
// Reject all pending commands
|
|
87
|
+
for (const [id, cmd] of this.pending) {
|
|
88
|
+
cmd.reject(new Error('Client disconnected'));
|
|
89
|
+
clearTimeout(cmd.timeout);
|
|
90
|
+
}
|
|
91
|
+
this.pending.clear();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Send a command and wait for the result.
|
|
95
|
+
*/
|
|
96
|
+
async sendCommand(event, payload, timeoutMs = 60_000) {
|
|
97
|
+
if (!this.socket?.connected) {
|
|
98
|
+
throw new Error('Not connected to orchestrator');
|
|
99
|
+
}
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const cmdId = `cmd_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
102
|
+
const timeout = setTimeout(() => {
|
|
103
|
+
this.pending.delete(cmdId);
|
|
104
|
+
reject(new Error(`Command ${event} timed out after ${timeoutMs}ms`));
|
|
105
|
+
}, timeoutMs);
|
|
106
|
+
this.pending.set(cmdId, {
|
|
107
|
+
resolve: resolve,
|
|
108
|
+
reject,
|
|
109
|
+
timeout,
|
|
110
|
+
});
|
|
111
|
+
this.socket.emit(event, { cmdId, ...payload });
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolve a pending command by its id.
|
|
116
|
+
*/
|
|
117
|
+
resolvePending(cmdId, data) {
|
|
118
|
+
const pending = this.pending.get(cmdId);
|
|
119
|
+
if (!pending) {
|
|
120
|
+
log.warn(`No pending command for ${cmdId}`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
clearTimeout(pending.timeout);
|
|
124
|
+
this.pending.delete(cmdId);
|
|
125
|
+
pending.resolve(data);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check if connected.
|
|
129
|
+
*/
|
|
130
|
+
get connected() {
|
|
131
|
+
return this.socket?.connected ?? false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.OrchestratorClient = OrchestratorClient;
|
|
135
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/orchestrator/client.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,uDAA8C;AAC9C,sCAAuC;AAEvC,MAAM,GAAG,GAAG;IACV,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,EAAE,CAAC;IAClE,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;IACnE,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC;CACtE,CAAC;AAaF,MA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AAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,KAAa,EAAE,IAA6B;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,GAAG,CAAC,IAAI,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;YAC5C,OAAO;QACT,CAAC;QAED,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,EAAE,SAAS,IAAI,KAAK,CAAC;IACzC,CAAC;CACF;AA7ID,gDA6IC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { OrchestratorClient } from './client';
|
|
2
|
+
export { createWorktree, removeWorktree, gitStatus, gitCommit, gitMerge, gitDiff, getWorktreeRoot, } from './worktree';
|
|
3
|
+
export type { WorktreeInfo, GitStatus } from './worktree';
|
|
4
|
+
export { runCommand, runVerificationCommand } from './runner';
|
|
5
|
+
export type { CommandResult } from './runner';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runVerificationCommand = exports.runCommand = exports.getWorktreeRoot = exports.gitDiff = exports.gitMerge = exports.gitCommit = exports.gitStatus = exports.removeWorktree = exports.createWorktree = exports.OrchestratorClient = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "OrchestratorClient", { enumerable: true, get: function () { return client_1.OrchestratorClient; } });
|
|
6
|
+
var worktree_1 = require("./worktree");
|
|
7
|
+
Object.defineProperty(exports, "createWorktree", { enumerable: true, get: function () { return worktree_1.createWorktree; } });
|
|
8
|
+
Object.defineProperty(exports, "removeWorktree", { enumerable: true, get: function () { return worktree_1.removeWorktree; } });
|
|
9
|
+
Object.defineProperty(exports, "gitStatus", { enumerable: true, get: function () { return worktree_1.gitStatus; } });
|
|
10
|
+
Object.defineProperty(exports, "gitCommit", { enumerable: true, get: function () { return worktree_1.gitCommit; } });
|
|
11
|
+
Object.defineProperty(exports, "gitMerge", { enumerable: true, get: function () { return worktree_1.gitMerge; } });
|
|
12
|
+
Object.defineProperty(exports, "gitDiff", { enumerable: true, get: function () { return worktree_1.gitDiff; } });
|
|
13
|
+
Object.defineProperty(exports, "getWorktreeRoot", { enumerable: true, get: function () { return worktree_1.getWorktreeRoot; } });
|
|
14
|
+
var runner_1 = require("./runner");
|
|
15
|
+
Object.defineProperty(exports, "runCommand", { enumerable: true, get: function () { return runner_1.runCommand; } });
|
|
16
|
+
Object.defineProperty(exports, "runVerificationCommand", { enumerable: true, get: function () { return runner_1.runVerificationCommand; } });
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/orchestrator/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAC3B,uCAQoB;AAPlB,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,qGAAA,SAAS,OAAA;AACT,qGAAA,SAAS,OAAA;AACT,oGAAA,QAAQ,OAAA;AACR,mGAAA,OAAO,OAAA;AACP,2GAAA,eAAe,OAAA;AAGjB,mCAA8D;AAArD,oGAAA,UAAU,OAAA;AAAE,gHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface CommandResult {
|
|
2
|
+
exitCode: number;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
durationMs: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Run a command in a worktree directory.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runCommand(command: string, cwd: string, options?: {
|
|
11
|
+
timeout?: number;
|
|
12
|
+
maxOutputBytes?: number;
|
|
13
|
+
}): Promise<CommandResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Run a verification step command.
|
|
16
|
+
* Returns the result with exit code and output.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runVerificationCommand(step: string, cwd: string, timeoutMs?: number): Promise<CommandResult>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommand = runCommand;
|
|
4
|
+
exports.runVerificationCommand = runVerificationCommand;
|
|
5
|
+
/**
|
|
6
|
+
* Command Runner: executes build/test/lint commands in a sandboxed manner.
|
|
7
|
+
* Used by the orchestrator verification pipeline.
|
|
8
|
+
*
|
|
9
|
+
* Security: command allowlist, denylist, timeout, max output bytes.
|
|
10
|
+
*/
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
const log = {
|
|
13
|
+
info: (msg) => console.log(`[runner] ${msg}`),
|
|
14
|
+
warn: (msg) => console.warn(`[runner] ${msg}`),
|
|
15
|
+
error: (msg) => console.error(`[runner] ${msg}`),
|
|
16
|
+
};
|
|
17
|
+
/** Commands allowed to run (allowlist). */
|
|
18
|
+
const ALLOWED_COMMANDS = new Set([
|
|
19
|
+
'npm',
|
|
20
|
+
'pnpm',
|
|
21
|
+
'yarn',
|
|
22
|
+
'bun',
|
|
23
|
+
'npx',
|
|
24
|
+
'node',
|
|
25
|
+
'git',
|
|
26
|
+
'tsc',
|
|
27
|
+
'eslint',
|
|
28
|
+
'jest',
|
|
29
|
+
'vitest',
|
|
30
|
+
'mocha',
|
|
31
|
+
'python',
|
|
32
|
+
'python3',
|
|
33
|
+
'pip',
|
|
34
|
+
'pip3',
|
|
35
|
+
]);
|
|
36
|
+
/** Commands that are never allowed (denylist). */
|
|
37
|
+
const DENIED_PATTERNS = [
|
|
38
|
+
/\brm\s+-rf\b/,
|
|
39
|
+
/\bsudo\b/,
|
|
40
|
+
/\bdocker\b/,
|
|
41
|
+
/\bssh\b/,
|
|
42
|
+
/\bcurl\b.*\bhttp/,
|
|
43
|
+
/\bwget\b/,
|
|
44
|
+
/\bchmod\b/,
|
|
45
|
+
/\bchown\b/,
|
|
46
|
+
/\bkill\b/,
|
|
47
|
+
/\bpkill\b/,
|
|
48
|
+
/\bsystemctl\b/,
|
|
49
|
+
/\bservice\b/,
|
|
50
|
+
];
|
|
51
|
+
const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
52
|
+
const DEFAULT_MAX_OUTPUT_BYTES = 2 * 1024 * 1024; // 2 MB
|
|
53
|
+
/**
|
|
54
|
+
* Redact potential secrets from command output.
|
|
55
|
+
* Strips API keys, tokens, passwords, and env var values that look sensitive.
|
|
56
|
+
*/
|
|
57
|
+
function redactSecrets(text) {
|
|
58
|
+
return text
|
|
59
|
+
// API keys (sk-..., ts_..., AIza..., Bearer ...)
|
|
60
|
+
.replace(/\b(sk-[a-zA-Z0-9]{20,})\b/g, '[REDACTED_KEY]')
|
|
61
|
+
.replace(/\b(ts_[a-zA-Z0-9]{20,})\b/g, '[REDACTED_KEY]')
|
|
62
|
+
.replace(/\b(AIza[a-zA-Z0-9_-]{20,})\b/g, '[REDACTED_KEY]')
|
|
63
|
+
.replace(/\bBearer\s+[a-zA-Z0-9._-]{20,}/g, 'Bearer [REDACTED]')
|
|
64
|
+
// Passwords in env output
|
|
65
|
+
.replace(/(PASSWORD|SECRET|TOKEN|KEY|CREDENTIALS?)\s*[=:]\s*\S+/gi, '$1=[REDACTED]')
|
|
66
|
+
// Connection strings
|
|
67
|
+
.replace(/(postgres|mysql|mongodb|redis):\/\/[^\s]+/gi, '$1://[REDACTED]')
|
|
68
|
+
// Generic long hex strings (potential hashes/tokens)
|
|
69
|
+
.replace(/\b[a-f0-9]{32,}\b/g, '[REDACTED_HASH]');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate that a command is allowed.
|
|
73
|
+
*/
|
|
74
|
+
function validateCommand(command) {
|
|
75
|
+
// Check denylist first
|
|
76
|
+
for (const pattern of DENIED_PATTERNS) {
|
|
77
|
+
if (pattern.test(command)) {
|
|
78
|
+
return { allowed: false, reason: `Denied by pattern: ${pattern.source}` };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Extract the base command (first word)
|
|
82
|
+
const baseCommand = command.trim().split(/\s+/)[0];
|
|
83
|
+
// Check allowlist
|
|
84
|
+
if (!ALLOWED_COMMANDS.has(baseCommand)) {
|
|
85
|
+
return {
|
|
86
|
+
allowed: false,
|
|
87
|
+
reason: `Command '${baseCommand}' not in allowlist`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return { allowed: true };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Run a command in a worktree directory.
|
|
94
|
+
*/
|
|
95
|
+
function runCommand(command, cwd, options = {}) {
|
|
96
|
+
const timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
97
|
+
const maxOutput = options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
|
|
98
|
+
// Validate command
|
|
99
|
+
const validation = validateCommand(command);
|
|
100
|
+
if (!validation.allowed) {
|
|
101
|
+
return Promise.resolve({
|
|
102
|
+
exitCode: 126,
|
|
103
|
+
stdout: '',
|
|
104
|
+
stderr: `Command blocked: ${validation.reason}`,
|
|
105
|
+
durationMs: 0,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
const startTime = Date.now();
|
|
110
|
+
let stdout = '';
|
|
111
|
+
let stderr = '';
|
|
112
|
+
let killed = false;
|
|
113
|
+
const child = (0, child_process_1.spawn)(command, [], {
|
|
114
|
+
cwd,
|
|
115
|
+
shell: true,
|
|
116
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
117
|
+
timeout,
|
|
118
|
+
windowsVerbatimArguments: true,
|
|
119
|
+
});
|
|
120
|
+
child.stdout.on('data', (data) => {
|
|
121
|
+
stdout += data.toString();
|
|
122
|
+
if (stdout.length > maxOutput) {
|
|
123
|
+
stdout = stdout.slice(0, maxOutput);
|
|
124
|
+
child.kill();
|
|
125
|
+
killed = true;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
child.stderr.on('data', (data) => {
|
|
129
|
+
stderr += data.toString();
|
|
130
|
+
if (stderr.length > maxOutput) {
|
|
131
|
+
stderr = stderr.slice(0, maxOutput);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
child.on('close', (code) => {
|
|
135
|
+
const durationMs = Date.now() - startTime;
|
|
136
|
+
resolve({
|
|
137
|
+
exitCode: killed ? 124 : (code ?? 1),
|
|
138
|
+
stdout: redactSecrets(stdout),
|
|
139
|
+
stderr: redactSecrets(killed ? `${stderr}\n[TIMEOUT or output limit exceeded]` : stderr),
|
|
140
|
+
durationMs,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
child.on('error', (err) => {
|
|
144
|
+
const durationMs = Date.now() - startTime;
|
|
145
|
+
resolve({
|
|
146
|
+
exitCode: 1,
|
|
147
|
+
stdout,
|
|
148
|
+
stderr: err.message,
|
|
149
|
+
durationMs,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Run a verification step command.
|
|
156
|
+
* Returns the result with exit code and output.
|
|
157
|
+
*/
|
|
158
|
+
async function runVerificationCommand(step, cwd, timeoutMs) {
|
|
159
|
+
const commands = {
|
|
160
|
+
build: 'npm run build',
|
|
161
|
+
test: 'npm test',
|
|
162
|
+
lint: 'npx eslint .',
|
|
163
|
+
git_diff: 'git diff --stat',
|
|
164
|
+
};
|
|
165
|
+
const command = commands[step];
|
|
166
|
+
if (!command) {
|
|
167
|
+
return {
|
|
168
|
+
exitCode: 1,
|
|
169
|
+
stdout: '',
|
|
170
|
+
stderr: `Unknown verification step: ${step}`,
|
|
171
|
+
durationMs: 0,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
log.info(`Running verification: ${step} -> ${command}`);
|
|
175
|
+
return runCommand(command, cwd, { timeout: timeoutMs });
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/lib/orchestrator/runner.ts"],"names":[],"mappings":";;AA4GA,gCA0EC;AAMD,wDAwBC;AApND;;;;;GAKG;AACH,iDAAsC;AAEtC,MAAM,GAAG,GAAG;IACV,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC;IACrD,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACtD,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC;CACzD,CAAC;AAEF,2CAA2C;AAC3C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,KAAK;IACL,MAAM;CACP,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,eAAe,GAAG;IACtB,cAAc;IACd,UAAU;IACV,YAAY;IACZ,SAAS;IACT,kBAAkB;IAClB,UAAU;IACV,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,eAAe;IACf,aAAa;CACd,CAAC;AAEF,MAAM,kBAAkB,GAAG,EAAE,G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,eAAe;QACtB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC;IAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,QAAQ,EAAE,CAAC;YACX,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,8BAA8B,IAAI,EAAE;YAC5C,UAAU,EAAE,CAAC;SACd,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,yBAAyB,IAAI,OAAO,OAAO,EAAE,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface WorktreeInfo {
|
|
2
|
+
path: string;
|
|
3
|
+
branch: string;
|
|
4
|
+
commitHash: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GitStatus {
|
|
7
|
+
branch: string;
|
|
8
|
+
dirty: boolean;
|
|
9
|
+
ahead: number;
|
|
10
|
+
files: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the worktree root directory for a project.
|
|
14
|
+
* Derived from the project's linked path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWorktreeRoot(projectPath: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new Git worktree for an orchestrator task.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createWorktree(repoPath: string, branch: string, baseBranch: string, taskId: string): WorktreeInfo;
|
|
21
|
+
/**
|
|
22
|
+
* Remove a Git worktree.
|
|
23
|
+
*/
|
|
24
|
+
export declare function removeWorktree(repoPath: string, worktreePath: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get git status for a worktree.
|
|
27
|
+
*/
|
|
28
|
+
export declare function gitStatus(worktreePath: string): GitStatus;
|
|
29
|
+
/**
|
|
30
|
+
* Commit changes in a worktree.
|
|
31
|
+
*/
|
|
32
|
+
export declare function gitCommit(worktreePath: string, message: string, files?: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Merge a branch into the integration branch.
|
|
35
|
+
*/
|
|
36
|
+
export declare function gitMerge(repoPath: string, sourceBranch: string, targetBranch: string): {
|
|
37
|
+
success: boolean;
|
|
38
|
+
conflictFiles?: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get the diff for a worktree.
|
|
42
|
+
*/
|
|
43
|
+
export declare function gitDiff(worktreePath: string): string;
|