relaymessenger 0.1.3 → 0.1.4-staging.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/README.md +56 -46
- package/dist/agent-handoff.d.ts +4 -4
- package/dist/agent-handoff.d.ts.map +1 -1
- package/dist/agent-handoff.js +24 -24
- package/dist/agent-handoff.js.map +1 -1
- package/dist/agent-image-upload.d.ts +4 -4
- package/dist/agent-image-upload.d.ts.map +1 -1
- package/dist/agent-image-upload.js +15 -15
- package/dist/agent-image-upload.js.map +1 -1
- package/dist/agent-session.d.ts +3 -3
- package/dist/agent-session.d.ts.map +1 -1
- package/dist/agent-session.js +7 -7
- package/dist/agent-session.js.map +1 -1
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +26 -25
- package/dist/agents.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -31
- package/dist/config.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +25 -23
- package/dist/doctor.js.map +1 -1
- package/dist/event-listen.d.ts.map +1 -1
- package/dist/event-listen.js +4 -3
- package/dist/event-listen.js.map +1 -1
- package/dist/interactive.js +9 -9
- package/dist/interactive.js.map +1 -1
- package/dist/local-image.d.ts +3 -2
- package/dist/local-image.d.ts.map +1 -1
- package/dist/local-image.js +29 -16
- package/dist/local-image.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +113 -111
- package/dist/program.js.map +1 -1
- package/dist/runtime-connect/implementation.js +59 -59
- package/dist/runtime-connect/implementation.js.map +1 -1
- package/dist/runtime-connect/windows-acl.js +4 -4
- package/dist/runtime-connect/windows-acl.js.map +1 -1
- package/dist/runtime-connect.d.ts +6 -5
- package/dist/runtime-connect.d.ts.map +1 -1
- package/dist/runtime-connect.js.map +1 -1
- package/dist/secret-input.d.ts +2 -1
- package/dist/secret-input.d.ts.map +1 -1
- package/dist/secret-input.js +9 -8
- package/dist/secret-input.js.map +1 -1
- package/dist/skill-offer.js +4 -4
- package/dist/skill-offer.js.map +1 -1
- package/dist/terminal-session.d.ts +1 -1
- package/dist/terminal-session.d.ts.map +1 -1
- package/dist/terminal-session.js +4 -4
- package/dist/terminal-session.js.map +1 -1
- package/dist/terminal-watch.d.ts +3 -3
- package/dist/terminal-watch.d.ts.map +1 -1
- package/dist/terminal-watch.js +3 -3
- package/dist/terminal-watch.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ installation; cancelling stops setup before any identity is created. Accepting r
|
|
|
37
37
|
agents and project/global scope:
|
|
38
38
|
|
|
39
39
|
```sh
|
|
40
|
-
npx --yes skills@1.5.
|
|
40
|
+
npx --yes skills@1.5.25 add https://github.com/RelayMessenger/Relay-SDK/tree/staging/skills/relay --skill relay
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
The CLI does not silently download skills or change every agent's configuration.
|
|
@@ -54,12 +54,12 @@ view open. Reopen an existing saved identity with
|
|
|
54
54
|
`relay --profile <saved-profile> auth status`. Press `q`, Ctrl-C, or Ctrl-D to
|
|
55
55
|
close the view; it does not delete the agent or stop a selected runtime.
|
|
56
56
|
|
|
57
|
-
The view
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
The view only watches. Your agent still receives every message, because this view
|
|
58
|
+
never answers Relay and never takes an event from it. It shows the events Relay
|
|
59
|
+
still holds, so some earlier ones may be missing, and it says so on screen when
|
|
60
|
+
they are. A connected view does not mean the agent is running, and the screen
|
|
61
|
+
says that too. `--json`, `--non-interactive`, and any command not attached to a
|
|
62
|
+
terminal never open this view.
|
|
63
63
|
|
|
64
64
|
## Agent Token authentication
|
|
65
65
|
|
|
@@ -107,7 +107,7 @@ relay chats typing start "$CHAT_ID"
|
|
|
107
107
|
relay chats read "$CHAT_ID"
|
|
108
108
|
|
|
109
109
|
relay contact-card get
|
|
110
|
-
relay contact-card setup --handle weather.
|
|
110
|
+
relay contact-card setup --handle weather.dev --name Weather
|
|
111
111
|
relay contact-card share "$CHAT_ID"
|
|
112
112
|
relay contact-requests create advait
|
|
113
113
|
|
|
@@ -137,13 +137,14 @@ accepts at most 6 recipient Handles.
|
|
|
137
137
|
Participant commands keep their generic names; add an eligible agent by its Handle:
|
|
138
138
|
|
|
139
139
|
```sh
|
|
140
|
-
relay chats participants add "$CHAT_ID" research.
|
|
141
|
-
relay chats participants remove "$CHAT_ID" research.
|
|
140
|
+
relay chats participants add "$CHAT_ID" research.dev
|
|
141
|
+
relay chats participants remove "$CHAT_ID" research.dev
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
`contact-card share` shares the authenticated agent's own card.
|
|
145
|
-
`contact-requests create` asks a
|
|
146
|
-
|
|
145
|
+
`contact-requests create` asks a person to add this agent. Only an agent on a paid
|
|
146
|
+
handle may ask; any other agent gets a 402 answer saying so. It is not a human
|
|
147
|
+
invitation. Agent-initiated Messages to users remain
|
|
147
148
|
supported subject to Contacts eligibility and blocking; a pending Add request
|
|
148
149
|
does not grant messaging eligibility. There are no phone address-book, mutual-contact, human discovery,
|
|
149
150
|
or human invite-link commands.
|
|
@@ -163,24 +164,27 @@ public metadata, a share link, and a terminal QR. JSON output includes
|
|
|
163
164
|
choose a new profile name; existing profiles and the current profile selection
|
|
164
165
|
are preserved. `--token-name` labels the token, not a machine identity.
|
|
165
166
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
`agents list` shows the agents saved on this computer, not every agent on your
|
|
168
|
+
account. Each row is `profile`, `handle`, `display_name`, `image_url`, `api_url`
|
|
169
|
+
and `token: "stored"`. Each row is read with that profile's own token and API
|
|
170
|
+
address, so a token in your environment never stands in for another profile. A
|
|
171
|
+
profile with no token stays in `profiles list` and is not shown here. A row Relay
|
|
172
|
+
cannot answer for reads `error: "Agent details unavailable"`, with nothing from
|
|
173
|
+
the failed answer repeated.
|
|
170
174
|
|
|
171
175
|
Deletion honors explicit profile/ENV selection. Otherwise it selects one saved
|
|
172
176
|
credential by its authenticated Contact Card, refusing unavailable or ambiguous
|
|
173
177
|
matches (including the same handle on multiple origins). It only clears that
|
|
174
|
-
profile's matching saved
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
profile's matching saved token after Relay confirms the agent is gone. If Relay
|
|
179
|
+
errors, or does not answer, the saved token stays; tokens for other profiles and
|
|
180
|
+
for your environment are never touched. New creation defaults to the staging API when this package has a staging prerelease
|
|
177
181
|
version; it never inherits an empty legacy production profile. Explicit `--api-url`
|
|
178
182
|
or `RELAY_API_URL` overrides remain authoritative, and existing profile origins
|
|
179
183
|
are unchanged. Creation is never automatically retried. If creation succeeds but local
|
|
180
184
|
storage fails, the command reports the safely assigned handle and whether local
|
|
181
|
-
storage is present, absent, or unverified, without printing the secret.
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
storage is present, absent, or unverified, without printing the secret. Relay
|
|
186
|
+
checks that it can write a private config file before it asks Relay to create the
|
|
187
|
+
agent, and it never overwrites a token that is already there.
|
|
184
188
|
|
|
185
189
|
### Optional identity and picture
|
|
186
190
|
|
|
@@ -218,7 +222,7 @@ metadata, paired with its rendered local image/URL/attachment. It is not a defau
|
|
|
218
222
|
interactive question. The CLI does not render recipes or generate images. The
|
|
219
223
|
server's response supplies the permanent public image URL.
|
|
220
224
|
|
|
221
|
-
### Optional
|
|
225
|
+
### Optional: connect a runtime
|
|
222
226
|
|
|
223
227
|
```sh
|
|
224
228
|
relay agents create --connect hermes \
|
|
@@ -239,25 +243,30 @@ OpenClaw binding; Claude uses `--runtime-home` for an existing session channel
|
|
|
239
243
|
directory and `--runtime-context` for its session identifier. Existing sender
|
|
240
244
|
permissions are preserved, not inferred from Contacts.
|
|
241
245
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
`
|
|
246
|
-
|
|
246
|
+
`agents create --connect` reads the profile it just saved, and ignores any token in
|
|
247
|
+
your environment. `auth login --connect` with no token option reuses the saved
|
|
248
|
+
profile you named and its API address, and ignores your environment too. Add
|
|
249
|
+
`--with-token` to read the token from a pipe instead. Plain `auth login` uses
|
|
250
|
+
`RELAY_AGENT_TOKEN` where there is no terminal, or asks for the token in a hidden
|
|
251
|
+
prompt. Relay checks the token with the API before saving it, and never creates an
|
|
252
|
+
agent as a fallback.
|
|
247
253
|
Empty Hermes profiles and explicit empty/new OpenClaw accounts can receive an
|
|
248
254
|
initial credential when their native context and state are safe. Occupied
|
|
249
255
|
credentials, unknown secret references, and bound/corrupt state are not replaced.
|
|
250
256
|
|
|
251
|
-
|
|
252
|
-
does not install,
|
|
253
|
-
|
|
257
|
+
The `connect` block in the output says whether the configuration was written, and
|
|
258
|
+
always reports `connected: false`: this command does not install, start, stop or
|
|
259
|
+
test anything. Start the runtime yourself. If writing the configuration fails
|
|
260
|
+
after an agent was created, the token is still saved; run `auth login --connect`
|
|
261
|
+
with that token rather than creating another agent.
|
|
254
262
|
|
|
255
263
|
## Local event forwarding
|
|
256
264
|
|
|
257
265
|
`relay events listen` is a development convenience backed only by the SDK's
|
|
258
266
|
source-backed Agent WebSocket. It refuses Relay's production API, requires an
|
|
259
|
-
explicit profile, and
|
|
260
|
-
|
|
267
|
+
explicit profile, and asks you to confirm that the profile belongs to a test agent.
|
|
268
|
+
Reading events here can make Relay stop resending them elsewhere, so never point it
|
|
269
|
+
at an agent something else is reading:
|
|
261
270
|
|
|
262
271
|
```sh
|
|
263
272
|
relay --profile staging events listen --acknowledge-events
|
|
@@ -265,23 +274,24 @@ relay --profile staging events listen --acknowledge-events \
|
|
|
265
274
|
--forward-to http://127.0.0.1:3000/relay-events
|
|
266
275
|
```
|
|
267
276
|
|
|
268
|
-
|
|
269
|
-
original Relay event
|
|
270
|
-
`x-relay-dev-forwarded: 1
|
|
271
|
-
|
|
272
|
-
so Relay can
|
|
277
|
+
`--forward-to` must be an address on your own computer, such as
|
|
278
|
+
`http://127.0.0.1:3000`. Each copy is the original Relay event, but it is **not
|
|
279
|
+
signed**, and it carries `x-relay-dev-forwarded: 1`. Use a real webhook to test
|
|
280
|
+
signature checking. If your own address answers with an error, this command stops
|
|
281
|
+
rather than let the event be lost, so Relay can send it again. Your receiver must
|
|
282
|
+
ignore an `event_id` it has already seen.
|
|
273
283
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
284
|
+
If the agent has been away longer than Relay keeps its events, Relay wants to send
|
|
285
|
+
everything it missed. This command cannot go back over old events and says so
|
|
286
|
+
instead of pretending. It also cannot run while the agent has webhook
|
|
287
|
+
subscriptions, because Relay sends events one way or the other, never both.
|
|
278
288
|
|
|
279
289
|
## Doctor
|
|
280
290
|
|
|
281
|
-
`relay doctor` checks
|
|
282
|
-
|
|
283
|
-
`relay doctor --offline` skips
|
|
284
|
-
|
|
291
|
+
`relay doctor` checks your Node.js version, the Relay API address, which token
|
|
292
|
+
Relay would use, the permissions on your config file, the installed
|
|
293
|
+
`@relaymessenger/sdk`, and whether Relay answers. `relay doctor --offline` skips
|
|
294
|
+
only the last of those, which suits a check right after installing.
|
|
285
295
|
|
|
286
296
|
## Security
|
|
287
297
|
|
package/dist/agent-handoff.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { AgentDependencies } from "./agents.js";
|
|
3
3
|
import { type RuntimeConnectTarget } from "./runtime-connect.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface ConnectOptions {
|
|
5
5
|
connect?: string;
|
|
6
6
|
runtimeHome?: string;
|
|
7
7
|
runtimeConfig?: string;
|
|
@@ -12,9 +12,9 @@ export interface HandoffOptions {
|
|
|
12
12
|
confirmConfigure?: boolean;
|
|
13
13
|
runtimeStopped?: boolean;
|
|
14
14
|
}
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
15
|
+
export declare function connectOptions(command: Command): Command;
|
|
16
|
+
export declare function connectTarget(options: ConnectOptions): Promise<RuntimeConnectTarget | undefined>;
|
|
17
|
+
export declare function connectAgentToRuntime(target: RuntimeConnectTarget, profile: string | undefined, deps: AgentDependencies, confirmation: {
|
|
18
18
|
consent: boolean;
|
|
19
19
|
runtimeStopped: boolean;
|
|
20
20
|
}, savedProfileOnly?: boolean): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-handoff.d.ts","sourceRoot":"","sources":["../src/agent-handoff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAA2C,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE1G,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AACD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAUxD;AAWD,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAsBtG;AAED,wBAAsB,
|
|
1
|
+
{"version":3,"file":"agent-handoff.d.ts","sourceRoot":"","sources":["../src/agent-handoff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAA2C,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE1G,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AACD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAUxD;AAWD,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAsBtG;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,EAAE,gBAAgB,UAAQ;;;;;;;;GAiBpN"}
|
package/dist/agent-handoff.js
CHANGED
|
@@ -3,40 +3,40 @@ import { lstat, realpath } from "node:fs/promises";
|
|
|
3
3
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
4
4
|
import { DEFAULT_API_URL, validateApiURL, validateToken } from "./config.js";
|
|
5
5
|
import { applyRuntimeConnect, planRuntimeConnect } from "./runtime-connect.js";
|
|
6
|
-
export function
|
|
7
|
-
return command.option("--connect <runtime>", "
|
|
8
|
-
.option("--runtime-home <path>", "
|
|
9
|
-
.option("--runtime-config <path>", "
|
|
10
|
-
.option("--runtime-state-dir <path>", "
|
|
11
|
-
.option("--runtime-account <name>", "
|
|
12
|
-
.option("--runtime-brain <id>", "
|
|
13
|
-
.option("--runtime-context <id>", "
|
|
14
|
-
.option("--confirm-configure", "
|
|
15
|
-
.option("--runtime-stopped", "
|
|
6
|
+
export function connectOptions(command) {
|
|
7
|
+
return command.option("--connect <runtime>", "save the token into Claude Code, Hermes or OpenClaw; does not start it")
|
|
8
|
+
.option("--runtime-home <path>", "full path to the Hermes profile folder, or to the Claude Code folder for this session")
|
|
9
|
+
.option("--runtime-config <path>", "full path to your existing OpenClaw config file")
|
|
10
|
+
.option("--runtime-state-dir <path>", "full path to the folder where that runtime keeps its saved data")
|
|
11
|
+
.option("--runtime-account <name>", "the Relay account name in OpenClaw")
|
|
12
|
+
.option("--runtime-brain <id>", "the OpenClaw brain already linked to that account")
|
|
13
|
+
.option("--runtime-context <id>", "a name for this Claude Code session")
|
|
14
|
+
.option("--confirm-configure", "yes, write the token into that one configuration file")
|
|
15
|
+
.option("--runtime-stopped", "yes, I have stopped the runtime I chose");
|
|
16
16
|
}
|
|
17
17
|
async function nativePath(value, name, file = false) {
|
|
18
18
|
if (!value || !isAbsolute(value))
|
|
19
|
-
throw new Error(`${name}
|
|
19
|
+
throw new Error(`${name} needs a full path that starts at the root of the disk.`);
|
|
20
20
|
// The user selects the context; resolve directory aliases, never linked config files.
|
|
21
21
|
return file ? join(await realpath(dirname(value)), basename(value)) : await realpath(value);
|
|
22
22
|
}
|
|
23
23
|
async function requiredNativeFile(path) {
|
|
24
24
|
const info = await lstat(path);
|
|
25
25
|
if (!info.isFile() || info.isSymbolicLink())
|
|
26
|
-
throw new Error("
|
|
26
|
+
throw new Error("That configuration file does not exist, or it is a link or a folder. Give the path to a real file.");
|
|
27
27
|
return path;
|
|
28
28
|
}
|
|
29
|
-
export async function
|
|
29
|
+
export async function connectTarget(options) {
|
|
30
30
|
if (!options.connect) {
|
|
31
31
|
if (Object.entries(options).some(([key, value]) => (key.startsWith("runtime") || key === "confirmConfigure") && value !== undefined))
|
|
32
|
-
throw new Error("
|
|
32
|
+
throw new Error("The --runtime options only work together with --connect. Add --connect claude-code, --connect hermes or --connect openclaw.");
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
35
|
if (!options.confirmConfigure || !options.runtimeStopped)
|
|
36
|
-
throw new Error("
|
|
36
|
+
throw new Error("Stop the runtime you chose, then run this again with --confirm-configure and --runtime-stopped.");
|
|
37
37
|
if (options.connect === "openclaw") {
|
|
38
38
|
if (!options.runtimeAccount)
|
|
39
|
-
throw new Error("
|
|
39
|
+
throw new Error("Pass --runtime-account with the name of the Relay account in your OpenClaw config file.");
|
|
40
40
|
return { runtime: "openclaw", configPath: await requiredNativeFile(await nativePath(options.runtimeConfig, "--runtime-config", true)), stateDir: await nativePath(options.runtimeStateDir, "--runtime-state-dir", true), account: options.runtimeAccount, ...(options.runtimeBrain ? { brain: options.runtimeBrain } : {}) };
|
|
41
41
|
}
|
|
42
42
|
if (options.connect === "hermes") {
|
|
@@ -46,20 +46,20 @@ export async function handoffTarget(options) {
|
|
|
46
46
|
}
|
|
47
47
|
if (options.connect === "claude-code") {
|
|
48
48
|
if (!options.runtimeContext?.trim())
|
|
49
|
-
throw new Error("
|
|
49
|
+
throw new Error("Pass --runtime-context with a name for this Claude Code session.");
|
|
50
50
|
const channelDir = await nativePath(options.runtimeHome, "--runtime-home");
|
|
51
51
|
await requiredNativeFile(join(channelDir, ".env"));
|
|
52
52
|
return { runtime: "claude-code", channelDir, context: options.runtimeContext };
|
|
53
53
|
}
|
|
54
54
|
throw new Error("--connect must be openclaw, hermes, or claude-code.");
|
|
55
55
|
}
|
|
56
|
-
export async function
|
|
56
|
+
export async function connectAgentToRuntime(target, profile, deps, confirmation, savedProfileOnly = false) {
|
|
57
57
|
if (confirmation.consent !== true || confirmation.runtimeStopped !== true)
|
|
58
|
-
throw new Error("
|
|
59
|
-
// Read the just
|
|
58
|
+
throw new Error("Pass both --confirm-configure and --runtime-stopped to write the configuration.");
|
|
59
|
+
// Read the token just created or just saved; the environment must not swap in another agent.
|
|
60
60
|
const saved = savedProfileOnly ? (await deps.read()).profiles[profile] : undefined;
|
|
61
61
|
if (savedProfileOnly && !saved?.agent_token)
|
|
62
|
-
throw new Error("
|
|
62
|
+
throw new Error("This profile has no saved token. Nothing was changed. Sign in for this profile first.");
|
|
63
63
|
const auth = savedProfileOnly
|
|
64
64
|
? { token: validateToken(saved.agent_token), apiURL: validateApiURL(saved.api_url ?? DEFAULT_API_URL), profile: profile }
|
|
65
65
|
: await deps.auth(profile);
|
|
@@ -68,14 +68,14 @@ export async function handoffAgent(target, profile, deps, confirmation, savedPro
|
|
|
68
68
|
cards = await deps.client(auth.token, auth.apiURL).contactCard.retrieve();
|
|
69
69
|
}
|
|
70
70
|
catch {
|
|
71
|
-
throw new Error("
|
|
71
|
+
throw new Error("Relay would not accept this token, so nothing was changed and no agent was created.");
|
|
72
72
|
}
|
|
73
73
|
const agents = cards.contact_cards.filter((card) => card.kind === "agent" && card.is_active);
|
|
74
74
|
if (agents.length !== 1)
|
|
75
|
-
throw new Error("
|
|
75
|
+
throw new Error("This token must belong to exactly one active agent. Use a token for a single agent.");
|
|
76
76
|
const plan = await planRuntimeConnect({ agent: { token: auth.token, origin: auth.apiURL, handle: agents[0].handle }, target });
|
|
77
77
|
const result = plan.status === "ready" ? await applyRuntimeConnect(plan, { consent: confirmation.consent, runtimeStopped: confirmation.runtimeStopped }) : plan;
|
|
78
|
-
//
|
|
78
|
+
// Never write out private input, plan internals, undo handles, or raw errors.
|
|
79
79
|
return safeMetadata({ profile: auth.profile, handle: agents[0].handle, runtime: target.runtime, status: result.status, code: result.code, message: result.message, connected: false }, [auth.token]);
|
|
80
80
|
}
|
|
81
81
|
//# sourceMappingURL=agent-handoff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-handoff.js","sourceRoot":"","sources":["../src/agent-handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EA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G,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7F,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAC;IAChI,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAChI,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChK,8EAA8E;IAC9E,OAAO,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACxM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type Relay from "@relaymessenger/sdk";
|
|
2
2
|
import type { ContactCardItem } from "@relaymessenger/sdk";
|
|
3
3
|
import type { LocalAgentImage } from "./local-image.js";
|
|
4
|
-
export type AgentImageUploadPhase = "
|
|
4
|
+
export type AgentImageUploadPhase = "agent" | "prepare" | "upload" | "check" | "save";
|
|
5
5
|
export type AgentImageUploadResult = {
|
|
6
6
|
status: "updated";
|
|
7
7
|
attachment_id: string;
|
|
@@ -12,9 +12,9 @@ export type AgentImageUploadResult = {
|
|
|
12
12
|
attachment_id?: string;
|
|
13
13
|
message: string;
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
/** Uses only the signed-in file-upload calls that already exist. The caller passes
|
|
16
|
+
* in the call that saves the picture on the agent; no route is rebuilt here.
|
|
17
|
+
* A step whose outcome is unknown is never repeated on its own. */
|
|
18
18
|
export declare function uploadAgentImage(input: {
|
|
19
19
|
handle: string;
|
|
20
20
|
image?: LocalAgentImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-image-upload.d.ts","sourceRoot":"","sources":["../src/agent-image-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"agent-image-upload.d.ts","sourceRoot":"","sources":["../src/agent-image-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACtF,MAAM,MAAM,sBAAsB,GAC9B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,GACpE;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,qBAAqB,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpG;;mEAEmE;AACnE,wBAAsB,gBAAgB,CACpC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EACzE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAAC,EAClD,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,GAC1D,OAAO,CAAC,sBAAsB,CAAC,CAmCjC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/** Uses only the signed-in file-upload calls that already exist. The caller passes
|
|
2
|
+
* in the call that saves the picture on the agent; no route is rebuilt here.
|
|
3
|
+
* A step whose outcome is unknown is never repeated on its own. */
|
|
4
4
|
export async function uploadAgentImage(input, client, promote) {
|
|
5
|
-
let phase = "
|
|
5
|
+
let phase = "agent";
|
|
6
6
|
let attachmentID = input.attachmentID;
|
|
7
7
|
try {
|
|
8
8
|
const cards = await client.contactCard.retrieve({}, { maxRetries: 0 });
|
|
9
9
|
if (cards.contact_cards.length !== 1 || cards.contact_cards[0]?.handle !== input.handle || cards.contact_cards[0].kind !== "agent" || !cards.contact_cards[0].is_active) {
|
|
10
|
-
throw new Error("
|
|
10
|
+
throw new Error("This token belongs to a different agent.");
|
|
11
11
|
}
|
|
12
12
|
if (input.image && input.attachmentID)
|
|
13
|
-
throw new Error("Choose a new
|
|
13
|
+
throw new Error("Choose either a new picture or a picture you already uploaded, not both.");
|
|
14
14
|
if (!attachmentID) {
|
|
15
15
|
if (!input.image)
|
|
16
|
-
throw new Error("
|
|
17
|
-
phase = "
|
|
16
|
+
throw new Error("No picture was given.");
|
|
17
|
+
phase = "prepare";
|
|
18
18
|
const allocation = await client.attachments.create({
|
|
19
19
|
filename: input.image.filename, content_type: input.image.contentType, size_bytes: input.image.size,
|
|
20
20
|
}, { maxRetries: 0 });
|
|
@@ -22,23 +22,23 @@ export async function uploadAgentImage(input, client, promote) {
|
|
|
22
22
|
phase = "upload";
|
|
23
23
|
await client.attachments.upload(allocation, new Blob([Uint8Array.from(input.image.data)], { type: input.image.contentType }), { maxRetries: 0, timeout: 120_000, signal: AbortSignal.timeout(120_000) });
|
|
24
24
|
}
|
|
25
|
-
phase = "
|
|
25
|
+
phase = "check";
|
|
26
26
|
const attachment = await client.attachments.retrieve(attachmentID, { maxRetries: 0 });
|
|
27
27
|
if (attachment.status !== "complete")
|
|
28
|
-
throw new Error("
|
|
29
|
-
phase = "
|
|
28
|
+
throw new Error("Relay has not finished storing this picture yet.");
|
|
29
|
+
phase = "save";
|
|
30
30
|
const agent = await promote(attachmentID);
|
|
31
31
|
if (agent.handle !== input.handle || agent.kind !== "agent")
|
|
32
|
-
throw new Error("
|
|
32
|
+
throw new Error("Relay answered about a different agent.");
|
|
33
33
|
return { status: "updated", attachment_id: attachmentID, agent };
|
|
34
34
|
}
|
|
35
35
|
catch {
|
|
36
|
-
// Never return
|
|
37
|
-
//
|
|
36
|
+
// Never return text from Relay or from the upload: either may echo the private
|
|
37
|
+
// token or the temporary upload address.
|
|
38
38
|
return {
|
|
39
39
|
status: "incomplete", phase,
|
|
40
40
|
...(attachmentID ? { attachment_id: attachmentID } : {}),
|
|
41
|
-
message: "
|
|
41
|
+
message: "The agent and its saved token are unchanged. The picture did not go through. Set the picture on this same agent; do not create another one.",
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-image-upload.js","sourceRoot":"","sources":["../src/agent-image-upload.ts"],"names":[],"mappings":"AASA;;
|
|
1
|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,EAAE,6IAA6I;SACvJ,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/agent-session.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export interface AgentSessionDependencies {
|
|
|
15
15
|
io?: TerminalSessionIO;
|
|
16
16
|
client?: (token: string, origin: string) => Pick<Relay, "contactCard" | "websocket">;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* only
|
|
18
|
+
/** A new agent uses the share link Relay returned. For an older imported profile,
|
|
19
|
+
* only the Relay addresses we know can be turned into a public link. */
|
|
20
20
|
export declare function savedAgentShareURL(origin: string, handle: string): string;
|
|
21
|
-
/** Uses the
|
|
21
|
+
/** Uses the saved profile itself, never an unrelated token or address from the environment. */
|
|
22
22
|
export declare function openSavedAgentSession(input: AgentSessionInput, dependencies: AgentSessionDependencies): Promise<TerminalSessionResult>;
|
|
23
23
|
//# sourceMappingURL=agent-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../src/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGvK,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AACD,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK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AG,WAAW,CAAC,CAAC;CACtF;AACD;wEACwE;AACxE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED,+FAA+F;AAC/F,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmB5I"}
|
package/dist/agent-session.js
CHANGED
|
@@ -2,30 +2,30 @@ import Relay from "@relaymessenger/sdk";
|
|
|
2
2
|
import { DEFAULT_API_URL, STAGING_API_URL, validateApiURL, validateToken } from "./config.js";
|
|
3
3
|
import { runTerminalSession } from "./terminal-session.js";
|
|
4
4
|
import { sdkTerminalObserver } from "./terminal-watch.js";
|
|
5
|
-
/**
|
|
6
|
-
* only
|
|
5
|
+
/** A new agent uses the share link Relay returned. For an older imported profile,
|
|
6
|
+
* only the Relay addresses we know can be turned into a public link. */
|
|
7
7
|
export function savedAgentShareURL(origin, handle) {
|
|
8
8
|
const publicOrigin = origin === STAGING_API_URL ? "https://staging.relayapp.im"
|
|
9
9
|
: origin === DEFAULT_API_URL ? "https://go.relayapp.im" : undefined;
|
|
10
10
|
return publicOrigin ? new URL(`/@${encodeURIComponent(handle)}`, publicOrigin).href : "";
|
|
11
11
|
}
|
|
12
|
-
/** Uses the
|
|
12
|
+
/** Uses the saved profile itself, never an unrelated token or address from the environment. */
|
|
13
13
|
export async function openSavedAgentSession(input, dependencies) {
|
|
14
14
|
const config = await dependencies.agents.read();
|
|
15
15
|
const selected = config.profiles[input.profile];
|
|
16
16
|
if (!selected?.agent_token)
|
|
17
|
-
throw new Error("
|
|
17
|
+
throw new Error("This profile has no saved token, so there is nothing to watch. Sign in for this profile first.");
|
|
18
18
|
const origin = validateApiURL(selected.api_url ?? DEFAULT_API_URL);
|
|
19
19
|
if (input.apiURL && input.apiURL !== origin)
|
|
20
|
-
throw new Error("
|
|
20
|
+
throw new Error("The saved profile now points at a different Relay API, so the view was not opened. Sign in again for this profile.");
|
|
21
21
|
const token = validateToken(selected.agent_token);
|
|
22
22
|
const client = dependencies.client?.(token, origin) ?? new Relay({ apiKey: token, baseURL: origin, ...(dependencies.fetch ? { fetch: dependencies.fetch } : {}) });
|
|
23
23
|
const cards = await client.contactCard.retrieve({}, { maxRetries: 0 });
|
|
24
24
|
if (cards.contact_cards.length !== 1 || cards.contact_cards[0]?.kind !== "agent" || !cards.contact_cards[0].is_active)
|
|
25
|
-
throw new Error("
|
|
25
|
+
throw new Error("This token does not belong to one active agent, so Relay cannot show its live view.");
|
|
26
26
|
const card = cards.contact_cards[0];
|
|
27
27
|
if (input.handle && input.handle !== card.handle)
|
|
28
|
-
throw new Error("
|
|
28
|
+
throw new Error("The saved profile now belongs to a different agent, so the view was not opened. Sign in again for this profile.");
|
|
29
29
|
return (dependencies.session ?? runTerminalSession)({
|
|
30
30
|
interactive: true,
|
|
31
31
|
agent: { handle: card.handle, name: card.first_name, profile: input.profile, shareUrl: input.shareURL ?? savedAgentShareURL(origin, card.handle) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../src/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAA8G,MAAM,uBAAuB,CAAC;AACvK,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAgB1D;
|
|
1
|
+
{"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../src/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAA8G,MAA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