@vibesdotdev/surface-cli 0.0.0-stage → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -0
- package/README.md +62 -2
- package/dist/bun/external-hook-relay.d.ts +26 -0
- package/dist/bun/external-hook-relay.d.ts.map +1 -0
- package/dist/bun/external-hook-relay.js +202 -0
- package/dist/bun/external-hook-relay.js.map +1 -0
- package/dist/bun/host-argv.d.ts +63 -0
- package/dist/bun/host-argv.d.ts.map +1 -0
- package/dist/bun/host-argv.js +129 -0
- package/dist/bun/host-argv.js.map +1 -0
- package/dist/bun/host.d.ts +10 -0
- package/dist/bun/host.d.ts.map +1 -0
- package/dist/bun/host.js +116 -0
- package/dist/bun/host.js.map +1 -0
- package/dist/cli-bootstrap.d.ts +38 -0
- package/dist/cli-bootstrap.d.ts.map +1 -0
- package/dist/cli-bootstrap.js +163 -0
- package/dist/cli-bootstrap.js.map +1 -0
- package/dist/execution/index.d.ts +53 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +58 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/toolchains/pinned-toolchain.d.ts +20 -0
- package/dist/execution/toolchains/pinned-toolchain.d.ts.map +1 -0
- package/dist/execution/toolchains/pinned-toolchain.js +23 -0
- package/dist/execution/toolchains/pinned-toolchain.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/relay.config.descriptor.d.ts +38 -0
- package/dist/relay.config.descriptor.d.ts.map +1 -0
- package/dist/relay.config.descriptor.js +25 -0
- package/dist/relay.config.descriptor.js.map +1 -0
- package/dist/schemas/hook-relay.d.ts +129 -0
- package/dist/schemas/hook-relay.d.ts.map +1 -0
- package/dist/schemas/hook-relay.js +71 -0
- package/dist/schemas/hook-relay.js.map +1 -0
- package/dist/schemas/host.d.ts +36 -0
- package/dist/schemas/host.d.ts.map +1 -0
- package/dist/schemas/host.js +2 -0
- package/dist/schemas/host.js.map +1 -0
- package/dist/session-lifecycle.d.ts +22 -0
- package/dist/session-lifecycle.d.ts.map +1 -0
- package/dist/session-lifecycle.js +83 -0
- package/dist/session-lifecycle.js.map +1 -0
- package/dist/workspace-effect-preparer.d.ts +14 -0
- package/dist/workspace-effect-preparer.d.ts.map +1 -0
- package/dist/workspace-effect-preparer.js +74 -0
- package/dist/workspace-effect-preparer.js.map +1 -0
- package/package.json +113 -4
package/dist/bun/host.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vibes CLI host entry's process duties (`@vibesdotdev/surface-cli/bun/host`),
|
|
3
|
+
* moved from `@vibesdotdev/plugins` (`src/bun/host.ts`): the external hook
|
|
4
|
+
* relay fast path, the shim custody and build surface the host declares, the
|
|
5
|
+
* self-spawn shape, the console formatter, the boot-failure report and the
|
|
6
|
+
* keep-alive exit. `@vibesdotdev/plugins` keeps its plugin floor
|
|
7
|
+
* (`hostPluginFloor`) and forwards `startHost` here.
|
|
8
|
+
*
|
|
9
|
+
* Every process fact comes from the Bun host (`captureBunCliProcessHost`,
|
|
10
|
+
* `runtime-environment-bun/services/cli-process-host`), captured once before
|
|
11
|
+
* any runtime exists; this module reads no process global itself. Terminating
|
|
12
|
+
* the process belongs to the host entry, not to CLISurface: the surface is a
|
|
13
|
+
* library and stays exit-free, and without this exit any ref'd handle a
|
|
14
|
+
* plugin left behind would hang the CLI.
|
|
15
|
+
*/
|
|
16
|
+
import { CaughtFailureSchema, parseBuildSurface } from '@vibesdotdev/kernel';
|
|
17
|
+
import { isRepairArgv, parseExternalHookRelayArgv } from "./host-argv.js";
|
|
18
|
+
/**
|
|
19
|
+
* Boot and run the CLI for this process's argv, then exit when nothing keeps
|
|
20
|
+
* the process alive. An external hook call relays to the workspace daemon
|
|
21
|
+
* without booting a CLI. A failed boot is reported through the CLI's failure
|
|
22
|
+
* renderer and `--json` envelope, and exits non-zero.
|
|
23
|
+
*/
|
|
24
|
+
export async function runCliHost(options) {
|
|
25
|
+
const { captureBunCliProcessHost } = await import('@vibesdotdev/host-bun/services/cli-process-host');
|
|
26
|
+
const { createBunHostResources } = await import('@vibesdotdev/host-bun/services/standard-output');
|
|
27
|
+
// The entry's own output owner for the writes it makes outside any runtime
|
|
28
|
+
// (the hook relay, boot failures, the final flush); runtimes resolve their
|
|
29
|
+
// Bun host through the kernel.
|
|
30
|
+
const hostResources = createBunHostResources();
|
|
31
|
+
const processHost = captureBunCliProcessHost(hostResources);
|
|
32
|
+
const argv = [...(options.argv ?? processHost.argv)];
|
|
33
|
+
// The hook relay runs first: it boots no CLI and never reads the bootstrap,
|
|
34
|
+
// and it runs on every tool call of every agent, so it loads nothing the
|
|
35
|
+
// CLI path needs.
|
|
36
|
+
const externalHookRelay = parseExternalHookRelayArgv(argv);
|
|
37
|
+
if (externalHookRelay) {
|
|
38
|
+
const { runExternalHookRelay } = await import("./external-hook-relay.js");
|
|
39
|
+
const relayOptions = {
|
|
40
|
+
request: externalHookRelay,
|
|
41
|
+
stdin: await processHost.readStdin(),
|
|
42
|
+
stdout: (text) => processHost.output.write('stdout', text),
|
|
43
|
+
stderr: (text) => processHost.output.write('stderr', text)
|
|
44
|
+
};
|
|
45
|
+
if (options.hookRelayTarget)
|
|
46
|
+
relayOptions.target = options.hookRelayTarget;
|
|
47
|
+
const exitCode = await runExternalHookRelay(relayOptions);
|
|
48
|
+
await processHost.output.flush();
|
|
49
|
+
processHost.exit(exitCode);
|
|
50
|
+
}
|
|
51
|
+
if (options.bootstrap !== undefined) {
|
|
52
|
+
const { parseHostBootstrap } = await import('@vibesdotdev/cli/host-bootstrap');
|
|
53
|
+
parseHostBootstrap(options.bootstrap);
|
|
54
|
+
}
|
|
55
|
+
const { createVibesCliApp } = await import("../cli-bootstrap.js");
|
|
56
|
+
const { computeSelfSpawnArgv } = await import('@vibesdotdev/host-bun/services/self-spawn');
|
|
57
|
+
// THE HOST DECLARATION, as data (rc01 §2.3). A shim-launched host takes R,
|
|
58
|
+
// its entry and self-spawn from the shim's captured channel; the Bun
|
|
59
|
+
// environment validates them. A host run from a checkout has no R and
|
|
60
|
+
// declares its own re-entry shape.
|
|
61
|
+
const sourceSelfSpawn = processHost.launchedByShim ? null : computeSelfSpawnArgv(import.meta.url);
|
|
62
|
+
const host = options.host ?? (processHost.launchedByShim
|
|
63
|
+
? { shimChannel: true }
|
|
64
|
+
: sourceSelfSpawn
|
|
65
|
+
? { selfSpawn: sourceSelfSpawn }
|
|
66
|
+
: {});
|
|
67
|
+
const buildSurface = parseBuildSurface(processHost.cliMode);
|
|
68
|
+
const verbose = argv.includes('-v') || argv.includes('--verbose');
|
|
69
|
+
const { reportBootstrapFailure } = await import('@vibesdotdev/cli');
|
|
70
|
+
const appOptions = {
|
|
71
|
+
host,
|
|
72
|
+
attestHostGraph: options.attestHostGraph,
|
|
73
|
+
hostPlugins: [...options.hostPlugins],
|
|
74
|
+
globalPackagePlugins: options.globalPackagePlugins ?? true,
|
|
75
|
+
verbose,
|
|
76
|
+
// Today's SHIPPING binary includes `internal: true` descriptors for the
|
|
77
|
+
// public artifact too; flipping it here would silently drop them — a
|
|
78
|
+
// product change, not a composition change (Rule 13). WU-10 owns it.
|
|
79
|
+
includeInternal: true,
|
|
80
|
+
buildSurface,
|
|
81
|
+
pluginFailurePolicy: isRepairArgv(argv) ? 'report' : 'abort',
|
|
82
|
+
hostOutput: processHost.output,
|
|
83
|
+
argv,
|
|
84
|
+
attachedTerminal: processHost.attachedTerminal
|
|
85
|
+
};
|
|
86
|
+
if (options.hostConfig)
|
|
87
|
+
appOptions.hostConfig = options.hostConfig;
|
|
88
|
+
if (options.environment)
|
|
89
|
+
appOptions.environment = options.environment;
|
|
90
|
+
const booted = await bootOutcome(() => createVibesCliApp(appOptions));
|
|
91
|
+
if (booted.kind === 'failed') {
|
|
92
|
+
// A failed boot (a broken config, `--workspace-root` naming no directory)
|
|
93
|
+
// is reported through the same renderer and `--json` envelope as a
|
|
94
|
+
// command failure.
|
|
95
|
+
const exitCode = await reportBootstrapFailure(booted.failure, verbose, argv, { output: processHost.output });
|
|
96
|
+
return processHost.exit(exitCode);
|
|
97
|
+
}
|
|
98
|
+
// The invocation's status is the surface's answer; the process status is
|
|
99
|
+
// written only here, so a failed command never exits 0.
|
|
100
|
+
const exitCode = await booted.app.cli.run(argv);
|
|
101
|
+
const { shouldKeepAlive } = await import('@vibesdotdev/cli/providers');
|
|
102
|
+
if (!shouldKeepAlive(booted.app.cli.activeRuntime)) {
|
|
103
|
+
await processHost.output.flush();
|
|
104
|
+
processHost.exit(exitCode);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** The CLI's boot: the app, or what its boot threw, parsed at the catch. */
|
|
108
|
+
async function bootOutcome(boot) {
|
|
109
|
+
try {
|
|
110
|
+
return { kind: 'booted', app: await boot() };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return { kind: 'failed', failure: CaughtFailureSchema.parse(error) };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/bun/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAM1E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAA0B;IAC1D,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,iDAAiD,CAAC,CAAC;IACrG,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,gDAAgD,CAAC,CAAC;IAClG,2EAA2E;IAC3E,2EAA2E;IAC3E,+BAA+B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AAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;IACtE,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Bootstrap (surface re-export)
|
|
3
|
+
*
|
|
4
|
+
* The bootstrap implementation lives in `@vibesdotdev/cli` (co-located with
|
|
5
|
+
* `CLISurface` and `cli.plugin`; executable hosts supply their version).
|
|
6
|
+
* This surface package re-exports it as the blessed public entrypoint. The
|
|
7
|
+
* edge here (runtime-surface-cli → cli) is the acyclic direction: `cli` does
|
|
8
|
+
* NOT depend on this package, so its published `bunx @vibesdotdev/cli` bin can
|
|
9
|
+
* bootstrap without a dependency cycle.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createVibesCliApp } from '@vibesdotdev/surface-cli';
|
|
14
|
+
* import { bunStandardOutput } from '@vibesdotdev/host-bun/services/standard-output';
|
|
15
|
+
*
|
|
16
|
+
* const app = await createVibesCliApp({ hostOutput: bunStandardOutput, argv: process.argv });
|
|
17
|
+
* await app.cli.run(process.argv);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { type CliPluginLoader, type VibesCliApp, type VibesCliAppOptions } from '@vibesdotdev/cli/bootstrap';
|
|
21
|
+
import { type VibesRuntime } from '@vibesdotdev/kernel';
|
|
22
|
+
export type { CliPluginLoader, VibesCliApp, VibesCliAppOptions };
|
|
23
|
+
export declare function createVibesCliApp(options: VibesCliAppOptions): Promise<VibesCliApp>;
|
|
24
|
+
export { CLI_HOME_WRITE_UNAVAILABLE_MESSAGE, createCliWorkspaceEffectPreparer } from './workspace-effect-preparer.ts';
|
|
25
|
+
/**
|
|
26
|
+
* Probe the CLI host's own home storage for writing.
|
|
27
|
+
*
|
|
28
|
+
* The probed directory is a host fact (`~/.vibes/storage`, published by the
|
|
29
|
+
* environment's `paths/roots`), so the filesystem owner selects an unbound
|
|
30
|
+
* adapter while preserving the host's declared provider preference. A rooted
|
|
31
|
+
* workspace binding cannot redirect this probe. The host must compose an
|
|
32
|
+
* adapter that supplies the required exclusive-create capability.
|
|
33
|
+
*
|
|
34
|
+
* The probe file is created exclusively, so cleanup removes only the entry this
|
|
35
|
+
* call created and a write failure is never replaced by a cleanup failure.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyCliHomeWrite(runtime: VibesRuntime): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=cli-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-bootstrap.d.ts","sourceRoot":"","sources":["../src/cli-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAA2D,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMjH,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AASjE,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAmDzF;AAED,OAAO,EAAE,kCAAkC,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAEtH;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC7E"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Bootstrap (surface re-export)
|
|
3
|
+
*
|
|
4
|
+
* The bootstrap implementation lives in `@vibesdotdev/cli` (co-located with
|
|
5
|
+
* `CLISurface` and `cli.plugin`; executable hosts supply their version).
|
|
6
|
+
* This surface package re-exports it as the blessed public entrypoint. The
|
|
7
|
+
* edge here (runtime-surface-cli → cli) is the acyclic direction: `cli` does
|
|
8
|
+
* NOT depend on this package, so its published `bunx @vibesdotdev/cli` bin can
|
|
9
|
+
* bootstrap without a dependency cycle.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createVibesCliApp } from '@vibesdotdev/surface-cli';
|
|
14
|
+
* import { bunStandardOutput } from '@vibesdotdev/host-bun/services/standard-output';
|
|
15
|
+
*
|
|
16
|
+
* const app = await createVibesCliApp({ hostOutput: bunStandardOutput, argv: process.argv });
|
|
17
|
+
* await app.cli.run(process.argv);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { resolveFileSystemAdapter } from '@vibesdotdev/filesystem/client';
|
|
21
|
+
import { requireExclusiveCreate } from '@vibesdotdev/filesystem/core';
|
|
22
|
+
import { createVibesCliApp as createBaseVibesCliApp } from '@vibesdotdev/cli/bootstrap';
|
|
23
|
+
import { getPathRoots } from '@vibesdotdev/paths';
|
|
24
|
+
import { CapabilityError, CaughtFailureSchema, isCapabilityError } from '@vibesdotdev/kernel';
|
|
25
|
+
import { projectRefPlugin, resolveProjectRefContext } from '@vibesdotdev/workspace/project-ref';
|
|
26
|
+
import workspaceDocumentPlugin from '@vibesdotdev/workspace/document-plugin';
|
|
27
|
+
import { createCliSessionInvocationObserver } from "./session-lifecycle.js";
|
|
28
|
+
import { createCliWorkspaceEffectPreparer } from "./workspace-effect-preparer.js";
|
|
29
|
+
/** The Vibes executable's suggestions; the composed CLI plugin config can replace them. */
|
|
30
|
+
const VIBES_COMMAND_RECOMMENDATIONS = {
|
|
31
|
+
login: 'auth login', logout: 'auth logout', signin: 'auth login', signup: 'auth login',
|
|
32
|
+
whoami: 'account whoami', deploy: 'infra deploy run', start: 'pm start',
|
|
33
|
+
init: 'docs show getting-started-cli', new: 'docs show getting-started-cli', create: 'docs show getting-started-cli'
|
|
34
|
+
};
|
|
35
|
+
export async function createVibesCliApp(options) {
|
|
36
|
+
// The CLI core boots once through the entry and binds the workspace at
|
|
37
|
+
// construction: the caller's explicit `workspaceRoot` or `--workspace-root`,
|
|
38
|
+
// else the nearest workspace above the cwd (rc02-rc03 §2.4); that
|
|
39
|
+
// workspace's `vibes.config.*` is what it composes. `runtime/workspace-path`
|
|
40
|
+
// is the one reader; this surface resolves nothing of its own.
|
|
41
|
+
let app;
|
|
42
|
+
const callerBeforeAutoExit = options.onBeforeAutoExit;
|
|
43
|
+
app = await createBaseVibesCliApp({
|
|
44
|
+
...options,
|
|
45
|
+
commandRecommendations: options.commandRecommendations ?? VIBES_COMMAND_RECOMMENDATIONS,
|
|
46
|
+
// Project identity rides the host floor, so the serve host a serve
|
|
47
|
+
// command boots composes it too (the workspace plugin skips its own
|
|
48
|
+
// registration when it is already present). The workspace environment
|
|
49
|
+
// kinds ride with it: the surface's own workspace-bind preparer reads
|
|
50
|
+
// `workspace/environment`, and a workspace that declares its own plugin
|
|
51
|
+
// list without that slice (a cloud-only app checkout) must not lose the
|
|
52
|
+
// CLI host's bind. First registration wins, so a workspace that
|
|
53
|
+
// composes them is unchanged.
|
|
54
|
+
surfaceFloorPlugins: [
|
|
55
|
+
...(options.surfaceFloorPlugins ?? []),
|
|
56
|
+
async () => projectRefPlugin,
|
|
57
|
+
async () => workspaceDocumentPlugin
|
|
58
|
+
],
|
|
59
|
+
onBeforeAutoExit: async () => {
|
|
60
|
+
try {
|
|
61
|
+
await callerBeforeAutoExit?.();
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
// The executable may hard-exit immediately after CLISurface.run()
|
|
65
|
+
// returns. Await disposal of the runtime the action ran on (the
|
|
66
|
+
// serve host after a serve transition) so feature-owned lifecycle
|
|
67
|
+
// children can close browsers, DBs, watchers, and other custody first.
|
|
68
|
+
await app.cli.activeRuntime.dispose();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
// Preparers and observers run at action time, on the runtime the action
|
|
73
|
+
// runs on: a serve command's transition replaces the CLI runtime first.
|
|
74
|
+
const activeRuntime = () => app.cli.activeRuntime;
|
|
75
|
+
app.cli.prependInvocationPreparer(createCliWorkspaceEffectPreparer({
|
|
76
|
+
verifyHomeWrite: () => verifyCliHomeWrite(activeRuntime()),
|
|
77
|
+
bind: (info) => bindCliWorkspaceEnvironment(activeRuntime(), info.effects.serve?.composition)
|
|
78
|
+
}));
|
|
79
|
+
// Commander's action dispatch is the execution boundary. Construction,
|
|
80
|
+
// parsing, help, version, and bare invocations never open a session turn.
|
|
81
|
+
app.cli.setInvocationObserver(createCliSessionInvocationObserver({ runtime: activeRuntime }));
|
|
82
|
+
return app;
|
|
83
|
+
}
|
|
84
|
+
export { CLI_HOME_WRITE_UNAVAILABLE_MESSAGE, createCliWorkspaceEffectPreparer } from "./workspace-effect-preparer.js";
|
|
85
|
+
/**
|
|
86
|
+
* Probe the CLI host's own home storage for writing.
|
|
87
|
+
*
|
|
88
|
+
* The probed directory is a host fact (`~/.vibes/storage`, published by the
|
|
89
|
+
* environment's `paths/roots`), so the filesystem owner selects an unbound
|
|
90
|
+
* adapter while preserving the host's declared provider preference. A rooted
|
|
91
|
+
* workspace binding cannot redirect this probe. The host must compose an
|
|
92
|
+
* adapter that supplies the required exclusive-create capability.
|
|
93
|
+
*
|
|
94
|
+
* The probe file is created exclusively, so cleanup removes only the entry this
|
|
95
|
+
* call created and a write failure is never replaced by a cleanup failure.
|
|
96
|
+
*/
|
|
97
|
+
export async function verifyCliHomeWrite(runtime) {
|
|
98
|
+
// The one reader of the host's published roots (`@vibesdotdev/paths`): it
|
|
99
|
+
// parses the descriptor, so `storageDir` is a non-empty path or the read
|
|
100
|
+
// refuses (`path-roots-unavailable` / `path-roots-invalid`). Either refusal
|
|
101
|
+
// is this probe's `home-storage-root-unpublished`, carrying the cause.
|
|
102
|
+
let storageDir;
|
|
103
|
+
try {
|
|
104
|
+
storageDir = getPathRoots(runtime).storageDir;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new CapabilityError('The runtime did not publish a valid storage root.', 'UNAVAILABLE', {
|
|
108
|
+
reason: 'home-storage-root-unpublished',
|
|
109
|
+
retryable: false,
|
|
110
|
+
details: { field: 'paths/roots.storageDir' },
|
|
111
|
+
cause: CaughtFailureSchema.parse(error)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const host = await resolveFileSystemAdapter(runtime, { binding: false });
|
|
115
|
+
requireExclusiveCreate(host, {
|
|
116
|
+
message: 'The host filesystem adapter cannot create files exclusively.',
|
|
117
|
+
reason: 'exclusive-create-unavailable'
|
|
118
|
+
});
|
|
119
|
+
const probePath = host.join(storageDir, `.cli-home-write-${crypto.randomUUID()}`);
|
|
120
|
+
await host.mkdir(storageDir, { recursive: true });
|
|
121
|
+
if (!(await host.createFileExclusive(probePath, ''))) {
|
|
122
|
+
throw new CapabilityError('The home write probe name already exists.', 'UNAVAILABLE', {
|
|
123
|
+
reason: 'probe-name-collision',
|
|
124
|
+
retryable: true,
|
|
125
|
+
details: { adapterId: host.descriptor.id }
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
await host.remove(probePath);
|
|
129
|
+
}
|
|
130
|
+
async function bindCliWorkspaceEnvironment(runtime, composition) {
|
|
131
|
+
// An unbound CLI (a bare `~` invocation) has no workspace environment to
|
|
132
|
+
// bind; commands that need one fail with `workspace-unbound` when they read
|
|
133
|
+
// it. Any other failure is real and propagates.
|
|
134
|
+
let root;
|
|
135
|
+
try {
|
|
136
|
+
root = await runtime.context('runtime/workspace-path');
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
// Confirmed absence of exactly this context (NOT_FOUND naming context
|
|
140
|
+
// `runtime/workspace-path`), and only its unbound form.
|
|
141
|
+
if (error instanceof Error &&
|
|
142
|
+
CapabilityError.isAbsenceOf(error, 'context', 'runtime/workspace-path') &&
|
|
143
|
+
isCapabilityError(error) &&
|
|
144
|
+
error.reason === 'workspace-unbound') {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
// The kernel has admitted this workspace for the transport host. Its
|
|
150
|
+
// execution worker owns feature binding and must complete it before ready.
|
|
151
|
+
if (composition === 'transport')
|
|
152
|
+
return;
|
|
153
|
+
const { bindWorkspaceEnvironment } = await import('@vibesdotdev/workspace/environment/node');
|
|
154
|
+
const projectRefContext = await resolveProjectRefContext(runtime);
|
|
155
|
+
const projectRef = projectRefContext.resolve({ cwd: root });
|
|
156
|
+
await bindWorkspaceEnvironment(runtime, {
|
|
157
|
+
sessionId: 'cli',
|
|
158
|
+
target: 'local',
|
|
159
|
+
root,
|
|
160
|
+
projectId: projectRef?.projectId
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=cli-bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-bootstrap.js","sourceRoot":"","sources":["../src/cli-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACN,iBAAiB,IAAI,qBAAqB,EAI1C,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,uBAAuB,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAIlF,2FAA2F;AAC3F,MAAM,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AAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,yCAAyC,CAAC,CAAC;IAC7F,MAAM,iBAAiB,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,wBAAwB,CAAC,OAAO,EAAE;QACvC,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,OAAO;QACf,IAAI;QACJ,SAAS,EAAE,UAAU,EAAE,SAAS;KAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-owned process execution for local toolchain probes.
|
|
3
|
+
*
|
|
4
|
+
* A probe runs on the runtime its host hands over (a CLI command's
|
|
5
|
+
* `context.runtime`, or a script host booted through the one entry,
|
|
6
|
+
* `bootstrapVibesRuntime`) and uses that runtime's `runtime/execution`
|
|
7
|
+
* capability. Nothing here boots a runtime of its own, and callers never
|
|
8
|
+
* import Bun or child-process implementations to discover or run a toolchain.
|
|
9
|
+
*/
|
|
10
|
+
import type { VibesRuntime } from '@vibesdotdev/kernel';
|
|
11
|
+
import type { RuntimeExecution } from '@vibesdotdev/kernel/execution';
|
|
12
|
+
export { resolvePinnedToolchain, type PinnedToolchain, type ResolvePinnedToolchainOptions } from './toolchains/pinned-toolchain.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Canonical version-probe argv per known toolchain command.
|
|
15
|
+
* Unknown commands fall back to `['--version']` in `inspectToolchain`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TOOLCHAIN_VERSION_ARGUMENTS: {
|
|
18
|
+
readonly zig: readonly ["version"];
|
|
19
|
+
readonly cargo: readonly ["--version"];
|
|
20
|
+
readonly rustc: readonly ["--version"];
|
|
21
|
+
readonly rustup: readonly ["--version"];
|
|
22
|
+
/** NSIS compiler; `/VERSION` is the documented flag (also accepted as `-VERSION`). */
|
|
23
|
+
readonly makensis: readonly ["/VERSION"];
|
|
24
|
+
};
|
|
25
|
+
export interface CliExecutionSurface {
|
|
26
|
+
runtime: VibesRuntime;
|
|
27
|
+
execution: RuntimeExecution;
|
|
28
|
+
}
|
|
29
|
+
/** The two `runtime/execution` operations a toolchain probe uses. */
|
|
30
|
+
export type ToolchainExecution = Pick<RuntimeExecution, 'resolveCommand' | 'execute'>;
|
|
31
|
+
export interface ToolchainInspection {
|
|
32
|
+
command: string;
|
|
33
|
+
path: string | null;
|
|
34
|
+
version: string | null;
|
|
35
|
+
available: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the execution capability of the runtime the host handed over.
|
|
39
|
+
* Preserves the kernel's typed absence refusal when the kind or a matching
|
|
40
|
+
* implementation is not registered.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createCliExecutionSurface(runtime: VibesRuntime): Promise<CliExecutionSurface>;
|
|
43
|
+
/**
|
|
44
|
+
* Ask the active execution environment whether a named tool is present and,
|
|
45
|
+
* when it is, capture its version without exposing any host primitive. The
|
|
46
|
+
* probe's whole environment is `options.env`, the caller's composition
|
|
47
|
+
* (`composeHostEnv(runtime)`); it never inherits the live process env.
|
|
48
|
+
*/
|
|
49
|
+
export declare function inspectToolchain(execution: ToolchainExecution, command: string, options: {
|
|
50
|
+
env: Record<string, string>;
|
|
51
|
+
versionArgs?: string[];
|
|
52
|
+
}): Promise<ToolchainInspection>;
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EACN,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;IAKvC,sFAAsF;;CAEvB,CAAC;AAOjE,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,gBAAgB,CAAC;CAC5B;AAED,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC;AAEtF,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;CACnB;AAGD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAKnG;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACrC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC9D,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-owned process execution for local toolchain probes.
|
|
3
|
+
*
|
|
4
|
+
* A probe runs on the runtime its host hands over (a CLI command's
|
|
5
|
+
* `context.runtime`, or a script host booted through the one entry,
|
|
6
|
+
* `bootstrapVibesRuntime`) and uses that runtime's `runtime/execution`
|
|
7
|
+
* capability. Nothing here boots a runtime of its own, and callers never
|
|
8
|
+
* import Bun or child-process implementations to discover or run a toolchain.
|
|
9
|
+
*/
|
|
10
|
+
export { resolvePinnedToolchain } from "./toolchains/pinned-toolchain.js";
|
|
11
|
+
/**
|
|
12
|
+
* Canonical version-probe argv per known toolchain command.
|
|
13
|
+
* Unknown commands fall back to `['--version']` in `inspectToolchain`.
|
|
14
|
+
*/
|
|
15
|
+
export const TOOLCHAIN_VERSION_ARGUMENTS = {
|
|
16
|
+
zig: ['version'],
|
|
17
|
+
cargo: ['--version'],
|
|
18
|
+
rustc: ['--version'],
|
|
19
|
+
rustup: ['--version'],
|
|
20
|
+
/** NSIS compiler; `/VERSION` is the documented flag (also accepted as `-VERSION`). */
|
|
21
|
+
makensis: ['/VERSION']
|
|
22
|
+
};
|
|
23
|
+
/** The canonical version argv for `command` (own entries only), else `['--version']`. */
|
|
24
|
+
function versionArgumentsFor(command) {
|
|
25
|
+
return Object.entries(TOOLCHAIN_VERSION_ARGUMENTS).find(([name]) => name === command)?.[1] ?? ['--version'];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the execution capability of the runtime the host handed over.
|
|
29
|
+
* Preserves the kernel's typed absence refusal when the kind or a matching
|
|
30
|
+
* implementation is not registered.
|
|
31
|
+
*/
|
|
32
|
+
export async function createCliExecutionSurface(runtime) {
|
|
33
|
+
const execution = await runtime
|
|
34
|
+
.query('runtime/execution')
|
|
35
|
+
.resolve();
|
|
36
|
+
return { runtime, execution };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Ask the active execution environment whether a named tool is present and,
|
|
40
|
+
* when it is, capture its version without exposing any host primitive. The
|
|
41
|
+
* probe's whole environment is `options.env`, the caller's composition
|
|
42
|
+
* (`composeHostEnv(runtime)`); it never inherits the live process env.
|
|
43
|
+
*/
|
|
44
|
+
export async function inspectToolchain(execution, command, options) {
|
|
45
|
+
const versionArgs = options.versionArgs ?? [...versionArgumentsFor(command)];
|
|
46
|
+
const path = await execution.resolveCommand(command);
|
|
47
|
+
if (!path)
|
|
48
|
+
return { command, path: null, version: null, available: false };
|
|
49
|
+
const result = await execution.execute({ command: path, args: versionArgs, env: options.env, envMode: 'replace' });
|
|
50
|
+
const output = `${result.stdout}\n${result.stderr}`.trim();
|
|
51
|
+
return {
|
|
52
|
+
command,
|
|
53
|
+
path,
|
|
54
|
+
version: result.exitCode === 0 ? output : null,
|
|
55
|
+
available: result.exitCode === 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EACN,sBAAsB,EAGtB,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,GAAG,EAAE,CAAC,SAAS,CAAC;IAChB,KAAK,EAAE,CAAC,WAAW,CAAC;IACpB,KAAK,EAAE,CAAC,WAAW,CAAC;IACpB,MAAM,EAAE,CAAC,WAAW,CAAC;IACrB,sFAAsF;IACtF,QAAQ,EAAE,CAAC,UAAU,CAAC;CACyC,CAAC;AAEjE,yFAAyF;AACzF,SAAS,mBAAmB,CAAC,OAAe;IAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7G,CAAC;AAkBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAAqB;IACpE,MAAM,SAAS,GAAG,MAAM,OAAO;SAC7B,KAAK,CAAwC,mBAAmB,CAAC;SACjE,OAAO,EAAE,CAAC;IACZ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,SAA6B,EAC7B,OAAe,EACf,OAAgE;IAEhE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAE3E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IACnH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAC3D,OAAO;QACN,OAAO;QACP,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;QAC9C,SAAS,EAAE,MAAM,CAAC,QAAQ,KAAK,CAAC;KAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RuntimeExecution } from '@vibesdotdev/kernel/execution';
|
|
2
|
+
export interface PinnedToolchain {
|
|
3
|
+
command: string;
|
|
4
|
+
path: string;
|
|
5
|
+
version: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolvePinnedToolchainOptions {
|
|
8
|
+
command: string;
|
|
9
|
+
candidates: readonly string[];
|
|
10
|
+
versionArgs: readonly string[];
|
|
11
|
+
versionPrefix: string;
|
|
12
|
+
/** The probe's whole environment: the caller's composition (`composeHostEnv(runtime)`). */
|
|
13
|
+
env: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a toolchain through the active execution capability and reject a
|
|
17
|
+
* binary whose reported version does not satisfy the caller's pin.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePinnedToolchain(execution: Pick<RuntimeExecution, 'resolveCommand' | 'execute'>, options: ResolvePinnedToolchainOptions): Promise<PinnedToolchain>;
|
|
20
|
+
//# sourceMappingURL=pinned-toolchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinned-toolchain.d.ts","sourceRoot":"","sources":["../../../src/execution/toolchains/pinned-toolchain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,6BAA6B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC,EAC/D,OAAO,EAAE,6BAA6B,GACpC,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a toolchain through the active execution capability and reject a
|
|
3
|
+
* binary whose reported version does not satisfy the caller's pin.
|
|
4
|
+
*/
|
|
5
|
+
export async function resolvePinnedToolchain(execution, options) {
|
|
6
|
+
for (const candidate of options.candidates) {
|
|
7
|
+
const path = await execution.resolveCommand(candidate);
|
|
8
|
+
if (!path)
|
|
9
|
+
continue;
|
|
10
|
+
const result = await execution.execute({
|
|
11
|
+
command: path,
|
|
12
|
+
args: [...options.versionArgs],
|
|
13
|
+
env: options.env,
|
|
14
|
+
envMode: 'replace'
|
|
15
|
+
});
|
|
16
|
+
const version = `${result.stdout}\n${result.stderr}`.trim();
|
|
17
|
+
if (result.exitCode === 0 && version.startsWith(options.versionPrefix)) {
|
|
18
|
+
return { command: options.command, path, version };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`No ${options.command} toolchain matching ${options.versionPrefix} was available through runtime/execution.`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=pinned-toolchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinned-toolchain.js","sourceRoot":"","sources":["../../../src/execution/toolchains/pinned-toolchain.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,SAA+D,EAC/D,OAAsC;IAEtC,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI;YAAE,SAAS;QAEpB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACtC,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;YAC9B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,SAAS;SAClB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5D,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACxE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACpD,CAAC;IACF,CAAC;IAED,MAAM,IAAI,KAAK,CACd,MAAM,OAAO,CAAC,OAAO,uBAAuB,OAAO,CAAC,aAAa,2CAA2C,CAC5G,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Surface: CLI
|
|
3
|
+
*
|
|
4
|
+
* Official blessed entrypoint for bootstrapping a Vibes CLI runtime.
|
|
5
|
+
* Re-exports the CLI application factory (createVibesCliApp) and related
|
|
6
|
+
* types after the surface layer is fully implemented.
|
|
7
|
+
*
|
|
8
|
+
* Consumers (cli-bin, shield-cli, internal CLI commands) should import from here
|
|
9
|
+
* rather than directly from @vibesdotdev/cli/bootstrap or raw runtime bootstrap symbols.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Runtime Surface — CLI
|
|
13
|
+
*
|
|
14
|
+
* The blessed way to bootstrap a full Vibes CLI application.
|
|
15
|
+
* Re-exports createVibesCliApp and related types from the implementation
|
|
16
|
+
* that now lives in this surface package.
|
|
17
|
+
*
|
|
18
|
+
* All production CLI entrypoints (cli-bin, shield-cli, internal tools)
|
|
19
|
+
* should import from here.
|
|
20
|
+
*/
|
|
21
|
+
export { createVibesCliApp, type VibesCliAppOptions, type VibesCliApp, type CliPluginLoader } from './cli-bootstrap.ts';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Surface: CLI
|
|
3
|
+
*
|
|
4
|
+
* Official blessed entrypoint for bootstrapping a Vibes CLI runtime.
|
|
5
|
+
* Re-exports the CLI application factory (createVibesCliApp) and related
|
|
6
|
+
* types after the surface layer is fully implemented.
|
|
7
|
+
*
|
|
8
|
+
* Consumers (cli-bin, shield-cli, internal CLI commands) should import from here
|
|
9
|
+
* rather than directly from @vibesdotdev/cli/bootstrap or raw runtime bootstrap symbols.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Runtime Surface — CLI
|
|
13
|
+
*
|
|
14
|
+
* The blessed way to bootstrap a full Vibes CLI application.
|
|
15
|
+
* Re-exports createVibesCliApp and related types from the implementation
|
|
16
|
+
* that now lives in this surface package.
|
|
17
|
+
*
|
|
18
|
+
* All production CLI entrypoints (cli-bin, shield-cli, internal tools)
|
|
19
|
+
* should import from here.
|
|
20
|
+
*/
|
|
21
|
+
export { createVibesCliApp } from "./cli-bootstrap.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAmE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const relayConfigDescriptor: {
|
|
2
|
+
id: string;
|
|
3
|
+
kind: "config/manifest";
|
|
4
|
+
name: string;
|
|
5
|
+
namespace: string;
|
|
6
|
+
schema: import("zod").ZodObject<{
|
|
7
|
+
timeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
8
|
+
}, import("zod/v4/core").$strip>;
|
|
9
|
+
storedLayer: "none";
|
|
10
|
+
allowedAdapters: string[];
|
|
11
|
+
customTables: false;
|
|
12
|
+
version: number;
|
|
13
|
+
internal: false;
|
|
14
|
+
scope: "global";
|
|
15
|
+
tier: "user";
|
|
16
|
+
fields: {
|
|
17
|
+
timeoutMs: {
|
|
18
|
+
ui: {
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
defaults: {
|
|
22
|
+
base: number;
|
|
23
|
+
resolver: (ctx: {
|
|
24
|
+
hardware: "consumer" | "cloud" | "gpu" | "cpu-only";
|
|
25
|
+
environment: "staging" | "production" | "development";
|
|
26
|
+
surface: "cli" | "tui" | "bridge" | "web";
|
|
27
|
+
isAuthenticated: boolean;
|
|
28
|
+
enabledFeatures: Set<string>;
|
|
29
|
+
get: import("zod/v4/core").$InferInnerFunctionType<import("zod").ZodTuple<readonly [import("zod").ZodString], null>, import("zod").ZodOptional<import("zod").ZodType<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue, import("zod/v4/core").$ZodTypeInternals<import("@vibesdotdev/kernel/bootstrap").JsonValue, import("@vibesdotdev/kernel/bootstrap").JsonValue>>>>;
|
|
30
|
+
custom: Record<string, import("@vibesdotdev/kernel/bootstrap").JsonValue>;
|
|
31
|
+
runtime: import("@vibesdotdev/kernel").RuntimeRef;
|
|
32
|
+
userRole?: string | undefined;
|
|
33
|
+
}) => number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=relay.config.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.config.descriptor.d.ts","sourceRoot":"","sources":["../src/relay.config.descriptor.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RelayConfigSchema, TimeoutEnvSchema } from "./schemas/hook-relay.js";
|
|
2
|
+
export const relayConfigDescriptor = {
|
|
3
|
+
id: 'surface-cli.hook-relay',
|
|
4
|
+
kind: 'config/manifest',
|
|
5
|
+
name: 'External hook relay',
|
|
6
|
+
namespace: 'surface-cli.hook-relay',
|
|
7
|
+
schema: RelayConfigSchema,
|
|
8
|
+
storedLayer: 'none',
|
|
9
|
+
allowedAdapters: ['storage.memory'],
|
|
10
|
+
customTables: false,
|
|
11
|
+
version: 1,
|
|
12
|
+
internal: false,
|
|
13
|
+
scope: 'global',
|
|
14
|
+
tier: 'user',
|
|
15
|
+
fields: {
|
|
16
|
+
timeoutMs: {
|
|
17
|
+
ui: { label: 'Timeout (ms)' },
|
|
18
|
+
defaults: {
|
|
19
|
+
base: RelayConfigSchema.parse({}).timeoutMs,
|
|
20
|
+
resolver: ctx => TimeoutEnvSchema.safeParse(ctx.runtime.getEnv('VIBES_EXTERNAL_HOOK_RELAY_TIMEOUT_MS')).data ?? RelayConfigSchema.parse({}).timeoutMs
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=relay.config.descriptor.js.map
|