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.
Files changed (56) hide show
  1. package/README.md +56 -46
  2. package/dist/agent-handoff.d.ts +4 -4
  3. package/dist/agent-handoff.d.ts.map +1 -1
  4. package/dist/agent-handoff.js +24 -24
  5. package/dist/agent-handoff.js.map +1 -1
  6. package/dist/agent-image-upload.d.ts +4 -4
  7. package/dist/agent-image-upload.d.ts.map +1 -1
  8. package/dist/agent-image-upload.js +15 -15
  9. package/dist/agent-image-upload.js.map +1 -1
  10. package/dist/agent-session.d.ts +3 -3
  11. package/dist/agent-session.d.ts.map +1 -1
  12. package/dist/agent-session.js +7 -7
  13. package/dist/agent-session.js.map +1 -1
  14. package/dist/agents.d.ts.map +1 -1
  15. package/dist/agents.js +26 -25
  16. package/dist/agents.js.map +1 -1
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +32 -31
  19. package/dist/config.js.map +1 -1
  20. package/dist/doctor.d.ts.map +1 -1
  21. package/dist/doctor.js +25 -23
  22. package/dist/doctor.js.map +1 -1
  23. package/dist/event-listen.d.ts.map +1 -1
  24. package/dist/event-listen.js +4 -3
  25. package/dist/event-listen.js.map +1 -1
  26. package/dist/interactive.js +9 -9
  27. package/dist/interactive.js.map +1 -1
  28. package/dist/local-image.d.ts +3 -2
  29. package/dist/local-image.d.ts.map +1 -1
  30. package/dist/local-image.js +29 -16
  31. package/dist/local-image.js.map +1 -1
  32. package/dist/program.d.ts.map +1 -1
  33. package/dist/program.js +113 -111
  34. package/dist/program.js.map +1 -1
  35. package/dist/runtime-connect/implementation.js +59 -59
  36. package/dist/runtime-connect/implementation.js.map +1 -1
  37. package/dist/runtime-connect/windows-acl.js +4 -4
  38. package/dist/runtime-connect/windows-acl.js.map +1 -1
  39. package/dist/runtime-connect.d.ts +6 -5
  40. package/dist/runtime-connect.d.ts.map +1 -1
  41. package/dist/runtime-connect.js.map +1 -1
  42. package/dist/secret-input.d.ts +2 -1
  43. package/dist/secret-input.d.ts.map +1 -1
  44. package/dist/secret-input.js +9 -8
  45. package/dist/secret-input.js.map +1 -1
  46. package/dist/skill-offer.js +4 -4
  47. package/dist/skill-offer.js.map +1 -1
  48. package/dist/terminal-session.d.ts +1 -1
  49. package/dist/terminal-session.d.ts.map +1 -1
  50. package/dist/terminal-session.js +4 -4
  51. package/dist/terminal-session.js.map +1 -1
  52. package/dist/terminal-watch.d.ts +3 -3
  53. package/dist/terminal-watch.d.ts.map +1 -1
  54. package/dist/terminal-watch.js +3 -3
  55. package/dist/terminal-watch.js.map +1 -1
  56. 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.24 add https://github.com/RelayMessenger/Relay-SDK/tree/main/skills/relay --skill relay
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 uses the SDK's explicit `observe: true` WebSocket mode and requires the
58
- server's `observational: true` ready confirmation. It sends no event ACK or
59
- FULL-sync completion and never falls back to a consuming listener. Events are
60
- best-effort and may have retention gaps; event-view connectivity is not model
61
- readiness. Unavailable observation is displayed without claiming a connected
62
- runtime. JSON, non-interactive, and non-TTY commands do not open this session.
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.acme --first-name 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.agent
141
- relay chats participants remove "$CHAT_ID" research.agent
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 user to add the authenticated Premium Handle
146
- agent; it is not a human invitation. Agent-initiated Messages to users remain
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
- Listing is local inventory, not a global account API. Each saved credential reads
167
- its current Contact Card using its saved API origin; environment token/origin
168
- overrides are not applied across the inventory. Tokenless profiles remain in `profiles list`, not agent inventory.
169
- Unavailable Contact Cards are reported without exposing error bodies.
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 credential after confirmed HTTP 204. Errors and uncertain
175
- responses retain credentials; unrelated environment/profile credentials are not
176
- removed. New creation defaults to the staging API when this package has a staging prerelease
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. Private
182
- config write/ACL preflight runs before the POST and never overwrites existing
183
- credentials. It is not a reservation or a durable recovery mechanism.
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 native runtime handoff
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
- Creation handoff reads the newly saved profile directly, ignoring unrelated ENV
243
- credentials. `auth login --connect` without token-input flags reuses the selected saved profile
244
- and its origin, ignoring unrelated ENV credentials. Add `--with-token` to select stdin explicitly. Plain `auth login` uses
245
- `RELAY_AGENT_TOKEN` in headless environments or a hidden terminal prompt. Handoff validates the credential before saving
246
- an import and never falls back to creation.
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
- Handoff output reports configuration status and `connected: false`: this command
252
- does not install, launch, stop, or test-connect a runtime. Start it using its native
253
- workflow. If handoff fails after creation, the token remains stored; use `auth login --connect` with the existing token rather than creating another identity.
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 requires confirmation that the profile belongs to a
260
- dedicated non-production Agent whose durable checkpoint may advance:
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
- Forward destinations must be loopback HTTP(S). Forwarded bodies are the
269
- original Relay event envelopes but are **unsigned** and carry
270
- `x-relay-dev-forwarded: 1`; this is not a substitute for testing Standard
271
- Webhooks signature verification. A non-2xx local response is not acknowledged,
272
- so Relay can redeliver it. Local receivers must deduplicate by `event_id`.
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
- The listener refuses a FULL-sync request rather than falsely claiming it
275
- rebuilt durable state. It also cannot run while the Agent has webhook
276
- subscriptions because Relay makes those delivery modes exclusive. Never point
277
- it at an Agent whose checkpoint is owned by another consumer.
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 the Node runtime, API URL, token resolution, local file
282
- permissions, SDK contract availability, and a read-only API request.
283
- `relay doctor --offline` skips only the network request and is suitable for
284
- package-install checks.
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
 
