@adaptiqai/deepseek-harness 0.2.6 → 0.2.11
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 +11 -9
- package/lib/client.js +4 -4
- package/lib/host.js +6123 -0
- package/lib/index.js +78 -4857
- package/lib/typert.host.js +54 -18
- package/lib/typert.remote-client.js +40 -18
- package/lib/types/client/Chips.d.ts +2 -0
- package/lib/types/client/Extras.d.ts +0 -6
- package/lib/types/client/Knowledge.d.ts +26 -0
- package/lib/types/client/Overlay.d.ts +13 -1
- package/lib/types/client/SettingsPage.d.ts +9 -0
- package/lib/types/client/Update.d.ts +48 -0
- package/lib/types/client/actions.d.ts +6 -0
- package/lib/types/client/attach.d.ts +62 -9
- package/lib/types/client/store.d.ts +2 -0
- package/lib/types/host/adapter.d.ts +22 -5
- package/lib/types/host/commands.d.ts +3 -0
- package/lib/types/host/controller.d.ts +6 -0
- package/lib/types/host/entry.d.ts +29 -0
- package/lib/types/host/index.d.ts +15 -1
- package/lib/types/host/relations.d.ts +23 -0
- package/lib/types/host/stream.d.ts +3 -1
- package/lib/types/host/tools.d.ts +1 -1
- package/lib/types/host/updater.d.ts +43 -0
- package/lib/types/host/wire.d.ts +31 -2
- package/package.json +3 -2
|
@@ -47,6 +47,8 @@ export interface AdaptiqRemote {
|
|
|
47
47
|
refresh(): Promise<RemoteResult<AccountSnapshot>>;
|
|
48
48
|
setPreferences(patch: Partial<Preferences>): Promise<RemoteResult<Preferences>>;
|
|
49
49
|
dismissNotice(id: string): Promise<RemoteResult<void>>;
|
|
50
|
+
updatePlugin(): Promise<RemoteResult<void>>;
|
|
51
|
+
activateUpdate(): Promise<RemoteResult<void>>;
|
|
50
52
|
getSession(sessionId: string): Promise<RemoteResult<SessionView>>;
|
|
51
53
|
watchSession(sessionId: string, signal?: AbortSignal): AsyncIterable<SessionView> & {
|
|
52
54
|
dispose(): void;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { LlmAdapter, LlmError } from '@deepseek-ai/dsh-llm';
|
|
8
8
|
import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
9
|
-
import { type AdaptiqFailure, type AuthManager, type CatalogModel, type RequestEvents } from '@adaptiqai/core';
|
|
10
|
-
import { type ReferencedSession } from './wire.ts';
|
|
9
|
+
import { type AdaptiqFailure, type AuthManager, type CatalogModel, type RequestEvents, type UserTurn } from '@adaptiqai/core';
|
|
10
|
+
import { type ParentSession, type ReferencedSession } from './wire.ts';
|
|
11
11
|
/** What the adapter tells the rest of the plugin about each request. */
|
|
12
12
|
export interface AdapterDeps {
|
|
13
13
|
readonly route: string;
|
|
@@ -33,13 +33,27 @@ export interface AdapterDeps {
|
|
|
33
33
|
* @returns session id → name of those attached and ready to read from memory.
|
|
34
34
|
*/
|
|
35
35
|
recall?(sessionId: string, model: string, references: readonly ReferencedSession[], signal: AbortSignal): Promise<ReadonlyMap<string, string>>;
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/** Attach what was added to the conversation before this, its first, message. */
|
|
37
|
+
attachPending?(sessionId: string): Promise<void>;
|
|
38
|
+
/** What the person wrote in this conversation (their own messages, marked when they answer an offer to save knowledge), for the tools' guards. */
|
|
39
|
+
noteUserTexts?(sessionId: string, texts: readonly UserTurn[]): void;
|
|
40
|
+
/** The session that started this one (a subagent's or teammate's parent), if any. */
|
|
41
|
+
parentSession?(sessionId: string): ParentSession | undefined;
|
|
38
42
|
readonly events: RequestEvents;
|
|
43
|
+
/** Whether the server behind a model puts idle conversations to sleep (it reports session history apart). */
|
|
44
|
+
readonly autoSleep?: (model: string) => boolean;
|
|
39
45
|
/** Diagnostics for one request (no content), when a debug log is on. */
|
|
40
46
|
debug?(message: string): void;
|
|
41
47
|
readonly fetch?: typeof fetch;
|
|
42
48
|
}
|
|
49
|
+
/** How long a first message waits for what was added before it to attach. */
|
|
50
|
+
export declare const ATTACH_WAIT_MS = 10000;
|
|
51
|
+
/**
|
|
52
|
+
* How often a conversation is told that it needs no compacting. The harness asks
|
|
53
|
+
* again at every step once its history passes its pressure threshold; the
|
|
54
|
+
* answer is the same each time and one toast says it.
|
|
55
|
+
*/
|
|
56
|
+
export declare const COMPACTION_NOTICE_MS: number;
|
|
43
57
|
/** The harness retries busy and preparing answers itself, honouring Retry-After. */
|
|
44
58
|
export declare const RETRY_POLICY: ResolvedRetryPolicy;
|
|
45
59
|
/**
|
|
@@ -53,8 +67,11 @@ export declare function resolvedInfo(route: string, model: CatalogModel): LlmRes
|
|
|
53
67
|
export declare function toLlmError(failure: AdaptiqFailure, cause?: unknown): LlmError;
|
|
54
68
|
export declare class AdaptiqAdapter extends LlmAdapter {
|
|
55
69
|
private readonly deps;
|
|
70
|
+
private readonly now;
|
|
56
71
|
private readonly fetch;
|
|
57
|
-
|
|
72
|
+
/** When each conversation was last told that nothing needs compacting. */
|
|
73
|
+
private readonly compactionTold;
|
|
74
|
+
constructor(deps: AdapterDeps, now?: () => number);
|
|
58
75
|
providerInfo(provider: string): LlmProviderInfo;
|
|
59
76
|
providerRetryPolicy(): ResolvedRetryPolicy;
|
|
60
77
|
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** `/adaptiq`: status, sign-in, privacy and knowledge from the composer, in plain text. */
|
|
2
2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import { type AuthManager, type Workspace } from '@adaptiqai/core';
|
|
4
|
+
export declare const HELP: string;
|
|
5
|
+
/** The actions the composer offers after `/adaptiq`: every one HELP lists. */
|
|
6
|
+
export declare const HINT = "status \u00B7 signin \u00B7 private \u00B7 remember \u00B7 knowledge \u00B7 open \u00B7 diagnostics \u00B7 signout";
|
|
4
7
|
/**
|
|
5
8
|
* The action word of `/adaptiq …`, however the composer passes it: with or
|
|
6
9
|
* without the command name, a leading slash, or a completion glued on with "/".
|
|
@@ -30,6 +30,8 @@ export declare class AdaptiqController extends TypertRemoteService {
|
|
|
30
30
|
private readonly deps;
|
|
31
31
|
static inject: string[];
|
|
32
32
|
constructor(ctx: Context, deps: ControllerDeps);
|
|
33
|
+
/** A stream ends when its caller leaves or this plugin code is replaced (an update loaded in place). */
|
|
34
|
+
private until;
|
|
33
35
|
/** Read the current account snapshot. */
|
|
34
36
|
getState(): Promise<AccountSnapshot>;
|
|
35
37
|
/** Follow the account snapshot: the current one, then every change. */
|
|
@@ -46,6 +48,10 @@ export declare class AdaptiqController extends TypertRemoteService {
|
|
|
46
48
|
setPreferences(patch: Partial<Preferences>): Promise<Preferences>;
|
|
47
49
|
/** Take one notice down. */
|
|
48
50
|
dismissNotice(id: string): Promise<void>;
|
|
51
|
+
/** Install the newest published version through the harness and load it, without a restart where the harness allows. */
|
|
52
|
+
updatePlugin(): Promise<void>;
|
|
53
|
+
/** Switch to the newer version already installed on disk. */
|
|
54
|
+
activateUpdate(): Promise<void>;
|
|
49
55
|
/** Read one conversation's memory and knowledge. */
|
|
50
56
|
getSession(sessionIdValue: string): Promise<SessionView>;
|
|
51
57
|
/** Follow one conversation's memory and request state. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { Config } from './config.ts';
|
|
3
|
+
import type { HostRuntime } from './updater.ts';
|
|
4
|
+
export { Config };
|
|
5
|
+
export declare const name = "adaptiq";
|
|
6
|
+
export declare const inject: string[];
|
|
7
|
+
export declare const usage = "\nAdaptiqAI models with native memory, signed in with your AdaptiqAI account.\nOpen **Settings \u2192 AdaptiqAI** to connect, or run `/adaptiq signin`.\n";
|
|
8
|
+
/** What this loader offers the code it loads; bumped when that changes. */
|
|
9
|
+
export declare const ENTRY_PROTOCOL = 1;
|
|
10
|
+
/** What lib/host.js exports. */
|
|
11
|
+
export interface HostModule {
|
|
12
|
+
applyWith(ctx: Context, config: Config, runtime: HostRuntime | undefined): Promise<void>;
|
|
13
|
+
/** Remote methods, composition and configuration schema: equal means the new code can replace the old in place. */
|
|
14
|
+
readonly RELOAD_SIGNATURE: string;
|
|
15
|
+
readonly ENTRY_PROTOCOL: number;
|
|
16
|
+
readonly VERSION: string;
|
|
17
|
+
}
|
|
18
|
+
/** Where the Host half and the package manifest live, beside this file. */
|
|
19
|
+
export interface HostFiles {
|
|
20
|
+
readonly host: URL;
|
|
21
|
+
readonly manifest: URL;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mount the plugin through the swappable Host half.
|
|
25
|
+
* @param ctx - the plugin context.
|
|
26
|
+
* @param config - resolved configuration.
|
|
27
|
+
* @param files - where the code lives (tests point elsewhere).
|
|
28
|
+
*/
|
|
29
|
+
export declare function apply(ctx: Context, config: Config, files?: HostFiles): Promise<void>;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import { Config } from './config.ts';
|
|
3
|
+
import { type HostRuntime } from './updater.ts';
|
|
3
4
|
export { Config };
|
|
4
5
|
export declare const name = "adaptiq";
|
|
5
6
|
export declare const inject: string[];
|
|
6
7
|
export declare const usage = "\nAdaptiqAI models with native memory, signed in with your AdaptiqAI account.\nOpen **Settings \u2192 AdaptiqAI** to connect, or run `/adaptiq signin`.\n";
|
|
8
|
+
/** The loader protocol this code expects (entry.ts ENTRY_PROTOCOL). */
|
|
9
|
+
export declare const ENTRY_PROTOCOL = 1;
|
|
10
|
+
/** Remote methods, composition and configuration schema, fixed at build time. */
|
|
11
|
+
export declare const RELOAD_SIGNATURE: string;
|
|
12
|
+
/** The version of this code. */
|
|
13
|
+
export declare const VERSION: string;
|
|
7
14
|
/**
|
|
8
|
-
* Mount the plugin.
|
|
15
|
+
* Mount the plugin, loaded directly.
|
|
9
16
|
* @param ctx - the plugin context.
|
|
10
17
|
* @param config - resolved configuration.
|
|
11
18
|
*/
|
|
12
19
|
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Mount the plugin.
|
|
22
|
+
* @param ctx - the plugin context.
|
|
23
|
+
* @param raw - configuration, resolved again with this version's own defaults.
|
|
24
|
+
* @param runtime - the loader's update hooks, when lib/index.js loaded this code.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyWith(ctx: Context, raw: Config, runtime: HostRuntime | undefined): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a live harness session came from: its subagents are helpers of the
|
|
3
|
+
* session that started them, its Agent Team's teammates are tracks. Read from
|
|
4
|
+
* the harness's own services, all optional.
|
|
5
|
+
*/
|
|
6
|
+
import { type ParentSession, type SessionOrigin } from './wire.ts';
|
|
7
|
+
/** A live harness Agent, as `agents` returns it. */
|
|
8
|
+
export interface AgentLike {
|
|
9
|
+
readonly session?: {
|
|
10
|
+
readonly header?: SessionOrigin;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** The harness context, as far as this reads it. */
|
|
14
|
+
export interface ServicesLike {
|
|
15
|
+
get(name: string): unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The session that started a live harness session.
|
|
19
|
+
* @param ctx - the plugin context.
|
|
20
|
+
* @param sessionId - harness session id.
|
|
21
|
+
* @returns the parent and role, or undefined for a root session or one not loaded.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sessionParent(ctx: ServicesLike, sessionId: string): ParentSession | undefined;
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* finish, nothing after finish.
|
|
5
5
|
*/
|
|
6
6
|
import type { StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
7
|
-
import { type SseEvent } from '@adaptiqai/core';
|
|
7
|
+
import { type MemoryNotice, type SseEvent } from '@adaptiqai/core';
|
|
8
8
|
export { mapUsage, parseSse, type SseEvent } from '@adaptiqai/core';
|
|
9
9
|
/** Hooks the translator calls as the stream unfolds. */
|
|
10
10
|
export interface TranslateHooks {
|
|
11
11
|
/** A server progress frame (`adaptiq.progress`): stage such as `context.preparing` or `inference.queued`. */
|
|
12
12
|
onProgress?(stage: string, elapsedMs: number | null): void;
|
|
13
|
+
/** The engine put idle conversations to sleep, or suggests which may (`adaptiq.memory`). */
|
|
14
|
+
onMemoryNotice?(notice: MemoryNotice): void;
|
|
13
15
|
/** The first visible output (text, thinking or a tool call) arrived. */
|
|
14
16
|
onFirstOutput?(): void;
|
|
15
17
|
/** An in-band error: map it to the thrown failure. */
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updating the plugin from inside the harness: the profile's plugin manager
|
|
3
|
+
* (`pluginManager`, the service behind the Plugins page) installs the
|
|
4
|
+
* version, and the loader in lib/index.js swaps the running Host half for the
|
|
5
|
+
* new code (see entry.ts).
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import { type PluginUpdater, UpdateFailure } from '@adaptiqai/core';
|
|
9
|
+
/** What lib/index.js offers the code it loads; absent when this module was loaded directly. */
|
|
10
|
+
export interface HostRuntime {
|
|
11
|
+
/** The version in the package.json on disk now, or null when it cannot be read. */
|
|
12
|
+
installedVersion(): string | null;
|
|
13
|
+
/** Whether the code on disk can replace the running code in place (same Remote methods and composition). */
|
|
14
|
+
canReload(): Promise<boolean>;
|
|
15
|
+
/** Replace the running Host half with the code on disk, right after this call returns. */
|
|
16
|
+
reload(): Promise<'reloaded' | 'restart'>;
|
|
17
|
+
}
|
|
18
|
+
interface ChangeResultLike {
|
|
19
|
+
application: 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
20
|
+
error?: {
|
|
21
|
+
code: string;
|
|
22
|
+
diagnostic?: string;
|
|
23
|
+
};
|
|
24
|
+
packageResult?: {
|
|
25
|
+
kind?: string;
|
|
26
|
+
output?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Why an install did not finish, in the words the person is told.
|
|
31
|
+
* @param result - the plugin manager's outcome.
|
|
32
|
+
* @returns the failure.
|
|
33
|
+
*/
|
|
34
|
+
export declare function installFailure(result: ChangeResultLike): UpdateFailure;
|
|
35
|
+
/**
|
|
36
|
+
* The updater for this harness.
|
|
37
|
+
* @param ctx - the plugin context.
|
|
38
|
+
* @param name - the plugin's package name.
|
|
39
|
+
* @param runtime - the loader's reload hooks, when lib/index.js loaded this code.
|
|
40
|
+
* @returns the updater the Workspace drives.
|
|
41
|
+
*/
|
|
42
|
+
export declare function harnessUpdater(ctx: Context, name: string, runtime: HostRuntime | undefined): PluginUpdater;
|
|
43
|
+
export {};
|
package/lib/types/host/wire.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* model's catalog entry.
|
|
5
5
|
*/
|
|
6
6
|
import type { GenerateOptions, RequestMessage } from '@deepseek-ai/dsh-llm';
|
|
7
|
-
import { type CatalogModel } from '@adaptiqai/core';
|
|
7
|
+
import { type CatalogModel, type SessionRole, type UserTurn } from '@adaptiqai/core';
|
|
8
8
|
/** One Chat Completions message. */
|
|
9
9
|
export type WireMessage = {
|
|
10
10
|
role: 'system';
|
|
@@ -83,6 +83,13 @@ export declare function recallSnapshot(text: string, references: readonly Refere
|
|
|
83
83
|
* @returns the text of each of the person's messages, oldest first.
|
|
84
84
|
*/
|
|
85
85
|
export declare function userTexts(messages: readonly RequestMessage[]): string[];
|
|
86
|
+
/**
|
|
87
|
+
* What the person wrote in the request history, each message marked when it
|
|
88
|
+
* answers the agent's offer to save knowledge (the agent asked right before).
|
|
89
|
+
* @param messages - the request history.
|
|
90
|
+
* @returns the person's turns, oldest first.
|
|
91
|
+
*/
|
|
92
|
+
export declare function userTurns(messages: readonly RequestMessage[]): UserTurn[];
|
|
86
93
|
/**
|
|
87
94
|
* Convert the harness history to Chat Completions messages.
|
|
88
95
|
* @param options - the harness request.
|
|
@@ -98,10 +105,32 @@ export declare function wireMessages(options: Pick<GenerateOptions, 'messages' |
|
|
|
98
105
|
* @returns the JSON body.
|
|
99
106
|
*/
|
|
100
107
|
export declare function buildChatBody(options: GenerateOptions, model: CatalogModel | null, extras: WireExtras): Record<string, unknown>;
|
|
108
|
+
/** The session that started a session, and how it relates to it. */
|
|
109
|
+
export interface ParentSession {
|
|
110
|
+
readonly parentSessionId: string;
|
|
111
|
+
readonly role: SessionRole;
|
|
112
|
+
}
|
|
113
|
+
/** What a harness session header says about where the session came from. */
|
|
114
|
+
export interface SessionOrigin {
|
|
115
|
+
readonly parentSession?: string;
|
|
116
|
+
readonly origin?: string;
|
|
117
|
+
readonly delegationDepth?: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The parent of a harness session. A subagent (`origin: 'subagent'` or a
|
|
121
|
+
* delegation depth) works for its parent: `helper`; a member of the parent's
|
|
122
|
+
* Agent Team is its own line of work: `track`. A root session and a fork the
|
|
123
|
+
* person made (`parentSession` without delegation) have none.
|
|
124
|
+
* @param header - the session's header.
|
|
125
|
+
* @param teammate - whether the Agent Team service counts the session as a teammate.
|
|
126
|
+
* @returns the parent and role, or undefined.
|
|
127
|
+
*/
|
|
128
|
+
export declare function parentSession(header: SessionOrigin | undefined, teammate: boolean): ParentSession | undefined;
|
|
101
129
|
/**
|
|
102
130
|
* The session headers for one call. A title request carries none: it reuses the
|
|
103
131
|
* conversation id with a different history and must not fork the saved conversation.
|
|
104
132
|
* @param options - the harness request.
|
|
133
|
+
* @param parent - the session that started this one, if any.
|
|
105
134
|
* @returns header name → value.
|
|
106
135
|
*/
|
|
107
|
-
export declare function sessionHeaders(options: Pick<GenerateOptions, 'sessionId' | 'purpose'
|
|
136
|
+
export declare function sessionHeaders(options: Pick<GenerateOptions, 'sessionId' | 'purpose'>, parent?: ParentSession): Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptiqai/deepseek-harness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "AdaptiqAI for DeepSeek Harness: models with 5M-token native memory and Knowledge. Sign up, get a model and work without leaving the harness",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"cordis.patch.yml",
|
|
43
43
|
"locale/*.json",
|
|
44
44
|
"lib/index.js",
|
|
45
|
+
"lib/host.js",
|
|
45
46
|
"lib/client.js",
|
|
46
47
|
"lib/typert.host.js",
|
|
47
48
|
"lib/typert.host.d.ts",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"react-dom": "~18.3.1",
|
|
90
91
|
"typescript": "~5.9.3",
|
|
91
92
|
"vitest": "~3.2.7",
|
|
92
|
-
"@adaptiqai/core": "0.2.
|
|
93
|
+
"@adaptiqai/core": "0.2.7"
|
|
93
94
|
},
|
|
94
95
|
"repository": {
|
|
95
96
|
"type": "git",
|