@agent-native/creative-context 0.8.29 → 0.8.30-nightly-20261003164120
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/client/useCreativeContextLab.d.ts +1 -0
- package/dist/client/useCreativeContextLab.d.ts.map +1 -1
- package/dist/server/labs.d.ts.map +1 -1
- package/dist/server/labs.js +2 -3
- package/dist/server/labs.js.map +1 -1
- package/package.json +5 -5
- package/src/server/labs.spec.ts +33 -20
- package/src/server/labs.ts +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreativeContextLab.d.ts","sourceRoot":"","sources":["../../src/client/useCreativeContextLab.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B
|
|
1
|
+
{"version":3,"file":"useCreativeContextLab.d.ts","sourceRoot":"","sources":["../../src/client/useCreativeContextLab.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B;;;;;;;;;EAEzC;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labs.d.ts","sourceRoot":"","sources":["../../src/server/labs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,SAAmC,GACxC,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"labs.d.ts","sourceRoot":"","sources":["../../src/server/labs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,SAAmC,GACxC,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,+BAA+B,CACnD,SAAS,qBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAYf;AAuBD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAS7B"}
|
package/dist/server/labs.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { fail } from "@agent-native/core/action";
|
|
2
|
-
import {
|
|
2
|
+
import { getUserLabEnabled } from "@agent-native/core/labs/server";
|
|
3
3
|
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
4
4
|
import { CREATIVE_CONTEXT_LIBRARY_LAB } from "../labs.js";
|
|
5
5
|
import { getCreativeContext } from "./context.js";
|
|
6
6
|
export async function isCreativeContextLabAvailable(userEmail, labKey = CREATIVE_CONTEXT_LIBRARY_LAB.key) {
|
|
7
7
|
if (!userEmail)
|
|
8
8
|
return false;
|
|
9
|
-
|
|
10
|
-
return labs[labKey] === true;
|
|
9
|
+
return getUserLabEnabled(userEmail, labKey);
|
|
11
10
|
}
|
|
12
11
|
export async function assertCreativeContextLabEnabled(userEmail = getRequestUserEmail()) {
|
|
13
12
|
if (!(await isCreativeContextLabAvailable(userEmail, getCreativeContext().labKey))) {
|
package/dist/server/labs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labs.js","sourceRoot":"","sources":["../../src/server/labs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"labs.js","sourceRoot":"","sources":["../../src/server/labs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,E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AAK,uBAAuB;YAC9B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC;KACtC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/creative-context",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.30-nightly-20261003164120",
|
|
4
4
|
"description": "Shared creative context ingestion, versioning, search, brand DNA, and context-pack primitives for agent-native apps.",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"react-dom": "^19.2.7",
|
|
59
59
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
60
60
|
"vitest": "^4.1.5",
|
|
61
|
-
"@agent-native/
|
|
62
|
-
"@agent-native/
|
|
61
|
+
"@agent-native/core": "0.201.0-nightly-20261003164120",
|
|
62
|
+
"@agent-native/toolkit": "^0.201.0-nightly-20261003164120"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@agent-native/core": "
|
|
66
|
-
"@agent-native/toolkit": "
|
|
65
|
+
"@agent-native/core": "0.201.0-nightly-20261003164120",
|
|
66
|
+
"@agent-native/toolkit": "0.201.0-nightly-20261003164120",
|
|
67
67
|
"@tabler/icons-react": ">=3.41.1",
|
|
68
68
|
"@tanstack/react-query": ">=5.101.4",
|
|
69
69
|
"drizzle-orm": ">=0.45",
|
package/src/server/labs.spec.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ActionEntry } from "@agent-native/core/server";
|
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
|
|
4
4
|
const mocks = vi.hoisted(() => ({
|
|
5
|
-
|
|
5
|
+
getUserLabEnabled: vi.fn(),
|
|
6
6
|
getRequestUserEmail: vi.fn(),
|
|
7
7
|
getCreativeContext: vi.fn(),
|
|
8
8
|
}));
|
|
@@ -27,20 +27,23 @@ beforeEach(() => {
|
|
|
27
27
|
describe("isCreativeContextLabAvailable", () => {
|
|
28
28
|
it("does not expose the library without an authenticated user", async () => {
|
|
29
29
|
await expect(isCreativeContextLabAvailable(undefined)).resolves.toBe(false);
|
|
30
|
-
expect(mocks.
|
|
30
|
+
expect(mocks.getUserLabEnabled).not.toHaveBeenCalled();
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it("uses the shared Creative Context Lab by default", async () => {
|
|
34
|
-
mocks.
|
|
34
|
+
mocks.getUserLabEnabled.mockResolvedValue(true);
|
|
35
35
|
|
|
36
36
|
await expect(
|
|
37
37
|
isCreativeContextLabAvailable("user@example.com"),
|
|
38
38
|
).resolves.toBe(true);
|
|
39
|
-
expect(mocks.
|
|
39
|
+
expect(mocks.getUserLabEnabled).toHaveBeenCalledWith(
|
|
40
|
+
"user@example.com",
|
|
41
|
+
"creative-context.library",
|
|
42
|
+
);
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
it("supports an app's existing Creative Context Lab key", async () => {
|
|
43
|
-
mocks.
|
|
46
|
+
mocks.getUserLabEnabled.mockResolvedValue(true);
|
|
44
47
|
|
|
45
48
|
await expect(
|
|
46
49
|
isCreativeContextLabAvailable(
|
|
@@ -51,7 +54,9 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
it("preserves unreadable lab state as an error", async () => {
|
|
54
|
-
mocks.
|
|
57
|
+
mocks.getUserLabEnabled.mockRejectedValue(
|
|
58
|
+
new Error("settings unavailable"),
|
|
59
|
+
);
|
|
55
60
|
|
|
56
61
|
await expect(
|
|
57
62
|
isCreativeContextLabAvailable("user@example.com"),
|
|
@@ -59,14 +64,17 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
59
64
|
});
|
|
60
65
|
|
|
61
66
|
it("requires the configured app Lab before Creative Context operations", async () => {
|
|
62
|
-
mocks.
|
|
67
|
+
mocks.getUserLabEnabled.mockResolvedValue(true);
|
|
63
68
|
await expect(
|
|
64
69
|
assertCreativeContextLabEnabled("user@example.com"),
|
|
65
70
|
).resolves.toBeUndefined();
|
|
66
|
-
expect(mocks.
|
|
71
|
+
expect(mocks.getUserLabEnabled).toHaveBeenCalledWith(
|
|
72
|
+
"user@example.com",
|
|
73
|
+
"content.creative-context",
|
|
74
|
+
);
|
|
67
75
|
expect(mocks.getCreativeContext).toHaveBeenCalled();
|
|
68
76
|
|
|
69
|
-
mocks.
|
|
77
|
+
mocks.getUserLabEnabled.mockResolvedValue(false);
|
|
70
78
|
await expect(
|
|
71
79
|
assertCreativeContextLabEnabled("user@example.com"),
|
|
72
80
|
).rejects.toMatchObject({
|
|
@@ -86,15 +94,18 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
86
94
|
});
|
|
87
95
|
const action = actions["manage-creative-context"];
|
|
88
96
|
|
|
89
|
-
mocks.
|
|
97
|
+
mocks.getUserLabEnabled.mockResolvedValue(true);
|
|
90
98
|
await expect(
|
|
91
99
|
action.run({}, { caller: "tool", userEmail: "user@example.test" }),
|
|
92
100
|
).resolves.toEqual({ ok: true });
|
|
93
|
-
expect(mocks.
|
|
101
|
+
expect(mocks.getUserLabEnabled).toHaveBeenCalledWith(
|
|
102
|
+
"user@example.test",
|
|
103
|
+
"content.creative-context",
|
|
104
|
+
);
|
|
94
105
|
expect(mocks.getCreativeContext).toHaveBeenCalled();
|
|
95
106
|
expect(run).toHaveBeenCalledOnce();
|
|
96
107
|
|
|
97
|
-
mocks.
|
|
108
|
+
mocks.getUserLabEnabled.mockResolvedValue(false);
|
|
98
109
|
await expect(
|
|
99
110
|
action.run({}, { caller: "tool", userEmail: "user@example.test" }),
|
|
100
111
|
).rejects.toThrow("Creative Context is disabled in Labs");
|
|
@@ -109,9 +120,9 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
109
120
|
},
|
|
110
121
|
});
|
|
111
122
|
const action = actions["manage-creative-context"];
|
|
112
|
-
mocks.
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
mocks.getUserLabEnabled.mockImplementation(
|
|
124
|
+
async (email: string) => email === "enabled@example.test",
|
|
125
|
+
);
|
|
115
126
|
|
|
116
127
|
await expect(
|
|
117
128
|
action.agentDiscoveryAvailable?.({
|
|
@@ -125,9 +136,9 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
125
136
|
userEmail: "enabled@example.test",
|
|
126
137
|
}),
|
|
127
138
|
).resolves.toBe(true);
|
|
128
|
-
expect(mocks.
|
|
129
|
-
"disabled@example.test",
|
|
130
|
-
"enabled@example.test",
|
|
139
|
+
expect(mocks.getUserLabEnabled.mock.calls).toEqual([
|
|
140
|
+
["disabled@example.test", "content.creative-context"],
|
|
141
|
+
["enabled@example.test", "content.creative-context"],
|
|
131
142
|
]);
|
|
132
143
|
});
|
|
133
144
|
|
|
@@ -139,12 +150,14 @@ describe("isCreativeContextLabAvailable", () => {
|
|
|
139
150
|
run,
|
|
140
151
|
},
|
|
141
152
|
});
|
|
142
|
-
mocks.
|
|
153
|
+
mocks.getUserLabEnabled.mockRejectedValue(
|
|
154
|
+
new Error("settings unavailable"),
|
|
155
|
+
);
|
|
143
156
|
|
|
144
157
|
await expect(actions["process-context-purge"].run({})).resolves.toEqual({
|
|
145
158
|
ok: true,
|
|
146
159
|
});
|
|
147
|
-
expect(mocks.
|
|
160
|
+
expect(mocks.getUserLabEnabled).not.toHaveBeenCalled();
|
|
148
161
|
expect(run).toHaveBeenCalledOnce();
|
|
149
162
|
});
|
|
150
163
|
});
|
package/src/server/labs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fail } from "@agent-native/core/action";
|
|
2
|
-
import {
|
|
2
|
+
import { getUserLabEnabled } from "@agent-native/core/labs/server";
|
|
3
3
|
import type { ActionEntry } from "@agent-native/core/server";
|
|
4
4
|
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
5
5
|
|
|
@@ -11,8 +11,7 @@ export async function isCreativeContextLabAvailable(
|
|
|
11
11
|
labKey = CREATIVE_CONTEXT_LIBRARY_LAB.key,
|
|
12
12
|
): Promise<boolean> {
|
|
13
13
|
if (!userEmail) return false;
|
|
14
|
-
|
|
15
|
-
return labs[labKey] === true;
|
|
14
|
+
return getUserLabEnabled(userEmail, labKey);
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export async function assertCreativeContextLabEnabled(
|