@lota-sdk/core 0.4.2 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lota-sdk/core",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -32,7 +32,7 @@
32
32
  "@chat-adapter/slack": "^4.23.0",
33
33
  "@chat-adapter/state-ioredis": "^4.23.0",
34
34
  "@logtape/logtape": "^2.0.5",
35
- "@lota-sdk/shared": "0.4.2",
35
+ "@lota-sdk/shared": "0.4.3",
36
36
  "@mendable/firecrawl-js": "^4.18.1",
37
37
  "@surrealdb/node": "^3.0.3",
38
38
  "ai": "^6.0.145",
@@ -360,11 +360,17 @@ class ArtifactService {
360
360
 
361
361
  async listBacklinks(artifact: Pick<ArtifactRecord, 'id' | 'organizationId'>): Promise<ArtifactRecord[]> {
362
362
  const artifactId = recordIdToString(artifact.id, TABLES.ARTIFACT)
363
- const records = await this.listArtifacts({ organizationId: artifact.organizationId, includeNonActive: true })
364
-
365
- return records.filter((record) =>
366
- record.references.some((reference) => reference.targetType === 'artifact' && reference.targetId === artifactId),
363
+ const records = await databaseService.queryMany(
364
+ {
365
+ query: `SELECT * FROM ${TABLES.ARTIFACT} WHERE organizationId = $organizationId AND references[*].targetId CONTAINS $targetId`,
366
+ bindings: {
367
+ organizationId: ensureRecordId(artifact.organizationId, TABLES.ORGANIZATION),
368
+ targetId: artifactId,
369
+ },
370
+ },
371
+ ArtifactRecordSchema,
367
372
  )
373
+ return records
368
374
  }
369
375
  }
370
376
 
@@ -713,6 +713,8 @@ class ThreadService extends BaseService<typeof ThreadSchema> {
713
713
  }
714
714
 
715
715
  async clearThread(threadId: RecordIdRef): Promise<void> {
716
+ const existing = await this.getById(threadId)
717
+ assertMutableThread(existing)
716
718
  const threadRef = ensureRecordId(threadId, TABLES.THREAD)
717
719
  await databaseService.deleteWhere(TABLES.THREAD_MESSAGE, { threadId: threadRef })
718
720
  await databaseService.query<unknown>(surql`
@@ -721,7 +723,8 @@ class ThreadService extends BaseService<typeof ThreadSchema> {
721
723
  compactionSummary = NONE,
722
724
  lastCompactedMessageId = NONE,
723
725
  activeRunId = NONE,
724
- activeStreamId = NONE
726
+ activeStreamId = NONE,
727
+ isCompacting = false
725
728
  `)
726
729
  }
727
730