actoviq-agent-sdk 0.1.12 → 0.3.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/README-zh.md +27 -3
- package/README.md +27 -3
- package/bin/actoviq-interactive-agent.js +5 -0
- package/bin/actoviq-link-runtime.js +74 -0
- package/bin/actoviq-react.js +5 -0
- package/dist/src/cli/actoviq-react.d.ts +3 -0
- package/dist/src/cli/actoviq-react.d.ts.map +1 -0
- package/dist/src/cli/actoviq-react.js +277 -0
- package/dist/src/cli/actoviq-react.js.map +1 -0
- package/dist/src/cli/bridge-interactive-agent.d.ts +2 -0
- package/dist/src/cli/bridge-interactive-agent.d.ts.map +1 -0
- package/dist/src/cli/bridge-interactive-agent.js +147 -0
- package/dist/src/cli/bridge-interactive-agent.js.map +1 -0
- package/dist/src/config/resolveRuntimeConfig.d.ts.map +1 -1
- package/dist/src/config/resolveRuntimeConfig.js +18 -14
- package/dist/src/config/resolveRuntimeConfig.js.map +1 -1
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +9 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/hooks/actoviqHooks.d.ts +2 -1
- package/dist/src/hooks/actoviqHooks.d.ts.map +1 -1
- package/dist/src/hooks/actoviqHooks.js +9 -1
- package/dist/src/hooks/actoviqHooks.js.map +1 -1
- package/dist/src/index.d.ts +29 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +26 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/connectionManager.d.ts.map +1 -1
- package/dist/src/mcp/connectionManager.js +1 -0
- package/dist/src/mcp/connectionManager.js.map +1 -1
- package/dist/src/parity/actoviqBridgeEvents.d.ts +7 -0
- package/dist/src/parity/actoviqBridgeEvents.d.ts.map +1 -0
- package/dist/src/parity/actoviqBridgeEvents.js +133 -0
- package/dist/src/parity/actoviqBridgeEvents.js.map +1 -0
- package/dist/src/parity/actoviqBridgeSdk.d.ts +179 -0
- package/dist/src/parity/actoviqBridgeSdk.d.ts.map +1 -0
- package/dist/src/parity/actoviqBridgeSdk.js +1267 -0
- package/dist/src/parity/actoviqBridgeSdk.js.map +1 -0
- package/dist/src/parity/actoviqTranscripts.d.ts +44 -0
- package/dist/src/parity/actoviqTranscripts.d.ts.map +1 -0
- package/dist/src/parity/actoviqTranscripts.js +282 -0
- package/dist/src/parity/actoviqTranscripts.js.map +1 -0
- package/dist/src/parity/portableSessions.d.ts +35 -0
- package/dist/src/parity/portableSessions.d.ts.map +1 -0
- package/dist/src/parity/portableSessions.js +233 -0
- package/dist/src/parity/portableSessions.js.map +1 -0
- package/dist/src/prompts/systemPrompt.d.ts +15 -0
- package/dist/src/prompts/systemPrompt.d.ts.map +1 -0
- package/dist/src/prompts/systemPrompt.js +73 -0
- package/dist/src/prompts/systemPrompt.js.map +1 -0
- package/dist/src/provider/client.d.ts +1 -0
- package/dist/src/provider/client.d.ts.map +1 -1
- package/dist/src/provider/client.js +14 -7
- package/dist/src/provider/client.js.map +1 -1
- package/dist/src/provider/json-parse.d.ts +7 -0
- package/dist/src/provider/json-parse.d.ts.map +1 -0
- package/dist/src/provider/json-parse.js +69 -0
- package/dist/src/provider/json-parse.js.map +1 -0
- package/dist/src/provider/openai-client.d.ts +42 -0
- package/dist/src/provider/openai-client.d.ts.map +1 -0
- package/dist/src/provider/openai-client.js +282 -0
- package/dist/src/provider/openai-client.js.map +1 -0
- package/dist/src/provider/openai-model-api.d.ts +13 -0
- package/dist/src/provider/openai-model-api.d.ts.map +1 -0
- package/dist/src/provider/openai-model-api.js +382 -0
- package/dist/src/provider/openai-model-api.js.map +1 -0
- package/dist/src/provider/openai-types.d.ts +116 -0
- package/dist/src/provider/openai-types.d.ts.map +1 -0
- package/dist/src/provider/openai-types.js +4 -0
- package/dist/src/provider/openai-types.js.map +1 -0
- package/dist/src/provider/types.d.ts +1 -0
- package/dist/src/provider/types.d.ts.map +1 -1
- package/dist/src/runtime/actoviqApiMicrocompact.d.ts.map +1 -1
- package/dist/src/runtime/actoviqApiMicrocompact.js +10 -17
- package/dist/src/runtime/actoviqApiMicrocompact.js.map +1 -1
- package/dist/src/runtime/actoviqCompact.d.ts +4 -0
- package/dist/src/runtime/actoviqCompact.d.ts.map +1 -1
- package/dist/src/runtime/actoviqCompact.js +133 -5
- package/dist/src/runtime/actoviqCompact.js.map +1 -1
- package/dist/src/runtime/actoviqPermissions.d.ts +11 -3
- package/dist/src/runtime/actoviqPermissions.d.ts.map +1 -1
- package/dist/src/runtime/actoviqPermissions.js +155 -50
- package/dist/src/runtime/actoviqPermissions.js.map +1 -1
- package/dist/src/runtime/actoviqSkills.js +6 -6
- package/dist/src/runtime/actoviqSkills.js.map +1 -1
- package/dist/src/runtime/actoviqToolCatalog.d.ts.map +1 -1
- package/dist/src/runtime/actoviqToolCatalog.js +2 -3
- package/dist/src/runtime/actoviqToolCatalog.js.map +1 -1
- package/dist/src/runtime/agentClient.d.ts +13 -1
- package/dist/src/runtime/agentClient.d.ts.map +1 -1
- package/dist/src/runtime/agentClient.js +84 -9
- package/dist/src/runtime/agentClient.js.map +1 -1
- package/dist/src/runtime/agentSession.d.ts +9 -1
- package/dist/src/runtime/agentSession.d.ts.map +1 -1
- package/dist/src/runtime/agentSession.js +28 -13
- package/dist/src/runtime/agentSession.js.map +1 -1
- package/dist/src/runtime/conversationEngine.d.ts +1 -0
- package/dist/src/runtime/conversationEngine.d.ts.map +1 -1
- package/dist/src/runtime/conversationEngine.js +150 -6
- package/dist/src/runtime/conversationEngine.js.map +1 -1
- package/dist/src/runtime/denialTracking.d.ts +10 -0
- package/dist/src/runtime/denialTracking.d.ts.map +1 -0
- package/dist/src/runtime/denialTracking.js +27 -0
- package/dist/src/runtime/denialTracking.js.map +1 -0
- package/dist/src/runtime/parallel.d.ts +4 -0
- package/dist/src/runtime/parallel.d.ts.map +1 -0
- package/dist/src/runtime/parallel.js +88 -0
- package/dist/src/runtime/parallel.js.map +1 -0
- package/dist/src/runtime/safetyChecks.d.ts +12 -0
- package/dist/src/runtime/safetyChecks.d.ts.map +1 -0
- package/dist/src/runtime/safetyChecks.js +62 -0
- package/dist/src/runtime/safetyChecks.js.map +1 -0
- package/dist/src/runtime/sessionManager.d.ts +33 -0
- package/dist/src/runtime/sessionManager.d.ts.map +1 -0
- package/dist/src/runtime/sessionManager.js +166 -0
- package/dist/src/runtime/sessionManager.js.map +1 -0
- package/dist/src/runtime/tools.d.ts.map +1 -1
- package/dist/src/runtime/tools.js +72 -3
- package/dist/src/runtime/tools.js.map +1 -1
- package/dist/src/scheduling/cron.d.ts +14 -0
- package/dist/src/scheduling/cron.d.ts.map +1 -0
- package/dist/src/scheduling/cron.js +157 -0
- package/dist/src/scheduling/cron.js.map +1 -0
- package/dist/src/scheduling/index.d.ts +3 -0
- package/dist/src/scheduling/index.d.ts.map +1 -0
- package/dist/src/scheduling/index.js +3 -0
- package/dist/src/scheduling/index.js.map +1 -0
- package/dist/src/scheduling/scheduler.d.ts +32 -0
- package/dist/src/scheduling/scheduler.d.ts.map +1 -0
- package/dist/src/scheduling/scheduler.js +196 -0
- package/dist/src/scheduling/scheduler.js.map +1 -0
- package/dist/src/storage/sessionStore.d.ts +8 -1
- package/dist/src/storage/sessionStore.d.ts.map +1 -1
- package/dist/src/storage/sessionStore.js +79 -0
- package/dist/src/storage/sessionStore.js.map +1 -1
- package/dist/src/tools/actoviqCoreTools.d.ts +23 -0
- package/dist/src/tools/actoviqCoreTools.d.ts.map +1 -0
- package/dist/src/tools/actoviqCoreTools.js +32 -0
- package/dist/src/tools/actoviqCoreTools.js.map +1 -0
- package/dist/src/tools/actoviqFileTools.d.ts.map +1 -1
- package/dist/src/tools/actoviqFileTools.js +338 -373
- package/dist/src/tools/actoviqFileTools.js.map +1 -1
- package/dist/src/tools/actoviqMiscTools.d.ts +11 -0
- package/dist/src/tools/actoviqMiscTools.d.ts.map +1 -0
- package/dist/src/tools/actoviqMiscTools.js +89 -0
- package/dist/src/tools/actoviqMiscTools.js.map +1 -0
- package/dist/src/tools/actoviqNotebookEdit.d.ts +4 -0
- package/dist/src/tools/actoviqNotebookEdit.d.ts.map +1 -0
- package/dist/src/tools/actoviqNotebookEdit.js +23 -0
- package/dist/src/tools/actoviqNotebookEdit.js.map +1 -0
- package/dist/src/tools/actoviqShellTools.d.ts +5 -0
- package/dist/src/tools/actoviqShellTools.d.ts.map +1 -0
- package/dist/src/tools/actoviqShellTools.js +35 -0
- package/dist/src/tools/actoviqShellTools.js.map +1 -0
- package/dist/src/tools/actoviqTaskTools.d.ts +12 -0
- package/dist/src/tools/actoviqTaskTools.d.ts.map +1 -0
- package/dist/src/tools/actoviqTaskTools.js +108 -0
- package/dist/src/tools/actoviqTaskTools.js.map +1 -0
- package/dist/src/tools/actoviqWebTools.d.ts +15 -0
- package/dist/src/tools/actoviqWebTools.d.ts.map +1 -0
- package/dist/src/tools/actoviqWebTools.js +395 -0
- package/dist/src/tools/actoviqWebTools.js.map +1 -0
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.d.ts +6 -0
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.d.ts.map +1 -0
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.js +43 -0
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.js.map +1 -0
- package/dist/src/tools/bash/BashTool.d.ts +14 -0
- package/dist/src/tools/bash/BashTool.d.ts.map +1 -0
- package/dist/src/tools/bash/BashTool.js +60 -0
- package/dist/src/tools/bash/BashTool.js.map +1 -0
- package/dist/src/tools/bash/prompt.d.ts +3 -0
- package/dist/src/tools/bash/prompt.d.ts.map +1 -0
- package/dist/src/tools/bash/prompt.js +63 -0
- package/dist/src/tools/bash/prompt.js.map +1 -0
- package/dist/src/tools/prompts/fileEditPrompt.d.ts +3 -0
- package/dist/src/tools/prompts/fileEditPrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/fileEditPrompt.js +14 -0
- package/dist/src/tools/prompts/fileEditPrompt.js.map +1 -0
- package/dist/src/tools/prompts/fileReadPrompt.d.ts +3 -0
- package/dist/src/tools/prompts/fileReadPrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/fileReadPrompt.js +18 -0
- package/dist/src/tools/prompts/fileReadPrompt.js.map +1 -0
- package/dist/src/tools/prompts/fileSearchPrompt.d.ts +2 -0
- package/dist/src/tools/prompts/fileSearchPrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/fileSearchPrompt.js +21 -0
- package/dist/src/tools/prompts/fileSearchPrompt.js.map +1 -0
- package/dist/src/tools/prompts/fileWritePrompt.d.ts +3 -0
- package/dist/src/tools/prompts/fileWritePrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/fileWritePrompt.js +13 -0
- package/dist/src/tools/prompts/fileWritePrompt.js.map +1 -0
- package/dist/src/tools/prompts/webFetchPrompt.d.ts +3 -0
- package/dist/src/tools/prompts/webFetchPrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/webFetchPrompt.js +13 -0
- package/dist/src/tools/prompts/webFetchPrompt.js.map +1 -0
- package/dist/src/tools/prompts/webSearchPrompt.d.ts +3 -0
- package/dist/src/tools/prompts/webSearchPrompt.d.ts.map +1 -0
- package/dist/src/tools/prompts/webSearchPrompt.js +17 -0
- package/dist/src/tools/prompts/webSearchPrompt.js.map +1 -0
- package/dist/src/tools/todo/TodoWriteTool.d.ts +6 -0
- package/dist/src/tools/todo/TodoWriteTool.d.ts.map +1 -0
- package/dist/src/tools/todo/TodoWriteTool.js +62 -0
- package/dist/src/tools/todo/TodoWriteTool.js.map +1 -0
- package/dist/src/types.d.ts +456 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/workflow/types.d.ts +59 -0
- package/dist/src/workflow/types.d.ts.map +1 -0
- package/dist/src/workflow/types.js +2 -0
- package/dist/src/workflow/types.js.map +1 -0
- package/dist/src/workflow/workflowBuilder.d.ts +39 -0
- package/dist/src/workflow/workflowBuilder.d.ts.map +1 -0
- package/dist/src/workflow/workflowBuilder.js +77 -0
- package/dist/src/workflow/workflowBuilder.js.map +1 -0
- package/dist/src/workflow/workflowEngine.d.ts +9 -0
- package/dist/src/workflow/workflowEngine.d.ts.map +1 -0
- package/dist/src/workflow/workflowEngine.js +312 -0
- package/dist/src/workflow/workflowEngine.js.map +1 -0
- package/package.json +29 -6
- package/vendor/actoviq-runtime/cli.js +54 -0
package/README-zh.md
CHANGED
|
@@ -36,8 +36,16 @@ import { createAgentSdk, loadDefaultActoviqSettings } from 'actoviq-agent-sdk';
|
|
|
36
36
|
|
|
37
37
|
await loadDefaultActoviqSettings();
|
|
38
38
|
|
|
39
|
+
// 默认:Anthropic 协议
|
|
39
40
|
const sdk = await createAgentSdk();
|
|
40
41
|
|
|
42
|
+
// 或使用 OpenAI / OpenAI 兼容接口(DeepSeek、vLLM 等)
|
|
43
|
+
const sdk = await createAgentSdk({
|
|
44
|
+
provider: 'openai',
|
|
45
|
+
baseURL: 'https://api.deepseek.com',
|
|
46
|
+
model: 'deepseek-chat',
|
|
47
|
+
});
|
|
48
|
+
|
|
41
49
|
try {
|
|
42
50
|
const result = await sdk.run('请用一句话做自我介绍。');
|
|
43
51
|
console.log(result.text);
|
|
@@ -49,10 +57,26 @@ try {
|
|
|
49
57
|
运行仓库自带示例:
|
|
50
58
|
|
|
51
59
|
```bash
|
|
52
|
-
npm run example:quickstart
|
|
60
|
+
npm run example:actoviq-quickstart
|
|
53
61
|
npm run example:actoviq-agent-helpers
|
|
54
62
|
```
|
|
55
63
|
|
|
64
|
+
## CLI 交互式 REPL
|
|
65
|
+
|
|
66
|
+
安装包后,可以直接在终端启动交互式 REPL:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx actoviq-react [工作目录]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
这是一个基于 readline 的交互式 Agent,特点:
|
|
73
|
+
- 主终端缓冲区实时流式输出(支持原生滚动回看)
|
|
74
|
+
- Tab 补全斜杠命令(`/help`、`/clear`、`/compact`、`/memory`、`/model`、`/tools`、`/dream`、`/exit`)
|
|
75
|
+
- ↑↓ 方向键浏览历史命令
|
|
76
|
+
- Ctrl+C 中止当前请求,连按两次退出
|
|
77
|
+
|
|
78
|
+
**注意:** `actoviq-react` 是一个轻量级滚动 REPL,**不是功能完整的 TUI**。它不使用 alternate screen buffer,不支持 ScrollBox 或富文本终端渲染。适合快速交互和调试,而非替代完整的终端 UI。
|
|
79
|
+
|
|
56
80
|
## 教程入口
|
|
57
81
|
|
|
58
82
|
- English tutorial: [docs/en/README.md](./docs/en/README.md)
|
|
@@ -62,8 +86,8 @@ npm run example:actoviq-agent-helpers
|
|
|
62
86
|
|
|
63
87
|
推荐从这里开始上手:
|
|
64
88
|
|
|
65
|
-
- [examples/quickstart.ts](./examples/quickstart.ts)
|
|
66
|
-
- [examples/actoviq-
|
|
89
|
+
- [examples/actoviq-quickstart.ts](./examples/actoviq-quickstart.ts)
|
|
90
|
+
- [examples/actoviq-workflow.ts](./examples/actoviq-workflow.ts)
|
|
67
91
|
- [examples/actoviq-agent-helpers.ts](./examples/actoviq-agent-helpers.ts)
|
|
68
92
|
|
|
69
93
|
## 欢迎贡献
|
package/README.md
CHANGED
|
@@ -36,8 +36,16 @@ import { createAgentSdk, loadDefaultActoviqSettings } from 'actoviq-agent-sdk';
|
|
|
36
36
|
|
|
37
37
|
await loadDefaultActoviqSettings();
|
|
38
38
|
|
|
39
|
+
// Default: Anthropic protocol
|
|
39
40
|
const sdk = await createAgentSdk();
|
|
40
41
|
|
|
42
|
+
// Or use OpenAI / OpenAI-compatible APIs (DeepSeek, vLLM, etc.)
|
|
43
|
+
const sdk = await createAgentSdk({
|
|
44
|
+
provider: 'openai',
|
|
45
|
+
baseURL: 'https://api.deepseek.com',
|
|
46
|
+
model: 'deepseek-chat',
|
|
47
|
+
});
|
|
48
|
+
|
|
41
49
|
try {
|
|
42
50
|
const result = await sdk.run('Introduce yourself in one short sentence.');
|
|
43
51
|
console.log(result.text);
|
|
@@ -49,10 +57,26 @@ try {
|
|
|
49
57
|
Run the repository examples with:
|
|
50
58
|
|
|
51
59
|
```bash
|
|
52
|
-
npm run example:quickstart
|
|
60
|
+
npm run example:actoviq-quickstart
|
|
53
61
|
npm run example:actoviq-agent-helpers
|
|
54
62
|
```
|
|
55
63
|
|
|
64
|
+
## CLI REPL
|
|
65
|
+
|
|
66
|
+
After installing the package, you can start an interactive scrollback-mode REPL directly from the terminal:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx actoviq-react [work-dir]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This launches a readline-based interactive agent with:
|
|
73
|
+
- Real-time streaming output in the main terminal buffer (native scrollback)
|
|
74
|
+
- Tab completion for slash commands (`/help`, `/clear`, `/compact`, `/memory`, `/model`, `/tools`, `/dream`, `/exit`)
|
|
75
|
+
- Command history via ↑↓ arrow keys
|
|
76
|
+
- Ctrl+C to abort the current request, press twice to exit
|
|
77
|
+
|
|
78
|
+
**Note:** `actoviq-react` is a lightweight scrollback REPL, **not a full-featured TUI**. It does not use an alternate screen buffer, ScrollBox, or rich terminal rendering. It is designed for quick interaction and debugging, not as a replacement for a complete terminal UI.
|
|
79
|
+
|
|
56
80
|
## Tutorials
|
|
57
81
|
|
|
58
82
|
- English tutorial: [docs/en/README.md](./docs/en/README.md)
|
|
@@ -62,8 +86,8 @@ npm run example:actoviq-agent-helpers
|
|
|
62
86
|
|
|
63
87
|
Start with these examples:
|
|
64
88
|
|
|
65
|
-
- [examples/quickstart.ts](./examples/quickstart.ts)
|
|
66
|
-
- [examples/actoviq-
|
|
89
|
+
- [examples/actoviq-quickstart.ts](./examples/actoviq-quickstart.ts)
|
|
90
|
+
- [examples/actoviq-workflow.ts](./examples/actoviq-workflow.ts)
|
|
67
91
|
- [examples/actoviq-agent-helpers.ts](./examples/actoviq-agent-helpers.ts)
|
|
68
92
|
|
|
69
93
|
## Contributing
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Link or copy a third-party agent runtime bundle for use with the bridge SDK.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx actoviq-link-runtime /path/to/claude-code
|
|
7
|
+
* npx actoviq-link-runtime /path/to/runtime-bundle
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, symlinkSync, copyFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
10
|
+
import { resolve, join, dirname } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const targetDir = resolve(__dirname, '..', 'vendor', 'actoviq-runtime');
|
|
15
|
+
const targetPath = join(targetDir, 'runtime.bundle.br');
|
|
16
|
+
|
|
17
|
+
const input = process.argv[2];
|
|
18
|
+
if (!input || input === '--help' || input === '-h') {
|
|
19
|
+
console.log('Usage: actoviq-link-runtime <path>');
|
|
20
|
+
console.log('');
|
|
21
|
+
console.log(' <path> Path to a third-party agent runtime installation,');
|
|
22
|
+
console.log(' or directly to a runtime bundle file.');
|
|
23
|
+
console.log('');
|
|
24
|
+
console.log('Examples:');
|
|
25
|
+
console.log(' actoviq-link-runtime ~/.nvm/versions/node/v22/lib/node_modules/@anthropic-ai/claude-code');
|
|
26
|
+
console.log(' actoviq-link-runtime /usr/local/lib/node_modules/@anthropic-ai/claude-code');
|
|
27
|
+
console.log(' actoviq-link-runtime ./runtime-bundle');
|
|
28
|
+
console.log('');
|
|
29
|
+
console.log('The bridge SDK works with a third-party agent runtime bundle');
|
|
30
|
+
console.log('to provide the reference implementation.');
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sourcePath = resolve(input);
|
|
35
|
+
|
|
36
|
+
// If the input is a directory, look for the bundle inside it
|
|
37
|
+
let bundlePath;
|
|
38
|
+
if (existsSync(sourcePath) && existsSync(join(sourcePath, 'vendor', 'actoviq-runtime', 'runtime.bundle.br'))) {
|
|
39
|
+
bundlePath = join(sourcePath, 'vendor', 'actoviq-runtime', 'runtime.bundle.br');
|
|
40
|
+
} else if (existsSync(sourcePath) && sourcePath.endsWith('.br')) {
|
|
41
|
+
bundlePath = sourcePath;
|
|
42
|
+
} else if (existsSync(join(sourcePath, 'runtime.bundle.br'))) {
|
|
43
|
+
bundlePath = join(sourcePath, 'runtime.bundle.br');
|
|
44
|
+
} else {
|
|
45
|
+
console.error(`Could not find runtime bundle in: ${sourcePath}`);
|
|
46
|
+
console.error('Make sure the path points to an agent runtime installation or a runtime bundle file.');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!existsSync(bundlePath)) {
|
|
51
|
+
console.error(`Bundle not found at: ${bundlePath}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Remove existing target if any
|
|
56
|
+
if (existsSync(targetPath)) {
|
|
57
|
+
console.log(`Removing existing: ${targetPath}`);
|
|
58
|
+
unlinkSync(targetPath);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Try symlink first, fall back to copy
|
|
62
|
+
try {
|
|
63
|
+
mkdirSync(targetDir, { recursive: true });
|
|
64
|
+
symlinkSync(bundlePath, targetPath);
|
|
65
|
+
console.log(`Linked: ${bundlePath} -> ${targetPath}`);
|
|
66
|
+
} catch {
|
|
67
|
+
mkdirSync(targetDir, { recursive: true });
|
|
68
|
+
copyFileSync(bundlePath, targetPath);
|
|
69
|
+
console.log(`Copied: ${bundlePath} -> ${targetPath}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log('');
|
|
73
|
+
console.log('Bridge runtime bundle is now available.');
|
|
74
|
+
console.log('Run: npx actoviq-interactive-agent');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actoviq-react.d.ts","sourceRoot":"","sources":["../../../src/cli/actoviq-react.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Actoviq — Interactive terminal agent.
|
|
4
|
+
*
|
|
5
|
+
* Clean SDK scrollback-mode REPL with readline input, slash commands,
|
|
6
|
+
* and real-time streaming output. Uses the main terminal buffer for
|
|
7
|
+
* native scrollback.
|
|
8
|
+
*/
|
|
9
|
+
import { createAgentSdk, loadJsonConfigFile, createActoviqCoreTools } from 'actoviq-agent-sdk';
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import * as readline from 'node:readline';
|
|
14
|
+
const WORK_DIR = path.resolve(process.argv[2] ?? process.cwd());
|
|
15
|
+
const CONFIG_PATH = process.argv[3] ?? path.join(os.homedir(), '.actoviq', 'settings.json');
|
|
16
|
+
let isGit = false;
|
|
17
|
+
try {
|
|
18
|
+
execSync('git rev-parse --is-inside-work-tree', { cwd: WORK_DIR, stdio: 'ignore' });
|
|
19
|
+
isGit = true;
|
|
20
|
+
}
|
|
21
|
+
catch { }
|
|
22
|
+
// ── ANSI ────────────────────────────────────────────────────────────
|
|
23
|
+
const C = {
|
|
24
|
+
r: '\x1b[0m', d: '\x1b[2m', c: '\x1b[36m', y: '\x1b[33m',
|
|
25
|
+
g: '\x1b[32m', R: '\x1b[31m', b: '\x1b[1m', m: '\x1b[35m',
|
|
26
|
+
};
|
|
27
|
+
function stripAnsi(s) {
|
|
28
|
+
return s.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
29
|
+
}
|
|
30
|
+
// ── System prompt ────────────────────────────────────────────────────
|
|
31
|
+
const SYSTEM_PROMPT = `You are Actoviq, an interactive CLI agent. Working directory: ${WORK_DIR}\n\n` +
|
|
32
|
+
`<env>\nWorking directory: ${WORK_DIR}\nIs git repo: ${isGit ? 'Yes' : 'No'}\nPlatform: ${process.platform}\nDate: ${new Date().toISOString().slice(0, 10)}\n</env>\n\n` +
|
|
33
|
+
`# Tone and style\n` +
|
|
34
|
+
`- Only use emojis if the user explicitly requests it.\n` +
|
|
35
|
+
`- Your responses should be short and concise.\n` +
|
|
36
|
+
`- When referencing code include the pattern file_path:line_number.\n\n` +
|
|
37
|
+
`# Doing tasks\n` +
|
|
38
|
+
`- Prefer editing existing files to creating new ones.\n` +
|
|
39
|
+
`- Do not add features, refactor, or introduce abstractions beyond what the task requires.\n` +
|
|
40
|
+
`- Default to writing no comments.\n\n` +
|
|
41
|
+
`# Git Safety Protocol\n` +
|
|
42
|
+
`- NEVER update the git config\n` +
|
|
43
|
+
`- NEVER run destructive git commands unless the user explicitly requests\n` +
|
|
44
|
+
`- NEVER skip hooks unless the user explicitly requests it\n` +
|
|
45
|
+
`- NEVER commit changes unless the user explicitly asks you to\n\n` +
|
|
46
|
+
`# Other\n` +
|
|
47
|
+
`- NEVER create documentation files (*.md) unless explicitly requested.\n` +
|
|
48
|
+
`- When in doubt, use TodoWrite to track progress.`;
|
|
49
|
+
// ── Slash commands ────────────────────────────────────────────────────
|
|
50
|
+
const CMDS = {
|
|
51
|
+
help: 'Show available commands',
|
|
52
|
+
clear: 'Clear the screen',
|
|
53
|
+
exit: 'Quit',
|
|
54
|
+
compact: 'Compact the current session',
|
|
55
|
+
memory: 'Show memory/compact state',
|
|
56
|
+
model: 'Show current model',
|
|
57
|
+
tools: 'List available tools',
|
|
58
|
+
dream: 'Trigger memory consolidation',
|
|
59
|
+
};
|
|
60
|
+
function completer(line) {
|
|
61
|
+
if (!line.startsWith('/'))
|
|
62
|
+
return [[], line];
|
|
63
|
+
const partial = line.slice(1).toLowerCase();
|
|
64
|
+
const hits = Object.keys(CMDS).filter(c => c.startsWith(partial));
|
|
65
|
+
return [hits.map(h => hits.length === 1 ? `/${h} ` : `/${h}`), line];
|
|
66
|
+
}
|
|
67
|
+
// ── Render helpers ────────────────────────────────────────────────────
|
|
68
|
+
function toolLine(name, input) {
|
|
69
|
+
const inp = JSON.stringify(input);
|
|
70
|
+
process.stdout.write(`${C.y} ⚡ ${name}${C.r} ${C.d}${inp.slice(0, 120)}${inp.length > 120 ? '...' : ''}${C.r}\n`);
|
|
71
|
+
}
|
|
72
|
+
function resultLine(isErr, dur, output) {
|
|
73
|
+
const ok = isErr ? `${C.R}✗` : `${C.g}✓`;
|
|
74
|
+
const d = dur ? ` ${dur < 1000 ? dur + 'ms' : (dur / 1000).toFixed(1) + 's'}` : '';
|
|
75
|
+
let o = '';
|
|
76
|
+
if (typeof output === 'string')
|
|
77
|
+
o = output.slice(0, 200);
|
|
78
|
+
else if (output)
|
|
79
|
+
o = JSON.stringify(output).slice(0, 200);
|
|
80
|
+
process.stdout.write(`${ok}${C.r}${C.d}${d} ${o}${C.r}\n`);
|
|
81
|
+
}
|
|
82
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
83
|
+
async function main() {
|
|
84
|
+
// Header
|
|
85
|
+
const w = process.stdout.columns || 80;
|
|
86
|
+
process.stdout.write(`\n${C.c}${C.b}╭${'─'.repeat(Math.min(w - 2, 60))}╮${C.r}\n`);
|
|
87
|
+
process.stdout.write(`${C.c}│${C.r} dir : ${C.y}${WORK_DIR.slice(0, 45)}${C.r}\n`);
|
|
88
|
+
try {
|
|
89
|
+
await loadJsonConfigFile(CONFIG_PATH);
|
|
90
|
+
}
|
|
91
|
+
catch { }
|
|
92
|
+
const sdk = await createAgentSdk({ workDir: WORK_DIR });
|
|
93
|
+
const tools = createActoviqCoreTools({ cwd: WORK_DIR });
|
|
94
|
+
const session = await sdk.createSession({ title: path.basename(WORK_DIR) });
|
|
95
|
+
process.stdout.write(`${C.c}│${C.r} model : ${C.y}${sdk.config.model}${C.r}\n`);
|
|
96
|
+
process.stdout.write(`${C.c}│${C.r} tools : ${C.y}${tools.length} tools loaded${C.r}\n`);
|
|
97
|
+
process.stdout.write(`${C.c}│${C.r} keys : Tab=complete ↑↓=history Ctrl+C=abort${C.r}\n`);
|
|
98
|
+
process.stdout.write(`${C.c}├${'─'.repeat(Math.min(w - 2, 60))}┤${C.r}\n\n`);
|
|
99
|
+
let abortCtrl = null;
|
|
100
|
+
let msgCount = 0;
|
|
101
|
+
// ── Process message ────────────────────────────────────────────
|
|
102
|
+
async function processMsg(text) {
|
|
103
|
+
const t = text.trim();
|
|
104
|
+
if (!t)
|
|
105
|
+
return;
|
|
106
|
+
msgCount++;
|
|
107
|
+
if (t.startsWith('/')) {
|
|
108
|
+
const sp = t.indexOf(' ');
|
|
109
|
+
const cmd = sp === -1 ? t.slice(1) : t.slice(1, sp);
|
|
110
|
+
switch (cmd) {
|
|
111
|
+
case 'exit':
|
|
112
|
+
process.stdout.write(`\n${C.d}Goodbye.${C.r}\n`);
|
|
113
|
+
process.exit(0);
|
|
114
|
+
case 'clear':
|
|
115
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
116
|
+
return;
|
|
117
|
+
case 'help':
|
|
118
|
+
process.stdout.write(`\n${C.b}Commands:${C.r}\n`);
|
|
119
|
+
for (const [k, v] of Object.entries(CMDS))
|
|
120
|
+
process.stdout.write(` ${C.y}/${k.padEnd(10)}${C.r} ${C.d}${v}${C.r}\n`);
|
|
121
|
+
process.stdout.write(`\n`);
|
|
122
|
+
return;
|
|
123
|
+
case 'model':
|
|
124
|
+
process.stdout.write(`${C.d}Model: ${C.y}${sdk.config.model}${C.r}\n\n`);
|
|
125
|
+
return;
|
|
126
|
+
case 'tools':
|
|
127
|
+
process.stdout.write(`${C.d}${tools.map(t => `${C.y}${t.name}${C.r}`).join(', ')}${C.r}\n\n`);
|
|
128
|
+
return;
|
|
129
|
+
case 'memory':
|
|
130
|
+
try {
|
|
131
|
+
const s = await session.compactState();
|
|
132
|
+
process.stdout.write(`${C.d}${JSON.stringify(s, null, 2)}${C.r}\n\n`);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
process.stdout.write(`${C.d}N/A${C.r}\n\n`);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
case 'compact':
|
|
139
|
+
try {
|
|
140
|
+
const r = await session.compact({ force: true });
|
|
141
|
+
process.stdout.write(`${C.g}✓ Compacted: ${r.messagesRemoved ?? '?'} msgs removed${C.r}\n\n`);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
process.stdout.write(`${C.R}✕ ${e.message}${C.r}\n\n`);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
case 'dream':
|
|
148
|
+
try {
|
|
149
|
+
await session.dream({ force: true });
|
|
150
|
+
process.stdout.write(`${C.g}✓ Dream triggered${C.r}\n\n`);
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
process.stdout.write(`${C.R}✕ ${e.message}${C.r}\n\n`);
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
default:
|
|
157
|
+
process.stdout.write(`${C.R}Unknown: /${cmd}${C.r} ${C.d}Type /help${C.r}\n\n`);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
abortCtrl = new AbortController();
|
|
162
|
+
const stream = session.stream(t, {
|
|
163
|
+
tools, systemPrompt: SYSTEM_PROMPT, signal: abortCtrl.signal, model: sdk.config.model,
|
|
164
|
+
});
|
|
165
|
+
let iteration = 0;
|
|
166
|
+
let hasText = false;
|
|
167
|
+
const activeTools = new Map();
|
|
168
|
+
for await (const event of stream) {
|
|
169
|
+
switch (event.type) {
|
|
170
|
+
case 'request.started':
|
|
171
|
+
iteration = event.iteration;
|
|
172
|
+
if (iteration > 1)
|
|
173
|
+
process.stdout.write(`\n${C.d}── iteration ${iteration} ──${C.r}\n`);
|
|
174
|
+
break;
|
|
175
|
+
case 'response.text.delta': {
|
|
176
|
+
const txt = typeof event.delta === 'string' ? event.delta : event.delta?.text ?? '';
|
|
177
|
+
process.stdout.write(txt);
|
|
178
|
+
hasText = true;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case 'response.content':
|
|
182
|
+
if (event.content.type === 'thinking') {
|
|
183
|
+
const th = (event.content.thinking ?? '').slice(0, 250);
|
|
184
|
+
process.stdout.write(`\n${C.d}💭 ${th}${C.r}\n`);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case 'tool.call': {
|
|
188
|
+
activeTools.set(event.call.id, { name: event.call.name, start: Date.now() });
|
|
189
|
+
toolLine(event.call.name, event.call.input);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case 'tool.progress': {
|
|
193
|
+
const p = event.data;
|
|
194
|
+
if (p?.message)
|
|
195
|
+
process.stdout.write(`\r\x1b[K${C.d} ${p.message}${C.r}`);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'tool.result': {
|
|
199
|
+
const info = activeTools.get(event.result.id);
|
|
200
|
+
activeTools.delete(event.result.id);
|
|
201
|
+
resultLine(event.result.isError, info ? Date.now() - info.start : undefined, event.result.output);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
case 'session.compacted':
|
|
205
|
+
process.stdout.write(`\n${C.d}── context compacted ──${C.r}\n`);
|
|
206
|
+
break;
|
|
207
|
+
case 'error':
|
|
208
|
+
process.stdout.write(`\n${C.R} ✕ ${event.error.message}${C.r}\n`);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!hasText) {
|
|
213
|
+
const r = await stream.result;
|
|
214
|
+
if (r.text)
|
|
215
|
+
process.stdout.write(r.text);
|
|
216
|
+
}
|
|
217
|
+
process.stdout.write(`\n`);
|
|
218
|
+
}
|
|
219
|
+
// ── Readline ──────────────────────────────────────────────────
|
|
220
|
+
const rl = readline.createInterface({
|
|
221
|
+
input: process.stdin, output: process.stdout,
|
|
222
|
+
prompt: '', completer, historySize: 1000, terminal: true,
|
|
223
|
+
});
|
|
224
|
+
rl.setPrompt(`${C.c}> ${C.r}`);
|
|
225
|
+
let cc = 0;
|
|
226
|
+
let ccT = null;
|
|
227
|
+
readline.emitKeypressEvents(process.stdin);
|
|
228
|
+
if (process.stdin.isTTY)
|
|
229
|
+
process.stdin.setRawMode(true);
|
|
230
|
+
process.stdin.on('keypress', (_ch, key) => {
|
|
231
|
+
if (key?.name === 'c' && key?.ctrl) {
|
|
232
|
+
cc++;
|
|
233
|
+
if (cc >= 2) {
|
|
234
|
+
process.stdout.write(`\n${C.d}Goodbye.${C.r}\n`);
|
|
235
|
+
rl.close();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (ccT)
|
|
239
|
+
clearTimeout(ccT);
|
|
240
|
+
ccT = setTimeout(() => { cc = 0; }, 500);
|
|
241
|
+
if (abortCtrl) {
|
|
242
|
+
abortCtrl.abort();
|
|
243
|
+
process.stdout.write(`\n${C.y} ⏹ Aborting...${C.r}\n`);
|
|
244
|
+
}
|
|
245
|
+
process.stdout.write('\n');
|
|
246
|
+
rl.prompt();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
cc = 0;
|
|
250
|
+
});
|
|
251
|
+
rl.prompt();
|
|
252
|
+
rl.on('line', async (line) => {
|
|
253
|
+
abortCtrl = null;
|
|
254
|
+
try {
|
|
255
|
+
await processMsg(line);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
if (e.name === 'AbortError')
|
|
259
|
+
process.stdout.write(`\n${C.y} ⏹ aborted${C.r}\n`);
|
|
260
|
+
else
|
|
261
|
+
process.stdout.write(`\n${C.R} ✕ ${e.message}${C.r}\n`);
|
|
262
|
+
}
|
|
263
|
+
rl.prompt();
|
|
264
|
+
});
|
|
265
|
+
rl.on('close', async () => {
|
|
266
|
+
if (process.stdin.isTTY)
|
|
267
|
+
process.stdin.setRawMode(false);
|
|
268
|
+
process.stdout.write(`\n${C.d}Goodbye.${C.r}\n`);
|
|
269
|
+
try {
|
|
270
|
+
await sdk.close();
|
|
271
|
+
}
|
|
272
|
+
catch { }
|
|
273
|
+
process.exit(0);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
main().catch((e) => { process.stderr.write(`Fatal: ${e.message}\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AAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAW,CAAW,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-interactive-agent.d.ts","sourceRoot":"","sources":["../../../src/cli/bridge-interactive-agent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { constants as fsConstants } from 'node:fs';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createInterface } from 'node:readline/promises';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { analyzeActoviqBridgeEvents, createActoviqBridgeSdk, getActoviqBridgeTextDelta, loadDefaultActoviqSettings, loadJsonConfigFile, } from 'actoviq-agent-sdk';
|
|
7
|
+
const WORKSPACE_PATH = process.cwd();
|
|
8
|
+
const JSON_CONFIG_PATH = path.resolve(process.cwd(), 'examples', 'interactive-agent.settings.local.json');
|
|
9
|
+
const EXIT_COMMANDS = new Set(['exit', 'quit', '/exit', ':q']);
|
|
10
|
+
async function ensureFileExists(filePath) {
|
|
11
|
+
try {
|
|
12
|
+
await access(filePath, fsConstants.F_OK);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error(`The config file was not found: ${filePath}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function summarizeJson(value) {
|
|
19
|
+
if (value == null) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
const serialized = JSON.stringify(value);
|
|
23
|
+
if (!serialized) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
return serialized.length > 160 ? `${serialized.slice(0, 157)}...` : serialized;
|
|
27
|
+
}
|
|
28
|
+
function shouldExit(input) {
|
|
29
|
+
return EXIT_COMMANDS.has(input.trim().toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
async function main() {
|
|
32
|
+
let configSource = JSON_CONFIG_PATH;
|
|
33
|
+
try {
|
|
34
|
+
await ensureFileExists(JSON_CONFIG_PATH);
|
|
35
|
+
await loadJsonConfigFile(JSON_CONFIG_PATH);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
await loadDefaultActoviqSettings();
|
|
39
|
+
configSource = '~/.actoviq/settings.json';
|
|
40
|
+
}
|
|
41
|
+
const sdk = await createActoviqBridgeSdk({
|
|
42
|
+
workDir: WORKSPACE_PATH,
|
|
43
|
+
tools: 'default',
|
|
44
|
+
maxTurns: 32,
|
|
45
|
+
permissionMode: 'bypassPermissions',
|
|
46
|
+
dangerouslySkipPermissions: true,
|
|
47
|
+
includePartialMessages: true,
|
|
48
|
+
});
|
|
49
|
+
const runtime = await sdk.getRuntimeInfo({
|
|
50
|
+
workDir: WORKSPACE_PATH,
|
|
51
|
+
maxTurns: 2,
|
|
52
|
+
});
|
|
53
|
+
const session = await sdk.createSession({
|
|
54
|
+
title: 'Interactive Agent Example',
|
|
55
|
+
workDir: WORKSPACE_PATH,
|
|
56
|
+
tools: 'default',
|
|
57
|
+
maxTurns: 32,
|
|
58
|
+
permissionMode: 'bypassPermissions',
|
|
59
|
+
dangerouslySkipPermissions: true,
|
|
60
|
+
includePartialMessages: true,
|
|
61
|
+
});
|
|
62
|
+
const rl = createInterface({
|
|
63
|
+
input: process.stdin,
|
|
64
|
+
output: process.stdout,
|
|
65
|
+
terminal: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
66
|
+
});
|
|
67
|
+
console.log('Actoviq interactive agent example');
|
|
68
|
+
console.log(`Workspace: ${WORKSPACE_PATH}`);
|
|
69
|
+
console.log(`Config source: ${configSource}`);
|
|
70
|
+
console.log(`Runtime model: ${runtime.model ?? 'unknown-model'}`);
|
|
71
|
+
console.log(`Built-in tools: ${runtime.tools.join(', ')}`);
|
|
72
|
+
console.log(`Skills: ${runtime.skills.join(', ')}`);
|
|
73
|
+
console.log(`Agents: ${runtime.agents.join(', ')}`);
|
|
74
|
+
console.log('Type your prompt and press Enter.');
|
|
75
|
+
console.log('Use exit, quit, /exit, or :q to leave.');
|
|
76
|
+
try {
|
|
77
|
+
while (true) {
|
|
78
|
+
let prompt = '';
|
|
79
|
+
try {
|
|
80
|
+
prompt = (await rl.question('\nYou> ')).trim();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (!prompt) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (shouldExit(prompt)) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
const stream = session.stream(prompt);
|
|
92
|
+
let printedText = false;
|
|
93
|
+
const bufferedEvents = [];
|
|
94
|
+
for await (const event of stream) {
|
|
95
|
+
bufferedEvents.push(event);
|
|
96
|
+
const delta = getActoviqBridgeTextDelta(event);
|
|
97
|
+
if (delta) {
|
|
98
|
+
if (!printedText) {
|
|
99
|
+
process.stdout.write('\nAgent> ');
|
|
100
|
+
printedText = true;
|
|
101
|
+
}
|
|
102
|
+
process.stdout.write(delta);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const result = await stream.result;
|
|
106
|
+
const analysis = analyzeActoviqBridgeEvents(bufferedEvents);
|
|
107
|
+
if (printedText) {
|
|
108
|
+
process.stdout.write('\n');
|
|
109
|
+
}
|
|
110
|
+
else if (result.text.trim()) {
|
|
111
|
+
console.log(`\nAgent> ${result.text}`);
|
|
112
|
+
}
|
|
113
|
+
if (result.initEvent) {
|
|
114
|
+
const tools = Array.isArray(result.initEvent.tools) ? result.initEvent.tools.length : 0;
|
|
115
|
+
const skills = Array.isArray(result.initEvent.skills) ? result.initEvent.skills.length : 0;
|
|
116
|
+
const agents = Array.isArray(result.initEvent.agents) ? result.initEvent.agents.length : 0;
|
|
117
|
+
const model = typeof result.initEvent.model === 'string' ? result.initEvent.model : 'unknown-model';
|
|
118
|
+
console.log(`\n[session ready] ${result.sessionId}`);
|
|
119
|
+
console.log(`[runtime] model=${model} tools=${tools} skills=${skills} agents=${agents}`);
|
|
120
|
+
}
|
|
121
|
+
for (const request of analysis.toolRequests) {
|
|
122
|
+
const inputSummary = summarizeJson(request.input);
|
|
123
|
+
console.log(`\n[tool request] ${request.name}${inputSummary ? ` ${inputSummary}` : ''}`);
|
|
124
|
+
}
|
|
125
|
+
for (const task of analysis.taskInvocations) {
|
|
126
|
+
const subject = task.subagentType ?? 'inherit';
|
|
127
|
+
const label = task.description ?? task.prompt ?? 'no-task-prompt';
|
|
128
|
+
console.log(`[task] subagent=${subject} prompt=${label}`);
|
|
129
|
+
}
|
|
130
|
+
for (const toolResult of analysis.toolResults) {
|
|
131
|
+
const status = toolResult.isError ? 'error' : 'ok';
|
|
132
|
+
console.log(`\n[tool result] ${toolResult.toolUseId} (${status})`);
|
|
133
|
+
}
|
|
134
|
+
console.log(`[turn complete] session=${result.sessionId} turns=${result.numTurns ?? 'unknown'} status=${result.subtype ?? 'unknown'}`);
|
|
135
|
+
if (result.isError && result.stderr.trim()) {
|
|
136
|
+
console.log(`[stderr] ${result.stderr.trim()}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
rl.close();
|
|
142
|
+
await sdk.close();
|
|
143
|
+
}
|
|
144
|
+
console.log('\nInteractive session closed.');
|
|
145
|
+
}
|
|
146
|
+
await main();
|
|
147
|
+
//# sourceMappingURL=bridge-interactive-agent.js.map
|