e2e

package
v0.0.0-...-88b6a2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

The harness-side CANNED model backend (RIG-1787 H3): a tiny host-side HTTP server that speaks the openai-completions streaming SSE contract the agent's SDK provider dials, so a leg-2 turn settles on a deterministic scripted reply with ZERO live-model egress. It is the model backend the custom `openai-completions` models.yml provider's baseUrl points at.

This file is DELIBERATELY UNTAGGED (no `//go:build podman`): the stub is pure net/http with no container dependency, so it compiles in the hermetic (non-podman) unit lane where cannedmodel_test.go exercises it, AND is consumed by the podman-tagged fixture. A Go package freely mixes tagged and untagged files; keeping the stub untagged is what lets its red->green unit test run under `moon run compass-go:test` without podman.

Grounded against the SDK parser firsthand, at the 18.0.11 pin (`packages/compass-agent/package.json`) — @oh-my-pi/pi-ai, and @oh-my-pi/pi-utils via pi-ai's dependency edge (openai-http.ts:17), which is transitive rather than a declared compass dependency:

  • The provider POSTs to `baseUrl + /chat/completions` (providers/openai-completions.ts:752-753) with `Accept: text/event-stream` (utils/openai-http.ts:93, in postOpenAIStream).
  • The response is decoded by readSseJson: each `data:` line is JSON-parsed into a ChatCompletionChunk, and the literal `data: [DONE]` ends the stream (pi-utils src/stream.ts:239-262 — the [DONE] return at :248-249, the JSON.parse at :253).
  • Each chunk's `choices[0].delta.content` string is appended as assistant text (providers/openai-completions.ts:1216), and `choices[0].finish_reason` maps the stop reason (:1180-1181); "stop" is a clean settle (mapStopReason :2504, its `case "stop"` at :2515-2517). A single text chunk + a terminal finish chunk + [DONE] is the minimal well-formed leg-2 turn (no tool calls).

These coordinates are pinned to a mutable npm dependency, not an in-repo tree: re-derive them at an SDK bump rather than trusting them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CannedTurn

type CannedTurn struct {
	// contains filtered or unexported fields
}

CannedTurn is one scripted model round-trip the canned backend serves: either a pure-text turn (delta.content + finish_reason "stop") or a single-tool-call turn (a one-element delta.tool_calls + finish_reason "tool_calls"). Build one with CannedText or CannedToolCall — the zero value is not a valid turn. The server serves an ordered script of these, one per request (request N serves script[N]), so a multi-round agent scenario advances one scripted turn per model round-trip.

func CannedText

func CannedText(reply string) CannedTurn

CannedText builds a pure-text scripted turn: the assistant settles on reply with a clean finish_reason "stop". This is the pre-script single-reply behavior, now expressed as one turn.

func CannedToolCall

func CannedToolCall(toolName, argsJSON string) CannedTurn

CannedToolCall builds a single-tool-call scripted turn: the assistant emits one tool call naming toolName with argsJSON as its arguments (passed already serialized as a JSON string, the OpenAI contract) and a finish_reason "tool_calls" (which maps to stopReason toolUse the agent loop gates tool execution on, openai-completions.ts:2364-2365). The server assigns a unique deterministic call id per served turn.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL