maka-agent 0.2.0-dev.27.20260910 → 0.2.0-dev.28.20260911
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 +106 -0
- package/dist/cli-core.js +7 -0
- package/dist/runtime-host-run-command.js +15 -7
- package/dist/session-import-command.js +69 -0
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +9 -4
- package/node_modules/@maka/core/dist/diagnostic-log.js +18 -7
- package/node_modules/@maka/core/dist/text-sanitize.js +8 -2
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +8 -8
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +3 -1
- package/node_modules/@maka/runtime/dist/bots/bot-test.js +2 -1
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +24 -20
- package/node_modules/@maka/runtime/dist/bots/slack-bridge.js +5 -3
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +87 -29
- package/node_modules/@maka/runtime/dist/bots/wecom-bridge.js +40 -36
- package/node_modules/@maka/runtime/dist/computer-use-tools.js +4 -1
- package/node_modules/@maka/runtime/dist/deep-research-tools.js +11 -5
- package/node_modules/@maka/runtime/dist/edit-replace.js +2 -2
- package/node_modules/@maka/runtime/dist/filesystem-worker/operations.js +5 -6
- package/node_modules/@maka/runtime/dist/memory-extraction-evidence.js +7 -1
- package/node_modules/@maka/runtime/dist/memory-extraction.js +12 -7
- package/node_modules/@maka/runtime/dist/openai-responses-websocket.js +2 -5
- package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +11 -2
- package/node_modules/@maka/runtime/dist/request-customization-fetch.js +14 -7
- package/node_modules/@maka/runtime/dist/session-export.js +1 -0
- package/node_modules/@maka/runtime/dist/session-import.js +100 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +6 -1
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +9 -6
- package/node_modules/@maka/runtime/dist/shell-run-tool-result.js +13 -6
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +43 -10
- package/node_modules/@maka/runtime/dist/stream-graph-handoff.js +6 -1
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +1 -4
- package/node_modules/@maka/runtime/dist/system-prompt/workspace-instructions.js +11 -6
- package/node_modules/@maka/runtime/dist/tavily-search.js +8 -2
- package/node_modules/@maka/runtime/dist/text-line-window.js +49 -0
- package/node_modules/@maka/runtime/dist/tool-output.js +35 -12
- package/node_modules/@maka/runtime/dist/unified-diff.js +40 -10
- package/node_modules/@maka/runtime/dist/web-fetch-tool.js +4 -2
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +82 -33
- package/node_modules/@maka/runtime/dist/workspace-executor.js +2 -6
- package/node_modules/@maka/runtime/package.json +2 -1
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +6 -6
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +7 -4
- package/node_modules/@maka/runtime-host/dist/protocol/artifact.js +2 -2
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +3 -2
- package/node_modules/@maka/runtime-host/dist/protocol/skill-catalog.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/artifact-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +29 -4
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +6 -1
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +35 -4
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +24 -8
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +17 -8
- package/node_modules/@maka/runtime-host/dist/server/runtime-resource-projection.js +3 -9
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +20 -21
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +24 -2
- package/node_modules/@maka/runtime-host/dist/server/skill-catalog-coordinator.js +18 -2
- package/node_modules/@maka/runtime-host/dist/transport/framed-byte-stream-transport.js +4 -1
- package/node_modules/@maka/runtime-host/dist/transport/local-ipc-framing.js +4 -2
- package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +9 -8
- package/node_modules/@maka/runtime-host/dist/transport/resumable-peer-stream.js +14 -9
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +19 -4
- package/node_modules/@maka/storage/dist/context-value-mutation-gate.js +59 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +579 -7
- package/node_modules/@maka/storage/dist/session-message-projection.js +8 -4
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +18 -4
- package/node_modules/@maka/storage/dist/stable-storage.js +2 -1
- package/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs +22 -5
- package/node_modules/@modelcontextprotocol/client/dist/src-NAgB4Mp8.cjs +22 -5
- package/node_modules/zod/v4/core/memoizer.cjs +12 -16
- package/node_modules/zod/v4/core/memoizer.js +12 -16
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -261,6 +261,112 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
261
261
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
262
262
|
SOFTWARE.
|
|
263
263
|
|
|
264
|
+
Pi TUI dependency patch
|
|
265
|
+
|
|
266
|
+
Source: https://www.npmjs.com/package/@earendil-works/pi-tui/v/0.84.4
|
|
267
|
+
Repository: https://github.com/earendil-works/pi/tree/v0.84.4/packages/tui
|
|
268
|
+
Version: 0.84.4
|
|
269
|
+
Dependency patch: patches/@earendil-works+pi-tui+0.84.4.patch
|
|
270
|
+
Copyright (c) 2025 Mario Zechner
|
|
271
|
+
License: MIT
|
|
272
|
+
|
|
273
|
+
Maka redistributes a source patch that copies mutable editor undo state while
|
|
274
|
+
sharing immutable pasted strings. The following MIT License applies to that
|
|
275
|
+
material:
|
|
276
|
+
|
|
277
|
+
MIT License
|
|
278
|
+
|
|
279
|
+
Copyright (c) 2025 Mario Zechner
|
|
280
|
+
|
|
281
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
282
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
283
|
+
in the Software without restriction, including without limitation the rights
|
|
284
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
285
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
286
|
+
furnished to do so, subject to the following conditions:
|
|
287
|
+
|
|
288
|
+
The above copyright notice and this permission notice shall be included in all
|
|
289
|
+
copies or substantial portions of the Software.
|
|
290
|
+
|
|
291
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
292
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
293
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
294
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
295
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
296
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
297
|
+
SOFTWARE.
|
|
298
|
+
|
|
299
|
+
Zod dependency patch
|
|
300
|
+
|
|
301
|
+
Source: https://www.npmjs.com/package/zod/v/4.5.4
|
|
302
|
+
Repository: https://github.com/colinhacks/zod
|
|
303
|
+
Version: 4.5.4
|
|
304
|
+
Dependency patch: patches/zod+4.5.4.patch
|
|
305
|
+
Copyright (c) 2025 Colin McDonnell
|
|
306
|
+
License: MIT
|
|
307
|
+
|
|
308
|
+
Maka redistributes a source patch that releases recursive parse state after
|
|
309
|
+
completion or failure. The following MIT License applies to that material:
|
|
310
|
+
|
|
311
|
+
MIT License
|
|
312
|
+
|
|
313
|
+
Copyright (c) 2025 Colin McDonnell
|
|
314
|
+
|
|
315
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
316
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
317
|
+
in the Software without restriction, including without limitation the rights
|
|
318
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
319
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
320
|
+
furnished to do so, subject to the following conditions:
|
|
321
|
+
|
|
322
|
+
The above copyright notice and this permission notice shall be included in all
|
|
323
|
+
copies or substantial portions of the Software.
|
|
324
|
+
|
|
325
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
326
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
327
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
328
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
329
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
330
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
331
|
+
SOFTWARE.
|
|
332
|
+
|
|
333
|
+
Model Context Protocol client dependency patch
|
|
334
|
+
|
|
335
|
+
Source: https://www.npmjs.com/package/@modelcontextprotocol/client/v/2.0.0
|
|
336
|
+
Repository: https://github.com/modelcontextprotocol/typescript-sdk
|
|
337
|
+
Version: 2.0.0
|
|
338
|
+
Dependency patch: patches/@modelcontextprotocol+client+2.0.0.patch
|
|
339
|
+
Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
|
|
340
|
+
Declared package license: MIT
|
|
341
|
+
|
|
342
|
+
Maka redistributes a source patch that releases settled request observers under
|
|
343
|
+
transport backpressure. The upstream package's LICENSE describes a transition
|
|
344
|
+
from MIT to Apache-2.0: contributions with relicensing consent use Apache-2.0,
|
|
345
|
+
while contributions without that consent retain their original MIT license.
|
|
346
|
+
The Apache License, Version 2.0 is reproduced above. The upstream MIT notice is:
|
|
347
|
+
|
|
348
|
+
MIT License
|
|
349
|
+
|
|
350
|
+
Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
|
|
351
|
+
|
|
352
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
353
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
354
|
+
in the Software without restriction, including without limitation the rights
|
|
355
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
356
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
357
|
+
furnished to do so, subject to the following conditions:
|
|
358
|
+
|
|
359
|
+
The above copyright notice and this permission notice shall be included in all
|
|
360
|
+
copies or substantial portions of the Software.
|
|
361
|
+
|
|
362
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
363
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
364
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
365
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
366
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
367
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
368
|
+
SOFTWARE.
|
|
369
|
+
|
|
264
370
|
Sigstore dependency patch
|
|
265
371
|
|
|
266
372
|
Source: https://www.npmjs.com/package/@sigstore/core/v/4.0.1
|
package/dist/cli-core.js
CHANGED
|
@@ -54,6 +54,8 @@ export function parseMakaCliArgs(argv, version, cliCommand = RELEASE_MAKA_CLI_LA
|
|
|
54
54
|
return { kind: 'activate', args: argv.slice(1) };
|
|
55
55
|
if (first === 'session-export')
|
|
56
56
|
return { kind: 'session-export', args: argv.slice(1) };
|
|
57
|
+
if (first === 'session-import')
|
|
58
|
+
return { kind: 'session-import', args: argv.slice(1) };
|
|
57
59
|
if (first === 'eval')
|
|
58
60
|
return { kind: 'eval', args: argv.slice(1) };
|
|
59
61
|
if (first === 'update')
|
|
@@ -100,6 +102,7 @@ function helpText(cliCommand) {
|
|
|
100
102
|
` ${cliCommand} run ... Run one non-interactive model turn`,
|
|
101
103
|
` ${cliCommand} activate ... Run one Cloud Session activation and emit JSONL`,
|
|
102
104
|
` ${cliCommand} session-export --workspace-root <dir> --session <id> --out <file.maka-session>`,
|
|
105
|
+
` ${cliCommand} session-import --workspace-root <dir> --bundle <file.maka-session>`,
|
|
103
106
|
` ${cliCommand} -p ... Alias for ${cliCommand} run`,
|
|
104
107
|
` ${cliCommand} eval ... Run one declarative multi-arm experiment`,
|
|
105
108
|
` ${cliCommand} update --target <latest|next|version> Update this npm-global CLI and its local Runtime Host`,
|
|
@@ -250,6 +253,10 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
|
|
|
250
253
|
const { runMakaSessionExportCli } = await import('./session-export-command.js');
|
|
251
254
|
return runMakaSessionExportCli(command.args);
|
|
252
255
|
}
|
|
256
|
+
case 'session-import': {
|
|
257
|
+
const { runMakaSessionImportCli } = await import('./session-import-command.js');
|
|
258
|
+
return runMakaSessionImportCli(command.args);
|
|
259
|
+
}
|
|
253
260
|
case 'eval': {
|
|
254
261
|
const { configureInstalledEvalBundle } = await import('./eval-bundle-path.js');
|
|
255
262
|
configureInstalledEvalBundle();
|
|
@@ -569,19 +569,25 @@ class NonInteractiveInteractionController {
|
|
|
569
569
|
#tasks = new Set();
|
|
570
570
|
#unsubscribe;
|
|
571
571
|
#failure;
|
|
572
|
-
#
|
|
573
|
-
#publishFailure;
|
|
572
|
+
#failureWaiters = new Set();
|
|
574
573
|
constructor(driver, stop) {
|
|
575
574
|
this.#driver = driver;
|
|
576
575
|
this.#stop = stop;
|
|
577
|
-
this.#failureSignal = new Promise((resolve) => {
|
|
578
|
-
this.#publishFailure = resolve;
|
|
579
|
-
});
|
|
580
576
|
this.#unsubscribe = driver.subscribePendingInteractions((pending) => this.#accept(pending));
|
|
581
577
|
}
|
|
582
578
|
race(operation) {
|
|
583
579
|
this.throwIfFailed();
|
|
584
|
-
return Promise
|
|
580
|
+
return new Promise((resolve, reject) => {
|
|
581
|
+
this.#failureWaiters.add(reject);
|
|
582
|
+
// Detach completed waits so the controller does not retain consumed event payloads.
|
|
583
|
+
operation.then((value) => {
|
|
584
|
+
this.#failureWaiters.delete(reject);
|
|
585
|
+
resolve(value);
|
|
586
|
+
}, (error) => {
|
|
587
|
+
this.#failureWaiters.delete(reject);
|
|
588
|
+
reject(error);
|
|
589
|
+
});
|
|
590
|
+
});
|
|
585
591
|
}
|
|
586
592
|
async settle() {
|
|
587
593
|
await Promise.all([...this.#tasks]);
|
|
@@ -623,7 +629,9 @@ class NonInteractiveInteractionController {
|
|
|
623
629
|
if (this.#failure)
|
|
624
630
|
return;
|
|
625
631
|
this.#failure = error;
|
|
626
|
-
this.#
|
|
632
|
+
for (const reject of this.#failureWaiters)
|
|
633
|
+
reject(error);
|
|
634
|
+
this.#failureWaiters.clear();
|
|
627
635
|
}
|
|
628
636
|
}
|
|
629
637
|
function delay(ms) {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { importSessionBundle } from '@maka/runtime/session-import';
|
|
20
|
+
const USAGE = 'maka session-import --workspace-root <dir> --bundle <file.maka-session>';
|
|
21
|
+
const FAILURE_EXIT_CODES = {
|
|
22
|
+
workspace_not_found: 6,
|
|
23
|
+
bundle_unreadable: 2,
|
|
24
|
+
session_exists: 3,
|
|
25
|
+
schema_unsupported: 4,
|
|
26
|
+
conflict: 5,
|
|
27
|
+
};
|
|
28
|
+
function parseArgs(args) {
|
|
29
|
+
const values = {};
|
|
30
|
+
for (let index = 0; index < args.length; index += 2) {
|
|
31
|
+
const name = args[index];
|
|
32
|
+
const value = args[index + 1];
|
|
33
|
+
if (!name || !value)
|
|
34
|
+
throw new Error(USAGE);
|
|
35
|
+
if (name === '--workspace-root')
|
|
36
|
+
values.workspaceRoot = value;
|
|
37
|
+
else if (name === '--bundle')
|
|
38
|
+
values.source = value;
|
|
39
|
+
else
|
|
40
|
+
throw new Error(USAGE);
|
|
41
|
+
}
|
|
42
|
+
if (!values.workspaceRoot || !values.source)
|
|
43
|
+
throw new Error(USAGE);
|
|
44
|
+
return values;
|
|
45
|
+
}
|
|
46
|
+
export async function runMakaSessionImportCli(args) {
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = parseArgs(args);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
process.stderr.write(`${error.message}\n`);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
const result = await importSessionBundle({
|
|
56
|
+
workspaceRoot: parsed.workspaceRoot,
|
|
57
|
+
source: parsed.source,
|
|
58
|
+
});
|
|
59
|
+
if (!result.ok) {
|
|
60
|
+
process.stderr.write(`${JSON.stringify(result.reason)}\n`);
|
|
61
|
+
return FAILURE_EXIT_CODES[result.reason.kind] ?? 1;
|
|
62
|
+
}
|
|
63
|
+
process.stdout.write(`${JSON.stringify({
|
|
64
|
+
sessionIds: result.sessionIds,
|
|
65
|
+
artifactFiles: result.artifactFiles,
|
|
66
|
+
contextRefs: result.contextRefs,
|
|
67
|
+
})}\n`);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,7 +2,6 @@ import { getKeybindings } from "../keybindings.js";
|
|
|
2
2
|
import { decodePrintableKey, matchesKey } from "../keys.js";
|
|
3
3
|
import { KillRing } from "../kill-ring.js";
|
|
4
4
|
import { CURSOR_MARKER } from "../tui.js";
|
|
5
|
-
import { UndoStack } from "../undo-stack.js";
|
|
6
5
|
import { cjkBreakRegex, getGraphemeSegmenter, getWordSegmenter, isWhitespaceChar, sliceByColumn, visibleWidth, } from "../utils.js";
|
|
7
6
|
import { findWordBackward, findWordForward } from "../word-navigation.js";
|
|
8
7
|
import { SelectList } from "./select-list.js";
|
|
@@ -243,7 +242,7 @@ export class Editor {
|
|
|
243
242
|
// to.
|
|
244
243
|
snappedFromCursorCol = null;
|
|
245
244
|
// Undo support
|
|
246
|
-
undoStack =
|
|
245
|
+
undoStack = [];
|
|
247
246
|
onSubmit;
|
|
248
247
|
onChange;
|
|
249
248
|
disableSubmit = false;
|
|
@@ -1073,7 +1072,7 @@ export class Editor {
|
|
|
1073
1072
|
this.pasteCounter = 0;
|
|
1074
1073
|
this.exitHistoryBrowsing();
|
|
1075
1074
|
this.scrollOffset = 0;
|
|
1076
|
-
this.undoStack.
|
|
1075
|
+
this.undoStack.length = 0;
|
|
1077
1076
|
this.lastAction = null;
|
|
1078
1077
|
if (this.onChange)
|
|
1079
1078
|
this.onChange("");
|
|
@@ -1700,7 +1699,13 @@ export class Editor {
|
|
|
1700
1699
|
}
|
|
1701
1700
|
}
|
|
1702
1701
|
pushUndoSnapshot() {
|
|
1703
|
-
|
|
1702
|
+
// Detach mutable containers, but share immutable line and paste strings.
|
|
1703
|
+
// structuredClone copies every large paste again for each typed word.
|
|
1704
|
+
this.undoStack.push({
|
|
1705
|
+
state: { ...this.state, lines: [...this.state.lines] },
|
|
1706
|
+
pastes: new Map(this.pastes),
|
|
1707
|
+
pasteCounter: this.pasteCounter,
|
|
1708
|
+
});
|
|
1704
1709
|
}
|
|
1705
1710
|
undo() {
|
|
1706
1711
|
this.exitHistoryBrowsing();
|
|
@@ -71,10 +71,13 @@ function requireMinimumInteger(value, label, minimum) {
|
|
|
71
71
|
return value;
|
|
72
72
|
}
|
|
73
73
|
function truncateCodePoints(value, maximum) {
|
|
74
|
-
const codePoints = [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
const codePoints = [];
|
|
75
|
+
for (const point of value) {
|
|
76
|
+
if (codePoints.length === maximum)
|
|
77
|
+
return `${codePoints.join('')}\n<log entry truncated>`;
|
|
78
|
+
codePoints.push(point);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
78
81
|
}
|
|
79
82
|
function truncateEncodedString(value, maximumBytes) {
|
|
80
83
|
if (encodedStringBytes(value) <= maximumBytes)
|
|
@@ -96,10 +99,18 @@ function truncateEncodedString(value, maximumBytes) {
|
|
|
96
99
|
}
|
|
97
100
|
export function truncateUtf8(value, maximumBytes, marker = '') {
|
|
98
101
|
requirePositiveInteger(maximumBytes, 'maximumBytes');
|
|
99
|
-
if (new TextEncoder().encode(value).byteLength <= maximumBytes)
|
|
102
|
+
if (value.length <= maximumBytes && new TextEncoder().encode(value).byteLength <= maximumBytes)
|
|
100
103
|
return value;
|
|
101
|
-
const suffix = new TextEncoder().encode(marker).byteLength <= maximumBytes
|
|
102
|
-
|
|
104
|
+
const suffix = marker.length <= maximumBytes && new TextEncoder().encode(marker).byteLength <= maximumBytes
|
|
105
|
+
? marker
|
|
106
|
+
: '';
|
|
107
|
+
// Every code point requires at least one UTF-8 byte, so only this prefix can fit.
|
|
108
|
+
const codePoints = [];
|
|
109
|
+
for (const point of value) {
|
|
110
|
+
if (codePoints.length === maximumBytes)
|
|
111
|
+
break;
|
|
112
|
+
codePoints.push(point);
|
|
113
|
+
}
|
|
103
114
|
let low = 0;
|
|
104
115
|
let high = codePoints.length;
|
|
105
116
|
while (low < high) {
|
|
@@ -75,7 +75,7 @@ const ZERO_WIDTH_REGEX = /[\u200B-\u200D\u2060-\u2064\uFEFF]/g;
|
|
|
75
75
|
*
|
|
76
76
|
* Pipeline (applied in order): NFC → control chars → space, bidi format →
|
|
77
77
|
* space, zero-width/invisible → removed, whitespace collapse, trim, then
|
|
78
|
-
* code-point cap. The cap
|
|
78
|
+
* code-point cap. The cap iterates by code points so a
|
|
79
79
|
* surrogate pair (e.g. `🦊` = U+1F98A, two UTF-16 code units) counts as one and
|
|
80
80
|
* is never split in half.
|
|
81
81
|
*
|
|
@@ -91,7 +91,13 @@ export function sanitizeUnicodeText(text, opts) {
|
|
|
91
91
|
.replace(ZERO_WIDTH_REGEX, '')
|
|
92
92
|
.replace(/\s+/g, ' ')
|
|
93
93
|
.trim();
|
|
94
|
-
const points =
|
|
94
|
+
const points = [];
|
|
95
|
+
for (const point of cleaned) {
|
|
96
|
+
points.push(point);
|
|
97
|
+
// One extra point detects truncation without expanding the entire input.
|
|
98
|
+
if (opts.maxCodePoints >= 0 && points.length > opts.maxCodePoints)
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
95
101
|
if (points.length <= opts.maxCodePoints)
|
|
96
102
|
return cleaned;
|
|
97
103
|
return points.slice(0, opts.maxCodePoints).join('') + suffix;
|
|
@@ -1903,15 +1903,12 @@ export class AiSdkTurn {
|
|
|
1903
1903
|
const rejectedSettlement = settlementOutcomes.find((outcome) => outcome.status === 'rejected');
|
|
1904
1904
|
if (rejectedSettlement)
|
|
1905
1905
|
throw rejectedSettlement.reason;
|
|
1906
|
-
|
|
1907
|
-
//
|
|
1908
|
-
//
|
|
1906
|
+
settlementOutcomes.forEach((outcome, index) => {
|
|
1907
|
+
// All settlements completed and rejection was checked above;
|
|
1908
|
+
// preserve provider order for Plan and Yield result handling.
|
|
1909
1909
|
if (outcome.status === 'rejected')
|
|
1910
1910
|
throw outcome.reason;
|
|
1911
|
-
|
|
1912
|
-
});
|
|
1913
|
-
for (let index = 0; index < settlements.length; index += 1) {
|
|
1914
|
-
const settlement = settlements[index];
|
|
1911
|
+
const settlement = outcome.value;
|
|
1915
1912
|
const toolCall = returnedToolCalls[index];
|
|
1916
1913
|
if (isPlanToolResult(settlement.result)) {
|
|
1917
1914
|
this.handlePlanToolResult(settlement.result, queue);
|
|
@@ -1921,7 +1918,10 @@ export class AiSdkTurn {
|
|
|
1921
1918
|
isAgentGraphYieldToolResult(settlement.result)) {
|
|
1922
1919
|
this.handleAgentGraphYieldToolResult(settlement.result);
|
|
1923
1920
|
}
|
|
1924
|
-
}
|
|
1921
|
+
});
|
|
1922
|
+
// Continuation reads durable events, not raw results. Do not retain
|
|
1923
|
+
// an entire completed batch across the next provider request.
|
|
1924
|
+
settlementOutcomes.length = 0;
|
|
1925
1925
|
await queue.waitUntilConsumedThroughCurrent();
|
|
1926
1926
|
const continuationWillRun = (maxSteps === undefined || runtimeSteps < maxSteps) &&
|
|
1927
1927
|
!this.loopStopRequested &&
|
|
@@ -91,7 +91,9 @@ export function buildArchiveReadTool(reader) {
|
|
|
91
91
|
: { success: false, error: result.error };
|
|
92
92
|
},
|
|
93
93
|
}),
|
|
94
|
-
impl: async (input, ctx) =>
|
|
94
|
+
impl: async (input, ctx) =>
|
|
95
|
+
// Detach bounded slices before active tool settlements retain their archive backing.
|
|
96
|
+
structuredClone(await readToolResultArchiveResource(reader, ctx.sessionId, input, ctx.abortSignal)),
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
99
|
function cleanArchiveReadInput(input) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
20
20
|
import { proxiedFetch } from './proxied-fetch.js';
|
|
21
21
|
import { botDiagnosticMessage } from './base-adapter.js';
|
|
22
22
|
import { normalizeWechatIlinkBaseUrl, testWechatBridge, testWechatIlinkCredentials, } from './wechat-bridge.js';
|
|
@@ -76,6 +76,7 @@ async function testSlack(channel) {
|
|
|
76
76
|
return { ok: false, errorCode: 'slack_tokens_missing' };
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
|
+
const { WebClient } = createRequire(import.meta.url)('@slack/web-api');
|
|
79
80
|
const identity = await new WebClient(botToken).auth.test();
|
|
80
81
|
if (!identity.ok)
|
|
81
82
|
return { ok: false, error: identity.error ?? 'Slack auth.test failed' };
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
20
20
|
import { BaseBotAdapter, botReadinessFromSettings } from './base-adapter.js';
|
|
21
21
|
const HANDSHAKE_TIMEOUT_MS = 15_000;
|
|
22
22
|
/**
|
|
@@ -81,24 +81,27 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
this.explicitlyStopped = false;
|
|
84
|
-
|
|
85
|
-
const channel = createLarkChannel({
|
|
86
|
-
appId,
|
|
87
|
-
appSecret,
|
|
88
|
-
domain: isLark ? Domain.Lark : Domain.Feishu,
|
|
89
|
-
transport: 'websocket',
|
|
90
|
-
source: 'maka',
|
|
91
|
-
loggerLevel: LoggerLevel.error,
|
|
92
|
-
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS,
|
|
93
|
-
policy: {
|
|
94
|
-
dmMode: this.settings.allowedUserIds?.length ? 'allowlist' : 'open',
|
|
95
|
-
dmAllowlist: [...(this.settings.allowedUserIds ?? [])],
|
|
96
|
-
requireMention: false,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
this.channel = channel;
|
|
100
|
-
this.wire(channel, appId);
|
|
84
|
+
let channel;
|
|
101
85
|
try {
|
|
86
|
+
// Keep lazy loading synchronous so stop() cannot race a module-loading await.
|
|
87
|
+
const { Domain, LoggerLevel, createLarkChannel } = createRequire(import.meta.url)('@larksuiteoapi/node-sdk');
|
|
88
|
+
const isLark = this.settings.domain?.trim() === 'larksuite.com';
|
|
89
|
+
channel = createLarkChannel({
|
|
90
|
+
appId,
|
|
91
|
+
appSecret,
|
|
92
|
+
domain: isLark ? Domain.Lark : Domain.Feishu,
|
|
93
|
+
transport: 'websocket',
|
|
94
|
+
source: 'maka',
|
|
95
|
+
loggerLevel: LoggerLevel.error,
|
|
96
|
+
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS,
|
|
97
|
+
policy: {
|
|
98
|
+
dmMode: this.settings.allowedUserIds?.length ? 'allowlist' : 'open',
|
|
99
|
+
dmAllowlist: [...(this.settings.allowedUserIds ?? [])],
|
|
100
|
+
requireMention: false,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
this.channel = channel;
|
|
104
|
+
this.wire(channel, appId);
|
|
102
105
|
await channel.connect();
|
|
103
106
|
if (this.explicitlyStopped || this.channel !== channel)
|
|
104
107
|
return;
|
|
@@ -106,13 +109,14 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
106
109
|
this.markConnected(channel, appId);
|
|
107
110
|
}
|
|
108
111
|
catch (error) {
|
|
109
|
-
if (this.explicitlyStopped || this.channel !== channel)
|
|
112
|
+
if (this.explicitlyStopped || (channel && this.channel !== channel))
|
|
110
113
|
return;
|
|
111
114
|
this.running = false;
|
|
112
115
|
this.recordFailure(error);
|
|
113
116
|
this.readiness = 'configured';
|
|
114
117
|
this.emitStatusChange();
|
|
115
|
-
|
|
118
|
+
if (channel)
|
|
119
|
+
await this.disconnectChannel(channel);
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
async stop() {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
20
|
-
import { WebClient } from '@slack/web-api';
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
21
20
|
import { BaseBotAdapter, botReadinessFromSettings } from './base-adapter.js';
|
|
22
21
|
export function slackMessageToEvent(event, receivedAt) {
|
|
23
22
|
if (event.type !== 'message' ||
|
|
@@ -57,8 +56,11 @@ export class SlackBotBridge extends BaseBotAdapter {
|
|
|
57
56
|
this.emitStatusChange();
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
this.web = new WebClient(botToken);
|
|
61
59
|
try {
|
|
60
|
+
const require = createRequire(import.meta.url);
|
|
61
|
+
const { WebClient } = require('@slack/web-api');
|
|
62
|
+
const { SocketModeClient } = require('@slack/socket-mode');
|
|
63
|
+
this.web = new WebClient(botToken);
|
|
62
64
|
const identity = await this.web.auth.test();
|
|
63
65
|
if (!identity.ok)
|
|
64
66
|
throw new Error(identity.error ?? 'Slack auth.test failed');
|