Skip to content

feat(ai): add AI stream types - #81

Merged
Reversean merged 1 commit into
masterfrom
feat/ai-stream-part
Sep 2, 2026
Merged

feat(ai): add AI stream types#81
Reversean merged 1 commit into
masterfrom
feat/ai-stream-part

Conversation

@Reversean

Copy link
Copy Markdown
Member

AiStreamPart carries an answer received by model and converted for further rendering.

Currently it unites following types: AiStreamTextDeltaPart (text increments) and AiStreamErrorPart (failure description).

AiStream carries part sequence asynchronously.

Tsconfig target moves from es6 to es2024 because AsyncIterable type is delivered only since es2018.

AiStreamPart carries an answer received by model and converted for
further rendering.

Currently it unites following types: AiStreamTextDeltaPart (text
increments) and AiStreamErrorPart (failure description).

AiStream carries part sequence asynchronously.

Tsconfig target moves from es6 to es2018 because AsyncIterable type is
delivered only since es2018.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The PR is small and additive, with only minor consistency/alignment nits noted that do not affect correctness.

Pull request overview

Adds foundational AI streaming type definitions to @hawk.so/types so downstream code can model AI-generated responses as an async sequence of discriminated “parts”.

Changes:

  • Introduces AiStreamTextDeltaPart, AiStreamErrorPart, AiStreamPart, and AiStream types under src/ai/stream.ts.
  • Exports the new AI stream types from the root index.ts (and corresponding build outputs).
  • Updates TypeScript compilation target to es2018 and bumps package version to 0.7.0.
File summaries
File Description
tsconfig.json Updates TS target to es2018 to support async-iterable typing during build.
src/ai/stream.ts Adds the new AI stream part and stream type definitions.
index.ts Re-exports AI stream types from the package entrypoint.
package.json Bumps package version to 0.7.0.
build/src/ai/stream.js Generated JS stub for the new module.
build/src/ai/stream.d.ts Generated type declarations for AI stream types.
build/index.js Re-exports the new build module at runtime entrypoint.
build/index.d.ts Re-exports the new type module at types entrypoint.
Review details

Suppressed comments (1)

src/ai/stream.ts:19

  • This object-shaped export is declared as a type alias, but the codebase overwhelmingly uses export interface for object types (e.g. src/auth/tokensPair.ts, src/dbScheme/promoCode.ts). Using an interface here improves consistency and makes future extension/augmentation easier.
export type AiStreamErrorPart = {
  • Files reviewed: 5/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ai/stream.ts
Comment on lines +4 to +14
export type AiStreamTextDeltaPart = {
/**
* Discriminant of a text-carrying part.
*/
type: 'text-delta';

/**
* Text generated for this part.
*/
delta: string;
};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These stay type because they're members of a discriminated union that gets exhaustively matched on .type – an interface can be reopened and merged into by any importer, so a variant's shape would no longer be fixed by its declaration, while interface still fits standalone, extendable shapes elsewhere in the package.

@Reversean
Reversean merged commit e6b69d3 into master Sep 2, 2026
2 of 4 checks passed
@Reversean
Reversean deleted the feat/ai-stream-part branch September 2, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants