{"_id":"@aevatar/kit-core","_rev":"5-ce2aacb48fc7ccfc4595c571e45109a0","name":"@aevatar/kit-core","dist-tags":{"latest":"1.2.1"},"versions":{"0.3.0":{"name":"@aevatar/kit-core","version":"0.3.0","keywords":["aevatar","agent","client","session","sdk"],"_id":"@aevatar/kit-core@0.3.0","maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"dist":{"shasum":"863bdaa942cb5d42816deef86bee0bd3b16e6d8c","tarball":"https://registry.npmjs.org/@aevatar/kit-core/-/kit-core-0.3.0.tgz","fileCount":9,"integrity":"sha512-mgNEq2LPG5m757eKXU6kxjyWXTZDG/c1/oi/YohF5hq/SigumBaHfrTX3Q5mESByH/v0Wm3IpQOK4ws7CcZcmQ==","signatures":[{"sig":"MEQCICJ7oGbq1JE/EPP2WoijIrCe3yhuOULe2o68WCXo1VM5AiAOvK+kA/CnBk48Df0fj9t4rO5jbYGviDnuek3wvQIRhg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":265908},"main":"./dist/index.js","_from":"file:aevatar-kit-core-0.3.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"potterf","email":"potter.sun@aelf.io"},"_resolved":"/private/var/folders/d9/bmbzh5n14v7byzn_zznk3gr80000gn/T/686ceb72c17775e4801fa4b454885ee4/aevatar-kit-core-0.3.0.tgz","_integrity":"sha512-mgNEq2LPG5m757eKXU6kxjyWXTZDG/c1/oi/YohF5hq/SigumBaHfrTX3Q5mESByH/v0Wm3IpQOK4ws7CcZcmQ==","repository":{"url":"git+https://github.com/aevatar/aevatarkit-ui.git","type":"git","directory":"packages/kit-core"},"_npmVersion":"10.7.0","description":"Core client and business logic for AevatarKit SDK","directories":{},"_nodeVersion":"18.20.3","dependencies":{"@aevatar/kit-types":"0.3.0","@aevatar/kit-protocol":"0.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.3.0"},"_npmOperationalInternal":{"tmp":"tmp/kit-core_0.3.0_1767689140626_0.4086244773861867","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@aevatar/kit-core","version":"1.0.0","keywords":["aevatar","agent","client","session","sdk"],"_id":"@aevatar/kit-core@1.0.0","maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"dist":{"shasum":"972c069accdad89668bbe8b7452f2b2fb9d86c3e","tarball":"https://registry.npmjs.org/@aevatar/kit-core/-/kit-core-1.0.0.tgz","fileCount":9,"integrity":"sha512-mXk4rrnMuK7zXcfwhaqdfGy/MUoBArIdpySoBGrDtP3tFHuP9NfdB4h2GFaLaZS8ImmjSHPZI17RYoBX22XCyg==","signatures":[{"sig":"MEQCIC2ssj3ZVmpM/kD7Tz01z53mH+njanSD6R4p9E55Om4rAiBz6Yi9f1JMTY6NX3A8E7Azg8X7NjfwI2XXySuOWRsGZA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":234441},"main":"./dist/index.js","_from":"file:aevatar-kit-core-1.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"potterf","email":"potter.sun@aelf.io"},"_resolved":"/private/var/folders/d9/bmbzh5n14v7byzn_zznk3gr80000gn/T/f2642c7c1f47b86abe661bd545fa5326/aevatar-kit-core-1.0.0.tgz","_integrity":"sha512-mXk4rrnMuK7zXcfwhaqdfGy/MUoBArIdpySoBGrDtP3tFHuP9NfdB4h2GFaLaZS8ImmjSHPZI17RYoBX22XCyg==","repository":{"url":"git+https://github.com/aevatar/aevatarkit-ui.git","type":"git","directory":"packages/kit-core"},"_npmVersion":"10.7.0","description":"Core client and business logic for AevatarKit SDK","directories":{},"_nodeVersion":"18.20.3","dependencies":{"@aevatar/kit-types":"0.3.0","@aevatar/kit-protocol":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.3.0"},"_npmOperationalInternal":{"tmp":"tmp/kit-core_1.0.0_1767757709684_0.8297644099736265","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aevatar/kit-core","version":"1.1.0","keywords":["aevatar","agent","client","session","sdk"],"_id":"@aevatar/kit-core@1.1.0","maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"dist":{"shasum":"a701e31696ce5540a4742f6a3c2a57577184f464","tarball":"https://registry.npmjs.org/@aevatar/kit-core/-/kit-core-1.1.0.tgz","fileCount":9,"integrity":"sha512-EKeyJSDDG/OekctsgNy1D4FC5GMxoylSQ7bmCOR9hGFOLkmhplMIMfQGnqPhaCbdXE/7umKevbXw2NoHCFPY4Q==","signatures":[{"sig":"MEUCIQD3WrwzFrdsI2PGzQ6bE7d1GHBnX79NYgDeyZMecinZxwIgVTzlE36H12eeZtwwf4lhq97IlJtm4ZFkMc92zPRq/Y8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":234441},"main":"./dist/index.js","_from":"file:aevatar-kit-core-1.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"potterf","email":"potter.sun@aelf.io"},"_resolved":"/private/var/folders/d9/bmbzh5n14v7byzn_zznk3gr80000gn/T/8a77a4734231328b5a3fedefca43ac97/aevatar-kit-core-1.1.0.tgz","_integrity":"sha512-EKeyJSDDG/OekctsgNy1D4FC5GMxoylSQ7bmCOR9hGFOLkmhplMIMfQGnqPhaCbdXE/7umKevbXw2NoHCFPY4Q==","repository":{"url":"git+https://github.com/aevatar/aevatarkit-ui.git","type":"git","directory":"packages/kit-core"},"_npmVersion":"10.7.0","description":"Core client and business logic for AevatarKit SDK","directories":{},"_nodeVersion":"18.20.3","dependencies":{"@aevatar/kit-types":"1.1.0","@aevatar/kit-protocol":"1.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.3.0"},"_npmOperationalInternal":{"tmp":"tmp/kit-core_1.1.0_1767769294861_0.5214742215879096","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@aevatar/kit-core","version":"1.2.0","keywords":["aevatar","agent","client","session","sdk"],"_id":"@aevatar/kit-core@1.2.0","maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"dist":{"shasum":"852121922eb86d4e47e3c7d32914bde765765053","tarball":"https://registry.npmjs.org/@aevatar/kit-core/-/kit-core-1.2.0.tgz","fileCount":9,"integrity":"sha512-4YLbf4AKipSstA0k5146xNo1z3hirt4ycmsQC8Swc0UoH7/i3A0BcCJ/hQFaJjopYXLsycV6WaI1rrCDvwBLFg==","signatures":[{"sig":"MEQCIGzUCB5iUKhR4txzePJhZ8WS45oRN03YSU24WHearXCiAiB0y70C5wVAXL46L2/ulerKvw4lIYWG12lmfg9A0JSOOQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":234441},"main":"./dist/index.js","_from":"file:aevatar-kit-core-1.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"potterf","email":"potter.sun@aelf.io"},"_resolved":"/private/var/folders/d9/bmbzh5n14v7byzn_zznk3gr80000gn/T/8492182b46dd1e0dc293481cfadb8eed/aevatar-kit-core-1.2.0.tgz","_integrity":"sha512-4YLbf4AKipSstA0k5146xNo1z3hirt4ycmsQC8Swc0UoH7/i3A0BcCJ/hQFaJjopYXLsycV6WaI1rrCDvwBLFg==","repository":{"url":"git+https://github.com/aevatar/aevatarkit-ui.git","type":"git","directory":"packages/kit-core"},"_npmVersion":"10.7.0","description":"Core client and business logic for AevatarKit SDK","directories":{},"_nodeVersion":"18.20.3","dependencies":{"@aevatar/kit-types":"1.1.0","@aevatar/kit-protocol":"1.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.3.0"},"_npmOperationalInternal":{"tmp":"tmp/kit-core_1.2.0_1768204662985_0.9519458375853553","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@aevatar/kit-core","version":"1.2.1","description":"Core client and business logic for AevatarKit SDK","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"dependencies":{"@aevatar/kit-types":"1.2.1","@aevatar/kit-protocol":"1.2.1"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","vitest":"^1.0.0"},"repository":{"type":"git","url":"git+https://github.com/aevatar/aevatarkit-ui.git","directory":"packages/kit-core"},"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","publishConfig":{"access":"public"},"keywords":["aevatar","agent","client","session","sdk"],"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist","test":"vitest"},"_id":"@aevatar/kit-core@1.2.1","bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"_integrity":"sha512-43EV+NQA0D0DA4/Nz4ItZ7a9U5pZqVRbPu/O91p3vzSdIAaqYx9fSCuXB+/63A8UZjQVYpb5/Ihj90F5s8QKkw==","_resolved":"/private/var/folders/d9/bmbzh5n14v7byzn_zznk3gr80000gn/T/1fbc64b4affb2f3c1165f41d6f2575a1/aevatar-kit-core-1.2.1.tgz","_from":"file:aevatar-kit-core-1.2.1.tgz","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-43EV+NQA0D0DA4/Nz4ItZ7a9U5pZqVRbPu/O91p3vzSdIAaqYx9fSCuXB+/63A8UZjQVYpb5/Ihj90F5s8QKkw==","shasum":"6e021acc8a6bf8c2a89ed56f6bd3dac346a0e759","tarball":"https://registry.npmjs.org/@aevatar/kit-core/-/kit-core-1.2.1.tgz","fileCount":9,"unpackedSize":234441,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCuE4waoKUiECL2xJ07i9/dGQTpoLsJ10tBF/KXmRHYcQIgSxfJBuceCpvuVNfs2aHZuNaoQfSj4F5nUm5xGxI5BEg="}]},"_npmUser":{"name":"potterf","email":"potter.sun@aelf.io"},"directories":{},"maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kit-core_1.2.1_1768983991928_0.33287290602914843"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-06T08:45:40.461Z","modified":"2026-01-21T08:26:32.220Z","0.3.0":"2026-01-06T08:45:40.773Z","1.0.0":"2026-01-07T03:48:29.831Z","1.1.0":"2026-01-07T07:01:35.001Z","1.2.0":"2026-01-12T07:57:43.136Z","1.2.1":"2026-01-21T08:26:32.067Z"},"bugs":{"url":"https://github.com/aevatar/aevatarkit-ui/issues"},"homepage":"https://github.com/aevatar/aevatarkit-ui#readme","keywords":["aevatar","agent","client","session","sdk"],"repository":{"type":"git","url":"git+https://github.com/aevatar/aevatarkit-ui.git","directory":"packages/kit-core"},"description":"Core client and business logic for AevatarKit SDK","maintainers":[{"name":"potterf","email":"potter.sun@aelf.io"}],"readme":"# @aevatar/kit-core\n\n> Core client and business logic for AevatarKit SDK\n\n## Overview\n\nThis package provides the main client implementation for connecting to Aevatar Agent Framework backends. It handles session management, run execution, state synchronization, and resource access.\n\n## Installation\n\n```bash\npnpm add @aevatar/kit-core\n```\n\n## Features\n\n- 🔗 **Client Connection** - Connect to Aevatar backend\n- 📋 **Session Management** - Create, manage, close sessions\n- 🏃 **Run Execution** - Start runs, track progress\n- 🗄️ **State Management** - Snapshot + JSON Patch delta\n- 🔄 **Retry Logic** - Automatic retry with backoff\n\n## Quick Start\n\n```typescript\nimport { createAevatarClient } from '@aevatar/kit-core';\n\n// Create client\nconst client = createAevatarClient({\n  baseUrl: 'http://localhost:5001',\n  apiKey: 'your-api-key', // optional\n  timeout: 30000,\n});\n\n// Connect\nawait client.connect();\n\n// Create session\nconst session = await client.createSession({\n  config: {\n    agentId: 'my-agent',\n    systemPrompt: 'You are helpful assistant.',\n  },\n});\n\n// Send message\nawait session.sendMessage('Hello!');\n\n// Subscribe to events\nsession.onEvent((event) => {\n  if (event.type === 'TEXT_MESSAGE_CONTENT') {\n    process.stdout.write(event.delta);\n  }\n});\n\n// Cleanup\nawait session.close();\nclient.disconnect();\n```\n\n## Core Modules\n\n### Client (`client.ts`)\n\nMain entry point for SDK:\n\n```typescript\nimport { createAevatarClient, type AevatarClient } from '@aevatar/kit-core';\n\nconst client = createAevatarClient({\n  baseUrl: 'http://localhost:5001',\n  apiKey: 'optional-api-key',\n  timeout: 30000,\n  logger: { level: 'info' },\n  onConnectionChange: (status) => console.log('Status:', status),\n});\n```\n\n**Client Interface:**\n\n```typescript\ninterface AevatarClient {\n  readonly baseUrl: string;\n  readonly status: ConnectionStatus;\n  \n  // Connection\n  connect(): Promise<void>;\n  disconnect(): void;\n  onConnectionChange(callback: (status: ConnectionStatus) => void): Unsubscribe;\n  \n  // Sessions\n  createSession(options?: CreateSessionOptions): Promise<SessionInstance>;\n  getSession(sessionId: string): Promise<Session | null>;\n  listSessions(): Promise<SessionSummary[]>;\n  deleteSession(sessionId: string): Promise<void>;\n  \n  // Runs\n  getRun(runId: string): Promise<Run | null>;\n  listRuns(sessionId: string): Promise<RunSummary[]>;\n  \n  // Agents\n  getAgent(agentId: string): Promise<AgentInfo | null>;\n  listAgents(): Promise<AgentSummary[]>;\n  \n  // Graphs\n  getGraph(graphId: string): Promise<GraphDefinition | null>;\n  listGraphs(): Promise<GraphSummary[]>;\n  \n  // Memory\n  getMemory(memoryId: string): Promise<Memory | null>;\n  searchMemory(options: MemorySearchOptions): Promise<MemorySearchResult[]>;\n}\n```\n\n### Session Manager (`session.ts`)\n\nSession lifecycle and state management:\n\n```typescript\nimport { createSessionManager, type SessionInstance } from '@aevatar/kit-core';\n\nconst manager = createSessionManager({\n  baseUrl: 'http://localhost:5001',\n  apiKey: 'optional',\n  logger: createLogger(),\n});\n\nconst session = await manager.create({\n  config: { agentId: 'my-agent' },\n  autoStart: false,\n});\n```\n\n**SessionInstance Interface:**\n\n```typescript\ninterface SessionInstance {\n  readonly id: string;\n  readonly data: Session;\n  readonly status: SessionStatus;\n  readonly state: SessionState;\n  readonly messages: AgUiMessage[];\n  readonly currentRun: RunInstance | null;\n  \n  // Operations\n  startRun(input?: RunInput): Promise<RunInstance>;\n  sendMessage(content: string): Promise<void>;\n  stopRun(): Promise<void>;\n  close(): Promise<void>;\n  \n  // Subscriptions\n  onStateChange(callback: (state: SessionState) => void): Unsubscribe;\n  onMessage(callback: (message: AgUiMessage) => void): Unsubscribe;\n  onEvent(callback: (event: AgUiEvent) => void): Unsubscribe;\n}\n```\n\n### Run Manager (`run.ts`)\n\nRun execution and tracking:\n\n```typescript\nimport { createRunManager, type RunInstance } from '@aevatar/kit-core';\n\nconst runManager = createRunManager({\n  baseUrl: 'http://localhost:5001',\n  sessionId: 'session-123',\n  logger: createLogger(),\n});\n\nconst run = await runManager.start({\n  message: 'What is the weather today?',\n});\n\nrun.onStep((step) => console.log('Step:', step.name));\nawait run.waitForCompletion();\n```\n\n**RunInstance Interface:**\n\n```typescript\ninterface RunInstance {\n  readonly id: string;\n  readonly status: RunStatus;\n  readonly steps: StepInfo[];\n  \n  // Operations\n  stop(): Promise<void>;\n  waitForCompletion(): Promise<void>;\n  \n  // Subscriptions\n  onStatusChange(callback: (status: RunStatus) => void): Unsubscribe;\n  onStep(callback: (step: StepInfo) => void): Unsubscribe;\n}\n```\n\n### State Store (`state.ts`)\n\nState synchronization with JSON Patch:\n\n```typescript\nimport { createStateStore, type StateStore } from '@aevatar/kit-core';\n\nconst store = createStateStore({\n  status: 'idle',\n  customState: {},\n});\n\n// Apply snapshot\nstore.setSnapshot({ user: 'Alice', tasks: [] });\n\n// Apply delta (JSON Patch)\nstore.applyDelta([\n  { op: 'add', path: '/tasks/-', value: { id: 1, title: 'Task 1' } },\n]);\n\n// Subscribe to changes\nstore.subscribe((state) => {\n  console.log('State updated:', state);\n});\n```\n\n### Utilities\n\n**Logger (`utils/logger.ts`):**\n\n```typescript\nimport { createLogger, type Logger } from '@aevatar/kit-core';\n\nconst logger = createLogger({ level: 'debug' });\nlogger.debug('Debug message');\nlogger.info('Info message', { key: 'value' });\nlogger.error('Error message', { error });\n```\n\n**Retry Manager (`utils/retry.ts`):**\n\n```typescript\nimport { createRetryManager } from '@aevatar/kit-core';\n\nconst retry = createRetryManager({\n  maxRetries: 3,\n  delayMs: 1000,\n  backoffMultiplier: 2,\n});\n\nconst result = await retry.execute(async () => {\n  return await fetch('/api/data');\n});\n```\n\n## File Structure\n\n```\nsrc/\n├── index.ts         # Re-exports all\n├── client.ts        # Main client implementation\n├── session.ts       # Session management\n├── run.ts           # Run execution\n├── state.ts         # State store (snapshot + delta)\n└── utils/\n    ├── logger.ts    # Logging utility\n    └── retry.ts     # Retry with backoff\n```\n\n## State Management\n\nThe SDK supports AG-UI state synchronization:\n\n```typescript\n// Full state snapshot\nsession.onEvent((event) => {\n  if (event.type === 'STATE_SNAPSHOT') {\n    // Replace entire state\n    console.log('New state:', event.snapshot);\n  }\n  \n  if (event.type === 'STATE_DELTA') {\n    // Apply JSON Patch (RFC 6902)\n    console.log('Patches:', event.delta);\n    // [{ op: 'add', path: '/tasks/-', value: {...} }]\n  }\n});\n```\n\n## Error Handling\n\n```typescript\ntry {\n  await client.connect();\n} catch (error) {\n  if (error.message.includes('401')) {\n    console.error('Authentication failed');\n  } else if (error.message.includes('network')) {\n    console.error('Network error');\n  }\n}\n\n// Or use connection status\nclient.onConnectionChange((status) => {\n  if (status === 'error') {\n    console.error('Connection error');\n  }\n});\n```\n\n## Dependencies\n\n- `@aevatar/kit-types` - Type definitions\n- `@aevatar/kit-protocol` - SSE/event handling\n\n## Design Principles\n\n1. **Framework Agnostic** - No React/Vue/Angular dependency\n2. **Stateful Sessions** - Full lifecycle management\n3. **Type Safe** - Complete TypeScript coverage\n4. **Testable** - All modules can be mocked\n\n## Related Packages\n\n- [`@aevatar/kit-types`](../kit-types) - Type definitions\n- [`@aevatar/kit-protocol`](../kit-protocol) - Protocol layer\n- [`@aevatar/kit-react`](../kit-react) - React bindings\n- [`@aevatar/kit`](../kit) - Main package\n\n## License\n\nMIT\n\n","readmeFilename":"README.md"}