@dbx-tools/appkit-generator 0.9.153 → 0.9.157
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/index.ts +16 -6
- package/lib/index.d.ts +16 -6
- package/lib/index.js +17 -7
- package/lib/src/assets.d.ts +1 -1
- package/lib/src/assets.js +4 -4
- package/lib/src/config.js +9 -12
- package/lib/src/dashboard.d.ts +2 -2
- package/lib/src/dashboard.js +6 -6
- package/lib/src/data.d.ts +1 -1
- package/lib/src/data.js +6 -6
- package/lib/src/defaults.d.ts +1 -1
- package/lib/src/defaults.js +1 -1
- package/lib/src/generate.d.ts +2 -1
- package/lib/src/generate.js +5 -4
- package/lib/src/genie.d.ts +1 -1
- package/lib/src/genie.js +5 -5
- package/lib/src/kpi.d.ts +1 -1
- package/lib/src/kpi.js +4 -4
- package/lib/src/namespace.d.ts +1 -1
- package/lib/src/namespace.js +12 -12
- package/lib/src/operations.d.ts +1 -3
- package/lib/src/operations.js +1 -1
- package/lib/src/plan.d.ts +1 -3
- package/lib/src/plan.js +2 -2
- package/lib/src/plugin.d.ts +8 -8
- package/lib/src/plugin.js +8 -12
- package/lib/src/research.d.ts +2 -3
- package/lib/src/research.js +8 -8
- package/lib/src/schema.d.ts +2 -4
- package/lib/src/schema.js +3 -4
- package/lib/src/structured.js +2 -2
- package/lib/src/workflow.js +3 -4
- package/package.json +10 -154
- package/src/assets.ts +4 -4
- package/src/config.ts +10 -21
- package/src/dashboard.ts +6 -6
- package/src/data.ts +7 -7
- package/src/defaults.ts +2 -1
- package/src/generate.ts +9 -10
- package/src/genie.ts +4 -4
- package/src/kpi.ts +3 -3
- package/src/namespace.ts +11 -11
- package/src/operations.ts +5 -3
- package/src/plan.ts +3 -3
- package/src/plugin.ts +9 -11
- package/src/research.ts +14 -16
- package/src/schema.ts +4 -29
- package/src/structured.ts +1 -1
- package/src/workflow.ts +3 -3
package/src/kpi.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { toDescription } from "@dbx-tools/shared-core";
|
|
8
8
|
import {
|
|
9
9
|
KpiResearchRequestSchema,
|
|
10
10
|
KpiResearchResultSchema,
|
|
11
11
|
type KpiResearchRequest,
|
|
12
12
|
type KpiResearchResult,
|
|
13
|
-
} from "@dbx-tools/shared-generator
|
|
13
|
+
} from "@dbx-tools/shared-generator";
|
|
14
14
|
import type { BrandResearchClient } from "./research.ts";
|
|
15
15
|
import { generateStructured } from "./structured.ts";
|
|
16
16
|
|
|
@@ -28,7 +28,7 @@ export interface ResearchKpisOptions {
|
|
|
28
28
|
|
|
29
29
|
/** Build the web query that grounds KPI selection in the requested questions. */
|
|
30
30
|
export function kpiResearchQuery(request: KpiResearchRequest): string {
|
|
31
|
-
return
|
|
31
|
+
return toDescription(`
|
|
32
32
|
Research current, standard business KPIs for ${request.company} and the
|
|
33
33
|
purpose "${request.purpose}". The generated demo must answer these
|
|
34
34
|
questions: ${request.queries.join(" | ")}. Prefer authoritative industry,
|
package/src/namespace.ts
CHANGED
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
getExecutionContext,
|
|
11
11
|
type WorkspaceClient,
|
|
12
12
|
} from "@databricks/appkit";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { toContext } from "@dbx-tools/appkit";
|
|
14
|
+
import { errorContext, fnvHash, toIdentifierWithOptions, trimToNull } from "@dbx-tools/shared-core";
|
|
15
15
|
import {
|
|
16
16
|
GeneratedSchemaSchema,
|
|
17
17
|
type GeneratedSchema,
|
|
18
18
|
type GeneratorRequest,
|
|
19
|
-
} from "@dbx-tools/shared-generator
|
|
19
|
+
} from "@dbx-tools/shared-generator";
|
|
20
20
|
|
|
21
21
|
const OWNER_DIGEST_PROPERTY = "dbx_tools.generator.owner_digest";
|
|
22
22
|
const REQUEST_DIGEST_PROPERTY = "dbx_tools.generator.request_digest";
|
|
@@ -43,7 +43,7 @@ export interface GeneratorIdentity {
|
|
|
43
43
|
|
|
44
44
|
/** Derive a readable, bounded schema name with collision-resistant overflow. */
|
|
45
45
|
export function generatorSchemaName(principal: string, company: string, purpose: string): string {
|
|
46
|
-
const base =
|
|
46
|
+
const base = toIdentifierWithOptions(
|
|
47
47
|
{
|
|
48
48
|
delimiter: "_",
|
|
49
49
|
omitEmailDomain: true,
|
|
@@ -65,7 +65,7 @@ export async function resolveGeneratorIdentity(): Promise<GeneratorIdentity> {
|
|
|
65
65
|
throw new ConfigurationError("Generator operations require an on-behalf-of user context");
|
|
66
66
|
}
|
|
67
67
|
const current = await context.client.currentUser.me();
|
|
68
|
-
const principal =
|
|
68
|
+
const principal = trimToNull(current.userName);
|
|
69
69
|
if (!principal) {
|
|
70
70
|
throw new ConfigurationError("The current Databricks user has no userName");
|
|
71
71
|
}
|
|
@@ -88,7 +88,7 @@ async function getSchema(
|
|
|
88
88
|
try {
|
|
89
89
|
return await client.toLegacyWorkspaceClient().schemas.get({ full_name: fullName });
|
|
90
90
|
} catch (cause) {
|
|
91
|
-
const context =
|
|
91
|
+
const context = errorContext(cause);
|
|
92
92
|
if (context.hasStatusCode(404) || context.hasMessage("does not exist")) return undefined;
|
|
93
93
|
throw cause;
|
|
94
94
|
}
|
|
@@ -129,7 +129,7 @@ export async function provisionGeneratorSchemaWithIdentity(
|
|
|
129
129
|
identity: GeneratorIdentity,
|
|
130
130
|
signal?: AbortSignal,
|
|
131
131
|
): Promise<GeneratedSchema> {
|
|
132
|
-
const catalog =
|
|
132
|
+
const catalog = trimToNull(input.catalog);
|
|
133
133
|
if (!catalog) throw new ConfigurationError("GENERATOR_CATALOG is required");
|
|
134
134
|
|
|
135
135
|
const schemaName = generatorSchemaName(
|
|
@@ -138,9 +138,9 @@ export async function provisionGeneratorSchemaWithIdentity(
|
|
|
138
138
|
input.request.purpose,
|
|
139
139
|
);
|
|
140
140
|
const fullName = `${catalog}.${schemaName}`;
|
|
141
|
-
const ownerDigest =
|
|
142
|
-
const requestDigest =
|
|
143
|
-
const context = signal ?
|
|
141
|
+
const ownerDigest = fnvHash(identity.userId);
|
|
142
|
+
const requestDigest = fnvHash(identity.userId, input.request.company, input.request.purpose);
|
|
143
|
+
const context = signal ? toContext(signal) : undefined;
|
|
144
144
|
|
|
145
145
|
await identity.userClient.toLegacyWorkspaceClient().catalogs.get({ name: catalog });
|
|
146
146
|
|
|
@@ -160,7 +160,7 @@ export async function provisionGeneratorSchemaWithIdentity(
|
|
|
160
160
|
context,
|
|
161
161
|
);
|
|
162
162
|
} catch (cause) {
|
|
163
|
-
if (!
|
|
163
|
+
if (!errorContext(cause).hasMessage("already exists")) throw cause;
|
|
164
164
|
}
|
|
165
165
|
schema = await getSchema(identity.serviceClient, fullName);
|
|
166
166
|
}
|
package/src/operations.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ConfigurationError } from "@databricks/appkit";
|
|
8
|
-
import type { BrandGenerationRequest, BrandPackage } from "@dbx-tools/shared-generator/brand";
|
|
9
|
-
import type { KpiResearchRequest, KpiResearchResult } from "@dbx-tools/shared-generator/kpi";
|
|
10
8
|
import type {
|
|
9
|
+
BrandGenerationRequest,
|
|
10
|
+
BrandPackage,
|
|
11
|
+
KpiResearchRequest,
|
|
12
|
+
KpiResearchResult,
|
|
11
13
|
CreateGeneratorPresentationRequest,
|
|
12
14
|
GeneratedDashboard,
|
|
13
15
|
GeneratedGenieSpace,
|
|
@@ -17,7 +19,7 @@ import type {
|
|
|
17
19
|
MaterializedGeneratorData,
|
|
18
20
|
PlanGeneratorDataRequest,
|
|
19
21
|
ProvisionGeneratorSchemaRequest,
|
|
20
|
-
} from "@dbx-tools/shared-generator
|
|
22
|
+
} from "@dbx-tools/shared-generator";
|
|
21
23
|
import type { ResolvedGeneratorConfig } from "./config.ts";
|
|
22
24
|
import { createGeneratorDashboard } from "./dashboard.ts";
|
|
23
25
|
import { materializeGeneratorData } from "./data.ts";
|
package/src/plan.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { BrandPackage } from "@dbx-tools/shared-generator/brand";
|
|
8
|
-
import type { KpiResearchResult } from "@dbx-tools/shared-generator/kpi";
|
|
9
7
|
import {
|
|
10
8
|
GeneratorPlanSchema,
|
|
9
|
+
type BrandPackage,
|
|
10
|
+
type KpiResearchResult,
|
|
11
11
|
type GeneratorPlan,
|
|
12
12
|
type GeneratorRequest,
|
|
13
|
-
} from "@dbx-tools/shared-generator
|
|
13
|
+
} from "@dbx-tools/shared-generator";
|
|
14
14
|
import { generateStructured } from "./structured.ts";
|
|
15
15
|
|
|
16
16
|
/** Inputs for deterministic demo-data planning. */
|
package/src/plugin.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import { defineManifest, toPlugin, type IAppRouter } from "@databricks/appkit";
|
|
8
8
|
import { defineTool, type ToolRegistry } from "@databricks/appkit/beta";
|
|
9
|
-
import {
|
|
9
|
+
import { ToolRegistryPlugin, require } from "@dbx-tools/appkit";
|
|
10
10
|
import { mastra } from "@dbx-tools/appkit-mastra";
|
|
11
11
|
import { webSearch } from "@dbx-tools/appkit-web-search";
|
|
12
|
-
import {
|
|
12
|
+
import { log, toError } from "@dbx-tools/shared-core";
|
|
13
13
|
import {
|
|
14
14
|
GENERATOR_ROUTES,
|
|
15
15
|
GeneratorClientConfigSchema,
|
|
@@ -17,9 +17,10 @@ import {
|
|
|
17
17
|
BrandGenerationEventSchema,
|
|
18
18
|
BrandGenerationRequestSchema,
|
|
19
19
|
type BrandGenerationEvent,
|
|
20
|
-
} from "@dbx-tools/shared-generator
|
|
21
|
-
import { KpiResearchRequestSchema, KpiResearchResultSchema } from "@dbx-tools/shared-generator/kpi";
|
|
20
|
+
} from "@dbx-tools/shared-generator";
|
|
22
21
|
import {
|
|
22
|
+
KpiResearchRequestSchema,
|
|
23
|
+
KpiResearchResultSchema,
|
|
23
24
|
CreateGeneratorPresentationRequestSchema,
|
|
24
25
|
GeneratedAssetsSchema,
|
|
25
26
|
GeneratedDashboardSchema,
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
MaterializedGeneratorDataSchema,
|
|
31
32
|
PlanGeneratorDataRequestSchema,
|
|
32
33
|
ProvisionGeneratorSchemaRequestSchema,
|
|
33
|
-
} from "@dbx-tools/shared-generator
|
|
34
|
+
} from "@dbx-tools/shared-generator";
|
|
34
35
|
import {
|
|
35
36
|
resolveGeneratorConfig,
|
|
36
37
|
type GeneratorPluginConfig,
|
|
@@ -129,10 +130,7 @@ export class GeneratorPlugin extends ToolRegistryPlugin<GeneratorPluginConfig> {
|
|
|
129
130
|
researchClient: this.researchClient(),
|
|
130
131
|
});
|
|
131
132
|
this.workflow = createGeneratorWorkflow(this.operations);
|
|
132
|
-
|
|
133
|
-
.require(this.context, mastra, this)
|
|
134
|
-
.exports()
|
|
135
|
-
.registerWorkflow(WORKFLOW_KEY, this.workflow);
|
|
133
|
+
require(this.context, mastra, this).exports().registerWorkflow(WORKFLOW_KEY, this.workflow);
|
|
136
134
|
logger.info("ready", {
|
|
137
135
|
model: this.resolved.model ?? "automatic",
|
|
138
136
|
catalog: this.resolved.catalog ?? "brand-only",
|
|
@@ -185,7 +183,7 @@ export class GeneratorPlugin extends ToolRegistryPlugin<GeneratorPluginConfig> {
|
|
|
185
183
|
.generateBrand(parsed.data, controller.signal, send);
|
|
186
184
|
send({ type: "result", package: generated });
|
|
187
185
|
} catch (cause) {
|
|
188
|
-
logger.warn("brand-route-failed", { error:
|
|
186
|
+
logger.warn("brand-route-failed", { error: toError(cause) });
|
|
189
187
|
send({
|
|
190
188
|
type: "error",
|
|
191
189
|
message:
|
|
@@ -224,7 +222,7 @@ export class GeneratorPlugin extends ToolRegistryPlugin<GeneratorPluginConfig> {
|
|
|
224
222
|
|
|
225
223
|
/** Resolve the sibling web-search plugin without recreating its policy. */
|
|
226
224
|
private researchClient(): BrandResearchClient {
|
|
227
|
-
const sibling =
|
|
225
|
+
const sibling = require(this.context, webSearch, this).exports();
|
|
228
226
|
return {
|
|
229
227
|
search: sibling.search,
|
|
230
228
|
fetch: sibling.fetch,
|
package/src/research.ts
CHANGED
|
@@ -9,23 +9,21 @@ import type {
|
|
|
9
9
|
WebAssetPageFetchRequest,
|
|
10
10
|
WebImageFetchRequest,
|
|
11
11
|
WebImageFetchResult,
|
|
12
|
-
} from "@dbx-tools/appkit-web-search/fetch";
|
|
13
|
-
import type {
|
|
14
12
|
WebFetchRequest,
|
|
15
13
|
WebFetchResult,
|
|
16
14
|
WebSearchCitation,
|
|
17
15
|
WebSearchRequest,
|
|
18
16
|
WebSearchResult,
|
|
19
|
-
} from "@dbx-tools/appkit-web-search
|
|
20
|
-
import {
|
|
17
|
+
} from "@dbx-tools/appkit-web-search";
|
|
18
|
+
import { log, toError, toDescription } from "@dbx-tools/shared-core";
|
|
19
|
+
import type {
|
|
20
|
+
BrandGenerationProgressEvent,
|
|
21
|
+
BrandGenerationRequest,
|
|
22
|
+
BrandPackageSource,
|
|
23
|
+
BrandVisualReference,
|
|
24
|
+
} from "@dbx-tools/shared-generator";
|
|
21
25
|
import { discoverMobileAppVisuals } from "./assets.ts";
|
|
22
|
-
import {
|
|
23
|
-
brandRequestSubject,
|
|
24
|
-
type BrandGenerationProgressEvent,
|
|
25
|
-
type BrandGenerationRequest,
|
|
26
|
-
type BrandPackageSource,
|
|
27
|
-
type BrandVisualReference,
|
|
28
|
-
} from "./schema.ts";
|
|
26
|
+
import { brandRequestSubject } from "./schema.ts";
|
|
29
27
|
|
|
30
28
|
const logger = log.logger("brand/research");
|
|
31
29
|
|
|
@@ -118,7 +116,7 @@ function fetchAssetPage(
|
|
|
118
116
|
export function brandResearchQuery(request: BrandGenerationRequest): string {
|
|
119
117
|
const subject = brandRequestSubject(request);
|
|
120
118
|
const website = request.website ? ` The known official website is ${request.website}.` : "";
|
|
121
|
-
return
|
|
119
|
+
return toDescription(`
|
|
122
120
|
Research the official brand identity and design direction for "${subject}".${website}
|
|
123
121
|
The broader brief is: ${request.prompt ?? subject}.
|
|
124
122
|
Prefer first-party sources and cite the official website first. Identify
|
|
@@ -193,7 +191,7 @@ async function researchMobileStore(
|
|
|
193
191
|
logger.warn("mobile-image-fetch-failed", {
|
|
194
192
|
platform,
|
|
195
193
|
url,
|
|
196
|
-
error:
|
|
194
|
+
error: toError(error),
|
|
197
195
|
});
|
|
198
196
|
return { url };
|
|
199
197
|
} finally {
|
|
@@ -217,7 +215,7 @@ async function researchMobileStore(
|
|
|
217
215
|
} catch (error) {
|
|
218
216
|
logger.warn("mobile-store-research-failed", {
|
|
219
217
|
platform,
|
|
220
|
-
error:
|
|
218
|
+
error: toError(error),
|
|
221
219
|
});
|
|
222
220
|
await onProgress?.({
|
|
223
221
|
type: "progress",
|
|
@@ -304,7 +302,7 @@ async function fetchSource(
|
|
|
304
302
|
} catch (error) {
|
|
305
303
|
logger.warn("source-fetch-failed", {
|
|
306
304
|
url: citation.url,
|
|
307
|
-
error:
|
|
305
|
+
error: toError(error),
|
|
308
306
|
});
|
|
309
307
|
return { ...citation, fetched: false };
|
|
310
308
|
} finally {
|
|
@@ -403,7 +401,7 @@ export async function researchBrand(
|
|
|
403
401
|
).catch((error: unknown) => {
|
|
404
402
|
logger.warn("official-page-html-fetch-failed", {
|
|
405
403
|
url: official.url,
|
|
406
|
-
error:
|
|
404
|
+
error: toError(error),
|
|
407
405
|
});
|
|
408
406
|
return undefined;
|
|
409
407
|
}),
|
package/src/schema.ts
CHANGED
|
@@ -6,45 +6,20 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import type
|
|
9
|
+
import { toDescription } from "@dbx-tools/shared-core";
|
|
10
|
+
import { type BrandGenerationRequest } from "@dbx-tools/shared-generator";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
export {
|
|
14
|
-
BrandGenerationErrorEventSchema,
|
|
15
|
-
BrandGenerationEventSchema,
|
|
16
|
-
BrandGenerationProgressEventSchema,
|
|
17
|
-
BrandGenerationRequestSchema,
|
|
18
|
-
BrandGenerationResultEventSchema,
|
|
19
|
-
BrandGenerationStageSchema,
|
|
20
|
-
BrandPackageSchema,
|
|
21
|
-
BrandPackageSourceSchema,
|
|
22
|
-
BrandVisualImageSchema,
|
|
23
|
-
BrandVisualReferenceSchema,
|
|
24
|
-
} from "@dbx-tools/shared-generator/brand";
|
|
25
|
-
export type {
|
|
26
|
-
BrandGenerationErrorEvent,
|
|
27
|
-
BrandGenerationEvent,
|
|
28
|
-
BrandGenerationProgressEvent,
|
|
29
|
-
BrandGenerationRequest,
|
|
30
|
-
BrandGenerationResultEvent,
|
|
31
|
-
BrandGenerationStage,
|
|
32
|
-
BrandPackage,
|
|
33
|
-
BrandPackageSource,
|
|
34
|
-
BrandVisualImage,
|
|
35
|
-
BrandVisualReference,
|
|
36
|
-
} from "@dbx-tools/shared-generator/brand";
|
|
37
|
-
|
|
38
13
|
const nonBlankString = z.string().trim().min(1);
|
|
39
14
|
const color = z.string().regex(/^#(?:[\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/i, "Expected a hex color.");
|
|
40
15
|
|
|
41
16
|
/** Resolve the human-readable subject from a validated brand request. */
|
|
42
|
-
export function brandRequestSubject(request:
|
|
17
|
+
export function brandRequestSubject(request: BrandGenerationRequest): string {
|
|
43
18
|
return request.name ?? request.prompt!;
|
|
44
19
|
}
|
|
45
20
|
|
|
46
21
|
/** Description shared by the native AppKit brand-generation tool. */
|
|
47
|
-
export const GENERATE_BRAND_TOOL_DESCRIPTION =
|
|
22
|
+
export const GENERATE_BRAND_TOOL_DESCRIPTION = toDescription(`
|
|
48
23
|
Research a named organization or product on the web and generate a portable
|
|
49
24
|
branding package. The result includes a validated BrandContext for
|
|
50
25
|
application and email presentation plus the sources used. Supply the
|
package/src/structured.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { WorkspaceClient } from "@databricks/appkit";
|
|
8
|
-
import { buildModel, RESPONSES_PROVIDER_OPTIONS } from "@dbx-tools/appkit-mastra
|
|
8
|
+
import { buildModel, RESPONSES_PROVIDER_OPTIONS } from "@dbx-tools/appkit-mastra";
|
|
9
9
|
import { Agent } from "@mastra/core/agent";
|
|
10
10
|
import type { MessageListInput } from "@mastra/core/agent/message-list";
|
|
11
11
|
import type { z } from "zod";
|
package/src/workflow.ts
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { BrandPackageSchema, type BrandGenerationRequest } from "@dbx-tools/shared-generator
|
|
8
|
-
import { KpiResearchResultSchema } from "@dbx-tools/shared-generator/kpi";
|
|
7
|
+
import { BrandPackageSchema, type BrandGenerationRequest } from "@dbx-tools/shared-generator";
|
|
9
8
|
import {
|
|
9
|
+
KpiResearchResultSchema,
|
|
10
10
|
GeneratedAssetsSchema,
|
|
11
11
|
GeneratedSchemaSchema,
|
|
12
12
|
GeneratorPlanSchema,
|
|
13
13
|
GeneratorRequestSchema,
|
|
14
14
|
MaterializedGeneratorDataSchema,
|
|
15
|
-
} from "@dbx-tools/shared-generator
|
|
15
|
+
} from "@dbx-tools/shared-generator";
|
|
16
16
|
import { createStep, createWorkflow } from "@mastra/core/workflows";
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import type { GeneratorOperations } from "./operations.ts";
|