refactor(core): consolidate references

This commit is contained in:
Dax Raad 2026-06-09 11:38:35 -04:00
commit f76ca58a54
63 changed files with 683 additions and 2722 deletions

View file

@ -172,8 +172,6 @@ import type {
QuestionReplyErrors,
QuestionReplyResponses,
QuestionV2Reply,
ReferenceListErrors,
ReferenceListResponses,
SessionAbortErrors,
SessionAbortResponses,
SessionChildrenErrors,
@ -288,6 +286,8 @@ import type {
V2ProviderListResponses,
V2QuestionRequestListErrors,
V2QuestionRequestListResponses,
V2ReferenceListErrors,
V2ReferenceListResponses,
V2SessionCompactErrors,
V2SessionCompactResponses,
V2SessionContextErrors,
@ -3335,38 +3335,6 @@ export class Provider extends HeyApiClient {
}
}
export class Reference extends HeyApiClient {
/**
* List configured references
*
* List configured references resolved in the current workspace.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<ReferenceListResponses, ReferenceListErrors, ThrowOnError>({
url: "/reference",
...options,
...params,
})
}
}
export class Session2 extends HeyApiClient {
/**
* List sessions
@ -5580,7 +5548,6 @@ export class Fs extends HeyApiClient {
workspace?: string
}
path: string
reference?: string
},
options?: Options<never, ThrowOnError>,
) {
@ -5591,7 +5558,6 @@ export class Fs extends HeyApiClient {
args: [
{ in: "query", key: "location" },
{ in: "query", key: "path" },
{ in: "query", key: "reference" },
],
},
],
@ -5615,7 +5581,6 @@ export class Fs extends HeyApiClient {
workspace?: string
}
path?: string
reference?: string
},
options?: Options<never, ThrowOnError>,
) {
@ -5626,7 +5591,6 @@ export class Fs extends HeyApiClient {
args: [
{ in: "query", key: "location" },
{ in: "query", key: "path" },
{ in: "query", key: "reference" },
],
},
],
@ -5746,6 +5710,30 @@ export class Question3 extends HeyApiClient {
}
}
export class Reference extends HeyApiClient {
/**
* List references
*
* List references available in the requested location.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
location?: {
directory?: string
workspace?: string
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "location" }] }])
return (options?.client ?? this.client).get<V2ReferenceListResponses, V2ReferenceListErrors, ThrowOnError>({
url: "/api/reference",
...options,
...params,
})
}
}
export class V2 extends HeyApiClient {
private _health?: Health
get health(): Health {
@ -5801,6 +5789,11 @@ export class V2 extends HeyApiClient {
get question(): Question3 {
return (this._question ??= new Question3({ client: this.client }))
}
private _reference?: Reference
get reference(): Reference {
return (this._reference ??= new Reference({ client: this.client }))
}
}
export class OpencodeClient extends HeyApiClient {
@ -5921,11 +5914,6 @@ export class OpencodeClient extends HeyApiClient {
return (this._provider ??= new Provider({ client: this.client }))
}
private _reference?: Reference
get reference(): Reference {
return (this._reference ??= new Reference({ client: this.client }))
}
private _session?: Session2
get session(): Session2 {
return (this._session ??= new Session2({ client: this.client }))

View file

@ -57,6 +57,7 @@ export type Event =
| EventAccountSwitched
| EventPermissionV2Asked
| EventPermissionV2Replied
| EventReferenceUpdated
| EventFileWatcherUpdated
| EventPtyCreated
| EventPtyUpdated
@ -633,7 +634,6 @@ export type Prompt = {
text: string
files?: Array<PromptFileAttachment>
agents?: Array<PromptAgentAttachment>
references?: Array<PromptReferenceAttachment>
}
export type Pty = {
@ -1296,6 +1296,13 @@ export type GlobalEvent = {
reply: PermissionV2Reply
}
}
| {
id: string
type: "reference.updated"
properties: {
[key: string]: unknown
}
}
| {
id: string
type: "file.watcher.updated"
@ -2590,26 +2597,6 @@ export type ProviderAuthError1 = {
}
}
export type ReferenceDescriptor =
| {
name: string
kind: "local"
path: string
}
| {
name: string
kind: "git"
repository: string
path: string
branch?: string
}
| {
name: string
kind: "invalid"
repository?: string
message: string
}
export type NotFoundError = {
name: "NotFoundError"
data: {
@ -2986,18 +2973,6 @@ export type PromptAgentAttachment = {
source?: PromptSource
}
export type PromptReferenceAttachment = {
name: string
kind: "local" | "git" | "invalid"
uri?: string
repository?: string
branch?: string
target?: string
targetUri?: string
problem?: string
source?: PromptSource
}
export type SessionErrorUnknown = {
type: "unknown"
message: string
@ -3896,7 +3871,6 @@ export type SessionMessageUser = {
text: string
files?: Array<PromptFileAttachment>
agents?: Array<PromptAgentAttachment>
references?: Array<PromptReferenceAttachment>
type: "user"
}
@ -4212,6 +4186,23 @@ export type QuestionV2Reply = {
answers: Array<QuestionV2Answer>
}
export type ReferenceLocalSource = {
type: "local"
path: string
}
export type ReferenceGitSource = {
type: "git"
repository: string
branch?: string
}
export type ReferenceInfo = {
name: string
path: string
source: ReferenceLocalSource | ReferenceGitSource
}
export type EventModelsDevRefreshed = {
id: string
type: "models-dev.refreshed"
@ -4933,6 +4924,14 @@ export type EventPermissionV2Replied = {
}
}
export type EventReferenceUpdated = {
id: string
type: "reference.updated"
properties: {
[key: string]: unknown
}
}
export type EventFileWatcherUpdated = {
id: string
type: "file.watcher.updated"
@ -7640,34 +7639,6 @@ export type ProviderOauthCallbackResponses = {
export type ProviderOauthCallbackResponse = ProviderOauthCallbackResponses[keyof ProviderOauthCallbackResponses]
export type ReferenceListData = {
body?: never
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/reference"
}
export type ReferenceListErrors = {
/**
* Bad request
*/
400: BadRequestError
}
export type ReferenceListError = ReferenceListErrors[keyof ReferenceListErrors]
export type ReferenceListResponses = {
/**
* Resolved configured references
*/
200: Array<ReferenceDescriptor>
}
export type ReferenceListResponse = ReferenceListResponses[keyof ReferenceListResponses]
export type SessionListData = {
body?: never
path?: never
@ -10098,7 +10069,6 @@ export type V2FsReadData = {
workspace?: string
}
path: string
reference?: string
}
url: "/api/fs/read"
}
@ -10137,7 +10107,6 @@ export type V2FsListData = {
workspace?: string
}
path?: string
reference?: string
}
url: "/api/fs/list"
}
@ -10384,6 +10353,43 @@ export type V2SessionQuestionRejectResponses = {
export type V2SessionQuestionRejectResponse = V2SessionQuestionRejectResponses[keyof V2SessionQuestionRejectResponses]
export type V2ReferenceListData = {
body?: never
path?: never
query?: {
location?: {
directory?: string
workspace?: string
}
}
url: "/api/reference"
}
export type V2ReferenceListErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
}
export type V2ReferenceListError = V2ReferenceListErrors[keyof V2ReferenceListErrors]
export type V2ReferenceListResponses = {
/**
* Success
*/
200: {
location: LocationInfo
data: Array<ReferenceInfo>
}
}
export type V2ReferenceListResponse = V2ReferenceListResponses[keyof V2ReferenceListResponses]
export type PtyConnectData = {
body?: never
path: {

View file

@ -5400,64 +5400,6 @@
]
}
},
"/reference": {
"get": {
"tags": ["reference"],
"operationId": "reference.list",
"parameters": [
{
"name": "directory",
"in": "query",
"schema": {
"type": "string"
},
"required": false
},
{
"name": "workspace",
"in": "query",
"schema": {
"type": "string"
},
"required": false
}
],
"responses": {
"200": {
"description": "Resolved configured references",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ReferenceDescriptor"
},
"description": "Resolved configured references"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BadRequestError"
}
}
}
}
},
"description": "List configured references resolved in the current workspace.",
"summary": "List configured references",
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.reference.list({\n ...\n})"
}
]
}
},
"/session": {
"get": {
"tags": ["session"],
@ -11414,14 +11356,6 @@
"type": "string"
},
"required": true
},
{
"name": "reference",
"in": "query",
"schema": {
"type": "string"
},
"required": false
}
],
"security": [],
@ -11515,14 +11449,6 @@
"type": "string"
},
"required": false
},
{
"name": "reference",
"in": "query",
"schema": {
"type": "string"
},
"required": false
}
],
"security": [],
@ -12062,6 +11988,87 @@
]
}
},
"/api/reference": {
"get": {
"tags": ["reference"],
"operationId": "v2.reference.list",
"parameters": [
{
"name": "location",
"in": "query",
"schema": {
"type": "object",
"properties": {
"directory": {
"type": "string"
},
"workspace": {
"type": "string"
}
},
"additionalProperties": false
},
"required": false,
"style": "deepObject",
"explode": true
}
],
"security": [],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"location": {
"$ref": "#/components/schemas/LocationInfo"
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ReferenceInfo"
}
}
},
"required": ["location", "data"],
"additionalProperties": false
}
}
}
},
"400": {
"description": "InvalidRequestError",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InvalidRequestError"
}
}
}
},
"401": {
"description": "UnauthorizedError",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UnauthorizedError"
}
}
}
}
},
"description": "List references available in the requested location.",
"summary": "List references",
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.v2.reference.list({\n ...\n})"
}
]
}
},
"/pty/{ptyID}/connect": {
"get": {
"tags": ["pty"],
@ -14068,12 +14075,6 @@
"items": {
"$ref": "#/components/schemas/PromptAgentAttachment"
}
},
"references": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PromptReferenceAttachment"
}
}
},
"required": ["text"],
@ -20041,70 +20042,6 @@
"required": ["name", "data"],
"additionalProperties": false
},
"ReferenceDescriptor": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": ["local"]
},
"path": {
"type": "string"
}
},
"required": ["name", "kind", "path"],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": ["git"]
},
"repository": {
"type": "string"
},
"path": {
"type": "string"
},
"branch": {
"type": "string"
}
},
"required": ["name", "kind", "repository", "path"],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": ["invalid"]
},
"repository": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": ["name", "kind", "message"],
"additionalProperties": false
}
]
},
"NotFoundError": {
"type": "object",
"required": ["name", "data"],
@ -21498,41 +21435,6 @@
"required": ["name"],
"additionalProperties": false
},
"PromptReferenceAttachment": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": ["local", "git", "invalid"]
},
"uri": {
"type": "string"
},
"repository": {
"type": "string"
},
"branch": {
"type": "string"
},
"target": {
"type": "string"
},
"targetUri": {
"type": "string"
},
"problem": {
"type": "string"
},
"source": {
"$ref": "#/components/schemas/PromptSource"
}
},
"required": ["name", "kind"],
"additionalProperties": false
},
"SessionErrorUnknown": {
"type": "object",
"properties": {
@ -24339,12 +24241,6 @@
"$ref": "#/components/schemas/PromptAgentAttachment"
}
},
"references": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PromptReferenceAttachment"
}
},
"type": {
"type": "string",
"enum": ["user"]
@ -25214,6 +25110,60 @@
"required": ["answers"],
"additionalProperties": false
},
"ReferenceLocalSource": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["local"]
},
"path": {
"type": "string"
}
},
"required": ["type", "path"],
"additionalProperties": false
},
"ReferenceGitSource": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["git"]
},
"repository": {
"type": "string"
},
"branch": {
"type": "string"
}
},
"required": ["type", "repository"],
"additionalProperties": false
},
"ReferenceInfo": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"path": {
"type": "string"
},
"source": {
"anyOf": [
{
"$ref": "#/components/schemas/ReferenceLocalSource"
},
{
"$ref": "#/components/schemas/ReferenceGitSource"
}
]
}
},
"required": ["name", "path", "source"],
"additionalProperties": false
},
"EventModels-devRefreshed": {
"type": "object",
"properties": {
@ -28767,10 +28717,6 @@
"name": "provider",
"description": "Experimental HttpApi provider routes."
},
{
"name": "reference",
"description": "Configured reference routes."
},
{
"name": "session",
"description": "Experimental HttpApi session routes."
@ -28835,6 +28781,10 @@
"name": "session questions",
"description": "Experimental session question routes."
},
{
"name": "reference",
"description": "Location-scoped project references."
},
{
"name": "pty",
"description": "PTY websocket route."