@agent-relay/session 11.5.5
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 +101 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @agent-relay/session
|
|
2
|
+
|
|
3
|
+
Portable session continuity for Agent Relay. The SDK keeps one stable Relay
|
|
4
|
+
session ID across machines and AI harnesses while preserving the immutable
|
|
5
|
+
owner, current steerer, and full control-transfer audit trail.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @agent-relay/session
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Set `RELAYHISTORY_URL` to the Relayhistory deployment. The client accepts a URL
|
|
14
|
+
with or without the `/v1` suffix.
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
export RELAYHISTORY_URL=https://history.agentrelay.com
|
|
18
|
+
export RELAYHISTORY_TOKEN=...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`RELAYHISTORY_ACCESS_TOKEN` and `RELAY_AGENT_TOKEN` are supported as token
|
|
22
|
+
fallbacks.
|
|
23
|
+
|
|
24
|
+
## Start and journal a session
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { SessionClient } from '@agent-relay/session';
|
|
28
|
+
|
|
29
|
+
const sessions = new SessionClient({ cli: 'claude', node: 'danny-mac' });
|
|
30
|
+
const owner = {
|
|
31
|
+
userId: 'usr_danny',
|
|
32
|
+
email: 'danny@example.com',
|
|
33
|
+
displayName: 'Danny',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const session = await sessions.createSession({
|
|
37
|
+
cli: 'claude',
|
|
38
|
+
node: 'danny-mac',
|
|
39
|
+
owner,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Best effort: failures do not interrupt the harness. Pass onWriteError to
|
|
43
|
+
// SessionClient when the host wants logging or telemetry for failed writes.
|
|
44
|
+
void sessions.writeTurn({
|
|
45
|
+
sessionId: session.sessionId,
|
|
46
|
+
role: 'user',
|
|
47
|
+
content: 'Continue the migration.',
|
|
48
|
+
actor: owner,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Resume from another harness
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const sessions = new SessionClient({ cli: 'codex', node: 'dev-mac' });
|
|
56
|
+
const { session, turns, resume } = await sessions.resumeSession(relaySessionId);
|
|
57
|
+
|
|
58
|
+
if (resume.mode === 'native') {
|
|
59
|
+
// Only selected for a Claude-origin session resumed by Claude.
|
|
60
|
+
launchClaude(['--resume', resume.nativeResumeId]);
|
|
61
|
+
} else {
|
|
62
|
+
// Codex, OpenCode, Grok, Cursor, and every cross-CLI handoff use this path.
|
|
63
|
+
launchHarness({ prompt: resume.contextPrompt });
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The injected prompt contains the ordered, attributed Relayhistory journal and
|
|
68
|
+
marks it as quoted prior context. Codex sessions are journal-only, including
|
|
69
|
+
Codex-to-Codex handoffs.
|
|
70
|
+
|
|
71
|
+
## Record steering and attribute commits
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
await sessions.recordSteering({
|
|
75
|
+
sessionId: relaySessionId,
|
|
76
|
+
actor: {
|
|
77
|
+
userId: 'usr_dev',
|
|
78
|
+
email: 'dev@example.com',
|
|
79
|
+
displayName: 'Dev',
|
|
80
|
+
},
|
|
81
|
+
relayMessageId: '213570121302978560',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const trailers = await sessions.getGitTrailers(relaySessionId);
|
|
85
|
+
// Append trailers.join('\n') to the commit message.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Trailers include de-duplicated `Co-authored-by` identities plus stable
|
|
89
|
+
`Relay-Session-*`, active-actor, origin-CLI, and origin-node attribution.
|
|
90
|
+
|
|
91
|
+
## Relayhistory wire contract
|
|
92
|
+
|
|
93
|
+
The SDK uses the existing Relayhistory journal endpoints:
|
|
94
|
+
|
|
95
|
+
- `POST /v1/sessions/:sessionId/turns`
|
|
96
|
+
- `GET /v1/sessions/:sessionId/turns`
|
|
97
|
+
|
|
98
|
+
Creation and steering are durable system turns whose metadata carries the full
|
|
99
|
+
`RelaySession` snapshot. Ordinary user, assistant, and system turns use the
|
|
100
|
+
same ordered journal. This makes the backend journal the single source of truth
|
|
101
|
+
for conversation context and the identity audit trail.
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-relay/session",
|
|
3
|
+
"version": "11.5.5",
|
|
4
|
+
"description": "Cross-harness session continuity and attribution for Agent Relay",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"package.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"test": "vitest run --root ../.. packages/session/src/client.test.ts",
|
|
24
|
+
"test:watch": "vitest --root ../.. packages/session/src/client.test.ts",
|
|
25
|
+
"prepack": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.19.3",
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"vitest": "^4.1.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22.0.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/AgentWorkforce/relay.git",
|
|
41
|
+
"directory": "packages/session"
|
|
42
|
+
},
|
|
43
|
+
"license": "Apache-2.0"
|
|
44
|
+
}
|