@keyou007/agent-bot 0.1.13 → 0.1.14-alpha.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/CHANGELOG.md +17 -0
- package/README.md +41 -44
- package/README.zh.md +41 -44
- package/config.example.yaml +4 -0
- package/dist/codex/CodexRuntime.js +8 -3
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +13 -0
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/config/loadConfig.js +2 -0
- package/dist/config/loadConfig.js.map +1 -1
- package/dist/config/schema.js +2 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/console/ConsoleTurnPresenter.js +2 -0
- package/dist/console/ConsoleTurnPresenter.js.map +1 -1
- package/dist/feishu/CardRenderer.js +428 -9
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +29 -8
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +78 -8
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +31 -2
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/feishu/ownerAccess.js +7 -0
- package/dist/feishu/ownerAccess.js.map +1 -0
- package/dist/index.js +14 -17
- package/dist/index.js.map +1 -1
- package/dist/presentation/OutboundRouter.js +19 -1
- package/dist/presentation/OutboundRouter.js.map +1 -1
- package/dist/presentation/splitMarkdown.js +16 -4
- package/dist/presentation/splitMarkdown.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +1012 -58
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/startup/StartupNotifier.js +65 -16
- package/dist/startup/StartupNotifier.js.map +1 -1
- package/dist/startup/startFeishu.js +2 -2
- package/dist/startup/startFeishu.js.map +1 -1
- package/dist/state/StateStore.js +250 -67
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/migrations.js +26 -0
- package/dist/state/migrations.js.map +1 -1
- package/dist/supervision/SafeRestartNotifier.js +17 -16
- package/dist/supervision/SafeRestartNotifier.js.map +1 -1
- package/dist/supervision/SafeRestartScheduler.js +12 -7
- package/dist/supervision/SafeRestartScheduler.js.map +1 -1
- package/dist/supervision/replacementSupervisor.js +45 -4
- package/dist/supervision/replacementSupervisor.js.map +1 -1
- package/dist/supervisor.js +30 -18
- package/dist/supervisor.js.map +1 -1
- package/docs/technical-reference.md +18 -5
- package/docs/technical-reference.zh.md +18 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/agent-bot/SKILL.md +8 -2
- package/src/codex/CodexRuntime.ts +9 -3
- package/src/commands/CommandRouter.ts +13 -0
- package/src/commands/commandTypes.ts +2 -0
- package/src/config/loadConfig.ts +2 -0
- package/src/config/schema.ts +2 -0
- package/src/console/ConsoleTurnPresenter.ts +4 -1
- package/src/feishu/CardRenderer.ts +533 -9
- package/src/feishu/FeishuConnector.ts +44 -10
- package/src/feishu/FeishuMessageClient.ts +118 -7
- package/src/feishu/FeishuTurnPresenter.ts +42 -3
- package/src/feishu/ownerAccess.ts +7 -0
- package/src/feishu/types.ts +7 -0
- package/src/index.ts +20 -20
- package/src/presentation/OutboundRouter.ts +28 -3
- package/src/presentation/splitMarkdown.ts +26 -3
- package/src/proxy/ProxySessionController.ts +1177 -57
- package/src/startup/StartupNotifier.ts +67 -17
- package/src/startup/startFeishu.ts +5 -3
- package/src/state/StateStore.ts +394 -65
- package/src/state/migrations.ts +26 -0
- package/src/supervision/SafeRestartNotifier.ts +17 -17
- package/src/supervision/SafeRestartScheduler.ts +13 -6
- package/src/supervision/replacementSupervisor.ts +50 -4
- package/src/supervisor.ts +35 -16
|
@@ -8,13 +8,23 @@ interface TextRange {
|
|
|
8
8
|
end: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function splitMarkdown(
|
|
11
|
+
export function splitMarkdown(
|
|
12
|
+
text: string,
|
|
13
|
+
maxLength = 4_000,
|
|
14
|
+
maxTablesPerChunk = Number.POSITIVE_INFINITY,
|
|
15
|
+
): string[] {
|
|
12
16
|
if (maxLength < 32) throw new Error("maxLength must be at least 32");
|
|
13
|
-
if (
|
|
17
|
+
if (
|
|
18
|
+
maxTablesPerChunk !== Number.POSITIVE_INFINITY
|
|
19
|
+
&& (!Number.isInteger(maxTablesPerChunk) || maxTablesPerChunk < 1)
|
|
20
|
+
) {
|
|
21
|
+
throw new Error("maxTablesPerChunk must be a positive integer");
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
const chunks: string[] = [];
|
|
16
25
|
let current = "";
|
|
17
26
|
let fence: FenceState | undefined;
|
|
27
|
+
let currentTableCount = 0;
|
|
18
28
|
const lines = text.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
19
29
|
|
|
20
30
|
const closingSuffix = (): string => {
|
|
@@ -27,6 +37,7 @@ export function splitMarkdown(text: string, maxLength = 4_000): string[] {
|
|
|
27
37
|
const continuation = fence;
|
|
28
38
|
chunks.push(`${current}${closingSuffix()}`);
|
|
29
39
|
current = continuation ? `${continuation.opener}\n` : "";
|
|
40
|
+
currentTableCount = 0;
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
const appendPlainLine = (line: string): void => {
|
|
@@ -78,10 +89,19 @@ export function splitMarkdown(text: string, maxLength = 4_000): string[] {
|
|
|
78
89
|
? headerLength + firstRow.length
|
|
79
90
|
: headerLength;
|
|
80
91
|
|
|
81
|
-
if (
|
|
92
|
+
if (
|
|
93
|
+
current
|
|
94
|
+
&& (
|
|
95
|
+
currentTableCount >= maxTablesPerChunk
|
|
96
|
+
|| (initialTableLength <= maxLength && current.length + initialTableLength > maxLength)
|
|
97
|
+
)
|
|
98
|
+
) {
|
|
99
|
+
flush();
|
|
100
|
+
}
|
|
82
101
|
if (headerLength <= maxLength) {
|
|
83
102
|
current += header;
|
|
84
103
|
current += delimiter;
|
|
104
|
+
currentTableCount += 1;
|
|
85
105
|
} else {
|
|
86
106
|
appendPlainLine(header);
|
|
87
107
|
appendPlainLine(delimiter);
|
|
@@ -95,6 +115,7 @@ export function splitMarkdown(text: string, maxLength = 4_000): string[] {
|
|
|
95
115
|
flush();
|
|
96
116
|
if (continuationPrefix.length + row.length <= maxLength) {
|
|
97
117
|
current = continuationPrefix;
|
|
118
|
+
currentTableCount = 1;
|
|
98
119
|
current += row;
|
|
99
120
|
continue;
|
|
100
121
|
}
|
|
@@ -103,8 +124,10 @@ export function splitMarkdown(text: string, maxLength = 4_000): string[] {
|
|
|
103
124
|
// to preserve it as one Markdown table row in that case, so retain the
|
|
104
125
|
// existing lossless hard-split fallback.
|
|
105
126
|
current = continuationPrefix;
|
|
127
|
+
currentTableCount = 1;
|
|
106
128
|
appendPlainLine(row);
|
|
107
129
|
}
|
|
130
|
+
if (currentTableCount >= maxTablesPerChunk) flush();
|
|
108
131
|
};
|
|
109
132
|
|
|
110
133
|
for (let index = 0; index < lines.length; index += 1) {
|