feat(core): port v2 command invocation (#34849)

This commit is contained in:
Aiden Cline 2026-07-02 11:22:04 -05:00 committed by GitHub
commit c176baee82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1445 additions and 179 deletions

View file

@ -142,7 +142,9 @@ import type {
ProjectListResponses,
ProjectUpdateErrors,
ProjectUpdateResponses,
PromptAgentAttachment,
PromptInput,
PromptInputFileAttachment,
ProviderAuthErrors,
ProviderAuthResponses,
ProviderListErrors,
@ -181,6 +183,7 @@ import type {
SessionChildrenResponses,
SessionCommandErrors,
SessionCommandResponses,
SessionContextEntryKey,
SessionCreateErrors,
SessionCreateResponses,
SessionDeleteErrors,
@ -349,8 +352,16 @@ import type {
V2SessionActiveResponses,
V2SessionBackgroundErrors,
V2SessionBackgroundResponses,
V2SessionCommandErrors,
V2SessionCommandResponses,
V2SessionCompactErrors,
V2SessionCompactResponses,
V2SessionContextEntryListErrors,
V2SessionContextEntryListResponses,
V2SessionContextEntryPutErrors,
V2SessionContextEntryPutResponses,
V2SessionContextEntryRemoveErrors,
V2SessionContextEntryRemoveResponses,
V2SessionContextErrors,
V2SessionContextResponses,
V2SessionCreateErrors,
@ -5224,6 +5235,113 @@ export class Revert extends HeyApiClient {
}
}
export class Entry extends HeyApiClient {
/**
* List context entries
*
* List API-managed context entries attached to the session's system context.
*/
public list<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "sessionID" }] }])
return (options?.client ?? this.client).get<
V2SessionContextEntryListResponses,
V2SessionContextEntryListErrors,
ThrowOnError
>({
url: "/api/session/{sessionID}/context-entry",
...options,
...params,
})
}
/**
* Remove context entry
*
* Remove one context entry; the removal is announced to the model at the next turn boundary.
*/
public remove<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
key: SessionContextEntryKey
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "path", key: "key" },
],
},
],
)
return (options?.client ?? this.client).delete<
V2SessionContextEntryRemoveResponses,
V2SessionContextEntryRemoveErrors,
ThrowOnError
>({
url: "/api/session/{sessionID}/context-entry/{key}",
...options,
...params,
})
}
/**
* Put context entry
*
* Attach or replace one durable context entry. The value is rendered into the session's system context; changes announce as updates at the next turn boundary.
*/
public put<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
key: SessionContextEntryKey
value?: unknown
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "path", key: "key" },
{ in: "body", key: "value" },
],
},
],
)
return (options?.client ?? this.client).put<
V2SessionContextEntryPutResponses,
V2SessionContextEntryPutErrors,
ThrowOnError
>({
url: "/api/session/{sessionID}/context-entry/{key}",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
}
export class Context extends HeyApiClient {
private _entry?: Entry
get entry(): Entry {
return (this._entry ??= new Entry({ client: this.client }))
}
}
export class Permission2 extends HeyApiClient {
/**
* List session permission requests
@ -5781,6 +5899,57 @@ export class Session3 extends HeyApiClient {
})
}
/**
* Run command
*
* Resolve a slash command into prompt input, admit it durably, and schedule execution unless resume is false.
*/
public command<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
id?: string
command?: string
arguments?: string
agent?: string
model?: ModelRef
files?: Array<PromptInputFileAttachment>
agents?: Array<PromptAgentAttachment>
delivery?: "steer" | "queue"
resume?: boolean
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "body", key: "id" },
{ in: "body", key: "command" },
{ in: "body", key: "arguments" },
{ in: "body", key: "agent" },
{ in: "body", key: "model" },
{ in: "body", key: "files" },
{ in: "body", key: "agents" },
{ in: "body", key: "delivery" },
{ in: "body", key: "resume" },
],
},
],
)
return (options?.client ?? this.client).post<V2SessionCommandResponses, V2SessionCommandErrors, ThrowOnError>({
url: "/api/session/{sessionID}/command",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* Activate skill
*
@ -6089,6 +6258,11 @@ export class Session3 extends HeyApiClient {
return (this._revert ??= new Revert({ client: this.client }))
}
private _context?: Context
get context2(): Context {
return (this._context ??= new Context({ client: this.client }))
}
private _permission?: Permission2
get permission(): Permission2 {
return (this._permission ??= new Permission2({ client: this.client }))

View file

@ -64,6 +64,7 @@ export type Event =
| EventPermissionV2Replied
| EventPluginAdded
| EventProjectDirectoriesUpdated
| EventCommandUpdated
| EventSkillUpdated
| EventFileWatcherUpdated
| EventPtyCreated
@ -1370,6 +1371,13 @@ export type GlobalEvent = {
projectID: string
}
}
| {
id: string
type: "command.updated"
properties: {
[key: string]: unknown
}
}
| {
id: string
type: "skill.updated"
@ -2840,6 +2848,18 @@ export type ConflictError = {
resource?: string
}
export type CommandNotFoundError = {
_tag: "CommandNotFoundError"
command: string
message: string
}
export type CommandEvaluationError = {
_tag: "CommandEvaluationError"
command: string
message: string
}
export type SkillNotFoundError = {
_tag: "SkillNotFoundError"
skill: string
@ -3061,6 +3081,7 @@ export type V2Event =
| PermissionV2Replied
| PluginAdded
| ProjectDirectoriesUpdated
| CommandUpdated
| SkillUpdated
| FileWatcherUpdated
| PtyCreated
@ -4427,6 +4448,13 @@ export type SessionMessage =
| SessionMessageAssistant
| SessionMessageCompaction
export type SessionContextEntryKey = string
export type SessionContextEntryInfo = {
key: SessionContextEntryKey
value: unknown
}
export type SessionNextAgentSwitched = {
id: string
metadata?: {
@ -5923,6 +5951,23 @@ export type ProjectDirectoriesUpdated = {
}
}
export type CommandUpdated = {
id: string
metadata?: {
[key: string]: unknown
}
type: "command.updated"
durable?: {
aggregateID: string
seq: number
version: number
}
location?: LocationRef
data: {
[key: string]: unknown
}
}
export type SkillUpdated = {
id: string
metadata?: {
@ -7320,6 +7365,14 @@ export type EventProjectDirectoriesUpdated = {
}
}
export type EventCommandUpdated = {
id: string
type: "command.updated"
properties: {
[key: string]: unknown
}
}
export type EventSkillUpdated = {
id: string
type: "skill.updated"
@ -12307,6 +12360,61 @@ export type V2SessionPromptResponses = {
export type V2SessionPromptResponse = V2SessionPromptResponses[keyof V2SessionPromptResponses]
export type V2SessionCommandData = {
body: {
id?: string
command: string
arguments?: string
agent?: string
model?: ModelRef
files?: Array<PromptInputFileAttachment>
agents?: Array<PromptAgentAttachment>
delivery?: "steer" | "queue"
resume?: boolean
}
path: {
sessionID: string
}
query?: never
url: "/api/session/{sessionID}/command"
}
export type V2SessionCommandErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError | CommandNotFoundError
*/
404: CommandNotFoundError | SessionNotFoundError
/**
* ConflictError
*/
409: ConflictError
/**
* CommandEvaluationError
*/
500: CommandEvaluationError
}
export type V2SessionCommandError = V2SessionCommandErrors[keyof V2SessionCommandErrors]
export type V2SessionCommandResponses = {
/**
* Success
*/
200: {
data: SessionInputAdmitted
}
}
export type V2SessionCommandResponse = V2SessionCommandResponses[keyof V2SessionCommandResponses]
export type V2SessionSkillData = {
body: {
id?: string
@ -12644,6 +12752,121 @@ export type V2SessionContextResponses = {
export type V2SessionContextResponse = V2SessionContextResponses[keyof V2SessionContextResponses]
export type V2SessionContextEntryListData = {
body?: never
path: {
sessionID: string
}
query?: never
url: "/api/session/{sessionID}/context-entry"
}
export type V2SessionContextEntryListErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError
*/
404: SessionNotFoundError
}
export type V2SessionContextEntryListError = V2SessionContextEntryListErrors[keyof V2SessionContextEntryListErrors]
export type V2SessionContextEntryListResponses = {
/**
* Success
*/
200: {
data: Array<SessionContextEntryInfo>
}
}
export type V2SessionContextEntryListResponse =
V2SessionContextEntryListResponses[keyof V2SessionContextEntryListResponses]
export type V2SessionContextEntryRemoveData = {
body?: never
path: {
sessionID: string
key: SessionContextEntryKey
}
query?: never
url: "/api/session/{sessionID}/context-entry/{key}"
}
export type V2SessionContextEntryRemoveErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError
*/
404: SessionNotFoundError
}
export type V2SessionContextEntryRemoveError =
V2SessionContextEntryRemoveErrors[keyof V2SessionContextEntryRemoveErrors]
export type V2SessionContextEntryRemoveResponses = {
/**
* <No Content>
*/
204: void
}
export type V2SessionContextEntryRemoveResponse =
V2SessionContextEntryRemoveResponses[keyof V2SessionContextEntryRemoveResponses]
export type V2SessionContextEntryPutData = {
body: {
value: unknown
}
path: {
sessionID: string
key: SessionContextEntryKey
}
query?: never
url: "/api/session/{sessionID}/context-entry/{key}"
}
export type V2SessionContextEntryPutErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError
*/
404: SessionNotFoundError
}
export type V2SessionContextEntryPutError = V2SessionContextEntryPutErrors[keyof V2SessionContextEntryPutErrors]
export type V2SessionContextEntryPutResponses = {
/**
* <No Content>
*/
204: void
}
export type V2SessionContextEntryPutResponse =
V2SessionContextEntryPutResponses[keyof V2SessionContextEntryPutResponses]
export type V2SessionHistoryData = {
body?: never
path: {