Files
shannon/apps/worker/src/ai/structured-generation.ts
T
ajmallesh 2469e6deac chore(license): attribute Mantis and Pi and refresh the docs
Add the final Mantis and Pi notices, license copies, acknowledgements, and residual copyright updates.

Update the README, maintained documentation, contributor guidance, and hand-maintained mirrors to describe Agentic
SAST, reconciliation, the Miscellaneous lane, current CLI behavior, and the final release contract. Correct stale
workspace and container guidance and annotate long-standing internals for maintainers.
2026-08-26 20:19:41 -07:00

44 lines
1.5 KiB
TypeScript

// Copyright (C) 2026 Keygraph, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License version 3
// as published by the Free Software Foundation.
/** One structured-generation request with exactly one output-schema tool. */
export interface StructuredGenerationRequest {
systemPrompt?: string;
userContent: string;
tool: {
name: 'submit_result';
description: string;
parametersJsonSchema: Record<string, unknown>;
};
maxTokens: number;
signal?: AbortSignal;
}
/** Typed classification of a failed provider request, set whenever `errorMessage` is. */
export interface StructuredGenerationProviderFailure {
readonly type: 'AuthenticationError' | 'ConfigurationError' | 'AgentExecutionError';
readonly retryable: boolean;
}
/** Host-neutral outcome of one structured generation request. */
export interface StructuredGenerationResult {
stopReason: 'toolUse' | 'stop' | 'length' | 'error' | 'aborted';
toolCalls: Array<{ name: string; arguments: unknown }>;
usage: {
inputTokens: number;
outputTokens: number;
costUsd: number;
};
errorMessage?: string;
/** Consumers branch on this typed flag, never on `errorMessage` text. */
providerFailure?: StructuredGenerationProviderFailure;
}
/** Host-supplied transport that makes exactly one model request per call. */
export interface StructuredGenerationPort<TModelContext> {
generate(request: StructuredGenerationRequest, modelContext: TModelContext): Promise<StructuredGenerationResult>;
}