mycomesh-consumer 0.1.31 → 0.1.32
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 +49 -111
- package/package.json +7 -5
- package/src/cli.mjs +1 -1
- package/src/consumer-runtime.mjs +1180 -0
- package/src/consumer.mjs +197 -118
- package/consumer.compose.yml +0 -90
- package/scripts/start-consumer.sh +0 -223
package/README.md
CHANGED
|
@@ -1,156 +1,94 @@
|
|
|
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 includes the official Codex
|
|
10
|
+
dependency and the small cryptographic dependencies needed for V8 EIP-712
|
|
11
|
+
payment-key authorizations.
|
|
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.
|
|
24
|
+
The command starts `127.0.0.1:8110`, prints and optionally opens the local
|
|
25
|
+
credentials page, waits for a healthy Settlement V8 Relay, and launches Codex
|
|
26
|
+
with a one-run `mycomesh` provider configuration. It does not edit Codex files.
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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.
|
|
52
33
|
|
|
53
|
-
|
|
54
|
-
mycomesh-consumer --reset-local
|
|
55
|
-
```
|
|
34
|
+
## Service-only mode
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
`mycomesh-consumer --no-codex` to restart the local edge.
|
|
59
|
-
|
|
60
|
-
This removes the local payment key and Consumer state. The command asks you to type `RESET`
|
|
61
|
-
and removes only the fixed Consumer Compose project and its protected volume.
|
|
62
|
-
|
|
63
|
-
The existing stateless API commands remain available. For example:
|
|
36
|
+
Keep the native Consumer running without launching Codex:
|
|
64
37
|
|
|
65
38
|
```sh
|
|
66
|
-
|
|
39
|
+
mycomesh-consumer --no-codex
|
|
67
40
|
```
|
|
68
41
|
|
|
69
|
-
|
|
42
|
+
Use `--no-browser` on a headless machine. Stop the process without deleting
|
|
43
|
+
the key or history with `mycomesh-consumer --stop`. A full reset is explicit:
|
|
70
44
|
|
|
71
45
|
```sh
|
|
72
|
-
|
|
73
|
-
export MYCOMESH_API_KEY=your-consumer-key
|
|
46
|
+
MYCOMESH_CONFIRM_RESET=RESET mycomesh-consumer --reset-local
|
|
74
47
|
```
|
|
75
48
|
|
|
76
|
-
|
|
77
|
-
variables. A base URL may be the service root or end in `/v1`.
|
|
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:
|
|
49
|
+
The local API is OpenAI-compatible:
|
|
92
50
|
|
|
93
51
|
```sh
|
|
94
|
-
export
|
|
95
|
-
export
|
|
52
|
+
export OPENAI_BASE_URL=http://127.0.0.1:8110/v1
|
|
53
|
+
export OPENAI_API_KEY='myco_sk_...'
|
|
54
|
+
mycomesh responses --input 'hello' --model mycomesh-codex-standard-v1
|
|
96
55
|
```
|
|
97
56
|
|
|
98
|
-
The
|
|
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.
|
|
57
|
+
The browser's export block is the canonical way to obtain both values.
|
|
101
58
|
|
|
102
|
-
##
|
|
59
|
+
## Relay scheduling and V8 payments
|
|
103
60
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
--model mycomesh-codex-standard-v1 \
|
|
111
|
-
--max-output-tokens 500
|
|
112
|
-
|
|
113
|
-
mycomesh chat \
|
|
114
|
-
--message "Explain this function" \
|
|
115
|
-
--system "Be concise." \
|
|
116
|
-
--model mycomesh-codex-standard-v1 \
|
|
117
|
-
--max-completion-tokens 500
|
|
118
|
-
```
|
|
61
|
+
The Consumer checks each configured Relay's V8 health and automatically tries
|
|
62
|
+
the next Relay after a health, timeout, or retryable HTTP failure. A single
|
|
63
|
+
request ID is preserved across failover. Each attempt carries a fresh V8
|
|
64
|
+
EIP-712 payment authorization signed by the persisted key; the Relay resolves
|
|
65
|
+
the key address to its on-chain grant and settles the signed receipt. No wallet
|
|
66
|
+
signature or Consumer-managed conversation state is involved in inference.
|
|
119
67
|
|
|
120
|
-
|
|
121
|
-
each request to the persisted payment key automatically.
|
|
122
|
-
|
|
123
|
-
Use `--stream` to request SSE. SSE bytes are forwarded to stdout as they arrive,
|
|
124
|
-
without rewriting event boundaries:
|
|
68
|
+
Configure multiple Relay origins and an optional outbound proxy:
|
|
125
69
|
|
|
126
70
|
```sh
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
--max-output-tokens 500 \
|
|
130
|
-
--stream
|
|
71
|
+
export MYCOMESH_V8_RELAY_URLS='https://relay-a.example,https://relay-b.example'
|
|
72
|
+
mycomesh-consumer --proxy http://127.0.0.1:10792
|
|
131
73
|
```
|
|
132
74
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
75
|
+
The default Relay is `https://bridge.mycomesh.xyz`. The V8 deployment and RPC
|
|
76
|
+
defaults are embedded in the package; `MYCOMESH_CONSUMER_NETWORK_CONFIG` and
|
|
77
|
+
`MYCOMESH_CONSUMER_SETTLEMENT_RPC_URLS` can override them for another network.
|
|
136
78
|
|
|
137
|
-
|
|
138
|
-
mycomesh responses --json '{"model":"my-model","input":"hello"}'
|
|
139
|
-
mycomesh chat --json @request.json
|
|
140
|
-
generate-request | mycomesh responses --json -
|
|
141
|
-
```
|
|
79
|
+
## Stateless request CLI
|
|
142
80
|
|
|
143
|
-
|
|
81
|
+
The package also keeps the stateless API commands:
|
|
144
82
|
|
|
145
83
|
```sh
|
|
146
|
-
|
|
147
|
-
|
|
84
|
+
mycomesh health
|
|
85
|
+
mycomesh models
|
|
86
|
+
mycomesh responses --input 'Summarize this' --max-output-tokens 500
|
|
87
|
+
mycomesh chat --message 'Explain this function'
|
|
148
88
|
```
|
|
149
89
|
|
|
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.
|
|
90
|
+
Use `--json @file`, `--json -`, or piped JSON for complete OpenAI-shaped
|
|
91
|
+
requests. `--stream` returns buffered-compatible SSE events from the Relay.
|
|
154
92
|
|
|
155
93
|
## Development
|
|
156
94
|
|
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.32",
|
|
4
|
+
"description": "Native Node.js MycoMesh Consumer and OpenAI-compatible request CLI.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,15 +15,17 @@
|
|
|
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
|
+
"@openai/codex": "0.146.0",
|
|
28
|
+
"undici": "6.28.0"
|
|
27
29
|
},
|
|
28
30
|
"scripts": {
|
|
29
31
|
"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.32";
|
|
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.
|