@mortiseai/stem 0.0.1
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 +190 -0
- package/README.md +328 -0
- package/bin/stem.mjs +51 -0
- package/dist/cli.mjs +1848 -0
- package/dist/daemon.mjs +1419 -0
- package/dist/mcp.mjs +1415 -0
- package/dist/package.json +3 -0
- package/package.json +91 -0
- package/preload.ts +28 -0
- package/stubs/ant-claude-for-chrome-mcp.ts +24 -0
- package/stubs/anthropic-ai-sdk.ts +62 -0
- package/stubs/color-diff-napi.ts +45 -0
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mortiseai/stem",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "MortiseAI Stem CLI, built on MSC Engine",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "MortiseAI <developer.mai@outlook.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"stem": "./bin/stem.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"dist",
|
|
14
|
+
"stubs",
|
|
15
|
+
"preload.ts",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "bun ./src/stem-entry/stem-entry-cli.tsx",
|
|
24
|
+
"build": "bun scripts/build-cli.ts",
|
|
25
|
+
"build:cli": "bun scripts/build-cli.ts cli",
|
|
26
|
+
"build:mcp": "bun scripts/build-cli.ts mcp",
|
|
27
|
+
"build:daemon": "bun scripts/build-cli.ts daemon",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "bun run build",
|
|
30
|
+
"start": "node ./bin/stem.mjs"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@alcalzone/ansi-tokenize": "^0.1.3",
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
35
|
+
"@mortiseai/mai_msc_engine_ts_module": "^0.0.3",
|
|
36
|
+
"@pondwader/socks5-server": "^1.0.10",
|
|
37
|
+
"ajv": "^8.18.0",
|
|
38
|
+
"ajv-formats": "^3.0.1",
|
|
39
|
+
"auto-bind": "^5.0.1",
|
|
40
|
+
"bidi-js": "^1.0.3",
|
|
41
|
+
"chalk": "^5.6.2",
|
|
42
|
+
"cli-boxes": "^4.0.1",
|
|
43
|
+
"code-excerpt": "^4.0.0",
|
|
44
|
+
"diff": "^8.0.4",
|
|
45
|
+
"emoji-regex": "^10.6.0",
|
|
46
|
+
"get-east-asian-width": "^1.5.0",
|
|
47
|
+
"indent-string": "^5.0.0",
|
|
48
|
+
"lodash-es": "^4.17.23",
|
|
49
|
+
"picomatch": "^4.0.4",
|
|
50
|
+
"react": "^19.2.4",
|
|
51
|
+
"react-reconciler": "^0.33.0",
|
|
52
|
+
"semver": "^7.7.4",
|
|
53
|
+
"shell-quote": "^1.8.3",
|
|
54
|
+
"signal-exit": "^4.1.0",
|
|
55
|
+
"slice-ansi": "^9.0.0",
|
|
56
|
+
"stack-utils": "^2.0.6",
|
|
57
|
+
"strip-ansi": "^7.2.0",
|
|
58
|
+
"supports-hyperlinks": "^4.4.0",
|
|
59
|
+
"turndown": "^7.2.4",
|
|
60
|
+
"usehooks-ts": "^3.1.1",
|
|
61
|
+
"vscode-jsonrpc": "^8.2.1",
|
|
62
|
+
"vscode-languageserver-protocol": "^3.17.5",
|
|
63
|
+
"wrap-ansi": "^10.0.0",
|
|
64
|
+
"yoga-layout": "^3.2.1",
|
|
65
|
+
"zod": "^4.3.6"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/lodash-es": "^4.17.12",
|
|
69
|
+
"@types/node": "^22.0.0",
|
|
70
|
+
"@types/react": "^19.2.14",
|
|
71
|
+
"@types/react-reconciler": "^0.28.9",
|
|
72
|
+
"@types/semver": "^7.7.1",
|
|
73
|
+
"@types/signal-exit": "^4.0.0",
|
|
74
|
+
"@types/stack-utils": "^2.0.3",
|
|
75
|
+
"bun-types": "latest",
|
|
76
|
+
"type-fest": "^5.6.0",
|
|
77
|
+
"typescript": "^5.5.0",
|
|
78
|
+
"ws": "^8.20.0"
|
|
79
|
+
},
|
|
80
|
+
"repository": {
|
|
81
|
+
"type": "git",
|
|
82
|
+
"url": "https://github.com/MortiseAI/mortise_ai_stem_agent_cli_project"
|
|
83
|
+
},
|
|
84
|
+
"keywords": [
|
|
85
|
+
"mortise-ai",
|
|
86
|
+
"msc-engine",
|
|
87
|
+
"cli",
|
|
88
|
+
"agent",
|
|
89
|
+
"stem"
|
|
90
|
+
]
|
|
91
|
+
}
|
package/preload.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const version = '0.0.1-develop';
|
|
6
|
+
const packageUrl = process.env.STEM_LOCAL_PACKAGE_URL ?? '@mortiseai/stem';
|
|
7
|
+
const buildTime = process.env.STEM_LOCAL_BUILD_TIME ?? new Date().toISOString();
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const pkgRaw = readFileSync(join(__dirname, 'package.json'), 'utf8');
|
|
11
|
+
const pkgJson = JSON.parse(pkgRaw) as { dependencies?: Record<string, string> };
|
|
12
|
+
const mscEngineSpec = pkgJson.dependencies?.['@mortiseai/mai_msc_engine_ts_module'] ?? '';
|
|
13
|
+
const mscEngineVersion = mscEngineSpec.replace(/^[\^~]/, '');
|
|
14
|
+
|
|
15
|
+
Object.assign(globalThis, {
|
|
16
|
+
MACRO: {
|
|
17
|
+
VERSION: version,
|
|
18
|
+
PACKAGE_URL: packageUrl,
|
|
19
|
+
NATIVE_PACKAGE_URL: packageUrl,
|
|
20
|
+
BUILD_TIME: buildTime,
|
|
21
|
+
FEEDBACK_CHANNEL: 'local',
|
|
22
|
+
MSC_ENGINE_VERSION: mscEngineVersion,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (process.env.CALLER_DIR) {
|
|
27
|
+
process.chdir(process.env.CALLER_DIR);
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type PermissionMode =
|
|
2
|
+
| 'ask'
|
|
3
|
+
| 'skip_all_permission_checks'
|
|
4
|
+
| 'follow_a_plan';
|
|
5
|
+
|
|
6
|
+
export type Logger = {
|
|
7
|
+
silly?: (...args: unknown[]) => void;
|
|
8
|
+
debug?: (...args: unknown[]) => void;
|
|
9
|
+
info?: (...args: unknown[]) => void;
|
|
10
|
+
warn?: (...args: unknown[]) => void;
|
|
11
|
+
error?: (...args: unknown[]) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ClaudeForChromeContext = Record<string, unknown>;
|
|
15
|
+
|
|
16
|
+
export const BROWSER_TOOLS: Array<{ name: string }> = [];
|
|
17
|
+
|
|
18
|
+
export function createClaudeForChromeMcpServer(
|
|
19
|
+
_context: ClaudeForChromeContext,
|
|
20
|
+
) {
|
|
21
|
+
return {
|
|
22
|
+
async connect(_transport: unknown): Promise<void> {},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @anthropic-ai/sdk 桩 — SDK 依赖已移除,由 tsconfig paths 别名
|
|
3
|
+
* ("@anthropic-ai/sdk" 与 "@anthropic-ai/sdk/*")把 vendored 上游文件的
|
|
4
|
+
* 类型导入指到这里(先例:@ant/claude-for-chrome-mcp / color-diff-napi)。
|
|
5
|
+
*
|
|
6
|
+
* 活跃代码请直接 import 'src/stem-utils/llm'(自研双协议客户端 + vendored 类型),
|
|
7
|
+
* 不要走本桩。桩覆盖上游文件用到的全部导入面:
|
|
8
|
+
* - 各 resources/*.mjs 子路径的类型名(ContentBlockParam / BetaUsage / ...)
|
|
9
|
+
* - 值导入 APIUserAbortError(instanceof / new 兼容)
|
|
10
|
+
* - `import type Anthropic from '@anthropic-ai/sdk'` 的命名空间用法
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type * as T from '../src/stem-utils/llm/types.js'
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
Base64ImageSource,
|
|
17
|
+
BetaContentBlock,
|
|
18
|
+
BetaMessage,
|
|
19
|
+
BetaMessageStreamParams,
|
|
20
|
+
BetaTextBlockParam,
|
|
21
|
+
BetaToolUnion,
|
|
22
|
+
BetaUsage,
|
|
23
|
+
ContentBlock,
|
|
24
|
+
ContentBlockParam,
|
|
25
|
+
ImageBlockParam,
|
|
26
|
+
MessageParam,
|
|
27
|
+
TextBlockParam,
|
|
28
|
+
ToolResultBlockParam,
|
|
29
|
+
ToolUseBlock,
|
|
30
|
+
ToolUseBlockParam,
|
|
31
|
+
Usage,
|
|
32
|
+
} from '../src/stem-utils/llm/types.js'
|
|
33
|
+
|
|
34
|
+
export { AbortError as APIUserAbortError, ApiError, ConnectionError as APIConnectionError, ConnectionTimeoutError as APIConnectionTimeoutError } from '../src/stem-utils/llm/errors.js'
|
|
35
|
+
|
|
36
|
+
/** 构造即抛 — SDK 已移除,运行时不应再实例化 Anthropic client。 */
|
|
37
|
+
class Anthropic {
|
|
38
|
+
constructor(_opts?: unknown) {
|
|
39
|
+
throw new Error("@anthropic-ai/sdk has been removed; use createLlmClient from 'src/stem-utils/llm'")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// class + namespace 合并:支持 `Anthropic.MessageParam` / `Anthropic.Beta.Messages.BetaMessage`
|
|
44
|
+
// 一类命名空间类型访问(仅类型,无运行时产物)。
|
|
45
|
+
declare namespace Anthropic {
|
|
46
|
+
export type MessageParam = T.MessageParam
|
|
47
|
+
export type ContentBlockParam = T.ContentBlockParam
|
|
48
|
+
export type TextBlockParam = T.TextBlockParam
|
|
49
|
+
export type ImageBlockParam = T.ImageBlockParam
|
|
50
|
+
export type ToolResultBlockParam = T.ToolResultBlockParam
|
|
51
|
+
export type ToolUseBlock = T.ToolUseBlock
|
|
52
|
+
export type Usage = T.Usage
|
|
53
|
+
export namespace Beta {
|
|
54
|
+
export namespace Messages {
|
|
55
|
+
export type BetaMessage = T.BetaMessage
|
|
56
|
+
export type BetaContentBlock = T.BetaContentBlock
|
|
57
|
+
export type BetaUsage = T.BetaUsage
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default Anthropic
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type SyntaxTheme = {
|
|
2
|
+
theme: string;
|
|
3
|
+
source: string | null;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export class ColorDiff {
|
|
7
|
+
private hunk: { oldStart: number; oldLines: number; newStart: number; newLines: number; lines: string[] };
|
|
8
|
+
private filePath: string;
|
|
9
|
+
private firstLine: string | null;
|
|
10
|
+
private prefixContent: string | null;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
hunk: { oldStart: number; oldLines: number; newStart: number; newLines: number; lines: string[] },
|
|
14
|
+
firstLine: string | null,
|
|
15
|
+
filePath: string,
|
|
16
|
+
prefixContent?: string | null,
|
|
17
|
+
) {
|
|
18
|
+
this.hunk = hunk;
|
|
19
|
+
this.filePath = filePath;
|
|
20
|
+
this.firstLine = firstLine;
|
|
21
|
+
this.prefixContent = prefixContent ?? null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render(themeName: string, width: number, dim: boolean): string[] | null {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ColorFile {
|
|
30
|
+
private code: string;
|
|
31
|
+
private filePath: string;
|
|
32
|
+
|
|
33
|
+
constructor(code: string, filePath: string) {
|
|
34
|
+
this.code = code;
|
|
35
|
+
this.filePath = filePath;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render(themeName: string, width: number, dim: boolean): string[] | null {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getSyntaxTheme(themeName: string): SyntaxTheme {
|
|
44
|
+
return { theme: themeName, source: null };
|
|
45
|
+
}
|