@g9tm/aiassistant 1.5.0 → 1.6.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/dist/api.d.ts CHANGED
@@ -17,6 +17,8 @@ export interface SendInput {
17
17
  subjectId?: string;
18
18
  subjectLabel?: string;
19
19
  };
20
+ /** The model a person picked (`id` or `id@effort`), kept on the conversation; the host must let them choose. */
21
+ model?: string;
20
22
  }
21
23
  export interface EventPage {
22
24
  events: RawEvent[];
package/dist/api.js CHANGED
@@ -59,6 +59,8 @@ export class AssistantApi {
59
59
  body["files"] = input.files;
60
60
  if (input.page)
61
61
  body["page"] = input.page;
62
+ if (input.model)
63
+ body["model"] = input.model;
62
64
  return this.request("POST", path, body).then((r) => ({ conversationId: str(obj(r)["conversationId"]), runId: str(obj(r)["runId"]) }));
63
65
  }
64
66
  async events(runId, after, wait) {
@@ -54,6 +54,8 @@ export declare class Assistant {
54
54
  /** Plans whose confirmation is in flight: no second confirmation and no refusal until it answers. */
55
55
  private readonly confirming;
56
56
  private attachments;
57
+ /** The model a person picked for what they send next (`id` or `id@effort`); null lets the route decide. */
58
+ model: string | null;
57
59
  private error;
58
60
  private stateNow;
59
61
  constructor(host: AssistantHost, options?: AssistantOptions);
package/dist/assistant.js CHANGED
@@ -27,6 +27,8 @@ export class Assistant {
27
27
  /** Plans whose confirmation is in flight: no second confirmation and no refusal until it answers. */
28
28
  this.confirming = new Set();
29
29
  this.attachments = [];
30
+ /** The model a person picked for what they send next (`id` or `id@effort`); null lets the route decide. */
31
+ this.model = null;
30
32
  this.error = null;
31
33
  this.api = new AssistantApi(host, options.base);
32
34
  this.texts = createTexts(host.locale, options.texts);
@@ -99,6 +101,8 @@ export class Assistant {
99
101
  input.files = this.attachments.map((a) => a.id);
100
102
  if (page)
101
103
  input.page = page;
104
+ if (this.model)
105
+ input.model = this.model;
102
106
  try {
103
107
  const t = await this.api.send(input);
104
108
  this.store.id = t.conversationId;
package/dist/history.d.ts CHANGED
@@ -7,7 +7,23 @@ export interface ConversationRow {
7
7
  waiting: boolean;
8
8
  /** When it last changed (milliseconds since 1970). */
9
9
  updatedAt: number;
10
+ /** The model it keeps (`id` or `id@effort`), if any. */
11
+ model?: string;
10
12
  }
13
+ /** A model a person may pick (`GET models`). */
14
+ export interface ModelChoice {
15
+ id: string;
16
+ kind: string;
17
+ ready: boolean;
18
+ /** Why it cannot answer now (`usage_limit`...), and when it opens again (milliseconds since 1970). */
19
+ unavailable?: string;
20
+ availableAt?: number;
21
+ }
22
+ /** Reads `GET models`: whether the person may pick at all, and the models to pick from. */
23
+ export declare function readModels(raw: unknown): {
24
+ choose: boolean;
25
+ models: ModelChoice[];
26
+ };
11
27
  export type HistoryTab = "today" | "earlier" | "pinned" | "waiting";
12
28
  export declare const HISTORY_TABS: readonly HistoryTab[];
13
29
  /** Reads the server's list (`GET conversations`), pinned first and then the newest. */
package/dist/history.js CHANGED
@@ -1,5 +1,19 @@
1
1
  /** The person's conversations as tabs: today, earlier, pinned and waiting for their code, each with its count. */
2
2
  import { latinDigits } from "./fa.js";
3
+ /** Reads `GET models`: whether the person may pick at all, and the models to pick from. */
4
+ export function readModels(raw) {
5
+ const r = obj(raw);
6
+ const list = Array.isArray(r["models"]) ? r["models"] : [];
7
+ const models = list.map(obj).filter((m) => typeof m["id"] === "string" && m["id"].length > 0).map((m) => {
8
+ const row = { id: m["id"], kind: typeof m["kind"] === "string" ? m["kind"] : "", ready: m["ready"] === true };
9
+ if (typeof m["unavailable"] === "string")
10
+ row.unavailable = m["unavailable"];
11
+ if (typeof m["availableAt"] === "number")
12
+ row.availableAt = m["availableAt"];
13
+ return row;
14
+ });
15
+ return { choose: r["choose"] === true, models };
16
+ }
3
17
  export const HISTORY_TABS = ["today", "earlier", "pinned", "waiting"];
4
18
  function obj(v) {
5
19
  return v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
@@ -14,6 +28,7 @@ export function readConversations(raw) {
14
28
  pinned: c["pinned"] === true,
15
29
  waiting: c["waiting"] === true,
16
30
  updatedAt: typeof c["updatedAt"] === "number" ? c["updatedAt"] : 0,
31
+ ...(typeof c["model"] === "string" ? { model: c["model"] } : {}),
17
32
  })).filter((c) => c.id.length > 0);
18
33
  return rows.sort((a, b) => Number(b.pinned) - Number(a.pinned) || b.updatedAt - a.updatedAt);
19
34
  }
package/dist/pages.d.ts CHANGED
@@ -18,6 +18,8 @@ export declare const pageCalls: {
18
18
  preview: (api: AssistantApi, routineId: string, values: Readonly<Record<string, string>>, conversationId?: string) => Promise<unknown>;
19
19
  /** Runs a previewed routine with the person's confirmation. */
20
20
  run: (api: AssistantApi, routineId: string, routineRunId: string, hash: string, code?: string) => Promise<unknown>;
21
+ /** The models the person may pick for a conversation (`readModels` reads the answer). */
22
+ models: (api: AssistantApi) => Promise<unknown>;
21
23
  };
22
24
  /**
23
25
  * Starts a run of a non-conversation capability (`POST capabilities/{id}/runs`, for a host's own screens without a
package/dist/pages.js CHANGED
@@ -17,6 +17,8 @@ export const pageCalls = {
17
17
  preview: (api, routineId, values, conversationId) => api.post("routines/" + enc(routineId) + "/preview", conversationId ? { values, conversationId } : { values }),
18
18
  /** Runs a previewed routine with the person's confirmation. */
19
19
  run: (api, routineId, routineRunId, hash, code) => api.post("routines/" + enc(routineId) + "/run", code ? { routineRunId, hash, code } : { routineRunId, hash }),
20
+ /** The models the person may pick for a conversation (`readModels` reads the answer). */
21
+ models: (api) => api.get("models"),
20
22
  };
21
23
  /**
22
24
  * Starts a run of a non-conversation capability (`POST capabilities/{id}/runs`, for a host's own screens without a
@@ -70,6 +72,14 @@ const PAGE_FA = {
70
72
  "page.actions.empty": "هنوز کاری انجام نشده است",
71
73
  "routine.type_to_search": "نامش را بنویسید",
72
74
  "confirm.remote_expired": "تأیید روی گوشی منقضی شد؛ دوباره بخواهید یا کد را وارد کنید",
75
+ "model.label": "مدل",
76
+ "model.auto": "خودکار",
77
+ "model.unavailable": "در دسترس نیست",
78
+ "model.effort": "عمق فکر",
79
+ "model.effort.default": "پیش‌فرض",
80
+ "model.effort.low": "کم",
81
+ "model.effort.medium": "متوسط",
82
+ "model.effort.high": "زیاد",
73
83
  "confirm.remote_refused": "روی گوشی رد شد",
74
84
  };
75
85
  const PAGE_EN = {
@@ -110,6 +120,14 @@ const PAGE_EN = {
110
120
  "page.actions.empty": "No actions yet",
111
121
  "routine.type_to_search": "Type its name",
112
122
  "confirm.remote_expired": "The approval on your phone expired: ask again or enter the code",
123
+ "model.label": "Model",
124
+ "model.auto": "Automatic",
125
+ "model.unavailable": "unavailable",
126
+ "model.effort": "Thinking",
127
+ "model.effort.default": "Default",
128
+ "model.effort.low": "Low",
129
+ "model.effort.medium": "Medium",
130
+ "model.effort.high": "High",
113
131
  "confirm.remote_refused": "It was refused on your phone",
114
132
  };
115
133
  /** The pages' texts over the assistant's: the host's texts and the core's win, then the pages' own. */
package/dist/types.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare const DEFAULT_THRESHOLDS: LayoutThresholds;
11
11
  /** The layout "auto" picks for a container width. */
12
12
  export declare function pickLayout(layout: Layout, containerWidth: number, thresholds?: LayoutThresholds): Exclude<Layout, "auto">;
13
13
  /** The stable part names hosts style and replace (layer 3): part of the public, versioned contract. */
14
- export declare const PARTS: readonly ["panel", "panel.header", "panel.body", "panel.footer", "hero", "bar-button", "ask-about", "chat", "messages", "message", "message.user", "message.assistant", "message.text", "message.provenance", "message.feedback", "composer", "composer.input", "composer.attach", "composer.mic", "composer.send", "composer.stop", "file-chips", "file-chip", "work", "work.stage", "work.progress", "work.tool", "work.elapsed", "card.approval", "card.approval.step", "card.approval.fact", "card.approval.code", "card.approval.confirm", "card.approval.refuse", "card.undo", "card.ask", "card.choice", "secret-field", "block", "block.text", "block.callout", "block.table", "block.table.card", "block.chart", "block.chart.bar", "block.chart.line", "block.kpi", "block.steps", "block.actions", "block.action", "block.flow", "block.image", "block.open", "block.fallback", "mode-banner", "usage-chip", "thinking-orb", "stages-thinking", "reveal-text"];
14
+ export declare const PARTS: readonly ["panel", "panel.header", "panel.body", "panel.footer", "hero", "bar-button", "ask-about", "chat", "messages", "message", "message.user", "message.assistant", "message.text", "message.provenance", "message.feedback", "composer", "composer.input", "composer.attach", "composer.mic", "composer.send", "composer.stop", "file-chips", "file-chip", "work", "work.stage", "work.progress", "work.tool", "work.elapsed", "card.approval", "card.approval.step", "card.approval.fact", "card.approval.code", "card.approval.confirm", "card.approval.refuse", "card.undo", "card.ask", "card.choice", "secret-field", "block", "block.text", "block.callout", "block.table", "block.table.card", "block.chart", "block.chart.bar", "block.chart.line", "block.kpi", "block.steps", "block.actions", "block.action", "block.flow", "block.image", "block.open", "block.fallback", "mode-banner", "usage-chip", "thinking-orb", "stages-thinking", "reveal-text", "model-picker"];
15
15
  export type PartName = (typeof PARTS)[number];
16
16
  /** Per-part classes and styles from the host (layer 3). */
17
17
  export interface PartStyles {
package/dist/types.js CHANGED
@@ -18,7 +18,7 @@ export const PARTS = [
18
18
  "card.undo", "card.ask", "card.choice", "secret-field",
19
19
  "block", "block.text", "block.callout", "block.table", "block.table.card", "block.chart", "block.chart.bar", "block.chart.line",
20
20
  "block.kpi", "block.steps", "block.actions", "block.action", "block.flow", "block.image", "block.open", "block.fallback",
21
- "mode-banner", "usage-chip", "thinking-orb", "stages-thinking", "reveal-text",
21
+ "mode-banner", "usage-chip", "thinking-orb", "stages-thinking", "reveal-text", "model-picker",
22
22
  ];
23
23
  /** The class of a part: the library's stable class plus the host's. */
24
24
  export function partClass(part, styles, unstyled = false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Headless client of the G9 AI assistant: API client, run state, transports, block view models, safe text and Persian helpers. No DOM, no framework.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@g9tm/aiassistant-contracts": "1.5.0"
36
+ "@g9tm/aiassistant-contracts": "1.6.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.json",