maka-agent 0.2.0-dev.30.20260912 → 0.2.0-dev.31.20260913
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/THIRD_PARTY_NOTICES.txt +392 -0
- package/dist/acp/maka-acp-agent.js +8 -2
- package/dist/acp/prompt-content.js +225 -0
- package/dist/acp/session-event-mapper.js +103 -0
- package/dist/acp/session-registry.js +654 -17
- package/dist/acp/stdio-server.js +10 -1
- package/dist/cli-core.js +1 -1
- package/dist/pi-transcript-tools.js +3 -2
- package/dist/pi-transcript.js +12 -2
- package/dist/runtime-host-session-channel.js +63 -9
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/artifacts.js +6 -0
- package/node_modules/@maka/core/dist/attachments.js +7 -2
- package/node_modules/@maka/core/dist/durable-tool-result-projection.js +3 -1
- package/node_modules/@maka/core/dist/events.js +21 -0
- package/node_modules/@maka/core/dist/goal.js +44 -2
- package/node_modules/@maka/core/dist/permission.js +0 -1
- package/node_modules/@maka/core/dist/runtime-boundary.js +73 -29
- package/node_modules/@maka/core/dist/runtime-event.js +6 -3
- package/node_modules/@maka/core/dist/runtime-handoff.js +10 -2
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +39 -14
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +3 -1
- package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
- package/node_modules/@maka/core/dist/unified-diff.js +33 -26
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +49 -178
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +7 -2
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +15 -53
- package/node_modules/@maka/runtime/dist/bash-model-output.js +7 -1
- package/node_modules/@maka/runtime/dist/bash-tail-buffer.js +13 -52
- package/node_modules/@maka/runtime/dist/builtin-tools.js +59 -111
- package/node_modules/@maka/runtime/dist/child-fd-input.js +3 -2
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +1 -11
- package/node_modules/@maka/runtime/dist/context-budget.js +12 -1
- package/node_modules/@maka/runtime/dist/conversation-copy.js +104 -9
- package/node_modules/@maka/runtime/dist/filesystem-executor.js +10 -6
- package/node_modules/@maka/runtime/dist/filesystem-worker/client.js +77 -19
- package/node_modules/@maka/runtime/dist/filesystem-worker/launch-spec.js +66 -55
- package/node_modules/@maka/runtime/dist/filesystem-worker/operations.js +34 -97
- package/node_modules/@maka/runtime/dist/filesystem-worker/protocol.js +25 -10
- package/node_modules/@maka/runtime/dist/filesystem-worker/worker-entry.js +2 -0
- package/node_modules/@maka/runtime/dist/glob-search.js +74 -0
- package/node_modules/@maka/runtime/dist/goal-continuation.js +78 -8
- package/node_modules/@maka/runtime/dist/goal-state.js +7 -0
- package/node_modules/@maka/runtime/dist/grep-search.js +155 -0
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +84 -94
- package/node_modules/@maka/runtime/dist/model-history.js +25 -3
- package/node_modules/@maka/runtime/dist/pipe-tail-collector.js +6 -9
- package/node_modules/@maka/runtime/dist/read-page.js +231 -0
- package/node_modules/@maka/runtime/dist/request-projection.js +2 -15
- package/node_modules/@maka/runtime/dist/ripgrep-executable.js +62 -0
- package/node_modules/@maka/runtime/dist/ripgrep-guidance.js +81 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +187 -20
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +2 -1
- package/node_modules/@maka/runtime/dist/sandbox/linux-profile-path.js +7 -1
- package/node_modules/@maka/runtime/dist/sandbox/linux-sandbox.js +20 -5
- package/node_modules/@maka/runtime/dist/session-manager.js +6 -6
- package/node_modules/@maka/runtime/dist/session-recap.js +9 -5
- package/node_modules/@maka/runtime/dist/shell-exec.js +7 -25
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +1 -1
- package/node_modules/@maka/runtime/dist/shell-run-tool-result.js +1 -1
- package/node_modules/@maka/runtime/dist/shell-tools.js +6 -12
- package/node_modules/@maka/runtime/dist/tool-availability.js +0 -1
- package/node_modules/@maka/runtime/dist/tool-output.js +1 -1
- package/node_modules/@maka/runtime/dist/tool-result-archive-capability.js +24 -36
- package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +32 -527
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +17 -119
- package/node_modules/@maka/runtime/dist/tool-result-archive.js +7 -25
- package/node_modules/@maka/runtime/dist/tool-runtime.js +7 -5
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +6933 -3681
- package/node_modules/@maka/runtime/dist/workspace-executor.js +20 -24
- package/node_modules/@maka/runtime/package.json +2 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +185 -191
- package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/message.js +2 -2
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -2
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +10 -2
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +38 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +2 -8
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +81 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +13 -13
- package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +65 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +88 -72
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +21 -4
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +145 -1
- package/node_modules/@maka/storage/dist/agent-run-store.js +5 -2
- package/node_modules/@maka/storage/dist/execution-stores.js +2 -1
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +27 -14
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +69 -3
- package/node_modules/balanced-match/LICENSE.md +23 -0
- package/node_modules/balanced-match/README.md +57 -0
- package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
- package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
- package/node_modules/balanced-match/dist/esm/index.js +54 -0
- package/node_modules/balanced-match/dist/esm/package.json +3 -0
- package/node_modules/balanced-match/package.json +68 -0
- package/node_modules/brace-expansion/LICENSE +23 -0
- package/node_modules/brace-expansion/README.md +105 -0
- package/node_modules/brace-expansion/dist/commonjs/index.js +289 -0
- package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
- package/node_modules/brace-expansion/dist/esm/index.js +285 -0
- package/node_modules/brace-expansion/dist/esm/package.json +3 -0
- package/node_modules/brace-expansion/package.json +64 -0
- package/node_modules/glob/LICENSE.md +63 -0
- package/node_modules/glob/README.md +1203 -0
- package/node_modules/glob/dist/commonjs/glob.js +248 -0
- package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
- package/node_modules/glob/dist/commonjs/ignore.js +119 -0
- package/node_modules/glob/dist/commonjs/index.js +68 -0
- package/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/node_modules/glob/dist/commonjs/package.json +3 -0
- package/node_modules/glob/dist/commonjs/pattern.js +223 -0
- package/node_modules/glob/dist/commonjs/processor.js +301 -0
- package/node_modules/glob/dist/commonjs/walker.js +387 -0
- package/node_modules/glob/dist/esm/glob.js +244 -0
- package/node_modules/glob/dist/esm/has-magic.js +23 -0
- package/node_modules/glob/dist/esm/ignore.js +115 -0
- package/node_modules/glob/dist/esm/index.js +55 -0
- package/node_modules/glob/dist/esm/index.min.js +4 -0
- package/node_modules/glob/dist/esm/package.json +3 -0
- package/node_modules/glob/dist/esm/pattern.js +219 -0
- package/node_modules/glob/dist/esm/processor.js +294 -0
- package/node_modules/glob/dist/esm/walker.js +381 -0
- package/node_modules/glob/package.json +98 -0
- package/node_modules/minimatch/LICENSE.md +55 -0
- package/node_modules/minimatch/README.md +528 -0
- package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/node_modules/minimatch/dist/commonjs/ast.js +845 -0
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
- package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/node_modules/minimatch/dist/commonjs/index.js +1127 -0
- package/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/node_modules/minimatch/dist/esm/ast.js +841 -0
- package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
- package/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/node_modules/minimatch/dist/esm/index.js +1114 -0
- package/node_modules/minimatch/dist/esm/package.json +3 -0
- package/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/node_modules/minimatch/package.json +73 -0
- package/node_modules/minipass/LICENSE.md +55 -0
- package/node_modules/minipass/README.md +825 -0
- package/node_modules/minipass/dist/commonjs/index.js +1038 -0
- package/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/node_modules/minipass/dist/esm/index.js +1020 -0
- package/node_modules/minipass/dist/esm/package.json +3 -0
- package/node_modules/minipass/package.json +77 -0
- package/node_modules/path-scurry/LICENSE.md +55 -0
- package/node_modules/path-scurry/README.md +636 -0
- package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
- package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/dist/esm/index.js +1983 -0
- package/node_modules/path-scurry/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
- package/node_modules/path-scurry/node_modules/lru-cache/README.md +469 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js +1726 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1726 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js +1726 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js +1722 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1722 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js +1722 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/package.json +154 -0
- package/node_modules/path-scurry/package.json +72 -0
- package/package.json +1 -1
- package/node_modules/@maka/runtime/dist/active-tool-result-prune.js +0 -248
- package/node_modules/@maka/runtime/dist/active-tool-result-working-set.js +0 -218
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +0 -115
package/THIRD_PARTY_NOTICES.txt
CHANGED
|
@@ -2320,6 +2320,38 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
2320
2320
|
|
|
2321
2321
|
================================================================================
|
|
2322
2322
|
|
|
2323
|
+
Package: balanced-match@4.0.4
|
|
2324
|
+
Declared license: MIT
|
|
2325
|
+
Selected license: MIT
|
|
2326
|
+
Repository: git://github.com/juliangruber/balanced-match.git
|
|
2327
|
+
|
|
2328
|
+
--- LICENSE.md ---
|
|
2329
|
+
(MIT)
|
|
2330
|
+
|
|
2331
|
+
Original code Copyright Julian Gruber <julian@juliangruber.com>
|
|
2332
|
+
|
|
2333
|
+
Port to TypeScript Copyright Isaac Z. Schlueter <i@izs.me>
|
|
2334
|
+
|
|
2335
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
2336
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
2337
|
+
the Software without restriction, including without limitation the rights to
|
|
2338
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
2339
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
2340
|
+
so, subject to the following conditions:
|
|
2341
|
+
|
|
2342
|
+
The above copyright notice and this permission notice shall be included in all
|
|
2343
|
+
copies or substantial portions of the Software.
|
|
2344
|
+
|
|
2345
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2346
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2347
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2348
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2349
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2350
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
2351
|
+
SOFTWARE.
|
|
2352
|
+
|
|
2353
|
+
================================================================================
|
|
2354
|
+
|
|
2323
2355
|
Package: bare-addon-resolve@1.10.1
|
|
2324
2356
|
Declared license: Apache-2.0
|
|
2325
2357
|
Selected license: Apache-2.0
|
|
@@ -2972,6 +3004,38 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
2972
3004
|
|
|
2973
3005
|
================================================================================
|
|
2974
3006
|
|
|
3007
|
+
Package: brace-expansion@5.0.9
|
|
3008
|
+
Declared license: MIT
|
|
3009
|
+
Selected license: MIT
|
|
3010
|
+
Repository: git+https://github.com/juliangruber/brace-expansion.git
|
|
3011
|
+
|
|
3012
|
+
--- LICENSE ---
|
|
3013
|
+
MIT License
|
|
3014
|
+
|
|
3015
|
+
Copyright Julian Gruber <julian@juliangruber.com>
|
|
3016
|
+
|
|
3017
|
+
TypeScript port Copyright Isaac Z. Schlueter <i@izs.me>
|
|
3018
|
+
|
|
3019
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3020
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
3021
|
+
in the Software without restriction, including without limitation the rights
|
|
3022
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3023
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
3024
|
+
furnished to do so, subject to the following conditions:
|
|
3025
|
+
|
|
3026
|
+
The above copyright notice and this permission notice shall be included in all
|
|
3027
|
+
copies or substantial portions of the Software.
|
|
3028
|
+
|
|
3029
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3030
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3031
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3032
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3033
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3034
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
3035
|
+
SOFTWARE.
|
|
3036
|
+
|
|
3037
|
+
================================================================================
|
|
3038
|
+
|
|
2975
3039
|
Package: call-bind-apply-helpers@1.0.2
|
|
2976
3040
|
Declared license: MIT
|
|
2977
3041
|
Selected license: MIT
|
|
@@ -4349,6 +4413,78 @@ SOFTWARE.
|
|
|
4349
4413
|
|
|
4350
4414
|
================================================================================
|
|
4351
4415
|
|
|
4416
|
+
Package: glob@13.0.6
|
|
4417
|
+
Declared license: BlueOak-1.0.0
|
|
4418
|
+
Selected license: BlueOak-1.0.0
|
|
4419
|
+
Repository: git@github.com:isaacs/node-glob.git
|
|
4420
|
+
|
|
4421
|
+
--- LICENSE.md ---
|
|
4422
|
+
All packages under `src/` are licensed according to the terms in
|
|
4423
|
+
their respective `LICENSE` or `LICENSE.md` files.
|
|
4424
|
+
|
|
4425
|
+
The remainder of this project is licensed under the Blue Oak
|
|
4426
|
+
Model License, as follows:
|
|
4427
|
+
|
|
4428
|
+
-----
|
|
4429
|
+
|
|
4430
|
+
# Blue Oak Model License
|
|
4431
|
+
|
|
4432
|
+
Version 1.0.0
|
|
4433
|
+
|
|
4434
|
+
## Purpose
|
|
4435
|
+
|
|
4436
|
+
This license gives everyone as much permission to work with
|
|
4437
|
+
this software as possible, while protecting contributors
|
|
4438
|
+
from liability.
|
|
4439
|
+
|
|
4440
|
+
## Acceptance
|
|
4441
|
+
|
|
4442
|
+
In order to receive this license, you must agree to its
|
|
4443
|
+
rules. The rules of this license are both obligations
|
|
4444
|
+
under that agreement and conditions to your license.
|
|
4445
|
+
You must not do anything with this software that triggers
|
|
4446
|
+
a rule that you cannot or will not follow.
|
|
4447
|
+
|
|
4448
|
+
## Copyright
|
|
4449
|
+
|
|
4450
|
+
Each contributor licenses you to do everything with this
|
|
4451
|
+
software that would otherwise infringe that contributor's
|
|
4452
|
+
copyright in it.
|
|
4453
|
+
|
|
4454
|
+
## Notices
|
|
4455
|
+
|
|
4456
|
+
You must ensure that everyone who gets a copy of
|
|
4457
|
+
any part of this software from you, with or without
|
|
4458
|
+
changes, also gets the text of this license or a link to
|
|
4459
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
4460
|
+
|
|
4461
|
+
## Excuse
|
|
4462
|
+
|
|
4463
|
+
If anyone notifies you in writing that you have not
|
|
4464
|
+
complied with [Notices](#notices), you can keep your
|
|
4465
|
+
license by taking all practical steps to comply within 30
|
|
4466
|
+
days after the notice. If you do not do so, your license
|
|
4467
|
+
ends immediately.
|
|
4468
|
+
|
|
4469
|
+
## Patent
|
|
4470
|
+
|
|
4471
|
+
Each contributor licenses you to do everything with this
|
|
4472
|
+
software that would otherwise infringe any patent claims
|
|
4473
|
+
they can license or become able to license.
|
|
4474
|
+
|
|
4475
|
+
## Reliability
|
|
4476
|
+
|
|
4477
|
+
No contributor can revoke this license.
|
|
4478
|
+
|
|
4479
|
+
## No Liability
|
|
4480
|
+
|
|
4481
|
+
***As far as the law allows, this software comes as is,
|
|
4482
|
+
without any warranty or condition, and no contributor
|
|
4483
|
+
will be liable to anyone for any damages related to this
|
|
4484
|
+
software or this license, under any kind of legal claim.***
|
|
4485
|
+
|
|
4486
|
+
================================================================================
|
|
4487
|
+
|
|
4352
4488
|
Package: gopd@1.2.0
|
|
4353
4489
|
Declared license: MIT
|
|
4354
4490
|
Selected license: MIT
|
|
@@ -5374,6 +5510,70 @@ Apache License
|
|
|
5374
5510
|
|
|
5375
5511
|
================================================================================
|
|
5376
5512
|
|
|
5513
|
+
Package: lru-cache@11.5.1
|
|
5514
|
+
Declared license: BlueOak-1.0.0
|
|
5515
|
+
Selected license: BlueOak-1.0.0
|
|
5516
|
+
Repository: git+ssh://git@github.com/isaacs/node-lru-cache.git
|
|
5517
|
+
|
|
5518
|
+
--- LICENSE.md ---
|
|
5519
|
+
# Blue Oak Model License
|
|
5520
|
+
|
|
5521
|
+
Version 1.0.0
|
|
5522
|
+
|
|
5523
|
+
## Purpose
|
|
5524
|
+
|
|
5525
|
+
This license gives everyone as much permission to work with
|
|
5526
|
+
this software as possible, while protecting contributors
|
|
5527
|
+
from liability.
|
|
5528
|
+
|
|
5529
|
+
## Acceptance
|
|
5530
|
+
|
|
5531
|
+
In order to receive this license, you must agree to its
|
|
5532
|
+
rules. The rules of this license are both obligations
|
|
5533
|
+
under that agreement and conditions to your license.
|
|
5534
|
+
You must not do anything with this software that triggers
|
|
5535
|
+
a rule that you cannot or will not follow.
|
|
5536
|
+
|
|
5537
|
+
## Copyright
|
|
5538
|
+
|
|
5539
|
+
Each contributor licenses you to do everything with this
|
|
5540
|
+
software that would otherwise infringe that contributor's
|
|
5541
|
+
copyright in it.
|
|
5542
|
+
|
|
5543
|
+
## Notices
|
|
5544
|
+
|
|
5545
|
+
You must ensure that everyone who gets a copy of
|
|
5546
|
+
any part of this software from you, with or without
|
|
5547
|
+
changes, also gets the text of this license or a link to
|
|
5548
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
5549
|
+
|
|
5550
|
+
## Excuse
|
|
5551
|
+
|
|
5552
|
+
If anyone notifies you in writing that you have not
|
|
5553
|
+
complied with [Notices](#notices), you can keep your
|
|
5554
|
+
license by taking all practical steps to comply within 30
|
|
5555
|
+
days after the notice. If you do not do so, your license
|
|
5556
|
+
ends immediately.
|
|
5557
|
+
|
|
5558
|
+
## Patent
|
|
5559
|
+
|
|
5560
|
+
Each contributor licenses you to do everything with this
|
|
5561
|
+
software that would otherwise infringe any patent claims
|
|
5562
|
+
they can license or become able to license.
|
|
5563
|
+
|
|
5564
|
+
## Reliability
|
|
5565
|
+
|
|
5566
|
+
No contributor can revoke this license.
|
|
5567
|
+
|
|
5568
|
+
## No Liability
|
|
5569
|
+
|
|
5570
|
+
***As far as the law allows, this software comes as is,
|
|
5571
|
+
without any warranty or condition, and no contributor
|
|
5572
|
+
will be liable to anyone for any damages related to this
|
|
5573
|
+
software or this license, under any kind of legal claim.***
|
|
5574
|
+
|
|
5575
|
+
================================================================================
|
|
5576
|
+
|
|
5377
5577
|
Package: marked@18.0.5
|
|
5378
5578
|
Declared license: MIT
|
|
5379
5579
|
Selected license: MIT
|
|
@@ -5521,6 +5721,134 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
5521
5721
|
|
|
5522
5722
|
================================================================================
|
|
5523
5723
|
|
|
5724
|
+
Package: minimatch@10.2.5
|
|
5725
|
+
Declared license: BlueOak-1.0.0
|
|
5726
|
+
Selected license: BlueOak-1.0.0
|
|
5727
|
+
Repository: git@github.com:isaacs/minimatch
|
|
5728
|
+
|
|
5729
|
+
--- LICENSE.md ---
|
|
5730
|
+
# Blue Oak Model License
|
|
5731
|
+
|
|
5732
|
+
Version 1.0.0
|
|
5733
|
+
|
|
5734
|
+
## Purpose
|
|
5735
|
+
|
|
5736
|
+
This license gives everyone as much permission to work with
|
|
5737
|
+
this software as possible, while protecting contributors
|
|
5738
|
+
from liability.
|
|
5739
|
+
|
|
5740
|
+
## Acceptance
|
|
5741
|
+
|
|
5742
|
+
In order to receive this license, you must agree to its
|
|
5743
|
+
rules. The rules of this license are both obligations
|
|
5744
|
+
under that agreement and conditions to your license.
|
|
5745
|
+
You must not do anything with this software that triggers
|
|
5746
|
+
a rule that you cannot or will not follow.
|
|
5747
|
+
|
|
5748
|
+
## Copyright
|
|
5749
|
+
|
|
5750
|
+
Each contributor licenses you to do everything with this
|
|
5751
|
+
software that would otherwise infringe that contributor's
|
|
5752
|
+
copyright in it.
|
|
5753
|
+
|
|
5754
|
+
## Notices
|
|
5755
|
+
|
|
5756
|
+
You must ensure that everyone who gets a copy of
|
|
5757
|
+
any part of this software from you, with or without
|
|
5758
|
+
changes, also gets the text of this license or a link to
|
|
5759
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
5760
|
+
|
|
5761
|
+
## Excuse
|
|
5762
|
+
|
|
5763
|
+
If anyone notifies you in writing that you have not
|
|
5764
|
+
complied with [Notices](#notices), you can keep your
|
|
5765
|
+
license by taking all practical steps to comply within 30
|
|
5766
|
+
days after the notice. If you do not do so, your license
|
|
5767
|
+
ends immediately.
|
|
5768
|
+
|
|
5769
|
+
## Patent
|
|
5770
|
+
|
|
5771
|
+
Each contributor licenses you to do everything with this
|
|
5772
|
+
software that would otherwise infringe any patent claims
|
|
5773
|
+
they can license or become able to license.
|
|
5774
|
+
|
|
5775
|
+
## Reliability
|
|
5776
|
+
|
|
5777
|
+
No contributor can revoke this license.
|
|
5778
|
+
|
|
5779
|
+
## No Liability
|
|
5780
|
+
|
|
5781
|
+
**_As far as the law allows, this software comes as is,
|
|
5782
|
+
without any warranty or condition, and no contributor
|
|
5783
|
+
will be liable to anyone for any damages related to this
|
|
5784
|
+
software or this license, under any kind of legal claim._**
|
|
5785
|
+
|
|
5786
|
+
================================================================================
|
|
5787
|
+
|
|
5788
|
+
Package: minipass@7.1.3
|
|
5789
|
+
Declared license: BlueOak-1.0.0
|
|
5790
|
+
Selected license: BlueOak-1.0.0
|
|
5791
|
+
Repository: https://github.com/isaacs/minipass
|
|
5792
|
+
|
|
5793
|
+
--- LICENSE.md ---
|
|
5794
|
+
# Blue Oak Model License
|
|
5795
|
+
|
|
5796
|
+
Version 1.0.0
|
|
5797
|
+
|
|
5798
|
+
## Purpose
|
|
5799
|
+
|
|
5800
|
+
This license gives everyone as much permission to work with
|
|
5801
|
+
this software as possible, while protecting contributors
|
|
5802
|
+
from liability.
|
|
5803
|
+
|
|
5804
|
+
## Acceptance
|
|
5805
|
+
|
|
5806
|
+
In order to receive this license, you must agree to its
|
|
5807
|
+
rules. The rules of this license are both obligations
|
|
5808
|
+
under that agreement and conditions to your license.
|
|
5809
|
+
You must not do anything with this software that triggers
|
|
5810
|
+
a rule that you cannot or will not follow.
|
|
5811
|
+
|
|
5812
|
+
## Copyright
|
|
5813
|
+
|
|
5814
|
+
Each contributor licenses you to do everything with this
|
|
5815
|
+
software that would otherwise infringe that contributor's
|
|
5816
|
+
copyright in it.
|
|
5817
|
+
|
|
5818
|
+
## Notices
|
|
5819
|
+
|
|
5820
|
+
You must ensure that everyone who gets a copy of
|
|
5821
|
+
any part of this software from you, with or without
|
|
5822
|
+
changes, also gets the text of this license or a link to
|
|
5823
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
5824
|
+
|
|
5825
|
+
## Excuse
|
|
5826
|
+
|
|
5827
|
+
If anyone notifies you in writing that you have not
|
|
5828
|
+
complied with [Notices](#notices), you can keep your
|
|
5829
|
+
license by taking all practical steps to comply within 30
|
|
5830
|
+
days after the notice. If you do not do so, your license
|
|
5831
|
+
ends immediately.
|
|
5832
|
+
|
|
5833
|
+
## Patent
|
|
5834
|
+
|
|
5835
|
+
Each contributor licenses you to do everything with this
|
|
5836
|
+
software that would otherwise infringe any patent claims
|
|
5837
|
+
they can license or become able to license.
|
|
5838
|
+
|
|
5839
|
+
## Reliability
|
|
5840
|
+
|
|
5841
|
+
No contributor can revoke this license.
|
|
5842
|
+
|
|
5843
|
+
## No Liability
|
|
5844
|
+
|
|
5845
|
+
***As far as the law allows, this software comes as is,
|
|
5846
|
+
without any warranty or condition, and no contributor
|
|
5847
|
+
will be liable to anyone for any damages related to this
|
|
5848
|
+
software or this license, under any kind of legal claim.***
|
|
5849
|
+
|
|
5850
|
+
================================================================================
|
|
5851
|
+
|
|
5524
5852
|
Package: minisearch@7.2.0
|
|
5525
5853
|
Declared license: MIT
|
|
5526
5854
|
Selected license: MIT
|
|
@@ -6097,6 +6425,70 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
6097
6425
|
|
|
6098
6426
|
================================================================================
|
|
6099
6427
|
|
|
6428
|
+
Package: path-scurry@2.0.2
|
|
6429
|
+
Declared license: BlueOak-1.0.0
|
|
6430
|
+
Selected license: BlueOak-1.0.0
|
|
6431
|
+
Repository: git+https://github.com/isaacs/path-scurry
|
|
6432
|
+
|
|
6433
|
+
--- LICENSE.md ---
|
|
6434
|
+
# Blue Oak Model License
|
|
6435
|
+
|
|
6436
|
+
Version 1.0.0
|
|
6437
|
+
|
|
6438
|
+
## Purpose
|
|
6439
|
+
|
|
6440
|
+
This license gives everyone as much permission to work with
|
|
6441
|
+
this software as possible, while protecting contributors
|
|
6442
|
+
from liability.
|
|
6443
|
+
|
|
6444
|
+
## Acceptance
|
|
6445
|
+
|
|
6446
|
+
In order to receive this license, you must agree to its
|
|
6447
|
+
rules. The rules of this license are both obligations
|
|
6448
|
+
under that agreement and conditions to your license.
|
|
6449
|
+
You must not do anything with this software that triggers
|
|
6450
|
+
a rule that you cannot or will not follow.
|
|
6451
|
+
|
|
6452
|
+
## Copyright
|
|
6453
|
+
|
|
6454
|
+
Each contributor licenses you to do everything with this
|
|
6455
|
+
software that would otherwise infringe that contributor's
|
|
6456
|
+
copyright in it.
|
|
6457
|
+
|
|
6458
|
+
## Notices
|
|
6459
|
+
|
|
6460
|
+
You must ensure that everyone who gets a copy of
|
|
6461
|
+
any part of this software from you, with or without
|
|
6462
|
+
changes, also gets the text of this license or a link to
|
|
6463
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
6464
|
+
|
|
6465
|
+
## Excuse
|
|
6466
|
+
|
|
6467
|
+
If anyone notifies you in writing that you have not
|
|
6468
|
+
complied with [Notices](#notices), you can keep your
|
|
6469
|
+
license by taking all practical steps to comply within 30
|
|
6470
|
+
days after the notice. If you do not do so, your license
|
|
6471
|
+
ends immediately.
|
|
6472
|
+
|
|
6473
|
+
## Patent
|
|
6474
|
+
|
|
6475
|
+
Each contributor licenses you to do everything with this
|
|
6476
|
+
software that would otherwise infringe any patent claims
|
|
6477
|
+
they can license or become able to license.
|
|
6478
|
+
|
|
6479
|
+
## Reliability
|
|
6480
|
+
|
|
6481
|
+
No contributor can revoke this license.
|
|
6482
|
+
|
|
6483
|
+
## No Liability
|
|
6484
|
+
|
|
6485
|
+
***As far as the law allows, this software comes as is,
|
|
6486
|
+
without any warranty or condition, and no contributor
|
|
6487
|
+
will be liable to anyone for any damages related to this
|
|
6488
|
+
software or this license, under any kind of legal claim.***
|
|
6489
|
+
|
|
6490
|
+
================================================================================
|
|
6491
|
+
|
|
6100
6492
|
Package: pkce-challenge@5.0.1
|
|
6101
6493
|
Declared license: MIT
|
|
6102
6494
|
Selected license: MIT
|
|
@@ -21,11 +21,17 @@ export function createMakaAcpAgent(options) {
|
|
|
21
21
|
return agent({ name: 'maka' })
|
|
22
22
|
.onRequest(methods.agent.initialize, () => ({
|
|
23
23
|
protocolVersion: 1,
|
|
24
|
-
agentCapabilities: { sessionCapabilities: { list: {} } },
|
|
24
|
+
agentCapabilities: { sessionCapabilities: { list: {}, close: {} } },
|
|
25
25
|
authMethods: [],
|
|
26
26
|
agentInfo: { name: 'maka', title: 'Maka', version: options.version },
|
|
27
27
|
}))
|
|
28
28
|
.onRequest(methods.agent.session.new, ({ params }) => options.sessionRegistry.create(params))
|
|
29
29
|
.onRequest(methods.agent.session.list, ({ params }) => options.sessionRegistry.list(params))
|
|
30
|
-
.onRequest(methods.agent.session.setConfigOption, ({ params }) => options.sessionRegistry.setConfigOption(params))
|
|
30
|
+
.onRequest(methods.agent.session.setConfigOption, ({ params }) => options.sessionRegistry.setConfigOption(params))
|
|
31
|
+
.onRequest(methods.agent.session.prompt, ({ params, signal, client }) => options.sessionRegistry.prompt(params, {
|
|
32
|
+
signal,
|
|
33
|
+
notify: (notification) => client.notify(methods.client.session.update, notification),
|
|
34
|
+
}))
|
|
35
|
+
.onNotification(methods.agent.session.cancel, ({ params }) => options.sessionRegistry.cancel(params))
|
|
36
|
+
.onRequest(methods.agent.session.close, ({ params }) => options.sessionRegistry.close(params));
|
|
31
37
|
}
|
|
@@ -0,0 +1,225 @@
|
|
|
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 { createHash, randomUUID } from 'node:crypto';
|
|
20
|
+
import { constants } from 'node:fs';
|
|
21
|
+
import { open, realpath } from 'node:fs/promises';
|
|
22
|
+
import { basename } from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { RequestError } from '@agentclientprotocol/sdk';
|
|
25
|
+
import { attachmentKindFromMimeType, MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT, PDF_HEADER_SCAN_BYTES, resolveAttachmentMimeType, } from '@maka/core/attachments';
|
|
26
|
+
import { ARTIFACT_INGEST_CHUNK_MAX_BYTES } from '@maka/runtime-host/protocol';
|
|
27
|
+
export async function mapAcpPromptContent(prompt, dependencies = {}) {
|
|
28
|
+
const resources = prompt.filter((block) => block.type === 'resource_link');
|
|
29
|
+
if (resources.length > MAX_ATTACHMENT_COUNT) {
|
|
30
|
+
throw invalidPrompt('prompt', 'too_many_attachments');
|
|
31
|
+
}
|
|
32
|
+
for (const block of prompt) {
|
|
33
|
+
if (block.type !== 'text' && block.type !== 'resource_link') {
|
|
34
|
+
throw invalidPrompt('prompt', 'unsupported_content_type');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const modelParts = [];
|
|
38
|
+
const displayParts = [];
|
|
39
|
+
const attachments = [];
|
|
40
|
+
for (const block of prompt) {
|
|
41
|
+
if (block.type === 'text') {
|
|
42
|
+
modelParts.push(block.text);
|
|
43
|
+
displayParts.push(block.text);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (block.type !== 'resource_link') {
|
|
47
|
+
throw invalidPrompt('prompt', 'unsupported_content_type');
|
|
48
|
+
}
|
|
49
|
+
const path = localFilePath(block.uri);
|
|
50
|
+
const file = await (dependencies.openFile ?? readPromptFile)(path).catch((error) => {
|
|
51
|
+
if (error instanceof RequestError)
|
|
52
|
+
throw error;
|
|
53
|
+
throw invalidPrompt('prompt', 'resource_unreadable');
|
|
54
|
+
});
|
|
55
|
+
if (!file.isFile)
|
|
56
|
+
throw invalidPrompt('prompt', 'resource_not_file');
|
|
57
|
+
if (!Number.isSafeInteger(file.size) || file.size < 0 || file.size > MAX_ATTACHMENT_BYTES) {
|
|
58
|
+
throw invalidPrompt('prompt', 'resource_too_large');
|
|
59
|
+
}
|
|
60
|
+
const name = block.name || basename(file.canonicalPath);
|
|
61
|
+
const mimeType = resolveAttachmentMimeType(file.prefix, block.mimeType ?? undefined, name);
|
|
62
|
+
modelParts.push(block.uri);
|
|
63
|
+
attachments.push({
|
|
64
|
+
kind: attachmentKindFromMimeType(mimeType, name),
|
|
65
|
+
name,
|
|
66
|
+
mimeType,
|
|
67
|
+
bytes: file.size,
|
|
68
|
+
ref: { kind: 'external_file', absolutePath: file.canonicalPath },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const text = modelParts.join('\n\n');
|
|
72
|
+
const displayText = displayParts.join('\n\n');
|
|
73
|
+
return {
|
|
74
|
+
text,
|
|
75
|
+
...(displayText !== text ? { displayText } : {}),
|
|
76
|
+
...(attachments.length > 0 ? { attachments } : {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Publish only after live attachment succeeds, before admitting the prompt's Turn. */
|
|
80
|
+
export async function publishAcpPromptAttachments(content, options) {
|
|
81
|
+
const attachments = [];
|
|
82
|
+
for (const attachment of content.attachments ?? []) {
|
|
83
|
+
options.assertActive();
|
|
84
|
+
if (attachment.ref.kind !== 'external_file') {
|
|
85
|
+
attachments.push(attachment);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const bytes = await readPromptAttachment(attachment.ref.absolutePath, options.assertActive);
|
|
89
|
+
options.assertActive();
|
|
90
|
+
const uploadId = randomUUID();
|
|
91
|
+
const identity = { sessionId: options.sessionId, uploadId };
|
|
92
|
+
let opened = false;
|
|
93
|
+
try {
|
|
94
|
+
const begin = await options.connection.request('artifact.ingest', {
|
|
95
|
+
kind: 'begin',
|
|
96
|
+
...identity,
|
|
97
|
+
name: attachment.name,
|
|
98
|
+
mimeType: resolveAttachmentMimeType(bytes, attachment.mimeType, attachment.name),
|
|
99
|
+
totalBytes: bytes.length,
|
|
100
|
+
contentSha256: `sha256:${createHash('sha256').update(bytes).digest('hex')}`,
|
|
101
|
+
});
|
|
102
|
+
if (begin.kind === 'committed') {
|
|
103
|
+
options.assertActive();
|
|
104
|
+
attachments.push(begin.attachment);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (begin.kind !== 'upload_opened') {
|
|
108
|
+
throw new Error('Runtime Host did not open the Attachment upload');
|
|
109
|
+
}
|
|
110
|
+
opened = true;
|
|
111
|
+
let offset = begin.nextOffset;
|
|
112
|
+
while (offset < bytes.length) {
|
|
113
|
+
options.assertActive();
|
|
114
|
+
const chunk = bytes.subarray(offset, offset + ARTIFACT_INGEST_CHUNK_MAX_BYTES);
|
|
115
|
+
const accepted = await options.connection.request('artifact.ingest', {
|
|
116
|
+
kind: 'chunk',
|
|
117
|
+
...identity,
|
|
118
|
+
offset,
|
|
119
|
+
chunkBase64: chunk.toString('base64'),
|
|
120
|
+
});
|
|
121
|
+
if (accepted.kind !== 'chunk_accepted' || accepted.nextOffset !== offset + chunk.length) {
|
|
122
|
+
throw new Error('Runtime Host did not advance the Attachment upload');
|
|
123
|
+
}
|
|
124
|
+
offset = accepted.nextOffset;
|
|
125
|
+
}
|
|
126
|
+
options.assertActive();
|
|
127
|
+
const committed = await options.connection.request('artifact.ingest', {
|
|
128
|
+
kind: 'commit',
|
|
129
|
+
...identity,
|
|
130
|
+
});
|
|
131
|
+
if (committed.kind !== 'committed') {
|
|
132
|
+
throw new Error('Runtime Host did not commit the Attachment upload');
|
|
133
|
+
}
|
|
134
|
+
opened = false;
|
|
135
|
+
options.assertActive();
|
|
136
|
+
attachments.push(committed.attachment);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (opened) {
|
|
140
|
+
await options.connection
|
|
141
|
+
.request('artifact.ingest', { kind: 'abort', ...identity })
|
|
142
|
+
.catch(() => undefined);
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
options.assertActive();
|
|
148
|
+
return content.attachments ? { ...content, attachments } : content;
|
|
149
|
+
}
|
|
150
|
+
async function readPromptAttachment(path, assertActive) {
|
|
151
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NONBLOCK).catch(() => {
|
|
152
|
+
throw invalidPrompt('prompt', 'resource_unreadable');
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
const stats = await handle.stat();
|
|
156
|
+
if (!stats.isFile())
|
|
157
|
+
throw invalidPrompt('prompt', 'resource_not_file');
|
|
158
|
+
if (!Number.isSafeInteger(stats.size) || stats.size < 0 || stats.size > MAX_ATTACHMENT_BYTES) {
|
|
159
|
+
throw invalidPrompt('prompt', 'resource_too_large');
|
|
160
|
+
}
|
|
161
|
+
const bytes = Buffer.alloc(stats.size);
|
|
162
|
+
let offset = 0;
|
|
163
|
+
while (offset < bytes.length) {
|
|
164
|
+
assertActive();
|
|
165
|
+
const { bytesRead } = await handle.read(bytes, offset, Math.min(ARTIFACT_INGEST_CHUNK_MAX_BYTES, bytes.length - offset), offset);
|
|
166
|
+
if (bytesRead === 0)
|
|
167
|
+
throw invalidPrompt('prompt', 'resource_changed');
|
|
168
|
+
offset += bytesRead;
|
|
169
|
+
}
|
|
170
|
+
if ((await handle.stat()).size !== bytes.length) {
|
|
171
|
+
throw invalidPrompt('prompt', 'resource_changed');
|
|
172
|
+
}
|
|
173
|
+
return bytes;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
await handle.close();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function readPromptFile(path) {
|
|
180
|
+
// A FIFO must not wait for a writer before we can reject it.
|
|
181
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
182
|
+
try {
|
|
183
|
+
const stats = await handle.stat();
|
|
184
|
+
if (!stats.isFile())
|
|
185
|
+
throw invalidPrompt('prompt', 'resource_not_file');
|
|
186
|
+
const prefix = Buffer.alloc(Math.min(PDF_HEADER_SCAN_BYTES, stats.size));
|
|
187
|
+
const { bytesRead } = await handle.read(prefix, 0, prefix.length, 0);
|
|
188
|
+
return {
|
|
189
|
+
size: stats.size,
|
|
190
|
+
isFile: stats.isFile(),
|
|
191
|
+
prefix: prefix.subarray(0, bytesRead),
|
|
192
|
+
canonicalPath: await realpath(path),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
await handle.close();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function localFilePath(uri) {
|
|
200
|
+
let url;
|
|
201
|
+
try {
|
|
202
|
+
url = new URL(uri);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
throw invalidPrompt('prompt', 'invalid_resource_uri');
|
|
206
|
+
}
|
|
207
|
+
if (url.protocol !== 'file:' ||
|
|
208
|
+
url.hostname !== '' ||
|
|
209
|
+
url.username !== '' ||
|
|
210
|
+
url.password !== '' ||
|
|
211
|
+
url.port !== '' ||
|
|
212
|
+
url.search !== '' ||
|
|
213
|
+
url.hash !== '') {
|
|
214
|
+
throw invalidPrompt('prompt', 'unsupported_resource_uri');
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
return fileURLToPath(url);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
throw invalidPrompt('prompt', 'invalid_resource_uri');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function invalidPrompt(field, reason) {
|
|
224
|
+
return RequestError.invalidParams({ field, reason }, 'Invalid ACP prompt content');
|
|
225
|
+
}
|