@aniketworks/kindcode-sdk 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/dist/generated.d.ts +646 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +149 -0
- package/dist/types.d.ts +57 -0
- package/openapi.json +241 -0
- package/package.json +36 -4
- package/src/generated.ts +647 -0
- package/src/index.ts +222 -0
- package/src/types.ts +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { EventEnvelope, ModelInfo, PermissionMode, SessionRecord, SkillDetail, SkillSummary } from './types';
|
|
2
|
+
export type { ApprovalRequest, ApprovalResult, EventEnvelope, ModelInfo, PermissionMode, SessionRecord, SkillDetail, SkillSummary, } from './types';
|
|
3
|
+
export type { paths as OpenApiPaths, components as OpenApiComponents } from './generated';
|
|
4
|
+
export declare class KindCodeError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(message: string, status: number, code: string);
|
|
8
|
+
}
|
|
9
|
+
export interface ClientOptions {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
token: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateSessionInput {
|
|
14
|
+
workspace?: string;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
mode?: PermissionMode;
|
|
17
|
+
title?: string;
|
|
18
|
+
providerPreference?: {
|
|
19
|
+
providerId: string;
|
|
20
|
+
modelId: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare class KindCodeClient {
|
|
24
|
+
private readonly baseUrl;
|
|
25
|
+
private readonly token;
|
|
26
|
+
constructor(options: ClientOptions);
|
|
27
|
+
private headers;
|
|
28
|
+
private request;
|
|
29
|
+
health(): Promise<{
|
|
30
|
+
ok: boolean;
|
|
31
|
+
version: string;
|
|
32
|
+
workspace: string;
|
|
33
|
+
}>;
|
|
34
|
+
listModels(): Promise<ModelInfo[]>;
|
|
35
|
+
discoverModels(): Promise<ModelInfo[]>;
|
|
36
|
+
listSkills(): Promise<SkillSummary[]>;
|
|
37
|
+
getSkill(name: string): Promise<SkillDetail>;
|
|
38
|
+
listSessions(): Promise<SessionRecord[]>;
|
|
39
|
+
createSession(input: CreateSessionInput): Promise<SessionRecord>;
|
|
40
|
+
getSession(id: string): Promise<{
|
|
41
|
+
session: SessionRecord;
|
|
42
|
+
lastSeq: number;
|
|
43
|
+
active: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
submitTurn(id: string, input: string, clientMessageId?: string): Promise<{
|
|
46
|
+
turn: number;
|
|
47
|
+
firstSeq: number;
|
|
48
|
+
}>;
|
|
49
|
+
cancel(id: string): Promise<{
|
|
50
|
+
cancelled: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
resolvePermission(sessionId: string, requestId: string, decision: 'allow' | 'deny', remember?: boolean): Promise<{
|
|
53
|
+
resolved: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
getDiff(sessionId: string): Promise<string>;
|
|
56
|
+
undo(sessionId: string): Promise<{
|
|
57
|
+
restored: string;
|
|
58
|
+
turn: number;
|
|
59
|
+
}>;
|
|
60
|
+
subscribe(sessionId: string, after: number, onEvent: (event: EventEnvelope) => void, onError?: (error: Error) => void): () => void;
|
|
61
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/index.ts
|
|
3
|
+
class KindCodeError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(message, status, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "KindCodeError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class KindCodeClient {
|
|
15
|
+
baseUrl;
|
|
16
|
+
token;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
19
|
+
this.token = options.token;
|
|
20
|
+
}
|
|
21
|
+
headers() {
|
|
22
|
+
return {
|
|
23
|
+
authorization: `Bearer ${this.token}`,
|
|
24
|
+
"content-type": "application/json"
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async request(method, path, body) {
|
|
28
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
29
|
+
method,
|
|
30
|
+
headers: this.headers(),
|
|
31
|
+
body: body === undefined ? undefined : JSON.stringify(body)
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
let code = "request_failed";
|
|
35
|
+
let message = `${method} ${path} failed with ${response.status}`;
|
|
36
|
+
try {
|
|
37
|
+
const payload = await response.json();
|
|
38
|
+
code = payload.error?.code ?? code;
|
|
39
|
+
message = payload.error?.message ?? message;
|
|
40
|
+
} catch {}
|
|
41
|
+
throw new KindCodeError(message, response.status, code);
|
|
42
|
+
}
|
|
43
|
+
return await response.json();
|
|
44
|
+
}
|
|
45
|
+
health() {
|
|
46
|
+
return this.request("GET", "/v1/health");
|
|
47
|
+
}
|
|
48
|
+
async listModels() {
|
|
49
|
+
const result = await this.request("GET", "/v1/models");
|
|
50
|
+
return result.models;
|
|
51
|
+
}
|
|
52
|
+
async discoverModels() {
|
|
53
|
+
const result = await this.request("POST", "/v1/models/discover");
|
|
54
|
+
return result.models;
|
|
55
|
+
}
|
|
56
|
+
async listSkills() {
|
|
57
|
+
const result = await this.request("GET", "/v1/skills");
|
|
58
|
+
return result.skills;
|
|
59
|
+
}
|
|
60
|
+
getSkill(name) {
|
|
61
|
+
return this.request("GET", `/v1/skills/${encodeURIComponent(name)}`);
|
|
62
|
+
}
|
|
63
|
+
async listSessions() {
|
|
64
|
+
const result = await this.request("GET", "/v1/sessions");
|
|
65
|
+
return result.sessions;
|
|
66
|
+
}
|
|
67
|
+
async createSession(input) {
|
|
68
|
+
const result = await this.request("POST", "/v1/sessions", input);
|
|
69
|
+
return result.session;
|
|
70
|
+
}
|
|
71
|
+
getSession(id) {
|
|
72
|
+
return this.request("GET", `/v1/sessions/${encodeURIComponent(id)}`);
|
|
73
|
+
}
|
|
74
|
+
submitTurn(id, input, clientMessageId = crypto.randomUUID()) {
|
|
75
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(id)}/turns`, {
|
|
76
|
+
input,
|
|
77
|
+
clientMessageId
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
cancel(id) {
|
|
81
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(id)}/cancel`);
|
|
82
|
+
}
|
|
83
|
+
resolvePermission(sessionId, requestId, decision, remember = false) {
|
|
84
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(sessionId)}/permissions/${encodeURIComponent(requestId)}`, { decision, remember });
|
|
85
|
+
}
|
|
86
|
+
async getDiff(sessionId) {
|
|
87
|
+
const result = await this.request("GET", `/v1/sessions/${encodeURIComponent(sessionId)}/diff`);
|
|
88
|
+
return result.diff;
|
|
89
|
+
}
|
|
90
|
+
undo(sessionId) {
|
|
91
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(sessionId)}/undo`);
|
|
92
|
+
}
|
|
93
|
+
subscribe(sessionId, after, onEvent, onError) {
|
|
94
|
+
const controller = new AbortController;
|
|
95
|
+
let lastSeq = after;
|
|
96
|
+
const run = async () => {
|
|
97
|
+
while (!controller.signal.aborted) {
|
|
98
|
+
try {
|
|
99
|
+
const response = await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(sessionId)}/events?after=${lastSeq}`, { headers: this.headers(), signal: controller.signal });
|
|
100
|
+
if (!response.ok || !response.body) {
|
|
101
|
+
throw new Error(`Event stream failed with ${response.status}`);
|
|
102
|
+
}
|
|
103
|
+
const reader = response.body.getReader();
|
|
104
|
+
const decoder = new TextDecoder;
|
|
105
|
+
let buffer = "";
|
|
106
|
+
while (!controller.signal.aborted) {
|
|
107
|
+
const { done, value } = await reader.read();
|
|
108
|
+
if (done)
|
|
109
|
+
break;
|
|
110
|
+
buffer += decoder.decode(value, { stream: true });
|
|
111
|
+
let newline = buffer.indexOf(`
|
|
112
|
+
`);
|
|
113
|
+
while (newline >= 0) {
|
|
114
|
+
const line = buffer.slice(0, newline).trim();
|
|
115
|
+
buffer = buffer.slice(newline + 1);
|
|
116
|
+
if (line.startsWith("data:")) {
|
|
117
|
+
const payload = line.slice(5).trim();
|
|
118
|
+
if (!payload || payload === "{}")
|
|
119
|
+
continue;
|
|
120
|
+
try {
|
|
121
|
+
const event = JSON.parse(payload);
|
|
122
|
+
if (event.seq > lastSeq) {
|
|
123
|
+
lastSeq = event.seq;
|
|
124
|
+
onEvent(event);
|
|
125
|
+
}
|
|
126
|
+
} catch {}
|
|
127
|
+
}
|
|
128
|
+
newline = buffer.indexOf(`
|
|
129
|
+
`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (controller.signal.aborted)
|
|
134
|
+
return;
|
|
135
|
+
onError?.(error);
|
|
136
|
+
}
|
|
137
|
+
if (controller.signal.aborted)
|
|
138
|
+
return;
|
|
139
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
run();
|
|
143
|
+
return () => controller.abort();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
KindCodeClient,
|
|
148
|
+
KindCodeError
|
|
149
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type PermissionMode = 'ask' | 'auto-edit' | 'plan' | 'yolo';
|
|
2
|
+
export type PermissionDecision = 'allow' | 'deny';
|
|
3
|
+
export interface EventEnvelope<T = unknown> {
|
|
4
|
+
id: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
seq: number;
|
|
7
|
+
ts: number;
|
|
8
|
+
type: string;
|
|
9
|
+
v: number;
|
|
10
|
+
data: T;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
workspace: string;
|
|
15
|
+
cwd: string;
|
|
16
|
+
mode: PermissionMode;
|
|
17
|
+
title: string | null;
|
|
18
|
+
providerPreference: {
|
|
19
|
+
providerId: string;
|
|
20
|
+
modelId: string;
|
|
21
|
+
} | null;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
updatedAt: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ModelInfo {
|
|
26
|
+
providerId: string;
|
|
27
|
+
modelId: string;
|
|
28
|
+
label: string;
|
|
29
|
+
local: boolean;
|
|
30
|
+
capabilities: {
|
|
31
|
+
toolUse: boolean;
|
|
32
|
+
contextLength: number | null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface ApprovalRequest {
|
|
36
|
+
requestId: string;
|
|
37
|
+
toolCallId: string;
|
|
38
|
+
tool: string;
|
|
39
|
+
summary: string;
|
|
40
|
+
risk: 'low' | 'high' | 'unknown';
|
|
41
|
+
args: string;
|
|
42
|
+
options: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface ApprovalResult {
|
|
45
|
+
decision: PermissionDecision;
|
|
46
|
+
remember: boolean;
|
|
47
|
+
reason?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SkillSummary {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
source: 'builtin' | 'global' | 'project';
|
|
53
|
+
}
|
|
54
|
+
export interface SkillDetail extends SkillSummary {
|
|
55
|
+
body: string;
|
|
56
|
+
path: string;
|
|
57
|
+
}
|
package/openapi.json
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "KindCode Local API",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Local control server for KindCode sessions, events, tools, and models."
|
|
7
|
+
},
|
|
8
|
+
"servers": [{ "url": "http://127.0.0.1:4096" }],
|
|
9
|
+
"security": [{ "bearerAuth": [] }],
|
|
10
|
+
"components": {
|
|
11
|
+
"securitySchemes": {
|
|
12
|
+
"bearerAuth": { "type": "http", "scheme": "bearer" }
|
|
13
|
+
},
|
|
14
|
+
"schemas": {
|
|
15
|
+
"ErrorEnvelope": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"error": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"code": { "type": "string" },
|
|
22
|
+
"message": { "type": "string" }
|
|
23
|
+
},
|
|
24
|
+
"required": ["code", "message"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": ["error"]
|
|
28
|
+
},
|
|
29
|
+
"PermissionMode": { "type": "string", "enum": ["ask", "auto-edit", "plan", "yolo"] },
|
|
30
|
+
"Session": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"id": { "type": "string" },
|
|
34
|
+
"workspace": { "type": "string" },
|
|
35
|
+
"cwd": { "type": "string" },
|
|
36
|
+
"mode": { "$ref": "#/components/schemas/PermissionMode" },
|
|
37
|
+
"title": { "type": ["string", "null"] },
|
|
38
|
+
"providerPreference": {
|
|
39
|
+
"type": ["object", "null"],
|
|
40
|
+
"properties": {
|
|
41
|
+
"providerId": { "type": "string" },
|
|
42
|
+
"modelId": { "type": "string" }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"createdAt": { "type": "integer" },
|
|
46
|
+
"updatedAt": { "type": "integer" }
|
|
47
|
+
},
|
|
48
|
+
"required": ["id", "workspace", "cwd", "mode", "createdAt", "updatedAt"]
|
|
49
|
+
},
|
|
50
|
+
"Model": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"providerId": { "type": "string" },
|
|
54
|
+
"modelId": { "type": "string" },
|
|
55
|
+
"label": { "type": "string" },
|
|
56
|
+
"local": { "type": "boolean" },
|
|
57
|
+
"capabilities": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"properties": {
|
|
60
|
+
"toolUse": { "type": "boolean" },
|
|
61
|
+
"contextLength": { "type": ["integer", "null"] }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"required": ["providerId", "modelId", "label", "local"]
|
|
66
|
+
},
|
|
67
|
+
"Skill": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {
|
|
70
|
+
"name": { "type": "string" },
|
|
71
|
+
"description": { "type": "string" },
|
|
72
|
+
"source": { "type": "string", "enum": ["builtin", "global", "project"] },
|
|
73
|
+
"body": { "type": "string" },
|
|
74
|
+
"path": { "type": "string" }
|
|
75
|
+
},
|
|
76
|
+
"required": ["name", "description"]
|
|
77
|
+
},
|
|
78
|
+
"Event": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"id": { "type": "string" },
|
|
82
|
+
"sessionId": { "type": "string" },
|
|
83
|
+
"seq": { "type": "integer" },
|
|
84
|
+
"ts": { "type": "integer" },
|
|
85
|
+
"type": { "type": "string" },
|
|
86
|
+
"v": { "type": "integer" },
|
|
87
|
+
"data": {}
|
|
88
|
+
},
|
|
89
|
+
"required": ["id", "sessionId", "seq", "ts", "type", "v", "data"]
|
|
90
|
+
},
|
|
91
|
+
"CreateSessionRequest": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"properties": {
|
|
94
|
+
"workspace": { "type": "string" },
|
|
95
|
+
"cwd": { "type": "string" },
|
|
96
|
+
"mode": { "$ref": "#/components/schemas/PermissionMode" },
|
|
97
|
+
"title": { "type": "string" },
|
|
98
|
+
"providerPreference": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {
|
|
101
|
+
"providerId": { "type": "string" },
|
|
102
|
+
"modelId": { "type": "string" }
|
|
103
|
+
},
|
|
104
|
+
"required": ["providerId", "modelId"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"CreateTurnRequest": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"properties": {
|
|
111
|
+
"input": { "type": "string" },
|
|
112
|
+
"clientMessageId": { "type": "string" }
|
|
113
|
+
},
|
|
114
|
+
"required": ["input"]
|
|
115
|
+
},
|
|
116
|
+
"PermissionDecision": {
|
|
117
|
+
"type": "object",
|
|
118
|
+
"properties": {
|
|
119
|
+
"decision": { "type": "string", "enum": ["allow", "deny"] },
|
|
120
|
+
"remember": { "type": "boolean" }
|
|
121
|
+
},
|
|
122
|
+
"required": ["decision"]
|
|
123
|
+
},
|
|
124
|
+
"Health": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"properties": {
|
|
127
|
+
"ok": { "type": "boolean" },
|
|
128
|
+
"version": { "type": "string" },
|
|
129
|
+
"uptimeMs": { "type": "integer" },
|
|
130
|
+
"workspace": { "type": "string" }
|
|
131
|
+
},
|
|
132
|
+
"required": ["ok", "version", "workspace"]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"paths": {
|
|
137
|
+
"/v1/health": {
|
|
138
|
+
"get": {
|
|
139
|
+
"operationId": "health",
|
|
140
|
+
"security": [],
|
|
141
|
+
"responses": { "200": { "description": "Health", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Health" } } } } }
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"/v1/models": {
|
|
145
|
+
"get": {
|
|
146
|
+
"operationId": "listModels",
|
|
147
|
+
"responses": { "200": { "description": "Models", "content": { "application/json": { "schema": { "type": "object", "properties": { "models": { "type": "array", "items": { "$ref": "#/components/schemas/Model" } } } } } } } }
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"/v1/models/discover": {
|
|
151
|
+
"post": {
|
|
152
|
+
"operationId": "discoverModels",
|
|
153
|
+
"responses": { "200": { "description": "Refreshed models", "content": { "application/json": { "schema": { "type": "object", "properties": { "models": { "type": "array", "items": { "$ref": "#/components/schemas/Model" } } } } } } } }
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"/v1/skills": {
|
|
157
|
+
"get": {
|
|
158
|
+
"operationId": "listSkills",
|
|
159
|
+
"responses": { "200": { "description": "Skills", "content": { "application/json": { "schema": { "type": "object", "properties": { "skills": { "type": "array", "items": { "$ref": "#/components/schemas/Skill" } } } } } } } }
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"/v1/skills/{name}": {
|
|
163
|
+
"get": {
|
|
164
|
+
"operationId": "getSkill",
|
|
165
|
+
"parameters": [{ "name": "name", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
166
|
+
"responses": {
|
|
167
|
+
"200": { "description": "Skill", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Skill" } } } },
|
|
168
|
+
"404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } } }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"/v1/sessions": {
|
|
173
|
+
"get": {
|
|
174
|
+
"operationId": "listSessions",
|
|
175
|
+
"responses": { "200": { "description": "Sessions", "content": { "application/json": { "schema": { "type": "object", "properties": { "sessions": { "type": "array", "items": { "$ref": "#/components/schemas/Session" } } } } } } } }
|
|
176
|
+
},
|
|
177
|
+
"post": {
|
|
178
|
+
"operationId": "createSession",
|
|
179
|
+
"requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateSessionRequest" } } } },
|
|
180
|
+
"responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "type": "object", "properties": { "session": { "$ref": "#/components/schemas/Session" } } } } } } }
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"/v1/sessions/{id}": {
|
|
184
|
+
"get": {
|
|
185
|
+
"operationId": "getSession",
|
|
186
|
+
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
187
|
+
"responses": { "200": { "description": "Session detail", "content": { "application/json": { "schema": { "type": "object", "properties": { "session": { "$ref": "#/components/schemas/Session" }, "lastSeq": { "type": "integer" }, "active": { "type": "boolean" } } } } } } }
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"/v1/sessions/{id}/turns": {
|
|
191
|
+
"post": {
|
|
192
|
+
"operationId": "submitTurn",
|
|
193
|
+
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
194
|
+
"requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateTurnRequest" } } } },
|
|
195
|
+
"responses": { "202": { "description": "Accepted", "content": { "application/json": { "schema": { "type": "object", "properties": { "turn": { "type": "integer" }, "firstSeq": { "type": "integer" } } } } } } }
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"/v1/sessions/{id}/cancel": {
|
|
199
|
+
"post": {
|
|
200
|
+
"operationId": "cancelTurn",
|
|
201
|
+
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
202
|
+
"responses": { "200": { "description": "Cancelled", "content": { "application/json": { "schema": { "type": "object", "properties": { "cancelled": { "type": "boolean" } } } } } } }
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"/v1/sessions/{id}/events": {
|
|
206
|
+
"get": {
|
|
207
|
+
"operationId": "streamEvents",
|
|
208
|
+
"parameters": [
|
|
209
|
+
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
|
|
210
|
+
{ "name": "after", "in": "query", "schema": { "type": "integer" } }
|
|
211
|
+
],
|
|
212
|
+
"responses": { "200": { "description": "SSE stream of Event envelopes", "content": { "text/event-stream": { "schema": { "$ref": "#/components/schemas/Event" } } } } }
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"/v1/sessions/{id}/permissions/{requestId}": {
|
|
216
|
+
"post": {
|
|
217
|
+
"operationId": "resolvePermission",
|
|
218
|
+
"parameters": [
|
|
219
|
+
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
|
|
220
|
+
{ "name": "requestId", "in": "path", "required": true, "schema": { "type": "string" } }
|
|
221
|
+
],
|
|
222
|
+
"requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PermissionDecision" } } } },
|
|
223
|
+
"responses": { "200": { "description": "Resolved", "content": { "application/json": { "schema": { "type": "object", "properties": { "resolved": { "type": "boolean" } } } } } } }
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"/v1/sessions/{id}/diff": {
|
|
227
|
+
"get": {
|
|
228
|
+
"operationId": "getDiff",
|
|
229
|
+
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
230
|
+
"responses": { "200": { "description": "Worktree diff", "content": { "application/json": { "schema": { "type": "object", "properties": { "diff": { "type": "string" } } } } } } }
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"/v1/sessions/{id}/undo": {
|
|
234
|
+
"post": {
|
|
235
|
+
"operationId": "undo",
|
|
236
|
+
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
|
|
237
|
+
"responses": { "200": { "description": "Restored", "content": { "application/json": { "schema": { "type": "object", "properties": { "restored": { "type": "string" }, "turn": { "type": "integer" } } } } } } }
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aniketworks/kindcode-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Typed client for the KindCode local API",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"openapi.json",
|
|
12
|
+
"README.md",
|
|
13
|
+
"src/index.ts",
|
|
14
|
+
"src/types.ts",
|
|
15
|
+
"src/generated.ts"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./src/index.ts",
|
|
20
|
+
"bun": "./src/index.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./openapi.json": "./openapi.json"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"generate": "openapi-typescript openapi.json -o src/generated.ts",
|
|
27
|
+
"build": "bun run generate && bun build src/index.ts --outdir dist --target=bun && tsc -p tsconfig.build.json",
|
|
28
|
+
"typecheck": "tsc -p ../../tsconfig.json --noEmit",
|
|
29
|
+
"test": "bun test",
|
|
30
|
+
"prepack": "bun run build"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"openapi-typescript": "^7.13.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|