@adecore/agents 0.0.1 → 0.17.0-beta.2
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 +110 -0
- package/README.md +48 -0
- package/dist/async.d.ts +2 -0
- package/dist/async.js +31 -0
- package/dist/chat/attachment-store.d.ts +10 -0
- package/dist/chat/attachment-store.js +93 -0
- package/dist/chat/backend.d.ts +214 -0
- package/dist/chat/backend.js +1 -0
- package/dist/chat/background-work.d.ts +8 -0
- package/dist/chat/background-work.js +33 -0
- package/dist/chat/bookmark-store.d.ts +25 -0
- package/dist/chat/bookmark-store.js +141 -0
- package/dist/chat/chat-core.d.ts +311 -0
- package/dist/chat/chat-core.js +1025 -0
- package/dist/chat/chat-log.d.ts +33 -0
- package/dist/chat/chat-log.js +163 -0
- package/dist/chat/chat-process.d.ts +46 -0
- package/dist/chat/chat-process.js +190 -0
- package/dist/chat/chat-session.d.ts +209 -0
- package/dist/chat/chat-session.js +1511 -0
- package/dist/chat/chat-store.d.ts +37 -0
- package/dist/chat/chat-store.js +202 -0
- package/dist/chat/chat-title.d.ts +10 -0
- package/dist/chat/chat-title.js +74 -0
- package/dist/chat/claude-backend.d.ts +35 -0
- package/dist/chat/claude-backend.js +214 -0
- package/dist/chat/claude-protocol.d.ts +41 -0
- package/dist/chat/claude-protocol.js +642 -0
- package/dist/chat/claude-title.d.ts +11 -0
- package/dist/chat/claude-title.js +97 -0
- package/dist/chat/claude-transcript.d.ts +28 -0
- package/dist/chat/claude-transcript.js +211 -0
- package/dist/chat/codex-backend.d.ts +51 -0
- package/dist/chat/codex-backend.js +364 -0
- package/dist/chat/codex-protocol.d.ts +56 -0
- package/dist/chat/codex-protocol.js +767 -0
- package/dist/chat/codex-thread.d.ts +32 -0
- package/dist/chat/codex-thread.js +131 -0
- package/dist/chat/codex-transport.d.ts +42 -0
- package/dist/chat/codex-transport.js +188 -0
- package/dist/chat/composer-preferences.d.ts +15 -0
- package/dist/chat/composer-preferences.js +46 -0
- package/dist/chat/context-breakdown.d.ts +2 -0
- package/dist/chat/context-breakdown.js +74 -0
- package/dist/chat/delta-coalescer.d.ts +12 -0
- package/dist/chat/delta-coalescer.js +55 -0
- package/dist/chat/errors.d.ts +4 -0
- package/dist/chat/errors.js +4 -0
- package/dist/chat/fake-claude.d.ts +3 -0
- package/dist/chat/fake-claude.js +982 -0
- package/dist/chat/fake-cli.d.ts +25 -0
- package/dist/chat/fake-cli.js +157 -0
- package/dist/chat/fake-codex.d.ts +10 -0
- package/dist/chat/fake-codex.js +502 -0
- package/dist/chat/fixtures/claude-2.1.285-auto-fallback.json +24 -0
- package/dist/chat/fixtures/claude-2.1.285-native-children.json +6600 -0
- package/dist/chat/fixtures/claude-2.1.285-resume-direct-compact.json +202 -0
- package/dist/chat/fixtures/claude-2.1.285-resume-task-notification.json +57 -0
- package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.jsonl +10 -0
- package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.meta.json +1 -0
- package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.jsonl +2 -0
- package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.meta.json +1 -0
- package/dist/chat/fixtures/codex-0.159.2-native-approval.json +119 -0
- package/dist/chat/fixtures/codex-0.159.2-native-file-approval.json +136 -0
- package/dist/chat/fixtures/codex-0.159.2-native-interacted.json +220 -0
- package/dist/chat/fixtures/codex-0.159.2-usage-windows.json +74 -0
- package/dist/chat/input.d.ts +19 -0
- package/dist/chat/input.js +71 -0
- package/dist/chat/limit-resume.d.ts +11 -0
- package/dist/chat/limit-resume.js +68 -0
- package/dist/chat/projector.d.ts +60 -0
- package/dist/chat/projector.js +860 -0
- package/dist/chat/request-summary.d.ts +3 -0
- package/dist/chat/request-summary.js +143 -0
- package/dist/chat/subagent-projection.d.ts +8 -0
- package/dist/chat/subagent-projection.js +40 -0
- package/dist/chat/subagent-reader.d.ts +66 -0
- package/dist/chat/subagent-reader.js +396 -0
- package/dist/chat/subagent-settlement.d.ts +6 -0
- package/dist/chat/subagent-settlement.js +103 -0
- package/dist/chat/thread.d.ts +30 -0
- package/dist/chat/thread.js +147 -0
- package/dist/chat/wake-chat.d.ts +20 -0
- package/dist/chat/wake-chat.js +27 -0
- package/dist/client-sinks.d.ts +9 -0
- package/dist/client-sinks.js +34 -0
- package/dist/coded-error.d.ts +5 -0
- package/dist/coded-error.js +17 -0
- package/dist/context/argv.d.ts +11 -0
- package/dist/context/argv.js +58 -0
- package/dist/context/refusal.d.ts +9 -0
- package/dist/context/refusal.js +38 -0
- package/dist/context/verb.d.ts +85 -0
- package/dist/context/verb.js +233 -0
- package/dist/error-text.d.ts +5 -0
- package/dist/error-text.js +24 -0
- package/dist/events.d.ts +12 -0
- package/dist/events.js +1 -0
- package/dist/fs.d.ts +9 -0
- package/dist/fs.js +107 -0
- package/dist/host/agent-host.d.ts +28 -0
- package/dist/host/agent-host.js +105 -0
- package/dist/host/environment.d.ts +7 -0
- package/dist/host/environment.js +22 -0
- package/dist/host/handlers.d.ts +30 -0
- package/dist/host/handlers.js +111 -0
- package/dist/host/memory-port.d.ts +2 -0
- package/dist/host/memory-port.js +25 -0
- package/dist/host/wiring.d.ts +40 -0
- package/dist/host/wiring.js +120 -0
- package/dist/lineage.d.ts +44 -0
- package/dist/lineage.js +134 -0
- package/dist/messages/deliver-message.d.ts +21 -0
- package/dist/messages/deliver-message.js +42 -0
- package/dist/messages/deliver-notice.d.ts +25 -0
- package/dist/messages/deliver-notice.js +75 -0
- package/dist/messages/notice-notes.d.ts +15 -0
- package/dist/messages/notice-notes.js +26 -0
- package/dist/messages/notice-store.d.ts +30 -0
- package/dist/messages/notice-store.js +120 -0
- package/dist/modes.d.ts +11 -0
- package/dist/modes.js +28 -0
- package/dist/outbox/manual-clock.d.ts +10 -0
- package/dist/outbox/manual-clock.js +25 -0
- package/dist/outbox/outbox-worker.d.ts +44 -0
- package/dist/outbox/outbox-worker.js +173 -0
- package/dist/outbox/outbox.d.ts +37 -0
- package/dist/outbox/outbox.js +76 -0
- package/dist/providers/accounts/accounts.d.ts +20 -0
- package/dist/providers/accounts/accounts.js +158 -0
- package/dist/providers/accounts/launch.d.ts +17 -0
- package/dist/providers/accounts/launch.js +30 -0
- package/dist/providers/accounts/service.d.ts +87 -0
- package/dist/providers/accounts/service.js +538 -0
- package/dist/providers/accounts/shadow-home.d.ts +8 -0
- package/dist/providers/accounts/shadow-home.js +70 -0
- package/dist/providers/accounts/status.d.ts +12 -0
- package/dist/providers/accounts/status.js +85 -0
- package/dist/providers/accounts/store.d.ts +14 -0
- package/dist/providers/accounts/store.js +112 -0
- package/dist/providers/accounts/test-accounts.d.ts +12 -0
- package/dist/providers/accounts/test-accounts.js +38 -0
- package/dist/providers/accounts/variables.d.ts +27 -0
- package/dist/providers/accounts/variables.js +94 -0
- package/dist/providers/catalog.d.ts +17 -0
- package/dist/providers/catalog.js +76 -0
- package/dist/providers/claude-models.json +114 -0
- package/dist/providers/claude-provider.d.ts +4 -0
- package/dist/providers/claude-provider.js +29 -0
- package/dist/providers/claude.d.ts +15 -0
- package/dist/providers/claude.js +105 -0
- package/dist/providers/codex-models.json +135 -0
- package/dist/providers/codex-provider.d.ts +4 -0
- package/dist/providers/codex-provider.js +27 -0
- package/dist/providers/codex-rules.d.ts +9 -0
- package/dist/providers/codex-rules.js +35 -0
- package/dist/providers/codex.d.ts +14 -0
- package/dist/providers/codex.js +52 -0
- package/dist/providers/detect.d.ts +6 -0
- package/dist/providers/detect.js +30 -0
- package/dist/providers/provider.d.ts +25 -0
- package/dist/providers/provider.js +1 -0
- package/dist/providers/registry.d.ts +28 -0
- package/dist/providers/registry.js +118 -0
- package/dist/record-directory.d.ts +27 -0
- package/dist/record-directory.js +114 -0
- package/dist/run-process.d.ts +13 -0
- package/dist/run-process.js +42 -0
- package/dist/serializer.d.ts +9 -0
- package/dist/serializer.js +34 -0
- package/dist/skills.d.ts +21 -0
- package/dist/skills.js +174 -0
- package/dist/tasks/background-limit.d.ts +16 -0
- package/dist/tasks/background-limit.js +55 -0
- package/dist/tasks/end-children.d.ts +34 -0
- package/dist/tasks/end-children.js +53 -0
- package/dist/tasks/give-task.d.ts +14 -0
- package/dist/tasks/give-task.js +33 -0
- package/dist/tasks/task-coordinator.d.ts +52 -0
- package/dist/tasks/task-coordinator.js +323 -0
- package/dist/tasks/task-store.d.ts +49 -0
- package/dist/tasks/task-store.js +197 -0
- package/dist/tasks/task-work.d.ts +47 -0
- package/dist/tasks/task-work.js +28 -0
- package/dist/tasks/waiting-child.d.ts +51 -0
- package/dist/tasks/waiting-child.js +143 -0
- package/dist/tasks/wake-parent.d.ts +19 -0
- package/dist/tasks/wake-parent.js +109 -0
- package/dist/tasks/wiring.d.ts +51 -0
- package/dist/tasks/wiring.js +151 -0
- package/dist/title-file.d.ts +2 -0
- package/dist/title-file.js +55 -0
- package/dist/usage/accounts.d.ts +15 -0
- package/dist/usage/accounts.js +64 -0
- package/dist/usage/aggregate.d.ts +12 -0
- package/dist/usage/aggregate.js +154 -0
- package/dist/usage/exchange.d.ts +16 -0
- package/dist/usage/exchange.js +84 -0
- package/dist/usage/index-file.d.ts +15 -0
- package/dist/usage/index-file.js +123 -0
- package/dist/usage/limits/monitor.d.ts +50 -0
- package/dist/usage/limits/monitor.js +179 -0
- package/dist/usage/limits/normalize.d.ts +21 -0
- package/dist/usage/limits/normalize.js +160 -0
- package/dist/usage/limits/probe.d.ts +9 -0
- package/dist/usage/limits/probe.js +113 -0
- package/dist/usage/prices-snapshot.json +1071 -0
- package/dist/usage/pricing.d.ts +34 -0
- package/dist/usage/pricing.js +186 -0
- package/dist/usage/projects.d.ts +17 -0
- package/dist/usage/projects.js +49 -0
- package/dist/usage/readers/claude.d.ts +3 -0
- package/dist/usage/readers/claude.js +59 -0
- package/dist/usage/readers/codex.d.ts +23 -0
- package/dist/usage/readers/codex.js +155 -0
- package/dist/usage/record.d.ts +15 -0
- package/dist/usage/record.js +39 -0
- package/dist/usage/roots.d.ts +12 -0
- package/dist/usage/roots.js +29 -0
- package/dist/usage/scanner.d.ts +30 -0
- package/dist/usage/scanner.js +234 -0
- package/dist/usage/usage-service.d.ts +35 -0
- package/dist/usage/usage-service.js +130 -0
- package/dist/watch-seam.d.ts +29 -0
- package/dist/watch-seam.js +78 -0
- package/dist/watch-test-helpers.d.ts +28 -0
- package/dist/watch-test-helpers.js +86 -0
- package/package.json +42 -3
- package/src/async.ts +40 -0
- package/src/chat/attachment-store.ts +108 -0
- package/src/chat/backend.ts +199 -0
- package/src/chat/background-work.ts +42 -0
- package/src/chat/bookmark-store.ts +166 -0
- package/src/chat/chat-core.ts +1228 -0
- package/src/chat/chat-log.ts +187 -0
- package/src/chat/chat-process.ts +237 -0
- package/src/chat/chat-session.ts +1723 -0
- package/src/chat/chat-store.ts +261 -0
- package/src/chat/chat-title.ts +90 -0
- package/src/chat/claude-backend.ts +235 -0
- package/src/chat/claude-protocol.ts +684 -0
- package/src/chat/claude-title.ts +106 -0
- package/src/chat/claude-transcript.ts +233 -0
- package/src/chat/codex-backend.ts +397 -0
- package/src/chat/codex-protocol.ts +872 -0
- package/src/chat/codex-thread.ts +162 -0
- package/src/chat/codex-transport.ts +224 -0
- package/src/chat/composer-preferences.ts +67 -0
- package/src/chat/context-breakdown.ts +80 -0
- package/src/chat/delta-coalescer.ts +62 -0
- package/src/chat/errors.ts +25 -0
- package/src/chat/fake-claude.ts +1006 -0
- package/src/chat/fake-cli.ts +199 -0
- package/src/chat/fake-codex.ts +534 -0
- package/src/chat/fixtures/claude-2.1.285-auto-fallback.json +24 -0
- package/src/chat/fixtures/claude-2.1.285-native-children.json +6600 -0
- package/src/chat/fixtures/claude-2.1.285-resume-direct-compact.json +202 -0
- package/src/chat/fixtures/claude-2.1.285-resume-task-notification.json +57 -0
- package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.jsonl +10 -0
- package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.meta.json +1 -0
- package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.jsonl +2 -0
- package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.meta.json +1 -0
- package/src/chat/fixtures/codex-0.159.2-native-approval.json +119 -0
- package/src/chat/fixtures/codex-0.159.2-native-file-approval.json +136 -0
- package/src/chat/fixtures/codex-0.159.2-native-interacted.json +220 -0
- package/src/chat/fixtures/codex-0.159.2-usage-windows.json +74 -0
- package/src/chat/input.ts +89 -0
- package/src/chat/limit-resume.ts +74 -0
- package/src/chat/projector.ts +969 -0
- package/src/chat/request-summary.ts +168 -0
- package/src/chat/subagent-projection.ts +45 -0
- package/src/chat/subagent-reader.ts +469 -0
- package/src/chat/subagent-settlement.ts +111 -0
- package/src/chat/thread.ts +167 -0
- package/src/chat/wake-chat.ts +45 -0
- package/src/client-sinks.ts +39 -0
- package/src/coded-error.ts +18 -0
- package/src/context/argv.ts +61 -0
- package/src/context/refusal.ts +50 -0
- package/src/context/verb.ts +392 -0
- package/src/error-text.ts +28 -0
- package/src/events.ts +9 -0
- package/src/fs.ts +118 -0
- package/src/host/agent-host.ts +124 -0
- package/src/host/environment.ts +31 -0
- package/src/host/handlers.ts +142 -0
- package/src/host/memory-port.ts +27 -0
- package/src/host/wiring.ts +164 -0
- package/src/lineage.ts +159 -0
- package/src/messages/deliver-message.ts +61 -0
- package/src/messages/deliver-notice.ts +120 -0
- package/src/messages/notice-notes.ts +34 -0
- package/src/messages/notice-store.ts +142 -0
- package/src/modes.ts +38 -0
- package/src/outbox/manual-clock.ts +31 -0
- package/src/outbox/outbox-worker.ts +214 -0
- package/src/outbox/outbox.ts +106 -0
- package/src/providers/accounts/accounts.ts +192 -0
- package/src/providers/accounts/launch.ts +55 -0
- package/src/providers/accounts/service.ts +632 -0
- package/src/providers/accounts/shadow-home.ts +85 -0
- package/src/providers/accounts/status.ts +106 -0
- package/src/providers/accounts/store.ts +158 -0
- package/src/providers/accounts/test-accounts.ts +48 -0
- package/src/providers/accounts/variables.ts +132 -0
- package/src/providers/catalog.ts +90 -0
- package/src/providers/claude-models.json +114 -0
- package/src/providers/claude-provider.ts +32 -0
- package/src/providers/claude.ts +123 -0
- package/src/providers/codex-models.json +135 -0
- package/src/providers/codex-provider.ts +30 -0
- package/src/providers/codex-rules.ts +54 -0
- package/src/providers/codex.ts +69 -0
- package/src/providers/detect.ts +40 -0
- package/src/providers/provider.ts +46 -0
- package/src/providers/registry.ts +150 -0
- package/src/record-directory.ts +136 -0
- package/src/run-process.ts +61 -0
- package/src/serializer.ts +41 -0
- package/src/skills.ts +199 -0
- package/src/tasks/background-limit.ts +72 -0
- package/src/tasks/end-children.ts +100 -0
- package/src/tasks/give-task.ts +52 -0
- package/src/tasks/task-coordinator.ts +384 -0
- package/src/tasks/task-store.ts +236 -0
- package/src/tasks/task-work.ts +62 -0
- package/src/tasks/waiting-child.ts +203 -0
- package/src/tasks/wake-parent.ts +142 -0
- package/src/tasks/wiring.ts +231 -0
- package/src/title-file.ts +57 -0
- package/src/usage/accounts.ts +86 -0
- package/src/usage/aggregate.ts +220 -0
- package/src/usage/exchange.ts +93 -0
- package/src/usage/index-file.ts +178 -0
- package/src/usage/limits/monitor.ts +239 -0
- package/src/usage/limits/normalize.ts +188 -0
- package/src/usage/limits/probe.ts +120 -0
- package/src/usage/prices-snapshot.json +1071 -0
- package/src/usage/pricing.ts +236 -0
- package/src/usage/projects.ts +65 -0
- package/src/usage/readers/claude.ts +60 -0
- package/src/usage/readers/codex.ts +196 -0
- package/src/usage/record.ts +60 -0
- package/src/usage/roots.ts +39 -0
- package/src/usage/scanner.ts +265 -0
- package/src/usage/usage-service.ts +161 -0
- package/src/watch-seam.ts +111 -0
- package/src/watch-test-helpers.ts +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 - present Bas Milius
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @adecore/agents
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@adecore/agents)
|
|
4
|
+
[](https://adecore.dev/agents/)
|
|
5
|
+
|
|
6
|
+
A host for agent chats in Node, Bun or an Electron utility process. It runs Claude Code and Codex as chat backends, keeps every thread on disk, streams it to its clients, and manages the CLIs' accounts and usage. It answers the requests of [`@adecore/agent-contracts`](https://adecore.dev/agent-contracts/) over a port you hand it, and registers no channel of its own.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
bun add @adecore/agents @adecore/agent-contracts
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The package brings no CLI: install Claude Code or Codex and sign in with it.
|
|
15
|
+
|
|
16
|
+
## Use
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { AgentHost } from '@adecore/agents/host/agent-host';
|
|
20
|
+
|
|
21
|
+
const host = await AgentHost.open({ dataDir });
|
|
22
|
+
const disconnect = host.connect(port);
|
|
23
|
+
|
|
24
|
+
// later
|
|
25
|
+
disconnect();
|
|
26
|
+
await host.close();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Every module has its own subpath, `@adecore/agents/<path>`; there is no root import. A new chat runs in `full-access` unless it names a runtime mode, so name one.
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
| Page | What it covers |
|
|
34
|
+
|---|---|
|
|
35
|
+
| [Getting started](https://adecore.dev/agents/getting-started) | A whole turn against a fake CLI, in one file |
|
|
36
|
+
| [Host](https://adecore.dev/agents/host) | `AgentHost`, its options, `wireAgents`, the hooks of `ChatCore` and Electron |
|
|
37
|
+
| [Chats and turns](https://adecore.dev/agents/chats) | Sending, queuing, approvals, stopping and restarts |
|
|
38
|
+
| [Providers](https://adecore.dev/agents/providers) | The CLIs, their model catalogs and the runtime modes |
|
|
39
|
+
| [Accounts and usage](https://adecore.dev/agents/accounts) | Config folders, secrets, the environment and usage |
|
|
40
|
+
| [Coordination](https://adecore.dev/agents/coordination) | The outbox, tasks between chats, lineage and messages |
|
|
41
|
+
| [Context commands](https://adecore.dev/agents/context-commands) | A command line your agents call back into |
|
|
42
|
+
| [Storage](https://adecore.dev/agents/storage) | What is written where, and the file helpers |
|
|
43
|
+
| [Testing](https://adecore.dev/agents/testing) | The fakes and the error codes |
|
|
44
|
+
| [Modules](https://adecore.dev/agents/reference) | Every subpath of the package |
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
FSL-1.1-MIT. See [LICENSE](./LICENSE).
|
package/dist/async.d.ts
ADDED
package/dist/async.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* The two waits the host does: a pause it can be woken from, and a deadline on somebody else's promise. */
|
|
2
|
+
/*
|
|
3
|
+
* Resolves after `ms`, or at once when the signal is raised. An abort ends the wait rather than
|
|
4
|
+
* failing it: every caller here is a loop that checks the signal itself on the next turn, and a
|
|
5
|
+
* rejection would only be caught and thrown away.
|
|
6
|
+
*/
|
|
7
|
+
export function wait(ms, signal) {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
const timer = setTimeout(resolve, ms);
|
|
10
|
+
signal?.addEventListener('abort', () => {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
resolve();
|
|
13
|
+
}, { once: true });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/*
|
|
17
|
+
* The promise, or `message` when it takes longer than `ms`. The timer is cleared either way, so a
|
|
18
|
+
* call that answers at once does not hold the process for the rest of its deadline.
|
|
19
|
+
*/
|
|
20
|
+
export function withTimeout(promise, ms, message) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const timer = setTimeout(() => reject(new Error(message)), ms);
|
|
23
|
+
promise.then((value) => {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
resolve(value);
|
|
26
|
+
}, (e) => {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ChatAttachment, type ChatAttachmentUpload } from '@adecore/agent-contracts';
|
|
2
|
+
export declare function extensionFor(name: string, mime: string): string;
|
|
3
|
+
export declare class AttachmentStore {
|
|
4
|
+
readonly dir: string;
|
|
5
|
+
constructor(home: string);
|
|
6
|
+
save(chatId: string, upload: ChatAttachmentUpload): Promise<ChatAttachment>;
|
|
7
|
+
removeAll(chatId: string): Promise<void>;
|
|
8
|
+
private folder;
|
|
9
|
+
}
|
|
10
|
+
export declare function migrateInlineAttachments(chatId: string, record: unknown, store: AttachmentStore): Promise<unknown | null>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { extname, join } from 'node:path';
|
|
4
|
+
import { attachmentImageMime } from '@adecore/agent-contracts';
|
|
5
|
+
// The extension the file gets on disk when its name does not carry a usable one.
|
|
6
|
+
const EXTENSIONS = {
|
|
7
|
+
'image/png': 'png',
|
|
8
|
+
'image/jpeg': 'jpg',
|
|
9
|
+
'image/gif': 'gif',
|
|
10
|
+
'image/webp': 'webp',
|
|
11
|
+
'image/svg+xml': 'svg',
|
|
12
|
+
'application/pdf': 'pdf',
|
|
13
|
+
'application/json': 'json',
|
|
14
|
+
'text/csv': 'csv',
|
|
15
|
+
'text/markdown': 'md',
|
|
16
|
+
'text/plain': 'txt'
|
|
17
|
+
};
|
|
18
|
+
const SAFE_EXTENSION = /^[A-Za-z0-9]{1,8}$/;
|
|
19
|
+
/* What the file is called on disk: the id, plus an extension the agent's tools can recognize. */
|
|
20
|
+
export function extensionFor(name, mime) {
|
|
21
|
+
const own = extname(name).slice(1).toLowerCase();
|
|
22
|
+
if (SAFE_EXTENSION.test(own)) {
|
|
23
|
+
return own;
|
|
24
|
+
}
|
|
25
|
+
const known = EXTENSIONS[mime.toLowerCase()];
|
|
26
|
+
if (known) {
|
|
27
|
+
return known;
|
|
28
|
+
}
|
|
29
|
+
const subtype = mime.split('/')[1]?.replace(/\+.*$/, '') ?? '';
|
|
30
|
+
return SAFE_EXTENSION.test(subtype) ? subtype.toLowerCase() : 'bin';
|
|
31
|
+
}
|
|
32
|
+
/*
|
|
33
|
+
* The files people attach to a message, under `<home>/attachments/<chatId>`. The thread keeps
|
|
34
|
+
* only what a row needs (name, mime, size, path); the bytes stay on disk, so a thread with a video
|
|
35
|
+
* in it is still a small JSON file.
|
|
36
|
+
*/
|
|
37
|
+
export class AttachmentStore {
|
|
38
|
+
dir;
|
|
39
|
+
constructor(home) {
|
|
40
|
+
this.dir = join(home, 'attachments');
|
|
41
|
+
}
|
|
42
|
+
/* Writes one upload and answers the metadata the thread stores. */
|
|
43
|
+
async save(chatId, upload) {
|
|
44
|
+
const bytes = Buffer.from(upload.data, 'base64');
|
|
45
|
+
const mime = attachmentImageMime(upload) ?? upload.mime;
|
|
46
|
+
const id = randomBytes(8).toString('hex');
|
|
47
|
+
const folder = this.folder(chatId);
|
|
48
|
+
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
49
|
+
const path = join(folder, `${id}.${extensionFor(upload.name, mime)}`);
|
|
50
|
+
await writeFile(path, bytes, { mode: 0o600 });
|
|
51
|
+
return { id, name: upload.name, mime, size: bytes.byteLength, path };
|
|
52
|
+
}
|
|
53
|
+
/* Everything a chat attached; used when the chat itself is deleted. */
|
|
54
|
+
async removeAll(chatId) {
|
|
55
|
+
await rm(this.folder(chatId), { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
folder(chatId) {
|
|
58
|
+
return join(this.dir, encodeURIComponent(chatId));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function isRecord(value) {
|
|
62
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
63
|
+
}
|
|
64
|
+
// What an attachment looked like before the files moved out of the thread: the bytes inline.
|
|
65
|
+
function isInline(value) {
|
|
66
|
+
return isRecord(value) && typeof value.name === 'string' && typeof value.mediaType === 'string' && typeof value.data === 'string';
|
|
67
|
+
}
|
|
68
|
+
/*
|
|
69
|
+
* Writes out the images a thread still carries inline and answers the record with metadata in their
|
|
70
|
+
* place, or null when there was nothing to do. Old records are migrated on the read that opens the
|
|
71
|
+
* chat, before the schema sees them, because the schema no longer knows the inline shape.
|
|
72
|
+
*/
|
|
73
|
+
export async function migrateInlineAttachments(chatId, record, store) {
|
|
74
|
+
const items = isRecord(record) && Array.isArray(record.items) ? record.items : null;
|
|
75
|
+
if (!items) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
let migrated = false;
|
|
79
|
+
const next = await Promise.all(items.map(async (item) => {
|
|
80
|
+
if (!isRecord(item) || !Array.isArray(item.attachments) || !item.attachments.some(isInline)) {
|
|
81
|
+
return item;
|
|
82
|
+
}
|
|
83
|
+
const attachments = await Promise.all(item.attachments.map(async (attachment) => {
|
|
84
|
+
if (!isInline(attachment)) {
|
|
85
|
+
return attachment;
|
|
86
|
+
}
|
|
87
|
+
migrated = true;
|
|
88
|
+
return await store.save(chatId, { name: attachment.name, mime: attachment.mediaType, data: attachment.data });
|
|
89
|
+
}));
|
|
90
|
+
return { ...item, attachments };
|
|
91
|
+
}));
|
|
92
|
+
return migrated ? { ...record, items: next } : null;
|
|
93
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import type { ChatAttachment, ChatFileChange, ChatQuestion, ChatSkill, ChatSubagentUsage, ChatTurnLimit, ChatWorkflow, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
|
|
2
|
+
import type { LimitsUpdate } from '../usage/limits/normalize.ts';
|
|
3
|
+
import type { SpawnChatProcess } from './chat-process.ts';
|
|
4
|
+
export interface BackendLaunch {
|
|
5
|
+
command: string[];
|
|
6
|
+
cwd: string;
|
|
7
|
+
env: Record<string, string>;
|
|
8
|
+
selection: ModelSelection;
|
|
9
|
+
modelName: string;
|
|
10
|
+
runtimeMode: RuntimeMode;
|
|
11
|
+
resume: string | null;
|
|
12
|
+
generation: number;
|
|
13
|
+
instructions: string | null;
|
|
14
|
+
resumeNote: string | null;
|
|
15
|
+
folders?: readonly string[];
|
|
16
|
+
spawn?: SpawnChatProcess;
|
|
17
|
+
}
|
|
18
|
+
export interface TurnInput {
|
|
19
|
+
promptId?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
preamble: string | null;
|
|
22
|
+
attachments: ChatAttachment[];
|
|
23
|
+
mentions: string[];
|
|
24
|
+
skills: string[];
|
|
25
|
+
}
|
|
26
|
+
export type ApprovalDecision = 'allow' | 'allow-always' | 'deny';
|
|
27
|
+
export type BackendEvent = {
|
|
28
|
+
type: 'turn.accepted';
|
|
29
|
+
promptId: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'session';
|
|
32
|
+
agentSessionId: string | null;
|
|
33
|
+
model: string | null;
|
|
34
|
+
slashCommands?: string[];
|
|
35
|
+
skills?: string[];
|
|
36
|
+
title?: string | null;
|
|
37
|
+
effectiveRuntimeMode?: RuntimeMode;
|
|
38
|
+
permissionMode?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'title';
|
|
41
|
+
title: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'permissions';
|
|
44
|
+
permissionMode: string;
|
|
45
|
+
effectiveRuntimeMode?: RuntimeMode;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'text.delta';
|
|
48
|
+
ref: string;
|
|
49
|
+
text: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'text.done';
|
|
52
|
+
ref: string;
|
|
53
|
+
text: string;
|
|
54
|
+
parentRef?: string | null;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'thinking.delta';
|
|
57
|
+
ref: string;
|
|
58
|
+
text: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'thinking.done';
|
|
61
|
+
ref: string;
|
|
62
|
+
text: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'tool.started';
|
|
65
|
+
ref: string;
|
|
66
|
+
name: string;
|
|
67
|
+
input: unknown;
|
|
68
|
+
parentRef: string | null;
|
|
69
|
+
changes?: ChatFileChange[];
|
|
70
|
+
} | {
|
|
71
|
+
type: 'tool.progress';
|
|
72
|
+
ref: string;
|
|
73
|
+
startedAt: number | null;
|
|
74
|
+
description: string | null;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'tool.output';
|
|
77
|
+
ref: string;
|
|
78
|
+
text: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'tool.done';
|
|
81
|
+
ref: string;
|
|
82
|
+
output: string | null;
|
|
83
|
+
state: 'done' | 'error';
|
|
84
|
+
changes?: ChatFileChange[];
|
|
85
|
+
} | {
|
|
86
|
+
type: 'approval.requested';
|
|
87
|
+
requestId: string;
|
|
88
|
+
ref: string | null;
|
|
89
|
+
toolName: string;
|
|
90
|
+
input: unknown;
|
|
91
|
+
description: string | null;
|
|
92
|
+
canAllowAlways: boolean;
|
|
93
|
+
background?: boolean;
|
|
94
|
+
allowAlways?: {
|
|
95
|
+
label: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
type: 'question.requested';
|
|
100
|
+
requestId: string;
|
|
101
|
+
questions: ChatQuestion[];
|
|
102
|
+
async?: boolean;
|
|
103
|
+
background?: boolean;
|
|
104
|
+
} | {
|
|
105
|
+
type: 'request.withdrawn';
|
|
106
|
+
requestId: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: 'task.started';
|
|
109
|
+
ref: string;
|
|
110
|
+
description: string | null;
|
|
111
|
+
subagentType: string | null;
|
|
112
|
+
prompt: string | null;
|
|
113
|
+
background: boolean;
|
|
114
|
+
taskId?: string | null;
|
|
115
|
+
threadId?: string | null;
|
|
116
|
+
depth?: number;
|
|
117
|
+
resumed?: boolean;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'task.progress';
|
|
120
|
+
ref: string;
|
|
121
|
+
taskId?: string | null;
|
|
122
|
+
summary: string | null;
|
|
123
|
+
lastTool: string | null;
|
|
124
|
+
usage: ChatSubagentUsage | null;
|
|
125
|
+
} | {
|
|
126
|
+
type: 'task.model';
|
|
127
|
+
ref: string;
|
|
128
|
+
model: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'task.done';
|
|
131
|
+
ref: string | null;
|
|
132
|
+
taskId?: string | null;
|
|
133
|
+
summary: string | null;
|
|
134
|
+
ok: boolean;
|
|
135
|
+
usage?: ChatSubagentUsage | null;
|
|
136
|
+
outputFile?: string | null;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'workflow.progress';
|
|
139
|
+
ref: string;
|
|
140
|
+
workflow: ChatWorkflow;
|
|
141
|
+
} | {
|
|
142
|
+
type: 'background.started';
|
|
143
|
+
taskId: string;
|
|
144
|
+
ref: string | null;
|
|
145
|
+
monitor: boolean;
|
|
146
|
+
description: string | null;
|
|
147
|
+
} | {
|
|
148
|
+
type: 'background.ended';
|
|
149
|
+
taskId: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: 'usage';
|
|
152
|
+
contextTokens?: number;
|
|
153
|
+
contextWindow?: number;
|
|
154
|
+
costUsd?: number;
|
|
155
|
+
} | {
|
|
156
|
+
type: 'limits';
|
|
157
|
+
update: LimitsUpdate;
|
|
158
|
+
} | {
|
|
159
|
+
type: 'compaction';
|
|
160
|
+
preTokens: number | null;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'model';
|
|
163
|
+
model: string;
|
|
164
|
+
} | {
|
|
165
|
+
type: 'note';
|
|
166
|
+
level: 'info' | 'warning' | 'error';
|
|
167
|
+
text: string;
|
|
168
|
+
} | {
|
|
169
|
+
type: 'turn.done';
|
|
170
|
+
promptId?: string;
|
|
171
|
+
state: 'done' | 'aborted' | 'error';
|
|
172
|
+
costUsd: number;
|
|
173
|
+
error?: string;
|
|
174
|
+
native?: {
|
|
175
|
+
turnId?: string;
|
|
176
|
+
lastUuid?: string;
|
|
177
|
+
};
|
|
178
|
+
limit?: ChatTurnLimit;
|
|
179
|
+
} | {
|
|
180
|
+
type: 'failed';
|
|
181
|
+
message: string;
|
|
182
|
+
processAlive?: boolean;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'exit';
|
|
185
|
+
exitCode: number | null;
|
|
186
|
+
stderr?: string;
|
|
187
|
+
};
|
|
188
|
+
export interface BackendHost {
|
|
189
|
+
onEvent(event: BackendEvent): void;
|
|
190
|
+
}
|
|
191
|
+
export interface ChatBackend {
|
|
192
|
+
readonly acknowledgesTurns?: boolean;
|
|
193
|
+
readonly running: boolean;
|
|
194
|
+
readonly pid: number | null;
|
|
195
|
+
start(): Promise<void>;
|
|
196
|
+
sendTurn(input: TurnInput): void;
|
|
197
|
+
compact(): void;
|
|
198
|
+
interrupt(): void;
|
|
199
|
+
respondApproval(requestId: string, decision: ApprovalDecision, message?: string): boolean;
|
|
200
|
+
respondQuestion(requestId: string, answers: Record<string, string>): boolean;
|
|
201
|
+
stopTask?(taskId: string): void;
|
|
202
|
+
declineRequest?(requestId: string, message: string): boolean;
|
|
203
|
+
dismissRequest?(requestId: string): boolean;
|
|
204
|
+
setTitle?(title: string): void;
|
|
205
|
+
listSkills?(): Promise<ChatSkill[]>;
|
|
206
|
+
listThreadItems?(params: {
|
|
207
|
+
threadId: string;
|
|
208
|
+
cursor?: string;
|
|
209
|
+
limit: number;
|
|
210
|
+
sortDirection: 'asc' | 'desc';
|
|
211
|
+
}): Promise<unknown>;
|
|
212
|
+
stop(): void;
|
|
213
|
+
dispose(): Promise<void>;
|
|
214
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AgentKind, ChatBackgroundTask, ChatItem, ChatSubagentItem, ChatToolItem } from '@adecore/agent-contracts';
|
|
2
|
+
export type BackgroundWork = ChatSubagentItem | ChatToolItem;
|
|
3
|
+
export declare function isBackgroundWork(item: ChatItem): item is BackgroundWork;
|
|
4
|
+
export declare function runsInBackground(item: BackgroundWork): boolean;
|
|
5
|
+
export declare function runningInBackground(items: readonly ChatItem[]): BackgroundWork[];
|
|
6
|
+
export declare const BACKGROUND_COMMAND_LIMIT_MS: number;
|
|
7
|
+
export declare function commandLabel(task: ChatBackgroundTask): string;
|
|
8
|
+
export declare function reportsOnBackgroundWork(provider: AgentKind): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Work a chat's CLI goes on with after the turn that started it ended: a subagent it runs in the
|
|
3
|
+
* background (Claude's `run_in_background`, every agent Codex spawns) and a Claude workflow, whose call
|
|
4
|
+
* answers at launch. A command or a monitor sent to the background is not work of this kind but a
|
|
5
|
+
* `ChatBackgroundTask` in the chat's info, held to `BACKGROUND_COMMAND_LIMIT_MS`; a row the host drew for
|
|
6
|
+
* work it delegated itself (origin `ruimte` on the wire) is that work's own.
|
|
7
|
+
*/
|
|
8
|
+
export function isBackgroundWork(item) {
|
|
9
|
+
return (item.kind === 'subagent' && item.background && item.origin !== 'ruimte') || (item.kind === 'tool' && item.name === 'Workflow');
|
|
10
|
+
}
|
|
11
|
+
export function runsInBackground(item) {
|
|
12
|
+
return item.kind === 'subagent' ? item.status === 'running' : item.state === 'running';
|
|
13
|
+
}
|
|
14
|
+
export function runningInBackground(items) {
|
|
15
|
+
return items.filter((item) => isBackgroundWork(item) && runsInBackground(item));
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* How long a command or a monitor still running in the background holds a child's task once nothing
|
|
19
|
+
* else does, since a dev server never ends. Subagents and workflows have no such limit.
|
|
20
|
+
*/
|
|
21
|
+
export const BACKGROUND_COMMAND_LIMIT_MS = 30 * 60_000;
|
|
22
|
+
export function commandLabel(task) {
|
|
23
|
+
return task.command ?? (task.description === '' ? task.id : task.description);
|
|
24
|
+
}
|
|
25
|
+
/*
|
|
26
|
+
* Whether the CLI opens a turn of its own once its background work ended, to tell what came of it.
|
|
27
|
+
* Claude Code 2.1.282 does after every task notification, a command's included; a command a subagent
|
|
28
|
+
* started first takes that subagent up again, which then notifies the main agent. Codex 0.156.1
|
|
29
|
+
* reports a spawned agent completed and opens nothing.
|
|
30
|
+
*/
|
|
31
|
+
export function reportsOnBackgroundWork(provider) {
|
|
32
|
+
return provider === 'claude';
|
|
33
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ChatBookmark } from '@adecore/agent-contracts';
|
|
2
|
+
export declare function bookmarkFileName(chatId: string): string;
|
|
3
|
+
export declare function isBookmarkFileName(name: string): boolean;
|
|
4
|
+
export type BookmarkListener = (chatId: string, bookmarks: ChatBookmark[]) => void;
|
|
5
|
+
export declare class BookmarkStore {
|
|
6
|
+
readonly dir: string;
|
|
7
|
+
private readonly writes;
|
|
8
|
+
private readonly listeners;
|
|
9
|
+
constructor(home: string);
|
|
10
|
+
listen(listener: BookmarkListener): () => void;
|
|
11
|
+
read(chatId: string): Promise<ChatBookmark[]>;
|
|
12
|
+
add(chatId: string, input: {
|
|
13
|
+
itemId: string;
|
|
14
|
+
excerpt: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
}, now: number): Promise<ChatBookmark[]>;
|
|
17
|
+
rename(chatId: string, itemId: string, name: string): Promise<ChatBookmark[]>;
|
|
18
|
+
remove(chatId: string, itemId: string): Promise<ChatBookmark[]>;
|
|
19
|
+
removeChat(chatId: string): Promise<void>;
|
|
20
|
+
copyChat(fromChatId: string, toChatId: string, keep: (itemId: string) => boolean): Promise<void>;
|
|
21
|
+
private change;
|
|
22
|
+
private tell;
|
|
23
|
+
private readFile;
|
|
24
|
+
private writeFile;
|
|
25
|
+
}
|