@qilin-agent/sdk-client 0.0.0-stage → 3.1.3
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 +21 -0
- package/README.i18n.yaml +55 -0
- package/README.md +133 -2
- package/README.zh.md +134 -0
- package/lib/index.js +844 -0
- package/lib/types/api.d.ts +116 -0
- package/lib/types/client.d.ts +149 -0
- package/lib/types/dispose.d.ts +27 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/launch.d.ts +58 -0
- package/lib/types/types.d.ts +77 -0
- package/package.json +43 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level run API over {@link HarnessClient}: `DeepSeekHarness` owns one
|
|
3
|
+
* runtime subprocess across many sessions; `HarnessSession.run` sends a
|
|
4
|
+
* prompt and settles when the whole agent next becomes idle.
|
|
5
|
+
*
|
|
6
|
+
* @module @qilin-agent/sdk-client/api
|
|
7
|
+
*/
|
|
8
|
+
import type { SessionEvent } from '@qilin-agent/session';
|
|
9
|
+
import { HarnessClient } from './client.ts';
|
|
10
|
+
import type { RuntimeProcessOptions } from './launch.ts';
|
|
11
|
+
import type { DeepSeekHarnessOptions, HarnessNotification, RunResult, SdkPromptContentBlock } from './types.ts';
|
|
12
|
+
/**
|
|
13
|
+
* Reusable SDK for running QiLin agent turns in a runtime
|
|
14
|
+
* subprocess. The subprocess starts lazily on first use and stays owned by
|
|
15
|
+
* this instance until {@link close}; always close (or `await using`) so the
|
|
16
|
+
* child is reaped.
|
|
17
|
+
*/
|
|
18
|
+
export declare class DeepSeekHarness implements AsyncDisposable {
|
|
19
|
+
private clientInstance;
|
|
20
|
+
private readonly createClient;
|
|
21
|
+
private readonly cwd;
|
|
22
|
+
private readonly provider;
|
|
23
|
+
private readonly model;
|
|
24
|
+
private readonly reasoningEffort;
|
|
25
|
+
private readonly maxTokens;
|
|
26
|
+
private initialized;
|
|
27
|
+
private closed;
|
|
28
|
+
/** @param options - qilin launch configuration plus the session route, effort, and output cap. */
|
|
29
|
+
constructor(options?: DeepSeekHarnessOptions);
|
|
30
|
+
/**
|
|
31
|
+
* The underlying JSON-RPC client (exposed for low-level access). A failed
|
|
32
|
+
* handshake swaps in a fresh instance only after cleanup proves the runtime
|
|
33
|
+
* exited; cleanup failure retains this client, so do not cache it across a
|
|
34
|
+
* failed {@link start}.
|
|
35
|
+
* @returns the client currently owning the runtime subprocess.
|
|
36
|
+
*/
|
|
37
|
+
get client(): HarnessClient;
|
|
38
|
+
/**
|
|
39
|
+
* Start the subprocess and perform the `initialize` handshake once. On
|
|
40
|
+
* failure, successful SDK-owned cleanup reaps the runtime and installs a
|
|
41
|
+
* fresh client (`HarnessClient.close` is permanent), so a later call retries
|
|
42
|
+
* with a new subprocess unless {@link close} already ended this harness. If
|
|
43
|
+
* cleanup also fails, rejects with an `AggregateError` whose ordered errors
|
|
44
|
+
* preserve both causes and retains the failed client rather than spawning
|
|
45
|
+
* alongside a process whose exit was not proved.
|
|
46
|
+
* @returns settlement of the (memoized) handshake.
|
|
47
|
+
*/
|
|
48
|
+
start(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Open a session handle (no wire traffic; the runtime creates the session
|
|
51
|
+
* on its first prompt).
|
|
52
|
+
* @param sessionId - explicit id to reuse; omitted mints a fresh one.
|
|
53
|
+
* @returns the session handle.
|
|
54
|
+
*/
|
|
55
|
+
session(sessionId?: string): HarnessSession;
|
|
56
|
+
/**
|
|
57
|
+
* Run one prompt on a fresh (or named) session.
|
|
58
|
+
* @param input - prompt text, or content blocks sent verbatim.
|
|
59
|
+
* @param options - optional session id and per-notification observer.
|
|
60
|
+
* @returns the owned activity interval.
|
|
61
|
+
*/
|
|
62
|
+
run(input: string | SdkPromptContentBlock[], options?: RunOptions): Promise<RunResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Shut down and reap the runtime subprocess. Idempotent and terminal —
|
|
65
|
+
* a closed harness no longer retries a failed handshake.
|
|
66
|
+
* @returns settlement of the complete teardown.
|
|
67
|
+
*/
|
|
68
|
+
close(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* `await using` support: {@link close}.
|
|
71
|
+
* @returns settlement of the teardown.
|
|
72
|
+
*/
|
|
73
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/** Construct the high-level API against a generic process for package-local fake-runtime tests. */
|
|
76
|
+
export declare function createProcessDeepSeekHarness(runtime: RuntimeProcessOptions, options?: DeepSeekHarnessOptions): DeepSeekHarness;
|
|
77
|
+
/** Per-run options: target session and streaming observer. */
|
|
78
|
+
export interface RunOptions {
|
|
79
|
+
/** Session id to run on; omitted mints a fresh session per call. */
|
|
80
|
+
sessionId?: string;
|
|
81
|
+
/** Observer invoked with every notification for this session tree, in wire order. */
|
|
82
|
+
onNotification?: (notification: HarnessNotification) => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One SDK session: a stable id plus owned activity intervals.
|
|
86
|
+
*/
|
|
87
|
+
export declare class HarnessSession {
|
|
88
|
+
readonly harness: DeepSeekHarness;
|
|
89
|
+
readonly id: string;
|
|
90
|
+
/**
|
|
91
|
+
* @param harness - the owning harness (supplies the client and handshake).
|
|
92
|
+
* @param id - the wire session id this handle runs on.
|
|
93
|
+
*/
|
|
94
|
+
constructor(harness: DeepSeekHarness, id: string);
|
|
95
|
+
/**
|
|
96
|
+
* Queue one prompt, then observe the whole session through its next idle.
|
|
97
|
+
* @param input - prompt text, or content blocks sent verbatim.
|
|
98
|
+
* @param options - optional per-notification observer.
|
|
99
|
+
* @returns the owned activity interval; rejects on transport loss, timeout,
|
|
100
|
+
* or a protocol error.
|
|
101
|
+
*/
|
|
102
|
+
run(input: string | SdkPromptContentBlock[], options?: Pick<RunOptions, 'onNotification'>): Promise<RunResult>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Normalize run input: a string becomes one text block; blocks pass verbatim.
|
|
106
|
+
* @param input - prompt text or content blocks.
|
|
107
|
+
* @returns the content blocks to send.
|
|
108
|
+
*/
|
|
109
|
+
export declare function normalizeInput(input: string | SdkPromptContentBlock[]): SdkPromptContentBlock[];
|
|
110
|
+
/**
|
|
111
|
+
* Extract the concatenated text of the last assistant message.
|
|
112
|
+
* @param events - the activity interval's `session.event` payloads in wire order.
|
|
113
|
+
* @returns the final response text, or `''` when no assistant message exists.
|
|
114
|
+
*/
|
|
115
|
+
export declare function finalResponse(events: SessionEvent[]): string;
|
|
116
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level JSON-RPC client for a QiLin SDK runtime subprocess.
|
|
3
|
+
* {@link HarnessClient} owns the child process: it spawns the runtime, speaks
|
|
4
|
+
* the `@qilin-agent/sdk-protocol` wire over the child's stdio, fans
|
|
5
|
+
* server notifications out to subscriptions, and tears the child down to
|
|
6
|
+
* quiescence through a private EOF → SIGTERM → SIGKILL ladder. The design
|
|
7
|
+
* twin is the Python SDK's `HarnessClient` (`python/sdk`); both drive the
|
|
8
|
+
* same runtime protocol. This client runs OUTSIDE any harness context, so it
|
|
9
|
+
* spawns directly rather than through the `qilin-subprocess` service — the
|
|
10
|
+
* seam's documented exception for SDK-managed transports.
|
|
11
|
+
*
|
|
12
|
+
* @module @qilin-agent/sdk-client/client
|
|
13
|
+
*/
|
|
14
|
+
import { type InitializeParams, type InitializeResult, type SdkPromptContentBlock } from '@qilin-agent/sdk-protocol';
|
|
15
|
+
import { type RuntimeProcessOptions } from './launch.ts';
|
|
16
|
+
import type { HarnessClientOptions, HarnessNotification, NotificationFilter } from './types.ts';
|
|
17
|
+
/**
|
|
18
|
+
* The runtime subprocess is gone or unusable: it exited, its stdio closed, or
|
|
19
|
+
* it was never launchable. The message carries the exit code and a stderr
|
|
20
|
+
* tail when available.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TransportClosedError extends Error {
|
|
23
|
+
/** @param message - the failure description, including any stderr tail. */
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/** A request exceeded {@link HarnessClientOptions.requestTimeoutMs}. */
|
|
27
|
+
export declare class RequestTimeoutError extends Error {
|
|
28
|
+
/** @param message - which method timed out. */
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The runtime answered outside its documented protocol (for example a
|
|
33
|
+
* `session/prompt` response without `accepted: true`).
|
|
34
|
+
*/
|
|
35
|
+
export declare class SdkProtocolError extends Error {
|
|
36
|
+
/** @param message - the protocol violation description. */
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
/** One client-side notification stream returned by {@link HarnessClient.subscribe}. */
|
|
40
|
+
export interface NotificationSubscription extends AsyncIterable<HarnessNotification> {
|
|
41
|
+
/**
|
|
42
|
+
* Await the next matching notification.
|
|
43
|
+
* @returns the notification; after the runtime died, drains what was
|
|
44
|
+
* already delivered and then rejects; after {@link close}, rejects
|
|
45
|
+
* immediately (the queue is dropped).
|
|
46
|
+
*/
|
|
47
|
+
next(): Promise<HarnessNotification>;
|
|
48
|
+
/**
|
|
49
|
+
* Drain one already-delivered notification without waiting.
|
|
50
|
+
* @returns the next queued notification, or `undefined` when none is queued.
|
|
51
|
+
*/
|
|
52
|
+
tryNext(): HarnessNotification | undefined;
|
|
53
|
+
/** Detach from the client; queued items drop and pending waiters reject. */
|
|
54
|
+
close(): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* JSON-RPC client for the QiLin SDK runtime over subprocess stdio.
|
|
58
|
+
*
|
|
59
|
+
* The subprocess starts lazily on {@link start} and is owned by this instance
|
|
60
|
+
* until {@link close}, which requests protocol `shutdown` and then walks the
|
|
61
|
+
* shared EOF → SIGTERM → SIGKILL dispose ladder to quiescence. There is no
|
|
62
|
+
* wire-level cancel: a timed-out request stays running server-side until the
|
|
63
|
+
* runtime is closed.
|
|
64
|
+
*/
|
|
65
|
+
export declare class HarnessClient {
|
|
66
|
+
/** Original public qilin launch and timeout options for this client. */
|
|
67
|
+
readonly options: HarnessClientOptions;
|
|
68
|
+
private readonly runtime;
|
|
69
|
+
private child;
|
|
70
|
+
private transport;
|
|
71
|
+
private readonly stderrTail;
|
|
72
|
+
private readonly subscriptions;
|
|
73
|
+
private readonly sessionParents;
|
|
74
|
+
private subscriptionSerial;
|
|
75
|
+
private exitCode;
|
|
76
|
+
private spawnError;
|
|
77
|
+
private streamsSettled;
|
|
78
|
+
private closeTask;
|
|
79
|
+
/** @param options - qilin profile, patch, home, process, environment, and timeout options. */
|
|
80
|
+
constructor(options?: HarnessClientOptions);
|
|
81
|
+
/**
|
|
82
|
+
* Spawn the runtime subprocess and start reading frames. Idempotent while
|
|
83
|
+
* the process is live; rejects reuse after {@link close}.
|
|
84
|
+
*/
|
|
85
|
+
start(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Perform the process-wide handshake.
|
|
88
|
+
* @param params - workspace cwd plus the provider/model route.
|
|
89
|
+
* @returns the runtime's wire identity.
|
|
90
|
+
*/
|
|
91
|
+
initialize(params: InitializeParams): Promise<InitializeResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Queue one prompt and return its durable inbox identity.
|
|
94
|
+
* @param sessionId - target session; an unknown id creates it.
|
|
95
|
+
* @param contentBlocks - the user message, sent verbatim.
|
|
96
|
+
* @returns the queued message id.
|
|
97
|
+
*/
|
|
98
|
+
prompt(sessionId: string, contentBlocks: SdkPromptContentBlock[]): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Send one JSON-RPC request and await its result.
|
|
101
|
+
* @param method - the wire method name.
|
|
102
|
+
* @param params - the params object; omitted params send `{}`.
|
|
103
|
+
* @param timeoutMs - per-call override of {@link HarnessClientOptions.requestTimeoutMs}.
|
|
104
|
+
* @returns the raw result; rejects with {@link JsonRpcResponseError} on a
|
|
105
|
+
* protocol error response, {@link RequestTimeoutError} on timeout, and
|
|
106
|
+
* {@link TransportClosedError} when the runtime is gone.
|
|
107
|
+
*/
|
|
108
|
+
request(method: string, params?: object, timeoutMs?: number): Promise<unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* Subscribe to server notifications.
|
|
111
|
+
* @param filter - optional predicate; omitted means every notification.
|
|
112
|
+
* @returns the subscription handle; close it to stop delivery. After
|
|
113
|
+
* {@link close} or runtime death the handle is born failed — there is no
|
|
114
|
+
* producer left, so `next()` rejects instead of waiting forever.
|
|
115
|
+
*/
|
|
116
|
+
subscribe(filter?: NotificationFilter): NotificationSubscription;
|
|
117
|
+
/**
|
|
118
|
+
* Subscribe to one session and the descendants discovered from
|
|
119
|
+
* `subagent.started` lineage edges. The runtime notifies for every session
|
|
120
|
+
* in its context, so this client applies the scope.
|
|
121
|
+
* @param sessionId - the root session id.
|
|
122
|
+
* @returns the filtered subscription handle.
|
|
123
|
+
*/
|
|
124
|
+
subscribeSessionTree(sessionId: string): NotificationSubscription;
|
|
125
|
+
/**
|
|
126
|
+
* Shut the runtime down and reap it: a best-effort protocol `shutdown`
|
|
127
|
+
* bounded by `shutdownTimeoutMs`, then the shared stdin-EOF → SIGTERM →
|
|
128
|
+
* SIGKILL ladder until the process actually exited. Idempotent.
|
|
129
|
+
* @returns settlement of the complete teardown.
|
|
130
|
+
*/
|
|
131
|
+
close(): Promise<void>;
|
|
132
|
+
private performClose;
|
|
133
|
+
private dispatchNotification;
|
|
134
|
+
private recordSessionRelationship;
|
|
135
|
+
private isDescendantOf;
|
|
136
|
+
private failSubscriptions;
|
|
137
|
+
private appendStderr;
|
|
138
|
+
private settleStreams;
|
|
139
|
+
private closedError;
|
|
140
|
+
}
|
|
141
|
+
/** Construct the transport against a generic process for package-local fake-runtime tests. */
|
|
142
|
+
export declare function createProcessHarnessClient(options: RuntimeProcessOptions): HarnessClient;
|
|
143
|
+
/**
|
|
144
|
+
* Whether `value` is a plain JSON object (the wire-boundary shape probe).
|
|
145
|
+
* @param value - the wire value to probe.
|
|
146
|
+
* @returns `true` iff `value` is a non-null, non-array object.
|
|
147
|
+
*/
|
|
148
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
149
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private teardown ladder for the runtime subprocess: stdin EOF (cooperative
|
|
3
|
+
* quiesce), then SIGTERM, then SIGKILL, resolving only after the process has
|
|
4
|
+
* actually exited. The SDK client runs OUTSIDE any harness context, so it
|
|
5
|
+
* cannot ride the `qilin-subprocess` service — this module is the seam's
|
|
6
|
+
* documented exception for SDK-managed transports.
|
|
7
|
+
*
|
|
8
|
+
* @module @qilin-agent/sdk-client/dispose
|
|
9
|
+
*/
|
|
10
|
+
import type { ChildProcess } from 'node:child_process';
|
|
11
|
+
/**
|
|
12
|
+
* Tear the runtime down to quiescence, resolving only after exit: close stdin
|
|
13
|
+
* and allow cooperative flush, then use the host's graceful and forced
|
|
14
|
+
* termination semantics. POSIX sends `SIGTERM` before `SIGKILL`; Windows
|
|
15
|
+
* skips directly to forced termination because Node maps both signals to
|
|
16
|
+
* `TerminateProcess`.
|
|
17
|
+
* @param child - the runtime child process to tear down.
|
|
18
|
+
* @param graces - the EOF and termination-confirmation windows (ms).
|
|
19
|
+
* @param platform - the host platform, injectable for unit coverage.
|
|
20
|
+
* @throws When forced termination errors or the child does not report exit
|
|
21
|
+
* within `disposeGraceMs`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function disposeRuntimeProcess(child: ChildProcess, graces: {
|
|
24
|
+
disposeEofGraceMs: number;
|
|
25
|
+
disposeGraceMs: number;
|
|
26
|
+
}, platform?: NodeJS.Platform): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=dispose.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript client SDK for the QiLin runtime: spawn the
|
|
3
|
+
* same-version `qilin --profile sdk` runtime as a subprocess and drive agent
|
|
4
|
+
* turns over stdio JSON-RPC. `DeepSeekHarness` is the high-level run API;
|
|
5
|
+
* `HarnessClient` is the lower-level protocol client. A pure library — it
|
|
6
|
+
* registers nothing on a Cordis context; named profiles and ordered patch
|
|
7
|
+
* files customize the runtime process it spawns.
|
|
8
|
+
*
|
|
9
|
+
* @module @qilin-agent/sdk-client
|
|
10
|
+
*/
|
|
11
|
+
export { DeepSeekHarness, HarnessSession } from './api.ts';
|
|
12
|
+
export type { RunOptions } from './api.ts';
|
|
13
|
+
export { HarnessClient, RequestTimeoutError, SdkProtocolError, TransportClosedError, } from './client.ts';
|
|
14
|
+
export type { NotificationSubscription } from './client.ts';
|
|
15
|
+
export { JsonRpcResponseError } from '@qilin-agent/sdk-protocol';
|
|
16
|
+
export type { ContentBlock, SdkPromptContentBlock, DeepSeekHarnessOptions, HarnessClientOptions, HarnessNotification, NotificationFilter, RunResult, } from './types.ts';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the public SDK launch configuration to one qilin subprocess.
|
|
3
|
+
* @module @qilin-agent/sdk-client/launch
|
|
4
|
+
*/
|
|
5
|
+
import type { HarnessClientOptions } from './types.ts';
|
|
6
|
+
/** Default bound for a profile to answer the SDK initialize handshake. */
|
|
7
|
+
export declare const DEFAULT_INITIALIZE_TIMEOUT_MS = 10000;
|
|
8
|
+
/** Internal generic process launch used by the transport and fake-runtime tests. */
|
|
9
|
+
export interface RuntimeProcessOptions {
|
|
10
|
+
command: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
cwd?: string;
|
|
13
|
+
/** Materialize the complete child environment when the client starts its subprocess. */
|
|
14
|
+
environment: () => NodeJS.ProcessEnv;
|
|
15
|
+
description: string;
|
|
16
|
+
initializeTimeoutMs: number;
|
|
17
|
+
requestTimeoutMs?: number;
|
|
18
|
+
shutdownTimeoutMs?: number;
|
|
19
|
+
disposeEofGraceMs?: number;
|
|
20
|
+
disposeGraceMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Node argv plus internal profile patches required by one resolved qilin entry. */
|
|
23
|
+
export interface QilinNodeLaunch {
|
|
24
|
+
/** Arguments before the profile selector. */
|
|
25
|
+
nodeArgs: string[];
|
|
26
|
+
/** Internal patches applied below caller-supplied patches. */
|
|
27
|
+
patches: string[];
|
|
28
|
+
/** Environment values required by the resolved entry mode. */
|
|
29
|
+
environment: NodeJS.ProcessEnv;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve and version-check a qilin executable from package manifests.
|
|
33
|
+
* @param qilinManifestUrl - resolved URL of the qilin package manifest.
|
|
34
|
+
* @param clientManifestUrl - resolved URL of the SDK client manifest.
|
|
35
|
+
* @returns the absolute qilin executable path.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveQilinBinFromManifests(qilinManifestUrl: string, clientManifestUrl: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve and version-check the built qilin executable installed with this SDK.
|
|
40
|
+
* @returns the absolute built executable path, whether or not it exists in a source checkout.
|
|
41
|
+
*/
|
|
42
|
+
export declare function installedQilinBin(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the Node launch for one same-version qilin package.
|
|
45
|
+
* @param qilinManifestUrl - resolved URL of the qilin package manifest.
|
|
46
|
+
* @param clientManifestUrl - resolved URL of the SDK client manifest.
|
|
47
|
+
* @param sourceLoaderUrl - optional absolute tsx loader URL for deterministic tests.
|
|
48
|
+
* @returns built output, or the source entry plus its compatibility patch and tsx environment.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveQilinNodeLaunchFromManifests(qilinManifestUrl: string, clientManifestUrl: string, sourceLoaderUrl?: string): QilinNodeLaunch;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve caller-relative filesystem inputs and construct canonical qilin argv.
|
|
53
|
+
* @param options - public SDK launch options.
|
|
54
|
+
* @param callerCwd - parent-process directory used for lexical resolution.
|
|
55
|
+
* @returns one generic subprocess spec for the JSON-RPC transport.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveQilinLaunch(options?: HarnessClientOptions, callerCwd?: string): RuntimeProcessOptions;
|
|
58
|
+
//# sourceMappingURL=launch.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the TypeScript SDK client: launch options, notification shapes,
|
|
3
|
+
* and owned activity results.
|
|
4
|
+
*
|
|
5
|
+
* @module @qilin-agent/sdk-client/types
|
|
6
|
+
*/
|
|
7
|
+
import type { ContentBlock, ReasoningEffortId } from '@qilin-agent/llm';
|
|
8
|
+
import type { SdkPromptContentBlock } from '@qilin-agent/sdk-protocol';
|
|
9
|
+
import type { SessionEvent } from '@qilin-agent/session';
|
|
10
|
+
/** One server-to-client notification as received off the wire. */
|
|
11
|
+
export interface HarnessNotification {
|
|
12
|
+
/** The JSON-RPC notification method name. */
|
|
13
|
+
method: string;
|
|
14
|
+
/** The raw params object; see `HarnessSdkNotificationMap` for the shapes per method. */
|
|
15
|
+
params: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** Predicate deciding whether a subscription receives a notification. */
|
|
18
|
+
export type NotificationFilter = (notification: HarnessNotification) => boolean;
|
|
19
|
+
/** Launch and timeout options for {@link HarnessClient}. */
|
|
20
|
+
export interface HarnessClientOptions {
|
|
21
|
+
/** Absolute or caller-relative qilin CLI module; omitted resolves this package's same-version dependency. */
|
|
22
|
+
qilinBin?: string;
|
|
23
|
+
/** Named profile serving the SDK protocol (default `sdk`). */
|
|
24
|
+
profile?: string;
|
|
25
|
+
/** Ordered per-launch profile patches; relative paths resolve before spawn. */
|
|
26
|
+
patches?: string[];
|
|
27
|
+
/** Explicit Harness home for this child; relative paths resolve before spawn. */
|
|
28
|
+
qilinHome?: string;
|
|
29
|
+
/** Working directory for the qilin process itself. */
|
|
30
|
+
processCwd?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The complete child environment, read when {@link HarnessClient.start}
|
|
33
|
+
* spawns. `undefined` reads the parent env at that time; passing an object
|
|
34
|
+
* reads that object at spawn and replaces the parent environment entirely, so callers own
|
|
35
|
+
* credential policy (see `scrubbedParentEnv` in `@qilin-agent/subprocess`
|
|
36
|
+
* for the shared scrub-then-merge base).
|
|
37
|
+
*/
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
/** Bound (ms) on the initial profile handshake (default 10000). */
|
|
40
|
+
initializeTimeoutMs?: number;
|
|
41
|
+
/** Per-request timeout (ms); `undefined` waits indefinitely (a turn can legitimately run long). */
|
|
42
|
+
requestTimeoutMs?: number;
|
|
43
|
+
/** Bound (ms) on the protocol `shutdown` exchange inside `close()` (default 1000). */
|
|
44
|
+
shutdownTimeoutMs?: number;
|
|
45
|
+
/** Grace (ms) for the runtime's stdin-EOF quiesce during `close()` (default 6000). */
|
|
46
|
+
disposeEofGraceMs?: number;
|
|
47
|
+
/** Termination confirmation window (ms) after SIGTERM/SIGKILL during `close()` (default 3000). */
|
|
48
|
+
disposeGraceMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Options for the high-level {@link DeepSeekHarness} wrapper. */
|
|
51
|
+
export interface DeepSeekHarnessOptions extends HarnessClientOptions {
|
|
52
|
+
/** Workspace cwd recorded on every SDK-created session (default: the process cwd, else `process.cwd()`). */
|
|
53
|
+
cwd?: string;
|
|
54
|
+
/** Provider route for SDK-created agents (default `deepseek-official`). */
|
|
55
|
+
provider?: string;
|
|
56
|
+
/** Model for SDK-created agents (default `deepseek-v4-flash`). */
|
|
57
|
+
model?: string;
|
|
58
|
+
/** Adapter-owned reasoning effort for the selected provider/model route. */
|
|
59
|
+
reasoningEffort?: ReasoningEffortId;
|
|
60
|
+
/** Maximum output tokens for each conversation-model request. */
|
|
61
|
+
maxTokens?: number;
|
|
62
|
+
}
|
|
63
|
+
/** One owned session activity interval, from enqueue receipt through idle. */
|
|
64
|
+
export interface RunResult {
|
|
65
|
+
/** The session the activity ran on. */
|
|
66
|
+
sessionId: string;
|
|
67
|
+
/** Concatenated text of the interval's last assistant message (empty when none). */
|
|
68
|
+
finalResponse: string;
|
|
69
|
+
/** Every `session.event` payload for the root session, in wire order. */
|
|
70
|
+
events: SessionEvent[];
|
|
71
|
+
/** Every notification for the root session and discovered descendants, in wire order. */
|
|
72
|
+
notifications: HarnessNotification[];
|
|
73
|
+
}
|
|
74
|
+
/** Re-exported content-block alias so SDK callers need no extra import. */
|
|
75
|
+
export type { ContentBlock };
|
|
76
|
+
export type { SdkPromptContentBlock };
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/sdk-client",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "TypeScript client SDK for driving a QiLin runtime subprocess over stdio JSON-RPC: the DeepSeekHarness high-level turns API and the lower-level HarnessClient",
|
|
4
|
+
"version": "3.1.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kkutysllb/QiLin.git",
|
|
11
|
+
"directory": "packages/sdk/client"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./lib/types/index.d.ts",
|
|
22
|
+
"default": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"lib/index.js",
|
|
28
|
+
"lib/types/**/*.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@qilin-agent/cli": "3.1.3"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@qilin-agent/llm": "3.1.3",
|
|
36
|
+
"@qilin-agent/sdk-protocol": "3.1.3",
|
|
37
|
+
"@qilin-agent/kylin": "~4.0.3",
|
|
38
|
+
"@qilin-agent/session": "3.1.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@qilin-agent/llm": "3.1.3",
|
|
42
|
+
"@qilin-agent/sdk-protocol": "3.1.3",
|
|
43
|
+
"@qilin-agent/session": "3.1.3",
|
|
44
|
+
"@qilin-agent/kylin": "~4.0.3"
|
|
45
|
+
}
|
|
6
46
|
}
|