@faces-sh/cli 0.0.0-stage → 1.0.1
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 +21 -0
- package/README.md +158 -2
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/base.d.ts +26 -0
- package/dist/base.js +181 -0
- package/dist/benchmark.d.ts +21 -0
- package/dist/benchmark.js +95 -0
- package/dist/billing.d.ts +17 -0
- package/dist/billing.js +101 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +242 -0
- package/dist/client.d.ts +98 -0
- package/dist/client.js +590 -0
- package/dist/commands/account/preferences.d.ts +20 -0
- package/dist/commands/account/preferences.js +190 -0
- package/dist/commands/account/state.d.ts +11 -0
- package/dist/commands/account/state.js +24 -0
- package/dist/commands/auth/connect.d.ts +17 -0
- package/dist/commands/auth/connect.js +190 -0
- package/dist/commands/auth/connections.d.ts +12 -0
- package/dist/commands/auth/connections.js +40 -0
- package/dist/commands/auth/disconnect.d.ts +15 -0
- package/dist/commands/auth/disconnect.js +49 -0
- package/dist/commands/auth/login.d.ts +13 -0
- package/dist/commands/auth/login.js +42 -0
- package/dist/commands/auth/logout.d.ts +11 -0
- package/dist/commands/auth/logout.js +14 -0
- package/dist/commands/auth/refresh.d.ts +11 -0
- package/dist/commands/auth/refresh.js +30 -0
- package/dist/commands/auth/register.d.ts +15 -0
- package/dist/commands/auth/register.js +98 -0
- package/dist/commands/auth/whoami.d.ts +11 -0
- package/dist/commands/auth/whoami.js +108 -0
- package/dist/commands/benchmark/get.d.ts +16 -0
- package/dist/commands/benchmark/get.js +42 -0
- package/dist/commands/benchmark/list.d.ts +13 -0
- package/dist/commands/benchmark/list.js +47 -0
- package/dist/commands/benchmark/start.d.ts +22 -0
- package/dist/commands/benchmark/start.js +80 -0
- package/dist/commands/billing/balance.d.ts +11 -0
- package/dist/commands/billing/balance.js +27 -0
- package/dist/commands/billing/card/default.d.ts +15 -0
- package/dist/commands/billing/card/default.js +33 -0
- package/dist/commands/billing/card/remove.d.ts +16 -0
- package/dist/commands/billing/card/remove.js +41 -0
- package/dist/commands/billing/card-setup.d.ts +13 -0
- package/dist/commands/billing/card-setup.js +41 -0
- package/dist/commands/billing/cards.d.ts +11 -0
- package/dist/commands/billing/cards.js +34 -0
- package/dist/commands/billing/llm-costs.d.ts +14 -0
- package/dist/commands/billing/llm-costs.js +95 -0
- package/dist/commands/billing/subscription/activate.d.ts +14 -0
- package/dist/commands/billing/subscription/activate.js +91 -0
- package/dist/commands/billing/subscription/cancel.d.ts +12 -0
- package/dist/commands/billing/subscription/cancel.js +54 -0
- package/dist/commands/billing/subscription/index.d.ts +11 -0
- package/dist/commands/billing/subscription/index.js +46 -0
- package/dist/commands/billing/subscription/plan.d.ts +16 -0
- package/dist/commands/billing/subscription/plan.js +86 -0
- package/dist/commands/billing/topup.d.ts +16 -0
- package/dist/commands/billing/topup.js +60 -0
- package/dist/commands/billing/usage.d.ts +15 -0
- package/dist/commands/billing/usage.js +68 -0
- package/dist/commands/catalog/backup.d.ts +11 -0
- package/dist/commands/catalog/backup.js +169 -0
- package/dist/commands/catalog/doctor.d.ts +14 -0
- package/dist/commands/catalog/doctor.js +303 -0
- package/dist/commands/catalog/list.d.ts +11 -0
- package/dist/commands/catalog/list.js +39 -0
- package/dist/commands/catalog/restore.d.ts +17 -0
- package/dist/commands/catalog/restore.js +259 -0
- package/dist/commands/causes.d.ts +27 -0
- package/dist/commands/causes.js +135 -0
- package/dist/commands/chat/chat.d.ts +42 -0
- package/dist/commands/chat/chat.js +363 -0
- package/dist/commands/chat/messages.d.ts +26 -0
- package/dist/commands/chat/messages.js +139 -0
- package/dist/commands/chat/responses.d.ts +27 -0
- package/dist/commands/chat/responses.js +150 -0
- package/dist/commands/chat/thread.d.ts +43 -0
- package/dist/commands/chat/thread.js +458 -0
- package/dist/commands/compile/all.d.ts +14 -0
- package/dist/commands/compile/all.js +186 -0
- package/dist/commands/compile/doc/create.d.ts +19 -0
- package/dist/commands/compile/doc/create.js +58 -0
- package/dist/commands/compile/doc/delete.d.ts +15 -0
- package/dist/commands/compile/doc/delete.js +33 -0
- package/dist/commands/compile/doc/edit.d.ts +19 -0
- package/dist/commands/compile/doc/edit.js +59 -0
- package/dist/commands/compile/doc/get.d.ts +15 -0
- package/dist/commands/compile/doc/get.js +43 -0
- package/dist/commands/compile/doc/index.d.ts +24 -0
- package/dist/commands/compile/doc/index.js +211 -0
- package/dist/commands/compile/doc/list.d.ts +15 -0
- package/dist/commands/compile/doc/list.js +46 -0
- package/dist/commands/compile/doc/make.d.ts +17 -0
- package/dist/commands/compile/doc/make.js +95 -0
- package/dist/commands/compile/doc/pause.d.ts +17 -0
- package/dist/commands/compile/doc/pause.js +74 -0
- package/dist/commands/compile/doc/reset.d.ts +15 -0
- package/dist/commands/compile/doc/reset.js +33 -0
- package/dist/commands/compile/import.d.ts +20 -0
- package/dist/commands/compile/import.js +138 -0
- package/dist/commands/compile/stats.d.ts +11 -0
- package/dist/commands/compile/stats.js +75 -0
- package/dist/commands/compile/status.d.ts +17 -0
- package/dist/commands/compile/status.js +110 -0
- package/dist/commands/compile/thread/create.d.ts +16 -0
- package/dist/commands/compile/thread/create.js +42 -0
- package/dist/commands/compile/thread/delete.d.ts +15 -0
- package/dist/commands/compile/thread/delete.js +33 -0
- package/dist/commands/compile/thread/edit.d.ts +19 -0
- package/dist/commands/compile/thread/edit.js +120 -0
- package/dist/commands/compile/thread/get.d.ts +15 -0
- package/dist/commands/compile/thread/get.js +48 -0
- package/dist/commands/compile/thread/list.d.ts +14 -0
- package/dist/commands/compile/thread/list.js +38 -0
- package/dist/commands/compile/thread/make.d.ts +17 -0
- package/dist/commands/compile/thread/make.js +87 -0
- package/dist/commands/compile/thread/message.d.ts +16 -0
- package/dist/commands/compile/thread/message.js +43 -0
- package/dist/commands/compile/thread/pause.d.ts +17 -0
- package/dist/commands/compile/thread/pause.js +75 -0
- package/dist/commands/compile/thread/replace.d.ts +27 -0
- package/dist/commands/compile/thread/replace.js +114 -0
- package/dist/commands/compile/thread/reset.d.ts +15 -0
- package/dist/commands/compile/thread/reset.js +33 -0
- package/dist/commands/compile/upload.d.ts +21 -0
- package/dist/commands/compile/upload.js +162 -0
- package/dist/commands/config/clear.d.ts +12 -0
- package/dist/commands/config/clear.js +17 -0
- package/dist/commands/config/set.d.ts +15 -0
- package/dist/commands/config/set.js +43 -0
- package/dist/commands/config/show.d.ts +11 -0
- package/dist/commands/config/show.js +19 -0
- package/dist/commands/decide.d.ts +35 -0
- package/dist/commands/decide.js +242 -0
- package/dist/commands/face/attributes.d.ts +11 -0
- package/dist/commands/face/attributes.js +44 -0
- package/dist/commands/face/avatar/delete.d.ts +15 -0
- package/dist/commands/face/avatar/delete.js +38 -0
- package/dist/commands/face/avatar/get.d.ts +20 -0
- package/dist/commands/face/avatar/get.js +100 -0
- package/dist/commands/face/avatar/list.d.ts +14 -0
- package/dist/commands/face/avatar/list.js +56 -0
- package/dist/commands/face/avatar/make.d.ts +16 -0
- package/dist/commands/face/avatar/make.js +64 -0
- package/dist/commands/face/avatar/upload.d.ts +15 -0
- package/dist/commands/face/avatar/upload.js +67 -0
- package/dist/commands/face/create.d.ts +23 -0
- package/dist/commands/face/create.js +122 -0
- package/dist/commands/face/delete.d.ts +15 -0
- package/dist/commands/face/delete.js +39 -0
- package/dist/commands/face/diff.d.ts +12 -0
- package/dist/commands/face/diff.js +50 -0
- package/dist/commands/face/edit.d.ts +25 -0
- package/dist/commands/face/edit.js +155 -0
- package/dist/commands/face/get.d.ts +16 -0
- package/dist/commands/face/get.js +145 -0
- package/dist/commands/face/groups.d.ts +15 -0
- package/dist/commands/face/groups.js +34 -0
- package/dist/commands/face/list.d.ts +23 -0
- package/dist/commands/face/list.js +168 -0
- package/dist/commands/face/lock.d.ts +15 -0
- package/dist/commands/face/lock.js +35 -0
- package/dist/commands/face/neighbors.d.ts +16 -0
- package/dist/commands/face/neighbors.js +63 -0
- package/dist/commands/face/publish.d.ts +16 -0
- package/dist/commands/face/publish.js +43 -0
- package/dist/commands/face/share.d.ts +22 -0
- package/dist/commands/face/share.js +104 -0
- package/dist/commands/face/sources.d.ts +21 -0
- package/dist/commands/face/sources.js +169 -0
- package/dist/commands/face/stats.d.ts +12 -0
- package/dist/commands/face/stats.js +46 -0
- package/dist/commands/face/tag/add.d.ts +15 -0
- package/dist/commands/face/tag/add.js +40 -0
- package/dist/commands/face/tag/all.d.ts +11 -0
- package/dist/commands/face/tag/all.js +31 -0
- package/dist/commands/face/tag/list.d.ts +14 -0
- package/dist/commands/face/tag/list.js +36 -0
- package/dist/commands/face/tag/remove.d.ts +16 -0
- package/dist/commands/face/tag/remove.js +44 -0
- package/dist/commands/face/tag/set.d.ts +15 -0
- package/dist/commands/face/tag/set.js +40 -0
- package/dist/commands/face/unlock.d.ts +15 -0
- package/dist/commands/face/unlock.js +35 -0
- package/dist/commands/face/unpublish.d.ts +14 -0
- package/dist/commands/face/unpublish.js +32 -0
- package/dist/commands/face/unshare.d.ts +18 -0
- package/dist/commands/face/unshare.js +66 -0
- package/dist/commands/fidelity/get.d.ts +15 -0
- package/dist/commands/fidelity/get.js +42 -0
- package/dist/commands/fidelity/pick.d.ts +19 -0
- package/dist/commands/fidelity/pick.js +70 -0
- package/dist/commands/fidelity/run.d.ts +20 -0
- package/dist/commands/fidelity/run.js +99 -0
- package/dist/commands/fidelity/save-thread.d.ts +15 -0
- package/dist/commands/fidelity/save-thread.js +35 -0
- package/dist/commands/fidelity/start.d.ts +17 -0
- package/dist/commands/fidelity/start.js +56 -0
- package/dist/commands/fidelity/turn.d.ts +17 -0
- package/dist/commands/fidelity/turn.js +48 -0
- package/dist/commands/group/add.d.ts +16 -0
- package/dist/commands/group/add.js +83 -0
- package/dist/commands/group/create.d.ts +16 -0
- package/dist/commands/group/create.js +68 -0
- package/dist/commands/group/delete.d.ts +15 -0
- package/dist/commands/group/delete.js +39 -0
- package/dist/commands/group/edit.d.ts +18 -0
- package/dist/commands/group/edit.js +75 -0
- package/dist/commands/group/get.d.ts +14 -0
- package/dist/commands/group/get.js +29 -0
- package/dist/commands/group/list.d.ts +11 -0
- package/dist/commands/group/list.js +39 -0
- package/dist/commands/group/members.d.ts +15 -0
- package/dist/commands/group/members.js +68 -0
- package/dist/commands/group/remove.d.ts +15 -0
- package/dist/commands/group/remove.js +55 -0
- package/dist/commands/group/tag/add.d.ts +15 -0
- package/dist/commands/group/tag/add.js +30 -0
- package/dist/commands/group/tag/list.d.ts +14 -0
- package/dist/commands/group/tag/list.js +36 -0
- package/dist/commands/group/tag/remove.d.ts +15 -0
- package/dist/commands/group/tag/remove.js +30 -0
- package/dist/commands/group/tag/set.d.ts +15 -0
- package/dist/commands/group/tag/set.js +30 -0
- package/dist/commands/keys/create.d.ts +17 -0
- package/dist/commands/keys/create.js +72 -0
- package/dist/commands/keys/list.d.ts +11 -0
- package/dist/commands/keys/list.js +24 -0
- package/dist/commands/keys/revoke.d.ts +15 -0
- package/dist/commands/keys/revoke.js +49 -0
- package/dist/commands/keys/update.d.ts +17 -0
- package/dist/commands/keys/update.js +41 -0
- package/dist/commands/models/list.d.ts +15 -0
- package/dist/commands/models/list.js +98 -0
- package/dist/commands/session/close.d.ts +16 -0
- package/dist/commands/session/close.js +36 -0
- package/dist/commands/session/compact.d.ts +15 -0
- package/dist/commands/session/compact.js +58 -0
- package/dist/commands/session/create.d.ts +15 -0
- package/dist/commands/session/create.js +45 -0
- package/dist/commands/session/get.d.ts +15 -0
- package/dist/commands/session/get.js +34 -0
- package/dist/commands/style/delete.d.ts +19 -0
- package/dist/commands/style/delete.js +94 -0
- package/dist/commands/style/make.d.ts +28 -0
- package/dist/commands/style/make.js +298 -0
- package/dist/commands/style/revert.d.ts +17 -0
- package/dist/commands/style/revert.js +66 -0
- package/dist/commands/style/status.d.ts +20 -0
- package/dist/commands/style/status.js +109 -0
- package/dist/commands/style/upload.d.ts +19 -0
- package/dist/commands/style/upload.js +100 -0
- package/dist/commands/style/versions.d.ts +15 -0
- package/dist/commands/style/versions.js +104 -0
- package/dist/commands/user/follow.d.ts +14 -0
- package/dist/commands/user/follow.js +38 -0
- package/dist/commands/user/followers.d.ts +14 -0
- package/dist/commands/user/followers.js +50 -0
- package/dist/commands/user/following.d.ts +14 -0
- package/dist/commands/user/following.js +50 -0
- package/dist/commands/user/get.d.ts +14 -0
- package/dist/commands/user/get.js +49 -0
- package/dist/commands/user/unfollow.d.ts +14 -0
- package/dist/commands/user/unfollow.js +38 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +139 -0
- package/dist/decisions.d.ts +42 -0
- package/dist/decisions.js +262 -0
- package/dist/fidelity.d.ts +50 -0
- package/dist/fidelity.js +92 -0
- package/dist/group-catalog.d.ts +22 -0
- package/dist/group-catalog.js +133 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +8 -0
- package/dist/poll.d.ts +26 -0
- package/dist/poll.js +75 -0
- package/dist/routing.d.ts +15 -0
- package/dist/routing.js +135 -0
- package/dist/session.d.ts +14 -0
- package/dist/session.js +18 -0
- package/dist/style.d.ts +46 -0
- package/dist/style.js +285 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +865 -0
- package/oclif.manifest.json +11070 -0
- package/package.json +127 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Headwaters Lab Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,159 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Faces CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line interface for [Faces](https://faces.sh). Faces are causal models: compile one from an
|
|
4
|
+
author's source texts, and when prompted it returns a **cause**, the principal *why* behind that
|
|
5
|
+
author's response in context. Get the cause alone, or let it steer any supported model through the
|
|
6
|
+
chat and decision wrappers.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @faces-sh/cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Node.js >= 18. Formerly published as `faces-cli`.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Register or log in: you will be asked for your password
|
|
20
|
+
faces auth:register --email you@example.com --username you
|
|
21
|
+
faces auth:login --email you@example.com
|
|
22
|
+
|
|
23
|
+
# Create a face
|
|
24
|
+
faces face:create --name "Alice" --alias alice --default-model gpt-5.4-mini \
|
|
25
|
+
--attr gender=woman --attr age=29 --attr occupation="Works as a product designer."
|
|
26
|
+
|
|
27
|
+
# Add source texts and compile: her own writing as a document, an interview as a thread
|
|
28
|
+
faces compile:doc alice --file essay.txt --medium essay
|
|
29
|
+
faces compile:upload alice --file interview.txt --kind thread --face-speaker Alice
|
|
30
|
+
|
|
31
|
+
# The cause alone
|
|
32
|
+
faces causes alice -m "Should I take the offer?"
|
|
33
|
+
|
|
34
|
+
# Chat: the face's cause steers the model's answer
|
|
35
|
+
faces chat:chat alice -m "What matters most to you?"
|
|
36
|
+
faces chat:chat alice -m "Tell me more" --llm claude-sonnet-4-6 --show-cause
|
|
37
|
+
|
|
38
|
+
# Decide: typed answers, with a cause per question
|
|
39
|
+
faces decide alice --state "A colleague asks you to sign a proposal you have not read." \
|
|
40
|
+
--question "Does the speaker sign?"
|
|
41
|
+
|
|
42
|
+
# Compare and compose
|
|
43
|
+
faces face:diff --face alice --face bob
|
|
44
|
+
faces face:create --name "Alice-Bob" --alias alice-bob --formula "alice | bob"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
faces auth:login / logout / register / whoami / refresh
|
|
51
|
+
faces auth:connect / disconnect / connections
|
|
52
|
+
|
|
53
|
+
faces face:create / list / get / edit / delete / stats / attributes / sources
|
|
54
|
+
faces face:diff / neighbors / lock / unlock / publish / unpublish / share / unshare / groups
|
|
55
|
+
faces face:avatar:list / get / make / upload / delete
|
|
56
|
+
faces face:tag:add / list / remove / set / all
|
|
57
|
+
|
|
58
|
+
faces causes # a face's cause alone
|
|
59
|
+
faces chat:chat / messages / responses / thread
|
|
60
|
+
faces decide # what a face would decide: yes/no, a choice, or a score
|
|
61
|
+
faces session:create / get / compact / close
|
|
62
|
+
|
|
63
|
+
faces compile:doc / compile:doc:create / list / get / edit / make / pause / reset / delete
|
|
64
|
+
faces compile:thread:create / list / get / edit / message / replace / make / pause / reset / delete
|
|
65
|
+
faces compile:upload / import / all / status / stats
|
|
66
|
+
|
|
67
|
+
faces style:upload / make / status / versions / revert / delete
|
|
68
|
+
|
|
69
|
+
faces models:list # the models you can name; --kind takes a list, or all
|
|
70
|
+
faces benchmark:start / get / list
|
|
71
|
+
faces fidelity:start / turn / pick / get / run / save-thread
|
|
72
|
+
|
|
73
|
+
faces group:create / list / get / edit / delete / members / add / remove
|
|
74
|
+
faces group:tag:add / list / remove / set
|
|
75
|
+
faces user:get / follow / unfollow / followers / following
|
|
76
|
+
|
|
77
|
+
faces catalog:list / doctor / backup / restore
|
|
78
|
+
|
|
79
|
+
faces keys:create / list / revoke / update
|
|
80
|
+
|
|
81
|
+
faces billing:balance / usage / llm-costs / topup / cards / card-setup / card:default / card:remove
|
|
82
|
+
faces billing:subscription / subscription:activate / subscription:plan / subscription:cancel
|
|
83
|
+
|
|
84
|
+
faces account:state / preferences
|
|
85
|
+
|
|
86
|
+
faces config:set / show / clear
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Run `faces <command> --help` for details on any command. Every command takes `--json`, and
|
|
90
|
+
`--toon` for a more compact encoding of the same data.
|
|
91
|
+
|
|
92
|
+
## Documents and threads
|
|
93
|
+
|
|
94
|
+
A **document** is the face's own writing: an essay, a letter, a paper, a book, a poem. Every word
|
|
95
|
+
in it is read as the face's. Writing about the face by someone else can also be a document, with
|
|
96
|
+
`--perspective third-person`.
|
|
97
|
+
|
|
98
|
+
An interview, transcript, dialogue or any other exchange between speakers is a **thread**. Upload
|
|
99
|
+
it with `--kind thread` and `--face-speaker` naming the face, so only the face's turns are used:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
faces compile:upload alice --file interview.txt --kind thread --face-speaker Alice
|
|
103
|
+
faces compile:upload alice --file podcast.mp3 --kind thread --face-speaker A
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
A labelled dialogue uploaded as a document is read as entirely the face's own words, other
|
|
107
|
+
speakers included. The document commands warn when a text file reads as a transcript.
|
|
108
|
+
|
|
109
|
+
## Styles
|
|
110
|
+
|
|
111
|
+
A style is built from a face's own writing in one medium, and applied on chat with `--style`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
faces style:make alice --all
|
|
115
|
+
faces chat:chat alice -m "Reply to the note below." --style email
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`--medium` says what the reply is without applying a built style. A style adds roughly 2,000 to
|
|
119
|
+
3,500 input tokens per request.
|
|
120
|
+
|
|
121
|
+
A build runs at no charge on Connect or Pro with a linked ChatGPT account. Anywhere else it is
|
|
122
|
+
charged to credits at the build model's listed price, so `style:make` needs `--allow-paid`.
|
|
123
|
+
|
|
124
|
+
## Sessions
|
|
125
|
+
|
|
126
|
+
A session groups the turns of one conversation with one face. Compacting it returns a summary
|
|
127
|
+
under a compaction id, which a later request reads in place of the history you no longer send.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
faces session:create alice
|
|
131
|
+
faces chat:chat alice -m "Should I take the offer?" --session fs_SESSION_ID
|
|
132
|
+
faces session:compact fs_SESSION_ID
|
|
133
|
+
faces chat:chat alice -m "So what do I tell them tomorrow?" --compaction fcmp_COMPACTION_ID
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Authentication
|
|
137
|
+
|
|
138
|
+
Login stores a JWT at `~/.faces/config.json`. You can also authenticate with environment variables:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
export FACES_API_KEY=sk-faces-...
|
|
142
|
+
export FACES_TOKEN=your_jwt
|
|
143
|
+
export FACES_BASE_URL=https://api.faces.sh # optional override
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Plans
|
|
147
|
+
|
|
148
|
+
- **Free**: a $5 activation, added as credits. Everything is paid as it goes, from credits.
|
|
149
|
+
- **Connect** ($17/month) and **Pro** ($49/month): monthly compile and cause allowances. Link a
|
|
150
|
+
ChatGPT account with `faces auth:connect openai`, and Codex-eligible models
|
|
151
|
+
(`faces models:list --chatgpt`) run on the ChatGPT plan at `/v1/responses`. The cause is still billed, from the
|
|
152
|
+
allowance and then credits.
|
|
153
|
+
|
|
154
|
+
Answering models are charged at the model's listed price plus 5%. Current prices: `faces models:list`
|
|
155
|
+
and `faces billing:llm-costs`.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT. Copyright (c) 2026 Headwaters Lab Inc.
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { FacesClient } from './client.js';
|
|
3
|
+
export declare abstract class BaseCommand extends Command {
|
|
4
|
+
static enableJsonFlag: boolean;
|
|
5
|
+
static baseFlags: {
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
protected toonEnabled(): boolean;
|
|
12
|
+
jsonEnabled(): boolean;
|
|
13
|
+
logJson(json: unknown): void;
|
|
14
|
+
protected makeClient(flags: {
|
|
15
|
+
'base-url'?: string;
|
|
16
|
+
token?: string;
|
|
17
|
+
'api-key'?: string;
|
|
18
|
+
}, _requireJwt?: boolean): FacesClient;
|
|
19
|
+
private apiClient?;
|
|
20
|
+
catch(err: Error & {
|
|
21
|
+
exitCode?: number;
|
|
22
|
+
}): Promise<unknown>;
|
|
23
|
+
protected confirmOrRefuse(message: string, yes: boolean): Promise<void>;
|
|
24
|
+
protected secretOrPrompt(value: string | undefined, flag: string, label: string): Promise<string>;
|
|
25
|
+
protected printHuman(data: unknown, indent?: number): void;
|
|
26
|
+
}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
import { Command, Flags, ux } from '@oclif/core';
|
|
3
|
+
import { encode as encodeToon } from '@toon-format/toon';
|
|
4
|
+
import { FacesAPIError, FacesClient } from './client.js';
|
|
5
|
+
import { resolveBaseUrl, resolveCredentials } from './config.js';
|
|
6
|
+
import { compileFieldLine } from './utils.js';
|
|
7
|
+
export class BaseCommand extends Command {
|
|
8
|
+
static enableJsonFlag = true;
|
|
9
|
+
static baseFlags = {
|
|
10
|
+
'base-url': Flags.string({
|
|
11
|
+
description: 'API base URL',
|
|
12
|
+
env: 'FACES_BASE_URL',
|
|
13
|
+
}),
|
|
14
|
+
token: Flags.string({
|
|
15
|
+
description: 'JWT bearer token',
|
|
16
|
+
env: 'FACES_TOKEN',
|
|
17
|
+
}),
|
|
18
|
+
'api-key': Flags.string({
|
|
19
|
+
description: 'API key',
|
|
20
|
+
env: 'FACES_API_KEY',
|
|
21
|
+
}),
|
|
22
|
+
toon: Flags.boolean({
|
|
23
|
+
description: 'Format output as TOON instead of JSON: the same data and field names in a more compact ' +
|
|
24
|
+
'encoding, for agents that pay for their input. Measured across this CLI it is about 40% fewer ' +
|
|
25
|
+
'tokens than --json.',
|
|
26
|
+
default: false,
|
|
27
|
+
exclusive: ['json'],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
toonEnabled() {
|
|
31
|
+
const passThrough = this.argv.indexOf('--');
|
|
32
|
+
const i = this.argv.indexOf('--toon');
|
|
33
|
+
if (i === -1)
|
|
34
|
+
return false;
|
|
35
|
+
if (this.argv.includes('--json'))
|
|
36
|
+
return false;
|
|
37
|
+
return passThrough === -1 || i < passThrough;
|
|
38
|
+
}
|
|
39
|
+
jsonEnabled() {
|
|
40
|
+
return this.toonEnabled() || super.jsonEnabled();
|
|
41
|
+
}
|
|
42
|
+
logJson(json) {
|
|
43
|
+
if (this.toonEnabled()) {
|
|
44
|
+
ux.stdout(encodeToon(json));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
super.logJson(json);
|
|
48
|
+
}
|
|
49
|
+
makeClient(flags, _requireJwt = false) {
|
|
50
|
+
const baseUrl = resolveBaseUrl(flags['base-url']);
|
|
51
|
+
const { token, apiKey, withheld, keySaved } = resolveCredentials(flags, baseUrl);
|
|
52
|
+
this.apiClient = new FacesClient(baseUrl, token, apiKey, withheld, keySaved);
|
|
53
|
+
return this.apiClient;
|
|
54
|
+
}
|
|
55
|
+
apiClient;
|
|
56
|
+
async catch(err) {
|
|
57
|
+
if (this.jsonEnabled()) {
|
|
58
|
+
const code = err.oclif?.exit ?? err.exitCode ?? 1;
|
|
59
|
+
const error = { message: err.message, code };
|
|
60
|
+
const api = err instanceof FacesAPIError ? err : this.apiClient?.lastError;
|
|
61
|
+
if (api) {
|
|
62
|
+
error.status = api.statusCode;
|
|
63
|
+
if (api.errorCode)
|
|
64
|
+
error.error_code = api.errorCode;
|
|
65
|
+
if (api.fallbackAvailable !== undefined)
|
|
66
|
+
error.fallback_available = api.fallbackAvailable;
|
|
67
|
+
if (api.retryAfter !== undefined)
|
|
68
|
+
error.retry_after = api.retryAfter;
|
|
69
|
+
if (typeof api.details?.rush_premium_usd === 'number')
|
|
70
|
+
error.rush_premium_usd = api.details.rush_premium_usd;
|
|
71
|
+
if (typeof api.details?.estimated_usd === 'number')
|
|
72
|
+
error.estimated_usd = api.details.estimated_usd;
|
|
73
|
+
if (typeof api.details?.balance_usd === 'number')
|
|
74
|
+
error.balance_usd = api.details.balance_usd;
|
|
75
|
+
}
|
|
76
|
+
const payload = { error };
|
|
77
|
+
process.stdout.write((this.toonEnabled() ? encodeToon(payload) : JSON.stringify(payload)) + '\n');
|
|
78
|
+
process.exit(code);
|
|
79
|
+
}
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
async confirmOrRefuse(message, yes) {
|
|
83
|
+
if (yes)
|
|
84
|
+
return;
|
|
85
|
+
if (this.jsonEnabled() || !process.stdin.isTTY) {
|
|
86
|
+
this.error(`${message}\nRe-run with --yes to confirm. Nothing was changed.`);
|
|
87
|
+
}
|
|
88
|
+
const answer = await new Promise((resolve) => {
|
|
89
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
90
|
+
rl.question(`${message} [y/N] `, (a) => {
|
|
91
|
+
rl.close();
|
|
92
|
+
resolve(a);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
if (answer.trim().toLowerCase() !== 'y')
|
|
96
|
+
this.error('Aborted. Nothing was changed.');
|
|
97
|
+
}
|
|
98
|
+
async secretOrPrompt(value, flag, label) {
|
|
99
|
+
if (value !== undefined)
|
|
100
|
+
return value;
|
|
101
|
+
if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== 'function') {
|
|
102
|
+
this.error(`--${flag} is required when not running in a terminal.`);
|
|
103
|
+
}
|
|
104
|
+
const typed = await new Promise((resolve) => {
|
|
105
|
+
const stdin = process.stdin;
|
|
106
|
+
let buf = '';
|
|
107
|
+
process.stderr.write(`${label}: `);
|
|
108
|
+
stdin.setRawMode(true);
|
|
109
|
+
stdin.resume();
|
|
110
|
+
stdin.setEncoding('utf8');
|
|
111
|
+
const done = (result) => {
|
|
112
|
+
stdin.setRawMode(false);
|
|
113
|
+
stdin.pause();
|
|
114
|
+
stdin.removeListener('data', onData);
|
|
115
|
+
process.stderr.write('\n');
|
|
116
|
+
resolve(result);
|
|
117
|
+
};
|
|
118
|
+
const onData = (chunk) => {
|
|
119
|
+
for (const ch of chunk) {
|
|
120
|
+
if (ch === '\r' || ch === '\n' || ch === '\u0004')
|
|
121
|
+
return done(buf);
|
|
122
|
+
if (ch === '\u0003')
|
|
123
|
+
return done(null);
|
|
124
|
+
if (ch === '\u007f' || ch === '\b')
|
|
125
|
+
buf = buf.slice(0, -1);
|
|
126
|
+
else if (ch >= ' ')
|
|
127
|
+
buf += ch;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
stdin.on('data', onData);
|
|
131
|
+
});
|
|
132
|
+
if (typed === null)
|
|
133
|
+
this.error('Aborted.');
|
|
134
|
+
if (typed === '')
|
|
135
|
+
this.error(`No ${label.toLowerCase()} entered.`);
|
|
136
|
+
return typed;
|
|
137
|
+
}
|
|
138
|
+
printHuman(data, indent = 0) {
|
|
139
|
+
const prefix = ' '.repeat(indent);
|
|
140
|
+
if (Array.isArray(data)) {
|
|
141
|
+
if (data.length === 0) {
|
|
142
|
+
this.log(`${prefix}(empty)`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (data.every((v) => v === null || typeof v !== 'object')) {
|
|
146
|
+
this.log(`${prefix}[${data.map((v) => String(v)).join(', ')}]`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (const [i, item] of data.entries()) {
|
|
150
|
+
this.log(`${prefix}[${i}]`);
|
|
151
|
+
this.printHuman(item, indent + 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (data !== null && typeof data === 'object') {
|
|
155
|
+
for (const [k, v] of Object.entries(data)) {
|
|
156
|
+
if (k === 'read_only') {
|
|
157
|
+
if (v)
|
|
158
|
+
this.log(`${prefix}read only`);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const line = compileFieldLine(k, v);
|
|
162
|
+
if (line === null)
|
|
163
|
+
continue;
|
|
164
|
+
if (line !== undefined) {
|
|
165
|
+
this.log(`${prefix}${line}`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (v !== null && typeof v === 'object') {
|
|
169
|
+
this.log(`${prefix}${k}:`);
|
|
170
|
+
this.printHuman(v, indent + 1);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this.log(`${prefix}${k}: ${v}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this.log(`${prefix}${data}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FacesAPIError, FacesClient } from './client.js';
|
|
2
|
+
export declare const BENCHMARK_RUNS = "/v1/benchmark/runs";
|
|
3
|
+
export interface BenchmarkRun {
|
|
4
|
+
run_id: string;
|
|
5
|
+
self_face?: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
reference_model?: string;
|
|
9
|
+
progress?: {
|
|
10
|
+
rounds_done?: number;
|
|
11
|
+
rounds_total?: number;
|
|
12
|
+
} | null;
|
|
13
|
+
result?: Record<string, unknown> | null;
|
|
14
|
+
error?: string | null;
|
|
15
|
+
created_at?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function resultLines(r: Record<string, unknown>): string[];
|
|
18
|
+
export declare function runLines(run: BenchmarkRun): string[];
|
|
19
|
+
export declare function benchmarkHint(err: FacesAPIError, face?: string): string | undefined;
|
|
20
|
+
export declare function benchmarkError(err: FacesAPIError, face?: string): string;
|
|
21
|
+
export declare function followRun(client: FacesClient, id: string, onProgress: (line: string) => unknown): Promise<BenchmarkRun>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { seg, usd } from './utils.js';
|
|
2
|
+
export const BENCHMARK_RUNS = '/v1/benchmark/runs';
|
|
3
|
+
const num = (v, places = 2) => (typeof v === 'number' && Number.isFinite(v) ? v.toFixed(places) : '-');
|
|
4
|
+
const signed = (v) => (typeof v === 'number' && Number.isFinite(v) ? `${v >= 0 ? '+' : ''}${v.toFixed(2)}` : '-');
|
|
5
|
+
function interval(ci) {
|
|
6
|
+
const c = ci;
|
|
7
|
+
if (!c)
|
|
8
|
+
return '';
|
|
9
|
+
return ` (95% interval ${signed(c.lo)} to ${signed(c.hi)}${c.resolved ? '' : ', too close to call'})`;
|
|
10
|
+
}
|
|
11
|
+
function winnerOf(w) {
|
|
12
|
+
return w === 'face' ? 'the face' : w === 'reference' ? 'the reference model' : 'neither, too close to call';
|
|
13
|
+
}
|
|
14
|
+
function sliceLine(name, s) {
|
|
15
|
+
const parts = [`face ${num(s.face)}`, `reference ${num(s.reference)}`];
|
|
16
|
+
if (s.gap !== undefined)
|
|
17
|
+
parts.push(`gap ${signed(s.gap)}`);
|
|
18
|
+
if (s.winner)
|
|
19
|
+
parts.push(`won by ${s.winner}`);
|
|
20
|
+
return ` ${name}: ${parts.join(', ')} (${s.rounds ?? 0} rounds)`;
|
|
21
|
+
}
|
|
22
|
+
export function resultLines(r) {
|
|
23
|
+
const lines = [
|
|
24
|
+
`winner: ${winnerOf(r.winner)}`,
|
|
25
|
+
`gap: ${signed(r.gap)}${interval(r.ci95)}`,
|
|
26
|
+
`scores: face ${num(r.face)}, reference ${num(r.reference)}`,
|
|
27
|
+
`rounds: ${r.rounds_fought ?? '-'} of ${r.rounds_requested ?? '-'}${r.stopped_early ? ', stopped early at the spend cap' : ''}`,
|
|
28
|
+
];
|
|
29
|
+
const usage = (r.usage ?? {});
|
|
30
|
+
if (usage.spend_usd !== undefined) {
|
|
31
|
+
lines.push(`spent: ${usd(usage.spend_usd)}${usage.budget_usd ? ` of a ${usd(usage.budget_usd)} cap` : ''}`);
|
|
32
|
+
}
|
|
33
|
+
if (r.seed !== undefined && r.seed !== null)
|
|
34
|
+
lines.push(`seed: ${r.seed} (pass --seed ${r.seed} to draw the same rounds again)`);
|
|
35
|
+
for (const [label, key] of [['by length', 'by_length'], ['by medium', 'by_medium']]) {
|
|
36
|
+
const slices = Object.entries((r[key] ?? {}));
|
|
37
|
+
if (slices.length === 0)
|
|
38
|
+
continue;
|
|
39
|
+
lines.push(`${label}:`);
|
|
40
|
+
for (const [name, s] of slices)
|
|
41
|
+
lines.push(sliceLine(name, s));
|
|
42
|
+
}
|
|
43
|
+
for (const w of r.warnings ?? [])
|
|
44
|
+
lines.push(`warning: ${w}`);
|
|
45
|
+
return lines;
|
|
46
|
+
}
|
|
47
|
+
export function runLines(run) {
|
|
48
|
+
const lines = [
|
|
49
|
+
`run: ${run.run_id}`,
|
|
50
|
+
`face: ${run.self_face ?? '-'} on ${run.model ?? '-'}`,
|
|
51
|
+
`reference: ${run.reference_model ?? '-'}`,
|
|
52
|
+
`status: ${run.status ?? '-'}`,
|
|
53
|
+
];
|
|
54
|
+
const p = run.progress;
|
|
55
|
+
if (p?.rounds_total)
|
|
56
|
+
lines.push(`progress: ${p.rounds_done ?? 0} of ${p.rounds_total} rounds`);
|
|
57
|
+
if (run.error)
|
|
58
|
+
lines.push(`error: ${run.error}`);
|
|
59
|
+
if (run.result)
|
|
60
|
+
lines.push('', ...resultLines(run.result));
|
|
61
|
+
return lines;
|
|
62
|
+
}
|
|
63
|
+
export function benchmarkHint(err, face) {
|
|
64
|
+
const alias = face ?? '<alias>';
|
|
65
|
+
if (err.errorCode === 'benchmark_no_compiled_corpus')
|
|
66
|
+
return `Add a source with: faces compile:upload ${alias} --file <file>`;
|
|
67
|
+
if (err.errorCode === 'benchmark_no_style')
|
|
68
|
+
return `Build its style with: faces style:make ${alias} --all`;
|
|
69
|
+
if (err.errorCode === 'benchmark_insufficient_credit')
|
|
70
|
+
return 'Lower --rounds or --max-spend, or add credit: faces billing:topup --amount <usd>';
|
|
71
|
+
if (err.statusCode === 400 && /model/i.test(err.message))
|
|
72
|
+
return 'List the models with: faces models:list';
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
export function benchmarkError(err, face) {
|
|
76
|
+
const hint = benchmarkHint(err, face);
|
|
77
|
+
return `HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`;
|
|
78
|
+
}
|
|
79
|
+
export async function followRun(client, id, onProgress) {
|
|
80
|
+
let last = '';
|
|
81
|
+
for (;;) {
|
|
82
|
+
const run = (await client.get(`${BENCHMARK_RUNS}/${seg(id)}`));
|
|
83
|
+
if (run.status === 'done' || run.status === 'failed') {
|
|
84
|
+
if (run.status === 'failed')
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
return run;
|
|
87
|
+
}
|
|
88
|
+
const p = run.progress;
|
|
89
|
+
const now = p?.rounds_total ? `${p.rounds_done ?? 0}/${p.rounds_total} rounds` : String(run.status);
|
|
90
|
+
if (now !== last)
|
|
91
|
+
onProgress(now);
|
|
92
|
+
last = now;
|
|
93
|
+
await new Promise((r) => setTimeout(r, 10_000));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PAID_PLANS: readonly ["connect", "pro"];
|
|
2
|
+
export type PaidPlan = (typeof PAID_PLANS)[number];
|
|
3
|
+
export declare const PLAN_PRICE: Record<PaidPlan, string>;
|
|
4
|
+
export declare function planName(plan: unknown): string;
|
|
5
|
+
export declare function tokens(n: unknown): string;
|
|
6
|
+
export declare function percentUsed(used: number, limit: number): string;
|
|
7
|
+
export declare function allowanceLines(sub: Record<string, unknown>): string[];
|
|
8
|
+
export interface Card {
|
|
9
|
+
id: string;
|
|
10
|
+
brand?: string;
|
|
11
|
+
last4?: string;
|
|
12
|
+
exp_month?: number;
|
|
13
|
+
exp_year?: number;
|
|
14
|
+
is_default?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function cardLine(c: Card): string;
|
|
17
|
+
export declare function llmCostLab(row: Record<string, unknown>): string;
|
package/dist/billing.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export const PAID_PLANS = ['connect', 'pro'];
|
|
2
|
+
export const PLAN_PRICE = {
|
|
3
|
+
connect: '$17/month',
|
|
4
|
+
pro: '$49/month',
|
|
5
|
+
};
|
|
6
|
+
export function planName(plan) {
|
|
7
|
+
const p = String(plan ?? '');
|
|
8
|
+
return p ? p[0].toUpperCase() + p.slice(1) : 'unknown';
|
|
9
|
+
}
|
|
10
|
+
const ALLOWANCES = [
|
|
11
|
+
['cause_5h', 'causes, rolling 5 hours'],
|
|
12
|
+
['cause_week', 'causes, this week'],
|
|
13
|
+
['cause_month', 'causes, this month'],
|
|
14
|
+
['compile_month', 'compile, this month'],
|
|
15
|
+
];
|
|
16
|
+
export function tokens(n) {
|
|
17
|
+
if (typeof n !== 'number' || !Number.isFinite(n))
|
|
18
|
+
return '-';
|
|
19
|
+
const millions = () => `${Math.floor(n / 10_000) / 100}M`;
|
|
20
|
+
const abs = Math.abs(n);
|
|
21
|
+
if (abs >= 1_000_000)
|
|
22
|
+
return millions();
|
|
23
|
+
if (abs >= 10_000)
|
|
24
|
+
return `${Math.floor(n / 100) / 10}k`;
|
|
25
|
+
return String(n);
|
|
26
|
+
}
|
|
27
|
+
export function percentUsed(used, limit) {
|
|
28
|
+
const pct = Math.floor((used / limit) * 100);
|
|
29
|
+
return pct === 0 && used > 0 ? '<1%' : `${pct}%`;
|
|
30
|
+
}
|
|
31
|
+
function when(ts) {
|
|
32
|
+
if (typeof ts !== 'string' || !ts)
|
|
33
|
+
return undefined;
|
|
34
|
+
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(ts);
|
|
35
|
+
return m ? `${m[1]} ${m[2]} UTC` : ts;
|
|
36
|
+
}
|
|
37
|
+
export function allowanceLines(sub) {
|
|
38
|
+
const all = sub.allowances;
|
|
39
|
+
if (!all || typeof all !== 'object')
|
|
40
|
+
return [];
|
|
41
|
+
const rows = ALLOWANCES.filter(([key]) => all[key]).map(([key, label]) => {
|
|
42
|
+
const a = all[key];
|
|
43
|
+
const unlimited = typeof a.limit === 'number' && a.limit < 0;
|
|
44
|
+
const none = a.limit === 0;
|
|
45
|
+
let amount;
|
|
46
|
+
if (unlimited) {
|
|
47
|
+
amount = `${tokens(a.used)} used, unlimited`;
|
|
48
|
+
}
|
|
49
|
+
else if (none) {
|
|
50
|
+
amount = 'none, paid per token';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const pct = typeof a.used === 'number' && typeof a.limit === 'number' && a.limit > 0
|
|
54
|
+
? ` (${percentUsed(a.used, a.limit)})`
|
|
55
|
+
: '';
|
|
56
|
+
amount = `${tokens(a.used)} of ${tokens(a.limit)}${pct}`;
|
|
57
|
+
}
|
|
58
|
+
const reset = when(a.resets_at);
|
|
59
|
+
return { label, amount, tail: unlimited || none ? '' : (reset ? `resets ${reset}` : 'rolls') };
|
|
60
|
+
});
|
|
61
|
+
for (const [key, a] of Object.entries(all)) {
|
|
62
|
+
if (ALLOWANCES.some(([k]) => k === key) || !a || typeof a !== 'object')
|
|
63
|
+
continue;
|
|
64
|
+
const amount = typeof a.limit === 'number' && a.limit < 0
|
|
65
|
+
? `${tokens(a.used)} used, unlimited`
|
|
66
|
+
: a.limit === 0 ? 'none, paid per token' : `${tokens(a.used)} of ${tokens(a.limit)}`;
|
|
67
|
+
rows.push({ label: key, amount, tail: a.limit !== 0 && when(a.resets_at) ? `resets ${when(a.resets_at)}` : '' });
|
|
68
|
+
}
|
|
69
|
+
if (rows.length === 0)
|
|
70
|
+
return [];
|
|
71
|
+
const lw = Math.max(...rows.map((r) => r.label.length));
|
|
72
|
+
const aw = Math.max(...rows.map((r) => r.amount.length));
|
|
73
|
+
const lines = [`${planName(sub.plan)} allowances (tokens):`];
|
|
74
|
+
for (const r of rows)
|
|
75
|
+
lines.push(` ${r.label.padEnd(lw)} ${r.amount.padEnd(aw)} ${r.tail}`.trimEnd());
|
|
76
|
+
const unlimited = rows.every((r) => r.amount.endsWith('unlimited'));
|
|
77
|
+
if (!unlimited) {
|
|
78
|
+
const rates = sub.rates;
|
|
79
|
+
let past = 'Past an allowance, api_fallback on pays from your credits; off refuses with a 429 until it resets.';
|
|
80
|
+
if (rates && typeof rates.cause_usd_per_million_input_tokens === 'number' && typeof rates.compile_usd_per_million_source_tokens === 'number') {
|
|
81
|
+
const added = typeof rates.cause_added_tokens === 'number' && rates.cause_added_tokens > 0
|
|
82
|
+
? `, each cause counting its input tokens plus ${rates.cause_added_tokens.toLocaleString('en-US')},`
|
|
83
|
+
: '';
|
|
84
|
+
const rush = typeof rates.compile_rush_usd_per_million_source_tokens === 'number'
|
|
85
|
+
? ` ($${rates.compile_rush_usd_per_million_source_tokens} for a rush)`
|
|
86
|
+
: '';
|
|
87
|
+
past +=
|
|
88
|
+
` Credits pay $${rates.cause_usd_per_million_input_tokens} per million cause tokens${added} and ` +
|
|
89
|
+
`$${rates.compile_usd_per_million_source_tokens} per million compile tokens${rush}.`;
|
|
90
|
+
}
|
|
91
|
+
lines.push(` ${past}`);
|
|
92
|
+
}
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
95
|
+
export function cardLine(c) {
|
|
96
|
+
const exp = c.exp_month && c.exp_year ? `, expires ${String(c.exp_month).padStart(2, '0')}/${c.exp_year}` : '';
|
|
97
|
+
return `${c.brand ?? 'card'} ending ${c.last4 ?? '????'}${exp} ${c.id}${c.is_default ? ' (default)' : ''}`;
|
|
98
|
+
}
|
|
99
|
+
export function llmCostLab(row) {
|
|
100
|
+
return typeof row.lab === 'string' ? row.lab : '';
|
|
101
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const CATALOG_DIR: string;
|
|
2
|
+
export declare const CATALOG_INDEX: string;
|
|
3
|
+
export interface FaceFrontmatter {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
alias: string;
|
|
7
|
+
attributes?: Record<string, string>;
|
|
8
|
+
tags?: string[];
|
|
9
|
+
default_model?: string;
|
|
10
|
+
formula?: string | null;
|
|
11
|
+
component_counts?: number[];
|
|
12
|
+
compiled_tokens?: number;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface FaceDataInput {
|
|
16
|
+
name: string;
|
|
17
|
+
alias: string;
|
|
18
|
+
uid?: string;
|
|
19
|
+
description?: string | null;
|
|
20
|
+
basic_facts?: Record<string, string | {
|
|
21
|
+
value: string;
|
|
22
|
+
}> | null;
|
|
23
|
+
tags?: string[] | null;
|
|
24
|
+
default_model?: string | null;
|
|
25
|
+
formula?: string | null;
|
|
26
|
+
component_counts?: number[] | null;
|
|
27
|
+
compile_tokens_synced?: number | null;
|
|
28
|
+
}
|
|
29
|
+
export declare class CatalogService {
|
|
30
|
+
isEnabled(): boolean;
|
|
31
|
+
writeFace(faceData: FaceDataInput, description?: string): void;
|
|
32
|
+
deleteFace(alias: string): void;
|
|
33
|
+
updateTags(alias: string, tags: string[]): void;
|
|
34
|
+
rebuildIndex(): void;
|
|
35
|
+
}
|