{"_id":"@animastor/ai-agent","name":"@animastor/ai-agent","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@animastor/ai-agent","version":"0.1.0","description":"AI Agent Core — the shared execution mechanism for AI analysis tasks: fail-closed host port validation, task→callAI→structured JSON lifecycle. No domain knowledge, no persistence, no generation.","main":"src/index.js","exports":{".":"./src/index.js"},"scripts":{"test":"mocha test/*.test.js"},"engines":{"node":">=18"},"license":"MIT","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/Animastor/animastor.git","directory":"packages/animastor-ai-agent"},"bugs":{"url":"https://github.com/Animastor/animastor/issues"},"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5"},"_id":"@animastor/ai-agent@0.1.0","gitHead":"4048c447d881859b9a145ba4455cb6c8349749b6","homepage":"https://github.com/Animastor/animastor#readme","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-jJjhanRl/Q+dmscAwiuKbiR7T/6cZ8Ckr/SHtk12XEUmJguut8mPAX9R9ncwYjgBL0YmjtKOjIwTTmV0HZBPbQ==","shasum":"a785710996c1ee6a38b42cb73855d4057af1a0a6","tarball":"https://registry.npmjs.org/@animastor/ai-agent/-/ai-agent-0.1.0.tgz","fileCount":7,"unpackedSize":12481,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD6n/ah+iLw1gdOsHI1q39fvpvxHjl8pvuIPD9lenTw9QIgEFpNO5Eutf8uVzCc+H/nVUulpkoOhEFh28mY3vZc+hQ="}]},"_npmUser":{"name":"animastor","email":"admin@animastor.in"},"directories":{},"maintainers":[{"name":"animastor","email":"admin@animastor.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-agent_0.1.0_1788925961699_0.060042008379852074"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-09T03:52:41.532Z","0.1.0":"2026-09-09T03:52:41.839Z","modified":"2026-09-09T03:52:42.045Z"},"maintainers":[{"name":"animastor","email":"admin@animastor.in"}],"description":"AI Agent Core — the shared execution mechanism for AI analysis tasks: fail-closed host port validation, task→callAI→structured JSON lifecycle. No domain knowledge, no persistence, no generation.","homepage":"https://github.com/Animastor/animastor#readme","repository":{"type":"git","url":"git+https://github.com/Animastor/animastor.git","directory":"packages/animastor-ai-agent"},"bugs":{"url":"https://github.com/Animastor/animastor/issues"},"license":"MIT","readme":"# @animastor/ai-agent\n\nGeneric AI execution engine — the shared mechanism for running any AI task through a standard lifecycle.\n\n**Core mechanism only** — no domain knowledge, no persistence, no generation. The AI Analysis layer (`@animastor/ai-analysis`) owns the semantic analysis tasks.\n\n## What this is\n\nThis package provides two primitives:\n\n- **`assertHostPorts(ports, required, taskName)`** — fail-closed validation that required host-injected ports are present. A task refuses to run without its host ports instead of silently degrading.\n- **`execute(task, input, ports)`** — a generic async lifecycle runner that takes a declarative task definition and runs it through a standard `buildMessages → callAI → normalize → log → complete` pipeline with shielded error handling.\n\n## Installation\n\n```bash\nnpm install @animastor/ai-agent\n```\n\nRequires Node.js >= 18.\n\n## Usage\n\n```js\nconst { execute, assertHostPorts } = require('@animastor/ai-agent');\n\n// Define a task\nconst myTask = {\n    requiredPorts: ['callAI', 'logConversation', 'updateSession', 'createStep', 'completeStep', 'failStep'],\n    taskName: 'my-task',\n    stage: 'running',\n    progressMessage: (ports) => 'Running...',\n    stepType: 'my_step',\n    buildMessages: (input, ports) => ({\n        messages: [{ role: 'user', content: input.text }],\n        options: { maxTokens: 1024 },\n    }),\n    normalize: (result) => result,\n};\n\n// Run it with host-injected ports\nconst result = await execute(myTask, { sessionId: 's1', text: 'hello' }, ports);\n```\n\n## Task definition contract\n\n| Field | Required | Description |\n|---|---|---|\n| `requiredPorts` | yes | Port names this task needs |\n| `taskName` | yes | e.g. `'ai-agent/locations'` |\n| `stage` | yes | Progress stage key |\n| `progressMessage` | yes | `(ports) => string` |\n| `stepType` | yes | PG step type, e.g. `'analyze_locations'` |\n| `buildMessages` | yes | `(input, ports) => { messages, options? }` |\n| `normalize` | no | `(result, input, ports) => any` — task-owned validation |\n| `failMessage` | no | `(err) => string` |\n| `onError` | no | `(err, step, ports, input) => any` — degradation |\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-0bcfe5c3261095f715b26cb19b10fc12"}