@steerable/agent-shell 0.6.21 → 0.6.22
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.md +34 -0
- package/dist/auth/index.d.ts +38 -0
- package/dist/auth/index.js +20 -0
- package/dist/host/pack-assembly.d.ts +7 -7
- package/dist/host/runtime.d.ts +6 -2
- package/dist/host/runtime.js +54 -14
- package/dist/insights/flush.d.ts +5 -4
- package/dist/insights/flush.js +14 -15
- package/dist/insights/record.d.ts +6 -5
- package/dist/insights/record.js +9 -10
- package/dist/llm/index.d.ts +6 -2
- package/dist/llm/index.js +19 -9
- package/dist/local-backend/prompt-builder.d.ts +10 -4
- package/dist/local-backend/prompt-builder.js +13 -12
- package/dist/local-backend/router.d.ts +18 -4
- package/dist/local-backend/router.js +133 -98
- package/dist/local-backend/skills/00-identity/SKILL.md +1 -1
- package/dist/local-backend/task-service.d.ts +14 -13
- package/dist/local-backend/task-service.js +32 -29
- package/dist/local-backend/worktree-service.d.ts +1 -1
- package/dist/local-backend/worktree-service.js +6 -6
- package/dist/main.js +43 -26
- package/dist/server/http-server.d.ts +13 -1
- package/dist/server/http-server.js +37 -8
- package/dist/server/index.js +4 -90
- package/dist/server/start.d.ts +26 -0
- package/dist/server/start.js +111 -0
- package/dist/sidecar/boot.d.ts +3 -1
- package/dist/sidecar/boot.js +6 -7
- package/dist/sidecar/reverse-spawn.js +12 -4
- package/dist/sidecar/reverse-tools.d.ts +1 -1
- package/dist/sidecar/reverse-tools.js +1 -1
- package/dist/sidecar/storage-path.js +2 -3
- package/dist/storage/driver.d.ts +57 -0
- package/dist/storage/driver.js +104 -0
- package/dist/storage/index.d.ts +75 -68
- package/dist/storage/index.js +506 -301
- package/dist/storage/pack-migrations.d.ts +2 -4
- package/dist/storage/pack-migrations.js +2 -4
- package/dist/storage/scoped-store.d.ts +125 -0
- package/dist/storage/scoped-store.js +1 -0
- package/dist/storage/sqlite-driver.d.ts +16 -0
- package/dist/storage/sqlite-driver.js +135 -0
- package/dist/storage/write-lease-error.d.ts +11 -0
- package/dist/storage/write-lease-error.js +18 -0
- package/package.json +14 -5
- package/dist/storage/local-store-singleton.d.ts +0 -28
- package/dist/storage/local-store-singleton.js +0 -38
|
@@ -14,16 +14,17 @@ import path from 'node:path';
|
|
|
14
14
|
import { loadSkills } from './skill-loader.js';
|
|
15
15
|
import { isSkillPinned } from './agent-capability.js';
|
|
16
16
|
import { getBrand } from '../brand.js';
|
|
17
|
-
|
|
17
|
+
function fallbackPrompt(identityName) {
|
|
18
18
|
const brand = getBrand();
|
|
19
|
+
const name = identityName?.trim() || brand.agentName;
|
|
19
20
|
return [
|
|
20
21
|
'# 角色',
|
|
21
22
|
'',
|
|
22
|
-
`你是 ${
|
|
23
|
+
`你是 ${name},${brand.tagline},运行在用户自己的 Windows / macOS / Linux 机器上。`,
|
|
23
24
|
'通过工具直接操作用户的本地环境(shell、文件、当前产品安装的场景工具等)。用中文回复。',
|
|
24
25
|
'不要凭空编造任何工具返回值。',
|
|
25
26
|
].join('\n');
|
|
26
|
-
}
|
|
27
|
+
}
|
|
27
28
|
const DEFAULT_CHAR_BUDGET = 60_000;
|
|
28
29
|
/**
|
|
29
30
|
* Derive condition strings from the set of tool names available this turn.
|
|
@@ -99,7 +100,7 @@ export async function buildSystemPrompt(options = {}) {
|
|
|
99
100
|
prompt: assembleFinal({
|
|
100
101
|
personaPreamble: options.personaPreamble ?? '',
|
|
101
102
|
chatSystemPrompt: options.chatSystemPrompt ?? '',
|
|
102
|
-
body:
|
|
103
|
+
body: fallbackPrompt(options.identityName),
|
|
103
104
|
realityCheckSuffix: options.realityCheckSuffix ?? '',
|
|
104
105
|
}),
|
|
105
106
|
modules,
|
|
@@ -116,9 +117,10 @@ export async function buildSystemPrompt(options = {}) {
|
|
|
116
117
|
if (options.forcedMcpTool) {
|
|
117
118
|
modules.push(buildForcedMcpToolModule(options.forcedMcpTool));
|
|
118
119
|
}
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
// `{agentName}` 优先用本轮智能体显示名,没有绑定智能体时才用产品品牌。
|
|
121
|
+
const body = modules
|
|
122
|
+
.map((m) => renderSkillContent(m, brandSkillVars({ identityName: options.identityName })))
|
|
123
|
+
.join('\n\n');
|
|
122
124
|
return {
|
|
123
125
|
prompt: assembleFinal({
|
|
124
126
|
personaPreamble: options.personaPreamble ?? '',
|
|
@@ -169,14 +171,13 @@ function buildForcedMcpToolModule(t) {
|
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
173
|
/**
|
|
172
|
-
*
|
|
173
|
-
* `{
|
|
174
|
-
* 中性默认)。eager 系统提示词路径统一注入;包技能同理可用。
|
|
174
|
+
* 品牌/身份占位符:`{brandDisplayName}` / `{brandTagline}` 始终是产品品牌;
|
|
175
|
+
* `{agentName}` 有本轮智能体时用智能体显示名,否则回落 `brand.agentName`。
|
|
175
176
|
*/
|
|
176
|
-
export function brandSkillVars() {
|
|
177
|
+
export function brandSkillVars(options = {}) {
|
|
177
178
|
const brand = getBrand();
|
|
178
179
|
return {
|
|
179
|
-
agentName: brand.agentName,
|
|
180
|
+
agentName: options.identityName?.trim() || brand.agentName,
|
|
180
181
|
brandDisplayName: brand.displayName,
|
|
181
182
|
brandTagline: brand.tagline,
|
|
182
183
|
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { ScopedStore } from '../storage/scoped-store.js';
|
|
1
2
|
import { ToolRouter } from '../tool-router.js';
|
|
2
3
|
import type { TaskService } from './task-service.js';
|
|
4
|
+
import { type Principal } from '../auth/index.js';
|
|
3
5
|
export interface LocalBackendRequest {
|
|
4
6
|
method: string;
|
|
5
7
|
path: string;
|
|
6
8
|
body?: unknown;
|
|
9
|
+
/** Authenticated identity supplied by the BS HTTP layer. */
|
|
10
|
+
principal?: Principal;
|
|
7
11
|
}
|
|
8
12
|
export interface LocalBackendResponse<T = unknown> {
|
|
9
13
|
status: number;
|
|
@@ -39,14 +43,23 @@ export interface StreamOptions {
|
|
|
39
43
|
export type LocalBackendBroadcast = (eventName: string, payload: unknown) => void;
|
|
40
44
|
export declare class LocalBackendRouter {
|
|
41
45
|
private readonly toolRouter;
|
|
46
|
+
private readonly defaultStore;
|
|
47
|
+
private readonly storeContext;
|
|
48
|
+
private readonly resolveStore;
|
|
42
49
|
private readonly broadcast;
|
|
43
50
|
/** 4.6a/4.6c:任务面板的路由入口(列表 + 合并/丢弃)。未注入时任务路由 503。 */
|
|
44
51
|
private readonly taskService;
|
|
45
|
-
constructor(toolRouter: ToolRouter, options
|
|
52
|
+
constructor(toolRouter: ToolRouter, options: {
|
|
53
|
+
store: ScopedStore;
|
|
54
|
+
resolveStore?: (principal?: Principal) => ScopedStore;
|
|
46
55
|
broadcast?: LocalBackendBroadcast;
|
|
47
56
|
taskService?: TaskService;
|
|
48
57
|
});
|
|
58
|
+
private get store();
|
|
59
|
+
/** Store selected for the active request, or the host default outside one. */
|
|
60
|
+
get activeStore(): ScopedStore;
|
|
49
61
|
handle(request: LocalBackendRequest): Promise<LocalBackendResponse>;
|
|
62
|
+
private handleScoped;
|
|
50
63
|
/**
|
|
51
64
|
* 对未显式实现的路由做"温柔降级":GET 返回空集合/空对象,不让 UI 因 404 抛错跳到
|
|
52
65
|
* not-found;其他方法返回 success:true 让前端流程继续。所有兜底都在主进程终端
|
|
@@ -67,6 +80,7 @@ export declare class LocalBackendRouter {
|
|
|
67
80
|
* - 结束:标准 SSE `[DONE]` 串。
|
|
68
81
|
*/
|
|
69
82
|
handleStream(request: LocalBackendRequest, emit: StreamEmit, options?: StreamOptions): Promise<StreamResult>;
|
|
83
|
+
private handleStreamScoped;
|
|
70
84
|
/**
|
|
71
85
|
* 后台异步生成 chat 标题。**完全 fire-and-forget**——不阻塞 `[DONE]`,
|
|
72
86
|
* 调用方只要 `void this.runTitleGenInBackground(...)` 就行。
|
|
@@ -89,10 +103,10 @@ export declare class LocalBackendRouter {
|
|
|
89
103
|
* Public: main.ts 的反向通道(reverse-tools.ts)经它给 CoreLoop 路径的
|
|
90
104
|
* 工具调用补上 projectRoot 围栏。
|
|
91
105
|
*/
|
|
92
|
-
resolveChatProject(chatId: string): {
|
|
106
|
+
resolveChatProject(chatId: string): Promise<{
|
|
93
107
|
name: string;
|
|
94
108
|
folderPath: string;
|
|
95
|
-
} | null
|
|
109
|
+
} | null>;
|
|
96
110
|
/**
|
|
97
111
|
* 解析本轮生效的智能体:人设前言、技能勾选、工具策略同源于这一次解析。
|
|
98
112
|
*
|
|
@@ -106,7 +120,7 @@ export declare class LocalBackendRouter {
|
|
|
106
120
|
*
|
|
107
121
|
* @param chatId 当前对话 id。
|
|
108
122
|
* @param payload 前端提交的流请求体。
|
|
109
|
-
* @returns
|
|
123
|
+
* @returns 本轮的智能体顺序、人设智能体、自称,以及合并后的能力面。
|
|
110
124
|
*/
|
|
111
125
|
private resolveTurnAgents;
|
|
112
126
|
private buildConversationMessages;
|