@demicodes/shell 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as HostFileSystem, c as HostProcessOutputChunk, d as HostSpawnParams, f as HostStore, i as HostFileStat, l as HostSpawnExit, m as createLogicalHostCwd, n as HostCwd, o as HostIdentity, p as SpawnErrorKind, r as HostDirent, s as HostProcess, t as Host, u as HostSpawnHandle } from "./host-BupAFtK6.mjs";
2
2
  import { HostBackedFileSystem, HostBackedFileSystemOptions } from "./host-fs.mjs";
3
- import { _ as runRegisteredCommand, a as CommandIO, c as CommandRegistry, d as CommandStdin, f as CommandStorage, g as renderCommandHelp, h as parseCommandInput, i as CommandExecutionContext, l as CommandRunContext, m as emptyStdin, n as COMMAND_HELP_DEFAULTS, o as CommandInputSpec, p as ParsedCommandInput, r as Command, s as CommandOutputSpec, t as AgentSessionCommandStorage, u as CommandRunResult } from "./storage-BDRwHNOB.mjs";
3
+ import { _ as runRegisteredCommand, a as CommandIO, c as CommandRegistry, d as CommandStdin, f as CommandStorage, g as renderCommandHelp, h as parseCommandInput, i as CommandExecutionContext, l as CommandRunContext, m as emptyStdin, n as COMMAND_HELP_DEFAULTS, o as CommandInputSpec, p as ParsedCommandInput, r as Command, s as CommandOutputSpec, t as AgentSessionCommandStorage, u as CommandRunResult } from "./storage-C0nS_VXD.mjs";
4
4
  import { CommandName } from "@demicodes/just-bash/commands";
5
5
  import { Interpreter, InterpreterState } from "@demicodes/just-bash/interpreter";
6
6
  import { CommandRegistry as CommandRegistry$1, ExecResult } from "@demicodes/just-bash/types";
@@ -77,6 +77,8 @@ interface ForegroundProcess {
77
77
  exitPromise: Promise<HostSpawnExit>;
78
78
  outputSinks: Record<1 | 2, ForegroundSink>;
79
79
  abortController: AbortController;
80
+ /** The resolved registered command's `runningHint`, surfaced on running command statuses. */
81
+ runningHint?: string;
80
82
  }
81
83
  interface ForegroundSink {
82
84
  kind: 'visible' | 'file' | 'null';
@@ -244,6 +246,8 @@ type ShellCommandStatus = {
244
246
  output: ShellOutputView;
245
247
  runningMs: number;
246
248
  idleMs: number;
249
+ /** The running foreground registered command's `runningHint`, when it declares one. */
250
+ runningHint?: string;
247
251
  } | {
248
252
  status: 'aborted';
249
253
  shellId: string;
package/dist/index.mjs CHANGED
@@ -135,7 +135,8 @@ const EXECUTION_ONLY_FIELDS = [
135
135
  "input",
136
136
  "positionals",
137
137
  "stdinField",
138
- "output"
138
+ "output",
139
+ "runningHint"
139
140
  ];
140
141
  const COMMAND_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
141
142
  var CommandRegistry = class {
@@ -712,7 +713,7 @@ function commandToForkCommand(session, command, storage, host, captureLimitBytes
712
713
  execute: async (args, ctx) => {
713
714
  const stdin = decodeForkStdin(ctx.stdin);
714
715
  const argv = [command.name, ...args];
715
- const job = new VirtualForegroundJob(session, command.name, args, ctx.cwd, captureLimitBytes);
716
+ const job = new VirtualForegroundJob(session, command.name, args, ctx.cwd, captureLimitBytes, resolveRunningHint(command, args));
716
717
  job.install();
717
718
  try {
718
719
  const result = await Promise.race([runRegisteredCommand(command, {
@@ -784,7 +785,7 @@ var VirtualForegroundJob = class {
784
785
  killedPromise;
785
786
  exitPromise;
786
787
  installed = false;
787
- constructor(session, command, args, cwd, captureLimitBytes) {
788
+ constructor(session, command, args, cwd, captureLimitBytes, runningHint) {
788
789
  this.session = session;
789
790
  this.captureLimitBytes = captureLimitBytes;
790
791
  this.exitPromise = new Promise((resolve) => {
@@ -835,7 +836,8 @@ var VirtualForegroundJob = class {
835
836
  stderrPump: Promise.resolve(),
836
837
  exitPromise: this.exitPromise,
837
838
  outputSinks: createOutputSinks(session.fs, cwd, void 0),
838
- abortController: this.abortController
839
+ abortController: this.abortController,
840
+ ...runningHint !== void 0 ? { runningHint } : {}
839
841
  };
840
842
  this.io = {
841
843
  stdout: (data) => {
@@ -920,6 +922,16 @@ function toBytes(data) {
920
922
  return typeof data === "string" ? encodeUtf8(data) : data;
921
923
  }
922
924
  async function* emptyByteStream() {}
925
+ /** The `runningHint` of the executed node argv selects (flags never collide with subcommand names). */
926
+ function resolveRunningHint(command, args) {
927
+ let node = command;
928
+ for (const token of args) {
929
+ const child = node.subcommands?.find((candidate) => candidate.name === token);
930
+ if (!child) break;
931
+ node = child;
932
+ }
933
+ return node.runningHint;
934
+ }
923
935
  function treeConsumesStdin(command) {
924
936
  if (command.stdinField) return true;
925
937
  return command.subcommands?.some(treeConsumesStdin) ?? false;
@@ -1803,6 +1815,11 @@ var BashEnvironment = class {
1803
1815
  ...base,
1804
1816
  status: "aborted"
1805
1817
  };
1818
+ if (foreground?.commandId === record.id && foreground.runningHint !== void 0) return {
1819
+ ...base,
1820
+ status: "running",
1821
+ runningHint: foreground.runningHint
1822
+ };
1806
1823
  return {
1807
1824
  ...base,
1808
1825
  status: "running"
@@ -25,6 +25,13 @@ interface Command {
25
25
  positionals?: string[];
26
26
  stdinField?: string;
27
27
  output?: CommandOutputSpec;
28
+ /**
29
+ * Replaces the generic "check again with shell_status, or call yield" next
30
+ * hint in model-facing shell results while this command is the running
31
+ * foreground job. For long-running commands whose running state should not
32
+ * be watched with status/yield polling (e.g. an attended child agent).
33
+ */
34
+ runningHint?: string;
28
35
  }
29
36
  interface ParsedCommandInput {
30
37
  /**
@@ -1,2 +1,2 @@
1
- import { t as AgentSessionCommandStorage } from "./storage-BDRwHNOB.mjs";
1
+ import { t as AgentSessionCommandStorage } from "./storage-C0nS_VXD.mjs";
2
2
  export { AgentSessionCommandStorage };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/shell",
3
3
  "description": "Sandboxable bash engine and Host contract for Demi.",
4
- "version": "0.20.0",
4
+ "version": "0.22.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@demicodes/just-bash": "^3.1.0-demi.4",
23
- "@demicodes/utils": "^0.20.0",
23
+ "@demicodes/utils": "^0.22.0",
24
24
  "zod": "^4.0.0"
25
25
  },
26
26
  "license": "Apache-2.0",