Skip to content

feat(agent): design @typia/agent streaming function-calling harness interface#1905

Open
samchon wants to merge 2 commits into
masterfrom
feat/agent
Open

feat(agent): design @typia/agent streaming function-calling harness interface#1905
samchon wants to merge 2 commits into
masterfrom
feat/agent

Conversation

@samchon

@samchon samchon commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Intent

@typia/agent인터페이스 설계(타입 + 문서 전용) 1차 산출물. typia validation 위에 구축된, 벤더 중립 streaming function-calling harness의 타입 표면을 확정한다.

핵심 use-case가 타입 안전·자동완성되도록 모든 타입을 정렬했다:

const agent = new TypiaAgent({ adapter, controllers });
const response = await agent.conversate("Yaho~");
for await (const r of response) {
  if (r.type === "tool") {
    if ((await r.success()) === false) await r.feedback();
    else                               await r.execute();
  } else if (r.type === "text") {
    for await (const piece of r.stream()) console.log("piece", piece);
  }
}

Scope

  • IAgent/TypiaAgentconversate()IAgentExecution(async-iterable of IAgentResponse) 반환, iterator는 IAgentTurn 결과를 return.
  • Harness 표면 — incremental validation(IAgentValidation: snapshot/locked/watch/phase), IAgentTool parse→validate→feedback→execute state machine, output-token 천장 continuation.
  • IAgentAdapter — OpenAI/Vercel를 한 줄로 갈아끼우는 벤더 중립 chat-stream 시임. 통합 ILlmSchema 덕에 provider 지식은 adapter 안에만.
  • Controllers/operations(class | http | mcp | output), 대규모 함수용 IAgentSelector, 직렬화 가능한 IAgentHistory(.Json) 메모리, 부차 IAgentEvent telemetry.
  • 타입 하나당 파일 하나(namespace 중첩 없음). 근거는 packages/agent/ARCHITECTURE.md.

Deferred

  • 런타임 구현 없음(adapter 구현체 OpenAiAdapter/VercelAdapter + harness loop는 후속).
  • 테스트(tests/test-agent/)는 후속.

Test plan

  • tsgo --noEmit -p packages/agent/tsconfig.json → 클린(전체 타입 표면 정합).
  • prettier --write 적용(import 정렬 + repo의 prettier-plugin-jsdoc).
  • 주의: 이 패키지는 types-only이며 CI의 pnpm build(ttsc) 검증은 후속 작업이 필요할 수 있다.

🤖 Generated with Claude Code

samchon and others added 2 commits June 10, 2026 00:16
…nterface

Introduces the interface-only (types + docs) design for `@typia/agent`, a
vendor-neutral streaming function-calling harness built on typia's validation.

- `IAgent`/`TypiaAgent`: `conversate()` returns an `IAgentExecution` that is an
  async-iterable of `IAgentResponse` parts (`text | tool`) consumed with
  `for await`, and returns an `IAgentTurn` outcome.
- Harness surface: incremental validation (`IAgentValidation` snapshot/locked/
  watch/phase), the `IAgentTool` parse->validate->feedback->execute state
  machine, and output-token-ceiling continuation.
- `IAgentAdapter`: vendor-neutral chat-stream seam (OpenAI/Vercel), with the
  unified `ILlmSchema` keeping all provider knowledge inside the adapter.
- Controllers/operations (`class | http | mcp | output`), `IAgentSelector` for
  large function counts, serializable `IAgentHistory(.Json)` memory, and a
  secondary `IAgentEvent` telemetry channel.
- One type per file (no namespace nesting); `ARCHITECTURE.md` documents the
  rationale; `tsgo --noEmit` is clean.

Types only; no runtime implementation yet (adapters + harness loop follow).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 3, 2026 01:46
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​typescript/​native-preview@​7.0.0-dev.20260527.210010082100100

View full report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Introduces the initial types + documentation only surface for a new @typia/agent package, defining a vendor-neutral streaming function-calling harness API (adapter seam, incremental validation view, tool/text parts, histories, and telemetry events) without runtime implementation.

Changes:

  • Adds a new packages/agent package with build scaffolding and a types-only public API (IAgent/TypiaAgent, streaming IAgentExecution, IAgentTool/IAgentText parts).
  • Defines a vendor-neutral adapter contract (IAgentAdapter + streamed chunk model) and the harness-facing incremental validation interfaces.
  • Adds package-level docs (ARCHITECTURE.md, INSTRUCTION.md) and updates repo ignore rules for research folders.