@@ -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 HandoffOptions {
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 handoffOptions(command: Command): Command;
16
- export declare function handoffTarget(options: HandoffOptions): Promise<RuntimeConnectTarget | undefined>;
17
- export declare function handoffAgent(target: RuntimeConnectTarget, profile: string | undefined, deps: AgentDependencies, confirmation: {
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,YAAY,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;;;;;;;;GAiB3M"}
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"}
@@ -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 handoffOptions(command) {
7
- return command.option("--connect <runtime>", "configure openclaw, hermes, or claude-code; does not launch it")
8
- .option("--runtime-home <path>", "absolute Hermes profile home or Claude session channel directory")
9
- .option("--runtime-config <path>", "absolute existing OpenClaw config file")
10
- .option("--runtime-state-dir <path>", "absolute selected runtime state directory")
11
- .option("--runtime-account <name>", "explicit OpenClaw Relay account")
12
- .option("--runtime-brain <id>", "existing OpenClaw brain binding")
13
- .option("--runtime-context <id>", "explicit Claude session context")
14
- .option("--confirm-configure", "consent to writing only the selected runtime credential config")
15
- .option("--runtime-stopped", "confirm you have stopped the selected runtime before configuration");
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} must select an absolute native path.`);
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("Select an existing regular native runtime configuration file.");
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 handoffTarget(options) {
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("Runtime options require --connect.");
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("Handoff requires --confirm-configure and --runtime-stopped after you stop the selected runtime.");
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("Select --runtime-account explicitly.");
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("Select --runtime-context explicitly.");
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 handoffAgent(target, profile, deps, confirmation, savedProfileOnly = false) {
56
+ export async function connectAgentToRuntime(target, profile, deps, confirmation, savedProfileOnly = false) {
57
57
  if (confirmation.consent !== true || confirmation.runtimeStopped !== true)
58
- throw new Error("Explicit handoff consent and runtime stop confirmation are required.");
59
- // Read the just-created/imported saved credential; ENV must not substitute another agent.
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("Saved profile credential is unavailable; no runtime config was changed.");
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("Existing credential validation failed; no runtime config changed and no new agent was created.");
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("Select a credential with exactly one active agent Contact Card before handoff.");
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
- // Do not serialize private input, plan internals, rollback capabilities, or errors.
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,MAA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AM,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 = "identity" | "allocation" | "upload" | "completion" | "promotion";
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
- /** Existing authenticated attachment lifecycle only. The caller supplies the
16
- * agreed SDK contact-card promotion operation; no route or HTTP implementation
17
- * is duplicated here. An uncertain operation is never automatically repeated. */
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,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,CAAC;AACtG,MAAM,MAAM,sBAAsB,GAC9B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE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AAE,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
- /** Existing authenticated attachment lifecycle only. The caller supplies the
2
- * agreed SDK contact-card promotion operation; no route or HTTP implementation
3
- * is duplicated here. An uncertain operation is never automatically repeated. */
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 = "identity";
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("Selected token does not match the intended agent.");
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 image or existing attachment.");
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("Image file required.");
17
- phase = "allocation";
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 = "completion";
25
+ phase = "check";
26
26
  const attachment = await client.attachments.retrieve(attachmentID, { maxRetries: 0 });
27
27
  if (attachment.status !== "complete")
28
- throw new Error("Attachment not complete.");
29
- phase = "promotion";
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("Promotion response does not match the intended agent.");
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 server/upload response text or exception details: either may
37
- // reflect the private token or temporary upload capability.
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: "Agent identity and saved token are retained. Image update was not confirmed; retry the image on this existing identity, not agent creation.",
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;;iFAEiF;AACjF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAyE,EACzE,MAAkD,EAClD,OAA2D;IAE3D,IAAI,KAAK,GAA0B,UAAU,CAAC;IAC9C,IAAI,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;QACvE,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,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AAC;QAChB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;QACtF,IAAI,UAAU,CAAC,MAAM,KAAK,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAC1G,KAAK,GAAG,MAAM,CAAC;QACf,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACxH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,+EAA+E;QAC/E,yCAAyC;QACzC,OAAO;YACL,MAAM,EAAE,YAAY,EAAE,KAAK;YAC3B,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO,EAAE,6IAA6I;SACvJ,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -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
- /** New identities use the exact server share URL. For older imported profiles,
19
- * only known Relay environments have a source-backed public-link mapping. */
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 actual saved profile, never an unrelated ENV token or origin. */
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,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACtG,EAAE,CAAC,EAAE,iBAAiB,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,CAAC;CACtF;AACD;6EAC6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED,6EAA6E;AAC7E,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmB5I"}
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,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACtG,EAAE,CAAC,EAAE,iBAAiB,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,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"}
@@ -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
- /** New identities use the exact server share URL. For older imported profiles,
6
- * only known Relay environments have a source-backed public-link mapping. */
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 actual saved profile, never an unrelated ENV token or origin. */
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("Selected profile has no saved credential for viewing.");
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("Selected profile origin changed; no observer opened.");
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("An active saved agent is required for the terminal view.");
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("Selected profile identity changed; no observer opened.");
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;6EAC6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,MAAc;IAC/D,MAAM,YAAY,GAAG,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC,6BAA6B;QAC7E,CAAC,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,OAAO,YAAY,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3F,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAwB,EAAE,YAAsC;IAC1G,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,EAAE,WAAW;QAAE,MAAM,IAAI,KAAK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