@1agents/acp-service 0.5.4 → 0.7.0

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.
Files changed (40) hide show
  1. package/README.md +180 -9
  2. package/dist/bin/a2a.d.ts +1 -0
  3. package/dist/bin/a2a.js +52 -0
  4. package/dist/bin/acp-service.js +20 -2
  5. package/dist/src/a2a/automation.d.ts +99 -0
  6. package/dist/src/a2a/automation.js +372 -0
  7. package/dist/src/a2a/executor.d.ts +29 -0
  8. package/dist/src/a2a/executor.js +144 -0
  9. package/dist/src/a2a/gateway.d.ts +151 -0
  10. package/dist/src/a2a/gateway.js +454 -0
  11. package/dist/src/a2a/index.d.ts +9 -0
  12. package/dist/src/a2a/index.js +5 -0
  13. package/dist/src/a2a/server.d.ts +22 -0
  14. package/dist/src/a2a/server.js +339 -0
  15. package/dist/src/a2a/store.d.ts +34 -0
  16. package/dist/src/a2a/store.js +468 -0
  17. package/dist/src/a2a/types.d.ts +26 -0
  18. package/dist/src/a2a/types.js +1 -0
  19. package/dist/src/acp-connection.js +3 -2
  20. package/dist/src/bridge.js +18 -3
  21. package/package.json +15 -8
  22. package/skills/acp-service/SKILL.md +90 -0
  23. package/skills/acp-service/agents/openai.yaml +3 -0
  24. package/skills/acp-service/references/a2a.md +183 -0
  25. package/skills/acp-service/references/acp.md +104 -0
  26. package/skills/acp-service/references/dsh.md +61 -0
  27. package/vendor/dsh/README.md +34 -10
  28. package/vendor/dsh/a2a-executor.d.ts +26 -0
  29. package/vendor/dsh/a2a-executor.js +195 -0
  30. package/vendor/dsh/a2a.d.ts +15 -0
  31. package/vendor/dsh/a2a.js +32 -0
  32. package/vendor/dsh/adapter.js +33 -10
  33. package/vendor/dsh/index.d.ts +5 -1
  34. package/vendor/dsh/index.js +3 -0
  35. package/vendor/runtime/dist/docs-site/output-formats.html +4 -1
  36. package/vendor/runtime/dist/runtime.d.ts +8 -0
  37. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  38. package/vendor/runtime/dist/runtime.js +3 -1
  39. package/vendor/runtime/dist/runtime.js.map +1 -1
  40. package/vendor/runtime/skills/acpx/SKILL.md +1 -0
package/README.md CHANGED
@@ -1,10 +1,64 @@
1
1
  # @1agents/acp-service
2
2
 
3
- ACP Agent Runtime Service for Codex, Grok Build, Claude Code and other Agents supported by its embedded 1ACP runtime. Version 0.2 uses **ACP v1 JSON-RPC 2.0 over WebSocket**. Each connection selects one Agent; each session keeps that Agent and its workspace when reconnected.
3
+ Run persistent Codex, Claude Code, Grok Build and other supported native Agent sessions in DeepSeek Harness (DSH), or use the same package as a standalone CLI and ACP service. DSH exposes the Agent's native models, settings, commands and permission requests; each session keeps its Agent and workspace when reconnected.
4
4
 
5
- ## Run
5
+ ## Install in DSH
6
6
 