Reviewed changes

Copilot reviewed 74 out of 76 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds packages/agent importer dependency graph.
packages/agent/tsconfig.json Adds TS build config for the new package.
packages/agent/src/TypiaAgent.ts Declares the TypiaAgent facade class (types-only).
packages/agent/src/structures/IAgentTokenUsageOutput.ts Adds output token usage breakdown type.
packages/agent/src/structures/IAgentTokenUsageInput.ts Adds input token usage breakdown type.
packages/agent/src/structures/IAgentTokenUsage.ts Adds aggregate token usage accounting type.
packages/agent/src/structures/IAgentTextDeltaChunk.ts Adds adapter text-delta chunk type.
packages/agent/src/structures/IAgentTextContent.ts Adds multimodal text content-part type.
packages/agent/src/structures/IAgentSystemPrompt.ts Adds system-prompt override shape.
packages/agent/src/structures/IAgentSelectorProps.ts Adds selector input props type.
packages/agent/src/structures/IAgentSelector.ts Adds “many tools” selection strategy interface.
packages/agent/src/structures/IAgentRawChunk.ts Adds raw passthrough provider chunk type.
packages/agent/src/structures/IAgentProps.ts Adds agent constructor props type.
packages/agent/src/structures/IAgentOutputOperation.ts Adds structured-output operation protocol type.
packages/agent/src/structures/IAgentOperationBase.ts Adds shared operation header shape.
packages/agent/src/structures/IAgentOperation.ts Adds operation union type.
packages/agent/src/structures/IAgentMessageContent.ts Adds multimodal message content-part union.
packages/agent/src/structures/IAgentMessage.ts Adds provider-neutral message type.
packages/agent/src/structures/IAgentMcpOperation.ts Adds MCP-backed operation shape.
packages/agent/src/structures/IAgentMcpController.ts Adds MCP controller shape.
packages/agent/src/structures/IAgentImageContent.ts Adds multimodal image content-part type.
packages/agent/src/structures/IAgentHttpOperation.ts Adds HTTP-backed operation shape.
packages/agent/src/structures/IAgentHttpExecuteProps.ts Adds custom HTTP executor input type.
packages/agent/src/structures/IAgentHttpController.ts Adds HTTP controller shape.
packages/agent/src/structures/IAgentFinishReason.ts Adds normalized finish reason union.
packages/agent/src/structures/IAgentFinishChunk.ts Adds adapter finish chunk (reason + usage).
packages/agent/src/structures/IAgentFileContent.ts Adds multimodal file content-part type.
packages/agent/src/structures/IAgentErrorChunk.ts Adds adapter error chunk type.
packages/agent/src/structures/IAgentConversateOptions.ts Adds per-turn conversate options type.
packages/agent/src/structures/IAgentController.ts Adds controller union type.
packages/agent/src/structures/IAgentContinuation.ts Adds ceiling-continuation policy type.
packages/agent/src/structures/IAgentConfig.ts Adds agent tuning configuration type.
packages/agent/src/structures/IAgentCompaction.ts Adds history compaction hook type.
packages/agent/src/structures/IAgentClassOperation.ts Adds class-backed operation shape.
packages/agent/src/structures/IAgentClassExecuteProps.ts Adds class dispatch/proxy executor input type.
packages/agent/src/structures/IAgentClassController.ts Adds class controller shape.
packages/agent/src/structures/IAgentChunk.ts Adds adapter chunk union type.
packages/agent/src/structures/IAgentAudioContent.ts Adds multimodal audio content-part type.
packages/agent/src/structures/IAgentAdapterRequest.ts Adds vendor-neutral adapter request type.
packages/agent/src/structures/IAgentAdapterCapabilities.ts Adds adapter capability advertisement type.
packages/agent/src/structures/IAgentAdapter.ts Adds vendor-neutral streaming adapter interface.
packages/agent/src/responses/IAgentValidationState.ts Adds incremental validation tick/state type.
packages/agent/src/responses/IAgentValidation.ts Adds incremental validation interface contract.
packages/agent/src/responses/IAgentTurn.ts Adds terminal turn result type returned by iterator.
packages/agent/src/responses/IAgentTool.ts Adds streamed tool-call part state machine interface.
packages/agent/src/responses/IAgentText.ts Adds streamed assistant text part interface.
packages/agent/src/responses/IAgentResponse.ts Adds response-part discriminated union type.
packages/agent/src/responses/IAgentFeedbackProps.ts Adds tool feedback/correction input type.
packages/agent/src/responses/IAgentExecution.ts Adds async-iterable execution surface (+ join/abort).
packages/agent/src/responses/IAgentExecute.ts Adds tool execution record type.
packages/agent/src/index.ts Adds public export surface for the package.
packages/agent/src/IAgent.ts Adds main agent contract interface.
packages/agent/src/histories/IAgentToolHistoryJson.ts Adds serialized tool history mirror type.
packages/agent/src/histories/IAgentToolHistory.ts Adds live tool history record type.
packages/agent/src/histories/IAgentTextHistoryJson.ts Adds serialized text history mirror type.
packages/agent/src/histories/IAgentTextHistory.ts Adds live text history record type.
packages/agent/src/histories/IAgentSystemHistoryJson.ts Adds serialized system history mirror type.
packages/agent/src/histories/IAgentSystemHistory.ts Adds live system history record type.
packages/agent/src/histories/IAgentHistoryJson.ts Adds serialized history union type.
packages/agent/src/histories/IAgentHistoryBase.ts Adds shared history header type.
packages/agent/src/histories/IAgentHistory.ts Adds live history union type.
packages/agent/src/events/IAgentValidateEvent.ts Adds validation telemetry event type.
packages/agent/src/events/IAgentUsageEvent.ts Adds usage telemetry event type.
packages/agent/src/events/IAgentResponseEvent.ts Adds adapter-response telemetry event type.
packages/agent/src/events/IAgentRequestEvent.ts Adds adapter-request telemetry event type.
packages/agent/src/events/IAgentParseEvent.ts Adds parse telemetry event type.
packages/agent/src/events/IAgentEventSource.ts Adds event source phase union type.
packages/agent/src/events/IAgentEventMapper.ts Adds event discriminator→payload mapping.
packages/agent/src/events/IAgentEventBase.ts Adds shared event header type.
packages/agent/src/events/IAgentEvent.ts Adds event union type.
packages/agent/src/events/IAgentContinuationEvent.ts Adds continuation telemetry event type.
packages/agent/rollup.config.mjs Adds rollup config forwarding to repo config.
packages/agent/package.json Adds new package manifest and publish config.
packages/agent/INSTRUCTION.md Adds package-level instruction/notes document.
packages/agent/ARCHITECTURE.md Adds architecture/design documentation for the new package.
.gitignore Ignores .repositories/ research clone folder.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,36 @@
나는 `@typia/agent` 라이브러리를 만들고자 하노라.

