@artinet/sdk 0.6.8 → 0.6.10

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.
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { A2A } from "../types/index.js";
6
6
  import { Tasks } from "../services/a2a/managers.js";
7
- import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
7
+ import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
8
8
  export declare const TABLE_NAME = "artinet_tasks";
9
9
  export declare const createTaskTable: (db: BaseSQLiteDatabase<`sync` | `async`, any, TaskTable>) => Promise<void>;
10
10
  export declare const TaskTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
@@ -346,6 +346,8 @@ export type TaskTable = typeof TaskTable.$inferSelect;
346
346
  export declare class SQLiteStore extends Tasks {
347
347
  private db;
348
348
  constructor(db: BaseSQLiteDatabase<`sync` | `async`, any, TaskTable>, tasks?: Map<string, A2A.Task>);
349
+ has(id: string): Promise<boolean>;
350
+ list(): Promise<A2A.Task[]>;
349
351
  get(id: string): Promise<A2A.Task | undefined>;
350
352
  set(id: string, data?: A2A.Task): Promise<void>;
351
353
  delete(id: string): Promise<void>;
@@ -3,10 +3,10 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { Tasks } from "../services/a2a/managers.js";
6
- import { eq, like, or, /*Table, TableConfig*/ } from "drizzle-orm";
7
- import { sqliteTable, text } from "drizzle-orm/sqlite-core";
6
+ import { eq, like, or /*Table, TableConfig*/ } from 'drizzle-orm';
7
+ import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
8
8
  import { logger } from "../config/index.js";
9
- export const TABLE_NAME = "artinet_tasks";
9
+ export const TABLE_NAME = 'artinet_tasks';
10
10
  const CREATE_TASKS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME}\
11
11
  (id TEXT PRIMARY KEY, contextId TEXT NOT NULL,\
12
12
  kind TEXT NOT NULL, status TEXT NOT NULL,\
@@ -20,20 +20,11 @@ export const createTaskTable = async (db) => {
20
20
  export const TaskTable = sqliteTable(TABLE_NAME, {
21
21
  id: text().primaryKey(),
22
22
  contextId: text().notNull(),
23
- kind: text("kind").$type().notNull(),
24
- status: text("status", { mode: "json" }).$type().notNull(),
25
- history: text("history", { mode: "json" })
26
- .$type()
27
- .notNull()
28
- .default([]),
29
- artifacts: text("artifacts", { mode: "json" })
30
- .$type()
31
- .notNull()
32
- .default([]),
33
- metadata: text("metadata", { mode: "json" })
34
- .$type()
35
- .notNull()
36
- .default({}),
23
+ kind: text('kind').$type().notNull(),
24
+ status: text('status', { mode: 'json' }).$type().notNull(),
25
+ history: text('history', { mode: 'json' }).$type().notNull().default([]),
26
+ artifacts: text('artifacts', { mode: 'json' }).$type().notNull().default([]),
27
+ metadata: text('metadata', { mode: 'json' }).$type().notNull().default({}),
37
28
  });
38
29
  export class SQLiteStore extends Tasks {
39
30
  db;
@@ -42,16 +33,19 @@ export class SQLiteStore extends Tasks {
42
33
  this.db = db;
43
34
  createTaskTable(db);
44
35
  }
36
+ async has(id) {
37
+ return ((await super.has(id)) ||
38
+ (await this.db.select().from(TaskTable).where(eq(TaskTable.id, id)).get()) !== undefined);
39
+ }
40
+ async list() {
41
+ return await this.db.select().from(TaskTable).execute();
42
+ }
45
43
  async get(id) {
46
44
  let task = await super.get(id);
47
45
  if (task) {
48
46
  return task;
49
47
  }
50
- task = await this.db
51
- .select()
52
- .from(TaskTable)
53
- .where(eq(TaskTable.id, id))
54
- .get();
48
+ task = await this.db.select().from(TaskTable).where(eq(TaskTable.id, id)).get();
55
49
  if (task) {
56
50
  await super.set(id, task);
57
51
  }
@@ -62,12 +56,16 @@ export class SQLiteStore extends Tasks {
62
56
  return;
63
57
  }
64
58
  if (id !== data.id) {
65
- logger.warn("SQLiteStore", `Task ID mismatch: ${id} !== ${data.id}`);
66
- throw new Error("Task ID mismatch");
59
+ logger.warn('SQLiteStore', `Task ID mismatch: ${id} !== ${data.id}`);
60
+ throw new Error('Task ID mismatch');
67
61
  }
68
62
  await this.db
69
63
  .insert(TaskTable)
70
64
  .values({ ...data, id })
65
+ .onConflictDoUpdate({
66
+ target: [TaskTable.id],
67
+ set: { ...data },
68
+ })
71
69
  .execute();
72
70
  await super.set(id, data);
73
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artinet/sdk",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "A TypeScript SDK for building collaborative AI agents.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",