@wrongstack/tools 0.297.0 → 0.298.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/dist/_spawn-stream.d.ts +2 -0
- package/dist/_util.d.ts +29 -1
- package/dist/audit.js +113 -65
- package/dist/bash.js +5 -4
- package/dist/batch-tool-use.js +70 -7
- package/dist/browser/index.js +31 -1
- package/dist/builtin.js +908 -390
- package/dist/codebase-index/index.js +68 -16
- package/dist/codebase-index/project-server-protocol.d.ts +26 -0
- package/dist/codebase-index/project-server.js +60 -16
- package/dist/codebase-index/worker.js +36 -13
- package/dist/codebase-index/writer-search-helpers.d.ts +16 -0
- package/dist/codebase-index/writer.d.ts +13 -1
- package/dist/design.d.ts +1 -1
- package/dist/design.js +4 -3
- package/dist/diff.js +11 -1
- package/dist/e2e.js +9 -6
- package/dist/edit.js +9 -6
- package/dist/exec-allowlist.d.ts +15 -0
- package/dist/exec.js +627 -568
- package/dist/format.js +116 -65
- package/dist/git.js +22 -2
- package/dist/glob.js +11 -5
- package/dist/grep.js +160 -104
- package/dist/index.js +859 -329
- package/dist/install.js +120 -68
- package/dist/json.js +64 -18
- package/dist/kanban-board-inputs.d.ts +21 -4
- package/dist/kanban.js +20 -5
- package/dist/languages/index.js +128 -71
- package/dist/lint.js +113 -65
- package/dist/outdated.js +86 -26
- package/dist/pack.js +908 -390
- package/dist/patch.js +11 -1
- package/dist/plan.js +32 -10
- package/dist/read.js +77 -23
- package/dist/replace.js +11 -3
- package/dist/scaffold.js +9 -6
- package/dist/session-kanban.js +21 -5
- package/dist/task.js +3 -1
- package/dist/test.js +113 -65
- package/dist/todo.js +3 -1
- package/dist/tool-tier.js +908 -390
- package/dist/tool-use.d.ts +1 -1
- package/dist/tool-use.js +28 -4
- package/dist/tree.d.ts +1 -0
- package/dist/tree.js +44 -8
- package/dist/typecheck.js +113 -65
- package/dist/write.js +9 -6
- package/package.json +7 -6
- package/dist/_concurrency.d.ts.map +0 -1
- package/dist/_danger-detect.d.ts.map +0 -1
- package/dist/_edit-match.d.ts.map +0 -1
- package/dist/_env.d.ts.map +0 -1
- package/dist/_fetch-guard.d.ts.map +0 -1
- package/dist/_output-spool.d.ts.map +0 -1
- package/dist/_redact-command.d.ts.map +0 -1
- package/dist/_regex.d.ts.map +0 -1
- package/dist/_session-shell.d.ts.map +0 -1
- package/dist/_shell-pick.d.ts.map +0 -1
- package/dist/_spawn-stream.d.ts.map +0 -1
- package/dist/_syntax-check.d.ts.map +0 -1
- package/dist/_util.d.ts.map +0 -1
- package/dist/_win32-resolve.d.ts.map +0 -1
- package/dist/audit.d.ts.map +0 -1
- package/dist/audit.js.map +0 -7
- package/dist/auto-proceed-loop-guard.d.ts.map +0 -1
- package/dist/auto-proceed-loop-guard.js.map +0 -7
- package/dist/bash-kill-guard.d.ts.map +0 -1
- package/dist/bash.d.ts.map +0 -1
- package/dist/bash.js.map +0 -7
- package/dist/batch-tool-use.d.ts.map +0 -1
- package/dist/batch-tool-use.js.map +0 -7
- package/dist/browser/artifacts.d.ts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js.map +0 -7
- package/dist/browser/manager.d.ts.map +0 -1
- package/dist/browser/network-guard-proxy.d.ts.map +0 -1
- package/dist/browser/security.d.ts.map +0 -1
- package/dist/browser/tools.d.ts.map +0 -1
- package/dist/browser/types.d.ts.map +0 -1
- package/dist/builtin.d.ts.map +0 -1
- package/dist/builtin.js.map +0 -7
- package/dist/circuit-breaker.d.ts.map +0 -1
- package/dist/circuit-breaker.js.map +0 -7
- package/dist/codebase-index/background-indexer.d.ts.map +0 -1
- package/dist/codebase-index/bm25.d.ts.map +0 -1
- package/dist/codebase-index/circuit-breaker.d.ts.map +0 -1
- package/dist/codebase-index/codebase-index-tool.d.ts.map +0 -1
- package/dist/codebase-index/codebase-search-tool.d.ts.map +0 -1
- package/dist/codebase-index/codebase-stats-tool.d.ts.map +0 -1
- package/dist/codebase-index/dead-code-scan.d.ts.map +0 -1
- package/dist/codebase-index/generic-parser.d.ts.map +0 -1
- package/dist/codebase-index/gitignore.d.ts.map +0 -1
- package/dist/codebase-index/go-parser.d.ts.map +0 -1
- package/dist/codebase-index/index-service.d.ts.map +0 -1
- package/dist/codebase-index/index.d.ts.map +0 -1
- package/dist/codebase-index/index.js.map +0 -7
- package/dist/codebase-index/indexer.d.ts.map +0 -1
- package/dist/codebase-index/json-parser.d.ts.map +0 -1
- package/dist/codebase-index/languages.d.ts.map +0 -1
- package/dist/codebase-index/lsp-kind.d.ts.map +0 -1
- package/dist/codebase-index/parser-dispatch.d.ts.map +0 -1
- package/dist/codebase-index/project-server-cache.d.ts.map +0 -1
- package/dist/codebase-index/project-server-client.d.ts.map +0 -1
- package/dist/codebase-index/project-server-endpoint.d.ts.map +0 -1
- package/dist/codebase-index/project-server-protocol.d.ts.map +0 -1
- package/dist/codebase-index/project-server.d.ts.map +0 -1
- package/dist/codebase-index/project-server.js.map +0 -7
- package/dist/codebase-index/py-parser.d.ts.map +0 -1
- package/dist/codebase-index/refs-extractor.d.ts.map +0 -1
- package/dist/codebase-index/rs-parser.d.ts.map +0 -1
- package/dist/codebase-index/schema.d.ts.map +0 -1
- package/dist/codebase-index/spawn-gate.d.ts.map +0 -1
- package/dist/codebase-index/sqlite-runtime.d.ts.map +0 -1
- package/dist/codebase-index/ts-parser.d.ts.map +0 -1
- package/dist/codebase-index/worker-protocol.d.ts.map +0 -1
- package/dist/codebase-index/worker.d.ts.map +0 -1
- package/dist/codebase-index/worker.js.map +0 -7
- package/dist/codebase-index/writer-admin.d.ts.map +0 -1
- package/dist/codebase-index/writer-bulk-insert.d.ts.map +0 -1
- package/dist/codebase-index/writer-graph-helpers.d.ts.map +0 -1
- package/dist/codebase-index/writer-graph-reader.d.ts.map +0 -1
- package/dist/codebase-index/writer-helpers.d.ts.map +0 -1
- package/dist/codebase-index/writer-pragmas.d.ts.map +0 -1
- package/dist/codebase-index/writer-ref-mapper.d.ts.map +0 -1
- package/dist/codebase-index/writer-schema.d.ts.map +0 -1
- package/dist/codebase-index/writer-search-helpers.d.ts.map +0 -1
- package/dist/codebase-index/writer-store-pool.d.ts.map +0 -1
- package/dist/codebase-index/writer.d.ts.map +0 -1
- package/dist/codebase-index/yaml-parser.d.ts.map +0 -1
- package/dist/design.d.ts.map +0 -1
- package/dist/design.js.map +0 -7
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js.map +0 -7
- package/dist/document.d.ts.map +0 -1
- package/dist/document.js.map +0 -7
- package/dist/e2e.d.ts.map +0 -1
- package/dist/e2e.js.map +0 -7
- package/dist/edit.d.ts.map +0 -1
- package/dist/edit.js.map +0 -7
- package/dist/exec-kill-guard.d.ts.map +0 -1
- package/dist/exec.d.ts.map +0 -1
- package/dist/exec.js.map +0 -7
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js.map +0 -7
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js.map +0 -7
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js.map +0 -7
- package/dist/glob.d.ts.map +0 -1
- package/dist/glob.js.map +0 -7
- package/dist/grep.d.ts.map +0 -1
- package/dist/grep.js.map +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/install.d.ts.map +0 -1
- package/dist/install.js.map +0 -7
- package/dist/json.d.ts.map +0 -1
- package/dist/json.js.map +0 -7
- package/dist/kanban-board-inputs.d.ts.map +0 -1
- package/dist/kanban-decomposition-actions.d.ts.map +0 -1
- package/dist/kanban-detail-actions.d.ts.map +0 -1
- package/dist/kanban-evidence-bridge.d.ts.map +0 -1
- package/dist/kanban-presence.d.ts.map +0 -1
- package/dist/kanban-split-task-handler.d.ts.map +0 -1
- package/dist/kanban-task-inputs.d.ts.map +0 -1
- package/dist/kanban-tool-results.d.ts.map +0 -1
- package/dist/kanban-tool-schema.d.ts.map +0 -1
- package/dist/kanban-tool-types.d.ts.map +0 -1
- package/dist/kanban.d.ts.map +0 -1
- package/dist/kanban.js.map +0 -7
- package/dist/languages/detect.d.ts.map +0 -1
- package/dist/languages/diagnostics.d.ts.map +0 -1
- package/dist/languages/execute-tool.d.ts.map +0 -1
- package/dist/languages/execute.d.ts.map +0 -1
- package/dist/languages/index.d.ts.map +0 -1
- package/dist/languages/index.js.map +0 -7
- package/dist/languages/legacy-bridge.d.ts.map +0 -1
- package/dist/languages/package-tool.d.ts.map +0 -1
- package/dist/languages/plan.d.ts.map +0 -1
- package/dist/languages/profile-helpers.d.ts.map +0 -1
- package/dist/languages/profiles/additional.d.ts.map +0 -1
- package/dist/languages/profiles/primary.d.ts.map +0 -1
- package/dist/languages/registry.d.ts.map +0 -1
- package/dist/languages/tool.d.ts.map +0 -1
- package/dist/languages/types.d.ts.map +0 -1
- package/dist/lint.d.ts.map +0 -1
- package/dist/lint.js.map +0 -7
- package/dist/logs.d.ts.map +0 -1
- package/dist/logs.js.map +0 -7
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js.map +0 -7
- package/dist/mode.d.ts.map +0 -1
- package/dist/mode.js.map +0 -7
- package/dist/next-steps.d.ts.map +0 -1
- package/dist/next-steps.js.map +0 -7
- package/dist/outdated.d.ts.map +0 -1
- package/dist/outdated.js.map +0 -7
- package/dist/pack.d.ts.map +0 -1
- package/dist/pack.js.map +0 -7
- package/dist/patch.d.ts.map +0 -1
- package/dist/patch.js.map +0 -7
- package/dist/plan.d.ts.map +0 -1
- package/dist/plan.js.map +0 -7
- package/dist/process-guardian.d.ts.map +0 -1
- package/dist/process-registry-persistent.d.ts.map +0 -1
- package/dist/process-registry.d.ts.map +0 -1
- package/dist/process-registry.js.map +0 -7
- package/dist/ps-slash.d.ts.map +0 -1
- package/dist/ps-slash.js.map +0 -7
- package/dist/read.d.ts.map +0 -1
- package/dist/read.js.map +0 -7
- package/dist/replace.d.ts.map +0 -1
- package/dist/replace.js.map +0 -7
- package/dist/scaffold.d.ts.map +0 -1
- package/dist/scaffold.js.map +0 -7
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -7
- package/dist/session-kanban.d.ts.map +0 -1
- package/dist/session-kanban.js.map +0 -7
- package/dist/set-working-dir.d.ts.map +0 -1
- package/dist/skill.d.ts.map +0 -1
- package/dist/skill.js.map +0 -7
- package/dist/spawn-background.d.ts.map +0 -1
- package/dist/task.d.ts.map +0 -1
- package/dist/task.js.map +0 -7
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js.map +0 -7
- package/dist/todo.d.ts.map +0 -1
- package/dist/todo.js.map +0 -7
- package/dist/tool-diff.d.ts.map +0 -1
- package/dist/tool-diff.js.map +0 -7
- package/dist/tool-help.d.ts.map +0 -1
- package/dist/tool-help.js.map +0 -7
- package/dist/tool-icon-map.d.ts.map +0 -1
- package/dist/tool-icons.d.ts.map +0 -1
- package/dist/tool-icons.js.map +0 -7
- package/dist/tool-search.d.ts.map +0 -1
- package/dist/tool-search.js.map +0 -7
- package/dist/tool-summary.d.ts.map +0 -1
- package/dist/tool-summary.js.map +0 -7
- package/dist/tool-tier.d.ts.map +0 -1
- package/dist/tool-tier.js.map +0 -7
- package/dist/tool-use.d.ts.map +0 -1
- package/dist/tool-use.js.map +0 -7
- package/dist/tree.d.ts.map +0 -1
- package/dist/tree.js.map +0 -7
- package/dist/typecheck.d.ts.map +0 -1
- package/dist/typecheck.js.map +0 -7
- package/dist/win32.d.ts.map +0 -1
- package/dist/win32.js.map +0 -7
- package/dist/write.d.ts.map +0 -1
- package/dist/write.js.map +0 -7
package/dist/logs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAInD,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;IAChD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CA6EhD,CAAC"}
|
package/dist/logs.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/logs.ts", "../src/_regex.ts", "../src/_util.ts"],
|
|
4
|
-
"sourcesContent": ["import { spawn } from 'node:child_process';\nimport { buildChildEnv } from '@wrongstack/core/utils';\nimport type { Tool } from '@wrongstack/core/types';\nimport { compileUserRegex } from './_regex.js';\nimport { safeResolve } from './_util.js';\n\ninterface LogsInput {\n service?: string | undefined;\n path?: string | undefined;\n lines?: number | undefined;\n stream?: boolean | undefined;\n filter?: string | undefined;\n since?: '1h' | '6h' | '24h' | 'all' | undefined;\n cwd?: string | undefined;\n}\n\ninterface LogEntry {\n timestamp: string;\n level: string;\n message: string;\n source?: string | undefined;\n}\n\ninterface LogsOutput {\n source: string;\n entries: LogEntry[];\n total: number;\n truncated: boolean;\n stream_mode: boolean;\n}\n\nexport const logsTool: Tool<LogsInput, LogsOutput> = {\n name: 'logs',\n category: 'Logs',\n description:\n 'Read or stream logs from files, Docker containers, or systemd services. Useful for debugging running applications.',\n usageHint:\n 'DEBUGGING TOOL \u2014 USE CAREFULLY IN AUTONOMOUS MODE:\\n\\n' +\n '- Prefer `path` for local files or `service` for containers/systemd.\\n' +\n '- `stream: true` = live tail (can be expensive).\\n' +\n '- Always use `filter` (regex) when possible to reduce noise and token usage.\\n' +\n '- Long-running streams should be avoided unless the user explicitly wants live logs.',\n permission: 'confirm',\n mutating: false,\n timeoutMs: 30_000,\n capabilities: ['shell.restricted'],\n icon: 'logs',\n inputSchema: {\n type: 'object',\n properties: {\n service: {\n type: 'string',\n description: 'Service name for Docker or systemd journal',\n },\n path: {\n type: 'string',\n description: 'Path to log file (alternative to service)',\n },\n lines: {\n type: 'integer',\n description: 'Number of log lines to fetch (default: 100, 0 for all)',\n minimum: 0,\n maximum: 10000,\n },\n stream: {\n type: 'boolean',\n description: 'Stream logs continuously (like tail -f) (default: false)',\n },\n filter: {\n type: 'string',\n description: 'Regex pattern to filter log lines',\n },\n since: {\n type: 'string',\n enum: ['1h', '6h', '24h', 'all'],\n description: 'Only show logs since duration',\n },\n cwd: { type: 'string', description: 'Working directory (default: cwd)' },\n },\n },\n async execute(input, ctx, opts) {\n const cwd = input.cwd ? safeResolve(input.cwd, ctx) : ctx.cwd;\n const lines = input.lines ?? 100;\n let filterRe: RegExp | null = null;\n if (input.filter) {\n const compiled = compileUserRegex(input.filter, 'i');\n if (!compiled.ok) {\n throw new Error(`logs: ${compiled.reason}`);\n }\n filterRe = compiled.regex;\n }\n\n if (input.service) {\n return await dockerLogs(input.service, lines, filterRe, cwd, opts.signal);\n }\n\n if (input.path) {\n return await fileLogs(safeResolve(input.path, ctx), lines, filterRe, input.stream ?? false);\n }\n\n return {\n source: 'none',\n entries: [],\n total: 0,\n truncated: false,\n stream_mode: false,\n };\n },\n};\n\nasync function dockerLogs(\n service: string,\n lines: number,\n filterRe: RegExp | null,\n cwd: string,\n signal: AbortSignal,\n since?: string | undefined,\n): Promise<LogsOutput> {\n const args = ['logs'];\n if (lines > 0) args.push('--tail', String(lines));\n /* v8 ignore start -- execute() does not forward `since` to dockerLogs yet; this block is currently unreachable. */\n if (since) {\n const sinceMap: Record<string, string> = { '1h': '1h', '6h': '6h', '24h': '24h' };\n args.push('--since', sinceMap[since] ?? '1h');\n }\n /* v8 ignore stop */\n // Validate service name to prevent container name injection.\n // Docker container names are limited to [a-zA-Z0-9][a-zA-Z0-9._-]+.\n if (!/^[a-zA-Z0-9][a-zA-Z0-9._:-]+$/.test(service)) {\n return {\n source: `docker:${service}`,\n entries: [],\n total: 0,\n truncated: false,\n stream_mode: false,\n };\n }\n args.push('--timestamps', service);\n\n return new Promise((resolve) => {\n let stdout = '';\n let stderr = '';\n const MAX = 200_000;\n let settled = false;\n\n const empty = (): LogsOutput => ({\n source: `docker:${service}`,\n entries: [],\n total: 0,\n truncated: false,\n stream_mode: false,\n });\n const finish = (result: LogsOutput) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(result);\n };\n\n const child = spawn('docker', args, { cwd, signal, env: buildChildEnv(), stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });\n\n // `docker logs --tail N` reads recent lines and exits \u2014 fast when the\n // daemon is up. But if the daemon is unreachable (common on CI runners\n // with no running Docker), the CLI can hang on the socket connection and\n // emit neither `close` nor `error`. Kill it and return empty so the tool\n // (and its tests) never hang.\n const timer = setTimeout(() => {\n child.kill('SIGTERM');\n finish(empty());\n }, DOCKER_LOGS_TIMEOUT_MS);\n\n child.stdout?.on('data', (c) => {\n if (stdout.length < MAX) stdout += c.toString();\n });\n child.stderr?.on('data', (c) => {\n if (stderr.length < MAX) stderr += c.toString();\n });\n // When the child is SIGTERM-killed on timeout (or aborted via `signal`),\n // its pipes can emit `error` (e.g. EPIPE on Windows). Without a listener\n // that surfaces as an unhandled error and can fail the host/test \u2014 swallow\n // it at debug level; `child.on('error')` and the timeout already drive the result.\n child.stdout?.on('error', (e) => {\n console.log(JSON.stringify({ level: 'debug', event: 'pipe_error', stream: 'stdout', error: e.message }));\n });\n child.stderr?.on('error', (e) => {\n console.log(JSON.stringify({ level: 'debug', event: 'pipe_error', stream: 'stderr', error: e.message }));\n });\n child.on('close', () => {\n const output = stdout + stderr;\n const entries = parseLogLines(output, filterRe);\n finish({\n source: `docker:${service}`,\n entries,\n total: entries.length,\n truncated: output.length >= MAX,\n stream_mode: false,\n });\n });\n child.on('error', () => finish(empty()));\n });\n}\n\n/**\n * Hard ceiling for a `docker logs` read. The daemon may be unreachable on CI\n * (no Docker running), where the CLI hangs on the socket without ever exiting.\n */\nconst DOCKER_LOGS_TIMEOUT_MS = 3_000;\n\n// Hard cap on tail-window size \u2014 `lines: 0` historically meant \"all\" and\n// happily buffered an entire multi-GB log into memory. Cap at 100k lines;\n// callers that need more should narrow with `filter`.\nconst MAX_TAIL_LINES = 100_000;\n\nasync function fileLogs(\n path: string,\n lines: number,\n filterRe: RegExp | null,\n stream: boolean,\n): Promise<LogsOutput> {\n const { createInterface } = await import('node:readline');\n const { createReadStream } = await import('node:fs');\n const entries: LogEntry[] = [];\n\n // Effective tail window: clamp to MAX_TAIL_LINES; treat 0 / negative as\n // \"max window\" rather than \"unlimited\" so a malicious /proc/kcore path\n // cannot OOM the worker.\n const effLines = lines > 0 ? Math.min(lines, MAX_TAIL_LINES) : MAX_TAIL_LINES;\n // Rolling window backed by a fixed-size circular buffer \u2014 at most\n // `effLines` strings live in memory regardless of file size.\n const window: string[] = new Array(effLines);\n let writeIdx = 0;\n let totalLines = 0;\n\n const rl = createInterface({\n input: createReadStream(path),\n crlfDelay: Number.POSITIVE_INFINITY,\n });\n\n for await (const line of rl) {\n if (filterRe && !filterRe.test(line)) continue;\n window[writeIdx] = line;\n writeIdx = (writeIdx + 1) % effLines;\n totalLines++;\n }\n\n // Read the window back in arrival order.\n const ordered: string[] = [];\n const start = totalLines >= effLines ? writeIdx : 0;\n const count = Math.min(totalLines, effLines);\n for (let i = 0; i < count; i++) {\n const v = window[(start + i) % effLines];\n if (v !== undefined) ordered.push(v);\n }\n\n for (const line of ordered) {\n const parsed = parseLine(line);\n if (parsed) entries.push(parsed);\n }\n\n return {\n source: path,\n entries,\n total: entries.length,\n truncated: totalLines > effLines,\n stream_mode: stream,\n };\n}\n\nfunction parseLogLines(output: string, filterRe: RegExp | null): LogEntry[] {\n const lines = output.split('\\n').filter(Boolean);\n const entries: LogEntry[] = [];\n\n for (const line of lines) {\n if (filterRe && !filterRe.test(line)) continue;\n const parsed = parseLine(line);\n if (parsed) entries.push(parsed);\n }\n\n return entries;\n}\n\nfunction parseLine(line: string): LogEntry | null {\n const tsRe = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z?)\\s+(?:\\[?(\\w+)\\]?)\\s*(.*)/;\n const match = tsRe.exec(line);\n\n if (match) {\n return {\n timestamp: match[1] ?? '',\n level: match[2]?.toLowerCase() ?? 'info',\n message: match[3] ?? '',\n };\n }\n\n const levelRe = /(ERROR|WARN|INFO|DEBUG|TRACE)\\s+(.*)/i;\n const levelMatch = levelRe.exec(line);\n\n if (levelMatch) {\n return {\n timestamp: '',\n level: levelMatch[1]?.toLowerCase() ?? 'info',\n message: levelMatch[2] ?? line,\n };\n }\n\n return {\n timestamp: '',\n level: 'info',\n message: line,\n };\n}\n", "/**\n * Compile a user-supplied regex with conservative bounds against ReDoS.\n *\n * Node's regex engine (V8) is backtracking-based and cannot interrupt a\n * synchronous match \u2014 a pattern like `(a+)+$` against a sufficiently long\n * line will pin a worker for seconds. The executor's outer `timeoutMs` only\n * fires between async boundaries, so a long regex eval inside a sync loop\n * is uninterruptible.\n *\n * We can't fully prevent ReDoS without an alternative engine (re2-wasm), but\n * we can sharply limit the blast radius:\n *\n * 1. Cap pattern length \u2014 practically all legitimate user patterns are\n * under 256 characters. A 4 KB pattern is almost certainly malicious\n * or a copy-paste accident.\n * 2. Reject patterns containing the most obvious super-linear structures.\n * This is a coarse filter (false-positives are likely; we accept that\n * for hostile-input contexts).\n *\n * Callers should additionally bound the *subject* length (e.g. by capping\n * line size before matching).\n */\n\nconst MAX_PATTERN_LEN = 256;\n\n// Heuristics for catastrophic-backtracking constructs. Not exhaustive; bias\n// toward false-positives in tools that accept LLM-generated input.\nconst DANGEROUS_PATTERNS: ReadonlyArray<RegExp> = [\n // (a+)+, (.*)+, etc \u2014 nested quantifier on a group with internal quantifier\n /(\\([^)]*[+*][^)]*\\))[+*]/,\n /(\\(\\?:[^)]*[+*][^)]*\\))[+*]/,\n // Adjacent quantifiers: a++ a*+\n /[+*]{2,}/,\n // Quantifier on alternation with length 2+\n /\\([^|)]+\\|[^)]+\\)[+*][+*]/,\n // Greedy quantifier inside lookahead/lookbehind \u2014 (?!.*a+)\n /[([][^)\\]]*[+*][^)\\]]*[)\\]][^)]*\\?\\??/,\n];\n\nexport interface CompileResult {\n ok: true;\n regex: RegExp;\n}\n\nexport interface CompileFail {\n ok: false;\n reason: string;\n}\n\nexport function compileUserRegex(pattern: string, flags: string): CompileResult | CompileFail {\n if (typeof pattern !== 'string') {\n return { ok: false, reason: 'pattern must be a string' };\n }\n if (pattern.length === 0) {\n return { ok: false, reason: 'pattern is empty' };\n }\n if (pattern.length > MAX_PATTERN_LEN) {\n return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };\n }\n for (const rx of DANGEROUS_PATTERNS) {\n if (rx.test(pattern)) {\n return {\n ok: false,\n reason:\n 'pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers',\n };\n }\n }\n try {\n return { ok: true, regex: new RegExp(pattern, flags) };\n } catch (err) {\n return {\n ok: false,\n reason: err instanceof Error ? err.message : 'invalid regex',\n };\n }\n}\n\n/**\n * Truncate a subject line to a safe length for synchronous regex eval.\n * The cap is conservative; tools that need exact-line matching against very\n * long lines should use ripgrep externally rather than the native walker.\n */\nexport const MAX_SUBJECT_LEN = 64 * 1024;\n\nexport function capSubject(line: string): string {\n return line.length > MAX_SUBJECT_LEN ? line.slice(0, MAX_SUBJECT_LEN) : line;\n}\n", "import { createHash } from 'node:crypto';\nimport * as fsp from 'node:fs/promises';\nimport * as path from 'node:path';\nimport * as Core from '@wrongstack/core/utils';\nimport type { Context } from '@wrongstack/core/agent';\n\n/**\n * sha-256 hex of a UTF-8 string. Used by the file tools to record a content\n * hash alongside the mtime in `ctx.recordRead` \u2014 the hash is the authoritative\n * staleness arbiter for `edit` (mtime has a 2 s tolerance window on Windows).\n */\nexport function sha256hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n/** Detected package manager for a project directory. */\nexport type PackageManager = 'pnpm' | 'yarn' | 'npm';\n\n/**\n * Detect the project's package manager by inspecting lockfiles in `cwd`.\n * Order: pnpm \u2192 yarn \u2192 npm (default). Missing or unreadable directories fall\n * back to `npm` rather than throwing, so a `safeResolve`-checked cwd that\n * happens to be empty never aborts the tool.\n */\nexport async function detectPackageManager(cwd: string): Promise<PackageManager> {\n const { stat } = await import('node:fs/promises');\n try {\n await stat(`${cwd}/pnpm-lock.yaml`);\n return 'pnpm';\n } catch {\n /* not pnpm */\n }\n try {\n await stat(`${cwd}/yarn.lock`);\n return 'yarn';\n } catch {\n /* not yarn */\n }\n return 'npm';\n}\n\nexport function resolvePath(input: string, ctx: Context): string {\n return path.isAbsolute(input) ? path.normalize(input) : path.resolve(ctx.workingDir ?? ctx.cwd, input);\n}\n\n/**\n * Roots every file tool may always reach, even in restricted mode: the\n * project root and the user-global `~/.wrongstack` directory (config, memory,\n * sessions, skills). `~/.wrongstack` honors the `WRONGSTACK_HOME` override.\n */\nfunction allowedRoots(ctx: Context): string[] {\n return [path.resolve(ctx.projectRoot), path.resolve(Core.wstackGlobalRoot())];\n}\n\n/** True if `target` is `root` itself or nested inside any of `roots`. */\nfunction isInsideAny(target: string, roots: string[]): boolean {\n return roots.some((root) => {\n const rel = path.relative(root, target);\n return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));\n });\n}\n\nexport function ensureInsideRoot(absPath: string, ctx: Context): string {\n const target = path.resolve(absPath);\n // Unrestricted filesystem access: skip the project-root containment check.\n if (ctx.allowOutsideProjectRoot) return target;\n if (isInsideAny(target, allowedRoots(ctx))) return target;\n throw new Error(`Path \"${absPath}\" is outside project root \"${path.resolve(ctx.projectRoot)}\"`);\n}\n\nexport function safeResolve(input: string, ctx: Context): string {\n return ensureInsideRoot(resolvePath(input, ctx), ctx);\n}\n\n/**\n * Defense against in-root\u2192out-of-root symlink escape (CWE-59). `safeResolve`\n * only does a syntactic `../` check, so a symlink that lives *inside* the\n * project root but points outside still passes it. This resolves the path\n * through `fs.realpath` and re-verifies containment against the realpath of\n * the project root (comparing like-for-like, since the root itself may be a\n * symlink \u2014 macOS `/var`\u2192`/private/var`, Windows 8.3 short names). For a path\n * that does not exist yet (e.g. a `write` to a new file) the nearest existing\n * ancestor directory is checked instead. Throws if the real target escapes.\n *\n * Mirrors the per-file guard already used in `replace.ts`/`grep.ts`; applied\n * to single-file `read`/`edit`/`write` it throws (rather than skips) because\n * the caller named exactly one file.\n */\nexport async function assertRealInsideRoot(absPath: string, ctx: Context): Promise<void> {\n // Unrestricted filesystem access: no symlink-escape check to perform.\n if (ctx.allowOutsideProjectRoot) return;\n // Compare like-for-like against the realpath of each always-allowed root\n // (project root + ~/.wrongstack), since a root may itself be a symlink.\n const realRoots = await Promise.all(\n allowedRoots(ctx).map((r) => fsp.realpath(r).catch(() => path.resolve(r))),\n );\n let probe = absPath;\n for (;;) {\n let real: string;\n try {\n real = await fsp.realpath(probe);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n const parent = path.dirname(probe);\n if (parent === probe) return; // reached fs root without escaping\n probe = parent;\n continue;\n }\n throw err;\n }\n if (isInsideAny(real, realRoots)) return;\n throw new Error(\n `Path \"${absPath}\" resolves through a symlink outside project root \"${realRoots[0]}\"`,\n );\n }\n}\n\n/** `safeResolve` + symlink realpath containment check. Async. */\nexport async function safeResolveReal(input: string, ctx: Context): Promise<string> {\n const abs = safeResolve(input, ctx);\n await assertRealInsideRoot(abs, ctx);\n return abs;\n}\n\nexport function truncateMiddle(s: string, max: number): string {\n if (Buffer.byteLength(s, 'utf8') <= max) return s;\n const half = Math.floor(max / 2);\n return (\n s.slice(0, half) +\n `\\n\u2026[truncated ${Buffer.byteLength(s, 'utf8') - max} bytes from middle]\u2026\\n` +\n s.slice(-half)\n );\n}\n\nexport function isBinaryBuffer(buf: Buffer): boolean {\n const len = Math.min(buf.length, 8192);\n for (let i = 0; i < len; i++) {\n if (buf[i] === 0) return true;\n }\n return false;\n}\n\n// \u2500\u2500\u2500 Command-output normalization (token-saving) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Raw process output is full of tokens the model gains nothing from: ANSI\n// escapes, carriage-return progress spam, runs of identical warning lines, and\n// huge tails of build noise. These helpers strip that noise before the output\n// reaches the LLM. They are scoped to COMMAND tools (bash/git/exec and the\n// _spawn-stream consumers) \u2014 never applied to structured/code outputs.\n\n/** Unified byte cap for all command tool output fed to the model. */\nexport const COMMAND_OUTPUT_MAX_BYTES = 32_768;\n\n/** Runs of >= this many identical consecutive lines are collapsed. */\nconst REPEAT_RUN_THRESHOLD = 3;\n\n/**\n * Collapse carriage-return overwrites the way a terminal would: `\\r\\n` becomes\n * `\\n`, and a bare `\\r` (progress redraw) keeps only the text after the LAST\n * `\\r` on its physical line. Without this, a single progress bar that redraws\n * 200 times explodes into 200 lines.\n */\nexport function collapseCarriageReturns(text: string): string {\n const lf = text.replace(/\\r\\n/g, '\\n');\n if (!lf.includes('\\r')) return lf;\n return lf\n .split('\\n')\n .map((line) => (line.includes('\\r') ? line.slice(line.lastIndexOf('\\r') + 1) : line))\n .join('\\n');\n}\n\n/**\n * Collapse a run of `minRun`+ identical consecutive lines into the line once\n * plus a marker. Consecutive-only \u2014 it never reorders or dedups non-adjacent\n * lines, so diffs/source stay intact.\n */\nexport function collapseConsecutiveDuplicates(text: string, minRun = REPEAT_RUN_THRESHOLD): string {\n const lines = text.split('\\n');\n const out: string[] = [];\n let i = 0;\n while (i < lines.length) {\n let j = i + 1;\n while (j < lines.length && lines[j] === lines[i]) j++;\n const run = j - i;\n if (run >= minRun) {\n out.push(lines[i]!, `\u2026 \u27E8repeated ${run}\u00D7\u27E9`);\n } else {\n for (let k = i; k < j; k++) out.push(lines[k]!);\n }\n i = j;\n }\n return out.join('\\n');\n}\n\n/** Largest prefix of `s` whose UTF-8 byte length is <= `maxBytes`. */\nfunction takeHeadBytes(s: string, maxBytes: number): string {\n if (maxBytes <= 0) return '';\n /* v8 ignore next -- only caller (truncateHeadTail) passes a budget smaller than s; defensive. */\n if (Buffer.byteLength(s, 'utf8') <= maxBytes) return s;\n let lo = 0;\n let hi = s.length;\n while (lo < hi) {\n const mid = Math.ceil((lo + hi) / 2);\n if (Buffer.byteLength(s.slice(0, mid), 'utf8') <= maxBytes) lo = mid;\n else hi = mid - 1;\n }\n return s.slice(0, lo);\n}\n\n/** Largest suffix of `s` whose UTF-8 byte length is <= `maxBytes`. */\nfunction takeTailBytes(s: string, maxBytes: number): string {\n if (maxBytes <= 0) return '';\n /* v8 ignore next -- only caller (truncateHeadTail) passes a budget smaller than s; defensive. */\n if (Buffer.byteLength(s, 'utf8') <= maxBytes) return s;\n let lo = 0;\n let hi = s.length;\n while (lo < hi) {\n const mid = Math.ceil((lo + hi) / 2);\n if (Buffer.byteLength(s.slice(s.length - mid), 'utf8') <= maxBytes) lo = mid;\n else hi = mid - 1;\n }\n return s.slice(s.length - lo);\n}\n\n/**\n * Truncate to `maxBytes` keeping BOTH ends \u2014 the head (what ran / early context)\n * and the tail (errors and summaries usually land last), biased ~45/55 toward\n * the tail. The result never exceeds `maxBytes`.\n */\nexport function truncateHeadTail(s: string, maxBytes: number): string {\n const total = Buffer.byteLength(s, 'utf8');\n if (total <= maxBytes) return s;\n // Reserve a fixed allowance for the marker so the final string can't exceed\n // the cap even though the dropped-byte count's digit width varies.\n const MARKER_RESERVE = 64;\n const avail = Math.max(0, maxBytes - MARKER_RESERVE);\n const headBudget = Math.floor(avail * 0.45);\n const head = takeHeadBytes(s, headBudget);\n const tail = takeTailBytes(s, avail - Buffer.byteLength(head, 'utf8'));\n const kept = Buffer.byteLength(head, 'utf8') + Buffer.byteLength(tail, 'utf8');\n return `${head}\\n\u2026[truncated ${total - kept} bytes]\u2026\\n${tail}`;\n}\n\n/**\n * Full token-saving pipeline for command tool output: strip ANSI \u2192 collapse\n * carriage-return progress \u2192 trim trailing whitespace \u2192 collapse identical\n * consecutive lines \u2192 squeeze blank-line runs \u2192 head+tail truncate to the cap.\n */\nexport function normalizeCommandOutput(\n raw: string,\n opts: { maxBytes?: number | undefined } = {},\n): string {\n if (!raw) return raw;\n let text = Core.stripAnsi(raw);\n text = collapseCarriageReturns(text);\n text = text.replace(/[ \\t]+$/gm, ''); // trailing whitespace per line\n text = collapseConsecutiveDuplicates(text);\n text = text.replace(/\\n{3,}/g, '\\n\\n'); // >=2 blank lines \u2192 1\n return truncateHeadTail(text, opts.maxBytes ?? COMMAND_OUTPUT_MAX_BYTES);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa;AACtB,SAAS,qBAAqB;;;ACsB9B,IAAM,kBAAkB;AAIxB,IAAM,qBAA4C;AAAA;AAAA,EAEhD;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AACF;AAYO,SAAS,iBAAiB,SAAiB,OAA4C;AAC5F,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO,EAAE,IAAI,OAAO,QAAQ,2BAA2B;AAAA,EACzD;AACA,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO,EAAE,IAAI,OAAO,QAAQ,mBAAmB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M,OAAO;AACb,QAAM,QAAQ,KAAK,KAAK,IAAI;AAE5B,MAAI,OAAO;AACT,WAAO;AAAA,MACL,WAAW,MAAM,CAAC,KAAK;AAAA,MACvB,OAAO,MAAM,CAAC,GAAG,YAAY,KAAK;AAAA,MAClC,SAAS,MAAM,CAAC,KAAK;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,UAAU;AAChB,QAAM,aAAa,QAAQ,KAAK,IAAI;AAEpC,MAAI,YAAY;AACd,WAAO;AAAA,MACL,WAAW;AAAA,MACX,OAAO,WAAW,CAAC,GAAG,YAAY,KAAK;AAAA,MACvC,SAAS,WAAW,CAAC,KAAK;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AACF;",
|
|
6
|
-
"names": ["resolve", "path"]
|
|
7
|
-
}
|
package/dist/memory.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG7E,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,SAAS,CAAC;IACpG,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;CAC/D;AAED,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,WAAW,CAAC;CACpB;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,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/memory.ts"],
|
|
4
|
-
"sourcesContent": ["import type { MemoryScope, MemoryStore, Tool } from '@wrongstack/core/types';\nimport { ToolValidationError, type MemoryEntry } from '@wrongstack/core/types';\n\ninterface RememberInput {\n text: string;\n scope?: MemoryScope | undefined;\n /** Memory type for categorization. */\n type?: 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern' | undefined;\n /** Hashtag-style tags for grouping and search. */\n tags?: string[] | undefined;\n /** Priority level \u2014 critical entries always injected into context. */\n priority?: 'critical' | 'high' | 'medium' | 'low' | undefined;\n}\n\ninterface RememberOutput {\n ok: true;\n scope: MemoryScope;\n}\n\ninterface ForgetInput {\n query: string;\n scope?: MemoryScope | undefined;\n}\n\ninterface ForgetOutput {\n removed: number;\n scope: MemoryScope;\n}\n\nexport function rememberTool(memory: MemoryStore): Tool<RememberInput, RememberOutput> {\n return {\n name: 'remember',\n category: 'Session',\n description:\n 'Persist facts, conventions, decisions, and preferences into long-term memory. Memories survive restarts and are scored for relevance in future sessions.',\n usageHint:\n 'Persist facts, conventions, decisions, and preferences into long-term memory.\\n\\n' +\n 'WHEN TO USE:\\n' +\n '- Project conventions discovered during a task (build tool, lint rules, code style)\\n' +\n '- Architecture decisions made (chose X over Y, decided to use pattern Z)\\n' +\n '- User preferences expressed (prefers short names, always uses pnpm)\\n' +\n '- Anti-patterns identified (never do X, avoid pattern Y)\\n' +\n '- File/location references useful across sessions\\n\\n' +\n 'WHEN NOT TO USE:\\n' +\n '- Temporary task state or progress \u2192 use `todo`\\n' +\n '- One-off debugging notes\\n' +\n '- Information already obvious from the codebase\\n\\n' +\n 'Always include `type` and `priority`. Use 1-3 `tags` for grouping.\\n' +\n 'Better to remember a fact now than rediscover it next session.',\n permission: 'confirm',\n mutating: true,\n timeoutMs: 2_000,\n capabilities: ['memory.write'],\n icon: 'settings',\n inputSchema: {\n type: 'object',\n properties: {\n text: {\n type: 'string',\n description: 'The fact or note to remember. Keep it concise and factual.',\n },\n scope: {\n type: 'string',\n enum: ['project-agents', 'project-memory', 'user-memory'],\n description: 'Where to store it: project-memory (shared), user-memory (personal), or project-agents.',\n },\n type: {\n type: 'string',\n enum: ['fact', 'decision', 'convention', 'preference', 'reference', 'anti_pattern'],\n description: 'Category for filtering and relevance scoring.',\n },\n tags: {\n type: 'array',\n items: { type: 'string' },\n description: 'Hashtag-style tags for grouping and search.',\n },\n priority: {\n type: 'string',\n enum: ['critical', 'high', 'medium', 'low'],\n description: 'Priority level. Critical = always injected into context.',\n },\n },\n required: ['text'],\n },\n async execute(input) {\n if (!input?.text) {\n throw new ToolValidationError({\n message: 'remember: text is required',\n field: 'text',\n });\n }\n const scope = input.scope ?? 'project-memory';\n await memory.remember(input.text, scope, {\n type: input.type,\n tags: input.tags,\n priority: input.priority,\n });\n return { ok: true, scope };\n },\n };\n}\n\nexport function forgetTool(memory: MemoryStore): Tool<ForgetInput, ForgetOutput> {\n return {\n name: 'forget',\n category: 'Session',\n description: 'Remove memory entries that contain the given substring (case-insensitive). Use with caution.',\n usageHint:\n 'This permanently deletes matching memories in the chosen scope.\\n' +\n '- Provide a reasonably specific `query` to avoid deleting unrelated memories.\\n' +\n '- Always double-check before calling with broad queries.\\n' +\n '- Use `remember` + `forget` together to maintain clean long-term memory.',\n permission: 'confirm',\n mutating: true,\n timeoutMs: 2_000,\n capabilities: ['memory.delete'],\n inputSchema: {\n type: 'object',\n properties: {\n query: { type: 'string' },\n scope: { type: 'string', enum: ['project-agents', 'project-memory', 'user-memory'] },\n },\n required: ['query'],\n },\n async execute(input) {\n if (!input?.query) {\n throw new ToolValidationError({\n message: 'forget: query is required',\n field: 'query',\n });\n }\n const scope = input.scope ?? 'project-memory';\n const removed = await memory.forget(input.query, scope);\n return { removed, scope };\n },\n };\n}\n\n// \u2500\u2500 Enhanced memory query tools \u2014 use backend capabilities \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface SearchMemoryInput {\n query: string;\n scope?: MemoryScope | undefined;\n limit?: number | undefined;\n}\n\ninterface SearchMemoryOutput {\n results: Array<{\n text: string;\n ts: string;\n scope: MemoryScope;\n type?: string | undefined;\n tags?: string[] | undefined;\n priority?: string | undefined;\n }>;\n}\n\nexport function searchMemoryTool(memory: MemoryStore): Tool<SearchMemoryInput, SearchMemoryOutput> {\n return {\n name: 'search_memory',\n category: 'Session',\n description:\n 'Search memory entries by content. With the default backend this does substring matching; semantic/graph backends use embedding similarity or graph traversal.',\n usageHint:\n 'Search long-term memory for relevant facts, conventions, or decisions.\\n' +\n '- Returns results ordered by relevance (newest-first for default, similarity for semantic).\\n' +\n '- Use before starting a task to recall project conventions and past decisions.\\n' +\n '- `limit` caps results (default 5, max 20).',\n permission: 'auto',\n mutating: false,\n timeoutMs: 2_000,\n capabilities: ['memory.read'],\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description: 'Search query \u2014 words or phrase to find in memory.',\n },\n scope: {\n type: 'string',\n enum: ['project-agents', 'project-memory', 'user-memory'],\n description: 'Which scope to search. Defaults to project-memory.',\n },\n limit: {\n type: 'number',\n description: 'Maximum results to return (default 5, max 20).',\n },\n },\n required: ['query'],\n },\n async execute(input) {\n if (!input?.query) {\n throw new ToolValidationError({\n message: 'search_memory: query is required',\n field: 'query',\n });\n }\n const scope = input.scope ?? 'project-memory';\n const limit = Math.min(input.limit ?? 5, 20);\n const entries = await memory.search(input.query, scope, limit);\n return {\n results: entries.map((e: MemoryEntry) => ({\n text: e.text,\n ts: e.ts,\n scope: e.scope,\n type: e.type,\n tags: e.tags,\n priority: e.priority,\n })),\n };\n },\n };\n}\n\ninterface RelatedMemoryInput {\n text: string;\n scope?: MemoryScope | undefined;\n limit?: number | undefined;\n}\n\nexport function relatedMemoryTool(memory: MemoryStore): Tool<RelatedMemoryInput, SearchMemoryOutput> {\n return {\n name: 'find_related_memories',\n category: 'Session',\n description:\n 'Find memories related to the given text via graph traversal. Only available with graph backends; falls back to content search with file backends.',\n usageHint:\n 'Discover memories connected to a topic through co-occurrence or similarity edges.\\n' +\n '- Useful for exploring what else the project knows about a given concept.\\n' +\n '- Falls back to content search when no graph backend is configured.\\n' +\n '- `limit` caps results (default 5, max 20).',\n permission: 'auto',\n mutating: false,\n timeoutMs: 2_000,\n capabilities: ['memory.read'],\n inputSchema: {\n type: 'object',\n properties: {\n text: {\n type: 'string',\n description: 'Text to find related memories for.',\n },\n scope: {\n type: 'string',\n enum: ['project-agents', 'project-memory', 'user-memory'],\n description: 'Which scope to search. Defaults to project-memory.',\n },\n limit: {\n type: 'number',\n description: 'Maximum results to return (default 5, max 20).',\n },\n },\n required: ['text'],\n },\n async execute(input) {\n if (!input?.text) {\n throw new ToolValidationError({\n message: 'find_related_memories: text is required',\n field: 'text',\n });\n }\n const scope = input.scope ?? 'project-memory';\n const limit = Math.min(input.limit ?? 5, 20);\n const entries = memory.findRelated\n ? await memory.findRelated(input.text, scope, limit)\n : await memory.search(input.text, scope, limit);\n return {\n results: entries.map((e: MemoryEntry) => ({\n text: e.text,\n ts: e.ts,\n scope: e.scope,\n type: e.type,\n tags: e.tags,\n priority: e.priority,\n })),\n };\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";AACA,SAAS,2BAA6C;AA4B/C,SAAS,aAAa,QAA0D;AACrF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aACE;AAAA,IACF,WACE;AAAA,IAaF,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc,CAAC,cAAc;AAAA,IAC7B,MAAM;AAAA,IACN,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,OAAO;AAAA,UACL,MAAM;AAAA,UACN,MAAM,CAAC,kBAAkB,kBAAkB,aAAa;AAAA,UACxD,aAAa;AAAA,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7
|
-
}
|
package/dist/mode.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9D,UAAU,SAAS;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE1D,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,CAAC,EAAE;QACN,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;IACJ,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AASD,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAiGhF"}
|
package/dist/mode.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/mode.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModeStore, Tool } from '@wrongstack/core/types';\n\ninterface ModeInput {\n action: 'get' | 'list' | 'set' | 'clear';\n mode?: string | undefined;\n}\n\ntype ModeFamily = 'lite' | 'deep' | 'balanced' | 'custom';\n\ninterface ModeOutput {\n action: string;\n currentMode?: string | undefined;\n modes?: {\n id: string | undefined;\n name: string;\n description: string;\n family: ModeFamily;\n tags: string[];\n }[];\n success: boolean;\n message: string;\n}\n\nfunction modeFamily(mode: { id?: string | undefined; tags?: string[] | undefined }): ModeFamily {\n if (mode.tags?.includes('lite')) return 'lite';\n if (mode.tags?.includes('deep')) return 'deep';\n if (mode.tags?.includes('balanced') || mode.id === 'default') return 'balanced';\n return 'custom';\n}\n\nexport function createModeTool(modeStore: ModeStore): Tool<ModeInput, ModeOutput> {\n return {\n name: 'mode',\n category: 'Session',\n description:\n 'Manage agent operating modes. Modes change the agent\\'s behavior, personality, and system prompt for different workflows (e.g. coding, security review, planning).',\n usageHint:\n 'POWERFUL BEHAVIOR CONTROL TOOL:\\n\\n' +\n '- Use `list` to see available modes.\\n' +\n '- Use `set <modeId>` to switch the agent into a specific role/mode.\\n' +\n '- Use `get` to check current mode.\\n' +\n '- Use `clear` to return to default behavior.\\n' +\n 'Switching modes is very effective for specialized tasks. The mode change affects how the agent reasons and which guidelines it follows.',\n permission: 'confirm',\n mutating: true,\n timeoutMs: 5_000,\n capabilities: ['session.mode'],\n icon: 'settings',\n inputSchema: {\n type: 'object',\n properties: {\n action: {\n type: 'string',\n enum: ['get', 'list', 'set', 'clear'],\n description: 'The mode operation to perform.',\n },\n mode: {\n type: 'string',\n description: 'The mode identifier to activate (only required when action=set).',\n },\n },\n required: ['action'],\n },\n async execute(input) {\n switch (input.action) {\n case 'get': {\n const mode = await modeStore.getActiveMode();\n return {\n action: 'get',\n currentMode: mode?.id,\n success: true,\n message: mode\n ? `Current mode: ${mode.name} \u2014 ${mode.description}`\n : 'No mode set (using default)',\n };\n }\n case 'list': {\n const modes = await modeStore.listModes();\n const lines = modes\n .map((m) => ` ${m.id.padEnd(20)} [${modeFamily(m)}] ${m.name} \u2014 ${m.description}`)\n .join('\\n');\n return {\n action: 'list',\n modes: modes.map((m) => ({\n id: m.id,\n name: m.name,\n description: m.description,\n family: modeFamily(m),\n tags: m.tags ?? [],\n })),\n success: true,\n message: lines,\n };\n }\n case 'set': {\n if (!input.mode) {\n return { action: 'set', success: false, message: 'mode is required for action=set' };\n }\n const mode = await modeStore.getMode(input.mode);\n if (!mode) {\n return { action: 'set', success: false, message: `Mode \"${input.mode}\" not found` };\n }\n await modeStore.setActiveMode(input.mode);\n return {\n action: 'set',\n currentMode: mode.id,\n success: true,\n message: `Switched to mode: ${mode.name}\\n\\n${mode.description}`,\n };\n }\n case 'clear': {\n await modeStore.setActiveMode(null);\n return {\n action: 'clear',\n success: true,\n message: 'Mode cleared \u2014 using default mode',\n };\n }\n default:\n return {\n action: input.action,\n success: false,\n message: `Unknown action \"${input.action}\"`,\n };\n }\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";AAuBA,SAAS,WAAW,MAA4E;AAC9F,MAAI,KAAK,MAAM,SAAS,MAAM,EAAG,QAAO;AACxC,MAAI,KAAK,MAAM,SAAS,MAAM,EAAG,QAAO;AACxC,MAAI,KAAK,MAAM,SAAS,UAAU,KAAK,KAAK,OAAO,UAAW,QAAO;AACrE,SAAO;AACT;AAEO,SAAS,eAAe,WAAmD;AAChF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aACE;AAAA,IACF,WACE;AAAA,IAMF,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc,CAAC,cAAc;AAAA,IAC7B,MAAM;AAAA,IACN,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO;AAAA,UACpC,aAAa;AAAA,QACf;AAAA,QACA,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,UAAU,CAAC,QAAQ;AAAA,IACrB;AAAA,IACA,MAAM,QAAQ,OAAO;AACnB,cAAQ,MAAM,QAAQ;AAAA,QACpB,KAAK,OAAO;AACV,gBAAM,OAAO,MAAM,UAAU,cAAc;AAC3C,i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YACR,SAAS;AAAA,YACT,SAAS;AAAA,UACX;AAAA,QACF;AAAA,QACA;AACE,iBAAO;AAAA,YACL,QAAQ,MAAM;AAAA,YACd,SAAS;AAAA,YACT,SAAS,mBAAmB,MAAM,MAAM;AAAA,UAC1C;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/next-steps.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"next-steps.d.ts","sourceRoot":"","sources":["../src/next-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,oEAAoE;IACpE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAID;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE7E;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,UAAQ,EACd,cAAc,UAAO,GACpB,oBAAoB,CAKtB;AAuKD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD"}
|
package/dist/next-steps.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/next-steps.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Canonical `<nextsteps>` block parser \u2014 the single source of truth shared by\n * the TUI history renderer, the CLI REPL suggestion store, the CLI /suggest\n * subagent output, and the WebUI MessageBubble/NextStepsBar.\n *\n * Three code paths feed into the parser:\n * 1. TUI rendering \u2014 entry.tsx parses only \"<nextsteps>\" from assistant output\n * 2. REPL store \u2014 repl.ts parses only \"<nextsteps>\" from final agent output\n * 3. /suggest output \u2014 suggest.ts parses LLM-generated numbered lists (raw mode)\n *\n * Heading mode (`requireHeading = true`, the default):\n * Assistant-output paths accept only balanced <nextsteps>...</nextsteps> blocks.\n * Loose headings like \"Next steps:\" are intentionally ignored so `/next` only\n * activates for the canonical machine-readable format.\n *\n * Raw mode (`requireHeading = false`):\n * Parses numbered/bullet items from anywhere in text (subagent /suggest output).\n *\n * Supported assistant-output format:\n * <nextsteps> (canonical XML tag format)\n *\n * The parser also tolerates attributes on the opening tag so malformed model\n * output such as `<nextsteps auto=\"true\">` does not leak into the UI. Opening\n * tag attributes are ignored; `auto=\"true\"` has meaning only on the first item.\n *\n * This module is BROWSER-SAFE \u2014 no Node-only imports \u2014 so it is safe to import\n * from Vite-bundled WebUI as well as Node-based CLI/TUI. Mirrors the proven\n * `tool-summary` / `tool-icons` extraction pattern (PRs #236 / #237 / #238).\n */\n\n// \u2500\u2500 Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface ParsedNextStep {\n index: number;\n text: string;\n /** Whether the first item has auto=\"true\" for YOLO+auto autonomy mode. */\n auto?: boolean;\n}\n\nexport interface ParseNextStepsResult {\n /** Matched steps with their original index and stripped text. */\n steps: ParsedNextStep[];\n /** Flat string array \u2014 what gets stored in the suggestion store. */\n texts: string[];\n /**\n * Content with the entire canonical \"<nextsteps>\" block removed.\n * Used by entry.tsx to strip suggestions from the rendered message body.\n */\n stripped: string;\n /** The first item's text when it has auto=\"true\"; otherwise empty. */\n autoTexts: string[];\n}\n\n// \u2500\u2500 Turn boundary \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Whether an LLM response's stop reason means the message is the FINAL one of\n * a turn.\n *\n * The agent loop calls the provider once per iteration, so a multi-step turn\n * emits several assistant messages. Only the last one \u2014 the response that\n * stopped without asking for another tool \u2014 is the model's actual answer;\n * everything before it is mid-turn prose the model wrote on its way to a tool\n * call. A `<nextsteps>` block in mid-turn text is noise: surfacing it would\n * offer the user suggestions while the work is still in flight, and would let\n * `/next` and auto-submit pick up a suggestion the model has already moved on\n * from.\n *\n * Every surface that renders suggestions gates on this so the three of them\n * cannot disagree about where a turn ends. Callers still strip the block from\n * the message body regardless \u2014 the raw XML must never reach the user.\n *\n * `tool_call` is the spelling some providers put on the WebUI wire (typed\n * loosely as `stopReason: string`); the canonical `StopReason` union uses\n * `tool_use`. An absent stop reason counts as final so legacy paths that never\n * carried one keep their suggestions.\n */\nexport function isFinalTurnStopReason(stopReason: string | undefined): boolean {\n return stopReason !== 'tool_use' && stopReason !== 'tool_call';\n}\n\n// \u2500\u2500 Patterns \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Matches the canonical <nextsteps> tag before numbered items.\n *\n * Attributes are accepted defensively because models occasionally attach the\n * item-only `auto=\"true\"` marker to this tag. They never affect parser state.\n */\nconst NEXT_STEPS_TAG_RE = /<nextsteps\\b[^>]*>\\s*\\n+/i;\n\n/** Matches an item line: \"1. text\", \"1) text\", \"- text\", \"* text\". */\n/** Also captures optional auto=\"true\" attribute at the end. */\nconst ITEM_RE = /^(?:(\\d+)[.)]\\s*|[-*\u2022]\\s*)(.+?)(\\s+auto=\"true\")?$/;\n\nconst MAX_STEPS = 6;\n\n// \u2500\u2500 Core parser \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Parse canonical \"<nextsteps>\" blocks from assistant output (or raw numbered lines).\n *\n * @param content \u2014 raw assistant message text or subagent output\n * @param strict \u2014 retained for compatibility; assistant-output paths always require the canonical XML tag.\n * @param requireHeading \u2014 when true, a canonical XML tag must precede the item list.\n * when false, numbered/bullet items are parsed from anywhere in text\n * (used by /suggest subagent output which has no heading).\n */\nexport function parseNextSteps(\n content: string,\n strict = false,\n requireHeading = true,\n): ParseNextStepsResult {\n if (requireHeading) {\n return parseWithHeading(content, strict);\n }\n return parseRawNumbered(content);\n}\n\n/** Push a step into the array, omitting `auto` when false (cleaner shape, matches WebUI parity). */\nfunction pushStep(\n steps: ParsedNextStep[],\n index: number,\n text: string,\n hasAuto: boolean,\n): void {\n steps.push(hasAuto ? { index, text, auto: true } : { index, text });\n}\n\n/** Parse numbered/bullet items from raw text without a heading. */\nfunction parseRawNumbered(content: string): ParseNextStepsResult {\n const lines = content.split('\\n');\n const steps: ParsedNextStep[] = [];\n const seenNumbers = new Set<number>();\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n if (!line) continue;\n\n const m = ITEM_RE.exec(line);\n if (!m) continue; // skip non-item lines in raw mode\n\n const numPart = m[1];\n const text = m[2]!.trim();\n let index: number;\n\n if (numPart !== undefined) {\n index = Number.parseInt(numPart, 10);\n } else {\n index = steps.length + 1; // bullet items get sequential indices\n }\n\n if (seenNumbers.has(index)) continue;\n seenNumbers.add(index);\n // Auto-submit is deliberately restricted to the first accepted item.\n // Later misplaced markers are stripped from display text but ignored.\n const hasAuto = !!m[3] && steps.length === 0 && index === 1;\n pushStep(steps, index, text, hasAuto);\n\n if (steps.length >= MAX_STEPS) break;\n }\n\n return {\n steps,\n texts: steps.map((s) => s.text),\n stripped: content,\n autoTexts: steps.filter((s) => s.auto).map((s) => s.text),\n };\n}\n\n/** Parse a heading + item block (the main assistant-message path). */\nfunction parseWithHeading(content: string, _strict: boolean): ParseNextStepsResult {\n const headingMatch = NEXT_STEPS_TAG_RE.exec(content);\n\n if (!headingMatch) {\n return { steps: [], texts: [], stripped: content, autoTexts: [] };\n }\n\n const headingEnd = headingMatch.index + headingMatch[0]!.length;\n const afterHeading = content.slice(headingEnd);\n const lines = afterHeading.split('\\n');\n const steps: ParsedNextStep[] = [];\n const seenNumbers = new Set<number>();\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n if (!line) continue;\n\n const m = ITEM_RE.exec(line);\n if (!m) break; // non-item line \u2014 block ends\n\n const numPart = m[1];\n const text = m[2]!.trim();\n let index: number;\n\n if (numPart !== undefined) {\n index = Number.parseInt(numPart, 10);\n } else {\n index = steps.length + 1;\n }\n\n if (seenNumbers.has(index)) continue;\n seenNumbers.add(index);\n // Only the first accepted item may opt into unattended auto-submit.\n const hasAuto = !!m[3] && steps.length === 0 && index === 1;\n pushStep(steps, index, text, hasAuto);\n\n if (steps.length >= MAX_STEPS) break;\n }\n\n if (steps.length === 0) {\n return { steps: [], texts: [], stripped: content, autoTexts: [] };\n }\n\n // Require a closing tag. Malformed XML is rejected so raw text remains\n // visible instead of being partially consumed as automation input.\n if (!afterHeading.includes('</nextsteps>')) {\n return { steps: [], texts: [], stripped: content, autoTexts: [] };\n }\n\n const texts = steps.map((s) => s.text);\n const autoTexts = steps.filter((s) => s.auto).map((s) => s.text);\n\n // Strip the entire XML block from the content. `blockEnd` is the LENGTH of\n // that block, so `content.slice(blockStart + blockEnd)` is the rest of the content.\n const blockStart = headingMatch.index;\n const blockEnd = headingMatch[0]!.length + findBlockEnd(afterHeading, steps.length);\n const stripped =\n (content.slice(0, blockStart) + content.slice(blockStart + blockEnd))\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n\n return { steps, texts, stripped, autoTexts };\n}\n\n/**\n * Find the byte offset in `afterHeading` where the block ends.\n *\n * The block to strip is the items (one per line) plus the `</nextsteps>`\n * closing tag (and the trailing newline after it).\n *\n * Returns the byte offset of the first character AFTER the block. The\n * caller's `content.slice(0, blockStart) + content.slice(blockStart + offset)`\n * then produces the stripped content.\n *\n * Walks line-by-line. Stops at the first non-item line, the closing XML\n * tag, or the end of the input \u2014 whichever comes first.\n */\nfunction findBlockEnd(afterHeading: string, stepCount: number): number {\n // Fast path: if the block is the <nextsteps> XML form, find the closing\n // tag and return its end (consuming the tag + trailing newline).\n const closeIdx = afterHeading.indexOf('</nextsteps>');\n if (closeIdx !== -1) {\n let end = closeIdx + '</nextsteps>'.length;\n if (afterHeading[end] === '\\n') end += 1;\n return end;\n }\n\n // Defensive fallback for malformed input that reached this helper without a\n // closing tag. The caller rejects such input before using the stripped text.\n const lines = afterHeading.split('\\n');\n let consumed = 0;\n let found = 0;\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n if (!line) break; // blank line ends the block\n\n const m = ITEM_RE.exec(line);\n if (!m) break; // non-item line ends the block\n\n consumed += rawLine.length + 1; // +1 for the \\n separator\n found++;\n if (found >= stepCount) {\n // Don't include the trailing newline of the last item \u2014 the slice\n // logic in the caller handles whitespace cleanup.\n consumed -= 1;\n break;\n }\n }\n\n return consumed;\n}\n\n/**\n * Strip <nextsteps>...</nextsteps> blocks from subagent output text.\n * Subagent results should not contain suggestion blocks \u2014 those belong to\n * the main assistant's output. This prevents raw XML tags from appearing\n * as literal text in the fleet panel.\n *\n * Also strips the legacy `<next_steps>` spelling that older persisted\n * subagent output may contain (WebUI parity).\n */\nexport function stripNextStepsBlock(text: string): string {\n return text\n .replace(/<next_?steps\\b[^>]*>[\\s\\S]*?<\\/next_?steps>/gi, '')\n .replace(/<next_?steps\\b[^>]*\\/?>/gi, '')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n}\n"],
|
|
5
|
-
"mappings": ";AA6EO,SAAS,sBAAsB,YAAyC;AAC7E,SAAO,eAAe,cAAc,eAAe;AACrD;AAUA,IAAM,oBAAoB;AAI1B,IAAM,UAAU;AAEhB,IAAM,YAAY;AAaX,SAAS,eACd,SACA,SAAS,OACT,iBAAiB,MACK;AACtB,MAAI,gBAAgB;AAClB,WAAO,iBAAiB,SAAS,MAAM;AAAA,EACzC;AACA,SAAO,iBAAiB,OAAO;AACjC;AAGA,SAAS,SACP,OACA,OACA,MACA,SACM;AACN,QAAM,KAAK,UAAU,EAAE,OAAO,MAAM,MAAM,KAAK,IAAI,EAAE,OAAO,KAAK,CAAC;AACpE;AAGA,SAAS,iBAAiB,SAAuC;AAC/D,QAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,QAAM,QAA0B,CAAC;AACjC,QAAM,cAAc,oBAAI,IAAY;AAEpC,aAAW,WAAW,OAAO;AAC3B,UAAM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,CAAC;IAClB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAwH5D,CAAC"}
|