다음 두 가지 아티클을 핵심 철학으로 삼을 것이며, 이 중 특히 Lenient JSDN parsing + function calling 내지 structured output의 streaming을 위해 달리는 것이니라.
- https://typia.io/blog/function-calling-harness-qwen-meetup-korea/
- https://typia.io/blog/function-calling-harness-2-cot-compliance/

그리고 `D:/github/wrtnlabs/agentica`를 보면, 이벤트에 기반하여 functino calling 프레임워크를 만들었음을 알 수 있다. `@typia/agent`도 이 중 `MicroAgentica`와 같은 기능을 만들 것이되, agentica처럼 tools 기능을 쓰는게 아니라, text streaming response를 통해 출력 가능 최대 토큰량의 제한을 뛰어넘을 것이며, function callling harness에 나오는 incremental validation을 이룩할 것이다.
}
} else if (r.type === "text") {
for await (const piece of r.stream()) {
consoole.log("piece", piece);
Comment on lines +42 to +48
"files": [
"README.md",
"INSTRUCTION.md",
"package.json",
"lib",
"src"
],
Comment on lines +17 to +18
/** 함수 이름. */
function: string;
Comment on lines +1 to +14
import { IAgentTokenUsage } from "../structures/IAgentTokenUsage";
import { IAgentEventBase } from "./IAgentEventBase";
import { IAgentEventSource } from "./IAgentEventSource";

/**
* 보고된 usage를 담은, 완료된 adapter 응답.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IAgentResponseEvent extends IAgentEventBase<"response"> {
source: IAgentEventSource;
usage: IAgentTokenUsage;
finishReason: string;
}
Comment on lines +1 to +14
import { IAgentEventBase } from "./IAgentEventBase";

/**
* Ceiling-continuation이 수행됨(출력이 단일 completion을 초과).
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IAgentContinuationEvent extends IAgentEventBase<"continuation"> {
/** 현재 답변 내 이 continuation의 1-based 인덱스. */
index: number;

/** 이를 trigger한 finish 사유(대개 `"length"`). */
trigger: string;
}
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.

2 participants