@cerebro-labs/agentnava-sdk 0.26.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/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +230 -0
- package/agent.d.ts +285 -0
- package/agent.js +394 -0
- package/agent.js.map +1 -0
- package/attach.d.ts +49 -0
- package/attach.js +115 -0
- package/attach.js.map +1 -0
- package/connection-status.d.ts +28 -0
- package/connection-status.js +61 -0
- package/connection-status.js.map +1 -0
- package/connection.d.ts +89 -0
- package/connection.js +143 -0
- package/connection.js.map +1 -0
- package/conversation.d.ts +177 -0
- package/conversation.js +348 -0
- package/conversation.js.map +1 -0
- package/end-user.d.ts +159 -0
- package/end-user.js +209 -0
- package/end-user.js.map +1 -0
- package/errors.d.ts +43 -0
- package/errors.js +55 -0
- package/errors.js.map +1 -0
- package/http.d.ts +32 -0
- package/http.js +192 -0
- package/http.js.map +1 -0
- package/import-tools.d.ts +282 -0
- package/import-tools.js +686 -0
- package/import-tools.js.map +1 -0
- package/index.d.ts +16 -0
- package/index.js +38 -0
- package/index.js.map +1 -0
- package/knowledge-base.d.ts +165 -0
- package/knowledge-base.js +274 -0
- package/knowledge-base.js.map +1 -0
- package/load-agent-dir.d.ts +17 -0
- package/load-agent-dir.js +192 -0
- package/load-agent-dir.js.map +1 -0
- package/package.json +32 -0
- package/project.d.ts +94 -0
- package/project.js +155 -0
- package/project.js.map +1 -0
- package/secret.d.ts +45 -0
- package/secret.js +69 -0
- package/secret.js.map +1 -0
- package/templates-inline.d.ts +2 -0
- package/templates-inline.js +16 -0
- package/templates-inline.js.map +1 -0
- package/templates.d.ts +16 -0
- package/templates.js +32 -0
- package/templates.js.map +1 -0
- package/turn.d.ts +11 -0
- package/turn.js +244 -0
- package/turn.js.map +1 -0
- package/types.d.ts +485 -0
- package/types.js +4 -0
- package/types.js.map +1 -0
- package/version.d.ts +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/workflows.d.ts +36 -0
- package/workflows.js +101 -0
- package/workflows.js.map +1 -0
- package/workspace.d.ts +290 -0
- package/workspace.js +390 -0
- package/workspace.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-tools.js","sourceRoot":"","sources":["../src/import-tools.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAC5E,+EAA+E;AAC/E,0EAA0E;AAC1E,EAAE;AACF,wEAAwE;AACxE,0DAA0D;AAC1D,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,iFAAiF;AACjF,4EAA4E;AAC5E,EAAE;AACF,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,0EAA0E;AAC1E,+EAA+E;AAC/E,uEAAuE;AACvE,+EAA+E;AAC/E,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,uDAAuD;AACvD,EAAE;AACF,QAAQ;AACR,6DAA6D;AAC7D,EAAE;AACF,gEAAgE;AAChE,qDAAqD;AACrD,oFAAoF;AACpF,EAAE;AACF,oFAAoF;AACpF,MAAM;AA2DN,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B;;;;;4EAK4E;AAC5E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IAClC,eAAe;IACf,qBAAqB;IACrB,QAAQ;IACR,WAAW;IACX,SAAS;IACT,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,OAAO;IACP,iBAAiB;IACjB,eAAe;IACf,UAAU;CACV,CAAC,CAAC;AAEH;;;;8BAI8B;AAC9B,MAAM,mBAAmB,GACxB,iNAAiN,CAAC;AAEnN,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAAQ,GAAG,MAAM;IAC1D,MAAM,IAAI,GAA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M;QAAE,OAAO,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrE,IAAI,SAAS,IAAI,MAAM;QAAE,OAAO,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrE,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;YAC5B,GAAG,OAAO;YACV,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YACvD,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;SAC5E,CAAC,CAAC;IACJ,CAAC;IACD,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;QAC5B,OAAO,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE;YACxC,GAAG,OAAO;YACV,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YAChE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;SAC1D,CAAC,CAAC;IACJ,CAAC;IACD,0EAA0E;IAC1E,yBAAyB;IACzB,MAAM,IAAI,KAAK,CACd,8EAA8E,CAC9E,CAAC;AACH,CAAC","sourcesContent":["// Turn an API you already describe somewhere into tools an agent can call.\n//\n// WHAT THIS IS FOR. A company adopting AgentNava has APIs already, and their\n// team already keeps a Postman collection, an OpenAPI document, or a handful of\n// curl commands that work. Asking them to hand-write a tool declaration per\n// endpoint is asking for a week of somebody's time, and asking them to produce\n// an artifact they do not already have is worse: it is a reason to stall.\n//\n// So this takes whichever of those three they have and gives back draft\n// `httpTools`. Self-serve, in the SDK, no support ticket.\n//\n// IT RUNS ENTIRELY ON YOUR MACHINE. Nothing here makes a network request except\n// `fromOpenApi` when you hand it a URL instead of a document, and that fetch\n// goes to YOUR server, not ours. That is a deliberate security property rather\n// than an implementation convenience: a Postman export routinely contains a live\n// token, and a collection you never upload is a token we can never receive.\n//\n// WHAT IT DOES NOT DO, and this is the honest part:\n//\n// IT CANNOT WRITE THE DESCRIPTIONS. A tool's `description` is what the model\n// reads to decide \"this is the tool for this job\", and none of these three\n// formats contains that. Their summaries are written for a developer reading\n// documentation, not for a model choosing between forty tools. \"Fetch one\n// order by its number, before deciding a refund\" is what works; \"Orders\n// endpoint\" is not. Where the source has nothing useful, the tool comes back\n// with a warning rather than a confident-looking stub, because a bad\n// description does not fail: it quietly makes the agent pick the wrong tool.\n//\n// IT DOES NOT CREATE ANYTHING. It returns drafts. You read them, fix the\n// descriptions, drop the endpoints an agent has no business calling, and pass\n// what is left to `ws.agents.create({ httpTools })`.\n//\n// ```ts\n// import { fromPostman } from '@cerebro-labs/agentnava-sdk';\n//\n// const { tools, secrets, warnings } = fromPostman(collection);\n// for (const w of warnings) console.warn(w.message);\n// for (const s of secrets) await ws.secrets.create({ name: s.name, value: '...' });\n//\n// await ws.agents.create({ id: 'support', instructions: '...', httpTools: tools });\n// ```\n\nimport type { HttpTool, HttpToolParam } from './types.ts';\n\n/** Something a human has to look at before these tools are good. */\nexport type ImportWarningKind =\n\t/** The source had no description worth showing a model. */\n\t| 'description-missing'\n\t/** A credential was found and replaced with a secret placeholder. */\n\t| 'credential-stripped'\n\t/** The request body is a shape we cannot express (file upload, form-data). */\n\t| 'unsupported-body'\n\t/** More tools than a model chooses well between. */\n\t| 'too-many-tools'\n\t/** A `{{variable}}` the source never defined. */\n\t| 'undefined-variable'\n\t/** Two endpoints produced the same tool name. */\n\t| 'name-collision'\n\t/** A parameter was renamed to something the API will accept. */\n\t| 'param-renamed';\n\nexport interface ImportWarning {\n\tkind: ImportWarningKind;\n\t/** The tool it concerns, when it concerns one. */\n\ttool?: string;\n\tmessage: string;\n}\n\nexport interface ImportedSecret {\n\t/** Create this with `ws.secrets.create({ name, value })`. */\n\tname: string;\n\t/** The tools that reference it. */\n\tusedBy: string[];\n\t/** Where in the source it came from, so you can find the real value. */\n\tfrom: string;\n}\n\nexport interface ImportedTools {\n\t/** Drafts. Read them before you ship them. */\n\ttools: HttpTool[];\n\t/** Secrets these tools need. None of them carries a value: see the note on\n\t * credentials in this module's header. */\n\tsecrets: ImportedSecret[];\n\t/** Everything a human should decide. Never silently resolved. */\n\twarnings: ImportWarning[];\n}\n\nexport interface ImportOptions {\n\t/** Name for the credential these requests authenticate with. Defaults are\n\t * derived from the header (`Authorization` becomes `API_TOKEN`), which is\n\t * fine for one API and confusing once you have three. */\n\tsecretName?: string;\n\t/** Keep only the operations you want. Returning everything is rarely right:\n\t * a model picks markedly worse between forty tools than between eight. */\n\tinclude?: (candidate: { name: string; method: string; url: string }) => boolean;\n\t/** Above this many tools, a `too-many-tools` warning is added. */\n\twarnAbove?: number;\n}\n\nconst DEFAULT_WARN_ABOVE = 15;\n\n/** Header names whose value is a credential whatever it looks like.\n *\n * MATCHED ON THE NAME, NOT THE VALUE, and that is the safe direction. A value\n * test has to guess, and the cost of guessing wrong is a live token written\n * into an agent version, which is readable. A name test over-collects at worst:\n * it turns something harmless into a secret, which is an inconvenience. */\nconst CREDENTIAL_HEADERS = new Set([\n\t'authorization',\n\t'proxy-authorization',\n\t'cookie',\n\t'x-api-key',\n\t'api-key',\n\t'apikey',\n\t'x-auth-token',\n\t'auth-token',\n\t'x-access-token',\n\t'access-token',\n\t'token',\n\t'x-session-token',\n\t'private-token',\n\t'x-secret',\n]);\n\n/** Shapes that are a credential wherever they appear, including in a URL.\n *\n * Deliberately narrow: each is a published prefix from a real provider, so a\n * match is near-certain rather than a heuristic. The header rule above is what\n * does the heavy lifting. */\nconst CREDENTIAL_VALUE_RE =\n\t/\\b(sk-[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|AIza[A-Za-z0-9_-]{30,}|AKIA[A-Z0-9]{16}|eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.)/;\n\n/** A tool name the API will accept: `^[a-z][a-z0-9_]{0,63}$`. */\nexport function toolNameFrom(raw: string, fallback = 'call'): string {\n\tconst slug = raw\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '_')\n\t\t.replace(/^_+|_+$/g, '')\n\t\t.slice(0, 64);\n\tif (slug === '' || !/^[a-z]/.test(slug)) {\n\t\tconst prefixed = `${fallback}_${slug}`.replace(/_+$/, '').slice(0, 64);\n\t\treturn /^[a-z][a-z0-9_]*$/.test(prefixed) ? prefixed : fallback;\n\t}\n\treturn slug;\n}\n\n/** A param name the API will accept: `^[A-Za-z][A-Za-z0-9_]*$`.\n *\n * THE WIRE NAME IS NOT THE PARAM NAME, and conflating them is what broke this.\n * An API's query key is whatever the API says it is (`page-size`,\n * `filter[status]`), while a param name is an identifier both our validator and\n * the runtime's placeholder regex constrain to `[A-Za-z][A-Za-z0-9_]*`. Copying\n * the wire name into the param name produced `400 params has invalid key\n * \"page-size\"` on documents that are completely ordinary, which is exactly the\n * unactionable 400 `uniqueName` exists to avoid. So the key on the wire keeps\n * its spelling and only the identifier is normalised. */\nexport function paramNameFrom(raw: string, fallback = 'arg'): string {\n\tconst slug = raw\n\t\t.trim()\n\t\t.replace(/[^A-Za-z0-9]+/g, '_')\n\t\t.replace(/^_+|_+$/g, '')\n\t\t.slice(0, 64);\n\tif (slug === '' || !/^[A-Za-z]/.test(slug)) {\n\t\tconst prefixed = `${fallback}_${slug}`.replace(/_+$/, '').slice(0, 64);\n\t\treturn /^[A-Za-z][A-Za-z0-9_]*$/.test(prefixed) ? prefixed : fallback;\n\t}\n\treturn slug;\n}\n\n/** A secret name the runtime's placeholder regex will match.\n *\n * `[A-Za-z_][A-Za-z0-9_]*`, so a leading digit is the case that matters. A\n * Postman collection with a `{{2fa_token}}` variable produced\n * `{{secrets.2FA_TOKEN}}`, which that regex does not match at all, so nothing\n * substituted it and the LITERAL braces went out as the header value. No error,\n * just a 401 from the far end. A name that cannot resolve is worse than an ugly\n * one. */\nfunction normalizeSecretName(raw: string, fallback = 'API_TOKEN'): string {\n\tconst slug = raw\n\t\t.replace(/[^A-Za-z0-9]+/g, '_')\n\t\t.replace(/^_+|_+$/g, '')\n\t\t.toUpperCase()\n\t\t.slice(0, 64);\n\tif (slug === '') return fallback;\n\treturn /^[A-Za-z_]/.test(slug) ? slug : `S_${slug}`.slice(0, 64);\n}\n\n/** A secret name from a header, or the caller's own choice. */\nfunction secretNameFor(header: string, options: ImportOptions): string {\n\tif (options.secretName) return options.secretName;\n\tconst h = header.toLowerCase();\n\tif (h === 'authorization') return 'API_TOKEN';\n\tif (h === 'x-api-key' || h === 'api-key' || h === 'apikey') return 'API_KEY';\n\treturn normalizeSecretName(header);\n}\n\n/** Accumulates tools, secrets and warnings, and keeps names unique.\n *\n * UNIQUE BECAUSE THE API NOW REFUSES DUPLICATES. Two endpoints called \"Get\" in\n * different folders both slug to `get`, and a duplicate name makes which\n * request goes out a matter of list order: the agent looks like it called the\n * right tool and returns the wrong answer. Renaming here, with a warning, beats\n * a 400 the importer's caller cannot act on. */\nclass Draft {\n\treadonly tools: HttpTool[] = [];\n\treadonly warnings: ImportWarning[] = [];\n\treadonly #secrets = new Map<string, ImportedSecret>();\n\treadonly #names = new Set<string>();\n\t/** `<tool>\\0<wire name>` to the param name chosen for it. */\n\treadonly #paramNames = new Map<string, string>();\n\n\tuniqueName(wanted: string): string {\n\t\tif (!this.#names.has(wanted)) {\n\t\t\tthis.#names.add(wanted);\n\t\t\treturn wanted;\n\t\t}\n\t\tfor (let i = 2; i < 1000; i++) {\n\t\t\tconst candidate = `${wanted}_${i}`.slice(0, 64);\n\t\t\tif (!this.#names.has(candidate)) {\n\t\t\t\tthis.#names.add(candidate);\n\t\t\t\tthis.warnings.push({\n\t\t\t\t\tkind: 'name-collision',\n\t\t\t\t\ttool: candidate,\n\t\t\t\t\tmessage: `Two operations both became \"${wanted}\"; this one is \"${candidate}\". Give it a name that says what it does.`,\n\t\t\t\t});\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`cannot find a free name for ${wanted}`);\n\t}\n\n\t/** Records the secret. Returns true the FIRST time this name is seen, so the\n\t * caller can warn once rather than once per tool that uses it. */\n\tsecret(name: string, tool: string, from: string): boolean {\n\t\tconst existing = this.#secrets.get(name);\n\t\tif (existing) {\n\t\t\tif (!existing.usedBy.includes(tool)) existing.usedBy.push(tool);\n\t\t\treturn false;\n\t\t}\n\t\tthis.#secrets.set(name, { name, usedBy: [tool], from });\n\t\treturn true;\n\t}\n\n\t/** Every secret this tool references, for the tool's own `secrets` field.\n\t *\n\t * LOAD-BEARING, NOT DECORATION. `collectSecretNames` in the control plane\n\t * builds a turn's secret map from each httpTool's `secrets` array; unlike\n\t * MCP servers it does NOT scan the tool's headers for {{secrets.X}}. A tool\n\t * that carries the placeholder but not the declaration therefore fails every\n\t * call with \"missing required secret\", which is what every drafted tool did\n\t * until this existed. */\n\tsecretsFor(tool: string): string[] {\n\t\treturn [...this.#secrets.values()].filter((s) => s.usedBy.includes(tool)).map((s) => s.name);\n\t}\n\n\t/** Declare a param under a name the API accepts, warning when it had to\n\t * change, and return the name to use in the placeholder.\n\t *\n\t * ONE WIRE NAME IS ONE PARAM, however many times it is mentioned. An\n\t * OpenAPI operation names a path variable twice: once in the path template\n\t * `/orders/{order-id}` and once in `parameters`. Treating the second sight\n\t * of it as a collision produced `order_id` in the url and a second,\n\t * never-sent `order_id_2` in `params`, which is the very \"declared and never\n\t * sent\" defect this class is meant to prevent. So a repeat returns the same\n\t * name and merges the richer definition over the first guess. */\n\tparam(\n\t\tparams: Record<string, HttpToolParam>,\n\t\twireName: string,\n\t\tdef: HttpToolParam,\n\t\ttool: string,\n\t): string {\n\t\tconst key = `${tool}\\u0000${wireName}`;\n\t\tconst already = this.#paramNames.get(key);\n\t\tif (already !== undefined) {\n\t\t\tparams[already] = { ...params[already], ...def };\n\t\t\treturn already;\n\t\t}\n\t\tconst wanted = paramNameFrom(wireName);\n\t\tlet name = wanted;\n\t\tfor (let i = 2; i < 1000 && name in params; i++) name = `${wanted}_${i}`.slice(0, 64);\n\t\tthis.#paramNames.set(key, name);\n\t\tif (name !== wireName) {\n\t\t\tthis.warnings.push({\n\t\t\t\tkind: 'param-renamed',\n\t\t\t\ttool,\n\t\t\t\tmessage:\n\t\t\t\t\t`Parameter \"${wireName}\" is called \"${name}\" on the tool, because a param name has ` +\n\t\t\t\t\t`to be a plain identifier. The request still sends \"${wireName}\" on the wire.`,\n\t\t\t});\n\t\t}\n\t\tparams[name] = def;\n\t\treturn name;\n\t}\n\n\tfinish(options: ImportOptions): ImportedTools {\n\t\tconst limit = options.warnAbove ?? DEFAULT_WARN_ABOVE;\n\t\tif (this.tools.length > limit) {\n\t\t\tthis.warnings.push({\n\t\t\t\tkind: 'too-many-tools',\n\t\t\t\tmessage:\n\t\t\t\t\t`${this.tools.length} tools. A model chooses markedly worse between forty than ` +\n\t\t\t\t\t`between eight, so keep the operations an agent genuinely needs and drop the rest ` +\n\t\t\t\t\t`(pass \\`include\\` to filter during the import).`,\n\t\t\t});\n\t\t}\n\t\treturn { tools: this.tools, secrets: [...this.#secrets.values()], warnings: this.warnings };\n\t}\n}\n\n/** Headers with every credential replaced by a secret placeholder. */\nfunction safeHeaders(\n\traw: Record<string, string>,\n\ttoolName: string,\n\tdraft: Draft,\n\toptions: ImportOptions,\n\tsource: string,\n): Record<string, string> {\n\tconst out: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(raw)) {\n\t\tconst isCredentialHeader = CREDENTIAL_HEADERS.has(name.toLowerCase());\n\t\tconst looksLikeOne = CREDENTIAL_VALUE_RE.test(value);\n\t\tif (!isCredentialHeader && !looksLikeOne) {\n\t\t\tout[name] = value;\n\t\t\tcontinue;\n\t\t}\n\t\tconst secret = secretNameFor(name, options);\n\t\t// The SCHEME is preserved, the credential is not. `Bearer {{secrets.X}}`\n\t\t// works; `{{secrets.X}}` alone silently drops the scheme and the server\n\t\t// answers 401 about a malformed header.\n\t\tconst scheme = /^(Bearer|Basic|Token|ApiKey)\\s+/i.exec(value)?.[1];\n\t\tout[name] = scheme ? `${scheme} {{secrets.${secret}}}` : `{{secrets.${secret}}}`;\n\t\tconst firstTime = draft.secret(secret, toolName, `${source} header \"${name}\"`);\n\t\t// ONCE PER SECRET, not once per tool. One token shared by twelve\n\t\t// operations produced twelve identical warnings, and a list nobody can\n\t\t// skim is a list nobody reads. `secrets[].usedBy` already names every tool\n\t\t// that references it, so the detail is not lost.\n\t\tif (firstTime) {\n\t\t\tdraft.warnings.push({\n\t\t\t\tkind: 'credential-stripped',\n\t\t\t\tmessage:\n\t\t\t\t\t`Header \"${name}\" held a credential. It is now {{secrets.${secret}}} and the value was ` +\n\t\t\t\t\t`NOT kept. Create it with ws.secrets.create({ name: '${secret}', value: '…' }).`,\n\t\t\t});\n\t\t}\n\t}\n\treturn out;\n}\n\n/** A description the model can act on, or a warning that there is none. */\nfunction describe(\n\tcandidates: (string | undefined)[],\n\ttoolName: string,\n\tmethod: string,\n\tpath: string,\n\tdraft: Draft,\n): string {\n\tconst found = candidates.map((c) => c?.trim()).find((c) => c && c.length >= 12);\n\tif (found) return found;\n\t// The fallback is `METHOD /path`, and the path must be the RESOLVED one. Using\n\t// the raw source url put `DELETE {{baseUrl}}/admin/purge` in a description,\n\t// which shows a model a placeholder it cannot act on and reads like a bug.\n\t// Collapse doubled slashes left behind by a stripped placeholder, but NOT the\n\t// `//` in `https://`: a Postman collection that writes absolute urls rather\n\t// than {{baseUrl}} produced the description \"DELETE https:/api.acme.example/…\",\n\t// and that string is what the model reads to choose the tool.\n\tconst stripped = path.replace(/\\{\\{[^}]*\\}\\}/g, '');\n\tconst scheme = /^[a-z][a-z0-9+.-]*:\\/\\//i.exec(stripped)?.[0] ?? '';\n\tconst clean = `${scheme}${stripped.slice(scheme.length).replace(/\\/{2,}/g, '/')}` || path;\n\tdraft.warnings.push({\n\t\tkind: 'description-missing',\n\t\ttool: toolName,\n\t\tmessage:\n\t\t\t`\"${toolName}\" has no usable description. This is the field the model reads to decide ` +\n\t\t\t`whether to call it, so write one line saying when someone would use it. ` +\n\t\t\t`A bad description does not error, it makes the agent pick the wrong tool.`,\n\t});\n\treturn `${method} ${clean}`;\n}\n\n// ---------------------------------------------------------------- postman\n\ninterface PostmanItem {\n\tname?: string;\n\trequest?: PostmanRequest | string;\n\titem?: PostmanItem[];\n\tdescription?: string;\n}\n\ninterface PostmanRequest {\n\tmethod?: string;\n\turl?: string | { raw?: string; host?: string[]; path?: string[]; query?: { key?: string; value?: string; description?: string; disabled?: boolean }[] };\n\theader?: { key?: string; value?: string; disabled?: boolean }[];\n\tbody?: { mode?: string; raw?: string };\n\tdescription?: string;\n\tauth?: { type?: string; [k: string]: unknown };\n}\n\nexport interface PostmanCollection {\n\tinfo?: { name?: string; description?: string };\n\titem?: PostmanItem[];\n\tvariable?: { key?: string; value?: string }[];\n\tauth?: { type?: string; [k: string]: unknown };\n}\n\n/**\n * Draft tools from a Postman collection export (v2.0 or v2.1).\n *\n * WHY POSTMAN AND NOT ONLY OPENAPI. OpenAPI is tidier; a collection is truer. It\n * holds the requests somebody has actually run, with the header names that\n * really work and real values in the body, which is what a tool has to\n * reproduce. Teams also already have one, and the best format to ask for is the\n * one nobody has to make.\n *\n * WHAT IT COSTS: a collection has no parameter TYPES, so every parameter comes\n * back a string. That is usually right and always safe; `fromOpenApi` gives real\n * types where a document exists.\n *\n * VARIABLES. Postman writes `{{baseUrl}}`, which is the same shape as our own\n * placeholders, so they map across almost directly. A variable the collection\n * DEFINES is substituted, unless it holds something that looks like a\n * credential, in which case it becomes a secret instead of being inlined. An\n * undefined variable becomes a secret too, with a warning, because the\n * alternative is a URL with a placeholder nothing resolves.\n */\nexport function fromPostman(\n\tcollection: PostmanCollection,\n\toptions: ImportOptions = {},\n): ImportedTools {\n\tconst draft = new Draft();\n\tconst vars = new Map<string, string>();\n\tfor (const v of collection.variable ?? []) {\n\t\tif (v.key) vars.set(v.key, v.value ?? '');\n\t}\n\n\t/** Substitute defined variables; anything else becomes a secret. */\n\tconst resolveVars = (text: string, toolName: string): string =>\n\t\ttext.replace(/\\{\\{([^}]+)\\}\\}/g, (_m, rawKey: string) => {\n\t\t\tconst keyName = rawKey.trim();\n\t\t\tconst value = vars.get(keyName);\n\t\t\t// A DEFINED VARIABLE HOLDING A CREDENTIAL IS STILL A CREDENTIAL. Inlining\n\t\t\t// it because the collection happened to define it is how a live token\n\t\t\t// ends up in an agent version, which is readable.\n\t\t\tif (value !== undefined && value !== '' && !CREDENTIAL_VALUE_RE.test(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tconst secret = normalizeSecretName(keyName);\n\t\t\tdraft.secret(secret, toolName, `collection variable \"${keyName}\"`);\n\t\t\tif (value === undefined) {\n\t\t\t\tdraft.warnings.push({\n\t\t\t\t\tkind: 'undefined-variable',\n\t\t\t\t\ttool: toolName,\n\t\t\t\t\tmessage: `{{${keyName}}} is not defined in the collection, so it became {{secrets.${secret}}}.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn `{{secrets.${secret}}}`;\n\t\t});\n\n\tconst walk = (items: PostmanItem[], trail: string[]): void => {\n\t\tfor (const item of items) {\n\t\t\tif (item.item) {\n\t\t\t\twalk(item.item, [...trail, item.name ?? '']);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst request = item.request;\n\t\t\tif (!request || typeof request === 'string') continue;\n\n\t\t\tconst rawUrl =\n\t\t\t\ttypeof request.url === 'string'\n\t\t\t\t\t? request.url\n\t\t\t\t\t: (request.url?.raw ??\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t(request.url?.host ?? []).join('.'),\n\t\t\t\t\t\t\t(request.url?.path ?? []).join('/'),\n\t\t\t\t\t\t]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join('/'));\n\t\t\tif (!rawUrl) continue;\n\n\t\t\tconst method = (request.method ?? 'GET').toUpperCase();\n\t\t\tconst candidateName = toolNameFrom(item.name ?? `${method} ${rawUrl}`);\n\t\t\tif (options.include && !options.include({ name: candidateName, method, url: rawUrl })) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst name = draft.uniqueName(candidateName);\n\n\t\t\t// Postman path variables are `:id`; ours are `{{params.id}}`.\n\t\t\tconst params: Record<string, HttpToolParam> = {};\n\t\t\tlet url = resolveVars(rawUrl, name).replace(\n\t\t\t\t/:([A-Za-z_][A-Za-z0-9_]*)/g,\n\t\t\t\t(_m, p: string) =>\n\t\t\t\t\t`{{params.${draft.param(params, p, { type: 'string', required: true }, name)}}}`,\n\t\t\t);\n\t\t\t// `?a=1&b=2` in the raw URL is kept as written; the structured `query`\n\t\t\t// array is what a caller edits in Postman, so it wins where present.\n\t\t\tconst query = typeof request.url === 'string' ? [] : (request.url?.query ?? []);\n\t\t\tconst enabled = query.filter((q) => q.key && !q.disabled);\n\t\t\tif (enabled.length > 0) {\n\t\t\t\turl = url.split('?')[0] as string;\n\t\t\t\tconst pairs = enabled.map((q) => {\n\t\t\t\t\tconst key = q.key as string;\n\t\t\t\t\tconst param = draft.param(\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{ type: 'string', ...(q.description ? { description: q.description } : {}) },\n\t\t\t\t\t\tname,\n\t\t\t\t\t);\n\t\t\t\t\treturn `${encodeURIComponent(key)}={{paramsEncoded.${param}}}`;\n\t\t\t\t});\n\t\t\t\turl = `${url}?${pairs.join('&')}`;\n\t\t\t}\n\n\t\t\tconst headerPairs: Record<string, string> = {};\n\t\t\tfor (const h of request.header ?? []) {\n\t\t\t\tif (h.key && !h.disabled) headerPairs[h.key] = resolveVars(h.value ?? '', name);\n\t\t\t}\n\t\t\t// Collection-level auth applies to a request that declares none.\n\t\t\tconst auth = request.auth ?? collection.auth;\n\t\t\tif (auth?.type && !Object.keys(headerPairs).some((k) => CREDENTIAL_HEADERS.has(k.toLowerCase()))) {\n\t\t\t\tconst secret = secretNameFor('authorization', options);\n\t\t\t\theaderPairs.Authorization =\n\t\t\t\t\tauth.type === 'basic' ? `Basic {{secrets.${secret}}}` : `Bearer {{secrets.${secret}}}`;\n\t\t\t\tdraft.secret(secret, name, `collection auth (${auth.type})`);\n\t\t\t}\n\t\t\tconst headers = safeHeaders(headerPairs, name, draft, options, 'Postman');\n\n\t\t\tlet body: string | undefined;\n\t\t\tconst mode = request.body?.mode;\n\t\t\tif (mode === 'raw' && request.body?.raw) {\n\t\t\t\tbody = resolveVars(request.body.raw, name);\n\t\t\t} else if (mode && mode !== 'raw' && mode !== 'none') {\n\t\t\t\tdraft.warnings.push({\n\t\t\t\t\tkind: 'unsupported-body',\n\t\t\t\t\ttool: name,\n\t\t\t\t\tmessage: `Body mode \"${mode}\" is not supported; the tool was created without a body.`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tdraft.tools.push({\n\t\t\t\tname,\n\t\t\t\tdescription: describe(\n\t\t\t\t\t[item.description, request.description, trail.filter(Boolean).join(' / ')],\n\t\t\t\t\tname,\n\t\t\t\t\tmethod,\n\t\t\t\t\trawUrl,\n\t\t\t\t\tdraft,\n\t\t\t\t),\n\t\t\t\tmethod: (['GET', 'POST', 'PUT', 'DELETE', 'PATCH'].includes(method)\n\t\t\t\t\t? method\n\t\t\t\t\t: 'GET') as HttpTool['method'],\n\t\t\t\turl,\n\t\t\t\t...(Object.keys(headers).length > 0 && { headers }),\n\t\t\t\t...(Object.keys(params).length > 0 && { params }),\n\t\t\t\t// DECLARED, because the placeholder alone does not reach the runtime.\n\t\t\t\t...(draft.secretsFor(name).length > 0 && { secrets: draft.secretsFor(name) }),\n\t\t\t\t// GET carries no body: the API refuses one at authoring time.\n\t\t\t\t...(body !== undefined && method !== 'GET' && { body }),\n\t\t\t});\n\t\t}\n\t};\n\n\twalk(collection.item ?? [], []);\n\treturn draft.finish(options);\n}\n\n// ---------------------------------------------------------------- openapi\n\ninterface OpenApiParam {\n\tname?: string;\n\tin?: string;\n\trequired?: boolean;\n\tdescription?: string;\n\tschema?: { type?: string; enum?: (string | number)[] };\n}\n\ninterface OpenApiOperation {\n\toperationId?: string;\n\tsummary?: string;\n\tdescription?: string;\n\tparameters?: OpenApiParam[];\n\trequestBody?: { content?: Record<string, unknown> };\n\tsecurity?: unknown[];\n}\n\nexport interface OpenApiDocument {\n\topenapi?: string;\n\tswagger?: string;\n\tinfo?: { title?: string };\n\tservers?: { url?: string }[];\n\thost?: string;\n\tbasePath?: string;\n\tschemes?: string[];\n\tpaths?: Record<string, Record<string, OpenApiOperation>>;\n\tcomponents?: { securitySchemes?: Record<string, { type?: string; scheme?: string; name?: string; in?: string }> };\n\tsecurityDefinitions?: Record<string, { type?: string; name?: string; in?: string }>;\n\tsecurity?: unknown[];\n}\n\nconst OPENAPI_METHODS = ['get', 'post', 'put', 'delete', 'patch'] as const;\n\nfunction openApiType(t: string | undefined): HttpToolParam['type'] {\n\tif (t === 'integer' || t === 'number') return 'number';\n\tif (t === 'boolean') return 'boolean';\n\treturn 'string';\n}\n\n/**\n * Draft tools from an OpenAPI 3 or Swagger 2 document.\n *\n * WHAT THIS GIVES THAT POSTMAN DOES NOT: real parameter types and required\n * flags, which is exactly the shape `HttpToolParam` wants, and an enum where the\n * document declares one. FastAPI publishes this at `/openapi.json` without\n * anybody writing it, so for a FastAPI shop this is usually the richer source.\n *\n * WHAT IT STILL DOES NOT GIVE: a description a model can choose on. `summary`\n * is written for a developer reading a reference. Read the warnings.\n */\nexport function fromOpenApi(doc: OpenApiDocument, options: ImportOptions = {}): ImportedTools {\n\tconst draft = new Draft();\n\n\t// OpenAPI 3 `servers`, or Swagger 2's three separate fields.\n\tconst base =\n\t\tdoc.servers?.[0]?.url ??\n\t\t(doc.host ? `${doc.schemes?.[0] ?? 'https'}://${doc.host}${doc.basePath ?? ''}` : '');\n\tif (!base) {\n\t\tdraft.warnings.push({\n\t\t\tkind: 'undefined-variable',\n\t\t\tmessage:\n\t\t\t\t'The document names no server, so every url is a path with no host. Set one, or edit ' +\n\t\t\t\t'the urls before creating the agent: the API refuses a url that is not absolute.',\n\t\t});\n\t}\n\n\tconst schemes = doc.components?.securitySchemes ?? doc.securityDefinitions ?? {};\n\tconst firstScheme = Object.values(schemes)[0] as\n\t\t| { type?: string; scheme?: string; name?: string; in?: string }\n\t\t| undefined;\n\n\tfor (const [path, operations] of Object.entries(doc.paths ?? {})) {\n\t\tfor (const method of OPENAPI_METHODS) {\n\t\t\tconst op = operations[method];\n\t\t\tif (!op) continue;\n\n\t\t\tconst candidateName = toolNameFrom(op.operationId ?? `${method}_${path}`, 'op');\n\t\t\tconst fullUrl = `${base}${path}`;\n\t\t\tif (options.include && !options.include({ name: candidateName, method: method.toUpperCase(), url: fullUrl })) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst name = draft.uniqueName(candidateName);\n\n\t\t\tconst params: Record<string, HttpToolParam> = {};\n\t\t\tconst headerPairs: Record<string, string> = {};\n\t\t\t// A path template's `{order-id}` is a wire name like any other, so it\n\t\t\t// gets the same normalisation as a query key. Declared or not: a brace\n\t\t\t// in the path has to resolve, and an operation that never declared the\n\t\t\t// parameter would otherwise leave `{{params.order-id}}` in the url.\n\t\t\tlet url = `${base}${path}`.replace(\n\t\t\t\t/\\{([^}]+)\\}/g,\n\t\t\t\t(_m, p: string) =>\n\t\t\t\t\t`{{params.${draft.param(params, p, { type: 'string', required: true }, name)}}}`,\n\t\t\t);\n\t\t\tconst queryPairs: string[] = [];\n\t\t\tfor (const p of op.parameters ?? []) {\n\t\t\t\tif (!p.name) continue;\n\t\t\t\tconst def: HttpToolParam = {\n\t\t\t\t\ttype: openApiType(p.schema?.type),\n\t\t\t\t\t...(p.description ? { description: p.description } : {}),\n\t\t\t\t\t...(p.required ? { required: true } : {}),\n\t\t\t\t\t...(p.schema?.enum ? { choices: p.schema.enum } : {}),\n\t\t\t\t};\n\t\t\t\t// A CREDENTIAL HEADER IS NEVER A PARAM. The model would have to be\n\t\t\t\t// handed the token to fill it in, and the whole point of the secret\n\t\t\t\t// placeholder is that it never sees one.\n\t\t\t\tif (p.in === 'header' && CREDENTIAL_HEADERS.has(p.name.toLowerCase())) {\n\t\t\t\t\tconst secret = secretNameFor(p.name, options);\n\t\t\t\t\theaderPairs[p.name] = `{{secrets.${secret}}}`;\n\t\t\t\t\tdraft.secret(secret, name, `securityScheme (header parameter \"${p.name}\")`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// A cookie parameter cannot be expressed: it would have to be merged\n\t\t\t\t// into a single Cookie header with every other one. Say so rather\n\t\t\t\t// than declaring a param that goes nowhere.\n\t\t\t\tif (p.in === 'cookie') {\n\t\t\t\t\tdraft.warnings.push({\n\t\t\t\t\t\tkind: 'unsupported-body',\n\t\t\t\t\t\ttool: name,\n\t\t\t\t\t\tmessage: `Cookie parameter \"${p.name}\" is not supported; the tool was created without it.`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst param = draft.param(params, p.name, def, name);\n\t\t\t\tif (p.in === 'query') {\n\t\t\t\t\tqueryPairs.push(`${encodeURIComponent(p.name)}={{paramsEncoded.${param}}}`);\n\t\t\t\t} else if (p.in === 'header') {\n\t\t\t\t\t// DECLARED AND NEVER SENT is the failure this closes. Every\n\t\t\t\t\t// parameter used to land in `params` whatever its `in` was, but\n\t\t\t\t\t// only query and path were wired to anything, so a required\n\t\t\t\t\t// `X-Tenant-Id` made the model supply a value that was dropped on\n\t\t\t\t\t// the floor and the request went out without the header.\n\t\t\t\t\theaderPairs[p.name] = `{{params.${param}}}`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (queryPairs.length > 0) url = `${url}?${queryPairs.join('&')}`;\n\n\t\t\tif (firstScheme) {\n\t\t\t\tconst secret = secretNameFor(\n\t\t\t\t\tfirstScheme.in === 'header' && firstScheme.name ? firstScheme.name : 'authorization',\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tconst headerName =\n\t\t\t\t\tfirstScheme.type === 'apiKey' && firstScheme.in === 'header' && firstScheme.name\n\t\t\t\t\t\t? firstScheme.name\n\t\t\t\t\t\t: 'Authorization';\n\t\t\t\theaderPairs[headerName] =\n\t\t\t\t\theaderName.toLowerCase() === 'authorization'\n\t\t\t\t\t\t? `${firstScheme.scheme === 'basic' ? 'Basic' : 'Bearer'} {{secrets.${secret}}}`\n\t\t\t\t\t\t: `{{secrets.${secret}}}`;\n\t\t\t\tdraft.secret(secret, name, `securityScheme (${firstScheme.type ?? 'unknown'})`);\n\t\t\t}\n\t\t\tconst headers = safeHeaders(headerPairs, name, draft, options, 'OpenAPI');\n\n\t\t\tconst upper = method.toUpperCase() as HttpTool['method'];\n\t\t\tlet body: string | undefined;\n\t\t\tif (op.requestBody && upper !== 'GET') {\n\t\t\t\tconst types = Object.keys(op.requestBody.content ?? {});\n\t\t\t\tif (types.some((t) => t.includes('json'))) {\n\t\t\t\t\t// A LITERAL EXAMPLE IS NOT INVENTED HERE. The schema says what the\n\t\t\t\t\t// shape is; guessing values would produce a tool that posts\n\t\t\t\t\t// plausible nonsense. The agent fills this in, so it is left for\n\t\t\t\t\t// the developer to shape.\n\t\t\t\t\tbody = '{{paramsJson.body}}';\n\t\t\t\t\tparams.body = { type: 'string', description: 'JSON body for this request.', required: true };\n\t\t\t\t} else if (types.length > 0) {\n\t\t\t\t\tdraft.warnings.push({\n\t\t\t\t\t\tkind: 'unsupported-body',\n\t\t\t\t\t\ttool: name,\n\t\t\t\t\t\tmessage: `Request body is ${types.join(', ')}, which is not supported; the tool was created without one.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdraft.tools.push({\n\t\t\t\tname,\n\t\t\t\tdescription: describe([op.description, op.summary], name, upper, path, draft),\n\t\t\t\tmethod: upper,\n\t\t\t\turl,\n\t\t\t\t...(Object.keys(headers).length > 0 && { headers }),\n\t\t\t\t...(Object.keys(params).length > 0 && { params }),\n\t\t\t\t...(draft.secretsFor(name).length > 0 && { secrets: draft.secretsFor(name) }),\n\t\t\t\t...(body !== undefined && { body }),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn draft.finish(options);\n}\n\n/**\n * Fetch an OpenAPI document and draft tools from it.\n *\n * THE FETCH GOES TO YOUR SERVER, NOT OURS. Pass `headers` if the document itself\n * is behind auth. Nothing about the document is sent to AgentNava: the drafts\n * are built in this process and you decide what to do with them.\n */\nexport async function fromOpenApiUrl(\n\turl: string,\n\toptions: ImportOptions & { headers?: Record<string, string>; fetch?: typeof fetch } = {},\n): Promise<ImportedTools> {\n\tconst f = options.fetch ?? fetch;\n\tconst res = await f(url, { headers: options.headers ?? {} });\n\tif (!res.ok) {\n\t\tthrow new Error(`could not read the OpenAPI document at ${url}: ${res.status}`);\n\t}\n\treturn fromOpenApi((await res.json()) as OpenApiDocument, options);\n}\n\n// ------------------------------------------------------------------- curl\n\n/**\n * Draft one tool from a curl command.\n *\n * THE LOWEST BAR ON PURPOSE. A team with no collection and no document still has\n * a curl command that works, usually pasted in a chat thread, and that is enough\n * to start. Handles the flags people actually use: `-X`, `-H`, `-d`/`--data`,\n * `--data-raw`, `--url`, and a bare URL.\n *\n * Give it a `name` and a `description`: a curl command carries neither, and the\n * description is the field that decides whether the agent picks this tool.\n */\nexport function fromCurl(\n\tcommand: string,\n\toptions: ImportOptions & { name?: string; description?: string } = {},\n): ImportedTools {\n\tconst draft = new Draft();\n\t// Join line continuations, then split on whitespace outside quotes.\n\tconst flat = command.replace(/\\\\\\r?\\n/g, ' ').trim();\n\tconst tokens = flat.match(/\"[^\"]*\"|'[^']*'|\\S+/g) ?? [];\n\tconst unquote = (s: string): string =>\n\t\t(s.startsWith('\"') && s.endsWith('\"')) || (s.startsWith(\"'\") && s.endsWith(\"'\"))\n\t\t\t? s.slice(1, -1)\n\t\t\t: s;\n\n\tlet method = '';\n\tlet url = '';\n\tlet body: string | undefined;\n\tconst headerPairs: Record<string, string> = {};\n\n\tfor (let i = 0; i < tokens.length; i++) {\n\t\tconst t = tokens[i] as string;\n\t\tif (t === 'curl') continue;\n\t\tif (t === '-X' || t === '--request') {\n\t\t\tmethod = unquote(tokens[++i] ?? 'GET').toUpperCase();\n\t\t} else if (t === '-H' || t === '--header') {\n\t\t\tconst raw = unquote(tokens[++i] ?? '');\n\t\t\tconst at = raw.indexOf(':');\n\t\t\tif (at > 0) headerPairs[raw.slice(0, at).trim()] = raw.slice(at + 1).trim();\n\t\t} else if (t === '-d' || t === '--data' || t === '--data-raw' || t === '--data-binary') {\n\t\t\tbody = unquote(tokens[++i] ?? '');\n\t\t} else if (t === '-u' || t === '--user') {\n\t\t\t// `-u user:pass` IS a credential, and it used to vanish without a trace:\n\t\t\t// `-u` matched no branch, and `user:pass` matched neither `^-` nor a\n\t\t\t// url, so both tokens were skipped in silence. Routed through the\n\t\t\t// Authorization header so safeHeaders strips it like any other, which\n\t\t\t// also produces the credential-stripped warning.\n\t\t\theaderPairs.Authorization = `Basic ${unquote(tokens[++i] ?? '')}`;\n\t\t} else if (t === '-b' || t === '--cookie') {\n\t\t\theaderPairs.Cookie = unquote(tokens[++i] ?? '');\n\t\t} else if (t === '--url') {\n\t\t\turl = unquote(tokens[++i] ?? '');\n\t\t} else if (!t.startsWith('-') && /^https?:\\/\\//.test(unquote(t))) {\n\t\t\turl = unquote(t);\n\t\t}\n\t}\n\n\tif (!url) throw new Error('no URL found in that curl command');\n\t// curl's own default: a body implies POST unless -X said otherwise.\n\tif (!method) method = body !== undefined ? 'POST' : 'GET';\n\n\tconst name = draft.uniqueName(toolNameFrom(options.name ?? `${method} ${url}`));\n\tconst headers = safeHeaders(headerPairs, name, draft, options, 'curl');\n\n\tdraft.tools.push({\n\t\tname,\n\t\tdescription: describe([options.description], name, method, url, draft),\n\t\tmethod: (['GET', 'POST', 'PUT', 'DELETE', 'PATCH'].includes(method)\n\t\t\t? method\n\t\t\t: 'GET') as HttpTool['method'],\n\t\turl,\n\t\t...(Object.keys(headers).length > 0 && { headers }),\n\t\t...(draft.secretsFor(name).length > 0 && { secrets: draft.secretsFor(name) }),\n\t\t...(body !== undefined && method !== 'GET' && { body }),\n\t});\n\n\treturn draft.finish(options);\n}\n\n// ------------------------------------------------------------------ entry\n\n/** Where a draft comes from. Exactly one key. */\nexport type ImportSource =\n\t/** An OpenAPI 3 or Swagger 2 document you already have in memory. */\n\t| { openapi: OpenApiDocument }\n\t/** A URL serving one. FastAPI publishes `/openapi.json` for free. The fetch\n\t * goes to YOUR server; nothing is sent to AgentNava. */\n\t| { openapiUrl: string; headers?: Record<string, string>; fetch?: typeof fetch }\n\t/** A Postman collection export, v2.0 or v2.1. */\n\t| { postman: PostmanCollection }\n\t/** One working curl command. */\n\t| { curl: string; name?: string; description?: string };\n\n/**\n * Draft tools from whatever a company already has.\n *\n * NO SOURCE IS THE PRIMARY ONE, and that is deliberate. Which artifact a team\n * can hand you is an accident of what they already keep, not a statement about\n * how good their API is:\n *\n * OpenAPI the actual standard, and what every API gateway publishes\n * (Apigee, MuleSoft, Kong, Azure APIM). Gives real parameter\n * TYPES, required flags and enums. Often auto-generated, which\n * means the descriptions are frequently empty.\n * Postman the most widely used API client there is, and for many teams the\n * only artifact anybody maintains. No parameter types, but it holds\n * the requests somebody has actually RUN: the header names that\n * really work and real example bodies.\n * curl the lowest bar. A team with neither of the above still has a\n * command that works, usually pasted in a chat thread.\n *\n * They all produce the same reviewable shape, because the useful step is not the\n * parsing. It is what comes after: choosing which operations an agent should\n * have and writing what each one is for.\n *\n * ```ts\n * const draft = await importTools({ openapiUrl: 'https://api.acme.com/openapi.json' });\n * const draft = importTools({ postman: collection });\n * const draft = importTools({ curl: 'curl -X POST https://api.acme.com/refunds -d ...' });\n * ```\n */\nexport function importTools(\n\tsource: Exclude<ImportSource, { openapiUrl: string }>,\n\toptions?: ImportOptions,\n): ImportedTools;\nexport function importTools(\n\tsource: Extract<ImportSource, { openapiUrl: string }>,\n\toptions?: ImportOptions,\n): Promise<ImportedTools>;\nexport function importTools(\n\tsource: ImportSource,\n\toptions: ImportOptions = {},\n): ImportedTools | Promise<ImportedTools> {\n\tif ('openapi' in source) return fromOpenApi(source.openapi, options);\n\tif ('postman' in source) return fromPostman(source.postman, options);\n\tif ('curl' in source) {\n\t\treturn fromCurl(source.curl, {\n\t\t\t...options,\n\t\t\t...(source.name !== undefined && { name: source.name }),\n\t\t\t...(source.description !== undefined && { description: source.description }),\n\t\t});\n\t}\n\tif ('openapiUrl' in source) {\n\t\treturn fromOpenApiUrl(source.openapiUrl, {\n\t\t\t...options,\n\t\t\t...(source.headers !== undefined && { headers: source.headers }),\n\t\t\t...(source.fetch !== undefined && { fetch: source.fetch }),\n\t\t});\n\t}\n\t// Named, not \"invalid source\": a caller who passed the wrong key wants to\n\t// know which keys exist.\n\tthrow new Error(\n\t\t'importTools needs one of: { openapi }, { openapiUrl }, { postman }, { curl }',\n\t);\n}\n"]}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { AgentNava, Workspace } from './workspace.ts';
|
|
2
|
+
export { Agent, type StartOptions } from './agent.ts';
|
|
3
|
+
export { Connection } from './connection.ts';
|
|
4
|
+
export { Secret } from './secret.ts';
|
|
5
|
+
export { EndUser } from './end-user.ts';
|
|
6
|
+
export { Conversation, type AskOptions, type FileUrlOptions } from './conversation.ts';
|
|
7
|
+
export { KnowledgeBase } from './knowledge-base.ts';
|
|
8
|
+
export { Project, type ProjectStartOptions } from './project.ts';
|
|
9
|
+
export { AgentNavaError } from './errors.ts';
|
|
10
|
+
export { loadWorkflows, parseWorkflow } from './workflows.ts';
|
|
11
|
+
export { importTools, fromOpenApi, fromOpenApiUrl, fromPostman, fromCurl, toolNameFrom, type ImportSource, type ImportOptions, type ImportedTools, type ImportedSecret, type ImportWarning, type ImportWarningKind, type OpenApiDocument, type PostmanCollection, } from './import-tools.ts';
|
|
12
|
+
export { loadAgentDir } from './load-agent-dir.ts';
|
|
13
|
+
export { loadManagerTemplate } from './templates.ts';
|
|
14
|
+
export type { Turn } from './turn.ts';
|
|
15
|
+
export type { ClientOptions } from './http.ts';
|
|
16
|
+
export type { AgentConversationData, AgentData, AgentFields, Attachment, Bindings, ConnectionRequirement, ConnectionStatus, Credits, FileEntry, Filesystem, Grade, HttpTool, HttpToolParam, McpServer, ProjectAgent, Message, Parameter, ProjectConversationData, ProjectData, ProjectFields, Requirement, CredentialOwner, Scope, SeatPlan, SecretMeta, SecretRequirement, Step, Trigger, TurnEvent, Workflow, WorkspaceInfo, WorkspaceMember, } from './types.ts';
|
package/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @cerebro-labs/agentnava-sdk
|
|
2
|
+
//
|
|
3
|
+
// Configure an agent, start a conversation, work with it.
|
|
4
|
+
//
|
|
5
|
+
// import { AgentNava } from '@cerebro-labs/agentnava-sdk';
|
|
6
|
+
//
|
|
7
|
+
// const ws = AgentNava.getWorkspace();
|
|
8
|
+
// const agent = await ws.agents.create({
|
|
9
|
+
// name: 'Refund checker',
|
|
10
|
+
// instructions: 'Decide whether a late delivery qualifies for a refund.',
|
|
11
|
+
// });
|
|
12
|
+
// const conversation = await agent.start({ endUserId: null });
|
|
13
|
+
// console.log(await conversation.ask('Order 4471 was nine days late.'));
|
|
14
|
+
//
|
|
15
|
+
// The reference this implements is design/sdk-design.md.
|
|
16
|
+
export { AgentNava, Workspace } from "./workspace.js";
|
|
17
|
+
export { Agent } from "./agent.js";
|
|
18
|
+
export { Connection } from "./connection.js";
|
|
19
|
+
export { Secret } from "./secret.js";
|
|
20
|
+
export { EndUser } from "./end-user.js";
|
|
21
|
+
export { Conversation } from "./conversation.js";
|
|
22
|
+
export { KnowledgeBase } from "./knowledge-base.js";
|
|
23
|
+
export { Project } from "./project.js";
|
|
24
|
+
export { AgentNavaError } from "./errors.js";
|
|
25
|
+
export { loadWorkflows, parseWorkflow } from "./workflows.js";
|
|
26
|
+
// Draft an agent's tools from whatever a company already has: an OpenAPI
|
|
27
|
+
// document, a Postman collection, or a working curl command. Runs entirely on
|
|
28
|
+
// your machine: nothing about the source is sent to AgentNava, which matters
|
|
29
|
+
// because those files routinely contain a live credential.
|
|
30
|
+
export { importTools, fromOpenApi, fromOpenApiUrl, fromPostman, fromCurl, toolNameFrom, } from "./import-tools.js";
|
|
31
|
+
// Reads a whole Claude-Code-shaped agent directory (AGENT.md + workflows/ +
|
|
32
|
+
// mcp-servers.json ...) into the fields ws.agents.create() takes.
|
|
33
|
+
export { loadAgentDir } from "./load-agent-dir.js";
|
|
34
|
+
// The platform's built-in project-manager configuration. apps/api imports this
|
|
35
|
+
// through the './templates' subpath; re-exported here so the package has one
|
|
36
|
+
// surface rather than two.
|
|
37
|
+
export { loadManagerTemplate } from "./templates.js";
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,6DAA6D;AAC7D,EAAE;AACF,yCAAyC;AACzC,2CAA2C;AAC3C,8BAA8B;AAC9B,8EAA8E;AAC9E,QAAQ;AACR,iEAAiE;AACjE,2EAA2E;AAC3E,EAAE;AACF,yDAAyD;AAEzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAwC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAA4B,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,2DAA2D;AAC3D,OAAO,EACN,WAAW,EACX,WAAW,EACX,cAAc,EACd,WAAW,EACX,QAAQ,EACR,YAAY,GASZ,MAAM,mBAAmB,CAAC;AAC3B,4EAA4E;AAC5E,kEAAkE;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,+EAA+E;AAC/E,6EAA6E;AAC7E,2BAA2B;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["// @cerebro-labs/agentnava-sdk\n//\n// Configure an agent, start a conversation, work with it.\n//\n// import { AgentNava } from '@cerebro-labs/agentnava-sdk';\n//\n// const ws = AgentNava.getWorkspace();\n// const agent = await ws.agents.create({\n// name: 'Refund checker',\n// instructions: 'Decide whether a late delivery qualifies for a refund.',\n// });\n// const conversation = await agent.start({ endUserId: null });\n// console.log(await conversation.ask('Order 4471 was nine days late.'));\n//\n// The reference this implements is design/sdk-design.md.\n\nexport { AgentNava, Workspace } from './workspace.ts';\nexport { Agent, type StartOptions } from './agent.ts';\nexport { Connection } from './connection.ts';\nexport { Secret } from './secret.ts';\nexport { EndUser } from './end-user.ts';\nexport { Conversation, type AskOptions, type FileUrlOptions } from './conversation.ts';\nexport { KnowledgeBase } from './knowledge-base.ts';\nexport { Project, type ProjectStartOptions } from './project.ts';\nexport { AgentNavaError } from './errors.ts';\nexport { loadWorkflows, parseWorkflow } from './workflows.ts';\n// Draft an agent's tools from whatever a company already has: an OpenAPI\n// document, a Postman collection, or a working curl command. Runs entirely on\n// your machine: nothing about the source is sent to AgentNava, which matters\n// because those files routinely contain a live credential.\nexport {\n\timportTools,\n\tfromOpenApi,\n\tfromOpenApiUrl,\n\tfromPostman,\n\tfromCurl,\n\ttoolNameFrom,\n\ttype ImportSource,\n\ttype ImportOptions,\n\ttype ImportedTools,\n\ttype ImportedSecret,\n\ttype ImportWarning,\n\ttype ImportWarningKind,\n\ttype OpenApiDocument,\n\ttype PostmanCollection,\n} from './import-tools.ts';\n// Reads a whole Claude-Code-shaped agent directory (AGENT.md + workflows/ +\n// mcp-servers.json ...) into the fields ws.agents.create() takes.\nexport { loadAgentDir } from './load-agent-dir.ts';\n// The platform's built-in project-manager configuration. apps/api imports this\n// through the './templates' subpath; re-exported here so the package has one\n// surface rather than two.\nexport { loadManagerTemplate } from './templates.ts';\nexport type { Turn } from './turn.ts';\nexport type { ClientOptions } from './http.ts';\nexport type {\n\tAgentConversationData,\n\tAgentData,\n\tAgentFields,\n\tAttachment,\n\tBindings,\n\tConnectionRequirement,\n\tConnectionStatus,\n\tCredits,\n\tFileEntry,\n\tFilesystem,\n\tGrade,\n\tHttpTool,\n\tHttpToolParam,\n\tMcpServer,\n\tProjectAgent,\n\tMessage,\n\tParameter,\n\tProjectConversationData,\n\tProjectData,\n\tProjectFields,\n\tRequirement,\n\tCredentialOwner,\n\tScope,\n\tSeatPlan,\n\tSecretMeta,\n\tSecretRequirement,\n\tStep,\n\tTrigger,\n\tTurnEvent,\n\tWorkflow,\n\tWorkspaceInfo,\n\tWorkspaceMember,\n} from './types.ts';\n"]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { Http } from './http.ts';
|
|
2
|
+
import type { KnowledgeBaseData, KnowledgeFileEntry } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A knowledge base: a named folder of files your agents read.
|
|
5
|
+
*
|
|
6
|
+
* A base lives on the WORKSPACE, not on one agent, and an agent configuration
|
|
7
|
+
* attaches it by key. Two agents attaching the same base is the point: correct a
|
|
8
|
+
* file once and both see the correction.
|
|
9
|
+
*
|
|
10
|
+
* Attached bases are mounted READ-ONLY at `/knowledge/<key>/` when a session
|
|
11
|
+
* starts, so the agent finds things the way a person would, with `ls`, `grep`
|
|
12
|
+
* and `cat`. There is no search endpoint and no embedding step, deliberately;
|
|
13
|
+
* see the NO EMBEDDINGS decision in CLAUDE.md.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const kb = await ws.knowledgeBases.create({ key: 'product-docs', name: 'Docs' });
|
|
17
|
+
* await kb.files.put('/pricing/tiers.md', bytes, 'text/markdown');
|
|
18
|
+
* await ws.agents.create({ name: 'Nava', knowledge: ['product-docs'] });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class KnowledgeBase {
|
|
22
|
+
#private;
|
|
23
|
+
/** Workspace-unique, and what an agent configuration stores. Not editable:
|
|
24
|
+
* renaming it would move every attachment silently. */
|
|
25
|
+
readonly key: string;
|
|
26
|
+
private snapshot?;
|
|
27
|
+
constructor(http: Http, key: string, snapshot?: KnowledgeBaseData);
|
|
28
|
+
private get base();
|
|
29
|
+
/** The base's current record: name, description, file count, timestamps. */
|
|
30
|
+
get(): Promise<KnowledgeBaseData>;
|
|
31
|
+
/** What was known at the time this handle was made, without a round trip.
|
|
32
|
+
* Undefined on a handle built from a bare key. */
|
|
33
|
+
get data(): KnowledgeBaseData | undefined;
|
|
34
|
+
/** Change the display name or description. The KEY is deliberately not
|
|
35
|
+
* changeable here: agent configurations point at it. */
|
|
36
|
+
update(fields: {
|
|
37
|
+
name?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
}): Promise<KnowledgeBase>;
|
|
40
|
+
/**
|
|
41
|
+
* Delete the base and everything in it.
|
|
42
|
+
*
|
|
43
|
+
* REFUSES while any agent still attaches it, with an error naming them. That
|
|
44
|
+
* refusal is what makes attaching safe: an agent configuration that named a
|
|
45
|
+
* base at save time would otherwise find it missing the next morning. Call
|
|
46
|
+
* `attachments()` first if you want to know before you try.
|
|
47
|
+
*/
|
|
48
|
+
delete(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Which agents read this base.
|
|
51
|
+
*
|
|
52
|
+
* The question worth asking before deleting or reorganising one: who breaks?
|
|
53
|
+
* Read from each agent's current configuration, so it reflects what a session
|
|
54
|
+
* would actually mount rather than what somebody typed into a draft.
|
|
55
|
+
*/
|
|
56
|
+
attachments(): Promise<{
|
|
57
|
+
agentId: string;
|
|
58
|
+
agentKey?: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
}[]>;
|
|
61
|
+
/**
|
|
62
|
+
* The files in this base.
|
|
63
|
+
*
|
|
64
|
+
* Paths, not flat names, so `/pricing/tiers.md` is a file inside `pricing/`
|
|
65
|
+
* and the session mount reproduces that shape exactly.
|
|
66
|
+
*/
|
|
67
|
+
readonly files: {
|
|
68
|
+
/**
|
|
69
|
+
* Upload, or REPLACE what is already at this path. A path holds one file;
|
|
70
|
+
* re-uploading it is a correction, not a second copy.
|
|
71
|
+
*/
|
|
72
|
+
put: (path: string, bytes: Uint8Array | ArrayBuffer, contentType?: string) => Promise<KnowledgeFileEntry>;
|
|
73
|
+
/** List files, optionally under one prefix. Ordered by path, so a listing
|
|
74
|
+
* reads like a directory rather than an upload log. */
|
|
75
|
+
list: (prefix?: string) => Promise<KnowledgeFileEntry[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Read a file's bytes back.
|
|
78
|
+
*
|
|
79
|
+
* Exists because until now you could write a file and list it but never
|
|
80
|
+
* read it, so a script had no way to verify its own upload except by
|
|
81
|
+
* asking an agent.
|
|
82
|
+
*/
|
|
83
|
+
get: (path: string) => Promise<Uint8Array>;
|
|
84
|
+
/**
|
|
85
|
+
* Read a file back as a string.
|
|
86
|
+
*
|
|
87
|
+
* `get` returns bytes, which is right for a PDF and awkward for text: you
|
|
88
|
+
* decode, change something, and encode again. This is the same file
|
|
89
|
+
* already decoded, for the case people actually hit, which is reading a
|
|
90
|
+
* document to check it or to correct it.
|
|
91
|
+
*/
|
|
92
|
+
text: (path: string) => Promise<string>;
|
|
93
|
+
remove: (path: string) => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Prepare a file again.
|
|
96
|
+
*
|
|
97
|
+
* Preparation happens by itself when a file is uploaded, so this is for
|
|
98
|
+
* the times it did not work: a scan that came out blank, or a document
|
|
99
|
+
* that failed before we could read its format and can now.
|
|
100
|
+
*
|
|
101
|
+
* It also hands back a file you have edited by hand. Anything you write
|
|
102
|
+
* yourself is left alone by later runs, and calling this returns it to
|
|
103
|
+
* being generated.
|
|
104
|
+
*
|
|
105
|
+
* Returns immediately. Watch `status` on the file listing to see it
|
|
106
|
+
* finish.
|
|
107
|
+
*/
|
|
108
|
+
retry: (path: string) => Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Upload a whole directory, preserving its structure under `prefix`.
|
|
111
|
+
*
|
|
112
|
+
* Sugar over repeated `put`, but it is the operation people actually
|
|
113
|
+
* perform, and hand-rolling the walk is where mistakes about path prefixes
|
|
114
|
+
* get made. Node and Bun only: it reads the local filesystem.
|
|
115
|
+
*
|
|
116
|
+
* Sequential on purpose. A knowledge base is uploaded once in a while, not
|
|
117
|
+
* in a hot path, and a burst of parallel writes against one base is a good
|
|
118
|
+
* way to meet a rate limit for no gain.
|
|
119
|
+
*/
|
|
120
|
+
putDirectory: (dir: string, options?: {
|
|
121
|
+
prefix?: string;
|
|
122
|
+
include?: string[];
|
|
123
|
+
}) => Promise<KnowledgeFileEntry[]>;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* The agent that looks after this base.
|
|
127
|
+
*
|
|
128
|
+
* Every base has one. It reads the documents you upload, turns the ones an
|
|
129
|
+
* agent cannot open into text, and keeps a list of what is in here. That
|
|
130
|
+
* happens by itself; these methods are for asking it to do something
|
|
131
|
+
* specific.
|
|
132
|
+
*
|
|
133
|
+
* It lives in your own workspace, so its runs cost turns like any other
|
|
134
|
+
* agent's, and you can see what it did.
|
|
135
|
+
*/
|
|
136
|
+
readonly librarian: {
|
|
137
|
+
/**
|
|
138
|
+
* Work through the whole base: read what has not been read, and rewrite
|
|
139
|
+
* the list of what is in here.
|
|
140
|
+
*
|
|
141
|
+
* The same routine every time, which is the difference between this and
|
|
142
|
+
* `ask`. Reach for it after uploading a lot at once, or when something
|
|
143
|
+
* looks out of date.
|
|
144
|
+
*
|
|
145
|
+
* RETURNS IMMEDIATELY. The work is queued and runs within about a minute,
|
|
146
|
+
* because reading a base can take several minutes and no HTTP call should
|
|
147
|
+
* be held open that long. Watch `status` on the file listing to see it
|
|
148
|
+
* finish, exactly as with `files.retry`.
|
|
149
|
+
*/
|
|
150
|
+
organize: () => Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Ask the librarian to do something to this base.
|
|
153
|
+
*
|
|
154
|
+
* 'split the handbook by chapter'
|
|
155
|
+
* 'the text from that scan came out garbled, read it again'
|
|
156
|
+
* 'what is in here about pricing?'
|
|
157
|
+
*
|
|
158
|
+
* It can add and change files, which is its job. Your documents are not
|
|
159
|
+
* sacred to it, so ask it for what you want rather than working around it.
|
|
160
|
+
*/
|
|
161
|
+
ask: (text: string) => Promise<{
|
|
162
|
+
reply: string;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
}
|