agent-relay 12.2.5 → 12.2.6
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/cli/commands/product-surfaces.d.ts +50 -0
- package/dist/cli/commands/product-surfaces.d.ts.map +1 -1
- package/dist/cli/commands/product-surfaces.js +209 -1
- package/dist/cli/commands/product-surfaces.js.map +1 -1
- package/dist/cli/lib/product-surface-store.d.ts +126 -0
- package/dist/cli/lib/product-surface-store.d.ts.map +1 -0
- package/dist/cli/lib/product-surface-store.js +404 -0
- package/dist/cli/lib/product-surface-store.js.map +1 -0
- package/dist/index.cjs +4 -1
- package/package.json +13 -13
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Command } from 'commander';
|
|
10
10
|
import { type RelayCliSurface } from '@agent-relay/cli-surface';
|
|
11
|
+
import { type SurfacePackage } from '../lib/product-surface-store.js';
|
|
11
12
|
import { type RelayCliSurfaceDependencies } from '../lib/relay-cli-surface.js';
|
|
12
13
|
/** How one product group is mounted. */
|
|
13
14
|
export interface ProductSurfaceDefinition {
|
|
@@ -46,9 +47,58 @@ export interface ProductSurfaceDependencies extends RelayCliSurfaceDependencies
|
|
|
46
47
|
}
|
|
47
48
|
/** The product groups `agent-relay` mounts. */
|
|
48
49
|
export declare const PRODUCT_SURFACES: readonly ProductSurfaceDefinition[];
|
|
50
|
+
/**
|
|
51
|
+
* The npm spec behind each mounted surface, mirroring `packages/cli/package.json`.
|
|
52
|
+
*
|
|
53
|
+
* Only the compiled standalone binary reads this: it has no `node_modules` and
|
|
54
|
+
* no manifest on disk, so when a specifier does not resolve it installs the
|
|
55
|
+
* package itself, and the version it installs has to be the one the npm
|
|
56
|
+
* distribution would have had. `product-surfaces.test.ts` asserts these ranges
|
|
57
|
+
* still match the manifest, because a pin bumped in one place and not the other
|
|
58
|
+
* is invisible until someone runs the binary.
|
|
59
|
+
*/
|
|
60
|
+
export declare const SURFACE_PACKAGES: Readonly<Record<string, SurfacePackage>>;
|
|
61
|
+
/** Seams for the standalone fallback; the defaults are the real store. */
|
|
62
|
+
export interface SurfaceImportDependencies {
|
|
63
|
+
/** Plain `import()`. The only path the npm distribution ever takes. */
|
|
64
|
+
importSpecifier: (specifier: string) => Promise<unknown>;
|
|
65
|
+
/** Whether this process is the compiled binary, which carries no packages. */
|
|
66
|
+
isStandalone: () => boolean;
|
|
67
|
+
/** Install the package on demand; returns the directory holding it. */
|
|
68
|
+
provision: (pkg: SurfacePackage) => Promise<string>;
|
|
69
|
+
/** Import the specifier out of a provisioned directory. */
|
|
70
|
+
importFromStore: (installRoot: string, specifier: string) => Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Injectable dependencies for surface import, with optional context for provisioned options.
|
|
74
|
+
*/
|
|
75
|
+
export interface SurfaceImportDependenciesWithContext extends SurfaceImportDependencies {
|
|
76
|
+
/** Optional product name for which to create options (e.g., 'sessions'). */
|
|
77
|
+
optionsFor?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Import a mounted surface, provisioning it first if this binary has to.
|
|
81
|
+
*
|
|
82
|
+
* On npm — every install, every CI runner, every test in this repo — the first
|
|
83
|
+
* `import()` resolves and this returns exactly what `import(specifier)` returns.
|
|
84
|
+
* Nothing below the `catch` runs, and no directory is created.
|
|
85
|
+
*
|
|
86
|
+
* The compiled standalone binary is the one caller that falls through: it is a
|
|
87
|
+
* single file with no `node_modules`, so a mounted SDK has to be installed
|
|
88
|
+
* before it can be imported (#1795). Only a specifier this CLI pins is eligible
|
|
89
|
+
* — a caller naming something else (the end-to-end test mounts product builds
|
|
90
|
+
* by absolute path) gets its original error back.
|
|
91
|
+
*
|
|
92
|
+
* @param specifier - Package subpath exporting `createRelayCliSurface`.
|
|
93
|
+
* @param overrides - Optional dependencies and context (including optionsFor for provisioned surfaces).
|
|
94
|
+
*/
|
|
95
|
+
export declare function importProductSurface(specifier: string, overrides?: Partial<SurfaceImportDependenciesWithContext>): Promise<unknown>;
|
|
49
96
|
/**
|
|
50
97
|
* Import a product's surface and prepare it for mounting.
|
|
51
98
|
*
|
|
99
|
+
* For the compiled standalone binary, passes context (optionsFor) to ensure
|
|
100
|
+
* provisioned surfaces are created with the same options as the npm distribution.
|
|
101
|
+
*
|
|
52
102
|
* @param definition - The group being loaded.
|
|
53
103
|
* @param deps - Import hook and output sink.
|
|
54
104
|
* @returns The surface, extended when the definition asks for it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-surfaces.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/product-surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAMlG,OAAO,EAAwB,KAAK,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAErG,wCAAwC;AACxC,MAAM,WAAW,wBAAwB;IACvC,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;CAChF;AAOD,oFAAoF;AACpF,MAAM,WAAW,0BAA2B,SAAQ,2BAA2B;IAC7E,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD;AAqBD,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,EAAE,SAA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AS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,8EAA8E;IAC9E,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,uEAAuE;IACvE,SAAS,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,2DAA2D;IAC3D,eAAe,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,oCAAqC,SAAQ,yBAAyB;IACrF,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,OAAO,CAAC,oCAAoC,CAAM,GAC5D,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAoLD;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,wBAAwB,EACpC,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,OAAO,CAAC,0BAA0B,CAAM,EACnD,WAAW,GAAE,SAAS,wBAAwB,EAAqB,GAClE,IAAI,CAmBN"}
|
|
@@ -10,6 +10,7 @@ import { composeSurfaces } from '@agent-relay/cli-surface';
|
|
|
10
10
|
import { describeError } from '../lib/describe-error.js';
|
|
11
11
|
import { redactCredentialValues } from '@agent-relay/cloud/redact';
|
|
12
12
|
import { defaultExit } from '../lib/exit.js';
|
|
13
|
+
import { loadSurfaceFromStore, isCompiledStandalone, provisionSurfacePackage, PROVISION_ERROR_CODE, SurfaceProvisionError, } from '../lib/product-surface-store.js';
|
|
13
14
|
import { mountRelayCliSurface } from '../lib/relay-cli-surface.js';
|
|
14
15
|
/**
|
|
15
16
|
* The real process streams, with credentials masked on stderr.
|
|
@@ -51,6 +52,121 @@ export const PRODUCT_SURFACES = [
|
|
|
51
52
|
extend: composeSessionReplay,
|
|
52
53
|
},
|
|
53
54
|
];
|
|
55
|
+
/**
|
|
56
|
+
* The npm spec behind each mounted surface, mirroring `packages/cli/package.json`.
|
|
57
|
+
*
|
|
58
|
+
* Only the compiled standalone binary reads this: it has no `node_modules` and
|
|
59
|
+
* no manifest on disk, so when a specifier does not resolve it installs the
|
|
60
|
+
* package itself, and the version it installs has to be the one the npm
|
|
61
|
+
* distribution would have had. `product-surfaces.test.ts` asserts these ranges
|
|
62
|
+
* still match the manifest, because a pin bumped in one place and not the other
|
|
63
|
+
* is invisible until someone runs the binary.
|
|
64
|
+
*/
|
|
65
|
+
export const SURFACE_PACKAGES = {
|
|
66
|
+
'@relayfile/sdk/relay-cli': { name: '@relayfile/sdk', range: '^0.10.64' },
|
|
67
|
+
'@relayflows/sdk/relay-cli': { name: '@relayflows/sdk', range: '^2.0.19' },
|
|
68
|
+
'ai-hist/relay-cli': {
|
|
69
|
+
name: 'ai-hist',
|
|
70
|
+
range: '^0.18.1',
|
|
71
|
+
// The cloud client is an optional dependency of this CLI, not of ai-hist,
|
|
72
|
+
// so provisioning ai-hist alone leaves the child unable to build it and
|
|
73
|
+
// `sessions cloud …` vanishes in the standalone binary only.
|
|
74
|
+
companions: [{ name: '@relayhistory/cloud-client', range: '^0.1.1' }],
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
function withImportDefaults(overrides) {
|
|
78
|
+
return {
|
|
79
|
+
importSpecifier: overrides.importSpecifier ?? ((specifier) => import(specifier)),
|
|
80
|
+
isStandalone: overrides.isStandalone ?? (() => isCompiledStandalone()),
|
|
81
|
+
provision: overrides.provision ?? ((pkg) => provisionSurfacePackage(pkg)),
|
|
82
|
+
optionsFor: overrides.optionsFor,
|
|
83
|
+
// Wrapped as a module so the caller's shape does not change: the store
|
|
84
|
+
// returns a ready surface, because `run` crosses a process boundary and
|
|
85
|
+
// cannot be reconstructed from an imported module.
|
|
86
|
+
importFromStore: overrides.importFromStore ??
|
|
87
|
+
(async (installRoot, specifier) => {
|
|
88
|
+
// Derived from the specifier, not taken from overrides: nothing in the
|
|
89
|
+
// command registration sets `optionsFor`, so relying on it meant the
|
|
90
|
+
// runner was always told "no options" and `sessions cloud …` was
|
|
91
|
+
// missing from the standalone binary while present on npm — the two
|
|
92
|
+
// distributions declaring different command trees. The override stays
|
|
93
|
+
// as a test seam.
|
|
94
|
+
const optionsFor = overrides.optionsFor ?? (specifier === 'ai-hist/relay-cli' ? 'sessions' : undefined);
|
|
95
|
+
let relayhistoryConfig;
|
|
96
|
+
if (optionsFor === 'sessions') {
|
|
97
|
+
try {
|
|
98
|
+
// Get the Relayhistory configuration that would be used in the normal flow
|
|
99
|
+
const { readStoredRelayhistoryAuth, resolveRelayhistoryConfig } = await import('./session.js');
|
|
100
|
+
const config = resolveRelayhistoryConfig(readStoredRelayhistoryAuth());
|
|
101
|
+
if (config.baseUrl && config.token) {
|
|
102
|
+
relayhistoryConfig = config;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// If helpers can't be imported, continue without config
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
createRelayCliSurface: await loadSurfaceFromStore(installRoot, specifier, optionsFor, relayhistoryConfig).then((surface) => () => surface),
|
|
111
|
+
};
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Whether the import failed because nothing answered to the specifier.
|
|
117
|
+
*
|
|
118
|
+
* Node reports this as a code; Bun's compiled runtime words it as a resolution
|
|
119
|
+
* failure and does not always carry one. Anything else — a package that exists
|
|
120
|
+
* and threw while evaluating, say — must propagate untouched, since installing
|
|
121
|
+
* a second copy of it would not help and would hide the real error.
|
|
122
|
+
*/
|
|
123
|
+
function isUnresolvedSpecifier(error) {
|
|
124
|
+
const code = error?.code;
|
|
125
|
+
if (code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND')
|
|
126
|
+
return true;
|
|
127
|
+
const message = error?.message ?? '';
|
|
128
|
+
return /Cannot find (module|package)|Could not resolve/i.test(message);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Import a mounted surface, provisioning it first if this binary has to.
|
|
132
|
+
*
|
|
133
|
+
* On npm — every install, every CI runner, every test in this repo — the first
|
|
134
|
+
* `import()` resolves and this returns exactly what `import(specifier)` returns.
|
|
135
|
+
* Nothing below the `catch` runs, and no directory is created.
|
|
136
|
+
*
|
|
137
|
+
* The compiled standalone binary is the one caller that falls through: it is a
|
|
138
|
+
* single file with no `node_modules`, so a mounted SDK has to be installed
|
|
139
|
+
* before it can be imported (#1795). Only a specifier this CLI pins is eligible
|
|
140
|
+
* — a caller naming something else (the end-to-end test mounts product builds
|
|
141
|
+
* by absolute path) gets its original error back.
|
|
142
|
+
*
|
|
143
|
+
* @param specifier - Package subpath exporting `createRelayCliSurface`.
|
|
144
|
+
* @param overrides - Optional dependencies and context (including optionsFor for provisioned surfaces).
|
|
145
|
+
*/
|
|
146
|
+
export async function importProductSurface(specifier, overrides = {}) {
|
|
147
|
+
const deps = withImportDefaults(overrides);
|
|
148
|
+
try {
|
|
149
|
+
return await deps.importSpecifier(specifier);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
const pkg = SURFACE_PACKAGES[specifier];
|
|
153
|
+
if (!pkg || !isUnresolvedSpecifier(error) || !deps.isStandalone())
|
|
154
|
+
throw error;
|
|
155
|
+
const installRoot = await deps.provision(pkg);
|
|
156
|
+
try {
|
|
157
|
+
return await deps.importFromStore(installRoot, specifier);
|
|
158
|
+
}
|
|
159
|
+
catch (storeError) {
|
|
160
|
+
// The package is on disk now, so "not installed" — what the generic
|
|
161
|
+
// handler would say about an ERR_MODULE_NOT_FOUND — is simply false, and
|
|
162
|
+
// sends the operator to reinstall something already there.
|
|
163
|
+
if (!isUnresolvedSpecifier(storeError))
|
|
164
|
+
throw storeError;
|
|
165
|
+
throw new SurfaceProvisionError(`${pkg.name} is installed at ${installRoot}, but this build cannot import it from there.\n` +
|
|
166
|
+
`${describeError(storeError)}`, { cause: storeError });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
54
170
|
/**
|
|
55
171
|
* Specifier for the optional cloud client.
|
|
56
172
|
*
|
|
@@ -92,6 +208,61 @@ async function composeSessionReplay(base) {
|
|
|
92
208
|
parts: [base, createSessionReplaySurface(base.version)],
|
|
93
209
|
});
|
|
94
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The package Node says it could not find, when it says so.
|
|
213
|
+
*
|
|
214
|
+
* ERR_MODULE_NOT_FOUND covers multiple situations and the code alone does
|
|
215
|
+
* not separate them:
|
|
216
|
+
*
|
|
217
|
+
* Cannot find package '@relayfile/sdk' imported from … -> genuinely absent
|
|
218
|
+
* Cannot find module '/abs/path/…/dist/index.js' -> present, incomplete
|
|
219
|
+
* Cannot find module 'some-dep' -> missing dependency
|
|
220
|
+
*
|
|
221
|
+
* The second and third happen while an install is still writing or a dependency
|
|
222
|
+
* is missing, and misreporting them as "not installed" sends the operator
|
|
223
|
+
* to reinstall the wrong thing.
|
|
224
|
+
*/
|
|
225
|
+
function missingPackageFrom(error) {
|
|
226
|
+
const message = error?.message ?? '';
|
|
227
|
+
return /Cannot find package '([^']+)'/.exec(message)?.[1];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Whether Node named a file rather than a package.
|
|
231
|
+
*
|
|
232
|
+
* Detected positively on POSIX (/path/to/file), Windows (C:\path\to\file),
|
|
233
|
+
* and UNC (\\server\share\path) paths. An error shape this does not recognise
|
|
234
|
+
* should fall through to the plain "not installed" advice, which is right far
|
|
235
|
+
* more often than "incomplete" would be.
|
|
236
|
+
*/
|
|
237
|
+
function missingFileFrom(error) {
|
|
238
|
+
const message = error?.message ?? '';
|
|
239
|
+
// Match POSIX paths (/), Windows paths (C:\), and UNC paths (\\)
|
|
240
|
+
return /Cannot find module '((?:\/|[A-Za-z]:\\|\\\\)[^']*)'/.exec(message)?.[1];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Whether the module import failed because a transitive dependency is missing.
|
|
244
|
+
*
|
|
245
|
+
* Bare module names in CommonJS errors indicate missing dependencies, distinct
|
|
246
|
+
* from package exports (which are qualified names). A CommonJS module that was
|
|
247
|
+
* present but incomplete would name a file instead.
|
|
248
|
+
*/
|
|
249
|
+
function missingDependencyFrom(error) {
|
|
250
|
+
const message = error?.message ?? '';
|
|
251
|
+
const named = /Cannot find module '([^']+)'/.exec(message)?.[1];
|
|
252
|
+
if (named === undefined)
|
|
253
|
+
return undefined;
|
|
254
|
+
// Reject anything path-shaped rather than trusting the first character. A
|
|
255
|
+
// leading-character test reads `C:\\Users\\...` as a bare name starting with
|
|
256
|
+
// "C", so a Windows incomplete install was reported as a missing dependency
|
|
257
|
+
// called `C:\\Users\\...`. Excluding paths here also makes the order of the
|
|
258
|
+
// checks below irrelevant, which is one less thing to get wrong.
|
|
259
|
+
if (/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(named))
|
|
260
|
+
return undefined;
|
|
261
|
+
// A specifier may contain forward slashes (`@scope/pkg`), never a backslash.
|
|
262
|
+
if (named.includes('\\'))
|
|
263
|
+
return undefined;
|
|
264
|
+
return named;
|
|
265
|
+
}
|
|
95
266
|
/**
|
|
96
267
|
* Explain an import failure in terms the operator can act on.
|
|
97
268
|
*
|
|
@@ -105,7 +276,41 @@ function describeLoadFailure(definition, error) {
|
|
|
105
276
|
.split('/')
|
|
106
277
|
.slice(0, definition.specifier.startsWith('@') ? 2 : 1)
|
|
107
278
|
.join('/');
|
|
279
|
+
// Provisioning already composed the operator-facing text — which package,
|
|
280
|
+
// which directory, and what to do about it. Re-describing it here would only
|
|
281
|
+
// bury that behind a second framing.
|
|
282
|
+
if (code === PROVISION_ERROR_CODE) {
|
|
283
|
+
return `\`agent-relay ${definition.as}\` could not be prepared.\n${describeError(error)}`;
|
|
284
|
+
}
|
|
108
285
|
if (code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND') {
|
|
286
|
+
// Check what Node said is missing: a package name, a file path, or a bare module
|
|
287
|
+
const missingPackage = missingPackageFrom(error);
|
|
288
|
+
const missingFile = missingFileFrom(error);
|
|
289
|
+
const missingDependency = missingDependencyFrom(error);
|
|
290
|
+
// A package import that failed: a dependency of the product, not the product itself.
|
|
291
|
+
// Reinstalling the product alone would not fix it, and naming the wrong package
|
|
292
|
+
// wastes the operator.
|
|
293
|
+
if (missingPackage !== undefined && missingPackage !== packageName) {
|
|
294
|
+
return (`\`agent-relay ${definition.as}\` could not load ${packageName}: ` +
|
|
295
|
+
`it depends on ${missingPackage}, which is not installed.\n` +
|
|
296
|
+
`Reinstall agent-relay to repair the dependency tree.`);
|
|
297
|
+
}
|
|
298
|
+
// A CommonJS bare module name: a transitive dependency is missing. Likely caused
|
|
299
|
+
// by an interrupted install or version mismatch in the dependency tree.
|
|
300
|
+
if (missingDependency !== undefined) {
|
|
301
|
+
return (`\`agent-relay ${definition.as}\` could not load ${packageName}: ` +
|
|
302
|
+
`it depends on ${missingDependency}, which is not installed.\n` +
|
|
303
|
+
`Reinstall agent-relay to repair the dependency tree.`);
|
|
304
|
+
}
|
|
305
|
+
// Node named a file path rather than a package name, so the package directory
|
|
306
|
+
// exists but its contents do not. An interrupted or concurrent install looks like
|
|
307
|
+
// this, and it resolves itself once the install finishes.
|
|
308
|
+
if (missingFile !== undefined) {
|
|
309
|
+
return (`\`agent-relay ${definition.as}\` could not load ${packageName}: ` +
|
|
310
|
+
`it is installed but incomplete.\n` +
|
|
311
|
+
`If an install is running, wait for it to finish and retry; ` +
|
|
312
|
+
`otherwise reinstall agent-relay.\n${describeError(error)}`);
|
|
313
|
+
}
|
|
109
314
|
return (`\`agent-relay ${definition.as}\` needs ${packageName}, which is not installed.\n` +
|
|
110
315
|
`Reinstall agent-relay, or install ${packageName} alongside it.`);
|
|
111
316
|
}
|
|
@@ -118,6 +323,9 @@ function describeLoadFailure(definition, error) {
|
|
|
118
323
|
/**
|
|
119
324
|
* Import a product's surface and prepare it for mounting.
|
|
120
325
|
*
|
|
326
|
+
* For the compiled standalone binary, passes context (optionsFor) to ensure
|
|
327
|
+
* provisioned surfaces are created with the same options as the npm distribution.
|
|
328
|
+
*
|
|
121
329
|
* @param definition - The group being loaded.
|
|
122
330
|
* @param deps - Import hook and output sink.
|
|
123
331
|
* @returns The surface, extended when the definition asks for it.
|
|
@@ -149,7 +357,7 @@ export async function loadProductSurface(definition, deps) {
|
|
|
149
357
|
*/
|
|
150
358
|
export function registerProductSurfaceCommands(program, overrides = {}, definitions = PRODUCT_SURFACES) {
|
|
151
359
|
const deps = {
|
|
152
|
-
importModule: overrides.importModule ??
|
|
360
|
+
importModule: overrides.importModule ?? importProductSurface,
|
|
153
361
|
io: overrides.io ?? processIo(),
|
|
154
362
|
exit: overrides.exit ?? defaultExit,
|
|
155
363
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-surfaces.js","sourceRoot":"","sources":["../../../src/cli/commands/product-surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,eAAe,EAAyC,MAAM,0BAA0B,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAoC,MAAM,6BAA6B,CAAC;AA4CrG;;;;;;;;GAQG;AACH,SAAS,SAAS;IAChB,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAC9C,sEAAsE;QAC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AAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAgB,EAChB,YAAiD,EAAE,EACnD,cAAmD,gBAAgB;IAEnE,MAAM,IAAI,GAA+B;QACvC,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,oBAAoB;QAC5D,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,SAAS,EAAE;QAC/B,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,WAAW;KACpC,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,oBAAoB,CAClB,OAAO,EACP;YACE,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChF,IAAI,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC;SACjD,EACD,IAAI,CACL,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand package tree for the mounted product SDKs.
|
|
3
|
+
*
|
|
4
|
+
* The npm distribution needs none of this: `@relayfile/sdk`, `@relayflows/sdk`
|
|
5
|
+
* and `ai-hist` are ordinary dependencies of `agent-relay`, so
|
|
6
|
+
* `import('@relayfile/sdk/relay-cli')` resolves and nothing here ever runs.
|
|
7
|
+
*
|
|
8
|
+
* The compiled standalone binary is the problem (#1795). It is one file with no
|
|
9
|
+
* node_modules, so every mounted group failed with MODULE_NOT_FOUND — reported
|
|
10
|
+
* as "not installed", in a distribution where installing cannot help. Bundling
|
|
11
|
+
* the SDKs does not fix it, and was tried:
|
|
12
|
+
*
|
|
13
|
+
* - `@relayfile/sdk/relay-cli` locates and spawns a Go binary; exec needs a
|
|
14
|
+
* real path on disk, not a bundled module
|
|
15
|
+
* - `ai-hist` dlopens a native addon through a *variable* specifier, which no
|
|
16
|
+
* bundler can see
|
|
17
|
+
* - all three read data files relative to `import.meta.url`, which relocates
|
|
18
|
+
* into Bun's `/$bunfs/root` once compiled
|
|
19
|
+
*
|
|
20
|
+
* So instead of pulling the packages into the binary, the binary puts them back
|
|
21
|
+
* on disk: a real `npm install` of the version pinned in
|
|
22
|
+
* `packages/cli/package.json`, under `~/.agentworkforce/relay/surfaces`, and the
|
|
23
|
+
* surface is imported from there. Real files satisfy dlopen, exec,
|
|
24
|
+
* `import.meta.url` and variable specifiers at once.
|
|
25
|
+
*/
|
|
26
|
+
import type { RelayCliSurface } from '@agent-relay/cli-surface';
|
|
27
|
+
/** How long a single provisioning install may take before it is abandoned. */
|
|
28
|
+
export declare const INSTALL_TIMEOUT_MS: number;
|
|
29
|
+
/** A product SDK to provision, named exactly as the CLI manifest pins it. */
|
|
30
|
+
export interface SurfacePackage {
|
|
31
|
+
/** Bare package name, e.g. `@relayfile/sdk`. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Version range copied from `packages/cli/package.json`, e.g. `^0.10.64`. */
|
|
34
|
+
range: string;
|
|
35
|
+
/**
|
|
36
|
+
* Packages the surface needs but does not depend on.
|
|
37
|
+
*
|
|
38
|
+
* `sessions` builds its Relayhistory cloud client from
|
|
39
|
+
* `@relayhistory/cloud-client`, which is an optional dependency of the CLI
|
|
40
|
+
* rather than of `ai-hist`. Installing only the surface leaves the child
|
|
41
|
+
* unable to import it, so `sessions cloud …` silently disappears in the
|
|
42
|
+
* standalone binary while working on npm — the two distributions would
|
|
43
|
+
* declare different command trees.
|
|
44
|
+
*/
|
|
45
|
+
companions?: readonly SurfacePackage[];
|
|
46
|
+
}
|
|
47
|
+
/** Injectable seams; the defaults are the real store on the real filesystem. */
|
|
48
|
+
export interface SurfaceStoreDependencies {
|
|
49
|
+
/** Directory holding every provisioned tree. */
|
|
50
|
+
root: string;
|
|
51
|
+
/** Install `pkg` into an already-created `directory`. */
|
|
52
|
+
install: (pkg: SurfacePackage, directory: string) => Promise<void>;
|
|
53
|
+
/** Progress and failure notices. Never stdout: that is the caller's data. */
|
|
54
|
+
notify: (line: string) => void;
|
|
55
|
+
}
|
|
56
|
+
/** Error code carried by every failure this module reports to the mount. */
|
|
57
|
+
export declare const PROVISION_ERROR_CODE = "ERR_RELAY_SURFACE_PROVISION";
|
|
58
|
+
/**
|
|
59
|
+
* A provisioning failure with an operator-facing message.
|
|
60
|
+
*
|
|
61
|
+
* Tagged with a code so `describeLoadFailure` can print {@link Error.message}
|
|
62
|
+
* verbatim. The message already names the package, the directory and the fix;
|
|
63
|
+
* wrapping it in "Could not load … :" or letting a stack through would bury
|
|
64
|
+
* that.
|
|
65
|
+
*/
|
|
66
|
+
export declare class SurfaceProvisionError extends Error {
|
|
67
|
+
readonly code = "ERR_RELAY_SURFACE_PROVISION";
|
|
68
|
+
constructor(message: string, options?: {
|
|
69
|
+
cause?: unknown;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** `~/.agentworkforce/relay/surfaces`, or the configured data directory. */
|
|
73
|
+
export declare function defaultSurfaceStoreRoot(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Whether this process is the compiled standalone binary.
|
|
76
|
+
*
|
|
77
|
+
* Both halves matter. `isBunRuntime` alone is true for anyone running the CLI
|
|
78
|
+
* under `bun`, where node_modules exists and provisioning would be pure waste;
|
|
79
|
+
* the `/$bunfs/root` entrypoint is what distinguishes `bun build --compile`
|
|
80
|
+
* output, which has no node_modules at all.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isCompiledStandalone(argv?: readonly string[]): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Where `pkg` is provisioned under `root`.
|
|
85
|
+
*
|
|
86
|
+
* Keyed by name *and* range, so upgrading the pin provisions a fresh tree
|
|
87
|
+
* rather than reusing a stale one. The readable prefix is for whoever opens the
|
|
88
|
+
* directory; the digest is what actually separates `^0.10.64` from `~0.10.64`,
|
|
89
|
+
* which sanitizing alone collapses onto the same name.
|
|
90
|
+
*/
|
|
91
|
+
export declare function surfaceInstallPath(root: string, pkg: SurfacePackage): string;
|
|
92
|
+
/**
|
|
93
|
+
* Ensure `pkg` is installed in the store and return the directory holding it.
|
|
94
|
+
*
|
|
95
|
+
* @param pkg - Package name and the range pinned by the CLI manifest.
|
|
96
|
+
* @param overrides - Test seams for the store root, installer, and notices.
|
|
97
|
+
* @returns Absolute path to a directory with `node_modules` and the loader.
|
|
98
|
+
* @throws {SurfaceProvisionError} When the install cannot be completed, with a
|
|
99
|
+
* message naming the fix rather than a stack.
|
|
100
|
+
*/
|
|
101
|
+
export declare function provisionSurfacePackage(pkg: SurfacePackage, overrides?: Partial<SurfaceStoreDependencies>): Promise<string>;
|
|
102
|
+
/**
|
|
103
|
+
* The surface's declared command tree, read out of a provisioned tree.
|
|
104
|
+
*
|
|
105
|
+
* Only the declaration crosses the process boundary — `run` cannot, so the
|
|
106
|
+
* returned surface's `run` delegates to another child process.
|
|
107
|
+
*
|
|
108
|
+
* @param installRoot - Directory holding the provisioned package.
|
|
109
|
+
* @param specifier - Package subpath exporting `createRelayCliSurface`.
|
|
110
|
+
* @param optionsFor - Optional product name for which to create options (e.g., 'sessions').
|
|
111
|
+
* @param relayhistoryConfig - Optional Relayhistory cloud client config for sessions.
|
|
112
|
+
*/
|
|
113
|
+
export declare function loadSurfaceFromStore(installRoot: string, specifier: string, optionsFor?: string, relayhistoryConfig?: {
|
|
114
|
+
baseUrl: string;
|
|
115
|
+
token: string;
|
|
116
|
+
}): Promise<RelayCliSurface>;
|
|
117
|
+
/**
|
|
118
|
+
* Turn a failed `npm install` into one actionable line.
|
|
119
|
+
*
|
|
120
|
+
* npm's own output is dozens of lines ending in a path to a debug log the user
|
|
121
|
+
* of a standalone binary has no reason to read. What decides their next move is
|
|
122
|
+
* the first error npm reported — `ENOTFOUND`, `E403`, `ETARGET` — so that is
|
|
123
|
+
* what gets lifted out.
|
|
124
|
+
*/
|
|
125
|
+
export declare function describeInstallFailure(command: string, error: unknown): string;
|
|
126
|
+
//# sourceMappingURL=product-surface-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-surface-store.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/product-surface-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAU5E,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AAiGjD,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACxC;AAED,gFAAgF;AAChF,MAAM,WAAW,wBAAwB;IACvC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,6EAA6E;IAC7E,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAElE;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,iCAAwB;gBAEzB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAiB,GAAG,OAAO,CAEpF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAM5E;AAmBD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,cAAc,EACnB,SAAS,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAChD,OAAO,CAAC,MAAM,CAAC,CAajB;AA6ID;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,kBAAkB,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,eAAe,CAAC,CAkC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAc9E"}
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand package tree for the mounted product SDKs.
|
|
3
|
+
*
|
|
4
|
+
* The npm distribution needs none of this: `@relayfile/sdk`, `@relayflows/sdk`
|
|
5
|
+
* and `ai-hist` are ordinary dependencies of `agent-relay`, so
|
|
6
|
+
* `import('@relayfile/sdk/relay-cli')` resolves and nothing here ever runs.
|
|
7
|
+
*
|
|
8
|
+
* The compiled standalone binary is the problem (#1795). It is one file with no
|
|
9
|
+
* node_modules, so every mounted group failed with MODULE_NOT_FOUND — reported
|
|
10
|
+
* as "not installed", in a distribution where installing cannot help. Bundling
|
|
11
|
+
* the SDKs does not fix it, and was tried:
|
|
12
|
+
*
|
|
13
|
+
* - `@relayfile/sdk/relay-cli` locates and spawns a Go binary; exec needs a
|
|
14
|
+
* real path on disk, not a bundled module
|
|
15
|
+
* - `ai-hist` dlopens a native addon through a *variable* specifier, which no
|
|
16
|
+
* bundler can see
|
|
17
|
+
* - all three read data files relative to `import.meta.url`, which relocates
|
|
18
|
+
* into Bun's `/$bunfs/root` once compiled
|
|
19
|
+
*
|
|
20
|
+
* So instead of pulling the packages into the binary, the binary puts them back
|
|
21
|
+
* on disk: a real `npm install` of the version pinned in
|
|
22
|
+
* `packages/cli/package.json`, under `~/.agentworkforce/relay/surfaces`, and the
|
|
23
|
+
* surface is imported from there. Real files satisfy dlopen, exec,
|
|
24
|
+
* `import.meta.url` and variable specifiers at once.
|
|
25
|
+
*/
|
|
26
|
+
import { execFile, spawn } from 'node:child_process';
|
|
27
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
28
|
+
import fs from 'node:fs';
|
|
29
|
+
import os from 'node:os';
|
|
30
|
+
import path from 'node:path';
|
|
31
|
+
import { promisify } from 'node:util';
|
|
32
|
+
import { redactCredentialValues } from '@agent-relay/cloud/redact';
|
|
33
|
+
import { describeError } from './describe-error.js';
|
|
34
|
+
import { isBundledBunEntrypointPath } from './agent-relay-mcp-command.js';
|
|
35
|
+
import { isBunRuntime } from './node-definition-loader.js';
|
|
36
|
+
const execFileAsync = promisify(execFile);
|
|
37
|
+
/** How long a single provisioning install may take before it is abandoned. */
|
|
38
|
+
export const INSTALL_TIMEOUT_MS = 10 * 60 * 1000;
|
|
39
|
+
/** Largest npm output we will buffer while waiting for the install. */
|
|
40
|
+
const INSTALL_MAX_BUFFER = 16 * 1024 * 1024;
|
|
41
|
+
/**
|
|
42
|
+
* Name of the generated module that performs the import.
|
|
43
|
+
*
|
|
44
|
+
* It has to live *inside* the provisioned directory. A bare specifier resolves
|
|
45
|
+
* against the `node_modules` directories above the importing module, so an
|
|
46
|
+
* `import()` written in the CLI's own source could never see this tree no
|
|
47
|
+
* matter where it is; one written next to it sees nothing else.
|
|
48
|
+
*/
|
|
49
|
+
const RUNNER_FILENAME = 'run-surface.mjs';
|
|
50
|
+
const RUNNER_SOURCE = `// Generated by agent-relay. Do not edit.
|
|
51
|
+
//
|
|
52
|
+
// Entry point for a child process that runs one mounted product surface out
|
|
53
|
+
// of the node_modules beside this file.
|
|
54
|
+
//
|
|
55
|
+
// Why a child process rather than importing into the CLI: inside the compiled
|
|
56
|
+
// standalone binary, Bun cannot resolve bare specifiers from a tree it loaded
|
|
57
|
+
// by absolute path. Resolving the surface entry point by hand gets as far as
|
|
58
|
+
// the entry point; its own imports then fail the same way, and there is no
|
|
59
|
+
// bottom to that. NODE_PATH does not change it. Running under the node that
|
|
60
|
+
// performed the install sidesteps module resolution entirely, and costs one
|
|
61
|
+
// process per invocation.
|
|
62
|
+
//
|
|
63
|
+
// Two modes, because the host renders help from the declared command tree and
|
|
64
|
+
// must not forward it — help has to say agent-relay, not the product's name:
|
|
65
|
+
//
|
|
66
|
+
// describe [--options-for=surface] specifier
|
|
67
|
+
// run [--options-for=surface] specifier [argv...]
|
|
68
|
+
import process from 'node:process';
|
|
69
|
+
|
|
70
|
+
const rawArgs = process.argv.slice(2);
|
|
71
|
+
let optionsFor = undefined;
|
|
72
|
+
let argIndex = 0;
|
|
73
|
+
|
|
74
|
+
// Parse --options-for flag
|
|
75
|
+
if (rawArgs[0]?.startsWith('--options-for=')) {
|
|
76
|
+
optionsFor = rawArgs[0].slice('--options-for='.length);
|
|
77
|
+
argIndex = 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const [mode, specifier, ...argv] = rawArgs.slice(argIndex);
|
|
81
|
+
|
|
82
|
+
const module = await import(specifier);
|
|
83
|
+
if (typeof module.createRelayCliSurface !== 'function') {
|
|
84
|
+
process.stderr.write(specifier + ' does not export createRelayCliSurface()\\n');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Resolve options from environment if the parent provided them.
|
|
89
|
+
// The parent passes cloud client configuration through environment variables so the
|
|
90
|
+
// child can create the client without importing from the parent's module tree.
|
|
91
|
+
let options = undefined;
|
|
92
|
+
if (optionsFor === 'sessions') {
|
|
93
|
+
const baseUrl = process.env['RELAY_RELAYHISTORY_BASE_URL'];
|
|
94
|
+
const token = process.env['RELAY_RELAYHISTORY_TOKEN'];
|
|
95
|
+
if (baseUrl && token) {
|
|
96
|
+
try {
|
|
97
|
+
const cloudClientModule = await import('@relayhistory/cloud-client');
|
|
98
|
+
options = {
|
|
99
|
+
cloud: cloudClientModule.createRelayhistoryCloudClient({ baseUrl, token })
|
|
100
|
+
};
|
|
101
|
+
} catch {
|
|
102
|
+
// Cloud client is optional; local session commands still work without it
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const surface = await module.createRelayCliSurface(options);
|
|
108
|
+
|
|
109
|
+
if (mode === 'describe') {
|
|
110
|
+
// Write JSON description and let streams flush before exiting.
|
|
111
|
+
// process.exit does not wait for pipe buffers, so output can be truncated.
|
|
112
|
+
const json = JSON.stringify({
|
|
113
|
+
id: surface.id,
|
|
114
|
+
version: surface.version,
|
|
115
|
+
contract: surface.contract,
|
|
116
|
+
commands: surface.commands,
|
|
117
|
+
});
|
|
118
|
+
process.stdout.write(json, () => process.exit(0));
|
|
119
|
+
} else {
|
|
120
|
+
// stdout and stderr are written straight through: the host pipes them into
|
|
121
|
+
// its own io sink, and chunks stay bytes so a binary payload survives.
|
|
122
|
+
const code = await surface.run(argv, {
|
|
123
|
+
stdout: (chunk) => process.stdout.write(chunk),
|
|
124
|
+
stderr: (chunk) => process.stderr.write(chunk),
|
|
125
|
+
});
|
|
126
|
+
// Exit only after all writes have been flushed.
|
|
127
|
+
process.stdout.write('', () => process.exit(typeof code === 'number' ? code : 0));
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
/** Error code carried by every failure this module reports to the mount. */
|
|
131
|
+
export const PROVISION_ERROR_CODE = 'ERR_RELAY_SURFACE_PROVISION';
|
|
132
|
+
/**
|
|
133
|
+
* A provisioning failure with an operator-facing message.
|
|
134
|
+
*
|
|
135
|
+
* Tagged with a code so `describeLoadFailure` can print {@link Error.message}
|
|
136
|
+
* verbatim. The message already names the package, the directory and the fix;
|
|
137
|
+
* wrapping it in "Could not load … :" or letting a stack through would bury
|
|
138
|
+
* that.
|
|
139
|
+
*/
|
|
140
|
+
export class SurfaceProvisionError extends Error {
|
|
141
|
+
code = PROVISION_ERROR_CODE;
|
|
142
|
+
constructor(message, options) {
|
|
143
|
+
super(message, options);
|
|
144
|
+
this.name = 'SurfaceProvisionError';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** `~/.agentworkforce/relay/surfaces`, or the configured data directory. */
|
|
148
|
+
export function defaultSurfaceStoreRoot() {
|
|
149
|
+
const dataDir = process.env['AGENT_RELAY_DATA_DIR'] || path.join(os.homedir(), '.agentworkforce/relay');
|
|
150
|
+
return path.join(dataDir, 'surfaces');
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Whether this process is the compiled standalone binary.
|
|
154
|
+
*
|
|
155
|
+
* Both halves matter. `isBunRuntime` alone is true for anyone running the CLI
|
|
156
|
+
* under `bun`, where node_modules exists and provisioning would be pure waste;
|
|
157
|
+
* the `/$bunfs/root` entrypoint is what distinguishes `bun build --compile`
|
|
158
|
+
* output, which has no node_modules at all.
|
|
159
|
+
*/
|
|
160
|
+
export function isCompiledStandalone(argv = process.argv) {
|
|
161
|
+
return isBunRuntime() && isBundledBunEntrypointPath(argv[1] ?? '');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Where `pkg` is provisioned under `root`.
|
|
165
|
+
*
|
|
166
|
+
* Keyed by name *and* range, so upgrading the pin provisions a fresh tree
|
|
167
|
+
* rather than reusing a stale one. The readable prefix is for whoever opens the
|
|
168
|
+
* directory; the digest is what actually separates `^0.10.64` from `~0.10.64`,
|
|
169
|
+
* which sanitizing alone collapses onto the same name.
|
|
170
|
+
*/
|
|
171
|
+
export function surfaceInstallPath(root, pkg) {
|
|
172
|
+
const digest = createHash('sha256').update(`${pkg.name}@${pkg.range}`).digest('hex').slice(0, 8);
|
|
173
|
+
// `-` is deliberately not in the kept set: leaving it in makes `sdk-^0.10.64`
|
|
174
|
+
// read as `sdk--0.10.64`, since the separator and the range operator are adjacent.
|
|
175
|
+
const readable = `${pkg.name}-${pkg.range}`.replace(/[^A-Za-z0-9.]+/g, '-').replace(/^-+|-+$/g, '');
|
|
176
|
+
return path.join(root, `${readable}-${digest}`);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Provisioning runs already in flight, keyed by their destination.
|
|
180
|
+
*
|
|
181
|
+
* Two groups invoked in one process, or one group whose loader is retried,
|
|
182
|
+
* must not start two npm installs of the same package. Cross-process races are
|
|
183
|
+
* handled separately, by the atomic rename in {@link provisionOnce}.
|
|
184
|
+
*/
|
|
185
|
+
const inFlight = new Map();
|
|
186
|
+
function defaults(overrides) {
|
|
187
|
+
return {
|
|
188
|
+
root: overrides.root ?? defaultSurfaceStoreRoot(),
|
|
189
|
+
install: overrides.install ?? npmInstall,
|
|
190
|
+
notify: overrides.notify ?? ((line) => process.stderr.write(`${line}\n`)),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Ensure `pkg` is installed in the store and return the directory holding it.
|
|
195
|
+
*
|
|
196
|
+
* @param pkg - Package name and the range pinned by the CLI manifest.
|
|
197
|
+
* @param overrides - Test seams for the store root, installer, and notices.
|
|
198
|
+
* @returns Absolute path to a directory with `node_modules` and the loader.
|
|
199
|
+
* @throws {SurfaceProvisionError} When the install cannot be completed, with a
|
|
200
|
+
* message naming the fix rather than a stack.
|
|
201
|
+
*/
|
|
202
|
+
export async function provisionSurfacePackage(pkg, overrides = {}) {
|
|
203
|
+
const deps = defaults(overrides);
|
|
204
|
+
const target = surfaceInstallPath(deps.root, pkg);
|
|
205
|
+
if (fs.existsSync(path.join(target, RUNNER_FILENAME)))
|
|
206
|
+
return target;
|
|
207
|
+
const existing = inFlight.get(target);
|
|
208
|
+
if (existing)
|
|
209
|
+
return existing;
|
|
210
|
+
const run = provisionOnce(pkg, target, deps).finally(() => {
|
|
211
|
+
inFlight.delete(target);
|
|
212
|
+
});
|
|
213
|
+
inFlight.set(target, run);
|
|
214
|
+
return run;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Install into a private staging directory, then publish it with one rename.
|
|
218
|
+
*
|
|
219
|
+
* The rename is what makes a concurrent second process safe: the destination
|
|
220
|
+
* either does not exist or is a finished tree, never a half-written one, so a
|
|
221
|
+
* reader can never import from an install that is still running. The loser of
|
|
222
|
+
* the race discards its own work and adopts the winner's — both trees hold the
|
|
223
|
+
* same pinned version, so there is nothing to reconcile.
|
|
224
|
+
*/
|
|
225
|
+
async function provisionOnce(pkg, target, deps) {
|
|
226
|
+
const spec = `${pkg.name}@${pkg.range}`;
|
|
227
|
+
fs.mkdirSync(deps.root, { recursive: true });
|
|
228
|
+
// Unique per attempt, so two processes never write into the same staging
|
|
229
|
+
// tree and npm never sees another install's partial node_modules.
|
|
230
|
+
const staging = `${target}.staging-${process.pid}-${randomBytes(4).toString('hex')}`;
|
|
231
|
+
fs.mkdirSync(staging, { recursive: true });
|
|
232
|
+
try {
|
|
233
|
+
// npm walks up from its cwd looking for a manifest; without this it would
|
|
234
|
+
// find the user's project (or this repo) and install into that instead.
|
|
235
|
+
fs.writeFileSync(path.join(staging, 'package.json'), `${JSON.stringify({
|
|
236
|
+
name: 'agent-relay-surface',
|
|
237
|
+
version: '0.0.0',
|
|
238
|
+
private: true,
|
|
239
|
+
dependencies: { [pkg.name]: pkg.range },
|
|
240
|
+
}, null, 2)}\n`);
|
|
241
|
+
fs.writeFileSync(path.join(staging, RUNNER_FILENAME), RUNNER_SOURCE);
|
|
242
|
+
// A silent multi-second npm install is indistinguishable from a hang, and
|
|
243
|
+
// this one is minutes on a cold cache.
|
|
244
|
+
deps.notify(`agent-relay: ${spec} is not bundled into the standalone binary; installing it now.\n` +
|
|
245
|
+
` -> ${target}\n` +
|
|
246
|
+
` This runs once per version. Later runs reuse it.`);
|
|
247
|
+
const started = Date.now();
|
|
248
|
+
try {
|
|
249
|
+
await deps.install(pkg, staging);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
throw new SurfaceProvisionError(`${spec} could not be installed into ${deps.root}.\n` +
|
|
253
|
+
`${describeError(error)}\n` +
|
|
254
|
+
`The standalone agent-relay binary installs the product SDKs on first use, ` +
|
|
255
|
+
`so this needs \`npm\` on PATH and network access to the npm registry.\n` +
|
|
256
|
+
`Retry when online, or install agent-relay from npm (\`npm i -g agent-relay\`), ` +
|
|
257
|
+
`which ships ${pkg.name} directly.`, { cause: error });
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
fs.renameSync(staging, target);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
// Another process published the same version between our existence check
|
|
264
|
+
// and this rename. Its tree is the same install, so use it.
|
|
265
|
+
if (!fs.existsSync(path.join(target, RUNNER_FILENAME)))
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
deps.notify(`agent-relay: ${spec} ready (${Math.round((Date.now() - started) / 1000)}s).`);
|
|
269
|
+
return target;
|
|
270
|
+
}
|
|
271
|
+
finally {
|
|
272
|
+
// A no-op after a successful rename; on any failure it is what keeps a
|
|
273
|
+
// dead staging tree from accumulating in the store.
|
|
274
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Run the surface runner in a child process and collect its result.
|
|
279
|
+
*
|
|
280
|
+
* `node` is the interpreter because `node` is what performed the install: a
|
|
281
|
+
* provisioned tree exists only if npm ran, and npm implies node. The compiled
|
|
282
|
+
* binary cannot run these itself — see RUNNER_SOURCE.
|
|
283
|
+
*/
|
|
284
|
+
function runnerProcess(installRoot, args, io, optionsFor, relayhistoryConfig) {
|
|
285
|
+
const runner = path.join(installRoot, RUNNER_FILENAME);
|
|
286
|
+
const runnerArgs = optionsFor ? [`--options-for=${optionsFor}`, ...args] : args;
|
|
287
|
+
// Pass cloud client config through environment if configured.
|
|
288
|
+
const env = { ...process.env };
|
|
289
|
+
if (relayhistoryConfig) {
|
|
290
|
+
env['RELAY_RELAYHISTORY_BASE_URL'] = relayhistoryConfig.baseUrl;
|
|
291
|
+
env['RELAY_RELAYHISTORY_TOKEN'] = relayhistoryConfig.token;
|
|
292
|
+
}
|
|
293
|
+
return new Promise((resolve, reject) => {
|
|
294
|
+
const child = spawn(process.execPath.endsWith('node') ? process.execPath : 'node', [runner, ...runnerArgs], {
|
|
295
|
+
// Do not change cwd: product commands may read relative paths (e.g., mount roots,
|
|
296
|
+
// output files), and those should be relative to where the user invoked the CLI.
|
|
297
|
+
cwd: process.cwd(),
|
|
298
|
+
// stdin inherited so an interactive product prompt still works.
|
|
299
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
300
|
+
env,
|
|
301
|
+
});
|
|
302
|
+
let stdout = '';
|
|
303
|
+
let stderr = '';
|
|
304
|
+
child.stdout?.on('data', (chunk) => {
|
|
305
|
+
if (io)
|
|
306
|
+
io.stdout(chunk);
|
|
307
|
+
else
|
|
308
|
+
stdout += chunk.toString('utf8');
|
|
309
|
+
});
|
|
310
|
+
child.stderr?.on('data', (chunk) => {
|
|
311
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
312
|
+
stderr += text;
|
|
313
|
+
if (io) {
|
|
314
|
+
// Redact credentials in stderr before passing to io, since the child's
|
|
315
|
+
// stderr may contain argv that the npm path masks.
|
|
316
|
+
io.stderr(redactCredentialValues(text));
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
child.on('error', reject);
|
|
320
|
+
child.on('close', (code) => {
|
|
321
|
+
// Let all pending writes flush before resolving.
|
|
322
|
+
setImmediate(() => resolve({ code: code ?? 1, stdout, stderr }));
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The surface's declared command tree, read out of a provisioned tree.
|
|
328
|
+
*
|
|
329
|
+
* Only the declaration crosses the process boundary — `run` cannot, so the
|
|
330
|
+
* returned surface's `run` delegates to another child process.
|
|
331
|
+
*
|
|
332
|
+
* @param installRoot - Directory holding the provisioned package.
|
|
333
|
+
* @param specifier - Package subpath exporting `createRelayCliSurface`.
|
|
334
|
+
* @param optionsFor - Optional product name for which to create options (e.g., 'sessions').
|
|
335
|
+
* @param relayhistoryConfig - Optional Relayhistory cloud client config for sessions.
|
|
336
|
+
*/
|
|
337
|
+
export async function loadSurfaceFromStore(installRoot, specifier, optionsFor, relayhistoryConfig) {
|
|
338
|
+
const described = await runnerProcess(installRoot, ['describe', specifier], undefined, optionsFor, relayhistoryConfig);
|
|
339
|
+
if (described.code !== 0) {
|
|
340
|
+
// If describe failed, show the child's stderr so the operator sees the real error
|
|
341
|
+
// (missing Go binary, native addon not compiled, factory threw, etc.) instead of
|
|
342
|
+
// just being told to reinstall. Only suggest reinstall if stderr is empty.
|
|
343
|
+
const detail = described.stderr.trim();
|
|
344
|
+
throw new SurfaceProvisionError(detail
|
|
345
|
+
? `The provisioned package tree at ${installRoot} could not describe ${specifier}:\n${detail}`
|
|
346
|
+
: `The provisioned package tree at ${installRoot} could not describe ${specifier}.\n` +
|
|
347
|
+
'Delete that directory and retry; it will be reinstalled.');
|
|
348
|
+
}
|
|
349
|
+
const declaration = JSON.parse(described.stdout);
|
|
350
|
+
return {
|
|
351
|
+
...declaration,
|
|
352
|
+
run: async (argv, io) => {
|
|
353
|
+
const result = await runnerProcess(installRoot, ['run', specifier, ...argv], io, optionsFor, relayhistoryConfig);
|
|
354
|
+
return result.code;
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Turn a failed `npm install` into one actionable line.
|
|
360
|
+
*
|
|
361
|
+
* npm's own output is dozens of lines ending in a path to a debug log the user
|
|
362
|
+
* of a standalone binary has no reason to read. What decides their next move is
|
|
363
|
+
* the first error npm reported — `ENOTFOUND`, `E403`, `ETARGET` — so that is
|
|
364
|
+
* what gets lifted out.
|
|
365
|
+
*/
|
|
366
|
+
export function describeInstallFailure(command, error) {
|
|
367
|
+
const code = error?.code;
|
|
368
|
+
if (code === 'ENOENT') {
|
|
369
|
+
return `\`${command}\` is not on PATH.`;
|
|
370
|
+
}
|
|
371
|
+
if (error?.killed === true) {
|
|
372
|
+
return `\`${command} install\` timed out after ${Math.round(INSTALL_TIMEOUT_MS / 60_000)} minutes.`;
|
|
373
|
+
}
|
|
374
|
+
const lines = String(error?.stderr ?? '')
|
|
375
|
+
.split('\n')
|
|
376
|
+
.map((line) => line.trim())
|
|
377
|
+
.filter((line) => line !== '')
|
|
378
|
+
.slice(0, 3);
|
|
379
|
+
return lines.length > 0 ? redactCredentialValues(lines.join('\n')) : describeError(error);
|
|
380
|
+
}
|
|
381
|
+
/** The real installer: one `npm install` scoped to the staging directory. */
|
|
382
|
+
async function npmInstall(pkg, directory) {
|
|
383
|
+
const command = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
384
|
+
try {
|
|
385
|
+
await execFileAsync(command, [
|
|
386
|
+
'install',
|
|
387
|
+
`${pkg.name}@${pkg.range}`,
|
|
388
|
+
...(pkg.companions ?? []).map((companion) => `${companion.name}@${companion.range}`),
|
|
389
|
+
'--no-audit',
|
|
390
|
+
'--no-fund',
|
|
391
|
+
'--loglevel=error',
|
|
392
|
+
], {
|
|
393
|
+
cwd: directory,
|
|
394
|
+
timeout: INSTALL_TIMEOUT_MS,
|
|
395
|
+
maxBuffer: INSTALL_MAX_BUFFER,
|
|
396
|
+
// The update notifier writes to stderr and can outlive the install.
|
|
397
|
+
env: { ...process.env, npm_config_update_notifier: 'false' },
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
throw new Error(describeInstallFailure(command, error), { cause: error });
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=product-surface-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACpF,YAAY;YACZ,WAAW;YACX,kBAAkB;SACnB,EACD;YACE,GAAG,EAAE,SAAS;YACd,OAAO,EAAE,kBAAkB;YAC3B,SAAS,EAAE,kBAAkB;YAC7B,oEAAoE;YACpE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,0BAA0B,EAAE,OAAO,EAAE;SAC7D,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -303,7 +303,7 @@ __export(index_exports, {
|
|
|
303
303
|
module.exports = __toCommonJS(index_exports);
|
|
304
304
|
|
|
305
305
|
// ../../node_modules/@relaycast/sdk/dist/version.js
|
|
306
|
-
var SDK_VERSION = "8.11.
|
|
306
|
+
var SDK_VERSION = "8.11.3";
|
|
307
307
|
|
|
308
308
|
// ../../node_modules/zod/v4/classic/external.js
|
|
309
309
|
var external_exports = {};
|
|
@@ -21338,6 +21338,9 @@ var FleetNodeRegisterMessageSchema = external_exports.object({
|
|
|
21338
21338
|
capabilities: external_exports.array(FleetCapabilitySchema),
|
|
21339
21339
|
// Provider-level capacity; the node figure is the aggregate across providers.
|
|
21340
21340
|
max_agents: external_exports.number().int().nonnegative(),
|
|
21341
|
+
// `cloud:*` is reserved for control-plane lifecycle tags set at enrollment.
|
|
21342
|
+
// The engine ignores (and logs) any `cloud:*` entry here and keeps the
|
|
21343
|
+
// node's enrolled `cloud:*` tags instead.
|
|
21341
21344
|
tags: external_exports.array(FleetNodeTagSchema),
|
|
21342
21345
|
// Placement-safe repository identities. The engine persists these as
|
|
21343
21346
|
// `repo:<owner/name>` tags so existing node roster readers can consume them.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.6",
|
|
4
4
|
"description": "Real-time agent-to-agent communication system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"pack:validate": "npm pack --dry-run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agent-relay/cli-surface": "12.2.
|
|
47
|
-
"@agent-relay/cloud": "12.2.
|
|
48
|
-
"@agent-relay/config": "12.2.
|
|
49
|
-
"@agent-relay/fleet": "12.2.
|
|
50
|
-
"@agent-relay/harness-driver": "12.2.
|
|
51
|
-
"@agent-relay/harnesses": "12.2.
|
|
52
|
-
"@agent-relay/sdk": "12.2.
|
|
53
|
-
"@agent-relay/session": "12.2.
|
|
54
|
-
"@agent-relay/utils": "12.2.
|
|
46
|
+
"@agent-relay/cli-surface": "12.2.6",
|
|
47
|
+
"@agent-relay/cloud": "12.2.6",
|
|
48
|
+
"@agent-relay/config": "12.2.6",
|
|
49
|
+
"@agent-relay/fleet": "12.2.6",
|
|
50
|
+
"@agent-relay/harness-driver": "12.2.6",
|
|
51
|
+
"@agent-relay/harnesses": "12.2.6",
|
|
52
|
+
"@agent-relay/sdk": "12.2.6",
|
|
53
|
+
"@agent-relay/session": "12.2.6",
|
|
54
|
+
"@agent-relay/utils": "12.2.6",
|
|
55
55
|
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
56
56
|
"@relayfile/client": "^0.10.27",
|
|
57
|
-
"@relayfile/sdk": "^0.10.
|
|
57
|
+
"@relayfile/sdk": "^0.10.64",
|
|
58
58
|
"@relayflows/cli": "1.0.1",
|
|
59
|
-
"@relayflows/sdk": "^2.0.
|
|
59
|
+
"@relayflows/sdk": "^2.0.19",
|
|
60
60
|
"@xterm/headless": "^6.0.0",
|
|
61
|
-
"ai-hist": "^0.18.
|
|
61
|
+
"ai-hist": "^0.18.1",
|
|
62
62
|
"commander": "^12.1.0",
|
|
63
63
|
"dotenv": "^17.2.3",
|
|
64
64
|
"jiti": "^2.6.1",
|