@rynx-ai/daemon 0.1.11-beta.24 → 0.1.11-beta.26

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.
@@ -38,9 +38,18 @@ export class SqliteSessionLogStore {
38
38
  created_by: stored.createdBy ?? null,
39
39
  created_at: stored.createdAt,
40
40
  });
41
- if (stored.type === "message" && stored.data.role === "user") {
42
- const resourceIds = stored.data.content.flatMap((part) => part.type === "input_image" ? [part.resourceId] : []);
43
- const operationIds = new Set();
41
+ const resourceIds = stored.type === "message" && stored.data.role === "user"
42
+ ? stored.data.content.flatMap((part) => (part.type === "input_image" || part.type === "input_file") &&
43
+ "resourceId" in part && part.resourceId
44
+ ? [part.resourceId]
45
+ : [])
46
+ : stored.type === "function_call_output" &&
47
+ stored.data.generatedImage &&
48
+ "resourceId" in stored.data.generatedImage &&
49
+ stored.data.generatedImage.resourceId
50
+ ? [stored.data.generatedImage.resourceId]
51
+ : [];
52
+ if (resourceIds.length > 0) {
44
53
  for (const resourceId of resourceIds) {
45
54
  const resource = conn.prepare(`SELECT state, message_item_id
46
55
  FROM session_resources
@@ -48,23 +57,12 @@ export class SqliteSessionLogStore {
48
57
  if (!resource ||
49
58
  resource.state === "uploading" ||
50
59
  (resource.message_item_id && resource.message_item_id !== stored.id)) {
51
- throw new Error(`Session image resource ${resourceId} is not committable`);
60
+ throw new Error(`Session resource ${resourceId} is not committable`);
52
61
  }
53
62
  conn.prepare(`UPDATE session_resources
54
63
  SET state = 'committed', message_item_id = ?,
55
64
  committed_at = COALESCE(committed_at, ?)
56
65
  WHERE id = ? AND session_id = ?`).run(stored.id, stored.createdAt, resourceId, sessionId);
57
- const operation = conn.prepare(`SELECT client_message_id
58
- FROM session_message_operation_resources
59
- WHERE session_id = ? AND resource_id = ?`).get(sessionId, resourceId);
60
- if (operation)
61
- operationIds.add(operation.client_message_id);
62
- }
63
- for (const clientMessageId of operationIds) {
64
- conn.prepare(`UPDATE session_message_operations
65
- SET state = 'mirrored', error = NULL, updated_at = ?
66
- WHERE session_id = ? AND client_message_id = ?
67
- AND state IN ('injecting', 'injected', 'outcome_unknown')`).run(stored.createdAt, sessionId, clientMessageId);
68
66
  }
69
67
  }
70
68
  return stored;
@@ -93,6 +91,10 @@ export class SqliteSessionLogStore {
93
91
  .all(sessionId, afterPosition, limit);
94
92
  return rows.map(toItem);
95
93
  }
94
+ async get(sessionId, itemId) {
95
+ const row = db().prepare("SELECT * FROM session_items WHERE session_id = ? AND id = ?").get(sessionId, itemId);
96
+ return row ? toItem(row) : undefined;
97
+ }
96
98
  async snapshot(sessionId) {
97
99
  const rows = db()
98
100
  .prepare("SELECT * FROM session_items WHERE session_id = ? ORDER BY position ASC")
@@ -1,6 +1,6 @@
1
- import { type UserContentPart } from "@rynx-ai/core";
1
+ import { type SessionImageFileReference, type UserContentPart } from "@rynx-ai/core";
2
2
  import { type RemoteRuntimeSessionResourceDeleteParams, type RemoteRuntimeSessionResourceDeleteResult, type RemoteRuntimeSessionResourceGetParams, type RemoteRuntimeSessionResourceGetResult, type RemoteRuntimeSessionResourcePolicyResult, type RemoteRuntimeSessionResourceReadParams, type RemoteRuntimeSessionResourceReadResult, type RemoteRuntimeSessionResourceUploadBeginParams, type RemoteRuntimeSessionResourceUploadBeginResult, type RemoteRuntimeSessionResourceUploadChunkParams, type RemoteRuntimeSessionResourceUploadChunkResult, type RemoteRuntimeSessionResourceUploadCommitParams, type RemoteRuntimeSessionResourceUploadCommitResult } from "@rynx-ai/protocol/remote-runtime-rpc";
3
- import { type MachineSessionPreparedInput, type MachineSessionResourcePort } from "@rynx-ai/server";
3
+ import { type MachineSessionPreparedInput, type MachineSessionResourcePort, type MachineSessionRunExecutionSelection, type MachineSessionRunExecutionSnapshot } from "@rynx-ai/server";
4
4
  export declare class SqliteSessionResourceStore implements MachineSessionResourcePort {
5
5
  private readonly root;
6
6
  constructor(root?: string);
@@ -9,18 +9,32 @@ export declare class SqliteSessionResourceStore implements MachineSessionResourc
9
9
  writeUploadChunk(input: RemoteRuntimeSessionResourceUploadChunkParams): Promise<RemoteRuntimeSessionResourceUploadChunkResult>;
10
10
  commitUpload(input: RemoteRuntimeSessionResourceUploadCommitParams): Promise<RemoteRuntimeSessionResourceUploadCommitResult>;
11
11
  getResource(input: RemoteRuntimeSessionResourceGetParams): Promise<RemoteRuntimeSessionResourceGetResult>;
12
+ resolveCommittedLocalPath(sessionId: string, resourceId: string): string;
12
13
  readResource(input: RemoteRuntimeSessionResourceReadParams): Promise<RemoteRuntimeSessionResourceReadResult>;
13
14
  deleteResource(input: RemoteRuntimeSessionResourceDeleteParams): Promise<RemoteRuntimeSessionResourceDeleteResult>;
14
- prepareInput(sessionId: string, content: UserContentPart[], clientMessageId?: string): Promise<MachineSessionPreparedInput>;
15
- markMessageInjecting(sessionId: string, clientMessageId: string): void;
16
- markMessageInjected(sessionId: string, clientMessageId: string): void;
15
+ materializeGeneratedImage(input: {
16
+ sessionId: string;
17
+ sourceId: string;
18
+ result: string;
19
+ }): Promise<SessionImageFileReference>;
20
+ prepareInput(sessionId: string, content: UserContentPart[], clientMessageId?: string, operationExecution?: {
21
+ selection: MachineSessionRunExecutionSelection;
22
+ snapshot: MachineSessionRunExecutionSnapshot;
23
+ }): Promise<MachineSessionPreparedInput>;
24
+ markMessageInjecting(sessionId: string, clientMessageId: string, identity?: {
25
+ responseId: string;
26
+ messageItemId: string;
27
+ }): void;
28
+ markMessageInjected(sessionId: string, clientMessageId: string, identity?: {
29
+ responseId: string;
30
+ }): void;
17
31
  markMessageOutcomeUnknown(sessionId: string, clientMessageId: string, reason: string): void;
18
32
  markMessageFailedNotStarted(sessionId: string, clientMessageId: string, reason: string): void;
19
33
  deleteSession(sessionId: string): void;
20
34
  private prepareMessageOperation;
21
35
  private bindOperationResources;
22
36
  private transitionOperation;
23
- private finalizeUpload;
37
+ private finalizeStoredFile;
24
38
  private reconcileUploadOffset;
25
39
  private rowByUpload;
26
40
  private requireUpload;