7
- Requires Node.js 22.13 or later. Version 0.5 includes the 1ACP runtime, CLI, service, DSH plugin, browser controls, skills and licenses; installing a separate `@scottzx/1acp` package is unnecessary. The runtime and service retain their respective ACP SDK versions.
7
+ Requires **Node.js 22.13+**, DSH, and the selected native Agent's CLI and credentials on the DSH host. Adapter-backed Agents also require their ACP adapter; the native Codex CLI alone does not provide `codex-acp`.
8
+
9
+ ```sh
10
+ dsh plugin --profile web add @1agents/acp-service@^0.7.0
11
+ ```
12
+
13
+ Restart DSH and check that **`@1agents/acp-service`** is enabled on the Plugins page. Create a session with a discovered **ACP · Agent** preset, choose an existing workspace, then send a text prompt. The plugin starts or reuses its local service automatically. Use your own profile name in place of `web`; from a DSH source checkout, replace `dsh` with `pnpm dsh`.
14
+
15
+ If pnpm reports an ignored transitive `esbuild` build script, follow the package manager's prompt or set that individual package's approval in the profile, then repeat the install. Approve or deny the script according to your policy, and check the bundle's enabled state after a partial install.
16
+
17
+ The pinned [GitHub Release tarball](https://github.com/scottzx/1acp/releases/tag/acp-service-v0.6.0) contains the same published npm artifact:
18
+
19
+ ```sh
20
+ dsh plugin --profile web add https://github.com/scottzx/1acp/releases/download/acp-service-v0.6.0/1agents-acp-service-0.6.0.tgz
21
+ ```
22
+
23
+ `@1agents/session-reader` is optional: install it separately to browse and continue existing Claude, Codex and Grok histories. For presets, native controls, configuration and migration, see the [DSH user guide](https://github.com/scottzx/1acp/blob/main/packages/dsh-plugin/README.md).
24
+
25
+ The CI baseline is **DSH 0.1.7-rc.2**, commit `21638c56315ae6a2b552d6091945d3144c9af32e`. Additional isolated-profile verification used a locally modified DSH tree labeled `0.2.0-rc.1`. The [verification record](https://github.com/scottzx/1acp/blob/main/docs/marketplaces/verification-2026-10-09.md) describes the installed-package, Loader, browser and lifecycle checks and their limits.
26
+
27
+ ### Screenshots
28
+
29
+ ![Discovered ACP Agent presets in DSH](https://raw.githubusercontent.com/scottzx/1acp/main/packages/service/assets/dsh-agent-presets.png)
30
+
31
+ ![Native Codex model and ACP controls](https://raw.githubusercontent.com/scottzx/1acp/main/packages/service/assets/dsh-codex-controls.png)
32
+
33
+ These unmodified screenshots show discovery and native capability loading in that fresh isolated local profile. No model prompt was sent for the UI check. Controls depend on the selected Agent, adapter and account.
34
+
35
+ ## Standalone CLI and service
36
+
37
+ ```sh
38
+ npm install -g @1agents/acp-service@^0.7.0
39
+ acp-service --help
40
+ acp-service serve --host 127.0.0.1 --port 36812 --no-report
41
+ ```
42
+
43
+ The service uses **ACP v1 JSON-RPC 2.0 over WebSocket**. DSH is unnecessary for the standalone entry points. A2A delegation is opt-in and disabled by default; its configuration is documented below. Waking a calling system's main Agent after task completion requires that system's receiving host adapter.
44
+
45
+ ## Bundled usage skill
46
+
47
+ [ACP Service skill](skills/acp-service/SKILL.md) is distributed in this npm package and maintained with the source. It covers entry-point selection, ACP CLI/WebSocket sessions, DSH presets and native model controls, A2A delegation, task queries and the durable completion inbox. Detailed examples are included in its `references/` directory.
48
+
49
+ ```sh
50
+ acp-service --skill list
51
+ acp-service --skill show acp-service
52
+ acp-service --skill export acp-service > acp-service-skill.tar
53
+ # Install the complete skill in the current project when wanted:
54
+ acp-service --skill install acp-service --agent codex --scope repo
55
+ ```
56
+
57
+ The existing embedded `acpx` runtime skill remains available. The skill and its references can also be read directly from `skills/acp-service/` after installing version 0.6.0 or later.
58
+
59
+ ## Service development and API
60
+
61
+ Version 0.6.0 includes the 1ACP runtime, CLI, service, DSH plugin, browser controls, skills and licenses. The runtime and service retain their respective ACP SDK versions.
8
62
 
9
63
  The runtime's per-session launch argv and transient credentials APIs support Provider Profiles. Public runtime APIs and flow authoring are available as `@1agents/acp-service/runtime` and `@1agents/acp-service/flows`. The `acp-service` command forwards runtime commands alongside its `serve` command.
10
64
 
@@ -37,17 +91,86 @@ HTTP endpoints:
37
91
  - `GET /manifest`: DreamMate service discovery, ACP version, custom transport and Agent endpoint paths. Profiles listed here describe registered launch configurations, not a successful installation/authentication probe.
38
92
  - `GET /services`: current service/session counts.
39
93
 
40
- ## DSH installation
94
+ ## DSH package entry points
41
95
 
42
- The same npm package can be installed as a DSH bundle:
96
+ DSH reads the package's bundle patch and browser metadata; the CLI uses its `bin` entry. There is no installation-time mode switch, and both uses can coexist. The package root retains the service API and exposes Cordis metadata plus a lazy `apply`; merely importing it starts no plugin or process. `/service` is the service API, while `/dsh`, `/dsh/preset` and `/dsh/imports` provide the typed plugin interfaces. DSH host dependencies are supplied by DSH rather than installed with the CLI.
43
97
 
44
- ```sh
45
- pnpm dsh plugin --profile web add @1agents/acp-service
98
+ The plugin starts or reuses a local service when activated. See [DSH plugin usage](https://github.com/scottzx/1acp/blob/main/packages/dsh-plugin/README.md) for presets, browser controls, configuration and lifecycle. Before migrating, stop DSH and remove `@1agents/dsh-acp`, then add the unified package; keep session bindings and preserve custom row configuration. Plugin and preset IDs are unchanged.
99
+
100
+ ## DSH A2A
101
+
102
+ The DSH plugin can expose an **A2A 1.0 JSON-RPC** agent using `@a2a-js/sdk@1.3.0`. The shared implementation is exported from `@1agents/acp-service/a2a`; it accepts an `A2ABackend` and starts no listener itself. This release mounts it on DSH's web server. The standalone `acp-service serve` command continues to expose ACP.
103
+
104
+ A2A is enabled by adding `a2a` to the existing `oneagents-acp` row's configuration. Set `DSH_A2A_TOKEN` in the DSH host's environment before startup, then restart DSH:
105
+
106
+ ```yaml
107
+ config:
108
+ serviceMode: auto
109
+ serviceUrl: http://127.0.0.1:36812
110
+ a2a:
111
+ enabled: true
112
+ publicUrl: http://100.125.201.118:3080
113
+ defaultCwd: /home/scott/projects
114
+ defaultAgentPreset: oneagents-acp-codex
115
+ workspaces:
116
+ demo: /home/scott/projects/demo
117
+ pushNotificationOrigins:
118
+ - http://100.100.100.100:9000
46
119
  ```
47
120
 
48
- DSH reads the package's bundle patch and browser metadata; the CLI uses its `bin` entry. There is no installation-time mode switch, and both uses can coexist. The package root retains the service API and exposes Cordis metadata plus a lazy `apply`; merely importing it starts no plugin or process. `/service` is the service API, while `/dsh`, `/dsh/preset` and `/dsh/imports` provide the typed plugin interfaces. DSH host dependencies are supplied by DSH rather than installed with the CLI.
121
+ The example URLs and directories must match your execution host and notification receiver. `publicUrl` is the externally reachable DSH origin. `tokenEnv` can select a different environment variable; `token` can be configured directly. A missing bearer token rejects activation. Omitting `a2a`, or setting `enabled: false`, leaves A2A disabled. DSH's UI login credential does not authenticate A2A calls.
49
122
 
50
- The plugin starts or reuses a local service when activated. See [DSH plugin usage](vendor/dsh/README.md) for presets, browser controls, configuration and lifecycle. Before migrating, stop DSH and remove `@1agents/dsh-acp`, then add the unified package; keep session bindings and preserve custom row configuration. Plugin and preset IDs are unchanged.
123
+ `GET /.well-known/agent-card.json` provides public discovery. Authenticated clients POST to `/a2a` with `Authorization: Bearer ...`, `A2A-Version: 1.0` and an A2A JSON request. `path` can change the JSON-RPC route. Only protocol 1.0 is advertised; v0.3 requests receive a version error.
124
+
125
+ Submit a text task and return after its DSH session has been created or restored, without waiting for the turn:
126
+
127
+ ```json
128
+ {
129
+ "jsonrpc": "2.0",
130
+ "id": "submit-1",
131
+ "method": "SendMessage",
132
+ "params": {
133
+ "message": {
134
+ "messageId": "message-001",
135
+ "role": "ROLE_USER",
136
+ "parts": [{ "text": "检查这个项目的测试失败原因", "mediaType": "text/plain" }]
137
+ },
138
+ "configuration": { "returnImmediately": true },
139
+ "metadata": { "1agents": { "workspace": "demo", "agentPreset": "oneagents-acp-codex" } }
140
+ }
141
+ }
142
+ ```
143
+
144
+ The standard response contains `result.task.id`, `result.task.contextId` and `result.task.metadata["1agents"]` with `sessionId`, canonical `cwd` and resolved `agentPreset`. Task IDs and DSH session IDs are distinct. Session preparation failures return a failed Task. The default `returnImmediately: false` waits for a terminal or input-required state.
145
+
146
+ Use `metadata["1agents"].cwd` for an absolute existing directory **on the DSH host**, or `workspace` for a configured alias. Supplying both is rejected. Omit location and preset to use host defaults, allowing a fixed-role agent to accept tasks without a project selector. A new context creates a new DSH session; the same directory alone never selects an old session. Retain `message.contextId` for later tasks in that session; cwd and preset cannot change within a saved context. A completed Task cannot be reopened. A Task requiring input can be continued with its `taskId` and a new `messageId`. Active Task follow-up messages are rejected; independent tasks in the same context queue as separate DSH turns.
147
+
148
+ | Method | Behavior |
149
+ | --- | --- |
150
+ | `GetTask`, params `{ "id": "task-id" }` | Current persisted status, history and artifacts. |
151
+ | `ListTasks` | Scoped filtering, pagination and history selection. |
152
+ | `SubscribeToTask`, params `{ "id": "task-id" }` | SSE beginning with the current Task, followed by status/artifact updates. Terminal tasks are queried instead. |
153
+ | `SendStreamingMessage` | Submit and observe through SSE; execution and persistence continue after disconnect. |
154
+ | `CancelTask`, params `{ "id": "task-id" }` | Remove this task's queued prompt or cancel its claimed DSH turn. Other queued prompts remain. |
155
+ | `Create/Get/List/DeleteTaskPushNotificationConfig(s)` | Standard webhook configuration lifecycle. The List method is `ListTaskPushNotificationConfigs`; the other three use the singular form. |
156
+
157
+ For completion notifications, add a receiver whose origin appears in `pushNotificationOrigins`, then include a standard v1 configuration in the send request:
158
+
159
+ ```json
160
+ {
161
+ "returnImmediately": true,
162
+ "taskPushNotificationConfig": {
163
+ "url": "http://100.100.100.100:9000/a2a-events",
164
+ "authentication": { "scheme": "Bearer", "credentials": "receiver-token" }
165
+ }
166
+ }
167
+ ```
168
+
169
+ The receiver gets A2A `StreamResponse` JSON (`application/a2a+json`), including `task`, `artifactUpdate` and `statusUpdate`. Completion is `statusUpdate.status.state: "TASK_STATE_COMPLETED"`; errors and cancellation use their corresponding standard states. Delivery is ordered per scoped task, has a five-second timeout and refuses redirects. Slow or unavailable receivers do not delay task acceptance or execution. Delivery is best effort without retry or a durable outbox; consumers can reconcile with `GetTask`. An empty origin list disables push notifications. The calling system owns waking its main agent after receiving a callback.
170
+
171
+ Tasks, callback configurations and context-to-session mappings live under `<DSH_HOME>/plugins/1agents-acp/a2a` by default (`a2a.stateDirectory` overrides it). Records are scoped by tenant and authenticated host credential, written atomically with restricted permissions, and protected against two live owners of the same directory. The `.lock` directory contains a unique process-owner record; dead owners can be reclaimed without deleting a newly acquired owner's lock. A legacy `.lock` file is rejected and must only be removed after verifying no instance is running. After a host restart, completed results remain queryable, interrupted nonterminal tasks become `TASK_STATE_FAILED`, and a new task with the saved `contextId` restores its DSH session. Interrupted work is never automatically replayed. Plugin unload removes both routes and cancels its own active or queued turns.
172
+
173
+ Verification covers the official A2A client over real HTTP, SSE, callbacks, disconnection and restart, durable storage, and keyless DSH session execution. Run `pnpm --filter @1agents/acp-service test:only` and `pnpm --filter @1agents/dsh-acp test:only` after building. The optional real DSH loop test uses `DSH_SOURCE=/absolute/path/DSH`; package smoke tests verify the installed tarball's shared export and embedded plugin.
51
174
 
52
175
  ## ACP connections
53
176
 
@@ -164,3 +287,51 @@ Tests use the official ACP SDK over real WebSockets, cover session lifecycle and
164
287
  Discovery checks PATH, `~/.local/bin`, `~/.grok/bin`, and installed adapter package launch files. A registered native ACP command is ready when its executable exists. Adapter-backed harnesses are ready when the adapter is installed, or when their native CLI and `npx` are installed; the latter uses the runtime's existing adapter download behavior when a session launches. Having `npx` or `uvx` alone does not expose uninstalled harnesses. Scanning neither executes agents nor downloads packages, and readiness does not verify credentials or model access. Detection-only frameworks remain in the inventory with `chat_ready: false`.
165
288
 
166
289
  The service launcher uses the same local command resolution, including absolute paths to user-local binaries. The catalog originates from 1agents_app's former Go detector; consumers no longer probe their own host or maintain separate detection tables. `discoverAgents()` is also exported for embedded service consumers and includes local executable paths; the HTTP response omits these paths.
290
+
291
+ ## Remote DSH tools and completion inbox
292
+
293
+ The optional automation listener supports Activepieces scheduled tasks:
294
+ authenticated occurrence submission, overlap prevention, durable task
295
+ correlation and completion-processing claims. See the repository's
296
+ [integration guide](https://github.com/scottzx/1acp/blob/main/docs/activepieces-automation.md) and
297
+ [configuration examples](https://github.com/scottzx/1acp/tree/main/examples/activepieces).
298
+
299
+ The same package includes `acp-service a2a gateway --config /absolute/gateway.json` and exports `RemoteAgentGateway` / `serveA2AGateway` from `@1agents/acp-service/a2a`. The gateway calls the standard A2A 1.0 SendMessage, GetTask and CancelTask APIs. It registers seven HTTP methods with the local DreamMate node; an existing `dreammate_invoke` client can use them immediately without another MCP server.
300
+
301
+ Create a private configuration file (`chmod 600`):
302
+
303
+ ```json
304
+ {
305
+ "stateDirectory": "/absolute/private/a2a-state",
306
+ "port": 36814,
307
+ "remotes": {
308
+ "wsl-dsh": { "url": "http://your-tailnet-host:3080", "token": "protected-DSH-A2A-token" }
309
+ },
310
+ "callback": {
311
+ "host": "your-local-tailnet-IP",
312
+ "port": 36815,
313
+ "url": "http://your-local-tailnet-IP:36815/a2a-events",
314
+ "token": "separate-protected-callback-token"
315
+ }
316
+ }
317
+ ```
318
+
319
+ The callback is optional; configure its exact origin in DSH `a2a.pushNotificationOrigins`. The tool listener binds only `127.0.0.1`; the separate authenticated callback listener exposes only the configured event path. Browser Origin requests cannot invoke local tools. Credentials stay in configuration, outside prompts and tool parameters. Local DreamMate clients are trusted; `originSessionId` is a routing identifier, not a remote authentication credential.
320
+
321
+ Discover `a2a-gateway`, inspect `remote_agent_spawn`, then call it with:
322
+
323
+ ```json
324
+ {
325
+ "remote": "wsl-dsh",
326
+ "originSessionId": "stable-parent-session-id",
327
+ "cwd": "/home/scott/project",
328
+ "agentPreset": "oneagents-acp-codex",
329
+ "prompt": "Read the project README and report its purpose. Do not change files."
330
+ }
331
+ ```
332
+
333
+ The returned `taskId` is available before execution finishes. `cwd` is an existing absolute path **on WSL**. Every spawn creates a new A2A context / DSH session even when cwd matches. `remote_agent_message` takes the previous task ID and prompt, creates a new task in the same context, and keeps that DSH session. `remote_agent_get` / `remote_agent_cancel` take `remote`, `originSessionId`, and `taskId`. `remote_agent_list` and `remote_agent_inbox` take only `originSessionId`; after handling a notice, confirm it with `remote_agent_ack` and its `noticeId`.
334
+
335
+ CLI callers use the same methods: pipe a JSON parameters object to `acp-service a2a invoke remote_agent_spawn` (or any method above). The gateway runs independently of the caller. A durable inbox, stable notice IDs, restart reconciliation and GetTask polling recover completions when a push event is missed. Offline queries return the cached task with `stale: true`; loss of connectivity never becomes a fabricated task failure. An ambiguous failed SendMessage is not automatically resubmitted, since A2A message IDs alone do not guarantee exactly-once task admission.
336
+
337
+ To wake a main-agent host, configure `notificationTargets` as a map of trusted target names to `{ "url": "...", "token": "..." }` and pass a target name as `notificationTarget` to spawn. Completion or input-required notices carry `originSessionId`, `taskId`, `contextId`, state and result. Deliveries use bearer authentication and a stable `Idempotency-Key`, retry after a failed response or gateway restart, and remain in the inbox until acknowledged. The receiving host must persist/deduplicate the notice and inject it into the named parent session (for example Phonetic's `async_task_notice`). A successful HTTP response means the receiver accepted the notice, not that the main model ran. Codex's ordinary MCP tool connection alone does not implement that host adapter; this gateway does not claim automatic Codex turn wake-up.
@@ -0,0 +1 @@
1
+ export declare function runA2ACli(args: string[]): Promise<void>;
@@ -0,0 +1,52 @@
1
+ import fs from 'node:fs';
2
+ import { serveA2AGateway } from '../src/a2a/gateway.js';
3
+ export async function runA2ACli(args) {
4
+ const flag = (name) => {
5
+ const index = args.indexOf(name);
6
+ if (index < 0)
7
+ return undefined;
8
+ if (!args[index + 1] || args[index + 1].startsWith('--'))
9
+ throw new Error(`Missing value for ${name}`);
10
+ return args[index + 1];
11
+ };
12
+ if (!args.length || args.includes('--help') || args.includes('-h')) {
13
+ console.log(`Usage:
14
+ acp-service a2a gateway --config <file> [--no-report]
15
+ acp-service a2a invoke <method> [--url http://127.0.0.1:36814]
16
+
17
+ invoke reads a JSON parameters object from stdin. Credentials stay in the
18
+ gateway config file (chmod 600), outside tool arguments. Remote cwd is absolute.
19
+ Methods: remote_agent_spawn, remote_agent_get, remote_agent_message,
20
+ remote_agent_cancel, remote_agent_list, remote_agent_inbox, remote_agent_ack`);
21
+ return;
22
+ }
23
+ if (args[0] === 'gateway') {
24
+ const file = flag('--config');
25
+ if (!file)
26
+ throw new Error('gateway requires --config <file>');
27
+ const stat = fs.statSync(file);
28
+ if (process.platform !== 'win32' && (stat.mode & 0o077))
29
+ throw new Error('Gateway config contains credentials; set chmod 600');
30
+ const config = JSON.parse(fs.readFileSync(file, 'utf8'));
31
+ const host = await serveA2AGateway(config, { report: !args.includes('--no-report') });
32
+ console.log(`a2a-gateway listening on http://127.0.0.1:${host.port}; registration=${host.registration?.ok ?? false}`);
33
+ if (host.automationPort !== undefined)
34
+ console.log(`a2a automation listening on http://${host.gateway.config.automation.host}:${host.automationPort}`);
35
+ const stop = () => { void host.close().then(() => { process.exitCode = 0; }); };
36
+ process.once('SIGINT', stop);
37
+ process.once('SIGTERM', stop);
38
+ return;
39
+ }
40
+ if (args[0] === 'invoke' && args[1] && !args[1].startsWith('--')) {
41
+ const url = new URL('/invoke', flag('--url') ?? 'http://127.0.0.1:36814');
42
+ const params = JSON.parse(fs.readFileSync(0, 'utf8'));
43
+ const response = await fetch(url, { method: 'POST', redirect: 'error', signal: AbortSignal.timeout(15_000),
44
+ headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ method: args[1], params }) });
45
+ const data = await response.json();
46
+ console.log(JSON.stringify(data, null, 2));
47
+ if (!response.ok)
48
+ process.exitCode = 1;
49
+ return;
50
+ }
51
+ throw new Error('Unknown A2A command; run acp-service a2a --help');
52
+ }
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { execFileSync, spawn } from 'node:child_process';
3
3
  import { createRequire } from 'node:module';
4
+ import path from 'node:path';
4
5
  import fs from 'node:fs';
5
- import { serveAcpService } from '../src/server.js';
6
- import { attachProcessSignalHandlers } from '../src/bridge.js';
7
6
  const require = createRequire(import.meta.url);
8
7
  const rawArgs = process.argv.slice(2);
9
8
  const invokedBin = 'acp-service';
@@ -54,9 +53,12 @@ function printUnifiedHelp(binName) {
54
53
  .replace(/^Usage:\s+acpx/m, `Usage: ${binName}`)
55
54
  .replace(/Headless CLI client for the Agent Client Protocol/, 'Headless CLI client & DreamMate Network runtime service for the Agent Client Protocol (ACP)');
56
55
  const serverCommands = `Commands:
56
+ a2a gateway --config <file> Start persistent remote-agent tools and completion inbox
57
+ a2a invoke <method> Invoke local remote-agent tools (JSON params on stdin)
57
58
  serve [options] Start DreamMate Network ACP runtime daemon (HTTP + WS)`;
58
59
  help = help.replace(/^Commands:/m, serverCommands);
59
60
  const serverOptions = `Options:
61
+ --skill <action> List, show, export or install bundled agent skills
60
62
  --port, -p <n> Server listen port (for serve, default: 36812)
61
63
  --host <ip> Server bind IP (for serve, default: 0.0.0.0)
62
64
  --no-report Do not report to local dreammate-node (36908)`;
@@ -103,6 +105,8 @@ function parseServerArgs(args) {
103
105
  return options;
104
106
  }
105
107
  async function runServer(options) {
108
+ const { serveAcpService } = await import('../src/server.js');
109
+ const { attachProcessSignalHandlers } = await import('../src/bridge.js');
106
110
  attachProcessSignalHandlers();
107
111
  try {
108
112
  await serveAcpService(options);
@@ -113,6 +117,20 @@ async function runServer(options) {
113
117
  }
114
118
  }
115
119
  async function main() {
120
+ if (rawArgs.includes('--skill')) {
121
+ const { maybeHandleSkillflag } = await import('skillflag');
122
+ const packageRoot = path.dirname(require.resolve('@1agents/acp-service/package.json'));
123
+ await maybeHandleSkillflag(process.argv, {
124
+ skillsRoot: [path.join(packageRoot, 'skills'), path.join(packageRoot, 'vendor/runtime/skills')],
125
+ includeBundledSkill: false,
126
+ });
127
+ return;
128
+ }
129
+ if (rawArgs[0] === 'a2a') {
130
+ const { runA2ACli } = await import('./a2a.js');
131
+ await runA2ACli(rawArgs.slice(1));
132
+ return;
133
+ }
116
134
  const isServe = rawArgs[0] === 'serve' || rawArgs[0] === 'run';
117
135
  const hasServerExplicitFlag = rawArgs[0] === '--port' ||
118
136
  rawArgs[0] === '-p' ||
@@ -0,0 +1,99 @@
1
+ import http from 'node:http';
2
+ import { z } from 'zod';
3
+ import type { RemoteAgentGateway, RemoteAgentNotice } from './gateway.js';
4
+ export declare const automationConfigSchema: z.ZodObject<{
5
+ host: z.ZodDefault<z.ZodString>;
6
+ port: z.ZodDefault<z.ZodNumber>;
7
+ token: z.ZodString;
8
+ schedules: z.ZodRecord<z.ZodString, z.ZodObject<{
9
+ remote: z.ZodString;
10
+ cwd: z.ZodString;
11
+ agentPreset: z.ZodOptional<z.ZodString>;
12
+ notificationTarget: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strict>>;
14
+ processingLeaseMs: z.ZodDefault<z.ZodNumber>;
15
+ }, z.core.$strict>;
16
+ export type A2AAutomationConfig = z.input<typeof automationConfigSchema>;
17
+ type Config = z.output<typeof automationConfigSchema>;
18
+ export type AutomationRunStatus = 'dispatching' | 'submitted' | 'submission_unknown' | 'skipped' | 'completed' | 'failed' | 'canceled' | 'rejected' | 'input_required' | 'auth_required';
19
+ export interface AutomationRun {
20
+ runId: string;
21
+ occurrenceKey: string;
22
+ originSessionId: string;
23
+ scheduleId: string;
24
+ scheduledFor: string;
25
+ flowRunId?: string;
26
+ businessRef?: string;
27
+ prompt: string;
28
+ remote: string;
29
+ cwd: string;
30
+ agentPreset?: string;
31
+ notificationTarget?: string;
32
+ status: AutomationRunStatus;
33
+ reason?: 'schedule_busy' | 'submission_unconfirmed' | 'ambiguous_submission';
34
+ blockedBy?: string;
35
+ taskId?: string;
36
+ contextId?: string;
37
+ sessionId?: string;
38
+ state?: string;
39
+ result?: string;
40
+ checkedAt?: string;
41
+ stale?: boolean;
42
+ createdAt: string;
43
+ updatedAt: string;
44
+ }
45
+ /** The gateway owns remote polling and delivery; this ledger owns occurrence admission and business acknowledgement. */
46
+ export declare class A2AAutomation {
47
+ private readonly gateway;
48
+ readonly config: Config;
49
+ private readonly file;
50
+ private readonly state;
51
+ private readonly admissions;
52
+ constructor(gateway: RemoteAgentGateway, config: Config);
53
+ private save;
54
+ private run;
55
+ private apply;
56
+ private refresh;
57
+ submit(params: unknown): Promise<{
58
+ run: AutomationRun;
59
+ created: boolean;
60
+ }>;
61
+ list(limit: number): Promise<{
62
+ runs: AutomationRun[];
63
+ }>;
64
+ get(runId: string): Promise<{
65
+ run: AutomationRun;
66
+ }>;
67
+ cancel(runId: string): Promise<{
68
+ run: AutomationRun;
69
+ }>;
70
+ private knownNotice;
71
+ claim(noticeId: string, params: unknown): Promise<{
72
+ claimed: boolean;
73
+ runId: string;
74
+ reason: string;
75
+ leaseUntil?: undefined;
76
+ notice?: undefined;
77
+ } | {
78
+ claimed: boolean;
79
+ runId: string;
80
+ reason: string;
81
+ leaseUntil: string;
82
+ notice?: undefined;
83
+ } | {
84
+ claimed: boolean;
85
+ runId: string;
86
+ notice: RemoteAgentNotice;
87
+ leaseUntil: string;
88
+ reason?: undefined;
89
+ }>;
90
+ ack(noticeId: string, params: unknown): Promise<{
91
+ acknowledged: boolean;
92
+ runId: string;
93
+ noticeId: string;
94
+ }>;
95
+ /** Retry only local inbox acknowledgement after durable business completion, never business effects. */
96
+ reconcileAcknowledgements(): Promise<void>;
97
+ }
98
+ export declare function createAutomationServer(automation: A2AAutomation): http.Server;
99
+ export {};