@lazyingart/agintiflow 0.20.67 → 0.20.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.67",
3
+ "version": "0.20.69",
4
4
  "type": "module",
5
5
  "description": "Low-cost, project-aware Web and CLI agents with DeepSeek/Venice/OpenAI routing, visible tool calls, durable sessions, scouts, AAPS, SCS, and guarded local execution.",
6
6
  "license": "Apache-2.0",
@@ -149,9 +149,10 @@ try {
149
149
  const behaviorContract = formatBehaviorContractForPrompt();
150
150
  if (
151
151
  !behaviorContract.includes("name the actual environment used") ||
152
- !behaviorContract.includes("Do not claim compatibility across untested runtimes")
152
+ !behaviorContract.includes("Do not claim compatibility across untested runtimes") ||
153
+ !behaviorContract.includes("Do not self-invoke AgInTiFlow")
153
154
  ) {
154
- throw new Error("behavior contract must guard against host/Docker and runtime-version overclaims");
155
+ throw new Error("behavior contract must guard against host/Docker, runtime-version, and recursive self-invocation overclaims");
155
156
  }
156
157
  const wrappedDockerCommand = dockerUserCommand("node --test 2>&1 | tail -30", {
157
158
  category: "general-shell",
@@ -246,6 +246,20 @@ try {
246
246
  failedNetworkAdvice.instruction.includes("Stop and present this blocker"),
247
247
  "network failure advice did not tell the model to stop and ask"
248
248
  );
249
+ const failedOutsidePathAdvice = buildFailedCommandAdvice({
250
+ args: { command: 'echo "outside permission test" > /home/lachlan/ProjectsLFS/outside.txt' },
251
+ commandPolicy: evaluateCommandPolicy('echo "outside permission test" > /home/lachlan/ProjectsLFS/outside.txt', dockerWorkspacePolicy),
252
+ commandResult: {
253
+ ok: false,
254
+ stdout: "EXIT: 1",
255
+ stderr: "bash: line 1: /home/lachlan/ProjectsLFS/outside.txt: No such file or directory",
256
+ },
257
+ config: dockerWorkspacePolicy,
258
+ state: { sessionId: "coding-outside-path-smoke" },
259
+ });
260
+ assert(failedOutsidePathAdvice?.failureKind === "workspace-path", "outside host path failure advice was not generated");
261
+ assert(failedOutsidePathAdvice.suggestedCommand.includes("--sandbox-mode host"), "outside path advice did not suggest host mode");
262
+ assert(!failedOutsidePathAdvice.suggestedCommand.includes("aginti run --sandbox host"), "outside path advice used legacy sandbox syntax");
249
263
  assert(
250
264
  shouldRunParallelScouts(
251
265
  {
@@ -78,6 +78,22 @@ try {
78
78
  });
79
79
  assert.equal(dockerTmuxSearch.allowed, true, "Docker run_command should still allow harmless tmux text searches");
80
80
 
81
+ const dockerNpxAginti = checkToolUse({
82
+ toolName: "run_command",
83
+ args: { command: "npx aginti doctor --json" },
84
+ config: { ...config, useDockerSandbox: true, sandboxMode: "docker-workspace", packageInstallPolicy: "allow" },
85
+ });
86
+ assert.equal(dockerNpxAginti.allowed, false, "Docker run_command should block npx aginti self-invocation");
87
+ assert.equal(dockerNpxAginti.category, "nested-aginti", "npx aginti block should be categorized");
88
+
89
+ const dockerNestedAginti = checkToolUse({
90
+ toolName: "run_command",
91
+ args: { command: "aginti storage status" },
92
+ config: { ...config, useDockerSandbox: true, sandboxMode: "docker-workspace", packageInstallPolicy: "allow" },
93
+ });
94
+ assert.equal(dockerNestedAginti.allowed, false, "Docker run_command should block nested aginti CLI calls");
95
+ assert.equal(dockerNestedAginti.category, "nested-aginti", "nested aginti block should be categorized");
96
+
81
97
  console.log(
82
98
  JSON.stringify(
83
99
  {
@@ -93,6 +109,8 @@ try {
93
109
  "destructive-guardrail",
94
110
  "docker-run-command-tmux-guardrail",
95
111
  "docker-run-command-tmux-search-allowed",
112
+ "docker-run-command-npx-aginti-guardrail",
113
+ "docker-run-command-nested-aginti-guardrail",
96
114
  ],
97
115
  },
98
116
  null,
@@ -358,10 +358,10 @@ async function createInitialState(config, sessionId) {
358
358
  "Treat AGINTI.md as durable project memory and operating instructions for this project. The user can edit it manually or ask you in chat to update it; use workspace file tools for that and never store secrets there.",
359
359
  config.allowShellTool
360
360
  ? config.useDockerSandbox
361
- ? `A shell command tool is available inside Docker sandbox mode ${config.sandboxMode}. Docker workspace mode with approved package installs supports broader setup and network commands. The project is mounted at /workspace and the persistent agent toolchain is mounted at /aginti-env with caches under /aginti-cache.`
361
+ ? `A shell command tool is available inside Docker sandbox mode ${config.sandboxMode}. Docker workspace mode with approved package installs supports broader setup and network commands. The project is mounted at /workspace and the persistent agent toolchain is mounted at /aginti-env with caches under /aginti-cache. Do not run npx aginti, npm exec aginti, or nested aginti diagnostics from this Docker shell; they may resolve stale project packages or create recursive agent sessions.`
362
362
  : `A host shell command tool is available under the configured trust policy on ${platformLabel(platform)}. On native Windows, prefer PowerShell/cmd-compatible commands or switch to WSL/Docker for bash-like toolchains.`
363
363
  : "No shell command tool is available.",
364
- "Permission contract: current-workspace file writes are allowed through workspace file tools when enabled. Outside-workspace paths, host sudo, host OS package installs, destructive git/shell actions, and blocked network/setup must not be bypassed by retrying variants. If a tool result includes permissionAdvice or suggestedCommand, stop, explain the blocker, and ask the user to approve/rerun that mode or choose a safer workspace-relative path.",
364
+ "Permission contract: current-workspace file writes are allowed through workspace file tools when enabled. Outside-workspace paths, host sudo, host OS package installs, destructive git/shell actions, and blocked network/setup must not be bypassed by retrying variants. If a tool result includes permissionAdvice or suggestedCommand, stop, explain the blocker, copy the exact suggestedCommand when giving a rerun path, and ask the user to approve/rerun that mode or choose a safer workspace-relative path. Never invent legacy AgInTi syntax such as `aginti run --sandbox host`; use the exact flags from permissionAdvice.",
365
365
  "If an operation fails but a directory, artifact, or file already exists, treat it as pre-existing unless you have evidence this run created or updated it. Verify expected outputs before claiming success.",
366
366
  config.allowShellTool
367
367
  ? "Host tmux tools are available for long-running terminals: list sessions, capture panes, send safe keys/text, and start detached sessions. Prefer these tools for monitoring long installs/tests/dev servers without blocking; capture before sending input and never send secrets or sudo passwords. Do not start or install tmux inside Docker run_command containers because those containers are short-lived."
@@ -68,9 +68,10 @@ export function formatBehaviorContractForPrompt({ mode = "runtime" } = {}) {
68
68
  "Prefer the smallest coherent change that satisfies the request; do not add speculative features or abstractions.",
69
69
  "Make surgical edits: no drive-by refactors, unrelated formatting churn, or deletion of code you did not need to touch.",
70
70
  "Define or infer concrete success criteria for non-trivial work, then run focused checks or state why checks are unavailable.",
71
- "Respect the permission contract: if a tool is blocked, stop and present the safe rerun/approval path instead of retrying variants.",
71
+ "Respect the permission contract: if a tool is blocked or returns permissionAdvice, stop and present the exact suggestedCommand/approval path instead of retrying variants or inventing CLI flags.",
72
72
  "Keep artifacts durable and discoverable with descriptive non-conflicting names; never overwrite unless the user clearly asked.",
73
73
  "When reporting shell, language, runtime, build, or test results, name the actual environment used (host vs Docker, relevant interpreter/tool path/version when it matters). Do not claim compatibility across untested runtimes, hosts, containers, or language versions; state the caveat or run an explicit check.",
74
+ "Do not self-invoke AgInTiFlow with npx/npm exec or nested aginti commands from inside the agent shell; it can resolve stale project packages or create recursive sessions. Use current runtime evidence, project/session files, or ask for a host-side diagnostic instead.",
74
75
  ].join(" ");
75
76
  }
76
77
 
package/src/guardrails.js CHANGED
@@ -49,6 +49,16 @@ function isDockerTmuxProcessCommand(command = "") {
49
49
  ].some((pattern) => pattern.test(command));
50
50
  }
51
51
 
52
+ function isNpxAgintiCommand(command = "") {
53
+ return /\b(?:npx(?:\s+(?:-y|--yes))?|npm\s+exec|pnpm\s+dlx|yarn\s+dlx)\s+(?:@lazyingart\/agintiflow|aginti)\b/i.test(
54
+ command
55
+ );
56
+ }
57
+
58
+ function isAgintiCliCommand(command = "") {
59
+ return /(?:^|[\s;&|('"])(?:node\s+[-\w./]*aginti-cli\.js|aginti)(?:\s|$)/i.test(command);
60
+ }
61
+
52
62
  function normalizeDomain(hostname) {
53
63
  return hostname.replace(/^www\./, "").toLowerCase();
54
64
  }
@@ -137,6 +147,22 @@ export function checkToolUse({ toolName, args, snapshot, config }) {
137
147
 
138
148
  if (toolName === "run_command") {
139
149
  const command = String(args.command || "").trim();
150
+ if (isNpxAgintiCommand(command)) {
151
+ return {
152
+ allowed: false,
153
+ reason:
154
+ "`npx aginti`/`npm exec aginti` is blocked inside agent shell tools because it can resolve a stale project-local AgInTiFlow package, install from the network, or start a nested agent session. Use the current runtime status, project/session files, or ask the user to run a host CLI diagnostic.",
155
+ category: "nested-aginti",
156
+ };
157
+ }
158
+ if (config.useDockerSandbox && isAgintiCliCommand(command)) {
159
+ return {
160
+ allowed: false,
161
+ reason:
162
+ "Nested AgInTiFlow CLI calls are blocked in Docker run_command because the container may not have the active host CLI and may resolve stale project node_modules. Use current session evidence, workspace files, or ask the user to run host-side `aginti doctor --json`/`aginti capabilities --json`.",
163
+ category: "nested-aginti",
164
+ };
165
+ }
140
166
  if (config.useDockerSandbox && isDockerTmuxProcessCommand(command)) {
141
167
  return {
142
168
  allowed: false,
@@ -508,7 +508,7 @@ export async function createPlan(client, config, state) {
508
508
  state.startUrl ? `Suggested start URL: ${state.startUrl}` : "",
509
509
  config.allowedDomains.length > 0 ? `Allowed domains: ${config.allowedDomains.join(", ")}` : "",
510
510
  config.allowShellTool
511
- ? `Shell tool is enabled in ${config.commandCwd}. Host platform: ${platformLabel(platform)}. In Docker, this path is mounted as /workspace with persistent /aginti-env and /aginti-cache mounts. Use relative paths or /workspace paths, not absolute host temp paths. Sandbox mode: ${config.sandboxMode}. Package install policy: ${config.packageInstallPolicy}. For npm/pip/conda/venv setup, explain the need and wait for approval unless policy is allow. On native Windows host mode, prefer PowerShell/cmd-compatible commands or WSL/Docker for bash-like toolchains.`
511
+ ? `Shell tool is enabled in ${config.commandCwd}. Host platform: ${platformLabel(platform)}. In Docker, this path is mounted as /workspace with persistent /aginti-env and /aginti-cache mounts. Use relative paths or /workspace paths, not absolute host temp paths. Sandbox mode: ${config.sandboxMode}. Package install policy: ${config.packageInstallPolicy}. For npm/pip/conda/venv setup, explain the need and wait for approval unless policy is allow. Do not run npx aginti, npm exec aginti, or nested aginti diagnostics from this shell; they may resolve stale project packages or create recursive agent sessions. On native Windows host mode, prefer PowerShell/cmd-compatible commands or WSL/Docker for bash-like toolchains.`
512
512
  : "",
513
513
  config.allowShellTool
514
514
  ? "Host tmux tools are enabled for long-running sessions. Plan to use tmux_start_session for durable jobs, tmux_capture_pane to monitor, tmux_send_keys to interact after capture, and tmux_list_sessions to discover existing sessions. Do not install or run tmux inside Docker run_command containers; those containers are short-lived and cannot preserve tmux servers."
@@ -828,7 +828,7 @@ export async function requestNextStep(client, config, messages) {
828
828
  function: {
829
829
  name: "run_command",
830
830
  description:
831
- "Run a terminal command in the configured working directory under the active shell policy. Secrets and npm publishing are always blocked; Docker workspace mode with approved package installs supports broader network/setup commands, while host destructive or privileged work requires explicit trust.",
831
+ "Run a terminal command in the configured working directory under the active shell policy. Secrets, npm publishing, npx/npm-exec AgInTiFlow self-invocation, and recursive Docker aginti calls are blocked; Docker workspace mode with approved package installs supports broader network/setup commands, while host destructive or privileged work requires explicit trust.",
832
832
  parameters: {
833
833
  type: "object",
834
834
  properties: {
@@ -10,6 +10,13 @@ const NETWORK_FAILURE_PATTERNS = [
10
10
  /unable to access ['"].*?:/i,
11
11
  ];
12
12
 
13
+ const DOCKER_WORKSPACE_PATH_FAILURE_PATTERNS = [
14
+ /\/home\/[^:\n]+:\s+No such file or directory/i,
15
+ /\/Users\/[^:\n]+:\s+No such file or directory/i,
16
+ /[A-Z]:\\[^:\n]+:\s+No such file or directory/i,
17
+ /cannot statx? ['"][^'"]+['"]:\s+No such file or directory/i,
18
+ ];
19
+
13
20
  function quoteShell(value = "") {
14
21
  const text = String(value || "");
15
22
  return `'${text.replace(/'/g, `'\\''`)}'`;
@@ -183,7 +190,26 @@ export function looksLikeNetworkFailure(result = {}) {
183
190
  return NETWORK_FAILURE_PATTERNS.some((pattern) => pattern.test(text));
184
191
  }
185
192
 
193
+ export function looksLikeDockerWorkspacePathFailure(result = {}, config = {}) {
194
+ if ((config.sandboxMode || "") !== "docker-workspace") return false;
195
+ const text = `${result.stdout || ""}\n${result.stderr || ""}`;
196
+ return DOCKER_WORKSPACE_PATH_FAILURE_PATTERNS.some((pattern) => pattern.test(text));
197
+ }
198
+
186
199
  export function buildFailedCommandAdvice({ args = {}, commandPolicy = {}, commandResult = {}, config = {}, state = {} } = {}) {
200
+ if (looksLikeDockerWorkspacePathFailure(commandResult, config)) {
201
+ return {
202
+ ...adviceForCategory("workspace-path", {
203
+ toolName: "run_command",
204
+ args,
205
+ config,
206
+ state,
207
+ reason:
208
+ "The command referenced a host absolute path that is not mounted inside the Docker workspace. Do not retry shell variants; keep output in the workspace or ask for explicit host-mode approval.",
209
+ }),
210
+ failureKind: "workspace-path",
211
+ };
212
+ }
187
213
  if (!looksLikeNetworkFailure(commandResult)) return null;
188
214
  return {
189
215
  ...adviceForCategory(commandPolicy.needsNetwork ? "network-fetch" : "general-shell", {