megacode-agent-sdk 0.0.0-stage → 0.31.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/LICENSE-APACHE +176 -0
- package/LICENSE-MIT +23 -0
- package/README.md +38 -2
- package/dist/binary/archive.d.ts +7 -0
- package/dist/binary/archive.js +215 -0
- package/dist/binary/cache.d.ts +21 -0
- package/dist/binary/cache.js +256 -0
- package/dist/binary/download.d.ts +16 -0
- package/dist/binary/download.js +174 -0
- package/dist/binary/index.d.ts +49 -0
- package/dist/binary/index.js +160 -0
- package/dist/client.d.ts +94 -0
- package/dist/client.js +868 -0
- package/dist/errors.d.ts +58 -0
- package/dist/errors.js +97 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +42 -0
- package/dist/options.d.ts +48 -0
- package/dist/options.js +49 -0
- package/dist/pins.d.ts +5 -0
- package/dist/pins.js +22 -0
- package/dist/process.d.ts +72 -0
- package/dist/process.js +255 -0
- package/dist/tools.d.ts +74 -0
- package/dist/tools.js +256 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/dist/wire.d.ts +241 -0
- package/dist/wire.js +620 -0
- package/package.json +33 -4
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type Options } from "./options.js";
|
|
2
|
+
import { type Compacted, type Decision, type Disposition, type Event, type Info, type State } from "./wire.js";
|
|
3
|
+
/** How long a start waits for `init` (R6.2). */
|
|
4
|
+
export declare const INIT_TIMEOUT_MS = 60000;
|
|
5
|
+
/** A turn's unread events past this end the session (R8.5.5). */
|
|
6
|
+
export declare const UNREAD_LIMIT = 10000;
|
|
7
|
+
/** How long `close` waits for the exit after `quit` (R8.6.2). */
|
|
8
|
+
export declare const QUIT_WAIT_MS = 5000;
|
|
9
|
+
/** How long `close` waits for handler and callback tasks before it stops
|
|
10
|
+
* waiting for them (R8.6.2). */
|
|
11
|
+
export declare const TASK_WAIT_MS = 5000;
|
|
12
|
+
/** How long the reader keeps reading stdout once the process has exited: its
|
|
13
|
+
* last lines are already in the pipe, while a descendant holding the pipe
|
|
14
|
+
* open may never end it. */
|
|
15
|
+
export declare const DRAIN_AFTER_EXIT_MS = 500;
|
|
16
|
+
/** Test support: shortens the wait for `init`. Not part of the API. */
|
|
17
|
+
export declare function setInitTimeoutMs(ms: number): void;
|
|
18
|
+
/** What `compact` did (R8.1.2): queued behind the running turn, or done,
|
|
19
|
+
* with the compaction its own response names (`null` when none was written). */
|
|
20
|
+
export type Compaction = {
|
|
21
|
+
readonly queued: true;
|
|
22
|
+
} | {
|
|
23
|
+
readonly done: Compacted | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A stream of events, a turn's or the session's between turns. An error ends
|
|
27
|
+
* the stream (thrown by `next`). `return()` (a `break` out of `for await`)
|
|
28
|
+
* drops the stream: the rest of its events are discarded.
|
|
29
|
+
*/
|
|
30
|
+
export declare class Events implements AsyncIterableIterator<Event> {
|
|
31
|
+
constructor();
|
|
32
|
+
next(): Promise<IteratorResult<Event>>;
|
|
33
|
+
return(): Promise<IteratorResult<Event>>;
|
|
34
|
+
[Symbol.asyncIterator](): this;
|
|
35
|
+
}
|
|
36
|
+
/** One turn's events, `user` to `result`. It ends after `result`, or with
|
|
37
|
+
* no event once an abort took its queued prompt back (`dequeued`). */
|
|
38
|
+
export declare class TurnStream extends Events {
|
|
39
|
+
}
|
|
40
|
+
/** A session: every method usable while a turn's stream is read (R8.1.2). */
|
|
41
|
+
export declare class Client {
|
|
42
|
+
private readonly session;
|
|
43
|
+
/** `init`'s data. */
|
|
44
|
+
readonly info: Info;
|
|
45
|
+
private closing;
|
|
46
|
+
private constructor();
|
|
47
|
+
/** The session's id. */
|
|
48
|
+
get id(): string;
|
|
49
|
+
/** Starts a session and reads its `init`. */
|
|
50
|
+
static start(options?: Options): Promise<Client>;
|
|
51
|
+
/** Continues the session `sessionId` (R2.5): the options send only what
|
|
52
|
+
* a resume may give, and the same tools. */
|
|
53
|
+
static resume(sessionId: string, options?: Options): Promise<Client>;
|
|
54
|
+
private static open;
|
|
55
|
+
/** Starts a turn with `prompt` and returns its events, `user` to
|
|
56
|
+
* `result`. One turn at a time: until the wire's `result` (whether or not
|
|
57
|
+
* the stream is read), or an abort that took the prompt back, another
|
|
58
|
+
* `send` is `TurnInProgress`. */
|
|
59
|
+
send(prompt: string): Promise<TurnStream>;
|
|
60
|
+
/** Joins the running turn at its next landing point. */
|
|
61
|
+
steer(text: string): Promise<Disposition>;
|
|
62
|
+
/** Interrupts the program's turn, naming its prompt: a running one is
|
|
63
|
+
* `interrupting`; one still `queued` is taken back, `dequeued`, never runs,
|
|
64
|
+
* and its stream ends with no `result`. With no turn of the program's,
|
|
65
|
+
* whatever runs is interrupted. */
|
|
66
|
+
abort(): Promise<Disposition>;
|
|
67
|
+
/** Compacts the context: at once when idle, after the turn when one runs.
|
|
68
|
+
* `done` carries the compaction its own response names; every `compacted`
|
|
69
|
+
* line goes to the running turn's stream or `sessionEvents()`. */
|
|
70
|
+
compact(): Promise<Compaction>;
|
|
71
|
+
/** Puts the running or next task away, or ends away. */
|
|
72
|
+
away(on: boolean): Promise<Disposition>;
|
|
73
|
+
/** The session's state. */
|
|
74
|
+
state(): Promise<State>;
|
|
75
|
+
/** Answers the approval request `requestId` (R8.3.3). */
|
|
76
|
+
respond(requestId: string, decision: Decision): Promise<void>;
|
|
77
|
+
/** The events that arrive while no turn's stream is open; the first call
|
|
78
|
+
* takes the stream, later calls get `null`. Until it is taken, those
|
|
79
|
+
* events are dropped. */
|
|
80
|
+
sessionEvents(): Events | null;
|
|
81
|
+
/** Ends the session (R8.6.2): every running call's signal fires; `quit`,
|
|
82
|
+
* up to 5 s for the exit, SIGTERM, up to 5 s more, SIGKILL, the process
|
|
83
|
+
* reaped; meanwhile up to 5 s for handler and callback tasks, then they
|
|
84
|
+
* are no longer waited for. Returns within about 15 s. A `close()` never
|
|
85
|
+
* awaited still kills the process at this process's exit. */
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
export interface Client {
|
|
89
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
/** Starts a session, sends `prompt`, and yields `init` and then that turn's
|
|
92
|
+
* events up to its `result`; then the session is closed (R8.1.1). Leaving
|
|
93
|
+
* the loop early closes it too. */
|
|
94
|
+
export declare function query(prompt: string, options?: Options): AsyncGenerator<Event, void, undefined>;
|