@nightowlsdev/core 0.3.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.
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/test-utils.ts
21
+ var test_utils_exports = {};
22
+ __export(test_utils_exports, {
23
+ USAGE: () => USAGE,
24
+ partsStream: () => partsStream,
25
+ scriptedModel: () => scriptedModel,
26
+ textScript: () => textScript,
27
+ toolCallScript: () => toolCallScript
28
+ });
29
+ module.exports = __toCommonJS(test_utils_exports);
30
+
31
+ // src/internal/mock-model.ts
32
+ var import_test = require("ai/test");
33
+ var USAGE = {
34
+ inputTokens: { total: 5 },
35
+ outputTokens: { total: 7 },
36
+ totalTokens: { total: 12 }
37
+ };
38
+ function partsStream(parts) {
39
+ return new ReadableStream({
40
+ start(controller) {
41
+ for (const p of parts) controller.enqueue(p);
42
+ controller.close();
43
+ }
44
+ });
45
+ }
46
+ function scriptedModel(scripts) {
47
+ let call = 0;
48
+ return new import_test.MockLanguageModelV3({
49
+ doStream: async () => {
50
+ const parts = scripts[Math.min(call, scripts.length - 1)] ?? [];
51
+ call += 1;
52
+ return { stream: partsStream(parts) };
53
+ }
54
+ });
55
+ }
56
+ var textScript = (chunks) => [
57
+ { type: "stream-start", warnings: [] },
58
+ { type: "text-start", id: "t" },
59
+ ...chunks.map((delta) => ({ type: "text-delta", id: "t", delta })),
60
+ { type: "text-end", id: "t" },
61
+ { type: "finish", finishReason: "stop", usage: USAGE }
62
+ ];
63
+ var toolCallScript = (toolName, toolCallId, input) => [
64
+ { type: "stream-start", warnings: [] },
65
+ { type: "tool-call", toolCallId, toolName, input: JSON.stringify(input) },
66
+ { type: "finish", finishReason: "tool-calls", usage: USAGE }
67
+ ];
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ USAGE,
71
+ partsStream,
72
+ scriptedModel,
73
+ textScript,
74
+ toolCallScript
75
+ });
@@ -0,0 +1,87 @@
1
+ import { MockLanguageModelV3 } from 'ai/test';
2
+
3
+ declare const USAGE: {
4
+ readonly inputTokens: {
5
+ readonly total: 5;
6
+ };
7
+ readonly outputTokens: {
8
+ readonly total: 7;
9
+ };
10
+ readonly totalTokens: {
11
+ readonly total: 12;
12
+ };
13
+ };
14
+ /** Wrap an array of LanguageModelV3 stream parts in a ReadableStream. */
15
+ declare function partsStream(parts: unknown[]): ReadableStream<never>;
16
+ /** A mock whose Nth doStream call returns the Nth scripted part list. */
17
+ declare function scriptedModel(scripts: unknown[][]): MockLanguageModelV3;
18
+ declare const textScript: (chunks: string[]) => ({
19
+ type: string;
20
+ id: string;
21
+ delta: string;
22
+ } | {
23
+ type: string;
24
+ warnings: never[];
25
+ id?: undefined;
26
+ finishReason?: undefined;
27
+ usage?: undefined;
28
+ } | {
29
+ type: string;
30
+ id: string;
31
+ warnings?: undefined;
32
+ finishReason?: undefined;
33
+ usage?: undefined;
34
+ } | {
35
+ type: string;
36
+ finishReason: string;
37
+ usage: {
38
+ readonly inputTokens: {
39
+ readonly total: 5;
40
+ };
41
+ readonly outputTokens: {
42
+ readonly total: 7;
43
+ };
44
+ readonly totalTokens: {
45
+ readonly total: 12;
46
+ };
47
+ };
48
+ warnings?: undefined;
49
+ id?: undefined;
50
+ })[];
51
+ declare const toolCallScript: (toolName: string, toolCallId: string, input: unknown) => ({
52
+ type: string;
53
+ warnings: never[];
54
+ toolCallId?: undefined;
55
+ toolName?: undefined;
56
+ input?: undefined;
57
+ finishReason?: undefined;
58
+ usage?: undefined;
59
+ } | {
60
+ type: string;
61
+ toolCallId: string;
62
+ toolName: string;
63
+ input: string;
64
+ warnings?: undefined;
65
+ finishReason?: undefined;
66
+ usage?: undefined;
67
+ } | {
68
+ type: string;
69
+ finishReason: string;
70
+ usage: {
71
+ readonly inputTokens: {
72
+ readonly total: 5;
73
+ };
74
+ readonly outputTokens: {
75
+ readonly total: 7;
76
+ };
77
+ readonly totalTokens: {
78
+ readonly total: 12;
79
+ };
80
+ };
81
+ warnings?: undefined;
82
+ toolCallId?: undefined;
83
+ toolName?: undefined;
84
+ input?: undefined;
85
+ })[];
86
+
87
+ export { USAGE, partsStream, scriptedModel, textScript, toolCallScript };
@@ -0,0 +1,87 @@
1
+ import { MockLanguageModelV3 } from 'ai/test';
2
+
3
+ declare const USAGE: {
4
+ readonly inputTokens: {
5
+ readonly total: 5;
6
+ };
7
+ readonly outputTokens: {
8
+ readonly total: 7;
9
+ };
10
+ readonly totalTokens: {
11
+ readonly total: 12;
12
+ };
13
+ };
14
+ /** Wrap an array of LanguageModelV3 stream parts in a ReadableStream. */
15
+ declare function partsStream(parts: unknown[]): ReadableStream<never>;
16
+ /** A mock whose Nth doStream call returns the Nth scripted part list. */
17
+ declare function scriptedModel(scripts: unknown[][]): MockLanguageModelV3;
18
+ declare const textScript: (chunks: string[]) => ({
19
+ type: string;
20
+ id: string;
21
+ delta: string;
22
+ } | {
23
+ type: string;
24
+ warnings: never[];
25
+ id?: undefined;
26
+ finishReason?: undefined;
27
+ usage?: undefined;
28
+ } | {
29
+ type: string;
30
+ id: string;
31
+ warnings?: undefined;
32
+ finishReason?: undefined;
33
+ usage?: undefined;
34
+ } | {
35
+ type: string;
36
+ finishReason: string;
37
+ usage: {
38
+ readonly inputTokens: {
39
+ readonly total: 5;
40
+ };
41
+ readonly outputTokens: {
42
+ readonly total: 7;
43
+ };
44
+ readonly totalTokens: {
45
+ readonly total: 12;
46
+ };
47
+ };
48
+ warnings?: undefined;
49
+ id?: undefined;
50
+ })[];
51
+ declare const toolCallScript: (toolName: string, toolCallId: string, input: unknown) => ({
52
+ type: string;
53
+ warnings: never[];
54
+ toolCallId?: undefined;
55
+ toolName?: undefined;
56
+ input?: undefined;
57
+ finishReason?: undefined;
58
+ usage?: undefined;
59
+ } | {
60
+ type: string;
61
+ toolCallId: string;
62
+ toolName: string;
63
+ input: string;
64
+ warnings?: undefined;
65
+ finishReason?: undefined;
66
+ usage?: undefined;
67
+ } | {
68
+ type: string;
69
+ finishReason: string;
70
+ usage: {
71
+ readonly inputTokens: {
72
+ readonly total: 5;
73
+ };
74
+ readonly outputTokens: {
75
+ readonly total: 7;
76
+ };
77
+ readonly totalTokens: {
78
+ readonly total: 12;
79
+ };
80
+ };
81
+ warnings?: undefined;
82
+ toolCallId?: undefined;
83
+ toolName?: undefined;
84
+ input?: undefined;
85
+ })[];
86
+
87
+ export { USAGE, partsStream, scriptedModel, textScript, toolCallScript };
@@ -0,0 +1,44 @@
1
+ // src/internal/mock-model.ts
2
+ import { MockLanguageModelV3 } from "ai/test";
3
+ var USAGE = {
4
+ inputTokens: { total: 5 },
5
+ outputTokens: { total: 7 },
6
+ totalTokens: { total: 12 }
7
+ };
8
+ function partsStream(parts) {
9
+ return new ReadableStream({
10
+ start(controller) {
11
+ for (const p of parts) controller.enqueue(p);
12
+ controller.close();
13
+ }
14
+ });
15
+ }
16
+ function scriptedModel(scripts) {
17
+ let call = 0;
18
+ return new MockLanguageModelV3({
19
+ doStream: async () => {
20
+ const parts = scripts[Math.min(call, scripts.length - 1)] ?? [];
21
+ call += 1;
22
+ return { stream: partsStream(parts) };
23
+ }
24
+ });
25
+ }
26
+ var textScript = (chunks) => [
27
+ { type: "stream-start", warnings: [] },
28
+ { type: "text-start", id: "t" },
29
+ ...chunks.map((delta) => ({ type: "text-delta", id: "t", delta })),
30
+ { type: "text-end", id: "t" },
31
+ { type: "finish", finishReason: "stop", usage: USAGE }
32
+ ];
33
+ var toolCallScript = (toolName, toolCallId, input) => [
34
+ { type: "stream-start", warnings: [] },
35
+ { type: "tool-call", toolCallId, toolName, input: JSON.stringify(input) },
36
+ { type: "finish", finishReason: "tool-calls", usage: USAGE }
37
+ ];
38
+ export {
39
+ USAGE,
40
+ partsStream,
41
+ scriptedModel,
42
+ textScript,
43
+ toolCallScript
44
+ };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nightowlsdev/core",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/cueplusplus/corale.git",
12
+ "directory": "packages/core"
13
+ },
14
+ "homepage": "https://github.com/cueplusplus/corale#readme",
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./test-utils": {
23
+ "types": "./dist/test-utils.d.ts",
24
+ "import": "./dist/test-utils.js",
25
+ "require": "./dist/test-utils.cjs"
26
+ }
27
+ },
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "@mastra/core": "^1.38.0",
36
+ "@mastra/memory": "^1.20.2",
37
+ "zod": "^4.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "ai": "^6.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@mastra/libsql": "1.12.0",
44
+ "@types/node": "^24.12.4",
45
+ "ai": "^6.0.0",
46
+ "tsup": "8.5.1",
47
+ "typescript": "6.0.3",
48
+ "vitest": "^3.2.0",
49
+ "@nightowlsdev/eslint-config": "0.0.0",
50
+ "@nightowlsdev/tsconfig": "0.0.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "typecheck": "tsc --noEmit",
55
+ "test": "vitest run",
56
+ "lint": "eslint src"
57
+ }
58
+ }