@agent-relay/continuity 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ export type PDEROPhase = 'plan' | 'design' | 'execute' | 'review' | 'observe';
2
+ /**
3
+ * Continuity System Types
4
+ *
5
+ * Core types for the CLI-agnostic session continuity system.
6
+ * Works with any CLI (Claude, Codex, Gemini, custom) via output
7
+ * pattern detection and PTY injection.
8
+ */
9
+ /**
10
+ * A decision recorded during agent work
11
+ */
12
+ export interface Decision {
13
+ /** The choice that was made */
14
+ decision: string;
15
+ /** Why this choice was made */
16
+ reasoning?: string;
17
+ /** Alternative options considered */
18
+ alternatives?: string[];
19
+ /** Confidence level (0-1) */
20
+ confidence?: number;
21
+ /** When the decision was made */
22
+ timestamp: Date;
23
+ }
24
+ /**
25
+ * A file reference with optional line numbers
26
+ */
27
+ export interface FileRef {
28
+ /** Relative or absolute path */
29
+ path: string;
30
+ /** Line range [start, end] */
31
+ lines?: [number, number];
32
+ /** Brief description of what's relevant */
33
+ description?: string;
34
+ }
35
+ /**
36
+ * Ledger - Within-session state snapshot
37
+ *
38
+ * Ephemeral, overwritten each session. Captures current work state
39
+ * for context injection on restart/clear.
40
+ */
41
+ export interface Ledger {
42
+ /** Agent name this ledger belongs to */
43
+ agentName: string;
44
+ /** Unique agent instance ID (persists across restarts for resume) */
45
+ agentId: string;
46
+ /** Unique session identifier */
47
+ sessionId: string;
48
+ /** CLI being used (claude, codex, gemini, custom) */
49
+ cli: string;
50
+ /** What the agent is currently working on */
51
+ currentTask: string;
52
+ /** Completed work items */
53
+ completed: string[];
54
+ /** Work in progress */
55
+ inProgress: string[];
56
+ /** Blocked items with reasons */
57
+ blocked: string[];
58
+ /** Key decisions made during session */
59
+ keyDecisions: Decision[];
60
+ /** Items marked as uncertain (need verification) */
61
+ uncertainItems: string[];
62
+ /** Recently touched files */
63
+ fileContext: FileRef[];
64
+ /** Active trajectory ID if using trail */
65
+ trajectoryId?: string;
66
+ /** Current PDERO phase */
67
+ pderoPhase?: PDEROPhase;
68
+ /** Last update timestamp */
69
+ updatedAt: Date;
70
+ }
71
+ /**
72
+ * Handoff - Cross-session transfer document
73
+ *
74
+ * Permanent, searchable. Created on trajectory completion,
75
+ * context limit, crash, or manual save.
76
+ */
77
+ export interface Handoff {
78
+ /** Unique handoff identifier */
79
+ id: string;
80
+ /** Agent that created this handoff */
81
+ agentName: string;
82
+ /** Agent instance ID that created this handoff */
83
+ agentId?: string;
84
+ /** CLI used (for context) */
85
+ cli: string;
86
+ /** Brief summary of the handoff */
87
+ summary: string;
88
+ /** Task being worked on */
89
+ taskDescription: string;
90
+ /** Work completed before handoff */
91
+ completedWork: string[];
92
+ /** Recommended next steps */
93
+ nextSteps: string[];
94
+ /** Files relevant to the work */
95
+ fileReferences: FileRef[];
96
+ /** Key decisions made */
97
+ decisions: Decision[];
98
+ /** Links to related previous handoffs */
99
+ relatedHandoffs: string[];
100
+ /** When the handoff was created */
101
+ createdAt: Date;
102
+ /** What triggered the handoff */
103
+ triggerReason: HandoffTrigger;
104
+ /** Trajectory ID if created from trajectory completion */
105
+ trajectoryId?: string;
106
+ /** PDERO phase at handoff time */
107
+ pderoPhase?: PDEROPhase;
108
+ /** Confidence level from trajectory */
109
+ confidence?: number;
110
+ /** Learnings extracted from trajectory */
111
+ learnings?: string[];
112
+ }
113
+ /**
114
+ * What triggered handoff creation
115
+ */
116
+ export type HandoffTrigger = 'manual' | 'trajectory_complete' | 'context_limit' | 'auto_restart' | 'crash' | 'session_end';
117
+ /**
118
+ * Continuity command parsed from agent output
119
+ */
120
+ export interface ContinuityCommand {
121
+ /** Command type */
122
+ type: 'save' | 'load' | 'search' | 'uncertain' | 'handoff';
123
+ /** Content for save commands */
124
+ content?: string;
125
+ /** Query for search commands */
126
+ query?: string;
127
+ /** Item for uncertain command */
128
+ item?: string;
129
+ /** Whether to create a handoff (for save) */
130
+ createHandoff?: boolean;
131
+ }
132
+ /**
133
+ * Context to inject on agent startup
134
+ */
135
+ export interface StartupContext {
136
+ /** The ledger if available */
137
+ ledger?: Ledger;
138
+ /** The most recent handoff if available */
139
+ handoff?: Handoff;
140
+ /** Relevant learnings from past sessions */
141
+ learnings?: string[];
142
+ /** Formatted markdown to inject */
143
+ formatted: string;
144
+ }
145
+ /**
146
+ * Continuity storage paths
147
+ */
148
+ export interface ContinuityPaths {
149
+ /** Base continuity directory */
150
+ base: string;
151
+ /** Ledgers directory */
152
+ ledgers: string;
153
+ /** Handoffs directory */
154
+ handoffs: string;
155
+ /** Artifact index database */
156
+ artifactDb: string;
157
+ }
158
+ /**
159
+ * Options for saving a ledger
160
+ */
161
+ export interface SaveLedgerOptions {
162
+ /** Create a handoff as well */
163
+ createHandoff?: boolean;
164
+ /** Trigger reason if creating handoff */
165
+ triggerReason?: HandoffTrigger;
166
+ }
167
+ /**
168
+ * Options for searching handoffs
169
+ */
170
+ export interface SearchOptions {
171
+ /** Filter by agent name */
172
+ agentName?: string;
173
+ /** Maximum results to return */
174
+ limit?: number;
175
+ /** Filter by date range */
176
+ since?: Date;
177
+ /** Filter by trigger reason */
178
+ triggerReason?: HandoffTrigger;
179
+ }
180
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9E;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,SAAS,E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AC,EAAE,MAAM,EAAE,CAAC;IACrB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yCAAyC;IACzC,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,+BAA+B;IAC/B,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@agent-relay/continuity",
3
+ "version": "0.1.0",
4
+ "description": "Session continuity manager for Relay (ledgers, handoffs, resume)",
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
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "clean": "rm -rf dist",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^22.19.3",
26
+ "typescript": "^5.9.3",
27
+ "vitest": "^3.2.4"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }