@kooka/core 0.1.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.
@@ -0,0 +1,33 @@
1
+ export declare const DEFAULT_BACKGROUND_TTL_MS: number;
2
+ export declare const DEFAULT_BACKGROUND_KILL_GRACE_MS = 1500;
3
+ export type BackgroundJob = {
4
+ id: string;
5
+ scope: string;
6
+ key: string;
7
+ command: string;
8
+ cwd: string;
9
+ pid: number;
10
+ createdAt: number;
11
+ ttlMs: number;
12
+ expiresAt: number;
13
+ };
14
+ export declare function createBackgroundJobKey(args: {
15
+ cwd: string;
16
+ command: string;
17
+ }): string;
18
+ export declare function isPidAlive(pid: number): boolean;
19
+ export declare function killProcessTree(pid: number, signal: NodeJS.Signals): void;
20
+ export declare function getBackgroundJob(scope: string, key: string): BackgroundJob | undefined;
21
+ export declare function listBackgroundJobs(scope?: string): BackgroundJob[];
22
+ export declare function removeBackgroundJob(scope: string, key: string): void;
23
+ export declare function refreshBackgroundJob(scope: string, key: string, ttlMs?: number): BackgroundJob | undefined;
24
+ export declare function registerBackgroundJob(args: {
25
+ scope: string;
26
+ key: string;
27
+ command: string;
28
+ cwd: string;
29
+ pid: number;
30
+ ttlMs: number;
31
+ }): BackgroundJob;
32
+ export declare function cleanupDeadBackgroundJobs(scope?: string): void;
33
+ //# sourceMappingURL=backgroundJobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backgroundJobs.d.ts","sourceRoot":"","sources":["../../src/backgroundJobs.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AACxD,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EA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 };
6
+ export type CompactionConfig = {
7
+ auto: boolean;
8
+ prune: boolean;
9
+ pruneProtectTokens: number;
10
+ pruneMinimumTokens: number;
11
+ };
12
+ export declare const COMPACTION_MARKER_TEXT = "What did we do so far?";
13
+ export declare const COMPACTION_PROMPT_TEXT = "Provide a detailed prompt for continuing our conversation above. Focus on information that would be helpful for continuing the conversation, including what we did, what we are doing, which files we are working on, and what we should do next. Assume a new session will not have access to the previous conversation.";
14
+ export declare const COMPACTION_AUTO_CONTINUE_TEXT = "Continue if you have next steps.";
15
+ export declare const COMPACTED_TOOL_PLACEHOLDER = "[Old tool result content cleared]";
16
+ export declare const COMPACTION_SYSTEM_PROMPT: string;
17
+ export declare function getReservedOutputTokens(params: {
18
+ modelLimit?: ModelLimit;
19
+ maxOutputTokens: number;
20
+ }): number;
21
+ export declare function extractUsageTokens(usage: unknown): AgentHistoryMetadata['tokens'] | undefined;
22
+ export declare function getEffectiveHistory(history: AgentHistoryMessage[]): AgentHistoryMessage[];
23
+ export declare function markPrunableToolOutputs(history: AgentHistoryMessage[], config: CompactionConfig): {
24
+ totalToolOutputTokens: number;
25
+ prunedTokens: number;
26
+ markedParts: number;
27
+ };
28
+ export declare function createHistoryForModel(history: AgentHistoryMessage[]): AgentHistoryMessage[];
29
+ export declare function isOverflow(params: {
30
+ lastTokens: AgentHistoryMetadata['tokens'] | undefined;
31
+ modelLimit: ModelLimit | undefined;
32
+ reservedOutputTokens: number;
33
+ config: CompactionConfig;
34
+ }): boolean;
35
+ //# sourceMappingURL=compaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,M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alizeFsPath(value: string): string;
2
+ export declare function isSubPath(childPath: string, parentPath: string): boolean;
3
+ export declare function expandHome(p: string): string;
4
+ //# sourceMappingURL=fsPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsPath.d.ts","sourceRoot":"","sources":["../../src/fsPath.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAIxE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5C"}
@@ -0,0 +1,48 @@
1
+ import type { DynamicToolUIPart, UIMessage } from 'ai';
2
+ export type AgentHistoryMetadata = {
3
+ mode?: 'build' | 'plan';
4
+ finishReason?: string;
5
+ synthetic?: boolean;
6
+ summary?: boolean;
7
+ compaction?: {
8
+ auto: boolean;
9
+ };
10
+ tokens?: {
11
+ input?: number;
12
+ output?: number;
13
+ cacheRead?: number;
14
+ cacheWrite?: number;
15
+ total?: number;
16
+ raw?: unknown;
17
+ };
18
+ };
19
+ export type AgentHistoryMessage = UIMessage<AgentHistoryMetadata>;
20
+ export declare function createUserHistoryMessage(text: string, options?: {
21
+ synthetic?: boolean;
22
+ compaction?: {
23
+ auto: boolean;
24
+ };
25
+ }): AgentHistoryMessage;
26
+ export declare function createAssistantHistoryMessage(): AgentHistoryMessage;
27
+ export declare function getMessageText(message: AgentHistoryMessage): string;
28
+ export declare function appendText(message: AgentHistoryMessage, delta: string): void;
29
+ export declare function appendReasoning(message: AgentHistoryMessage, delta: string): void;
30
+ export declare function upsertDynamicToolCall(message: AgentHistoryMessage, params: {
31
+ toolName: string;
32
+ toolCallId: string;
33
+ input: unknown;
34
+ }): DynamicToolUIPart;
35
+ export declare function setDynamicToolOutput(message: AgentHistoryMessage, params: {
36
+ toolName: string;
37
+ toolCallId: string;
38
+ input: unknown;
39
+ output: unknown;
40
+ }): void;
41
+ export declare function setDynamicToolError(message: AgentHistoryMessage, params: {
42
+ toolName: string;
43
+ toolCallId: string;
44
+ input: unknown;
45
+ errorText: string;
46
+ }): void;
47
+ export declare function finalizeStreamingParts(message: AgentHistoryMessage): void;
48
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAC/B,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC;AAElE,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAChE,mBAAmB,CAiBrB;AAED,wBAAgB,6BAA6B,IAAI,mBAAmB,CAMnE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAKnE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW5E;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAWjF;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC/D,iBAAiB,CAuBnB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChF,IAAI,CAUN;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAClF,IAAI,CAUN;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAQzE"}
@@ -0,0 +1,14 @@
1
+ export type { ToolParameterSchema } from './toolSchema';
2
+ export { expandHome, isSubPath, normalizeFsPath } from './fsPath';
3
+ export type { PermissionAction, PermissionRule, PermissionRuleset } from './permission';
4
+ export { evaluatePermission, mergeRulesets, wildcardMatch } from './permission';
5
+ export { findExternalPathReferencesInShellCommand, isPathInsideWorkspace } from './shellPaths';
6
+ export type { ValidationResult, ShellCommandDecision } from './validation';
7
+ export { evaluateShellCommand, optionalBoolean, optionalNumber, optionalString, requireString, validateToolArgs, } from './validation';
8
+ export type { BackgroundJob } from './backgroundJobs';
9
+ export { DEFAULT_BACKGROUND_KILL_GRACE_MS, DEFAULT_BACKGROUND_TTL_MS, cleanupDeadBackgroundJobs, createBackgroundJobKey, getBackgroundJob, isPidAlive, killProcessTree, listBackgroundJobs, refreshBackgroundJob, registerBackgroundJob, removeBackgroundJob, } from './backgroundJobs';
10
+ export type { AgentHistoryMessage, AgentHistoryMetadata } from './history';
11
+ export { appendReasoning, appendText, createAssistantHistoryMessage, createUserHistoryMessage, finalizeStreamingParts, getMessageText, setDynamicToolError, setDynamicToolOutput, upsertDynamicToolCall, } from './history';
12
+ export type { CompactionConfig, ModelLimit } from './compaction';
13
+ export { COMPACTED_TOOL_PLACEHOLDER, COMPACTION_AUTO_CONTINUE_TEXT, COMPACTION_MARKER_TEXT, COMPACTION_PROMPT_TEXT, COMPACTION_SYSTEM_PROMPT, createHistoryForModel, extractUsageTokens, getEffectiveHistory, getReservedOutputTokens, isOverflow, markPrunableToolOutputs, } from './compaction';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAElE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAE,wCAAwC,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE/F,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,UAAU,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,uBAAuB,GACxB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type PermissionAction = 'allow' | 'ask' | 'deny';
2
+ export type PermissionRule = {
3
+ permission: string;
4
+ pattern: string;
5
+ action: PermissionAction;
6
+ };
7
+ export type PermissionRuleset = PermissionRule[];
8
+ export declare function wildcardMatch(pattern: string, value: string): boolean;
9
+ export declare function evaluatePermission(permission: string, pattern: string, ruleset: PermissionRuleset): PermissionRule | undefined;
10
+ export declare function mergeRulesets(...rulesets: Array<PermissionRuleset | undefined>): PermissionRuleset;
11
+ //# sourceMappingURL=permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/permission.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,EAAE,CAAC;AAwBjD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAMrE;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,GACzB,cAAc,GAAG,SAAS,CAQ5B;AAED,wBAAgB,aAAa,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC,GAAG,iBAAiB,CAOlG"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Best-effort detection of file-system path references in a shell command.
3
+ * Used to enforce "no external paths" without blocking all shell usage.
4
+ *
5
+ * This is not a sandbox; it only aims to catch explicit path references like:
6
+ * - absolute paths: /etc/passwd, C:\Windows\system.ini
7
+ * - parent traversal that resolves outside workspace: ../outside.txt
8
+ * - home paths: ~/.ssh/id_rsa
9
+ */
10
+ export declare function findExternalPathReferencesInShellCommand(command: string, options: {
11
+ cwd: string;
12
+ workspaceRoot: string;
13
+ }): string[];
14
+ export declare function isPathInsideWorkspace(targetPath: string, workspaceRoot: string): boolean;
15
+ //# sourceMappingURL=shellPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shellPaths.d.ts","sourceRoot":"","sources":["../../src/shellPaths.ts"],"names":[],"mappings":"AAkGA;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAC9C,MAAM,EAAE,CAyCV;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAMxF"}
@@ -0,0 +1,10 @@
1
+ export interface ToolParameterSchema {
2
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
3
+ description?: string;
4
+ enum?: string[];
5
+ items?: ToolParameterSchema;
6
+ properties?: Record<string, ToolParameterSchema>;
7
+ required?: string[];
8
+ default?: unknown;
9
+ }
10
+ //# sourceMappingURL=toolSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSchema.d.ts","sourceRoot":"","sources":["../../src/toolSchema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,29 @@
1
+ import type { ToolParameterSchema } from './toolSchema';
2
+ export interface ValidationResult<T = Record<string, unknown>> {
3
+ valid: boolean;
4
+ errors: string[];
5
+ data: T;
6
+ }
7
+ export declare function validateToolArgs(args: Record<string, unknown>, schema: {
8
+ properties: Record<string, ToolParameterSchema>;
9
+ required?: string[];
10
+ }): ValidationResult;
11
+ export declare function requireString(args: Record<string, unknown>, field: string): {
12
+ value: string;
13
+ } | {
14
+ error: string;
15
+ };
16
+ export declare function optionalString(args: Record<string, unknown>, field: string, defaultValue?: string): string | undefined;
17
+ export declare function optionalNumber(args: Record<string, unknown>, field: string, defaultValue?: number): number | undefined;
18
+ export declare function optionalBoolean(args: Record<string, unknown>, field: string, defaultValue?: boolean): boolean | undefined;
19
+ export type ShellCommandDecision = {
20
+ verdict: 'allow';
21
+ } | {
22
+ verdict: 'needs_approval';
23
+ reason: string;
24
+ } | {
25
+ verdict: 'deny';
26
+ reason: string;
27
+ };
28
+ export declare function evaluateShellCommand(command: string): ShellCommandDecision;
29
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GACA,gBAAgB,CAiClB;AAmFD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAMvC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMtH;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAetH;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,OAAO,GACrB,OAAO,GAAG,SAAS,CAcrB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACpB;IAAE,OAAO,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAkExC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAsB1E"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@kooka/core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Shared LingYun core library (runtime-agnostic agent primitives).",
6
+ "license": "Apache-2.0",
7
+ "main": "./dist/cjs/index.cjs",
8
+ "types": "./dist/types/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/cjs/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "dependencies": {
23
+ "ai": "^6.0.6"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.11.16",
27
+ "esbuild": "^0.25.0",
28
+ "typescript": "^5.3.3"
29
+ },
30
+ "scripts": {
31
+ "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
32
+ "build:types": "tsc -p tsconfig.json",
33
+ "build:esm": "esbuild src/index.ts --bundle --platform=node --target=es2022 --format=esm --outfile=dist/esm/index.js",
34
+ "build:cjs": "esbuild src/index.ts --bundle --platform=node --target=es2022 --format=cjs --outfile=dist/cjs/index.cjs",
35
+ "build": "pnpm run clean && pnpm run build:types && pnpm run build:esm && pnpm run build:cjs",
36
+ "typecheck": "tsc -p tsconfig.json --noEmit"
37
+ }
38
+ }