@love-moon/ai-sdk 0.2.17 → 0.2.19

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/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export function createAiSession(backend: any, options?: {}): import("./session-factory.js").CodexAppServerSession | RemoteAiSession;
1
+ export function createAiSession(backend: any, options?: {}): import("./session-factory.js").CodexAppServerSession | import("./session-factory.js").ClaudeAgentSdkSession | import("./session-factory.js").OpencodeSdkSession | RemoteAiSession;
2
2
  export class RemoteAiSession extends EventEmitter<[never]> {
3
3
  constructor(backend: any, options?: {});
4
4
  backend: string;
@@ -7,7 +7,7 @@ export class RemoteAiSession extends EventEmitter<[never]> {
7
7
  variant: string;
8
8
  threadIdValue: any;
9
9
  threadOptionsValue: {
10
- model: string;
10
+ model: any;
11
11
  };
12
12
  useSessionFileReplyStreamValue: boolean;
13
13
  sessionInfo: any;
@@ -33,7 +33,7 @@ export class RemoteAiSession extends EventEmitter<[never]> {
33
33
  readyPromise: Promise<any>;
34
34
  get threadId(): any;
35
35
  get threadOptions(): {
36
- model: string;
36
+ model: any;
37
37
  };
38
38
  getSnapshot(): {
39
39
  sessionInfo: any;
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import { EventEmitter } from "node:events";
2
2
  import { spawn } from "node:child_process";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import readline from "node:readline";
5
- import { assertSupportedBackend, createLocalAiSession, DEFAULT_PROVIDER_VARIANT, } from "./session-factory.js";
5
+ import { assertSupportedBackend, createLocalAiSession, providerVariantForBackend, } from "./session-factory.js";
6
6
  import { normalizeLogger, reviveError } from "./shared.js";
7
7
  const WORKER_PATH = fileURLToPath(new URL("./worker.js", import.meta.url));
8
8
  function sanitizeOptionsForWorker(options = {}) {
@@ -29,13 +29,15 @@ export class RemoteAiSession extends EventEmitter {
29
29
  this.backend = assertSupportedBackend(backend);
30
30
  this.options = options;
31
31
  this.logger = normalizeLogger(options.logger);
32
- this.variant = DEFAULT_PROVIDER_VARIANT;
32
+ this.variant = providerVariantForBackend(this.backend);
33
33
  this.threadIdValue =
34
34
  typeof options.resumeSessionId === "string" && options.resumeSessionId.trim()
35
35
  ? options.resumeSessionId.trim()
36
36
  : "";
37
37
  this.threadOptionsValue = {
38
- model: this.backend || "unknown",
38
+ model: typeof options.model === "string" && options.model.trim()
39
+ ? options.model.trim()
40
+ : this.backend || "unknown",
39
41
  };
40
42
  this.useSessionFileReplyStreamValue = true;
41
43
  this.sessionInfo = null;
@@ -0,0 +1,141 @@
1
+ export class ClaudeAgentSdkSession extends EventEmitter<[never]> {
2
+ constructor(backend: any, options?: {});
3
+ backend: string;
4
+ options: {};
5
+ logger: any;
6
+ cwd: any;
7
+ resumeSessionId: any;
8
+ sessionId: any;
9
+ sessionInfo: {
10
+ backend: string;
11
+ sessionId: any;
12
+ } | null;
13
+ history: any[];
14
+ pendingHistorySeed: boolean;
15
+ closeRequested: boolean;
16
+ closed: boolean;
17
+ closeWaiters: Set<any>;
18
+ sessionMessageHandler: any;
19
+ workingStatusHandler: any;
20
+ activeReplyTarget: string;
21
+ lastReplyTarget: string;
22
+ manualResumeReady: boolean;
23
+ currentTurn: {
24
+ abortController: AbortController;
25
+ emittedAssistantMessage: boolean;
26
+ fullText: string;
27
+ items: never[];
28
+ query: null;
29
+ resultMessage: null;
30
+ terminalWorkingStatusEmitted: boolean;
31
+ } | null;
32
+ lastResult: any;
33
+ rateLimitInfo: any;
34
+ turnDeadlineMs: any;
35
+ sdkModulePromise: Promise<any> | Promise<typeof import("@anthropic-ai/claude-agent-sdk")> | null;
36
+ env: any;
37
+ writeLog(message: any): void;
38
+ trace(message: any): void;
39
+ get threadId(): any;
40
+ get threadOptions(): {
41
+ model: any;
42
+ };
43
+ getSnapshot(): {
44
+ backend: string;
45
+ provider: string;
46
+ cwd: any;
47
+ sessionId: any;
48
+ sessionInfo: {
49
+ backend: string;
50
+ sessionId: any;
51
+ } | null;
52
+ useSessionFileReplyStream: boolean;
53
+ resumeReady: boolean;
54
+ manualResume: {
55
+ ready: boolean;
56
+ command: string;
57
+ } | null;
58
+ };
59
+ getSessionInfo(): {
60
+ backend: string;
61
+ sessionId: any;
62
+ } | null;
63
+ ensureSessionInfo(): Promise<{
64
+ backend: string;
65
+ sessionId: any;
66
+ } | null>;
67
+ getSessionUsageSummary(): Promise<{
68
+ sessionId: any;
69
+ sessionFilePath: undefined;
70
+ totalCostUsd: number | undefined;
71
+ usage: any;
72
+ modelUsage: any;
73
+ rateLimits: any;
74
+ manualResume: {
75
+ ready: boolean;
76
+ command: string;
77
+ } | null;
78
+ }>;
79
+ usesSessionFileReplyStream(): boolean;
80
+ setSessionMessageHandler(handler: any): void;
81
+ setWorkingStatusHandler(handler: any): void;
82
+ setSessionReplyTarget(replyTo: any): void;
83
+ getCurrentReplyTarget(): string | undefined;
84
+ emitWorkingStatus(payload: any, onProgress?: null): Promise<void>;
85
+ emitAssistantMessage(text: any): Promise<void>;
86
+ emitTerminalWorkingStatus(currentTurn: any, payload: any, onProgress?: null): Promise<void>;
87
+ createSessionClosedError(): Error;
88
+ createTurnTimeoutError(timeoutMs: any): Error;
89
+ createCloseGuard(onClose: any): {
90
+ promise: Promise<any>;
91
+ cleanup: () => void;
92
+ };
93
+ createTurnTimeoutGuard(onTimeout: any): {
94
+ promise: Promise<any>;
95
+ cleanup: () => void;
96
+ };
97
+ flushCloseWaiters(): void;
98
+ buildPrompt(promptText: any, { useInitialImages }?: {
99
+ useInitialImages?: boolean | undefined;
100
+ }): string;
101
+ updateSessionInfo(sessionId: any): void;
102
+ maybeEmitAuthRequired(message: any, extraMessage?: string): void;
103
+ buildSdkOptions(abortController: any): {
104
+ abortController: any;
105
+ cwd: any;
106
+ env: any;
107
+ permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "plan" | "dontAsk";
108
+ settingSources: string[];
109
+ persistSession: boolean;
110
+ };
111
+ getSdkModule(): Promise<any>;
112
+ handleSdkMessage(message: any, currentTurn: any, { onProgress }: {
113
+ onProgress: any;
114
+ }): Promise<void>;
115
+ interruptCurrentTurn(): Promise<void>;
116
+ runTurn(promptText: any, { useInitialImages, onProgress }?: {
117
+ useInitialImages?: boolean | undefined;
118
+ onProgress?: null | undefined;
119
+ }): Promise<{
120
+ text: string;
121
+ usage: null;
122
+ items: never[];
123
+ events: never[];
124
+ provider?: undefined;
125
+ metadata?: undefined;
126
+ } | {
127
+ text: any;
128
+ usage: any;
129
+ items: never[];
130
+ events: never[];
131
+ provider: string;
132
+ metadata: {
133
+ source: string;
134
+ sessionId: any;
135
+ totalCostUsd: number | undefined;
136
+ modelUsage: any;
137
+ };
138
+ }>;
139
+ close(): Promise<void>;
140
+ }
141
+ import { EventEmitter } from "node:events";