@evident-ai/cli 3.1.1-dev.14c6359 → 3.1.1-dev.186f6ef
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 +10 -4
- package/dist/index.js +65 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,7 @@ Options:
|
|
|
85
85
|
|
|
86
86
|
- `-a, --agent [id]` — Runner ID to connect to. Optional when `EVIDENT_AGENT_KEY`
|
|
87
87
|
is set (the runner is then resolved automatically from the key).
|
|
88
|
+
- `--runner [id]` — Alias for `--agent` (preferred name; wins if both are given).
|
|
88
89
|
- `-p, --port <port>` — OpenCode port (default: `4096`).
|
|
89
90
|
- `--log-level <level>` — Log verbosity: `debug | info | warn | error` (default:
|
|
90
91
|
`info`). Env: `EVIDENT_LOG_LEVEL`.
|
|
@@ -105,15 +106,18 @@ targets the **production** Evident platform by default.
|
|
|
105
106
|
|
|
106
107
|
## Environment variables
|
|
107
108
|
|
|
108
|
-
- `
|
|
109
|
-
that runner and resolves the runner ID automatically, so `--agent`
|
|
110
|
-
required. Ideal for CI/CD.
|
|
109
|
+
- `EVIDENT_RUNNER_KEY` — A runner key. When set, `evident run` authenticates as
|
|
110
|
+
that runner and resolves the runner ID automatically, so `--runner`/`--agent`
|
|
111
|
+
is not required. Ideal for CI/CD. Preferred name; wins over `EVIDENT_AGENT_KEY`
|
|
112
|
+
if both are set.
|
|
113
|
+
- `EVIDENT_AGENT_KEY` — Alias for `EVIDENT_RUNNER_KEY` (still fully supported).
|
|
111
114
|
- `EVIDENT_TOKEN` — A user token used for authentication (alternative to a
|
|
112
115
|
keychain login from `evident login`).
|
|
113
116
|
- `EVIDENT_API_URL` — Override the API base URL (equivalent to `--endpoint`).
|
|
114
117
|
- `EVIDENT_TUNNEL_URL` — Override the tunnel relay URL (equivalent to `--tunnel`).
|
|
115
118
|
|
|
116
|
-
Authentication precedence for `run`: `EVIDENT_AGENT_KEY`
|
|
119
|
+
Authentication precedence for `run`: `EVIDENT_RUNNER_KEY`/`EVIDENT_AGENT_KEY`
|
|
120
|
+
(tied; `EVIDENT_RUNNER_KEY` wins if both are set) → `EVIDENT_TOKEN` →
|
|
117
121
|
credentials stored by `evident login`. For the URL flags, an explicit
|
|
118
122
|
`--endpoint` / `--tunnel` flag wins over the matching environment variable, which
|
|
119
123
|
in turn overrides the production default.
|
|
@@ -150,6 +154,8 @@ For CI or unattended use, set `EVIDENT_AGENT_KEY` and omit `--agent`:
|
|
|
150
154
|
EVIDENT_AGENT_KEY=<agent-key> evident run --idle-timeout 30
|
|
151
155
|
```
|
|
152
156
|
|
|
157
|
+
(`EVIDENT_RUNNER_KEY` is equivalent and the preferred name — use whichever you like.)
|
|
158
|
+
|
|
153
159
|
## How it works
|
|
154
160
|
|
|
155
161
|
```
|
package/dist/index.js
CHANGED
|
@@ -645,14 +645,27 @@ var EventTypes = {
|
|
|
645
645
|
// CLI lifecycle
|
|
646
646
|
CLI_STARTED: "cli.started",
|
|
647
647
|
CLI_COMMAND: "cli.command",
|
|
648
|
-
CLI_ERROR: "cli.error"
|
|
648
|
+
CLI_ERROR: "cli.error",
|
|
649
|
+
// Deprecation telemetry (#412) — usage of the old `--agent`/`EVIDENT_AGENT_KEY`
|
|
650
|
+
// names instead of the preferred `--runner`/`EVIDENT_RUNNER_KEY` (#409).
|
|
651
|
+
DEPRECATED_AGENT_FLAG_USED: "cli.deprecated_agent_flag_used",
|
|
652
|
+
DEPRECATED_AGENT_KEY_ENV_USED: "cli.deprecated_agent_key_env_used"
|
|
649
653
|
};
|
|
650
654
|
|
|
651
655
|
// src/lib/auth.ts
|
|
652
656
|
async function getAuthCredentials() {
|
|
657
|
+
const runnerKey = process.env.EVIDENT_RUNNER_KEY;
|
|
653
658
|
const agentKey = process.env.EVIDENT_AGENT_KEY;
|
|
659
|
+
if (runnerKey) {
|
|
660
|
+
return {
|
|
661
|
+
token: runnerKey,
|
|
662
|
+
authType: "agent_key",
|
|
663
|
+
keySource: "runner_key",
|
|
664
|
+
notice: agentKey ? "Both EVIDENT_RUNNER_KEY and EVIDENT_AGENT_KEY are set; using EVIDENT_RUNNER_KEY." : void 0
|
|
665
|
+
};
|
|
666
|
+
}
|
|
654
667
|
if (agentKey) {
|
|
655
|
-
return { token: agentKey, authType: "agent_key" };
|
|
668
|
+
return { token: agentKey, authType: "agent_key", keySource: "agent_key" };
|
|
656
669
|
}
|
|
657
670
|
const userToken = process.env.EVIDENT_TOKEN;
|
|
658
671
|
if (userToken) {
|
|
@@ -2511,7 +2524,7 @@ var ChannelDriver = class {
|
|
|
2511
2524
|
}
|
|
2512
2525
|
/**
|
|
2513
2526
|
* Fetch ONE inbound image's bytes through Evident's WI-6 endpoint
|
|
2514
|
-
* (`GET {apiUrl}/
|
|
2527
|
+
* (`GET {apiUrl}/runners/{agentId}/attachments/{messageId}/{index}`) using the
|
|
2515
2528
|
* existing authenticated fetch, and base64-encode into a
|
|
2516
2529
|
* `data:<mime>;base64,<…>` URL for the opencode `file` part's `url`.
|
|
2517
2530
|
*
|
|
@@ -2524,7 +2537,7 @@ var ChannelDriver = class {
|
|
|
2524
2537
|
async fetchAttachmentDataUrl(messageId, index, mime) {
|
|
2525
2538
|
try {
|
|
2526
2539
|
const res = await this.fetchImpl(
|
|
2527
|
-
`${this.apiUrl}/
|
|
2540
|
+
`${this.apiUrl}/runners/${this.agentId}/attachments/${messageId}/${index}`,
|
|
2528
2541
|
{ headers: { Authorization: this.getAuthHeader() } }
|
|
2529
2542
|
);
|
|
2530
2543
|
if (!res.ok) {
|
|
@@ -3790,7 +3803,7 @@ var ChannelDriver = class {
|
|
|
3790
3803
|
// Evident API calls (combinedAuth thread routes)
|
|
3791
3804
|
async getPendingConversations() {
|
|
3792
3805
|
const res = await this.fetchImpl(
|
|
3793
|
-
`${this.apiUrl}/
|
|
3806
|
+
`${this.apiUrl}/runners/${this.agentId}/conversations/pending`,
|
|
3794
3807
|
{
|
|
3795
3808
|
headers: { Authorization: this.getAuthHeader() }
|
|
3796
3809
|
}
|
|
@@ -3808,7 +3821,7 @@ var ChannelDriver = class {
|
|
|
3808
3821
|
}
|
|
3809
3822
|
async getPendingMessages(conversationId) {
|
|
3810
3823
|
const res = await this.fetchImpl(
|
|
3811
|
-
`${this.apiUrl}/
|
|
3824
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/messages?status=pending`,
|
|
3812
3825
|
{ headers: { Authorization: this.getAuthHeader() } }
|
|
3813
3826
|
);
|
|
3814
3827
|
this.assertAuth(res, "fetching pending messages");
|
|
@@ -3832,7 +3845,7 @@ var ChannelDriver = class {
|
|
|
3832
3845
|
*/
|
|
3833
3846
|
async getProcessingMessages() {
|
|
3834
3847
|
const res = await this.fetchImpl(
|
|
3835
|
-
`${this.apiUrl}/
|
|
3848
|
+
`${this.apiUrl}/runners/${this.agentId}/conversations/processing`,
|
|
3836
3849
|
{ headers: { Authorization: this.getAuthHeader() } }
|
|
3837
3850
|
);
|
|
3838
3851
|
this.assertAuth(res, "fetching processing messages");
|
|
@@ -3869,7 +3882,7 @@ var ChannelDriver = class {
|
|
|
3869
3882
|
*/
|
|
3870
3883
|
async markProcessing(conversationId, messageId, sessionId, opencodeMessageId, title) {
|
|
3871
3884
|
const res = await this.fetchImpl(
|
|
3872
|
-
`${this.apiUrl}/
|
|
3885
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/messages/${messageId}`,
|
|
3873
3886
|
{
|
|
3874
3887
|
method: "PATCH",
|
|
3875
3888
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -3918,7 +3931,7 @@ var ChannelDriver = class {
|
|
|
3918
3931
|
*/
|
|
3919
3932
|
async markDone(conversationId, messageId, sessionId, opencodeMessageId, title, usage) {
|
|
3920
3933
|
const res = await this.fetchImpl(
|
|
3921
|
-
`${this.apiUrl}/
|
|
3934
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/messages/${messageId}`,
|
|
3922
3935
|
{
|
|
3923
3936
|
method: "PATCH",
|
|
3924
3937
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -3953,7 +3966,7 @@ var ChannelDriver = class {
|
|
|
3953
3966
|
await this.callWithRetry(
|
|
3954
3967
|
"marking message as failed",
|
|
3955
3968
|
() => this.fetchImpl(
|
|
3956
|
-
`${this.apiUrl}/
|
|
3969
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/messages/${messageId}`,
|
|
3957
3970
|
{
|
|
3958
3971
|
method: "PATCH",
|
|
3959
3972
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -3980,7 +3993,7 @@ var ChannelDriver = class {
|
|
|
3980
3993
|
async postSignal(conversationId, messageId, signal, extra) {
|
|
3981
3994
|
try {
|
|
3982
3995
|
const res = await this.fetchImpl(
|
|
3983
|
-
`${this.apiUrl}/
|
|
3996
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/messages/${messageId}/signal`,
|
|
3984
3997
|
{
|
|
3985
3998
|
method: "POST",
|
|
3986
3999
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -4009,7 +4022,7 @@ var ChannelDriver = class {
|
|
|
4009
4022
|
}
|
|
4010
4023
|
async persistSession(conversationId, sessionId) {
|
|
4011
4024
|
const res = await this.fetchImpl(
|
|
4012
|
-
`${this.apiUrl}/
|
|
4025
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}`,
|
|
4013
4026
|
{
|
|
4014
4027
|
method: "PATCH",
|
|
4015
4028
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -4035,7 +4048,7 @@ var ChannelDriver = class {
|
|
|
4035
4048
|
await this.callWithRetry(
|
|
4036
4049
|
"reporting interactive event",
|
|
4037
4050
|
() => this.fetchImpl(
|
|
4038
|
-
`${this.apiUrl}/
|
|
4051
|
+
`${this.apiUrl}/runners/${this.agentId}/threads/${conversationId}/interactive-event`,
|
|
4039
4052
|
{
|
|
4040
4053
|
method: "POST",
|
|
4041
4054
|
headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
|
|
@@ -4278,7 +4291,7 @@ async function resolveAgentIdFromKey(authHeader) {
|
|
|
4278
4291
|
async function notifyAgentDisconnected(agentId, authHeader) {
|
|
4279
4292
|
const apiUrl = getApiUrlConfig();
|
|
4280
4293
|
try {
|
|
4281
|
-
const response = await fetch(`${apiUrl}/
|
|
4294
|
+
const response = await fetch(`${apiUrl}/runners/${agentId}/disconnect`, {
|
|
4282
4295
|
method: "POST",
|
|
4283
4296
|
headers: { Authorization: authHeader }
|
|
4284
4297
|
});
|
|
@@ -4297,7 +4310,7 @@ async function notifyAgentDisconnected(agentId, authHeader) {
|
|
|
4297
4310
|
async function getAgentInfo(agentId, authHeader) {
|
|
4298
4311
|
const apiUrl = getApiUrlConfig();
|
|
4299
4312
|
try {
|
|
4300
|
-
const response = await fetch(`${apiUrl}/
|
|
4313
|
+
const response = await fetch(`${apiUrl}/runners/${agentId}`, {
|
|
4301
4314
|
headers: { Authorization: authHeader }
|
|
4302
4315
|
});
|
|
4303
4316
|
if (response.status === 401) {
|
|
@@ -4684,7 +4697,7 @@ async function run(options) {
|
|
|
4684
4697
|
return;
|
|
4685
4698
|
}
|
|
4686
4699
|
const state = {
|
|
4687
|
-
agentId: options.agent || "",
|
|
4700
|
+
agentId: options.runner || options.agent || "",
|
|
4688
4701
|
agentName: null,
|
|
4689
4702
|
port: options.port ?? 4096,
|
|
4690
4703
|
conversationFilter: options.conversation ?? null,
|
|
@@ -4706,6 +4719,14 @@ async function run(options) {
|
|
|
4706
4719
|
sessionCleanupTimers: [],
|
|
4707
4720
|
authHeader: ""
|
|
4708
4721
|
};
|
|
4722
|
+
if (!options.runner && options.agent) {
|
|
4723
|
+
telemetry.info(
|
|
4724
|
+
EventTypes.DEPRECATED_AGENT_FLAG_USED,
|
|
4725
|
+
"Deprecated --agent flag used instead of --runner",
|
|
4726
|
+
{ command: "run" },
|
|
4727
|
+
state.agentId
|
|
4728
|
+
);
|
|
4729
|
+
}
|
|
4709
4730
|
if (state.idleTimeout === null && (process.env.GITHUB_ACTIONS || process.env.CI)) {
|
|
4710
4731
|
log2(
|
|
4711
4732
|
state,
|
|
@@ -4734,7 +4755,9 @@ async function run(options) {
|
|
|
4734
4755
|
if (!interactive) {
|
|
4735
4756
|
printError("Authentication required");
|
|
4736
4757
|
blank();
|
|
4737
|
-
console.log(
|
|
4758
|
+
console.log(
|
|
4759
|
+
chalk6.dim("Set EVIDENT_RUNNER_KEY (or EVIDENT_AGENT_KEY) environment variable for CI")
|
|
4760
|
+
);
|
|
4738
4761
|
console.log(chalk6.dim("Or run `evident login` for interactive authentication"));
|
|
4739
4762
|
blank();
|
|
4740
4763
|
process.exit(1);
|
|
@@ -4748,6 +4771,20 @@ async function run(options) {
|
|
|
4748
4771
|
);
|
|
4749
4772
|
}
|
|
4750
4773
|
state.authHeader = getAuthHeader(credentials2);
|
|
4774
|
+
if (credentials2.notice) {
|
|
4775
|
+
log2(state, credentials2.notice, "warn");
|
|
4776
|
+
if (state.interactive && !state.json) {
|
|
4777
|
+
logActivity(state, { type: "info", level: "warn", message: credentials2.notice });
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
if (credentials2.keySource === "agent_key") {
|
|
4781
|
+
telemetry.info(
|
|
4782
|
+
EventTypes.DEPRECATED_AGENT_KEY_ENV_USED,
|
|
4783
|
+
"Deprecated EVIDENT_AGENT_KEY env var used instead of EVIDENT_RUNNER_KEY",
|
|
4784
|
+
{ command: "run" },
|
|
4785
|
+
state.agentId
|
|
4786
|
+
);
|
|
4787
|
+
}
|
|
4751
4788
|
if (!state.agentId) {
|
|
4752
4789
|
if (credentials2.authType === "agent_key") {
|
|
4753
4790
|
const resolved = await resolveAgentIdFromKey(state.authHeader);
|
|
@@ -4765,9 +4802,15 @@ async function run(options) {
|
|
|
4765
4802
|
process.exit(1);
|
|
4766
4803
|
}
|
|
4767
4804
|
} else {
|
|
4768
|
-
printError(
|
|
4805
|
+
printError(
|
|
4806
|
+
"--runner (or --agent) is required when not using EVIDENT_RUNNER_KEY or EVIDENT_AGENT_KEY"
|
|
4807
|
+
);
|
|
4769
4808
|
blank();
|
|
4770
|
-
console.log(
|
|
4809
|
+
console.log(
|
|
4810
|
+
chalk6.dim(
|
|
4811
|
+
"Either provide --runner/--agent <id> or set EVIDENT_RUNNER_KEY/EVIDENT_AGENT_KEY"
|
|
4812
|
+
)
|
|
4813
|
+
);
|
|
4771
4814
|
blank();
|
|
4772
4815
|
process.exit(1);
|
|
4773
4816
|
}
|
|
@@ -4982,7 +5025,7 @@ async function run(options) {
|
|
|
4982
5025
|
}
|
|
4983
5026
|
telemetry.error(EventTypes.CLI_ERROR, `Run command failed: ${message}`, {
|
|
4984
5027
|
command: "run",
|
|
4985
|
-
agentId: options.agent
|
|
5028
|
+
agentId: options.runner || options.agent
|
|
4986
5029
|
});
|
|
4987
5030
|
await shutdownTelemetry();
|
|
4988
5031
|
process.exit(1);
|
|
@@ -5007,7 +5050,7 @@ program.name("evident").description("Run OpenCode locally and connect it to Evid
|
|
|
5007
5050
|
program.command("login").description("Authenticate with Evident").option("--token", "Use token-based authentication (for CI/CD)").option("--no-browser", "Do not open the browser automatically").action(login);
|
|
5008
5051
|
program.command("logout").description("Remove stored credentials for the current endpoint").option("--all", "Remove stored credentials for all endpoints").action((options) => logout({ all: options.all }));
|
|
5009
5052
|
program.command("whoami").description("Show the currently logged in user").action(whoami);
|
|
5010
|
-
program.command("run").description("Connect to Evident and process messages").option("-a, --agent [id]", "Runner ID to connect to (optional when EVIDENT_AGENT_KEY is set)").option("-p, --port <port>", "OpenCode port (default: 4096)", "4096").option(
|
|
5053
|
+
program.command("run").description("Connect to Evident and process messages").option("-a, --agent [id]", "Runner ID to connect to (optional when EVIDENT_AGENT_KEY is set)").option("--runner [id]", "Alias for --agent (preferred name; wins if both are given)").option("-p, --port <port>", "OpenCode port (default: 4096)", "4096").option(
|
|
5011
5054
|
"--log-level <level>",
|
|
5012
5055
|
"Log verbosity: debug | info | warn | error (default: info). Env: EVIDENT_LOG_LEVEL"
|
|
5013
5056
|
).option("-v, --verbose", "Alias for --log-level debug (ignored if --log-level is set)").option("-c, --conversation <id>", "Process only this specific conversation").option("--idle-timeout <seconds>", "Exit after N seconds idle").option("--json", "Output in JSON format").option(
|
|
@@ -5023,6 +5066,7 @@ program.command("run").description("Connect to Evident and process messages").op
|
|
|
5023
5066
|
(options) => {
|
|
5024
5067
|
run({
|
|
5025
5068
|
agent: options.agent,
|
|
5069
|
+
runner: options.runner,
|
|
5026
5070
|
port: parseInt(options.port, 10),
|
|
5027
5071
|
// Raw string — validation/precedence is single-sourced in run.ts's
|
|
5028
5072
|
// resolveLogLevel (flag > -v > EVIDENT_LOG_LEVEL > info).
|