@infinite-room-labs/claudesync-core 0.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/dist/auth/__tests__/env.test.d.ts +2 -0
- package/dist/auth/__tests__/env.test.d.ts.map +1 -0
- package/dist/auth/__tests__/env.test.js +42 -0
- package/dist/auth/__tests__/env.test.js.map +1 -0
- package/dist/auth/__tests__/firefox.test.d.ts +2 -0
- package/dist/auth/__tests__/firefox.test.d.ts.map +1 -0
- package/dist/auth/__tests__/firefox.test.js +291 -0
- package/dist/auth/__tests__/firefox.test.js.map +1 -0
- package/dist/auth/env.d.ts +10 -0
- package/dist/auth/env.d.ts.map +1 -0
- package/dist/auth/env.js +46 -0
- package/dist/auth/env.js.map +1 -0
- package/dist/auth/errors.d.ts +4 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +7 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/firefox.d.ts +12 -0
- package/dist/auth/firefox.d.ts.map +1 -0
- package/dist/auth/firefox.js +190 -0
- package/dist/auth/firefox.js.map +1 -0
- package/dist/auth/types.d.ts +10 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client/__tests__/client.test.d.ts +2 -0
- package/dist/client/__tests__/client.test.d.ts.map +1 -0
- package/dist/client/__tests__/client.test.js +50 -0
- package/dist/client/__tests__/client.test.js.map +1 -0
- package/dist/client/__tests__/endpoints.test.d.ts +2 -0
- package/dist/client/__tests__/endpoints.test.d.ts.map +1 -0
- package/dist/client/__tests__/endpoints.test.js +26 -0
- package/dist/client/__tests__/endpoints.test.js.map +1 -0
- package/dist/client/client.d.ts +54 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +144 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/endpoints.d.ts +18 -0
- package/dist/client/endpoints.d.ts.map +1 -0
- package/dist/client/endpoints.js +25 -0
- package/dist/client/endpoints.js.map +1 -0
- package/dist/client/errors.d.ts +11 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +22 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/export/__tests__/bundle-builder.test.d.ts +2 -0
- package/dist/export/__tests__/bundle-builder.test.d.ts.map +1 -0
- package/dist/export/__tests__/bundle-builder.test.js +272 -0
- package/dist/export/__tests__/bundle-builder.test.js.map +1 -0
- package/dist/export/__tests__/conversation-formatter.test.d.ts +2 -0
- package/dist/export/__tests__/conversation-formatter.test.d.ts.map +1 -0
- package/dist/export/__tests__/conversation-formatter.test.js +99 -0
- package/dist/export/__tests__/conversation-formatter.test.js.map +1 -0
- package/dist/export/bundle-builder.d.ts +24 -0
- package/dist/export/bundle-builder.d.ts.map +1 -0
- package/dist/export/bundle-builder.js +94 -0
- package/dist/export/bundle-builder.js.map +1 -0
- package/dist/export/conversation-formatter.d.ts +23 -0
- package/dist/export/conversation-formatter.d.ts.map +1 -0
- package/dist/export/conversation-formatter.js +40 -0
- package/dist/export/conversation-formatter.js.map +1 -0
- package/dist/export/git-exporter.d.ts +12 -0
- package/dist/export/git-exporter.d.ts.map +1 -0
- package/dist/export/git-exporter.js +68 -0
- package/dist/export/git-exporter.js.map +1 -0
- package/dist/export/types.d.ts +27 -0
- package/dist/export/types.d.ts.map +1 -0
- package/dist/export/types.js +2 -0
- package/dist/export/types.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/models/__tests__/schemas.test.d.ts +2 -0
- package/dist/models/__tests__/schemas.test.d.ts.map +1 -0
- package/dist/models/__tests__/schemas.test.js +189 -0
- package/dist/models/__tests__/schemas.test.js.map +1 -0
- package/dist/models/schemas.d.ts +805 -0
- package/dist/models/schemas.d.ts.map +1 -0
- package/dist/models/schemas.js +119 -0
- package/dist/models/schemas.js.map +1 -0
- package/dist/models/types.d.ts +15 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +2 -0
- package/dist/models/types.js.map +1 -0
- package/dist/tree/__tests__/message-tree.test.d.ts +2 -0
- package/dist/tree/__tests__/message-tree.test.d.ts.map +1 -0
- package/dist/tree/__tests__/message-tree.test.js +176 -0
- package/dist/tree/__tests__/message-tree.test.js.map +1 -0
- package/dist/tree/message-tree.d.ts +35 -0
- package/dist/tree/message-tree.d.ts.map +1 -0
- package/dist/tree/message-tree.js +70 -0
- package/dist/tree/message-tree.js.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import git from "isomorphic-git";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a real git repository from a GitBundle.
|
|
6
|
+
*
|
|
7
|
+
* Uses a staging approach: writes to `{outputPath}.tmp`, then renames on
|
|
8
|
+
* success. On failure, cleans up the `.tmp` directory.
|
|
9
|
+
*
|
|
10
|
+
* @param bundle - The GitBundle describing commits to create
|
|
11
|
+
* @param outputPath - Absolute path for the output git repository
|
|
12
|
+
*/
|
|
13
|
+
export async function exportToGit(bundle, outputPath) {
|
|
14
|
+
const tmpPath = `${outputPath}.tmp`;
|
|
15
|
+
// Clean up any leftover tmp directory from a previous failed run
|
|
16
|
+
if (fs.existsSync(tmpPath)) {
|
|
17
|
+
fs.rmSync(tmpPath, { recursive: true, force: true });
|
|
18
|
+
}
|
|
19
|
+
// Fail if target already exists
|
|
20
|
+
if (fs.existsSync(outputPath)) {
|
|
21
|
+
throw new Error(`Output path already exists: ${outputPath}`);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
// Initialize git repo
|
|
25
|
+
fs.mkdirSync(tmpPath, { recursive: true });
|
|
26
|
+
await git.init({ fs, dir: tmpPath, defaultBranch: "main" });
|
|
27
|
+
// Replay each commit
|
|
28
|
+
for (const commit of bundle.commits) {
|
|
29
|
+
// Write files
|
|
30
|
+
for (const [filePath, content] of Object.entries(commit.files)) {
|
|
31
|
+
const fullPath = path.join(tmpPath, filePath);
|
|
32
|
+
const dir = path.dirname(fullPath);
|
|
33
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
34
|
+
if (typeof content === "string") {
|
|
35
|
+
fs.writeFileSync(fullPath, content, "utf-8");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
fs.writeFileSync(fullPath, content);
|
|
39
|
+
}
|
|
40
|
+
// Stage the file
|
|
41
|
+
await git.add({ fs, dir: tmpPath, filepath: filePath });
|
|
42
|
+
}
|
|
43
|
+
// Create the commit
|
|
44
|
+
const timestamp = Math.floor(new Date(commit.timestamp).getTime() / 1000);
|
|
45
|
+
await git.commit({
|
|
46
|
+
fs,
|
|
47
|
+
dir: tmpPath,
|
|
48
|
+
message: commit.message,
|
|
49
|
+
author: {
|
|
50
|
+
name: commit.author.name,
|
|
51
|
+
email: commit.author.email,
|
|
52
|
+
timestamp,
|
|
53
|
+
timezoneOffset: 0,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Success: rename .tmp to final path
|
|
58
|
+
fs.renameSync(tmpPath, outputPath);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// Failure: clean up .tmp directory
|
|
62
|
+
if (fs.existsSync(tmpPath)) {
|
|
63
|
+
fs.rmSync(tmpPath, { recursive: true, force: true });
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=git-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-exporter.js","sourceRoot":"","sources":["../../src/export/git-exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,GAAG,MAAM,gBAAgB,CAAC;AAGjC;;;;;;;;GAQG;AACH,MAAM,CAAC,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CAAC;gBAC/C,CAAC;qBAAM,CAAC;oBACN,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBACtC,CAAC;gBAED,iBAAiB;gBACjB,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC1D,CAAC;YAED,oBAAoB;YACpB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAC1B,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAC5C,CAAC;YAEF,MAAM,GAAG,CAAC,MAAM,CAAC;gBACf,EAAE;gBACF,GAAG,EAAE,OAAO;gBACZ,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;oBACxB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;oBAC1B,SAAS;oBACT,cAAc,EAAE,CAAC;iBAClB;aACF,CAAC,CAAC;QACL,CAAC;QAED,qCAAqC;QACrC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mCAAmC;QACnC,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitBundle -- JSON intermediate representation for git export.
|
|
3
|
+
*
|
|
4
|
+
* This format is designed for environments without git (browser extension).
|
|
5
|
+
* It describes what commits should be created so a CLI or Node.js consumer
|
|
6
|
+
* can replay them into an actual git repository via isomorphic-git.
|
|
7
|
+
*/
|
|
8
|
+
export interface GitBundle {
|
|
9
|
+
metadata: {
|
|
10
|
+
conversationId: string;
|
|
11
|
+
conversationName: string;
|
|
12
|
+
model: string | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
exportedAt: string;
|
|
15
|
+
};
|
|
16
|
+
commits: GitBundleCommit[];
|
|
17
|
+
}
|
|
18
|
+
export interface GitBundleCommit {
|
|
19
|
+
message: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
author: {
|
|
22
|
+
name: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
files: Record<string, string | Uint8Array>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/export/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/export/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { AuthProvider } from "./auth/types.js";
|
|
2
|
+
export { EnvAuth } from "./auth/env.js";
|
|
3
|
+
export { FirefoxProfileAuth } from "./auth/firefox.js";
|
|
4
|
+
export { AuthError } from "./auth/errors.js";
|
|
5
|
+
export { ClaudeSyncClient } from "./client/client.js";
|
|
6
|
+
export type { ClientOptions } from "./client/client.js";
|
|
7
|
+
export { ClaudeSyncError, RateLimitError } from "./client/errors.js";
|
|
8
|
+
export { ENDPOINTS, buildUrl } from "./client/endpoints.js";
|
|
9
|
+
export { OrganizationSchema, ConversationSettingsSchema, AttachmentSchema, ChatMessageSchema, ConversationSummarySchema, ConversationSchema, SearchChunkSchema, SearchResponseSchema, ArtifactFileMetadataSchema, ArtifactListResponseSchema, ProjectSchema, ProjectDocSchema, } from "./models/schemas.js";
|
|
10
|
+
export type { Organization, ConversationSettings, Attachment, ChatMessage, ConversationSummary, Conversation, SearchChunk, SearchResponse, ArtifactFileMetadata, ArtifactListResponse, Project, ProjectDoc, } from "./models/types.js";
|
|
11
|
+
export type { MessageTreeNode } from "./tree/message-tree.js";
|
|
12
|
+
export { buildMessageTree, findLeafMessages, getLinearBranch, } from "./tree/message-tree.js";
|
|
13
|
+
export type { GitBundle, GitBundleCommit } from "./export/types.js";
|
|
14
|
+
export type { BuildGitBundleOptions } from "./export/bundle-builder.js";
|
|
15
|
+
export { buildGitBundle } from "./export/bundle-builder.js";
|
|
16
|
+
export { exportToGit } from "./export/git-exporter.js";
|
|
17
|
+
export { formatConversation } from "./export/conversation-formatter.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kB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firefox.js";
|
|
3
|
+
export { AuthError } from "./auth/errors.js";
|
|
4
|
+
// Client
|
|
5
|
+
export { ClaudeSyncClient } from "./client/client.js";
|
|
6
|
+
export { ClaudeSyncError, RateLimitError } from "./client/errors.js";
|
|
7
|
+
export { ENDPOINTS, buildUrl } from "./client/endpoints.js";
|
|
8
|
+
// Models -- Schemas
|
|
9
|
+
export { OrganizationSchema, ConversationSettingsSchema, AttachmentSchema, ChatMessageSchema, ConversationSummarySchema, ConversationSchema, SearchChunkSchema, SearchResponseSchema, ArtifactFileMetadataSchema, ArtifactListResponseSchema, ProjectSchema, ProjectDocSchema, } from "./models/schemas.js";
|
|
10
|
+
export { buildMessageTree, findLeafMessages, getLinearBranch, } from "./tree/message-tree.js";
|
|
11
|
+
export { buildGitBundle } from "./export/bundle-builder.js";
|
|
12
|
+
export { exportToGit } from "./export/git-exporter.js";
|
|
13
|
+
export { formatConversation } from "./export/conversation-formatter.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,SAAS;AACT,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,oBAAoB;AACpB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAoB7B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.test.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/schemas.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { OrganizationSchema, ConversationSummarySchema, ConversationSettingsSchema, ChatMessageSchema, ConversationSchema, SearchResponseSchema, ArtifactFileMetadataSchema, ArtifactListResponseSchema, } from "../schemas.js";
|
|
3
|
+
describe("OrganizationSchema", () => {
|
|
4
|
+
it("parses a valid organization", () => {
|
|
5
|
+
const data = {
|
|
6
|
+
uuid: "abc-123",
|
|
7
|
+
name: "My Org",
|
|
8
|
+
capabilities: ["chat"],
|
|
9
|
+
active_flags: [],
|
|
10
|
+
created_at: "2026-01-01T00:00:00Z",
|
|
11
|
+
updated_at: "2026-01-01T00:00:00Z",
|
|
12
|
+
};
|
|
13
|
+
const result = OrganizationSchema.parse(data);
|
|
14
|
+
expect(result.uuid).toBe("abc-123");
|
|
15
|
+
expect(result.name).toBe("My Org");
|
|
16
|
+
});
|
|
17
|
+
it("preserves unknown fields via passthrough", () => {
|
|
18
|
+
const data = {
|
|
19
|
+
uuid: "abc-123",
|
|
20
|
+
name: "My Org",
|
|
21
|
+
capabilities: ["chat"],
|
|
22
|
+
active_flags: [],
|
|
23
|
+
created_at: "2026-01-01T00:00:00Z",
|
|
24
|
+
updated_at: "2026-01-01T00:00:00Z",
|
|
25
|
+
rate_limit_tier: "default_claude_max_20x",
|
|
26
|
+
billing_type: "stripe_subscription",
|
|
27
|
+
};
|
|
28
|
+
const result = OrganizationSchema.parse(data);
|
|
29
|
+
expect(result.rate_limit_tier).toBe("default_claude_max_20x");
|
|
30
|
+
});
|
|
31
|
+
it("rejects missing uuid", () => {
|
|
32
|
+
expect(() => OrganizationSchema.parse({ name: "My Org" })).toThrow();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("ConversationSettingsSchema", () => {
|
|
36
|
+
it("preserves unknown codename fields via passthrough", () => {
|
|
37
|
+
const data = {
|
|
38
|
+
enabled_web_search: true,
|
|
39
|
+
enabled_bananagrams: true,
|
|
40
|
+
enabled_sourdough: false,
|
|
41
|
+
enabled_foccacia: true,
|
|
42
|
+
enabled_compass: null,
|
|
43
|
+
some_future_codename: "unknown_value",
|
|
44
|
+
};
|
|
45
|
+
const result = ConversationSettingsSchema.parse(data);
|
|
46
|
+
expect(result.enabled_web_search).toBe(true);
|
|
47
|
+
expect(result.some_future_codename).toBe("unknown_value");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("ChatMessageSchema", () => {
|
|
51
|
+
it("parses a valid message with parent_message_uuid", () => {
|
|
52
|
+
const data = {
|
|
53
|
+
uuid: "msg-1",
|
|
54
|
+
text: "Hello",
|
|
55
|
+
sender: "human",
|
|
56
|
+
index: 0,
|
|
57
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
58
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
59
|
+
parent_message_uuid: "root",
|
|
60
|
+
attachments: [],
|
|
61
|
+
files_v2: [],
|
|
62
|
+
sync_sources: [],
|
|
63
|
+
};
|
|
64
|
+
const result = ChatMessageSchema.parse(data);
|
|
65
|
+
expect(result.sender).toBe("human");
|
|
66
|
+
expect(result.parent_message_uuid).toBe("root");
|
|
67
|
+
});
|
|
68
|
+
it("accepts assistant sender with stop_reason", () => {
|
|
69
|
+
const data = {
|
|
70
|
+
uuid: "msg-2",
|
|
71
|
+
text: "Hi there",
|
|
72
|
+
sender: "assistant",
|
|
73
|
+
index: 1,
|
|
74
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
75
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
76
|
+
parent_message_uuid: "msg-1",
|
|
77
|
+
stop_reason: "end_turn",
|
|
78
|
+
attachments: [],
|
|
79
|
+
files_v2: [],
|
|
80
|
+
sync_sources: [],
|
|
81
|
+
};
|
|
82
|
+
const result = ChatMessageSchema.parse(data);
|
|
83
|
+
expect(result.sender).toBe("assistant");
|
|
84
|
+
expect(result.stop_reason).toBe("end_turn");
|
|
85
|
+
});
|
|
86
|
+
it("rejects invalid sender", () => {
|
|
87
|
+
const data = {
|
|
88
|
+
uuid: "msg-3",
|
|
89
|
+
text: "Bad",
|
|
90
|
+
sender: "system",
|
|
91
|
+
index: 0,
|
|
92
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
93
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
94
|
+
parent_message_uuid: "root",
|
|
95
|
+
attachments: [],
|
|
96
|
+
files_v2: [],
|
|
97
|
+
sync_sources: [],
|
|
98
|
+
};
|
|
99
|
+
expect(() => ChatMessageSchema.parse(data)).toThrow();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe("ConversationSummarySchema", () => {
|
|
103
|
+
it("parses with null model and current_leaf_message_uuid", () => {
|
|
104
|
+
const data = {
|
|
105
|
+
uuid: "conv-1",
|
|
106
|
+
name: "Test Chat",
|
|
107
|
+
model: null,
|
|
108
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
109
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
110
|
+
current_leaf_message_uuid: "leaf-1",
|
|
111
|
+
};
|
|
112
|
+
const result = ConversationSummarySchema.parse(data);
|
|
113
|
+
expect(result.model).toBeNull();
|
|
114
|
+
expect(result.current_leaf_message_uuid).toBe("leaf-1");
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe("ConversationSchema", () => {
|
|
118
|
+
it("parses a full conversation with messages", () => {
|
|
119
|
+
const data = {
|
|
120
|
+
uuid: "conv-1",
|
|
121
|
+
name: "Test Chat",
|
|
122
|
+
model: "claude-opus-4-6",
|
|
123
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
124
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
125
|
+
current_leaf_message_uuid: "msg-1",
|
|
126
|
+
chat_messages: [
|
|
127
|
+
{
|
|
128
|
+
uuid: "msg-1",
|
|
129
|
+
text: "Hello",
|
|
130
|
+
sender: "human",
|
|
131
|
+
index: 0,
|
|
132
|
+
created_at: "2026-03-10T00:00:00Z",
|
|
133
|
+
updated_at: "2026-03-10T00:00:00Z",
|
|
134
|
+
parent_message_uuid: "root",
|
|
135
|
+
attachments: [],
|
|
136
|
+
files_v2: [],
|
|
137
|
+
sync_sources: [],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
const result = ConversationSchema.parse(data);
|
|
142
|
+
expect(result.chat_messages).toHaveLength(1);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe("SearchResponseSchema", () => {
|
|
146
|
+
it("parses search results with extras", () => {
|
|
147
|
+
const data = {
|
|
148
|
+
chunks: [
|
|
149
|
+
{
|
|
150
|
+
doc_uuid: "doc-1",
|
|
151
|
+
start: 0,
|
|
152
|
+
end: 50,
|
|
153
|
+
name: "Test Conv",
|
|
154
|
+
text: "matching text",
|
|
155
|
+
extras: {
|
|
156
|
+
conversation_uuid: "conv-1",
|
|
157
|
+
conversation_title: "Test Conv",
|
|
158
|
+
doc_type: "conversation",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
const result = SearchResponseSchema.parse(data);
|
|
164
|
+
expect(result.chunks).toHaveLength(1);
|
|
165
|
+
expect(result.chunks[0].extras.conversation_uuid).toBe("conv-1");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe("ArtifactListResponseSchema", () => {
|
|
169
|
+
it("parses wiggle list-files response", () => {
|
|
170
|
+
const data = {
|
|
171
|
+
success: true,
|
|
172
|
+
files: ["/mnt/user-data/outputs/architecture.md"],
|
|
173
|
+
files_metadata: [
|
|
174
|
+
{
|
|
175
|
+
path: "/mnt/user-data/outputs/architecture.md",
|
|
176
|
+
size: 29446,
|
|
177
|
+
content_type: "text/plain",
|
|
178
|
+
created_at: "2026-03-12T23:08:39.328229Z",
|
|
179
|
+
custom_metadata: { filename: "architecture.md" },
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
const result = ArtifactListResponseSchema.parse(data);
|
|
184
|
+
expect(result.success).toBe(true);
|
|
185
|
+
expect(result.files_metadata).toHaveLength(1);
|
|
186
|
+
expect(result.files_metadata[0].custom_metadata.filename).toBe("architecture.md");
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
//# sourceMappingURL=schemas.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.test.js","sourceRoot":"","sources":["../../../src/models/__tests__/schemas.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,CAAC,MAAM,CAAC;YACtB,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;SACnC,CAAC;QACF,MAAM,MA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