mycomesh-consumer 0.1.31 → 0.1.33
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/README.md +55 -108
- package/package.json +6 -5
- package/src/cli.mjs +1 -1
- package/src/consumer-runtime.mjs +1180 -0
- package/src/consumer.mjs +202 -121
- package/consumer.compose.yml +0 -90
- package/scripts/start-consumer.sh +0 -223
package/README.md
CHANGED
|
@@ -1,156 +1,103 @@
|
|
|
1
1
|
# mycomesh-consumer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
the loopback proxy.
|
|
3
|
+
Native Node.js Consumer for the MycoMesh Settlement V8 Relay network. It runs
|
|
4
|
+
on the user's machine with no Docker, Python runtime, Compose file, or public
|
|
5
|
+
Gateway dependency.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
short `mycomesh` command are equivalent.
|
|
7
|
+
## Install
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- Docker Desktop/Engine with Compose V2
|
|
15
|
-
- The official Codex dependency installed with this npm package
|
|
16
|
-
|
|
17
|
-
For local development, install it directly from the repository:
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npm install --global ./packages/mycomesh-cli
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
For an npm install from the public registry:
|
|
9
|
+
Requirements: Node.js 20 or newer. The package contains only the small
|
|
10
|
+
cryptographic dependencies needed for V8 EIP-712 payment-key authorizations;
|
|
11
|
+
Codex is an independent client.
|
|
24
12
|
|
|
25
13
|
```sh
|
|
26
14
|
npm install --global mycomesh-consumer
|
|
27
15
|
mycomesh-consumer
|
|
28
16
|
```
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
required. The command prints the local credentials URL and opens it when
|
|
32
|
-
possible. The page contains only `OPENAI_BASE_URL` and `OPENAI_API_KEY` exports;
|
|
33
|
-
the payment key is generated and persisted in a protected Docker volume. No
|
|
34
|
-
wallet signature or browser session is required.
|
|
35
|
-
|
|
36
|
-
The runtime image is pinned by digest. Stop it without deleting state with:
|
|
18
|
+
For a checkout:
|
|
37
19
|
|
|
38
20
|
```sh
|
|
39
|
-
mycomesh-
|
|
21
|
+
npm install --global ./packages/mycomesh-cli
|
|
40
22
|
```
|
|
41
23
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
hosts are translated to `host.docker.internal`. Dedicated
|
|
46
|
-
`MYCOMESH_CONSUMER_*_PROXY` variables remain available for operators.
|
|
47
|
-
|
|
48
|
-
Upgrading the npm package does not require clearing the payment key. The
|
|
49
|
-
Consumer volume is intentionally reused so its key and routing state survive
|
|
50
|
-
restarts. To reset all local Consumer state,
|
|
51
|
-
use the explicit, confirmed reset command:
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
mycomesh-consumer --reset-local
|
|
55
|
-
```
|
|
24
|
+
The command starts the Consumer API on `127.0.0.1:8110`, prints and optionally
|
|
25
|
+
opens the local credentials page, and stays available for any
|
|
26
|
+
OpenAI-compatible client. It does not start or configure Codex.
|
|
56
27
|
|
|
57
|
-
|
|
58
|
-
|
|
28
|
+
The page exposes only the local API URL, payment key/export, prepaid balance,
|
|
29
|
+
key operations, and local consumption history. It has no conversation or
|
|
30
|
+
request-session UI. The payment key is generated once and stored at
|
|
31
|
+
`~/.mycomesh/consumer/payment-key` with mode `0600`; set
|
|
32
|
+
`MYCOMESH_CONSUMER_DATA_DIR` to choose another directory.
|
|
59
33
|
|
|
60
|
-
|
|
61
|
-
and removes only the fixed Consumer Compose project and its protected volume.
|
|
34
|
+
## Connect a client
|
|
62
35
|
|
|
63
|
-
The
|
|
36
|
+
The default command is already service-only. Load the export block into a
|
|
37
|
+
shell and then use Codex or another compatible client:
|
|
64
38
|
|
|
65
39
|
```sh
|
|
66
|
-
|
|
40
|
+
mycomesh-consumer --no-browser
|
|
41
|
+
eval "$(curl -sS http://127.0.0.1:8110/credentials)"
|
|
42
|
+
codex
|
|
67
43
|
```
|
|
68
44
|
|
|
69
|
-
|
|
45
|
+
The optional convenience wrapper is explicit:
|
|
70
46
|
|
|
71
47
|
```sh
|
|
72
|
-
|
|
73
|
-
export MYCOMESH_API_KEY=your-consumer-key
|
|
48
|
+
mycomesh-consumer --codex
|
|
74
49
|
```
|
|
75
50
|
|
|
76
|
-
`--
|
|
77
|
-
|
|
78
|
-
Remote base URLs must use HTTPS. Loopback HTTP remains available for local
|
|
79
|
-
development; `--allow-insecure-http` is an explicit test-only escape hatch.
|
|
80
|
-
Requests default to a 300-second deadline. Set `MYCOMESH_TIMEOUT_SECONDS` or
|
|
81
|
-
`--timeout`; successful JSON bodies are capped at 32 MiB while SSE remains
|
|
82
|
-
streamed with backpressure.
|
|
83
|
-
|
|
84
|
-
Prefer `MYCOMESH_API_KEY` over `--api-key`: command-line arguments may be stored
|
|
85
|
-
in shell history or visible to other local processes. The CLI never writes the
|
|
86
|
-
key to disk and redacts it from HTTP error output.
|
|
87
|
-
|
|
88
|
-
The zero-argument launcher configures Codex directly with a temporary
|
|
89
|
-
`mycomesh` model provider and does not modify `~/.codex/config.toml`. For manual
|
|
90
|
-
API commands, read the local credentials with the repository operator command
|
|
91
|
-
or provide explicit values:
|
|
51
|
+
Use `--no-browser` on a headless machine. Stop the process without deleting
|
|
52
|
+
the key or history with `mycomesh-consumer --stop`. A full reset is explicit:
|
|
92
53
|
|
|
93
54
|
```sh
|
|
94
|
-
|
|
95
|
-
export MYCOMESH_API_KEY='replace-with-local-consumer-key'
|
|
55
|
+
MYCOMESH_CONFIRM_RESET=RESET mycomesh-consumer --reset-local
|
|
96
56
|
```
|
|
97
57
|
|
|
98
|
-
The local
|
|
99
|
-
persisted payment key. No session identifier or per-request wallet signature is needed. A public Gateway can
|
|
100
|
-
still be used explicitly with `--base-url`, but it is never the default.
|
|
101
|
-
|
|
102
|
-
## Commands
|
|
58
|
+
The local API is OpenAI-compatible:
|
|
103
59
|
|
|
104
60
|
```sh
|
|
105
|
-
|
|
106
|
-
|
|
61
|
+
export OPENAI_BASE_URL=http://127.0.0.1:8110/v1
|
|
62
|
+
export OPENAI_API_KEY='myco_sk_...'
|
|
63
|
+
mycomesh responses --input 'hello' --model mycomesh-codex-standard-v1
|
|
64
|
+
```
|
|
107
65
|
|
|
108
|
-
|
|
109
|
-
--input "Summarize this text" \
|
|
110
|
-
--model mycomesh-codex-standard-v1 \
|
|
111
|
-
--max-output-tokens 500
|
|
66
|
+
The browser's export block is the canonical way to obtain both values.
|
|
112
67
|
|
|
113
|
-
|
|
114
|
-
--message "Explain this function" \
|
|
115
|
-
--system "Be concise." \
|
|
116
|
-
--model mycomesh-codex-standard-v1 \
|
|
117
|
-
--max-completion-tokens 500
|
|
118
|
-
```
|
|
68
|
+
## Relay scheduling and V8 payments
|
|
119
69
|
|
|
120
|
-
The
|
|
121
|
-
|
|
70
|
+
The Consumer checks each configured Relay's V8 health and automatically tries
|
|
71
|
+
the next Relay after a health, timeout, or retryable HTTP failure. A single
|
|
72
|
+
request ID is preserved across failover. Each attempt carries a fresh V8
|
|
73
|
+
EIP-712 payment authorization signed by the persisted key; the Relay resolves
|
|
74
|
+
the key address to its on-chain grant and settles the signed receipt. No wallet
|
|
75
|
+
signature or Consumer-managed conversation state is involved in inference.
|
|
122
76
|
|
|
123
|
-
|
|
124
|
-
without rewriting event boundaries:
|
|
77
|
+
Configure multiple Relay origins and an optional outbound proxy:
|
|
125
78
|
|
|
126
79
|
```sh
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
--max-output-tokens 500 \
|
|
130
|
-
--stream
|
|
80
|
+
export MYCOMESH_V8_RELAY_URLS='https://relay-a.example,https://relay-b.example'
|
|
81
|
+
mycomesh-consumer --proxy http://127.0.0.1:10792
|
|
131
82
|
```
|
|
132
83
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
84
|
+
The default Relay is `https://bridge.mycomesh.xyz`. The V8 deployment and RPC
|
|
85
|
+
defaults are embedded in the package; `MYCOMESH_CONSUMER_NETWORK_CONFIG` and
|
|
86
|
+
`MYCOMESH_CONSUMER_SETTLEMENT_RPC_URLS` can override them for another network.
|
|
136
87
|
|
|
137
|
-
|
|
138
|
-
mycomesh responses --json '{"model":"my-model","input":"hello"}'
|
|
139
|
-
mycomesh chat --json @request.json
|
|
140
|
-
generate-request | mycomesh responses --json -
|
|
141
|
-
```
|
|
88
|
+
## Stateless request CLI
|
|
142
89
|
|
|
143
|
-
|
|
90
|
+
The package also keeps the stateless API commands:
|
|
144
91
|
|
|
145
92
|
```sh
|
|
146
|
-
|
|
147
|
-
|
|
93
|
+
mycomesh health
|
|
94
|
+
mycomesh models
|
|
95
|
+
mycomesh responses --input 'Summarize this' --max-output-tokens 500
|
|
96
|
+
mycomesh chat --message 'Explain this function'
|
|
148
97
|
```
|
|
149
98
|
|
|
150
|
-
|
|
151
|
-
`--stream`
|
|
152
|
-
are pretty-printed. SSE and other response types are copied to stdout. HTTP and
|
|
153
|
-
input errors are written to stderr and return a nonzero exit status.
|
|
99
|
+
Use `--json @file`, `--json -`, or piped JSON for complete OpenAI-shaped
|
|
100
|
+
requests. `--stream` returns buffered-compatible SSE events from the Relay.
|
|
154
101
|
|
|
155
102
|
## Development
|
|
156
103
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mycomesh-consumer",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.33",
|
|
4
|
+
"description": "Native Node.js MycoMesh Consumer and OpenAI-compatible request CLI.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
"bin/mycomesh-consumer.mjs",
|
|
16
16
|
"src/cli.mjs",
|
|
17
17
|
"src/consumer.mjs",
|
|
18
|
-
"
|
|
19
|
-
"consumer.compose.yml",
|
|
18
|
+
"src/consumer-runtime.mjs",
|
|
20
19
|
"README.md"
|
|
21
20
|
],
|
|
22
21
|
"engines": {
|
|
23
22
|
"node": ">=20"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@
|
|
25
|
+
"@noble/curves": "1.9.1",
|
|
26
|
+
"@noble/hashes": "1.8.0",
|
|
27
|
+
"undici": "6.28.0"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"test": "node --test"
|
package/src/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { once } from "node:events";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
|
|
4
|
-
const CLI_VERSION = "0.1.
|
|
4
|
+
const CLI_VERSION = "0.1.33";
|
|
5
5
|
// The npm client is local-first. A public Gateway is an explicit override;
|
|
6
6
|
// the default remains the loopback Consumer edge so a blocked domain cannot
|
|
7
7
|
// strand the Codex client.
|