chore: include pre-built dist for github install
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
import type { PendingContext, RegisterContextOptions } from "./types";
|
||||
export declare class ContextCollector {
|
||||
private sessions;
|
||||
register(sessionID: string, options: RegisterContextOptions): void;
|
||||
getPending(sessionID: string): PendingContext;
|
||||
consume(sessionID: string): PendingContext;
|
||||
clear(sessionID: string): void;
|
||||
hasPending(sessionID: string): boolean;
|
||||
private sortEntries;
|
||||
}
|
||||
export declare const contextCollector: ContextCollector;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { ContextCollector, contextCollector } from "./collector";
|
||||
export { createContextInjectorMessagesTransformHook, } from "./injector";
|
||||
export type { ContextSourceType, ContextPriority, ContextEntry, RegisterContextOptions, PendingContext, MessageContext, OutputParts, InjectionStrategy, } from "./types";
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import type { ContextCollector } from "./collector";
|
||||
import type { Message, Part } from "@opencode-ai/sdk";
|
||||
interface OutputPart {
|
||||
type: string;
|
||||
text?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
interface InjectionResult {
|
||||
injected: boolean;
|
||||
contextLength: number;
|
||||
}
|
||||
export declare function injectPendingContext(collector: ContextCollector, sessionID: string, parts: OutputPart[]): InjectionResult;
|
||||
interface ChatMessageInput {
|
||||
sessionID: string;
|
||||
agent?: string;
|
||||
model?: {
|
||||
providerID: string;
|
||||
modelID: string;
|
||||
};
|
||||
messageID?: string;
|
||||
}
|
||||
interface ChatMessageOutput {
|
||||
message: Record<string, unknown>;
|
||||
parts: OutputPart[];
|
||||
}
|
||||
export declare function createContextInjectorHook(collector: ContextCollector): {
|
||||
"chat.message": (input: ChatMessageInput, output: ChatMessageOutput) => Promise<void>;
|
||||
};
|
||||
interface MessageWithParts {
|
||||
info: Message;
|
||||
parts: Part[];
|
||||
}
|
||||
type MessagesTransformHook = {
|
||||
"experimental.chat.messages.transform"?: (input: Record<string, never>, output: {
|
||||
messages: MessageWithParts[];
|
||||
}) => Promise<void>;
|
||||
};
|
||||
export declare function createContextInjectorMessagesTransformHook(collector: ContextCollector): MessagesTransformHook;
|
||||
export {};
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Source identifier for context injection
|
||||
* Each source registers context that will be merged and injected together
|
||||
*/
|
||||
export type ContextSourceType = "keyword-detector" | "rules-injector" | "directory-agents" | "directory-readme" | "custom";
|
||||
/**
|
||||
* Priority levels for context ordering
|
||||
* Higher priority contexts appear first in the merged output
|
||||
*/
|
||||
export type ContextPriority = "critical" | "high" | "normal" | "low";
|
||||
/**
|
||||
* A single context entry registered by a source
|
||||
*/
|
||||
export interface ContextEntry {
|
||||
/** Unique identifier for this entry within the source */
|
||||
id: string;
|
||||
/** The source that registered this context */
|
||||
source: ContextSourceType;
|
||||
/** The actual context content to inject */
|
||||
content: string;
|
||||
/** Priority for ordering (default: normal) */
|
||||
priority: ContextPriority;
|
||||
/** Monotonic order when registered */
|
||||
registrationOrder: number;
|
||||
/** Optional metadata for debugging/logging */
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* Options for registering context
|
||||
*/
|
||||
export interface RegisterContextOptions {
|
||||
/** Unique ID for this context entry (used for deduplication) */
|
||||
id: string;
|
||||
/** Source identifier */
|
||||
source: ContextSourceType;
|
||||
/** The content to inject */
|
||||
content: string;
|
||||
/** Priority for ordering (default: normal) */
|
||||
priority?: ContextPriority;
|
||||
/** Optional metadata */
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* Result of getting pending context for a session
|
||||
*/
|
||||
export interface PendingContext {
|
||||
/** Merged context string, ready for injection */
|
||||
merged: string;
|
||||
/** Individual entries that were merged */
|
||||
entries: ContextEntry[];
|
||||
/** Whether there's any content to inject */
|
||||
hasContent: boolean;
|
||||
}
|
||||
/**
|
||||
* Message context from the original user message
|
||||
* Used when injecting to match the message format
|
||||
*/
|
||||
export interface MessageContext {
|
||||
agent?: string;
|
||||
model?: {
|
||||
providerID?: string;
|
||||
modelID?: string;
|
||||
};
|
||||
path?: {
|
||||
cwd?: string;
|
||||
root?: string;
|
||||
};
|
||||
tools?: Record<string, boolean>;
|
||||
}
|
||||
/**
|
||||
* Output parts from chat.message hook
|
||||
*/
|
||||
export interface OutputParts {
|
||||
parts: Array<{
|
||||
type: string;
|
||||
text?: string;
|
||||
[key: string]: unknown;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* Injection strategy
|
||||
*/
|
||||
export type InjectionStrategy = "prepend-parts" | "storage" | "auto";
|
||||
Reference in New Issue
Block a user