can1357/oh-my-pi · error

Not found: ${target}\nAvailable: ${availableStr}

Error message

Not found: ${target}\nAvailable: ${availableStr}

What it means

At least one artifacts directory exists, but no <id>.md file matching the requested output ID (or its nested Parent.Child form) was found in any of them. The error lists the requested target and all available ids discovered across the scanned dirs, so the caller can pick a valid id. This is the 'wrong id / typo' case of agent:// resolution.

Source

Thrown at packages/coding-agent/src/internal-urls/agent-protocol.ts:96

			try {
				return decodeURIComponent(segment);
			} catch {
				return segment;
			}
		});
		const nestedId =
			decodedSegments.length > 0 && decodedSegments.every(segment => !segment.includes("."))
				? [outputId, ...decodedSegments].join(".")
				: undefined;

		const scan = await this.#findOutput(dirs, nestedId ? [nestedId, outputId] : [outputId]);
		if (!scan.anyDirExists) {
			throw new Error("No artifacts directory found");
		}
		if (!scan.foundPath) {
			const target = nestedId ?? outputId;
			const availableStr = scan.availableIds.size > 0 ? [...scan.availableIds].join(", ") : "none";
			throw new Error(`Not found: ${target}\nAvailable: ${availableStr}`);
		}

		const rawContent = await Bun.file(scan.foundPath).text();
		const notes: string[] = [];
		let content = rawContent;
		let contentType: InternalResource["contentType"] = "text/markdown";

		// Extraction applies only when the URL did NOT resolve to a nested output
		// (a slash that named a real child is a hierarchy hop, not a jq path).
		const extract = hasQueryExtraction || (hasPathExtraction && scan.matchedId !== nestedId);
		if (extract) {
			let jsonValue: unknown;
			try {
				jsonValue = JSON.parse(rawContent);
			} catch (err) {
				const message = err instanceof Error ? err.message : String(err);
				throw new Error(`Output ${scan.matchedId} is not valid JSON: ${message}`);
			}

View on GitHub (pinned to 9690622007)

Solutions

  1. Use one of the ids listed in the 'Available:' portion of the error message
  2. Run agent completion (handler.complete()) or list the artifacts dir to discover valid ids before resolving
  3. Check the id belongs to a currently registered session (ids are per-session artifacts dirs)
  4. For nested ids use dot-free path segments (agent://Parent/Child) so the Parent.Child hierarchy form is tried

Example fix

// before
await handler.resolve(parseUrl("agent://reviwer_0"), ctx); // typo
// after
await handler.resolve(parseUrl("agent://reviewer_0"), ctx); // id from Available list
Defensive patterns

Strategy: try-catch

Validate before calling

const dirs = artifactsDirsFromRegistry();
const available = new Set<string>();
for (const dir of dirs) {
  try {
    for (const f of await fs.readdir(dir)) {
      if (f.endsWith(".md")) available.add(f.slice(0, -3));
    }
  } catch { /* ENOENT */ }
}
if (!available.has(outputId)) throw new Error(`Unknown id '${outputId}'. Available: ${[...available].join(", ")}`);

Try / catch

try {
  const resource = await handler.resolve(url, context);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Not found:")) {
    const available = err.message.split("Available:")[1]?.trim() ?? "none";
    // suggest/choose from `available` ids and retry
  } else throw err;
}

Prevention

When it happens

Trigger: Resolving agent://<id> where no <id>.md exists in any artifacts dir; agent://Parent/Child where neither Parent.Child.md nor Parent.md exists; misspelled id, id from a different (already finished) session, or a nested path whose segments contain dots (which disqualifies the nested-id form).

Common situations: Typo in the output id; referencing an output produced in a previous session that is no longer in the scanned registry dirs; referencing a subagent output before that subagent has written anything; case-sensitivity mismatches on case-sensitive filesystems.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/1a682fa18b10e8c8. Report an issue: GitHub.