proofscan 0.8.1 → 0.9.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.
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +74 -3
- package/dist/db/connection.js.map +1 -1
- package/dist/db/events-store.d.ts +70 -1
- package/dist/db/events-store.d.ts.map +1 -1
- package/dist/db/events-store.js +162 -0
- package/dist/db/events-store.js.map +1 -1
- package/dist/db/schema.d.ts +8 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +40 -1
- package/dist/db/schema.js.map +1 -1
- package/dist/db/types.d.ts +12 -0
- package/dist/db/types.d.ts.map +1 -1
- package/dist/shell/inscribe-commands.d.ts +32 -0
- package/dist/shell/inscribe-commands.d.ts.map +1 -0
- package/dist/shell/inscribe-commands.js +461 -0
- package/dist/shell/inscribe-commands.js.map +1 -0
- package/dist/shell/ref-commands.d.ts +32 -0
- package/dist/shell/ref-commands.d.ts.map +1 -0
- package/dist/shell/ref-commands.js +337 -0
- package/dist/shell/ref-commands.js.map +1 -0
- package/dist/shell/ref-resolver.d.ts +199 -0
- package/dist/shell/ref-resolver.d.ts.map +1 -0
- package/dist/shell/ref-resolver.js +423 -0
- package/dist/shell/ref-resolver.js.map +1 -0
- package/dist/shell/repl.d.ts +28 -0
- package/dist/shell/repl.d.ts.map +1 -1
- package/dist/shell/repl.js +170 -6
- package/dist/shell/repl.js.map +1 -1
- package/dist/shell/router-commands.d.ts +18 -1
- package/dist/shell/router-commands.d.ts.map +1 -1
- package/dist/shell/router-commands.js +222 -2
- package/dist/shell/router-commands.js.map +1 -1
- package/dist/shell/tool-commands.d.ts +7 -1
- package/dist/shell/tool-commands.d.ts.map +1 -1
- package/dist/shell/tool-commands.js +187 -5
- package/dist/shell/tool-commands.js.map +1 -1
- package/dist/shell/types.d.ts +10 -0
- package/dist/shell/types.d.ts.map +1 -1
- package/dist/shell/types.js +11 -0
- package/dist/shell/types.js.map +1 -1
- package/dist/types/config.d.ts +13 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell ref commands: ref add, ref ls, ref rm, ref <@target> (Phase 4.1-4.2)
|
|
3
|
+
*
|
|
4
|
+
* These commands manage user-defined references and resolve references.
|
|
5
|
+
*
|
|
6
|
+
* Commands:
|
|
7
|
+
* - ref add <name> @this : Save current context as named reference
|
|
8
|
+
* - ref add <name> @last : Save latest session/rpc as named reference
|
|
9
|
+
* - ref add <name> @rpc:<id> : Save specific RPC as named reference
|
|
10
|
+
* - ref ls : List all user-defined references
|
|
11
|
+
* - ref rm <name> : Remove a user-defined reference
|
|
12
|
+
*
|
|
13
|
+
* Resolve mode (argument starts with @):
|
|
14
|
+
* - ref @this : Resolve and display current context
|
|
15
|
+
* - ref @last : Resolve and display latest session/RPC
|
|
16
|
+
* - ref @rpc:<id> : Resolve and display specific RPC reference
|
|
17
|
+
* - ref @ref:<name> : Resolve and display user-defined reference
|
|
18
|
+
* - ref @... --json : Output RefStruct as JSON
|
|
19
|
+
*
|
|
20
|
+
* Pipe support:
|
|
21
|
+
* - pwd --json | ref add <name> : Save piped JSON as reference
|
|
22
|
+
*/
|
|
23
|
+
import { printSuccess, printError, printInfo, dimText } from './prompt.js';
|
|
24
|
+
import { EventsStore } from '../db/events-store.js';
|
|
25
|
+
import { ConfigManager } from '../config/index.js';
|
|
26
|
+
import { RefResolver, createRefDataProvider, createRefFromContext, parseRef, isRef, refFromJson, refToJson, } from './ref-resolver.js';
|
|
27
|
+
/** Max length for reference names */
|
|
28
|
+
const REF_NAME_MAX_LENGTH = 64;
|
|
29
|
+
/** Pattern for valid reference names: alphanumeric, hyphens, underscores */
|
|
30
|
+
const REF_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
31
|
+
/** Reserved names that cannot be used as reference names */
|
|
32
|
+
const RESERVED_NAMES = ['this', 'last', 'rpc', 'session', 'fav', 'ref'];
|
|
33
|
+
/**
|
|
34
|
+
* Validate reference name
|
|
35
|
+
* @returns Error message if invalid, null if valid
|
|
36
|
+
*/
|
|
37
|
+
function validateRefName(name) {
|
|
38
|
+
if (!name) {
|
|
39
|
+
return 'Reference name is required';
|
|
40
|
+
}
|
|
41
|
+
if (name.startsWith('@')) {
|
|
42
|
+
return `Name cannot start with @: ${name}`;
|
|
43
|
+
}
|
|
44
|
+
if (name.length > REF_NAME_MAX_LENGTH) {
|
|
45
|
+
return `Name too long (max ${REF_NAME_MAX_LENGTH} chars): ${name}`;
|
|
46
|
+
}
|
|
47
|
+
if (!REF_NAME_PATTERN.test(name)) {
|
|
48
|
+
return `Invalid name. Use only letters, numbers, hyphens, and underscores: ${name}`;
|
|
49
|
+
}
|
|
50
|
+
if (RESERVED_NAMES.includes(name.toLowerCase())) {
|
|
51
|
+
return `Reserved name cannot be used: ${name}`;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handle 'ref' command
|
|
57
|
+
*/
|
|
58
|
+
export async function handleRef(args, context, configPath, stdinData) {
|
|
59
|
+
if (args.length === 0) {
|
|
60
|
+
printInfo('Usage: ref <subcommand> or ref <@target>');
|
|
61
|
+
printInfo('');
|
|
62
|
+
printInfo('Subcommands:');
|
|
63
|
+
printInfo(' ref add <name> @this Save current context');
|
|
64
|
+
printInfo(' ref add <name> @last Save latest session/rpc');
|
|
65
|
+
printInfo(' ref add <name> @rpc:<id> Save specific RPC');
|
|
66
|
+
printInfo(' ref ls List all refs');
|
|
67
|
+
printInfo(' ref rm <name> Remove a ref');
|
|
68
|
+
printInfo('');
|
|
69
|
+
printInfo('Resolve mode (@ prefix):');
|
|
70
|
+
printInfo(' ref @this Resolve current context');
|
|
71
|
+
printInfo(' ref @last Resolve latest session/RPC');
|
|
72
|
+
printInfo(' ref @rpc:<id> Resolve specific RPC');
|
|
73
|
+
printInfo(' ref @ref:<name> Resolve saved reference');
|
|
74
|
+
printInfo(' ref @... --json Output as JSON');
|
|
75
|
+
printInfo('');
|
|
76
|
+
printInfo('Pipe support:');
|
|
77
|
+
printInfo(' pwd --json | ref add <name>');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const firstArg = args[0];
|
|
81
|
+
// Resolve mode: if first argument starts with @, resolve the reference
|
|
82
|
+
if (isRef(firstArg)) {
|
|
83
|
+
await handleRefResolve(args, context, configPath);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const subcommand = firstArg;
|
|
87
|
+
const subArgs = args.slice(1);
|
|
88
|
+
switch (subcommand) {
|
|
89
|
+
case 'add':
|
|
90
|
+
await handleRefAdd(subArgs, context, configPath, stdinData);
|
|
91
|
+
break;
|
|
92
|
+
case 'ls':
|
|
93
|
+
case 'list':
|
|
94
|
+
await handleRefLs(subArgs, configPath);
|
|
95
|
+
break;
|
|
96
|
+
case 'rm':
|
|
97
|
+
case 'remove':
|
|
98
|
+
case 'delete':
|
|
99
|
+
await handleRefRm(subArgs, configPath);
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
printError(`Unknown subcommand: ${subcommand}`);
|
|
103
|
+
printInfo('Available: add, ls, rm');
|
|
104
|
+
printInfo('Or use: ref @this, ref @last, ref @rpc:<id>, ref @ref:<name>');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Handle 'ref @...' - resolve and display a reference (Phase 4.2)
|
|
109
|
+
*
|
|
110
|
+
* This is "resolve mode" - when the first argument starts with @
|
|
111
|
+
*
|
|
112
|
+
* Examples:
|
|
113
|
+
* ref @this - Show current context as reference
|
|
114
|
+
* ref @last - Show latest session/RPC as reference
|
|
115
|
+
* ref @rpc:abc123 - Show specific RPC reference
|
|
116
|
+
* ref @ref:myname - Show saved user-defined reference
|
|
117
|
+
* ref @this --json - Output as JSON for piping
|
|
118
|
+
*/
|
|
119
|
+
async function handleRefResolve(args, context, configPath) {
|
|
120
|
+
const isJson = args.includes('--json');
|
|
121
|
+
const target = args.find(a => !a.startsWith('-') && a.startsWith('@'));
|
|
122
|
+
if (!target) {
|
|
123
|
+
printError('No reference target specified');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const manager = new ConfigManager(configPath);
|
|
127
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
128
|
+
const dataProvider = createRefDataProvider(eventsStore);
|
|
129
|
+
const resolver = new RefResolver(dataProvider);
|
|
130
|
+
// Special handling for @this - use createRefFromContext directly
|
|
131
|
+
const parsed = parseRef(target);
|
|
132
|
+
let ref;
|
|
133
|
+
if (parsed.type === 'this') {
|
|
134
|
+
ref = createRefFromContext(context);
|
|
135
|
+
ref.source = '@this';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const result = resolver.resolve(target, context);
|
|
139
|
+
if (!result.success || !result.ref) {
|
|
140
|
+
printError(result.error || `Failed to resolve: ${target}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
ref = result.ref;
|
|
144
|
+
}
|
|
145
|
+
// Output
|
|
146
|
+
if (isJson) {
|
|
147
|
+
console.log(refToJson(ref));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// Human-readable format
|
|
151
|
+
console.log();
|
|
152
|
+
console.log(`Reference: ${target}`);
|
|
153
|
+
console.log(` Kind: ${ref.kind}`);
|
|
154
|
+
if (ref.connector)
|
|
155
|
+
console.log(` Connector: ${ref.connector}`);
|
|
156
|
+
if (ref.session)
|
|
157
|
+
console.log(` Session: ${ref.session.slice(0, 8)}...`);
|
|
158
|
+
if (ref.rpc)
|
|
159
|
+
console.log(` RPC: ${ref.rpc}`);
|
|
160
|
+
if (ref.proto)
|
|
161
|
+
console.log(` Proto: ${ref.proto}`);
|
|
162
|
+
if (ref.level)
|
|
163
|
+
console.log(` Level: ${ref.level}`);
|
|
164
|
+
if (ref.captured_at)
|
|
165
|
+
console.log(` Captured: ${ref.captured_at}`);
|
|
166
|
+
console.log();
|
|
167
|
+
printInfo('Tip: Use --json to get JSON output for piping');
|
|
168
|
+
printInfo(' Use "show ..." to view resource details instead of address');
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Handle 'ref add' - save a reference
|
|
172
|
+
*/
|
|
173
|
+
async function handleRefAdd(args, context, configPath, stdinData) {
|
|
174
|
+
// Check for stdin data first (pipe support)
|
|
175
|
+
if (stdinData) {
|
|
176
|
+
// Format: ref add <name> (with piped JSON)
|
|
177
|
+
const name = args[0];
|
|
178
|
+
if (!name) {
|
|
179
|
+
printError('Usage: ... | ref add <name>');
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const validationError = validateRefName(name);
|
|
183
|
+
if (validationError) {
|
|
184
|
+
printError(validationError);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const ref = refFromJson(stdinData);
|
|
188
|
+
if (!ref) {
|
|
189
|
+
printError('Invalid JSON input');
|
|
190
|
+
printInfo('Expected RefStruct JSON (use pwd --json to generate)');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
await saveRef(name, ref, configPath);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
// Format: ref add <name> @ref
|
|
197
|
+
if (args.length < 2) {
|
|
198
|
+
printError('Usage: ref add <name> <@ref>');
|
|
199
|
+
printInfo('Example: ref add myref @this');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const name = args[0];
|
|
203
|
+
const refArg = args[1];
|
|
204
|
+
const validationError = validateRefName(name);
|
|
205
|
+
if (validationError) {
|
|
206
|
+
printError(validationError);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// Parse and resolve the reference
|
|
210
|
+
const parsed = parseRef(refArg);
|
|
211
|
+
if (parsed.type === 'literal') {
|
|
212
|
+
printError(`Not a valid reference: ${refArg}`);
|
|
213
|
+
printInfo('Valid refs: @this, @last, @rpc:<id>, @session:<id>');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const manager = new ConfigManager(configPath);
|
|
217
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
218
|
+
const dataProvider = createRefDataProvider(eventsStore);
|
|
219
|
+
const resolver = new RefResolver(dataProvider);
|
|
220
|
+
// Handle @this specially - use current context directly
|
|
221
|
+
let ref;
|
|
222
|
+
if (parsed.type === 'this') {
|
|
223
|
+
ref = createRefFromContext(context);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const result = resolver.resolve(refArg, context);
|
|
227
|
+
if (!result.success || !result.ref) {
|
|
228
|
+
printError(result.error || `Failed to resolve: ${refArg}`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
ref = result.ref;
|
|
232
|
+
}
|
|
233
|
+
await saveRef(name, ref, configPath);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Save a reference to the database
|
|
237
|
+
*/
|
|
238
|
+
async function saveRef(name, ref, configPath) {
|
|
239
|
+
const manager = new ConfigManager(configPath);
|
|
240
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
241
|
+
eventsStore.saveUserRef(name, {
|
|
242
|
+
kind: ref.kind,
|
|
243
|
+
connector: ref.connector,
|
|
244
|
+
session: ref.session,
|
|
245
|
+
rpc: ref.rpc,
|
|
246
|
+
proto: ref.proto,
|
|
247
|
+
level: ref.level,
|
|
248
|
+
captured_at: ref.captured_at,
|
|
249
|
+
});
|
|
250
|
+
printSuccess(`Saved reference: ${name}`);
|
|
251
|
+
printInfo(` Kind: ${ref.kind}`);
|
|
252
|
+
if (ref.connector)
|
|
253
|
+
printInfo(` Connector: ${ref.connector}`);
|
|
254
|
+
if (ref.session)
|
|
255
|
+
printInfo(` Session: ${ref.session.slice(0, 8)}`);
|
|
256
|
+
if (ref.rpc)
|
|
257
|
+
printInfo(` RPC: ${ref.rpc}`);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Handle 'ref ls' - list all references
|
|
261
|
+
*/
|
|
262
|
+
async function handleRefLs(args, configPath) {
|
|
263
|
+
const isJson = args.includes('--json');
|
|
264
|
+
const manager = new ConfigManager(configPath);
|
|
265
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
266
|
+
const refs = eventsStore.listUserRefs();
|
|
267
|
+
if (refs.length === 0) {
|
|
268
|
+
printInfo('No user-defined references');
|
|
269
|
+
printInfo('Create one with: ref add <name> @this');
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (isJson) {
|
|
273
|
+
console.log(JSON.stringify(refs, null, 2));
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// Table format
|
|
277
|
+
const isTTY = process.stdout.isTTY;
|
|
278
|
+
console.log();
|
|
279
|
+
// Calculate column widths
|
|
280
|
+
const maxName = Math.max(8, ...refs.map(r => r.name.length));
|
|
281
|
+
// Header
|
|
282
|
+
console.log(dimText('Name', isTTY).padEnd(isTTY ? maxName + 9 : maxName) + ' ' +
|
|
283
|
+
dimText('Kind', isTTY).padEnd(isTTY ? 17 : 10) + ' ' +
|
|
284
|
+
dimText('Target', isTTY));
|
|
285
|
+
console.log(dimText('-'.repeat(maxName + 50), isTTY));
|
|
286
|
+
// Rows
|
|
287
|
+
for (const ref of refs) {
|
|
288
|
+
let target = '';
|
|
289
|
+
if (ref.connector)
|
|
290
|
+
target = ref.connector;
|
|
291
|
+
if (ref.session)
|
|
292
|
+
target += '/' + ref.session.slice(0, 8);
|
|
293
|
+
if (ref.rpc)
|
|
294
|
+
target += '/' + ref.rpc.slice(0, 8);
|
|
295
|
+
if (!target)
|
|
296
|
+
target = '(root)';
|
|
297
|
+
console.log(ref.name.padEnd(maxName) + ' ' +
|
|
298
|
+
ref.kind.padEnd(10) + ' ' +
|
|
299
|
+
target);
|
|
300
|
+
}
|
|
301
|
+
console.log();
|
|
302
|
+
printInfo(`${refs.length} reference(s). Use: @ref:<name> to reference`);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Handle 'ref rm' - remove a reference
|
|
306
|
+
*/
|
|
307
|
+
async function handleRefRm(args, configPath) {
|
|
308
|
+
const name = args.find(a => !a.startsWith('-'));
|
|
309
|
+
if (!name) {
|
|
310
|
+
printError('Usage: ref rm <name>');
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const manager = new ConfigManager(configPath);
|
|
314
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
315
|
+
const deleted = eventsStore.deleteUserRef(name);
|
|
316
|
+
if (deleted) {
|
|
317
|
+
printSuccess(`Deleted reference: ${name}`);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
printError(`Reference not found: ${name}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Get ref names for completion
|
|
325
|
+
*/
|
|
326
|
+
export async function getRefNamesForCompletion(configPath) {
|
|
327
|
+
try {
|
|
328
|
+
const manager = new ConfigManager(configPath);
|
|
329
|
+
const eventsStore = new EventsStore(manager.getConfigDir());
|
|
330
|
+
const refs = eventsStore.listUserRefs();
|
|
331
|
+
return refs.map(r => r.name);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=ref-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref-commands.js","sourceRoot":"","sources":["../../src/shell/ref-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,KAAK,EACL,WAAW,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a,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RefResolver - Unified reference resolution for shell (Phase 4.1)
|
|
3
|
+
*
|
|
4
|
+
* @ is the dereference operator - used only when resolving references.
|
|
5
|
+
* References are first-class citizens that connect all shell operations.
|
|
6
|
+
*
|
|
7
|
+
* Built-in References:
|
|
8
|
+
* - @this : Current context (connector/session based on level)
|
|
9
|
+
* - @last : Latest session or RPC (context-dependent)
|
|
10
|
+
* - @rpc:<id> : Explicit RPC reference
|
|
11
|
+
* - @session:<id> : Explicit session reference
|
|
12
|
+
* - @fav:<name> : Favorites (named references from DB)
|
|
13
|
+
* - @ref:<name> : User-defined references (Phase 4.2)
|
|
14
|
+
*/
|
|
15
|
+
import type { ShellContext, ProtoType } from './types.js';
|
|
16
|
+
import { type ContextLevel } from './router-commands.js';
|
|
17
|
+
/**
|
|
18
|
+
* Reference kind - what type of entity the reference points to
|
|
19
|
+
*/
|
|
20
|
+
export type RefKind = 'connector' | 'session' | 'rpc' | 'tool_call' | 'context';
|
|
21
|
+
/**
|
|
22
|
+
* RefStruct - The universal reference structure
|
|
23
|
+
*
|
|
24
|
+
* This is the core data structure that represents any reference in the system.
|
|
25
|
+
* It can be serialized to JSON for pipe operations and stored in the database.
|
|
26
|
+
*/
|
|
27
|
+
export interface RefStruct {
|
|
28
|
+
/** Reference kind */
|
|
29
|
+
kind: RefKind;
|
|
30
|
+
/** Connector ID (always present except for root context) */
|
|
31
|
+
connector?: string;
|
|
32
|
+
/** Session ID (present for session/rpc/tool_call refs) */
|
|
33
|
+
session?: string;
|
|
34
|
+
/** RPC ID (present for rpc refs) */
|
|
35
|
+
rpc?: string;
|
|
36
|
+
/** Protocol type (mcp/a2a/?) */
|
|
37
|
+
proto?: ProtoType;
|
|
38
|
+
/** Context level when captured */
|
|
39
|
+
level?: ContextLevel;
|
|
40
|
+
/** Timestamp when reference was created */
|
|
41
|
+
captured_at?: string;
|
|
42
|
+
/** Original reference string (e.g., "@this", "@rpc:abc123") */
|
|
43
|
+
source?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parsed reference from user input
|
|
47
|
+
*/
|
|
48
|
+
export interface ParsedRef {
|
|
49
|
+
/** Reference type */
|
|
50
|
+
type: 'this' | 'last' | 'rpc' | 'session' | 'fav' | 'ref' | 'literal';
|
|
51
|
+
/** Optional identifier (e.g., RPC ID, favorite name) */
|
|
52
|
+
id?: string;
|
|
53
|
+
/** Original input string */
|
|
54
|
+
raw: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolution result
|
|
58
|
+
*/
|
|
59
|
+
export interface ResolveResult {
|
|
60
|
+
success: boolean;
|
|
61
|
+
ref?: RefStruct;
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Data provider interface for resolution
|
|
66
|
+
* Allows RefResolver to query database without direct dependency
|
|
67
|
+
*/
|
|
68
|
+
export interface RefDataProvider {
|
|
69
|
+
/** Get latest session for a connector (or globally if no connector) */
|
|
70
|
+
getLatestSession(connectorId?: string): {
|
|
71
|
+
session_id: string;
|
|
72
|
+
connector_id: string;
|
|
73
|
+
} | null;
|
|
74
|
+
/** Get latest RPC for a session */
|
|
75
|
+
getLatestRpc(sessionId: string): {
|
|
76
|
+
rpc_id: string;
|
|
77
|
+
method: string;
|
|
78
|
+
} | null;
|
|
79
|
+
/** Get RPC by ID */
|
|
80
|
+
getRpcById(rpcId: string, sessionId?: string): {
|
|
81
|
+
rpc_id: string;
|
|
82
|
+
session_id: string;
|
|
83
|
+
method: string;
|
|
84
|
+
} | null;
|
|
85
|
+
/** Get session by ID or prefix */
|
|
86
|
+
getSessionByPrefix(prefix: string, connectorId?: string): {
|
|
87
|
+
session_id: string;
|
|
88
|
+
connector_id: string;
|
|
89
|
+
} | null;
|
|
90
|
+
/** Get user-defined ref by name */
|
|
91
|
+
getUserRef(name: string): RefStruct | null;
|
|
92
|
+
/** Get favorite by name */
|
|
93
|
+
getFavorite(name: string): RefStruct | null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parse a reference string into structured form
|
|
97
|
+
*
|
|
98
|
+
* Supported formats:
|
|
99
|
+
* - @this -> { type: 'this' }
|
|
100
|
+
* - @last -> { type: 'last' }
|
|
101
|
+
* - @rpc:abc123 -> { type: 'rpc', id: 'abc123' }
|
|
102
|
+
* - @session:xyz -> { type: 'session', id: 'xyz' }
|
|
103
|
+
* - @fav:myname -> { type: 'fav', id: 'myname' }
|
|
104
|
+
* - @ref:myref -> { type: 'ref', id: 'myref' }
|
|
105
|
+
* - anything else -> { type: 'literal' }
|
|
106
|
+
*/
|
|
107
|
+
export declare function parseRef(input: string): ParsedRef;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a string is a reference
|
|
110
|
+
*/
|
|
111
|
+
export declare function isRef(input: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* RefResolver - Central reference resolution service
|
|
114
|
+
*/
|
|
115
|
+
export declare class RefResolver {
|
|
116
|
+
private dataProvider;
|
|
117
|
+
constructor(dataProvider: RefDataProvider);
|
|
118
|
+
/**
|
|
119
|
+
* Resolve @this to current context
|
|
120
|
+
*/
|
|
121
|
+
resolveThis(context: ShellContext): ResolveResult;
|
|
122
|
+
/**
|
|
123
|
+
* Resolve @last to latest session or RPC
|
|
124
|
+
*/
|
|
125
|
+
resolveLast(context: ShellContext): ResolveResult;
|
|
126
|
+
/**
|
|
127
|
+
* Resolve @rpc:<id> to specific RPC
|
|
128
|
+
*/
|
|
129
|
+
resolveRpc(rpcId: string, context: ShellContext): ResolveResult;
|
|
130
|
+
/**
|
|
131
|
+
* Resolve @session:<id> to specific session
|
|
132
|
+
*/
|
|
133
|
+
resolveSession(sessionId: string, context: ShellContext): ResolveResult;
|
|
134
|
+
/**
|
|
135
|
+
* Resolve @fav:<name> to favorite
|
|
136
|
+
*/
|
|
137
|
+
resolveFavorite(name: string): ResolveResult;
|
|
138
|
+
/**
|
|
139
|
+
* Resolve @ref:<name> to user-defined reference
|
|
140
|
+
*/
|
|
141
|
+
resolveUserRef(name: string): ResolveResult;
|
|
142
|
+
/**
|
|
143
|
+
* Resolve any reference string
|
|
144
|
+
*/
|
|
145
|
+
resolve(input: string, context: ShellContext): ResolveResult;
|
|
146
|
+
/**
|
|
147
|
+
* Resolve multiple arguments, replacing refs with their resolved values
|
|
148
|
+
* Returns the args with refs replaced by their target IDs
|
|
149
|
+
*/
|
|
150
|
+
resolveArgs(args: string[], context: ShellContext): {
|
|
151
|
+
resolved: string[];
|
|
152
|
+
errors: string[];
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a RefStruct from current shell context
|
|
157
|
+
*/
|
|
158
|
+
export declare function createRefFromContext(context: ShellContext): RefStruct;
|
|
159
|
+
/**
|
|
160
|
+
* Serialize RefStruct to JSON string
|
|
161
|
+
*/
|
|
162
|
+
export declare function refToJson(ref: RefStruct): string;
|
|
163
|
+
/**
|
|
164
|
+
* Parse RefStruct from JSON string
|
|
165
|
+
*/
|
|
166
|
+
export declare function refFromJson(json: string): RefStruct | null;
|
|
167
|
+
/**
|
|
168
|
+
* Create a RefDataProvider from EventsStore
|
|
169
|
+
* This adapts the EventsStore to the RefDataProvider interface
|
|
170
|
+
*/
|
|
171
|
+
export declare function createRefDataProvider(eventsStore: {
|
|
172
|
+
getLatestSession(connectorId?: string): {
|
|
173
|
+
session_id: string;
|
|
174
|
+
connector_id: string;
|
|
175
|
+
} | null;
|
|
176
|
+
getLatestRpc(sessionId: string): {
|
|
177
|
+
rpc_id: string;
|
|
178
|
+
method: string;
|
|
179
|
+
} | null;
|
|
180
|
+
getRpcById(rpcId: string, sessionId?: string): {
|
|
181
|
+
rpc_id: string;
|
|
182
|
+
session_id: string;
|
|
183
|
+
method: string;
|
|
184
|
+
} | null;
|
|
185
|
+
getSessionByPrefix(prefix: string, connectorId?: string): {
|
|
186
|
+
session_id: string;
|
|
187
|
+
connector_id: string;
|
|
188
|
+
} | null;
|
|
189
|
+
getUserRef(name: string): {
|
|
190
|
+
kind: RefKind;
|
|
191
|
+
connector: string | null;
|
|
192
|
+
session: string | null;
|
|
193
|
+
rpc: string | null;
|
|
194
|
+
proto: string | null;
|
|
195
|
+
level: string | null;
|
|
196
|
+
captured_at: string;
|
|
197
|
+
} | null;
|
|
198
|
+
}): RefDataProvider;
|
|
199
|
+
//# sourceMappingURL=ref-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref-resolver.d.ts","sourceRoot":"","sources":["../../src/shell/ref-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,qBAAqB;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,K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