@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
57 lines • 3.23 kB
TypeScript
import type { AnthropicSubscriptionAuthLane } from "./options.ts";
import type { Options } from "./sdk-boundary.ts";
import { type AnthropicSubscriptionSessionEntry } from "./session-registry.ts";
export type ContinuityBinding = {
senpiSessionId: string;
sdkSessionId: string;
sentCount: number;
sentHashes: readonly string[];
sentPrefixHash?: string;
/**
* False while the SDK has not yet acknowledged this session id (no init and
* no replay echo): continuity must never resume or fork such an id.
*/
sdkSessionIdConfirmed?: boolean;
lastAssistantUuid: string | null;
accountName: string;
modelId: string;
systemPromptHash: string;
toolsetHash: string;
/** Assistant boundaries kept as entries so a later fork still has a resume point. */
assistantUuidByIndex?: readonly (readonly [number, string])[];
/**
* Digest of the FULL sent stream an attempt pushed but never got answered
* (stream-start timeout abort/failure). Purely in-memory: it lets the SAME
* turn's retry fork at the pre-turn boundary instead of re-appending its user
* message to a lineage that already carries it. Never persisted — the sidecar
* schema is fixed at schemaVersion 1 and restart retries are out of scope.
*/
unansweredTurnDigest?: string;
};
export type ReattachInput = {
binding: ContinuityBinding;
options: Options;
atUuid?: string;
signal?: AbortSignal;
};
export type AbortOutcome = "keep" | "reattach";
export declare function evaluateAbortOutcome(receipt: unknown): AbortOutcome;
export declare function rememberBinding(binding: ContinuityBinding): void;
export declare function getBinding(senpiSessionId: string): ContinuityBinding | undefined;
export declare function forgetBinding(senpiSessionId: string): void;
export declare function rememberBindingInvalidation(senpiSessionId: string, reason: string | undefined): void;
export declare function bindingInvalidationReason(senpiSessionId: string): string | undefined;
export declare function bindingFromEntry(entry: Pick<AnthropicSubscriptionSessionEntry, "senpiSessionId" | "sdkSessionId" | "sentCount" | "accountName" | "modelId" | "systemPromptHash" | "toolsetHash" | "assistantUuidByIndex" | "sdkSessionIdConfirmed">, sentHashes: readonly string[]): ContinuityBinding;
/**
* Closes the live process but keeps its lineage resumable. A switch still waiting for Claude Code's confirmation is
* recorded on the model it selects, so the next turn on that model resumes instead of re-sending (senpi#6411).
*/
export declare function keepBindingThenClose(senpiSessionId: string, reason: string): void;
export declare function verifyRestoredTranscript(binding: ContinuityBinding, cwd: string, authLane: AnthropicSubscriptionAuthLane): Promise<boolean>;
/**
* A new query is not a new session: `resume` re-attaches to the existing lineage.
* `sessionId` must stay absent unless forking, because the SDK rejects the pair
* (sdk.d.ts:1805-1808) and would otherwise silently start an unrelated session.
*/
export declare function reattachSession(input: ReattachInput): Promise<AnthropicSubscriptionSessionEntry>;
//# sourceMappingURL=session-reattach.d.ts.map