@dench.com/cli 0.2.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.
- package/README.md +151 -0
- package/agentKind.ts +58 -0
- package/crm.ts +1402 -0
- package/dench +10 -0
- package/dench.mjs +10 -0
- package/dench.ts +3305 -0
- package/fs-daemon +10 -0
- package/fs-daemon.ts +682 -0
- package/host.ts +44 -0
- package/lib/cli-args.ts +52 -0
- package/openUrl.ts +120 -0
- package/package.json +35 -0
- package/session.ts +504 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Dench CLI
|
|
2
|
+
|
|
3
|
+
Agent-facing CLI for the Dench agent workspace.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Run without installing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -y dench-cli login --name "AI Agent - Billing Repo"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install globally:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g dench-cli
|
|
17
|
+
dench login --name "AI Agent - Billing Repo"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`--kind` accepts any string. Suggested values: `claude_code`, `codex`, `cursor`,
|
|
21
|
+
`hermes`, `openclaw`, or any custom kind such as `aider`, `goose`, or
|
|
22
|
+
`some_custom_agent`. Defaults to `other` when omitted. Values are normalized
|
|
23
|
+
to lowercase snake_case before send (e.g. `--kind "Claude Code"` becomes
|
|
24
|
+
`claude_code`).
|
|
25
|
+
|
|
26
|
+
The default host is `https://dench.dev`.
|
|
27
|
+
|
|
28
|
+
The smooth setup flow is:
|
|
29
|
+
|
|
30
|
+
1. Run `dench login --name "AI Agent - Billing Repo"` once.
|
|
31
|
+
2. Let the CLI open the approval link. If it cannot, ask the human to open the
|
|
32
|
+
printed link and confirm the email/workspace. Use `--no-open` to print the
|
|
33
|
+
link without opening it.
|
|
34
|
+
3. Run `dench status --mine --json` and `dench tasks --json` to verify setup.
|
|
35
|
+
|
|
36
|
+
The CLI selects the approved session for later commands automatically.
|
|
37
|
+
Setup is complete after approval, both verification commands work, and you know
|
|
38
|
+
which Dench agent/session is selected.
|
|
39
|
+
|
|
40
|
+
Approval happens in the human's browser and uses the currently selected Dench
|
|
41
|
+
workspace. The human should switch to the intended workspace before approving.
|
|
42
|
+
The CLI opens the approval link automatically when possible. If opening fails,
|
|
43
|
+
use the printed link manually.
|
|
44
|
+
|
|
45
|
+
If multiple sessions already exist, do not log in again to fix ambiguity and do
|
|
46
|
+
not silently guess from the newest timestamp, agent name, or kind. List sessions
|
|
47
|
+
and ask the human which exact session to use:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
dench sessions
|
|
51
|
+
dench use <session-key-or-workspace-slug>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Use a human-readable `DENCH_SESSION_KEY` at login time only for long-lived
|
|
55
|
+
agents or when the human asks for a stable identity:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
DENCH_SESSION_KEY=billing-repo-agent dench login --name "AI Agent - Billing Repo"
|
|
59
|
+
DENCH_SESSION_KEY=billing-repo-agent dench status --mine --json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Do not set `DENCH_SESSION_KEY` to values like `auto:...` or `explicit:...`.
|
|
63
|
+
Those are internal scopes shown by `dench sessions`; select them with
|
|
64
|
+
`dench use <session-key-or-workspace-slug>` instead.
|
|
65
|
+
|
|
66
|
+
`dench logout` removes only the current selected session for this local agent
|
|
67
|
+
context. Other saved sessions can still be reused by future chats. To remove the
|
|
68
|
+
wrong local session, run `dench logout --session <session-key>`. Use
|
|
69
|
+
`dench logout --all` only when you want to clear every local Dench session.
|
|
70
|
+
|
|
71
|
+
Do not create or edit local agent memory files during setup. Use Dench logs for
|
|
72
|
+
meaningful progress, and use Dench memory only when the human asks or when
|
|
73
|
+
saving a stable workspace fact.
|
|
74
|
+
|
|
75
|
+
Do not create, claim, or log a setup task by default. Only create or claim a
|
|
76
|
+
task if the human assigns work, an open matching task exists, or coordination
|
|
77
|
+
benefits from creating one. For ad-hoc requests, work directly and only log
|
|
78
|
+
meaningful work.
|
|
79
|
+
|
|
80
|
+
Use `dench context` when you need to know who you are, which workspace you are
|
|
81
|
+
using, assigned tasks, pending approvals you requested, connected apps, and the
|
|
82
|
+
best next commands. Add `--json` for structured output.
|
|
83
|
+
|
|
84
|
+
## Billing
|
|
85
|
+
|
|
86
|
+
Fresh workspaces verify a card for abuse prevention before starter credits are
|
|
87
|
+
issued. The card verification does not charge the human. New workspaces receive
|
|
88
|
+
$5 in starter AI credits, with automatic overage disabled by default.
|
|
89
|
+
|
|
90
|
+
Check AI credits:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
dench billing status --json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Create a top-up link for the human to pay:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
dench billing topup --amount 5 --json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Do not claim the top-up succeeded until Stripe returns success or
|
|
103
|
+
`dench billing status --json` shows the new credits.
|
|
104
|
+
|
|
105
|
+
## External Apps
|
|
106
|
+
|
|
107
|
+
List connected apps:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
dench apps --json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`dench apps` is an alias for `dench tool status` with no toolkit.
|
|
114
|
+
|
|
115
|
+
Other tool commands:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
dench tool status [toolkit] --json
|
|
119
|
+
dench tool connect <toolkit> --json
|
|
120
|
+
dench tool search "list recent gmail emails" --toolkit gmail
|
|
121
|
+
dench tool run <composio_tool_slug> --args '{"key":"value"}' --json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Start with compact `dench tool search` output. It lists ranked tools with slug,
|
|
125
|
+
toolkit, connection status, and read-only/approval hints. Add `--json` only when
|
|
126
|
+
you need full raw schemas or exact argument details.
|
|
127
|
+
|
|
128
|
+
Run clear read-only information retrieval tools through Dench without requesting
|
|
129
|
+
manual approval first. This includes slugs containing `FETCH`, `GET`, `LIST`,
|
|
130
|
+
`SEARCH`, `READ`, or `FIND`, such as `GMAIL_FETCH_EMAILS`:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
dench tool run GMAIL_FETCH_EMAILS --args '{"max_results":10}' --json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Dench enforces the final policy and returns `requiresApproval` when approval is
|
|
137
|
+
needed.
|
|
138
|
+
|
|
139
|
+
For Gmail and other email tools, summarize safely. Prefer metadata and snippets.
|
|
140
|
+
Do not repeat OTP codes, security codes, passwords, tokens, API keys, or secrets
|
|
141
|
+
from email bodies. Non-JSON `tool run` display redacts likely sensitive codes;
|
|
142
|
+
`--json` preserves the raw provider response for cases that need it.
|
|
143
|
+
|
|
144
|
+
Run `dench tool --help` or `dench apps --help` for command help.
|
|
145
|
+
|
|
146
|
+
For staging:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
dench login --staging
|
|
150
|
+
dench login --host https://workspace-staging.dench.com
|
|
151
|
+
```
|
package/agentKind.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirror of `convex/lib/agentKind.ts` for the CLI. The published package
|
|
3
|
+
* cannot import from the Convex backend, so the normalization logic lives
|
|
4
|
+
* here as well. Keep both copies in lockstep.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const KNOWN_AGENT_KINDS = [
|
|
8
|
+
"claude_code",
|
|
9
|
+
"codex",
|
|
10
|
+
"cursor",
|
|
11
|
+
"hermes",
|
|
12
|
+
"openclaw",
|
|
13
|
+
"other",
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export type KnownAgentKind = (typeof KNOWN_AGENT_KINDS)[number];
|
|
17
|
+
|
|
18
|
+
export const KNOWN_AGENT_KIND_SET: ReadonlySet<string> = new Set(
|
|
19
|
+
KNOWN_AGENT_KINDS,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_AGENT_KIND: KnownAgentKind = "other";
|
|
23
|
+
|
|
24
|
+
export const KNOWN_AGENT_KIND_LABELS: Record<KnownAgentKind, string> = {
|
|
25
|
+
claude_code: "Claude Code Agent",
|
|
26
|
+
codex: "Codex Agent",
|
|
27
|
+
cursor: "Cursor Agent",
|
|
28
|
+
hermes: "Hermes Agent",
|
|
29
|
+
openclaw: "OpenClaw Agent",
|
|
30
|
+
other: "Agent",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const MAX_AGENT_KIND_LENGTH = 64;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a user-supplied agent kind into the canonical form Dench stores.
|
|
37
|
+
* Lower-cases, trims, replaces spaces and dashes with underscores, drops
|
|
38
|
+
* unsafe characters, caps length, and falls back to `other` when the input
|
|
39
|
+
* is missing or normalizes to empty.
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeAgentKind(input: unknown): string {
|
|
42
|
+
if (typeof input !== "string") return DEFAULT_AGENT_KIND;
|
|
43
|
+
const trimmed = input.trim().toLowerCase();
|
|
44
|
+
if (!trimmed) return DEFAULT_AGENT_KIND;
|
|
45
|
+
|
|
46
|
+
const normalized = trimmed
|
|
47
|
+
.replace(/[\s-]+/g, "_")
|
|
48
|
+
.replace(/[^a-z0-9_]/g, "")
|
|
49
|
+
.replace(/_+/g, "_")
|
|
50
|
+
.replace(/^_+|_+$/g, "")
|
|
51
|
+
.slice(0, MAX_AGENT_KIND_LENGTH);
|
|
52
|
+
|
|
53
|
+
return normalized || DEFAULT_AGENT_KIND;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function agentKindLabel(kind: string): string {
|
|
57
|
+
return KNOWN_AGENT_KIND_LABELS[kind as KnownAgentKind] ?? "Agent";
|
|
58
|
+
}
|