@agents-ensemble/operator-agent 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/list-operator-sessions-tool.d.ts +5 -0
- package/dist/list-operator-sessions-tool.d.ts.map +1 -0
- package/dist/list-operator-sessions-tool.js +85 -0
- package/dist/list-operator-sessions-tool.js.map +1 -0
- package/dist/operator-base-module.d.ts +14 -0
- package/dist/operator-base-module.d.ts.map +1 -0
- package/dist/operator-base-module.js +50 -0
- package/dist/operator-base-module.js.map +1 -0
- package/dist/run-operator-agent.d.ts +20 -0
- package/dist/run-operator-agent.d.ts.map +1 -0
- package/dist/run-operator-agent.js +120 -0
- package/dist/run-operator-agent.js.map +1 -0
- package/package.json +41 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 otolab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { runOperatorAgent } from './run-operator-agent.js';
|
|
2
|
+
export type { OperatorAgentInput, OperatorAgentOutput, RunOperatorAgentDependencies, RunOperatorAgentOptions, } from './run-operator-agent.js';
|
|
3
|
+
export { createListOperatorSessionsTool, LIST_OPERATOR_SESSIONS_TOOL, } from './list-operator-sessions-tool.js';
|
|
4
|
+
export { operatorBaseModule } from './operator-base-module.js';
|
|
5
|
+
export type { OperatorPromptContext } from './operator-base-module.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { runOperatorAgent } from './run-operator-agent.js';
|
|
2
|
+
export { createListOperatorSessionsTool, LIST_OPERATOR_SESSIONS_TOOL, } from './list-operator-sessions-tool.js';
|
|
3
|
+
export { operatorBaseModule } from './operator-base-module.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAO3D,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ConductorTool } from '@agents-ensemble/core/operator-runtime';
|
|
2
|
+
export declare const LIST_OPERATOR_SESSIONS_TOOL = "list_operator_sessions";
|
|
3
|
+
/** Build a read-only tool over this repository's existing conductor sidecars. */
|
|
4
|
+
export declare function createListOperatorSessionsTool(repoRoot: string): ConductorTool;
|
|
5
|
+
//# sourceMappingURL=list-operator-sessions-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-operator-sessions-tool.d.ts","sourceRoot":"","sources":["../src/list-operator-sessions-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,wCAAwC,CAAC;AAEhD,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAsBpE,iFAAiF;AACjF,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CA2C9E"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { listSessionSidecars, } from '@agents-ensemble/core/operator-runtime';
|
|
3
|
+
export const LIST_OPERATOR_SESSIONS_TOOL = 'list_operator_sessions';
|
|
4
|
+
const DEFAULT_LIMIT = 20;
|
|
5
|
+
const MAX_LIMIT = 50;
|
|
6
|
+
/** Build a read-only tool over this repository's existing conductor sidecars. */
|
|
7
|
+
export function createListOperatorSessionsTool(repoRoot) {
|
|
8
|
+
const root = resolve(repoRoot);
|
|
9
|
+
return {
|
|
10
|
+
name: LIST_OPERATOR_SESSIONS_TOOL,
|
|
11
|
+
description: 'Read saved conductor session sidecars under <repoRoot>/.ensemble/sessions and return a concise summary.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'integer',
|
|
17
|
+
minimum: 1,
|
|
18
|
+
maximum: MAX_LIMIT,
|
|
19
|
+
description: `Maximum number of recent sessions to return (default ${DEFAULT_LIMIT}).`,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
execute: async (args) => {
|
|
25
|
+
const limit = resolveLimit(args.limit);
|
|
26
|
+
const sidecars = await listSessionSidecars(root);
|
|
27
|
+
sidecars.sort((left, right) => right.updatedAt - left.updatedAt);
|
|
28
|
+
const sessions = sidecars
|
|
29
|
+
.slice(0, limit)
|
|
30
|
+
.map(summarizeSession);
|
|
31
|
+
const payload = {
|
|
32
|
+
repoRoot: root,
|
|
33
|
+
total: sidecars.length,
|
|
34
|
+
returned: sessions.length,
|
|
35
|
+
sessions,
|
|
36
|
+
};
|
|
37
|
+
const structuredContent = payload;
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: JSON.stringify(payload, null, 2),
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
structuredContent,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function resolveLimit(value) {
|
|
51
|
+
if (value === undefined)
|
|
52
|
+
return DEFAULT_LIMIT;
|
|
53
|
+
if (typeof value !== 'number' ||
|
|
54
|
+
!Number.isInteger(value) ||
|
|
55
|
+
value < 1 ||
|
|
56
|
+
value > MAX_LIMIT) {
|
|
57
|
+
throw new Error(`limit must be an integer between 1 and ${MAX_LIMIT}`);
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function summarizeSession(sidecar) {
|
|
62
|
+
return {
|
|
63
|
+
agentId: sidecar.conductorAgentId,
|
|
64
|
+
issueUrl: sidecar.issueUrl,
|
|
65
|
+
conductorBackend: sidecar.conductorBackend ?? 'cursor',
|
|
66
|
+
profile: sidecar.profile.meta?.title ??
|
|
67
|
+
sidecar.profilePath ??
|
|
68
|
+
'unknown',
|
|
69
|
+
updatedAt: sidecar.updatedAt,
|
|
70
|
+
workers: Object.keys(sidecar.workers).sort(),
|
|
71
|
+
openQuestions: sidecar.openQuestions
|
|
72
|
+
.filter((question) => question.status === 'open')
|
|
73
|
+
.map((question) => ({
|
|
74
|
+
id: question.id,
|
|
75
|
+
question: question.question,
|
|
76
|
+
responseType: question.responseType,
|
|
77
|
+
...(question.context ? { context: question.context } : {}),
|
|
78
|
+
...(question.relatedPermissionId
|
|
79
|
+
? { relatedPermissionId: question.relatedPermissionId }
|
|
80
|
+
: {}),
|
|
81
|
+
})),
|
|
82
|
+
answeredQuestionCount: sidecar.openQuestions.filter((question) => question.status === 'answered').length,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=list-operator-sessions-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-operator-sessions-tool.js","sourceRoot":"","sources":["../src/list-operator-sessions-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,mBAAmB,GAIpB,MAAM,wCAAwC,CAAC;AAEhD,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CAAC;AAEpE,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,SAAS,GAAG,EAAE,CAAC;AAmBrB,iFAAiF;AACjF,MAAM,UAAU,8BAA8B,CAAC,QAAgB;IAC7D,MAAM,IAAI,GAAG,OAAO,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AqB,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,CACjD,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,CAC7C,CAAC,MAAM;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PromptModule } from '@modular-prompt/core';
|
|
2
|
+
import type { ConductorBackend } from '@agents-ensemble/core/operator-runtime';
|
|
3
|
+
export interface OperatorPromptContext {
|
|
4
|
+
repoRoot: string;
|
|
5
|
+
conductorBackend: ConductorBackend;
|
|
6
|
+
profileName: string;
|
|
7
|
+
workers: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
kind: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/** The operator role has its own voice and does not inherit conductor instructions. */
|
|
13
|
+
export declare const operatorBaseModule: PromptModule<OperatorPromptContext>;
|
|
14
|
+
//# sourceMappingURL=operator-base-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-base-module.d.ts","sourceRoot":"","sources":["../src/operator-base-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,qBAAqB,CAmDlE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The operator role has its own voice and does not inherit conductor instructions. */
|
|
2
|
+
export const operatorBaseModule = {
|
|
3
|
+
persona: [
|
|
4
|
+
'あなたは agents-ensemble の operator ロールを担う operator-agent です。',
|
|
5
|
+
'user と密に対話し、保存された Issue セッション情報を材料に、横断的な状況把握と判断を支援してください。',
|
|
6
|
+
],
|
|
7
|
+
objective: [
|
|
8
|
+
'user が conductor と worker の状況を理解し、次の判断を行えるよう支援する。',
|
|
9
|
+
],
|
|
10
|
+
terms: [
|
|
11
|
+
'- **operator**: user を支援し、conductor と workers を横断して監督する役割',
|
|
12
|
+
'- **session sidecar**: `.ensemble/sessions/` に保存された conductor セッションの状態ファイル',
|
|
13
|
+
],
|
|
14
|
+
methodology: [
|
|
15
|
+
'user は operator-agent と対話し、operator-agent は保存済みのセッション情報を介して conductor の状況を把握する。',
|
|
16
|
+
'operator-agent と conductor の間に同期接続はなく、worker へ直接指示する経路もない。',
|
|
17
|
+
],
|
|
18
|
+
instructions: [
|
|
19
|
+
'状況を尋ねられたら `list_operator_sessions` を使い、保存済み sidecar に含まれる情報と取得時点を明示してください。',
|
|
20
|
+
'sidecar にない稼働状況や最新の GitHub 情報を推測せず、確認できない点を user に伝えてください。',
|
|
21
|
+
'作業や conductor への連絡を実行したと主張せず、判断に必要な事実・選択肢・不確実な点を簡潔に整理してください。',
|
|
22
|
+
'profile の operator 向け追加指示と Prepared Materials があれば、それに従ってください。',
|
|
23
|
+
{
|
|
24
|
+
type: 'subsection',
|
|
25
|
+
title: 'list_operator_sessions',
|
|
26
|
+
items: [
|
|
27
|
+
'- `.ensemble/sessions/` の sidecar 一覧と要約を読む読み取り専用ツールです',
|
|
28
|
+
'- Issue URL、conductor backend、profile、worker 名、open question の要約、更新時刻を返します',
|
|
29
|
+
'- `limit` は返却する件数(1〜50、既定 20)です',
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
state: [
|
|
34
|
+
(context) => `- repository: \`${context.repoRoot}\``,
|
|
35
|
+
(context) => `- conductor backend: \`${context.conductorBackend}\``,
|
|
36
|
+
(context) => `- team profile: ${context.profileName}`,
|
|
37
|
+
{
|
|
38
|
+
type: 'subsection',
|
|
39
|
+
title: 'configured workers',
|
|
40
|
+
items: [
|
|
41
|
+
(context) => context.workers.length > 0
|
|
42
|
+
? context.workers
|
|
43
|
+
.map((worker) => `- **${worker.name}**: \`${worker.kind}\``)
|
|
44
|
+
.join('\n')
|
|
45
|
+
: '- profile に worker は登録されていません',
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=operator-base-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-base-module.js","sourceRoot":"","sources":["../src/operator-base-module.ts"],"names":[],"mappings":"AAUA,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAwC;IACrE,OAAO,EAAE;QACP,2DAA2D;QAC3D,2DAA2D;KAC5D;IACD,SAAS,EAAE;QACT,mDAAmD;KACpD;IACD,KAAK,EAAE;QACL,2DAA2D;QAC3D,4EAA4E;KAC7E;IACD,WAAW,EAAE;QACX,iFAAiF;QACjF,4DAA4D;KAC7D;IACD,YAAY,EAAE;QACZ,4EAA4E;QAC5E,4DAA4D;QAC5D,8DAA8D;QAC9D,gEAAgE;QAChE;YACE,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,wBAAwB;YAC/B,KAAK,EAAE;gBACL,uDAAuD;gBACvD,4EAA4E;gBAC5E,iCAAiC;aAClC;SACF;KACF;IACD,KAAK,EAAE;QACL,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,OAAO,CAAC,QAAQ,IAAI;QACpD,CAAC,OAAO,EAAE,EAAE,CAAC,0BAA0B,OAAO,CAAC,gBAAgB,IAAI;QACnE,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,OAAO,CAAC,WAAW,EAAE;QACrD;YACE,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,oBAAoB;YAC3B,KAAK,EAAE;gBACL,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;oBACxB,CAAC,CAAC,OAAO,CAAC,OAAO;yBACZ,GAAG,CACF,CAAC,MAAgD,EAAE,EAAE,CACnD,OAAO,MAAM,CAAC,IAAI,SAAS,MAAM,CAAC,IAAI,IAAI,CAC7C;yBACA,IAAI,CAAC,IAAI,CAAC;oBACf,CAAC,CAAC,+BAA+B;aACtC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { loadEnsembleConfig, loadProfile, type ConductorAgentFactory } from '@agents-ensemble/core/operator-runtime';
|
|
2
|
+
export interface RunOperatorAgentOptions {
|
|
3
|
+
repoRoot?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface OperatorAgentInput extends NodeJS.ReadableStream {
|
|
6
|
+
isTTY?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface OperatorAgentOutput extends NodeJS.WritableStream {
|
|
9
|
+
isTTY?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface RunOperatorAgentDependencies {
|
|
12
|
+
stdin?: OperatorAgentInput;
|
|
13
|
+
stdout?: OperatorAgentOutput;
|
|
14
|
+
loadConfig?: typeof loadEnsembleConfig;
|
|
15
|
+
loadProfile?: typeof loadProfile;
|
|
16
|
+
agentFactory?: ConductorAgentFactory;
|
|
17
|
+
}
|
|
18
|
+
/** Start an operator-role conversation on an interactive terminal. */
|
|
19
|
+
export declare function runOperatorAgent(options?: RunOperatorAgentOptions, dependencies?: RunOperatorAgentDependencies): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=run-operator-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-operator-agent.d.ts","sourceRoot":"","sources":["../src/run-operator-agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAClB,WAAW,EASX,KAAK,qBAAqB,EAI3B,MAAM,wCAAwC,CAAC;AAIhD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,MAAM,CAAC,cAAc;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,cAAc;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,kBAAkB,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC;IACjC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC;AAWD,sEAAsE;AACtE,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,EACrC,YAAY,GAAE,4BAAiC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { compile, merge } from '@modular-prompt/core';
|
|
4
|
+
import { createConductorAgentFactory, filterMaterialsForKind, loadEnsembleConfig, loadProfile, profilePromptModule, renderCompiledPrompt, resolveAgentPromptModule, resolveConductorBackendSetting, resolveConductorModelId, resolveConductorPiResourcePaths, sessionStateFromProfile, } from '@agents-ensemble/core/operator-runtime';
|
|
5
|
+
import { operatorBaseModule } from './operator-base-module.js';
|
|
6
|
+
import { createListOperatorSessionsTool } from './list-operator-sessions-tool.js';
|
|
7
|
+
/** Start an operator-role conversation on an interactive terminal. */
|
|
8
|
+
export async function runOperatorAgent(options = {}, dependencies = {}) {
|
|
9
|
+
const stdin = dependencies.stdin ?? process.stdin;
|
|
10
|
+
const stdout = dependencies.stdout ?? process.stdout;
|
|
11
|
+
assertTty(stdin, stdout);
|
|
12
|
+
const runtime = await resolveOperatorRuntime(options, dependencies);
|
|
13
|
+
const factory = dependencies.agentFactory ?? createConductorAgentFactory(runtime.backend);
|
|
14
|
+
const agent = await factory.create({
|
|
15
|
+
cwd: runtime.repoRoot,
|
|
16
|
+
systemPrompt: runtime.systemPrompt,
|
|
17
|
+
modelId: runtime.modelId,
|
|
18
|
+
// The operator role has no repository editing or shell tools in Phase 1.
|
|
19
|
+
builtinTools: false,
|
|
20
|
+
...(runtime.backend === 'pi'
|
|
21
|
+
? {
|
|
22
|
+
pi: resolveConductorPiResourcePaths({
|
|
23
|
+
repoRoot: runtime.repoRoot,
|
|
24
|
+
config: runtime.config,
|
|
25
|
+
}),
|
|
26
|
+
piSkills: runtime.profile.conductor?.piSkills !== false,
|
|
27
|
+
piExtensions: false,
|
|
28
|
+
}
|
|
29
|
+
: {}),
|
|
30
|
+
customTools: {
|
|
31
|
+
list_operator_sessions: createListOperatorSessionsTool(runtime.repoRoot),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
await runTtyConversation({
|
|
36
|
+
agent,
|
|
37
|
+
backend: runtime.backend,
|
|
38
|
+
systemPrompt: runtime.systemPrompt,
|
|
39
|
+
stdin,
|
|
40
|
+
stdout,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await agent.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function resolveOperatorRuntime(options, dependencies) {
|
|
48
|
+
const repoRoot = resolve(options.repoRoot ?? process.cwd());
|
|
49
|
+
const config = await (dependencies.loadConfig ?? loadEnsembleConfig)(repoRoot);
|
|
50
|
+
const { profile, profilePath } = await (dependencies.loadProfile ?? loadProfile)({
|
|
51
|
+
cwd: repoRoot,
|
|
52
|
+
config,
|
|
53
|
+
});
|
|
54
|
+
const backend = resolveConductorBackendSetting({ profile, config });
|
|
55
|
+
const modelId = resolveConductorModelId(undefined, { config });
|
|
56
|
+
const sessionState = sessionStateFromProfile(profile);
|
|
57
|
+
const profileModule = profilePromptModule({
|
|
58
|
+
agentModule: resolveAgentPromptModule('operator', profile.agents),
|
|
59
|
+
materials: filterMaterialsForKind(sessionState.materials, 'operator'),
|
|
60
|
+
});
|
|
61
|
+
const promptModule = profileModule
|
|
62
|
+
? merge(operatorBaseModule, profileModule)
|
|
63
|
+
: operatorBaseModule;
|
|
64
|
+
const systemPrompt = renderCompiledPrompt(compile(promptModule, {
|
|
65
|
+
repoRoot,
|
|
66
|
+
conductorBackend: backend,
|
|
67
|
+
profileName: profile.meta?.title ?? profilePath,
|
|
68
|
+
workers: profile.workers.map(({ name, kind }) => ({ name, kind })),
|
|
69
|
+
}));
|
|
70
|
+
return { repoRoot, config, profile, backend, modelId, systemPrompt };
|
|
71
|
+
}
|
|
72
|
+
async function runTtyConversation(options) {
|
|
73
|
+
const terminal = createInterface({
|
|
74
|
+
input: options.stdin,
|
|
75
|
+
output: options.stdout,
|
|
76
|
+
terminal: true,
|
|
77
|
+
crlfDelay: Infinity,
|
|
78
|
+
});
|
|
79
|
+
const input = terminal[Symbol.asyncIterator]();
|
|
80
|
+
let firstSend = true;
|
|
81
|
+
options.stdout.write(`operator-agent (${options.backend}) ready — enter /exit to quit.\n`);
|
|
82
|
+
try {
|
|
83
|
+
while (true) {
|
|
84
|
+
options.stdout.write('user> ');
|
|
85
|
+
const next = await input.next();
|
|
86
|
+
if (next.done)
|
|
87
|
+
return;
|
|
88
|
+
const message = next.value.trim();
|
|
89
|
+
if (!message)
|
|
90
|
+
continue;
|
|
91
|
+
if (message === '/exit') {
|
|
92
|
+
options.stdout.write('operator-agent session ended.\n');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const prompt = options.backend === 'cursor' && firstSend
|
|
96
|
+
? `${options.systemPrompt}\n\n## User message\n\n${message}`
|
|
97
|
+
: message;
|
|
98
|
+
const result = await options.agent.send(prompt);
|
|
99
|
+
firstSend = false;
|
|
100
|
+
if (result.status === 'error') {
|
|
101
|
+
options.stdout.write(`operator-agent error: ${result.error?.message ?? result.result ?? 'request failed'}\n`);
|
|
102
|
+
}
|
|
103
|
+
else if (result.result?.trim()) {
|
|
104
|
+
options.stdout.write(`operator> ${result.result.trim()}\n`);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
options.stdout.write(`operator-agent completed (status: ${result.status}).\n`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
terminal.close();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function assertTty(stdin, stdout) {
|
|
116
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
117
|
+
throw new Error('ensemble operator-agent requires an interactive TTY on stdin and stdout.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=run-operator-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-operator-agent.js","sourceRoot":"","sources":["../src/run-operator-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,uBAAuB,GAMxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AA+BlF,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAmC,EAAE,EACrC,eAA6C,EAAE;IAE/C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,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;YAClB,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yBAAyB,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,gBAAgB,IAAI,CACxF,CAAC;YACJ,CAAC;iBAAM,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;gBACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAyB,EAAE,MAA2B;IACvE,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agents-ensemble/operator-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Embedded operator-role agent runtime for agents-ensemble",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@modular-prompt/core": "0.3.0",
|
|
16
|
+
"@agents-ensemble/core": "0.13.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "22.18.10",
|
|
20
|
+
"typescript": "5.9.3",
|
|
21
|
+
"vitest": "3.2.4"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/otolab/agents-ensemble.git",
|
|
27
|
+
"directory": "packages/operator-agent"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc --build",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"test:run": "vitest run"
|
|
43
|
+
}
|
|
6
44
|
}
|
package/README.md
DELETED