@atlaswork/atlascode 0.0.0-stage → 0.1.125
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 +124 -2
- package/dist/cli.js +506227 -0
- package/dist/web-contract/index.d.ts +727 -0
- package/dist/web-contract/index.js +260 -0
- package/dist/web-session-runtime/atlascode/web/contract.d.ts +10 -0
- package/dist/web-session-runtime/atlascode/web/cursorLedger.d.ts +63 -0
- package/dist/web-session-runtime/atlascode/web/entry.d.ts +19 -0
- package/dist/web-session-runtime/atlascode/web/errors.d.ts +16 -0
- package/dist/web-session-runtime/atlascode/web/follow.d.ts +82 -0
- package/dist/web-session-runtime/atlascode/web/limits.d.ts +63 -0
- package/dist/web-session-runtime/atlascode/web/projection.d.ts +69 -0
- package/dist/web-session-runtime/atlascode/web/readonlyRuntime.d.ts +156 -0
- package/dist/web-session-runtime/atlascode/web/runtimeDefault.d.ts +26 -0
- package/dist/web-session-runtime/atlascode/web/sessionStoreAdapter.d.ts +70 -0
- package/dist/web-session-runtime/engine/session/env.d.ts +32 -0
- package/dist/web-session-runtime/engine/session/firstPrompt.d.ts +21 -0
- package/dist/web-session-runtime/engine/session/json.d.ts +27 -0
- package/dist/web-session-runtime/engine/session/load.d.ts +88 -0
- package/dist/web-session-runtime/engine/session/paths.d.ts +25 -0
- package/dist/web-session-runtime/engine/session/predicates.d.ts +55 -0
- package/dist/web-session-runtime/engine/session/readonly.d.ts +29 -0
- package/dist/web-session-runtime/engine/session/scanner.d.ts +26 -0
- package/dist/web-session-runtime/engine/session/search.d.ts +44 -0
- package/dist/web-session-runtime/engine/session/types.d.ts +379 -0
- package/dist/web-session-runtime/index.d.ts +1 -0
- package/dist/web-session-runtime/index.js +2635 -0
- package/dist/web-session-runtime/kernel/protocol/webSessionV0.d.ts +727 -0
- package/dist/web-session-runtime/shared/ProductDefinition.d.ts +47 -0
- package/dist/web-session-runtime/shared/agentRoleTemplates.d.ts +44 -0
- package/dist/web-session-runtime/shared/agentSwarmsEnabled.d.ts +5 -0
- package/dist/web-session-runtime/shared/boundedImageRead.d.ts +31 -0
- package/dist/web-session-runtime/shared/circular-buffer.d.ts +42 -0
- package/dist/web-session-runtime/shared/configDir.d.ts +57 -0
- package/dist/web-session-runtime/shared/constants.d.ts +19 -0
- package/dist/web-session-runtime/shared/debug.d.ts +32 -0
- package/dist/web-session-runtime/shared/env.d.ts +38 -0
- package/dist/web-session-runtime/shared/errors.d.ts +56 -0
- package/dist/web-session-runtime/shared/feature.d.ts +25 -0
- package/dist/web-session-runtime/shared/format.d.ts +11 -0
- package/dist/web-session-runtime/shared/fs-operations.d.ts +116 -0
- package/dist/web-session-runtime/shared/hash.d.ts +13 -0
- package/dist/web-session-runtime/shared/identity.d.ts +23 -0
- package/dist/web-session-runtime/shared/index.d.ts +46 -0
- package/dist/web-session-runtime/shared/lazySchema.d.ts +12 -0
- package/dist/web-session-runtime/shared/log.d.ts +1 -0
- package/dist/web-session-runtime/shared/path.d.ts +22 -0
- package/dist/web-session-runtime/shared/pdfPageImages.d.ts +19 -0
- package/dist/web-session-runtime/shared/pdfReference.d.ts +70 -0
- package/dist/web-session-runtime/shared/permissionDeadline.d.ts +24 -0
- package/dist/web-session-runtime/shared/platform.d.ts +8 -0
- package/dist/web-session-runtime/shared/stringUtils.d.ts +110 -0
- package/dist/web-session-runtime/shared/swarmSchemaFilter.d.ts +23 -0
- package/dist/web-session-runtime/shared/teamFileSchema.d.ts +151 -0
- package/dist/web-session-runtime/shared/teamInboxSchema.d.ts +112 -0
- package/dist/web-session-runtime/shared/teammateContext.d.ts +89 -0
- package/dist/web-session-runtime/shared/tempDir.d.ts +1 -0
- package/dist/web-session-runtime/shared/textEncoding.d.ts +41 -0
- package/dist/web-session-runtime/shared/tokenEstimation.d.ts +36 -0
- package/dist/web-session-runtime/shared/types-session.d.ts +266 -0
- package/dist/web-session-runtime/shared/types.d.ts +190 -0
- package/dist/web-session-runtime/shared/unc.d.ts +5 -0
- package/dist/web-session-runtime/shared/windowsPaths.d.ts +24 -0
- package/package.json +116 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 无损文本编码判别(0.1.84 V3-5 K5-3,工单 §B)。
|
|
3
|
+
*
|
|
4
|
+
* 单一解码权威:UTF-8(严格验证全输入)与 UTF-16LE(仅明确 FF FE BOM 识别
|
|
5
|
+
* + 合法 code unit 验证)。其余(UTF-16BE / GBK / Shift-JIS / Win-1252 …
|
|
6
|
+
* 传统编码)一律明确拒绝——不猜编码、不尝试转码、不靠 U+FFFD 出现与否
|
|
7
|
+
* 判合法性(合法 U+FFFD = EF BF BD 是正常内容)。
|
|
8
|
+
*
|
|
9
|
+
* 与 4096B 前缀探测(fileRead detectEncodingForResolvedPath)的关系:探测
|
|
10
|
+
* 仅作提示(hint),不能认证可安全写回——非法字节晚于 4096B 采样窗时探测
|
|
11
|
+
* 必漏检。本模块对完整输入做判别,是 mutation 面(Write/Edit/NotebookEdit
|
|
12
|
+
* 经 readFileSyncWithMetadata)与 Read LE 支的唯一解码事实源。
|
|
13
|
+
*
|
|
14
|
+
* 消费面:engine/TUI 双体 fileRead.ts(readFileSyncWithMetadata 元数据)+
|
|
15
|
+
* 双体 readFileInRange.ts(LE BOM Read)。纯叶子:不依赖 settings/工具/UI。
|
|
16
|
+
*/
|
|
17
|
+
/** 解码失败(不支持编码 / 非法字节 / 坏码元)——带可定位原因。 */
|
|
18
|
+
export declare class UndecodableTextError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export type DecodedText = {
|
|
22
|
+
/** 已剥离开头编码 BOM 的文本内容。 */
|
|
23
|
+
content: string;
|
|
24
|
+
encoding: 'utf8' | 'utf16le';
|
|
25
|
+
/** 输入是否以本编码的 BOM 开头(LE 识别必带 BOM → 恒 true)。 */
|
|
26
|
+
bom: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 判别输入是否以 UTF-16LE BOM(FF FE)开头。
|
|
30
|
+
* readFileInRange 快/流路径的编码分流探针(Read 面轻判别入口)。
|
|
31
|
+
*/
|
|
32
|
+
export declare function hasUtf16LeBom(bytes: Buffer): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 无损解码:全输入判别 + 严格验证,失败抛 UndecodableTextError。
|
|
35
|
+
*
|
|
36
|
+
* 判别序(互斥、无猜测):
|
|
37
|
+
* 1. FF FE 前缀 → UTF-16LE(BOM 剥离 + 码元/代理项验证;奇数字节拒绝);
|
|
38
|
+
* 2. FE FF 前缀 → UTF-16BE,明确拒绝(不倒转字节、不猜传统编码);
|
|
39
|
+
* 3. 其余 → UTF-8 严格验证(超长/代理项/>U+10FFFF/截断序列全拒)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function decodeTextLosslessly(bytes: Buffer): DecodedText;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 纯函数(services 分流)— rough token 估计族
|
|
3
|
+
*
|
|
4
|
+
* 实现波次: C 波(§8.55 S-C1 占位填充,B18 按需重建先例 = 实质实现非
|
|
5
|
+
* 重占位)。
|
|
6
|
+
*
|
|
7
|
+
* 旧仓来源(a8af45b):src/services/tokenEstimation.ts 350L 的纯函数
|
|
8
|
+
* 子集逐字(roughTokenCountEstimation / bytesPerTokenForFileType /
|
|
9
|
+
* roughTokenCountEstimationForFileType,L160-198)。裁面登记:
|
|
10
|
+
* countTokensWithAPI / countMessagesTokensWithAPI / countTokensViaHaikuFallback
|
|
11
|
+
* / roughTokenCountEstimationForMessages / roughTokenCountEstimationForMessage
|
|
12
|
+
* 等 API/消息面 8 导出位不迁(本波零消费者;模型 provider token 计数面归
|
|
13
|
+
* D 波,§8.55 C 组登记)。
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Rough token count estimate: content length / bytesPerToken, rounded.
|
|
17
|
+
* The default 4 bytes/token is a conservative approximation for
|
|
18
|
+
* mixed-language text; file-type-aware callers use
|
|
19
|
+
* {@link bytesPerTokenForFileType} for a tighter ratio.
|
|
20
|
+
*/
|
|
21
|
+
export declare function roughTokenCountEstimation(content: string, bytesPerToken?: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Returns an estimated bytes-per-token ratio for a given file extension.
|
|
24
|
+
* Dense JSON has many single-character tokens (`{`, `}`, `:`, `,`, `"`)
|
|
25
|
+
* which makes the real ratio closer to 2 rather than the default 4.
|
|
26
|
+
*/
|
|
27
|
+
export declare function bytesPerTokenForFileType(fileExtension: string): number;
|
|
28
|
+
/**
|
|
29
|
+
* Like {@link roughTokenCountEstimation} but uses a more accurate
|
|
30
|
+
* bytes-per-token ratio when the file type is known.
|
|
31
|
+
*
|
|
32
|
+
* This matters when the API-based token count is unavailable (e.g. on
|
|
33
|
+
* Bedrock) and we fall back to the rough estimate — an underestimate can
|
|
34
|
+
* let an oversized tool result slip into the conversation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function roughTokenCountEstimationForFileType(content: string, fileExtension: string): number;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shared 会话级类型骨架 — 契约冻结(B 波分叉前锁死)
|
|
3
|
+
*
|
|
4
|
+
* 旧仓来源(a8af45b)→ 新仓 shared 下沉:
|
|
5
|
+
* PermissionRule / ToolPermissionContext ← src/types/permissions.ts
|
|
6
|
+
* MCPServerConnection ← src/services/mcp/types.ts
|
|
7
|
+
* TaskState / TaskStateBase ← src/tasks/types.ts(旧仓 = any stub)
|
|
8
|
+
*
|
|
9
|
+
* 关键发现(类型提取 agent 报告):
|
|
10
|
+
* - ToolPermissionContext 旧仓双定义(Tool.ts DeepImmutable 版 + permissions.ts readonly 版),
|
|
11
|
+
* DeepImmutable 是 any stub → 此处冻结用 readonly 版(permissions.ts:427)
|
|
12
|
+
* - AlwaysAllowRule 等不存在 → 规则按 PermissionBehavior 区分非类型名
|
|
13
|
+
* - TaskState 旧仓 = any stub → 此处基于 TaskStateBase(Task.ts:45)定义
|
|
14
|
+
*/
|
|
15
|
+
export type PermissionBehavior = "allow" | "deny" | "ask";
|
|
16
|
+
export type PermissionRuleSource = "userSettings" | "projectSettings" | "localSettings" | "flagSettings" | "policySettings" | "cliArg" | "command" | "session";
|
|
17
|
+
export type PermissionRuleValue = {
|
|
18
|
+
toolName: string;
|
|
19
|
+
ruleContent?: string;
|
|
20
|
+
};
|
|
21
|
+
export type PermissionRule = {
|
|
22
|
+
source: PermissionRuleSource;
|
|
23
|
+
ruleBehavior: PermissionBehavior;
|
|
24
|
+
ruleValue: PermissionRuleValue;
|
|
25
|
+
};
|
|
26
|
+
export type ToolPermissionRulesBySource = {
|
|
27
|
+
[T in PermissionRuleSource]?: string[];
|
|
28
|
+
};
|
|
29
|
+
export type ExternalPermissionMode = "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "plan";
|
|
30
|
+
export type InternalPermissionMode = ExternalPermissionMode | "auto" | "bubble";
|
|
31
|
+
export type PermissionMode = InternalPermissionMode;
|
|
32
|
+
export type WorkingDirectorySource = PermissionRuleSource;
|
|
33
|
+
export type AdditionalWorkingDirectory = {
|
|
34
|
+
path: string;
|
|
35
|
+
source: WorkingDirectorySource;
|
|
36
|
+
};
|
|
37
|
+
export type ToolPermissionContext = {
|
|
38
|
+
readonly mode: PermissionMode;
|
|
39
|
+
readonly additionalWorkingDirectories: ReadonlyMap<string, AdditionalWorkingDirectory>;
|
|
40
|
+
readonly alwaysAllowRules: ToolPermissionRulesBySource;
|
|
41
|
+
readonly alwaysDenyRules: ToolPermissionRulesBySource;
|
|
42
|
+
readonly alwaysAskRules: ToolPermissionRulesBySource;
|
|
43
|
+
readonly isBypassPermissionsModeAvailable: boolean;
|
|
44
|
+
readonly strippedDangerousRules?: ToolPermissionRulesBySource;
|
|
45
|
+
readonly shouldAvoidPermissionPrompts?: boolean;
|
|
46
|
+
readonly awaitAutomatedChecksBeforeDialog?: boolean;
|
|
47
|
+
readonly prePlanMode?: PermissionMode;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 权限元数据挂的命令最小形(旧仓刻意用 Command 子集避免 import 环)。
|
|
51
|
+
*/
|
|
52
|
+
export type PermissionCommandMetadata = {
|
|
53
|
+
name: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
/** 权限决策附带的元数据。 */
|
|
58
|
+
export type PermissionMetadata = {
|
|
59
|
+
command: PermissionCommandMetadata;
|
|
60
|
+
} | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Metadata for a pending classifier check that will run asynchronously.
|
|
63
|
+
* Used to enable non-blocking allow classifier evaluation.
|
|
64
|
+
*(旧仓 src/types/permissions.ts:185-194 逐字,工具本体波 S-T2b 恢复:
|
|
65
|
+
* bashPermissions buildPendingClassifierCheck 族第一真消费者。注:
|
|
66
|
+
* PermissionAskDecision 的 pendingClassifierCheck 字段本身仍裁——
|
|
67
|
+
* ask 决策产点以本地对象携值(结构流),字段恢复归 auto-mode 纵切波,
|
|
68
|
+
* 见文件头裁量登记。)
|
|
69
|
+
*/
|
|
70
|
+
export type PendingClassifierCheck = {
|
|
71
|
+
command: string;
|
|
72
|
+
cwd: string;
|
|
73
|
+
descriptions: string[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* 权限决策原因(薄骨架裁剪版)。
|
|
77
|
+
*/
|
|
78
|
+
export type PermissionDecisionReason = {
|
|
79
|
+
type: "rule";
|
|
80
|
+
rule: PermissionRule;
|
|
81
|
+
} | {
|
|
82
|
+
type: "mode";
|
|
83
|
+
mode: PermissionMode;
|
|
84
|
+
} | {
|
|
85
|
+
/**
|
|
86
|
+
* 分类器代判原因(旧仓 L303-306 逐字,工具本体波 S-T2b 恢复;
|
|
87
|
+
* bashPermissions speculative 分类器 ask 支 2 产点,stub 态惰性)。
|
|
88
|
+
*/
|
|
89
|
+
type: "classifier";
|
|
90
|
+
classifier: string;
|
|
91
|
+
reason: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: "workingDir";
|
|
94
|
+
reason: string;
|
|
95
|
+
} | {
|
|
96
|
+
type: "safetyCheck";
|
|
97
|
+
reason: string;
|
|
98
|
+
/**
|
|
99
|
+
* 为 true 时自动模式让分类器代判而非强制弹框(敏感文件路径
|
|
100
|
+
* .atlas/、.git/、shell 配置);为 false 是 Windows 路径绕过尝试等
|
|
101
|
+
* 不可代判情形。薄骨架恒按静态判定,分类器代判归 engine。
|
|
102
|
+
*/
|
|
103
|
+
classifierApprovable: boolean;
|
|
104
|
+
} | {
|
|
105
|
+
type: "other";
|
|
106
|
+
reason: string;
|
|
107
|
+
} | {
|
|
108
|
+
/**
|
|
109
|
+
* 分段命令(splitCommand 多段)逐段权限结果聚合(工具本体波 S-T2a
|
|
110
|
+
* 恢复,bashCommandHelpers 第一真消费者;见文件头裁量登记)。
|
|
111
|
+
*/
|
|
112
|
+
type: "subcommandResults";
|
|
113
|
+
reasons: Map<string, PermissionResult>;
|
|
114
|
+
};
|
|
115
|
+
/** 权限授予时的结果。 */
|
|
116
|
+
export type PermissionAllowDecision<Input extends {
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
} = {
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}> = {
|
|
121
|
+
behavior: "allow";
|
|
122
|
+
updatedInput?: Input;
|
|
123
|
+
userModified?: boolean;
|
|
124
|
+
decisionReason?: PermissionDecisionReason;
|
|
125
|
+
toolUseID?: string;
|
|
126
|
+
acceptFeedback?: string;
|
|
127
|
+
};
|
|
128
|
+
/** 需弹框询问时的结果。 */
|
|
129
|
+
export type PermissionAskDecision<Input extends {
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
} = {
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}> = {
|
|
134
|
+
behavior: "ask";
|
|
135
|
+
message: string;
|
|
136
|
+
updatedInput?: Input;
|
|
137
|
+
decisionReason?: PermissionDecisionReason;
|
|
138
|
+
suggestions?: PermissionUpdate[];
|
|
139
|
+
blockedPath?: string;
|
|
140
|
+
metadata?: PermissionMetadata;
|
|
141
|
+
/**
|
|
142
|
+
* If true, this ask decision was triggered by a bashCommandIsSafe_DEPRECATED
|
|
143
|
+
* security check for patterns that splitCommand_DEPRECATED could misparse
|
|
144
|
+
* (e.g. line continuations, shell-quote transformations). Used by
|
|
145
|
+
* bashToolHasPermission to block early before splitCommand_DEPRECATED
|
|
146
|
+
* transforms the command. Not set for simple newline compound commands.
|
|
147
|
+
*(工具本体波 S-T2a 恢复:bashSecurity 8 生产点为第一真消费者,§8.53 登记;
|
|
148
|
+
* 旧仓同族的 pendingClassifierCheck / contentBlocks 仍裁——分类器波消费。)
|
|
149
|
+
*/
|
|
150
|
+
isBashSecurityCheckForMisparsing?: boolean;
|
|
151
|
+
};
|
|
152
|
+
/** 权限拒绝时的结果。 */
|
|
153
|
+
export type PermissionDenyDecision = {
|
|
154
|
+
behavior: "deny";
|
|
155
|
+
message: string;
|
|
156
|
+
decisionReason: PermissionDecisionReason;
|
|
157
|
+
toolUseID?: string;
|
|
158
|
+
};
|
|
159
|
+
/** 权限决策——allow / ask / deny 三态。 */
|
|
160
|
+
export type PermissionDecision<Input extends {
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
} = {
|
|
163
|
+
[key: string]: unknown;
|
|
164
|
+
}> = PermissionAllowDecision<Input> | PermissionAskDecision<Input> | PermissionDenyDecision;
|
|
165
|
+
/** 带 passthrough(内部路径检查续查)的权限结果。 */
|
|
166
|
+
export type PermissionResult<Input extends {
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
} = {
|
|
169
|
+
[key: string]: unknown;
|
|
170
|
+
}> = PermissionDecision<Input> | {
|
|
171
|
+
behavior: "passthrough";
|
|
172
|
+
message: string;
|
|
173
|
+
decisionReason?: PermissionDecision<Input>["decisionReason"];
|
|
174
|
+
suggestions?: PermissionUpdate[];
|
|
175
|
+
blockedPath?: string;
|
|
176
|
+
};
|
|
177
|
+
/** 权限更新应持久化的落点。 */
|
|
178
|
+
export type PermissionUpdateDestination = "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg";
|
|
179
|
+
/** 权限配置的更新操作。 */
|
|
180
|
+
export type PermissionUpdate = {
|
|
181
|
+
type: "addRules";
|
|
182
|
+
destination: PermissionUpdateDestination;
|
|
183
|
+
rules: PermissionRuleValue[];
|
|
184
|
+
behavior: PermissionBehavior;
|
|
185
|
+
} | {
|
|
186
|
+
type: "replaceRules";
|
|
187
|
+
destination: PermissionUpdateDestination;
|
|
188
|
+
rules: PermissionRuleValue[];
|
|
189
|
+
behavior: PermissionBehavior;
|
|
190
|
+
} | {
|
|
191
|
+
type: "removeRules";
|
|
192
|
+
destination: PermissionUpdateDestination;
|
|
193
|
+
rules: PermissionRuleValue[];
|
|
194
|
+
behavior: PermissionBehavior;
|
|
195
|
+
} | {
|
|
196
|
+
type: "setMode";
|
|
197
|
+
destination: PermissionUpdateDestination;
|
|
198
|
+
mode: ExternalPermissionMode;
|
|
199
|
+
} | {
|
|
200
|
+
type: "addDirectories";
|
|
201
|
+
destination: PermissionUpdateDestination;
|
|
202
|
+
directories: string[];
|
|
203
|
+
} | {
|
|
204
|
+
type: "removeDirectories";
|
|
205
|
+
destination: PermissionUpdateDestination;
|
|
206
|
+
directories: string[];
|
|
207
|
+
};
|
|
208
|
+
export type ScopedMcpServerConfig = {
|
|
209
|
+
scope: unknown;
|
|
210
|
+
pluginSource?: string;
|
|
211
|
+
[key: string]: unknown;
|
|
212
|
+
};
|
|
213
|
+
export type ConnectedMCPServer = {
|
|
214
|
+
client: unknown;
|
|
215
|
+
name: string;
|
|
216
|
+
type: "connected";
|
|
217
|
+
capabilities: unknown;
|
|
218
|
+
serverInfo?: {
|
|
219
|
+
name: string;
|
|
220
|
+
version: string;
|
|
221
|
+
};
|
|
222
|
+
instructions?: string;
|
|
223
|
+
config: ScopedMcpServerConfig;
|
|
224
|
+
cleanup: () => Promise<void>;
|
|
225
|
+
};
|
|
226
|
+
export type FailedMCPServer = {
|
|
227
|
+
name: string;
|
|
228
|
+
type: "failed";
|
|
229
|
+
config: ScopedMcpServerConfig;
|
|
230
|
+
error?: string;
|
|
231
|
+
};
|
|
232
|
+
export type NeedsAuthMCPServer = {
|
|
233
|
+
name: string;
|
|
234
|
+
type: "needs-auth";
|
|
235
|
+
config: ScopedMcpServerConfig;
|
|
236
|
+
};
|
|
237
|
+
export type PendingMCPServer = {
|
|
238
|
+
name: string;
|
|
239
|
+
type: "pending";
|
|
240
|
+
config: ScopedMcpServerConfig;
|
|
241
|
+
reconnectAttempt?: number;
|
|
242
|
+
maxReconnectAttempts?: number;
|
|
243
|
+
};
|
|
244
|
+
export type DisabledMCPServer = {
|
|
245
|
+
name: string;
|
|
246
|
+
type: "disabled";
|
|
247
|
+
config: ScopedMcpServerConfig;
|
|
248
|
+
};
|
|
249
|
+
export type MCPServerConnection = ConnectedMCPServer | FailedMCPServer | NeedsAuthMCPServer | PendingMCPServer | DisabledMCPServer;
|
|
250
|
+
export type TaskStatus = "running" | "completed" | "failed" | "cancelled";
|
|
251
|
+
export type TaskType = string;
|
|
252
|
+
export type TaskStateBase = {
|
|
253
|
+
id: string;
|
|
254
|
+
type: TaskType;
|
|
255
|
+
status: TaskStatus;
|
|
256
|
+
description: string;
|
|
257
|
+
toolUseId?: string;
|
|
258
|
+
startTime: number;
|
|
259
|
+
endTime?: number;
|
|
260
|
+
totalPausedMs?: number;
|
|
261
|
+
outputFile: string;
|
|
262
|
+
outputOffset: number;
|
|
263
|
+
notified: boolean;
|
|
264
|
+
};
|
|
265
|
+
/** 旧仓 = any stub;C 波迁移各 task 子类型时基于 TaskStateBase 扩展 */
|
|
266
|
+
export type TaskState = TaskStateBase;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shared 纯类型骨架 — 契约冻结(B 波分叉前锁死,charter §2 第 1 项)
|
|
3
|
+
*
|
|
4
|
+
* 旧仓来源(a8af45b)→ 新仓 shared 下沉:
|
|
5
|
+
* atlas types ← src/types/atlas.ts
|
|
6
|
+
* message types ← src/types/message.ts / src/utils/messages.ts
|
|
7
|
+
* SystemPrompt ← src/utils/systemPromptType.ts
|
|
8
|
+
* ThinkingConfig ← src/utils/thinking.ts
|
|
9
|
+
* Effort ← src/utils/effort.ts(EffortLevel 旧仓 = any stub,此处冻结为真实联合)
|
|
10
|
+
* Tool/Tools ← src/Tool.ts(仅类型部分,React render 字段用 unknown)
|
|
11
|
+
*
|
|
12
|
+
* 签名和旧仓对齐(B/C 波迁移代码 import 这些类型),实现可空。
|
|
13
|
+
* 两个 fork session(S1 sandbox+executor / S2 memory+modelprovider)共享此契约。
|
|
14
|
+
*/
|
|
15
|
+
export interface ContentBlock {
|
|
16
|
+
type: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface ContentBlockParam {
|
|
20
|
+
type: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface Usage {
|
|
24
|
+
input_tokens?: number;
|
|
25
|
+
output_tokens?: number;
|
|
26
|
+
cache_creation_input_tokens?: number;
|
|
27
|
+
cache_read_input_tokens?: number;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface ToolUseBlock extends ContentBlock {
|
|
31
|
+
type: "tool_use";
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
input: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface ToolResultBlockParam extends ContentBlockParam {
|
|
37
|
+
type: "tool_result";
|
|
38
|
+
tool_use_id: string;
|
|
39
|
+
content?: string | ContentBlockParam[];
|
|
40
|
+
is_error?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export type TextBlock = ContentBlock & {
|
|
43
|
+
type: "text";
|
|
44
|
+
text: string;
|
|
45
|
+
};
|
|
46
|
+
export type ThinkingBlock = {
|
|
47
|
+
type: "thinking";
|
|
48
|
+
thinking: string;
|
|
49
|
+
signature: string;
|
|
50
|
+
};
|
|
51
|
+
export type RedactedThinkingBlock = {
|
|
52
|
+
type: "redacted_thinking";
|
|
53
|
+
data: string;
|
|
54
|
+
};
|
|
55
|
+
export type MessageParam = {
|
|
56
|
+
role: string;
|
|
57
|
+
content: string | ContentBlockParam[];
|
|
58
|
+
};
|
|
59
|
+
export interface Message {
|
|
60
|
+
role?: string;
|
|
61
|
+
content?: unknown;
|
|
62
|
+
id?: string;
|
|
63
|
+
uuid?: string;
|
|
64
|
+
usage?: Usage;
|
|
65
|
+
stop_reason?: string;
|
|
66
|
+
timestamp?: number | string;
|
|
67
|
+
metadata?: unknown;
|
|
68
|
+
type?: string;
|
|
69
|
+
message?: unknown;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
export interface UserMessage extends Message {
|
|
73
|
+
role?: "user";
|
|
74
|
+
content?: unknown;
|
|
75
|
+
isImage?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface AssistantMessage extends Message {
|
|
78
|
+
role?: "assistant";
|
|
79
|
+
content?: unknown;
|
|
80
|
+
stop_reason?: string;
|
|
81
|
+
usage?: Usage;
|
|
82
|
+
}
|
|
83
|
+
export interface SystemMessage extends Message {
|
|
84
|
+
role: "system";
|
|
85
|
+
}
|
|
86
|
+
export type SystemAPIErrorMessage = SystemMessage & {
|
|
87
|
+
error: string;
|
|
88
|
+
};
|
|
89
|
+
export type NormalizedMessage = {
|
|
90
|
+
role: string;
|
|
91
|
+
content: string;
|
|
92
|
+
id?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
export type SystemPrompt = readonly string[] & {
|
|
96
|
+
readonly __brand: "SystemPrompt";
|
|
97
|
+
};
|
|
98
|
+
export declare function asSystemPrompt(value: readonly string[]): SystemPrompt;
|
|
99
|
+
export type ThinkingConfig = {
|
|
100
|
+
type: "adaptive";
|
|
101
|
+
} | {
|
|
102
|
+
type: "enabled";
|
|
103
|
+
budgetTokens: number;
|
|
104
|
+
} | {
|
|
105
|
+
type: "disabled";
|
|
106
|
+
};
|
|
107
|
+
/** 旧仓 runtimeTypes.ts:22 = any stub;真实运行时集见 EFFORT_LEVELS(effort.ts:7-17) */
|
|
108
|
+
export type EffortLevel = "low" | "medium" | "high" | "xhigh" | "max";
|
|
109
|
+
export declare const EFFORT_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
110
|
+
export type EffortValue = EffortLevel | number;
|
|
111
|
+
export type ToolInputJSONSchema = {
|
|
112
|
+
[x: string]: unknown;
|
|
113
|
+
type: "object";
|
|
114
|
+
properties?: {
|
|
115
|
+
[x: string]: unknown;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export type ToolProgressData = unknown;
|
|
119
|
+
export type ToolResult<T = unknown> = {
|
|
120
|
+
data: T;
|
|
121
|
+
newMessages?: unknown[];
|
|
122
|
+
contextModifier?: (context: unknown) => unknown;
|
|
123
|
+
mcpMeta?: {
|
|
124
|
+
_meta?: Record<string, unknown>;
|
|
125
|
+
structuredContent?: Record<string, unknown>;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export type ValidationResult = {
|
|
129
|
+
result: true;
|
|
130
|
+
} | {
|
|
131
|
+
result: false;
|
|
132
|
+
message: string;
|
|
133
|
+
errorCode: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Tool 契约(跨域消费的核心字段)。
|
|
137
|
+
* 完整旧仓 Tool 有 ~40 字段含 React render;此处锁 modelprovider/params.ts
|
|
138
|
+
* 和 engine/pipeline 消费的类型部分。React render 字段 C/D 波补。
|
|
139
|
+
*/
|
|
140
|
+
export interface Tool<Input extends ToolInputJSONSchema = ToolInputJSONSchema, Output = unknown, P extends ToolProgressData = ToolProgressData> {
|
|
141
|
+
readonly name: string;
|
|
142
|
+
readonly inputSchema: Input;
|
|
143
|
+
readonly inputJSONSchema?: ToolInputJSONSchema;
|
|
144
|
+
outputSchema?: unknown;
|
|
145
|
+
maxResultSizeChars: number;
|
|
146
|
+
readonly strict?: boolean;
|
|
147
|
+
readonly shouldDefer?: boolean;
|
|
148
|
+
readonly alwaysLoad?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* 声明执行预算(毫秒;0.1.104 切片 2,lock-face 必答 3/5)。wrapper 层契约——
|
|
151
|
+
* toolExecution 在权限门后 arm deadline,到期经既有 abort 通道中止并以
|
|
152
|
+
* TOOL_TIMEOUT isError tool_result 替换(模型可路由)。**不出 LLM schema**
|
|
153
|
+
* (防 token manifest/wire 锚漂移);无声明 = 无限期(cooperative)。
|
|
154
|
+
*/
|
|
155
|
+
readonly timeoutMs?: number;
|
|
156
|
+
isMcp?: boolean;
|
|
157
|
+
isLsp?: boolean;
|
|
158
|
+
aliases?: string[];
|
|
159
|
+
searchHint?: string;
|
|
160
|
+
mcpInfo?: {
|
|
161
|
+
serverName: string;
|
|
162
|
+
toolName: string;
|
|
163
|
+
};
|
|
164
|
+
call(args: unknown, context: unknown, canUseTool: unknown, parentMessage: AssistantMessage, onProgress?: (progress: P) => void): Promise<ToolResult<Output>>;
|
|
165
|
+
description(input: unknown, options: {
|
|
166
|
+
isNonInteractiveSession: boolean;
|
|
167
|
+
toolPermissionContext: unknown;
|
|
168
|
+
tools: Tools;
|
|
169
|
+
}): Promise<string>;
|
|
170
|
+
isConcurrencySafe(input: unknown): boolean;
|
|
171
|
+
isEnabled(): boolean;
|
|
172
|
+
isReadOnly(input: unknown): boolean;
|
|
173
|
+
isDestructive?(input: unknown): boolean;
|
|
174
|
+
interruptBehavior?(): "cancel" | "block";
|
|
175
|
+
checkPermissions(input: unknown, context: unknown): Promise<unknown>;
|
|
176
|
+
validateInput?(input: unknown, context: unknown): Promise<ValidationResult>;
|
|
177
|
+
userFacingName(input: unknown): string;
|
|
178
|
+
toAutoClassifierInput(input: unknown): unknown;
|
|
179
|
+
mapToolResultToToolResultBlockParam(content: Output, toolUseID: string): ToolResultBlockParam;
|
|
180
|
+
renderToolUseMessage(input: unknown, options: {
|
|
181
|
+
theme: unknown;
|
|
182
|
+
verbose: boolean;
|
|
183
|
+
commands?: unknown[];
|
|
184
|
+
}): unknown;
|
|
185
|
+
renderToolResultMessage?(content: Output, progressMessages: unknown[], options: unknown): unknown;
|
|
186
|
+
extractSearchText?(out: Output): string;
|
|
187
|
+
foldResult?(data: Output): string | null;
|
|
188
|
+
isResultTruncated?(output: Output): boolean;
|
|
189
|
+
}
|
|
190
|
+
export type Tools = readonly Tool[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shared — windowsPathToPosixPath / posixPathToWindowsPath 纯路径转换
|
|
3
|
+
* (§8.55 S-C2 跨域叶子提升,C-Deep T5 / §8.55 S-C1 logError 提升先例)。
|
|
4
|
+
*
|
|
5
|
+
* 旧仓来源(a8af45b):src/utils/windowsPaths.ts 两纯函数体逐字随迁
|
|
6
|
+
* (UNC / 盘符 / cygdrive / MinGW /c/ 四形态 + 纯反斜杠翻转)。
|
|
7
|
+
*
|
|
8
|
+
* 提升理由:memory 域(memoryFileDetection 的 MinGW 形态比较)+
|
|
9
|
+
* engine/tools/bash 域(bashPermissions cwd 转换)双消费,shared =
|
|
10
|
+
* 唯一跨域叶子汇。
|
|
11
|
+
*
|
|
12
|
+
* delta 登记(复审勿当遗漏重提):
|
|
13
|
+
* - 旧仓 memoizeWithLRU(fn, key, 500) 包裹不随迁(LRU 缓存面 = lodash 族
|
|
14
|
+
* 裁剪先例,同 §8.53 S-T2b bash 域内最小实现裁定;纯函数多调用点
|
|
15
|
+
* 语义零影响)。
|
|
16
|
+
* - 旧仓同文件其余导出(setShellIfWindows / findGitBashPath /
|
|
17
|
+
* checkPathExists / findExecutable = Git Bash 探活族,Windows 专属
|
|
18
|
+
* shell 面)不随迁(新仓无 Windows shell 探活消费点;Bash 工具本体波
|
|
19
|
+
* 归 shell·swarm 后续波,届时按需重建)。
|
|
20
|
+
*/
|
|
21
|
+
/** Convert a Windows path to a POSIX path using pure JS. */
|
|
22
|
+
export declare const windowsPathToPosixPath: (windowsPath: string) => string;
|
|
23
|
+
/** Convert a POSIX path to a Windows path using pure JS. */
|
|
24
|
+
export declare const posixPathToWindowsPath: (posixPath: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,118 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaswork/atlascode",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.125",
|
|
4
|
+
"description": "AtlasCode — Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
|
|
5
|
+
"homepage": "https://www.atlaswork.cn/",
|
|
6
|
+
"bin": {
|
|
7
|
+
"atlas": "dist/cli.js",
|
|
8
|
+
"atlascode": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
"./web-contract": {
|
|
16
|
+
"types": "./dist/web-contract/index.d.ts",
|
|
17
|
+
"import": "./dist/web-contract/index.js",
|
|
18
|
+
"default": "./dist/web-contract/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./web-session-runtime": {
|
|
21
|
+
"types": "./dist/web-session-runtime/index.d.ts",
|
|
22
|
+
"import": "./dist/web-session-runtime/index.js",
|
|
23
|
+
"default": "./dist/web-session-runtime/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"check": "bun run --check src/atlascode/cli.ts",
|
|
35
|
+
"test": "bun test --isolate tests/",
|
|
36
|
+
"build": "bun build src/atlascode/cli.ts --outfile dist/cli.js --target node --external modifiers-napi --external url-handler-napi --external audio-capture-napi --external image-processor-napi --external plist --external sharp --external fflate --external cli-highlight --external undici --external @ant/computer-use-input --external @ant/computer-use-swift",
|
|
37
|
+
"dev": "bun run --watch src/atlascode/launcher.ts",
|
|
38
|
+
"lint": "eslint src/",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"atlasweb:boundary-scan": "bun scripts/atlasweb-kernel-boundary-scan.ts",
|
|
41
|
+
"build:web-contract": "bun build src/kernel/protocol/webSessionV0.ts --outfile dist/web-contract/index.js --target browser --external zod && tsc -p tsconfig.web-contract.json && mv dist/web-contract/webSessionV0.d.ts dist/web-contract/index.d.ts",
|
|
42
|
+
"build:web-session-runtime": "bun build src/atlascode/web/entry.ts --outfile dist/web-session-runtime/index.js --target node --external zod && tsc -p tsconfig.web-session-runtime.json && printf 'export * from \"./atlascode/web/entry.js\"\\n' > dist/web-session-runtime/index.d.ts && bun scripts/rewrite-web-session-runtime-dts.ts",
|
|
43
|
+
"prepublishOnly": "bun run build && bun run build:web-contract && bun run build:web-session-runtime"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@alcalzone/ansi-tokenize": "^0.3.0",
|
|
47
|
+
"@commander-js/extra-typings": "15",
|
|
48
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
49
|
+
"@opentelemetry/api": "^1.9.1",
|
|
50
|
+
"@vscode/ripgrep": "1.18.0",
|
|
51
|
+
"ajv": "^8.20.0",
|
|
52
|
+
"asciichart": "^1.5.25",
|
|
53
|
+
"auto-bind": "^5.0.1",
|
|
54
|
+
"axios": "^1.20.0",
|
|
55
|
+
"bidi-js": "^1.0.3",
|
|
56
|
+
"chalk": "^6.0.0",
|
|
57
|
+
"chokidar": "^5.0.0",
|
|
58
|
+
"cli-boxes": "^4.0.1",
|
|
59
|
+
"cli-highlight": "^2.1.11",
|
|
60
|
+
"code-excerpt": "^4.0.0",
|
|
61
|
+
"diff": "9.0.0",
|
|
62
|
+
"emoji-regex": "^10.6.0",
|
|
63
|
+
"env-paths": "^4.0.0",
|
|
64
|
+
"execa": "^10.0.1",
|
|
65
|
+
"fflate": "^0.8.3",
|
|
66
|
+
"figures": "^6.1.0",
|
|
67
|
+
"fuse.js": "^7.5.0",
|
|
68
|
+
"highlight.js": "^10.7.3",
|
|
69
|
+
"https-proxy-agent": "^9.1.0",
|
|
70
|
+
"ignore": "^7.0.8",
|
|
71
|
+
"indent-string": "^5.0.0",
|
|
72
|
+
"ink": "^7.1.1",
|
|
73
|
+
"jsonc-parser": "^3.3.1",
|
|
74
|
+
"lodash-es": "^4.18.1",
|
|
75
|
+
"lru-cache": "^11.5.2",
|
|
76
|
+
"marked": "^18.0.11",
|
|
77
|
+
"openai": "^7.9.0",
|
|
78
|
+
"p-map": "^7.0.7",
|
|
79
|
+
"picomatch": "^4.0.7",
|
|
80
|
+
"proper-lockfile": "^4.1.2",
|
|
81
|
+
"qrcode": "^1.5.4",
|
|
82
|
+
"react": "^19.2.8",
|
|
83
|
+
"react-reconciler": "^0.33.0",
|
|
84
|
+
"semver": "^7.6.0",
|
|
85
|
+
"shell-quote": "1.10.0",
|
|
86
|
+
"strip-ansi": "^7.2.0",
|
|
87
|
+
"supports-hyperlinks": "^4.5.0",
|
|
88
|
+
"tree-kill": "^1.2.2",
|
|
89
|
+
"turndown": "^7.2.4",
|
|
90
|
+
"undici": "^7.30.1",
|
|
91
|
+
"usehooks-ts": "^3.1.1",
|
|
92
|
+
"vscode-jsonrpc": "^9.0.2",
|
|
93
|
+
"wrap-ansi": "^10.0.1",
|
|
94
|
+
"ws": "^8.21.3",
|
|
95
|
+
"xss": "^1.0.15",
|
|
96
|
+
"yaml": "^2.9.0",
|
|
97
|
+
"zod": "^4.5.4"
|
|
98
|
+
},
|
|
99
|
+
"optionalDependencies": {
|
|
100
|
+
"audio-capture-napi": "^0.0.1",
|
|
101
|
+
"image-processor-napi": "^0.0.1",
|
|
102
|
+
"modifiers-napi": "^0.0.1",
|
|
103
|
+
"plist": "^5.0.0",
|
|
104
|
+
"sharp": "^0.35.5",
|
|
105
|
+
"url-handler-napi": "^0.0.1"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@types/bun": "^1.4.0",
|
|
109
|
+
"@types/node": "^20.0.0",
|
|
110
|
+
"@types/react": "^19.2.18",
|
|
111
|
+
"@typescript-eslint/parser": "^8",
|
|
112
|
+
"eslint": "^9.0.0",
|
|
113
|
+
"eslint-import-resolver-typescript": "4.4.5",
|
|
114
|
+
"eslint-plugin-boundaries": "^5.0.0",
|
|
115
|
+
"typescript": "^5.9.3",
|
|
116
|
+
"typescript-eslint": "^8"
|
|
117
|
+
}
|
|
118
|
+
}
|