@chanaka_nakandala/agent-core
v1.0.2
Published
Shared TypeScript types and utilities used internally by Grubtech Integration Agent packages.
Maintainers
Readme
@grubtech/agent-core
Shared TypeScript types and utilities for Grubtech Integration Agent packages.
Overview
This package provides common types, enums, and constants used across the Grubtech Integration Agent monorepo. It's a types-only package with no runtime dependencies.
Installation
npm install @grubtech/agent-coreExports
Types
CachedDocument
Represents a cached documentation page:
interface CachedDocument {
url: string;
html: string;
chunks: DocumentChunk[];
cachedAt: Date;
expiresAt: Date;
}DocumentChunk
A chunk of documentation content:
interface DocumentChunk {
chunkId: string;
sourceUrl: string;
title: string;
content: string;
relevanceScore?: number;
metadata?: {
integrationPhase?: string;
tags?: string[];
};
}IntegrationContext
User session context:
interface IntegrationContext {
sessionId: string;
integrationPhase: IntegrationPhase;
lastQuery: string;
timestamp: Date;
}Enums
IntegrationPhase
Integration journey stages:
enum IntegrationPhase {
NOT_STARTED = 'NOT_STARTED',
AUTH = 'AUTH',
MENU_SYNC = 'MENU_SYNC',
ORDER_CREATION = 'ORDER_CREATION',
ORDER_STATUS = 'ORDER_STATUS',
GO_LIVE = 'GO_LIVE',
COMPLETED = 'COMPLETED'
}Constants
API URLs
const API_BASE_URL = 'https://api.grubtech.io';
const DOCS_BASE_URL = 'https://docs.grubtech.io';Error Codes
const ERROR_CODES = {
CACHE_READ_FAILED: 'CACHE_READ_FAILED',
CACHE_WRITE_FAILED: 'CACHE_WRITE_FAILED',
SCRAPE_FAILED: 'SCRAPE_FAILED',
PARSE_FAILED: 'PARSE_FAILED',
NETWORK_ERROR: 'NETWORK_ERROR',
RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
} as const;
type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];Usage
import {
type CachedDocument,
type DocumentChunk,
type IntegrationContext,
IntegrationPhase,
API_BASE_URL,
DOCS_BASE_URL,
ERROR_CODES,
type ErrorCode
} from '@grubtech/agent-core';
// Use types
const doc: CachedDocument = {
url: `${DOCS_BASE_URL}/docs/getting-started`,
html: '<html>...</html>',
chunks: [],
cachedAt: new Date(),
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000)
};
// Use enums
const context: IntegrationContext = {
sessionId: 'abc123',
integrationPhase: IntegrationPhase.AUTH,
lastQuery: 'How do I authenticate?',
timestamp: new Date()
};
// Use error codes
throw new Error(ERROR_CODES.CACHE_READ_FAILED);Development
Build:
npm run buildThe package compiles to dist/ with TypeScript declaration files.
License
MIT © Grubtech
