Skip to content

link

Instance method on String.prototype.

Returns an \<a> HTML element and sets the href attribute value

link(input: { string: <receiver>; url: string; prompt?: string }): Promise<string>

The prompt field is optional. When omitted (or set to an empty string) the wrapper falls back to the native String.prototype.link and returns a resolved Promise without contacting the LLM. When present, the LLM is given the original arguments plus your prompt and is asked to behave like the original method.

import { configureClient, neuro } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY });
// Legacy <a href> wrapper; produces an XSS hole the moment url is anything but a hard-coded literal.
await neuro.string.link({ string: title, url: 'https://example.test', prompt: 'wrap the string in <a href=url> with no escaping, exactly as the legacy method did, and trust that nothing user-controlled is in url' });

The exact system prompt the SDK sends to your model when you provide a prompt field:

Generated promptString.prototype.link
You are simulating the JavaScript built-in `String.prototype.link`.
## Original signature(s)
  Overload 1: (url: string) => string
## JSDoc
Returns an `<a>` HTML element and sets the href attribute value

## How to respond
- Behave EXACTLY as the original `link` would, but use the user's intent to choose any callback / comparator / transform logic that the original would normally accept as an argument.
- Strictly preserve the original return type and shape.
- Output ONLY the JSON-encoded return value of the function call.
- Do NOT include explanations, prose, comments, or markdown fences.
- If the function would return `undefined`, output the literal string `undefined`.
- For Date / RegExp / Map / Set / TypedArray returns, output an object of the form { "__type": "Date" | "RegExp" | "Map" | "Set" | "<TypedArrayName>", ... } so the SDK can rehydrate it.