@centlu/agent-core 0.1.0-beta.0 → 0.1.1
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/package.json +14 -7
- package/src/agent/core.ts +49 -0
- package/src/agent/index.ts +1 -0
- package/src/agent/omp.ts +64 -0
- package/src/agent/store.ts +76 -0
- package/src/buffer.ts +78 -0
- package/src/index.ts +4 -1
- package/src/manage.ts +143 -0
- package/src/model.ts +77 -3
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centlu/agent-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Core TypeScript types for Bun-based agents.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ilovejavac/agent-core.git"
|
|
8
|
+
},
|
|
4
9
|
"type": "module",
|
|
5
|
-
"main": "./src/index.ts",
|
|
6
10
|
"types": "./src/index.ts",
|
|
7
11
|
"exports": {
|
|
8
12
|
".": "./src/index.ts"
|
|
@@ -10,14 +14,17 @@
|
|
|
10
14
|
"files": [
|
|
11
15
|
"src"
|
|
12
16
|
],
|
|
13
|
-
"
|
|
14
|
-
"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
15
19
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/bun": "latest",
|
|
22
|
+
"typescript": "^5"
|
|
19
23
|
},
|
|
20
24
|
"publishConfig": {
|
|
21
25
|
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@oh-my-pi/pi-coding-agent": "^19.1.0"
|
|
22
29
|
}
|
|
23
30
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type {AgentEvent, AgentOptions, UserOperation} from "../model.ts"
|
|
2
|
+
|
|
3
|
+
export interface AgentCore {
|
|
4
|
+
handleInput(input: UserOperation, options: AgentOptions): Promise<void>
|
|
5
|
+
waitForEnd(): Promise<void>
|
|
6
|
+
subscribe(listener: (event: AgentEvent) => void): () => void
|
|
7
|
+
startHeartbeat(report: () => Promise<void>): void
|
|
8
|
+
dispose(): Promise<void>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export abstract class AbstractAgent implements AgentCore {
|
|
12
|
+
private heartbeat?: ReturnType<typeof setInterval>
|
|
13
|
+
private reporting?: Promise<void>
|
|
14
|
+
private disposal?: Promise<void>
|
|
15
|
+
|
|
16
|
+
protected constructor(protected readonly id: string) {}
|
|
17
|
+
|
|
18
|
+
startHeartbeat(report: () => Promise<void>): void {
|
|
19
|
+
if (this.heartbeat !== undefined || this.disposal) return
|
|
20
|
+
|
|
21
|
+
const tick = () => {
|
|
22
|
+
if (this.reporting) return
|
|
23
|
+
this.reporting = Promise.resolve()
|
|
24
|
+
.then(report)
|
|
25
|
+
.catch(error => console.error("心跳上报失败", this.id, error))
|
|
26
|
+
.finally(() => {
|
|
27
|
+
this.reporting = undefined
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.heartbeat = setInterval(tick, 5000)
|
|
32
|
+
tick()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
dispose(): Promise<void> {
|
|
36
|
+
clearInterval(this.heartbeat)
|
|
37
|
+
return this.disposal ??= this.finishDispose()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private async finishDispose(): Promise<void> {
|
|
41
|
+
await this.reporting
|
|
42
|
+
await this.doDispose()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
abstract handleInput(input: UserOperation, options: AgentOptions): Promise<void>
|
|
46
|
+
abstract waitForEnd(): Promise<void>
|
|
47
|
+
abstract subscribe(listener: (event: AgentEvent) => void): () => void
|
|
48
|
+
protected abstract doDispose(): Promise<void>
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './store.ts'
|
package/src/agent/omp.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type {AgentSession} from "@oh-my-pi/pi-coding-agent/session/agent-session"
|
|
2
|
+
import {USER_INTERRUPT_LABEL} from "@oh-my-pi/pi-coding-agent/session/messages"
|
|
3
|
+
import {SessionManager} from "@oh-my-pi/pi-coding-agent/session/session-manager"
|
|
4
|
+
import {createAgentSession} from "@oh-my-pi/pi-coding-agent/sdk"
|
|
5
|
+
import type {AgentEvent, AgentOptions, UserOperation} from "../model.ts"
|
|
6
|
+
import {type AgentCore, AbstractAgent} from "./core.ts"
|
|
7
|
+
|
|
8
|
+
export async function CreateOhMyPiAgent(id: string, options: AgentOptions): Promise<AgentCore> {
|
|
9
|
+
const {session} = await createAgentSession({
|
|
10
|
+
cwd: options.cwd,
|
|
11
|
+
sessionManager: SessionManager.inMemory(),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
session.setSteeringMode("all", false)
|
|
15
|
+
return new OhMyPiAgent(id, session)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class OhMyPiAgent extends AbstractAgent {
|
|
19
|
+
constructor(id: string, private readonly core: AgentSession) {
|
|
20
|
+
super(id)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override subscribe(listener: (event: AgentEvent) => void): () => void {
|
|
24
|
+
return this.core.subscribe(listener)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override waitForEnd(): Promise<void> {
|
|
28
|
+
return this.core.waitForIdle()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected override doDispose(): Promise<void> {
|
|
32
|
+
return this.core.dispose()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override async handleInput(input: UserOperation): Promise<void> {
|
|
36
|
+
switch (input.kind) {
|
|
37
|
+
case "user-input":
|
|
38
|
+
await this.core.prompt(input.prompt, {
|
|
39
|
+
streamingBehavior: input.mode === "followup" ? "followUp" : "steer",
|
|
40
|
+
throwOnDrop: true,
|
|
41
|
+
})
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
case "user-interrupt":
|
|
45
|
+
await this.core.abort({reason: USER_INTERRUPT_LABEL})
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
case "user-compact":
|
|
49
|
+
await this.core.compact()
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
case "user-resume":
|
|
53
|
+
await this.core.resume()
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
default:
|
|
57
|
+
return assertNever(input)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function assertNever(_input: never): never {
|
|
63
|
+
throw new Error("Unsupported user operation")
|
|
64
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {AgentEvent, Submission} from "../model.ts";
|
|
2
|
+
|
|
3
|
+
export interface HistoryStore {
|
|
4
|
+
load_history_from_store(id: string): Promise<Array<AgentEvent>>
|
|
5
|
+
append_history_to_store(event: AgentEvent): Promise<void>
|
|
6
|
+
|
|
7
|
+
/** Take the currently queued batch without waiting for new messages. */
|
|
8
|
+
recall_pending_messages(id: string): Promise<Array<Submission>>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wait until messages are available and take a batch. On cancellation, return
|
|
12
|
+
* an empty batch if nothing was taken, or return the batch already taken.
|
|
13
|
+
*/
|
|
14
|
+
wait_and_recall_pending_messages(id: string, signal: AbortSignal): Promise<Array<Submission>>
|
|
15
|
+
|
|
16
|
+
submit_pending_messages(submission: Submission): Promise<void>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createMemoryPendingStore(): Pick<
|
|
20
|
+
HistoryStore,
|
|
21
|
+
| "submit_pending_messages"
|
|
22
|
+
| "recall_pending_messages"
|
|
23
|
+
| "wait_and_recall_pending_messages"
|
|
24
|
+
> {
|
|
25
|
+
const queues = new Map<string, Submission[]>()
|
|
26
|
+
const waiters = new Map<string, (batch: Submission[]) => void>()
|
|
27
|
+
|
|
28
|
+
function take(id: string): Submission[] {
|
|
29
|
+
const batch = queues.get(id) ?? []
|
|
30
|
+
queues.delete(id)
|
|
31
|
+
return batch
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
async submit_pending_messages(submission) {
|
|
36
|
+
const id = submission.session
|
|
37
|
+
const waiter = waiters.get(id)
|
|
38
|
+
if (waiter) {
|
|
39
|
+
waiter([submission])
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const queue = queues.get(id) ?? []
|
|
44
|
+
queue.push(submission)
|
|
45
|
+
queues.set(id, queue)
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
async recall_pending_messages(id) {
|
|
49
|
+
return take(id)
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
async wait_and_recall_pending_messages(id, signal) {
|
|
53
|
+
if (signal.aborted) return []
|
|
54
|
+
|
|
55
|
+
const batch = take(id)
|
|
56
|
+
if (batch.length > 0) return batch
|
|
57
|
+
|
|
58
|
+
if (waiters.has(id)) {
|
|
59
|
+
throw new Error(`Session ${id} already has a waiting consumer`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return new Promise<Submission[]>(resolve => {
|
|
63
|
+
const cancel = () => finish([])
|
|
64
|
+
|
|
65
|
+
function finish(messages: Submission[]) {
|
|
66
|
+
signal.removeEventListener("abort", cancel)
|
|
67
|
+
waiters.delete(id)
|
|
68
|
+
resolve(messages)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
waiters.set(id, finish)
|
|
72
|
+
signal.addEventListener("abort", cancel, { once: true })
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/buffer.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export function createEventSmoother(
|
|
2
|
+
write: (chunk: string) => void | Promise<void>,
|
|
3
|
+
{ intervalMs = 30, charsPerTick = 4 } = {},
|
|
4
|
+
) {
|
|
5
|
+
if (!Number.isInteger(charsPerTick) || charsPerTick < 1) {
|
|
6
|
+
throw new RangeError("charsPerTick must be a positive integer");
|
|
7
|
+
}
|
|
8
|
+
if (!Number.isInteger(intervalMs) || intervalMs < 1 || intervalMs > 2_147_483_647) {
|
|
9
|
+
throw new RangeError("intervalMs is outside the supported timer range");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let buffer = "";
|
|
13
|
+
let ended = false;
|
|
14
|
+
let running = false;
|
|
15
|
+
let resolveDone!: () => void;
|
|
16
|
+
let rejectDone!: (error: unknown) => void;
|
|
17
|
+
|
|
18
|
+
const done = new Promise<void>((resolve, reject) => {
|
|
19
|
+
resolveDone = resolve;
|
|
20
|
+
rejectDone = reject;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
async function drain(): Promise<void> {
|
|
24
|
+
if (running) return;
|
|
25
|
+
running = true;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
while (buffer) {
|
|
29
|
+
await new Promise<void>((resolve) => setTimeout(resolve, intervalMs));
|
|
30
|
+
|
|
31
|
+
let end = 0;
|
|
32
|
+
let count = 0;
|
|
33
|
+
for (const char of buffer) {
|
|
34
|
+
// 保留末尾单独的高代理项,等待下一段补齐 emoji 等字符。
|
|
35
|
+
if (!ended && end + 1 === buffer.length && /[\uD800-\uDBFF]/.test(char)) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
end += char.length;
|
|
40
|
+
count += 1;
|
|
41
|
+
if (count === charsPerTick) break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (end === 0) break;
|
|
45
|
+
|
|
46
|
+
const chunk = buffer.slice(0, end);
|
|
47
|
+
buffer = buffer.slice(end);
|
|
48
|
+
await write(chunk);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (ended) resolveDone();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
ended = true;
|
|
54
|
+
buffer = "";
|
|
55
|
+
rejectDone(error);
|
|
56
|
+
} finally {
|
|
57
|
+
running = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
push(chunk: string) {
|
|
63
|
+
if (ended) throw new Error("The text input is closed");
|
|
64
|
+
if (!chunk) return;
|
|
65
|
+
|
|
66
|
+
buffer += chunk;
|
|
67
|
+
void drain();
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
end() {
|
|
71
|
+
ended = true;
|
|
72
|
+
void drain();
|
|
73
|
+
return done;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
done,
|
|
77
|
+
};
|
|
78
|
+
}
|
package/src/index.ts
CHANGED
package/src/manage.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type {AgentEventListener, AgentLife, AgentOptions, Submission} from "./model.ts"
|
|
2
|
+
import type {HistoryStore} from "./agent"
|
|
3
|
+
import type {AgentCore} from "./agent/core.ts"
|
|
4
|
+
import {CreateOhMyPiAgent} from "./agent/omp.ts";
|
|
5
|
+
|
|
6
|
+
type SessionState = {
|
|
7
|
+
closing: boolean
|
|
8
|
+
pendingWait?: AbortController
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type ManagedSession = {
|
|
12
|
+
state: SessionState
|
|
13
|
+
ready: Promise<AgentCore>
|
|
14
|
+
done: Promise<void>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class SessionManager {
|
|
18
|
+
private readonly sessions = new Map<string, ManagedSession>()
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
private readonly store: HistoryStore,
|
|
22
|
+
private readonly life: AgentLife,
|
|
23
|
+
private readonly getCoreAgent: (id: string, options: AgentOptions) => Promise<AgentCore>,
|
|
24
|
+
private readonly listener?: AgentEventListener,
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
async submit(submission: Submission): Promise<void> {
|
|
28
|
+
await this.store.submit_pending_messages(submission)
|
|
29
|
+
|
|
30
|
+
const {session: id, options} = submission
|
|
31
|
+
while (true) {
|
|
32
|
+
let session = this.sessions.get(id)
|
|
33
|
+
if (!session) {
|
|
34
|
+
const alive = await this.life.alive(id)
|
|
35
|
+
session = this.sessions.get(id)
|
|
36
|
+
if (!session) {
|
|
37
|
+
if (alive) return
|
|
38
|
+
session = this.startSession(id, options)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!session.state.closing) {
|
|
43
|
+
await session.ready
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// A submission can arrive after the closing session's final queue read.
|
|
48
|
+
await session.done.catch(() => undefined)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async close(id: string): Promise<void> {
|
|
53
|
+
const session = this.sessions.get(id)
|
|
54
|
+
if (!session) return
|
|
55
|
+
|
|
56
|
+
session.state.closing = true
|
|
57
|
+
session.state.pendingWait?.abort()
|
|
58
|
+
await session.done
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private startSession(id: string, options: AgentOptions): ManagedSession {
|
|
62
|
+
const ready = Promise.resolve().then(() => this.getCoreAgent(id, options))
|
|
63
|
+
const state: SessionState = {closing: false}
|
|
64
|
+
const session: ManagedSession = {
|
|
65
|
+
state,
|
|
66
|
+
ready,
|
|
67
|
+
done: this.runSession(id, ready, state).finally(() => {
|
|
68
|
+
this.sessions.delete(id)
|
|
69
|
+
}),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.sessions.set(id, session)
|
|
73
|
+
void session.done.catch(error => console.error("会话运行失败", id, error))
|
|
74
|
+
return session
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private async runSession(id: string, ready: Promise<AgentCore>, state: SessionState): Promise<void> {
|
|
78
|
+
const agent = await ready
|
|
79
|
+
let events = Promise.resolve()
|
|
80
|
+
let unsubscribe: (() => void) | undefined
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
unsubscribe = agent.subscribe(event => {
|
|
84
|
+
events = events.then(async () => {
|
|
85
|
+
await this.store.append_history_to_store(event)
|
|
86
|
+
await this.listener?.onEvent(event)
|
|
87
|
+
}).catch(error => console.error("事件处理失败", id, event.type, error))
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
agent.startHeartbeat(() => this.life.report(id))
|
|
91
|
+
await this.consumePending(id, agent, state)
|
|
92
|
+
} finally {
|
|
93
|
+
try {
|
|
94
|
+
await agent.dispose()
|
|
95
|
+
} finally {
|
|
96
|
+
unsubscribe?.()
|
|
97
|
+
await events
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private async consumePending(id: string, agent: AgentCore, state: SessionState): Promise<void> {
|
|
103
|
+
const running = new Set<Promise<void>>()
|
|
104
|
+
|
|
105
|
+
while (true) {
|
|
106
|
+
let batch: Submission[]
|
|
107
|
+
if (state.closing && running.size === 0) {
|
|
108
|
+
batch = await this.store.recall_pending_messages(id)
|
|
109
|
+
if (batch.length === 0) break
|
|
110
|
+
} else {
|
|
111
|
+
const wait = new AbortController()
|
|
112
|
+
state.pendingWait = wait
|
|
113
|
+
try {
|
|
114
|
+
batch = await this.store.wait_and_recall_pending_messages(id, wait.signal)
|
|
115
|
+
} finally {
|
|
116
|
+
state.pendingWait = undefined
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
for (const {operation, options} of batch) {
|
|
121
|
+
const task = agent.handleInput(operation, options)
|
|
122
|
+
.catch(error => console.error("处理操作失败", id, operation.kind, error))
|
|
123
|
+
running.add(task)
|
|
124
|
+
void task.then(() => {
|
|
125
|
+
running.delete(task)
|
|
126
|
+
if (state.closing && running.size === 0) state.pendingWait?.abort()
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await agent.waitForEnd()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function createManager(
|
|
136
|
+
store: HistoryStore,
|
|
137
|
+
life: AgentLife,
|
|
138
|
+
listener?: AgentEventListener,
|
|
139
|
+
): SessionManager {
|
|
140
|
+
return new SessionManager(store, life, async (id, options) => {
|
|
141
|
+
return CreateOhMyPiAgent(id, options)
|
|
142
|
+
}, listener)
|
|
143
|
+
}
|
package/src/model.ts
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type UserInput = {
|
|
2
|
+
kind: "user-input"
|
|
3
|
+
|
|
4
|
+
mode: 'steer' | 'followup'
|
|
5
|
+
prompt: string
|
|
6
|
+
|
|
7
|
+
skills: {
|
|
8
|
+
name: string
|
|
9
|
+
path: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
attachments: {
|
|
13
|
+
index: number,
|
|
14
|
+
path: string,
|
|
15
|
+
detail: string
|
|
16
|
+
}[]
|
|
17
|
+
|
|
18
|
+
mentions: {
|
|
19
|
+
name: string,
|
|
20
|
+
path: string
|
|
21
|
+
}[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type UserInterrupt = {
|
|
25
|
+
kind: "user-interrupt"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type UserResume = {
|
|
29
|
+
kind: "user-resume"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type UserCompact = {
|
|
33
|
+
kind: "user-compact"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type UserSettingOverride = {
|
|
37
|
+
kind: "user-setting-override"
|
|
38
|
+
setting: TurnConfig
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type AgentOptions = {
|
|
42
|
+
cwd: string,
|
|
43
|
+
setting: TurnConfig
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type TurnConfig = {
|
|
47
|
+
revision: number
|
|
48
|
+
provider: 'openai' | 'anthropic' | 'google' | 'grok' | 'kimi' | 'deepseek'
|
|
49
|
+
baseurl?: string
|
|
50
|
+
model: string
|
|
51
|
+
apiKey: string
|
|
52
|
+
contextWindow: number
|
|
53
|
+
thinkingLevel: 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type UserOperation = UserInput | UserInterrupt | UserCompact | UserResume
|
|
57
|
+
|
|
58
|
+
export type Submission = {
|
|
59
|
+
session: string,
|
|
60
|
+
options: AgentOptions,
|
|
61
|
+
operation: UserOperation
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type AgentEvent = {
|
|
65
|
+
type: string
|
|
66
|
+
usage?: any
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface AgentEventListener {
|
|
70
|
+
onEvent(evt: AgentEvent): Promise<void>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface AgentLife {
|
|
74
|
+
alive(id: string): Promise<boolean>
|
|
75
|
+
|
|
76
|
+
report(id: string): Promise<void>
|
|
77
|
+
}
|