@cartanova/qgrid-ai-sdk 2.0.2 → 2.1.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/README.md CHANGED
@@ -221,6 +221,7 @@ type QgridSupportedModel =
221
221
  | "anthropic/claude-opus-4-5"
222
222
  | "anthropic/claude-opus-4-6"
223
223
  | "anthropic/claude-opus-4-7"
224
+ | "anthropic/claude-opus-4-8"
224
225
  ```
225
226
 
226
227
  ## 설정
package/dist/index.d.ts CHANGED
@@ -28,11 +28,17 @@ type QgridOpenAIProviderOptions = {
28
28
  type QgridProviderOptions = {
29
29
  openai?: QgridOpenAIProviderOptions;
30
30
  };
31
- type QgridSupportedModel = "openai/gpt-5.5" | "openai/gpt-5.4" | "openai/gpt-5.2" | "openai/gpt-5.4-mini" | "openai/gpt-5.3-codex" | "openai/gpt-5.3-codex-spark" | "anthropic/claude-haiku-4-5" | "anthropic/claude-sonnet-4" | "anthropic/claude-sonnet-4-5" | "anthropic/claude-sonnet-4-6" | "anthropic/claude-sonnet-4-7" | "anthropic/claude-opus-4" | "anthropic/claude-opus-4-1" | "anthropic/claude-opus-4-5" | "anthropic/claude-opus-4-6" | "anthropic/claude-opus-4-7";
31
+ type QgridSupportedModel = "openai/gpt-5.5" | "openai/gpt-5.4" | "openai/gpt-5.2" | "openai/gpt-5.4-mini" | "openai/gpt-5.3-codex" | "openai/gpt-5.3-codex-spark" | "anthropic/claude-haiku-4-5" | "anthropic/claude-sonnet-4" | "anthropic/claude-sonnet-4-5" | "anthropic/claude-sonnet-4-6" | "anthropic/claude-sonnet-4-7" | "anthropic/claude-opus-4" | "anthropic/claude-opus-4-1" | "anthropic/claude-opus-4-5" | "anthropic/claude-opus-4-6" | "anthropic/claude-opus-4-7" | "anthropic/claude-opus-4-8";
32
32
  type QgridLoggerConfig = {
33
- /** qgrid 서버 주소. 기본값: QGRID_URL 환경변수 또는 http://localhost:44900 */
33
+ /** qgrid 서버 주소. default: process.env.QGRID_URL, 없으면 기본값은 "http://localhost:44900" */
34
34
  serverUrl?: string;
35
+ /**
36
+ * 프로젝트 이름. default: process.env.QGRID_PROJECT_NAME, 없으면 기본값은 ""
37
+ */
35
38
  projectName?: string;
39
+ /**
40
+ * 토큰 이름. 외부에서 호출할경우 기본값은 "external"
41
+ */
36
42
  tokenName?: string;
37
43
  /**
38
44
  * Fallback timeout for runs that receive onStart but never receive onFinish.
package/dist/index.js CHANGED
@@ -239,6 +239,8 @@ function timedKeySet() {
239
239
  }
240
240
  function createQgridLogger(config = {}) {
241
241
  const serverUrl = config.serverUrl ?? process.env.QGRID_URL ?? "http://localhost:44900";
242
+ const projectName = config.projectName ?? process.env.QGRID_PROJECT_NAME;
243
+ config.tokenName ?? process.env.QGRID_TOKEN_NAME;
242
244
  const onLogError = config.onLogError ?? ((e) => console.warn(`[qgrid-logger] ${e.message}`));
243
245
  const runs = /* @__PURE__ */ new Map();
244
246
  const keyTtl = typeof config.staleRunTimeoutMs === "number" && config.staleRunTimeoutMs > 0 ? config.staleRunTimeoutMs : DEFAULT_STALE_RUN_TIMEOUT_MS;
@@ -273,7 +275,6 @@ function createQgridLogger(config = {}) {
273
275
  totalCacheReadTokens: result.totalUsage?.inputTokenDetails?.cacheReadTokens ?? 0,
274
276
  totalCacheCreationTokens: result.totalUsage?.inputTokenDetails?.cacheWriteTokens ?? 0,
275
277
  totalDurationMs: Date.now() - run.startTime,
276
- history: run.history,
277
278
  ...result.errorMessage ? { errorMessage: result.errorMessage } : {}
278
279
  }).catch((e) => onLogError(e instanceof Error ? e : new Error(String(e))));
279
280
  };
@@ -310,11 +311,13 @@ function createQgridLogger(config = {}) {
310
311
  }
311
312
  try {
312
313
  const messages = event.messages ?? (Array.isArray(event.prompt) ? event.prompt : void 0);
314
+ const history = serializeHistory(messages);
313
315
  const result = await createRun(serverUrl, {
314
316
  userPrompt: extractUserPrompt(event.prompt, messages),
315
317
  systemPrompt: extractSystemPrompt(event.system),
316
318
  modelName: event.model.modelId,
317
- projectName: config.projectName
319
+ projectName,
320
+ history
318
321
  });
319
322
  let watchdogTimeout = DEFAULT_STALE_RUN_TIMEOUT_MS;
320
323
  if (typeof config.staleRunTimeoutMs === "number") watchdogTimeout = config.staleRunTimeoutMs;
@@ -354,7 +357,6 @@ function createQgridLogger(config = {}) {
354
357
  pendingToolCalls: [],
355
358
  startTime: Date.now(),
356
359
  toolDurations: /* @__PURE__ */ new Map(),
357
- history: serializeHistory(messages),
358
360
  watchdog,
359
361
  cleanupAbortListener,
360
362
  finishing: false
@@ -591,6 +593,7 @@ function qgrid(modelId, config) {
591
593
  const jsonSchema = !hasTools && rawSchema && rawSchema.type === "object" ? JSON.stringify(rawSchema) : void 0;
592
594
  let runContext;
593
595
  let toolResultsPayload;
596
+ let logMode;
594
597
  if (clientRun) {
595
598
  const toolResults = extractToolResultsFromHistory(options.prompt);
596
599
  const resultIds = new Set(toolResults.map((r) => r.callId));
@@ -600,11 +603,13 @@ function qgrid(modelId, config) {
600
603
  toolCallId: r.callId,
601
604
  output: r.result
602
605
  }));
606
+ logMode = "run";
603
607
  } else {
604
608
  console.warn("[qgrid] pending tool results not found in prompt, clearing client run state");
605
609
  clientRun = null;
606
610
  }
607
611
  }
612
+ if (!logMode && hasTools) logMode = "run";
608
613
  const prepRes = await fetch(`${serverUrl}/api/qgrid/prepareStream`, {
609
614
  method: "POST",
610
615
  headers: { "Content-Type": "application/json" },
@@ -618,7 +623,7 @@ function qgrid(modelId, config) {
618
623
  ...hasTools ? { tools: tools.map(toQgridTool) } : {},
619
624
  ...jsonSchema ? { jsonSchema } : {},
620
625
  ...history.length > 0 ? { history: JSON.stringify(history) } : {},
621
- logMode: "run",
626
+ ...logMode ? { logMode } : {},
622
627
  ...runContext ? { runContext } : {},
623
628
  ...toolResultsPayload ? { toolResults: toolResultsPayload } : {}
624
629
  } }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartanova/qgrid-ai-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "AI SDK LanguageModelV3 provider for qgrid",
5
5
  "repository": {
6
6
  "type": "git",