@contractspec/example.knowledge-canon 1.57.0 → 1.58.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.
Files changed (53) hide show
  1. package/.turbo/turbo-build.log +40 -42
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +12 -0
  4. package/dist/agent.d.ts +8 -16
  5. package/dist/agent.d.ts.map +1 -1
  6. package/dist/agent.js +28 -31
  7. package/dist/blueprint.d.ts +2 -6
  8. package/dist/blueprint.d.ts.map +1 -1
  9. package/dist/blueprint.js +26 -28
  10. package/dist/browser/agent.js +31 -0
  11. package/dist/browser/blueprint.js +26 -0
  12. package/dist/browser/docs/index.js +42 -0
  13. package/dist/browser/docs/knowledge-canon.docblock.js +42 -0
  14. package/dist/browser/example.js +33 -0
  15. package/dist/browser/index.js +191 -0
  16. package/dist/browser/source.sample.js +29 -0
  17. package/dist/browser/tenant.js +34 -0
  18. package/dist/docs/index.d.ts +2 -1
  19. package/dist/docs/index.d.ts.map +1 -0
  20. package/dist/docs/index.js +43 -1
  21. package/dist/docs/knowledge-canon.docblock.d.ts +2 -1
  22. package/dist/docs/knowledge-canon.docblock.d.ts.map +1 -0
  23. package/dist/docs/knowledge-canon.docblock.js +40 -26
  24. package/dist/example.d.ts +2 -6
  25. package/dist/example.d.ts.map +1 -1
  26. package/dist/example.js +32 -44
  27. package/dist/index.d.ts +7 -6
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +192 -8
  30. package/dist/node/agent.js +31 -0
  31. package/dist/node/blueprint.js +26 -0
  32. package/dist/node/docs/index.js +42 -0
  33. package/dist/node/docs/knowledge-canon.docblock.js +42 -0
  34. package/dist/node/example.js +33 -0
  35. package/dist/node/index.js +191 -0
  36. package/dist/node/source.sample.js +29 -0
  37. package/dist/node/tenant.js +34 -0
  38. package/dist/source.sample.d.ts +2 -6
  39. package/dist/source.sample.d.ts.map +1 -1
  40. package/dist/source.sample.js +29 -29
  41. package/dist/tenant.d.ts +2 -6
  42. package/dist/tenant.d.ts.map +1 -1
  43. package/dist/tenant.js +34 -32
  44. package/package.json +84 -29
  45. package/tsdown.config.js +1 -2
  46. package/.turbo/turbo-build$colon$bundle.log +0 -42
  47. package/dist/agent.js.map +0 -1
  48. package/dist/blueprint.js.map +0 -1
  49. package/dist/docs/knowledge-canon.docblock.js.map +0 -1
  50. package/dist/example.js.map +0 -1
  51. package/dist/source.sample.js.map +0 -1
  52. package/dist/tenant.js.map +0 -1
  53. package/tsconfig.tsbuildinfo +0 -1
@@ -1,43 +1,41 @@
1
- $ bun build:types && bun build:bundle
2
- $ tsc --noEmit
3
- $ tsdown
4
- ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3
5
- ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/knowledge-canon/tsdown.config.js
6
- ℹ entry: src/agent.ts, src/blueprint.ts, src/example.ts, src/index.ts, src/source.sample.ts, src/tenant.ts, src/docs/index.ts, src/docs/knowledge-canon.docblock.ts
7
- ℹ target: esnext
8
- ℹ tsconfig: tsconfig.json
9
- ℹ Build start
10
- ℹ dist/docs/knowledge-canon.docblock.js 1.68 kB │ gzip: 0.79 kB
11
- ℹ dist/agent.js 1.25 kB │ gzip: 0.62 kB
12
- ℹ dist/example.js 1.05 kB │ gzip: 0.55 kB
13
- ℹ dist/blueprint.js 0.85 kB │ gzip: 0.46 kB
14
- ℹ dist/tenant.js 0.82 kB │ gzip: 0.45 kB
15
- ℹ dist/source.sample.js 0.70 kB │ gzip: 0.41 kB
16
- ℹ dist/index.js 0.47 kB │ gzip: 0.20 kB
17
- ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
18
- ℹ dist/docs/knowledge-canon.docblock.js.map 2.18 kB │ gzip: 0.97 kB
19
- ℹ dist/agent.js.map 2.13 kB │ gzip: 1.00 kB
20
- ℹ dist/example.js.map 1.52 kB │ gzip: 0.75 kB
21
- ℹ dist/tenant.js.map 1.35 kB │ gzip: 0.68 kB
22
- ℹ dist/blueprint.js.map 1.26 kB │ gzip: 0.64 kB
23
- ℹ dist/source.sample.js.map 1.14 kB │ gzip: 0.58 kB
24
- ℹ dist/agent.d.ts.map 0.29 kB │ gzip: 0.19 kB
25
- ℹ dist/source.sample.d.ts.map 0.13 kB │ gzip: 0.12 kB
26
- ℹ dist/example.d.ts.map 0.13 kB │ gzip: 0.13 kB
27
- ℹ dist/blueprint.d.ts.map 0.12 kB │ gzip: 0.12 kB
28
- ℹ dist/tenant.d.ts.map 0.11 kB │ gzip: 0.12 kB
29
- ℹ dist/agent.d.ts 0.91 kB │ gzip: 0.44 kB
30
- ℹ dist/index.d.ts 0.44 kB │ gzip: 0.19 kB
31
- ℹ dist/source.sample.d.ts 0.28 kB │ gzip: 0.18 kB
32
- ℹ dist/blueprint.d.ts 0.26 kB │ gzip: 0.18 kB
33
- ℹ dist/tenant.d.ts 0.26 kB │ gzip: 0.18 kB
34
- ℹ dist/example.d.ts 0.25 kB │ gzip: 0.17 kB
35
- ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
36
- ℹ dist/docs/knowledge-canon.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
37
- ℹ 27 files, total: 19.65 kB
38
- [PLUGIN_TIMINGS] Warning: Your build spent significant time in plugins. Here is a breakdown:
39
- - rolldown-plugin-dts:generate (72%)
40
- - tsdown:external (24%)
41
- See https://rolldown.rs/options/checks#plugintimings for more details.
1
+ $ contractspec-bun-build prebuild
2
+ $ bun run prebuild && bun run build:bundle && bun run build:types
3
+ $ contractspec-bun-build prebuild
4
+ $ contractspec-bun-build transpile
5
+ [contractspec-bun-build] transpile target=bun root=src entries=8
6
+ Bundled 8 modules in 10ms
42
7
 
43
- ✔ Build complete in 20950ms
8
+ ./agent.js 1.0 KB (entry point)
9
+ ./index.js 5.98 KB (entry point)
10
+ ./blueprint.js 0.82 KB (entry point)
11
+ docs/index.js 1.67 KB (entry point)
12
+ docs/knowledge-canon.docblock.js 1.67 KB (entry point)
13
+ ./example.js 1.0 KB (entry point)
14
+ ./source.sample.js 0.67 KB (entry point)
15
+ ./tenant.js 0.85 KB (entry point)
16
+
17
+ [contractspec-bun-build] transpile target=node root=src entries=8
18
+ Bundled 8 modules in 31ms
19
+
20
+ ./agent.js 0.99 KB (entry point)
21
+ ./index.js 5.96 KB (entry point)
22
+ ./blueprint.js 0.81 KB (entry point)
23
+ docs/index.js 1.66 KB (entry point)
24
+ docs/knowledge-canon.docblock.js 1.66 KB (entry point)
25
+ ./example.js 1.0 KB (entry point)
26
+ ./source.sample.js 0.66 KB (entry point)
27
+ ./tenant.js 0.84 KB (entry point)
28
+
29
+ [contractspec-bun-build] transpile target=browser root=src entries=8
30
+ Bundled 8 modules in 16ms
31
+
32
+ ./agent.js 0.99 KB (entry point)
33
+ ./index.js 5.96 KB (entry point)
34
+ ./blueprint.js 0.81 KB (entry point)
35
+ docs/index.js 1.66 KB (entry point)
36
+ docs/knowledge-canon.docblock.js 1.66 KB (entry point)
37
+ ./example.js 1.0 KB (entry point)
38
+ ./source.sample.js 0.66 KB (entry point)
39
+ ./tenant.js 0.84 KB (entry point)
40
+
41
+ $ contractspec-bun-build types
@@ -0,0 +1 @@
1
+ $ contractspec-bun-build prebuild
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @contractspec/example.knowledge-canon
2
2
 
3
+ ## 1.58.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d1f0fd0: chore: Migrate non-app package builds from tsdown to shared Bun tooling, add `@contractspec/tool.bun`, and standardize `prebuild`/`build`/`typecheck` with platform-aware exports and `tsc` declaration emission into `dist`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d1f0fd0]
12
+ - Updated dependencies [4355a9e]
13
+ - @contractspec/lib.contracts@1.58.0
14
+
3
15
  ## 1.57.0
4
16
 
5
17
  ### Minor Changes
package/dist/agent.d.ts CHANGED
@@ -1,25 +1,17 @@
1
- import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
- import { ResolvedAppConfig } from "@contractspec/lib.contracts/app-config/runtime";
3
-
4
- //#region src/agent.d.ts
1
+ import type { ResolvedAppConfig } from '@contractspec/lib.contracts/app-config/runtime';
5
2
  /**
6
3
  * Selects knowledge bindings that apply to a workflow or agent identifier.
7
4
  */
8
- declare function selectKnowledgeBindings(resolved: ResolvedAppConfig, options: {
9
- workflowId?: string;
10
- agentId?: string;
11
- }): _contractspec_lib_contracts0.ResolvedKnowledge[];
5
+ export declare function selectKnowledgeBindings(resolved: ResolvedAppConfig, options: {
6
+ workflowId?: string;
7
+ agentId?: string;
8
+ }): import("@contractspec/lib.contracts").ResolvedKnowledge[];
12
9
  /**
13
10
  * Pseudo implementation of an assistant lookup that routes prompts to the appropriate
14
11
  * knowledge sources. In a real system this would call the ingestion/search services.
15
12
  */
16
- declare function answerWithKnowledge(resolved: ResolvedAppConfig, question: string, {
17
- workflowId,
18
- agentId
19
- }: {
20
- workflowId?: string;
21
- agentId?: string;
13
+ export declare function answerWithKnowledge(resolved: ResolvedAppConfig, question: string, { workflowId, agentId }: {
14
+ workflowId?: string;
15
+ agentId?: string;
22
16
  }): Promise<string>;
23
- //#endregion
24
- export { answerWithKnowledge, selectKnowledgeBindings };
25
17
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","names":[],"sources":["../src/agent.ts"],"mappings":";;;;;;;iBAKgB,uBAAA,CACd,QAAA,EAAU,iBAAA,EACV,OAAA;EAAW,UAAA;EAAqB,OAAA;AAAA,IADL,4BAAA,CACuB,iBAAA;;;;;iBAmB9B,mBAAA,CACpB,QAAA,EAAU,iBAAA,EACV,QAAA;EACE,UAAA;EAAY;AAAA;EAAa,UAAA;EAAqB,OAAA;AAAA,IAC/C,OAAA"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAExF;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,6DAanD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,EAChB,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACjE,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
package/dist/agent.js CHANGED
@@ -1,35 +1,32 @@
1
- //#region src/agent.ts
2
- /**
3
- * Selects knowledge bindings that apply to a workflow or agent identifier.
4
- */
1
+ // @bun
2
+ // src/agent.ts
5
3
  function selectKnowledgeBindings(resolved, options) {
6
- return resolved.knowledge.filter(({ binding }) => {
7
- if (!binding.scope) return true;
8
- if (options.workflowId && binding.scope.workflows?.includes(options.workflowId)) return true;
9
- if (options.agentId && binding.scope.agents?.includes(options.agentId)) return true;
10
- return false;
11
- });
4
+ return resolved.knowledge.filter(({ binding }) => {
5
+ if (!binding.scope)
6
+ return true;
7
+ if (options.workflowId && binding.scope.workflows?.includes(options.workflowId))
8
+ return true;
9
+ if (options.agentId && binding.scope.agents?.includes(options.agentId))
10
+ return true;
11
+ return false;
12
+ });
12
13
  }
13
- /**
14
- * Pseudo implementation of an assistant lookup that routes prompts to the appropriate
15
- * knowledge sources. In a real system this would call the ingestion/search services.
16
- */
17
14
  async function answerWithKnowledge(resolved, question, { workflowId, agentId }) {
18
- const bindings = selectKnowledgeBindings(resolved, {
19
- workflowId,
20
- agentId
21
- });
22
- if (bindings.length === 0) return "No knowledge space available for this request.";
23
- const summaries = bindings.map(({ space }) => `• ${space.meta.title || space.meta.description}`);
24
- return [
25
- `Q: ${question}`,
26
- "Routed to knowledge spaces:",
27
- ...summaries,
28
- "",
29
- "TODO: invoke knowledge search service and synthesize response."
30
- ].join("\n");
15
+ const bindings = selectKnowledgeBindings(resolved, { workflowId, agentId });
16
+ if (bindings.length === 0) {
17
+ return "No knowledge space available for this request.";
18
+ }
19
+ const summaries = bindings.map(({ space }) => `\u2022 ${space.meta.title || space.meta.description}`);
20
+ return [
21
+ `Q: ${question}`,
22
+ "Routed to knowledge spaces:",
23
+ ...summaries,
24
+ "",
25
+ "TODO: invoke knowledge search service and synthesize response."
26
+ ].join(`
27
+ `);
31
28
  }
32
-
33
- //#endregion
34
- export { answerWithKnowledge, selectKnowledgeBindings };
35
- //# sourceMappingURL=agent.js.map
29
+ export {
30
+ selectKnowledgeBindings,
31
+ answerWithKnowledge
32
+ };
@@ -1,7 +1,3 @@
1
- import { AppBlueprintSpec } from "@contractspec/lib.contracts/app-config/spec";
2
-
3
- //#region src/blueprint.d.ts
4
- declare const artisanKnowledgeBlueprint: AppBlueprintSpec;
5
- //#endregion
6
- export { artisanKnowledgeBlueprint };
1
+ import type { AppBlueprintSpec } from '@contractspec/lib.contracts/app-config/spec';
2
+ export declare const artisanKnowledgeBlueprint: AppBlueprintSpec;
7
3
  //# sourceMappingURL=blueprint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blueprint.d.ts","names":[],"sources":["../src/blueprint.ts"],"mappings":";;;cAOa,yBAAA,EAA2B,gBAAA"}
1
+ {"version":3,"file":"blueprint.d.ts","sourceRoot":"","sources":["../src/blueprint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAOpF,eAAO,MAAM,yBAAyB,EAAE,gBAkBvC,CAAC"}
package/dist/blueprint.js CHANGED
@@ -1,29 +1,27 @@
1
- import { OwnersEnum, StabilityEnum, TagsEnum } from "@contractspec/lib.contracts/ownership";
2
-
3
- //#region src/blueprint.ts
4
- const artisanKnowledgeBlueprint = {
5
- meta: {
6
- key: "artisan.knowledge.product",
7
- version: "1.0.0",
8
- appId: "artisan",
9
- title: "ArtisanOS Knowledge – Product Canon",
10
- description: "Blueprint that surfaces canonical product knowledge to agents and workflows.",
11
- domain: "knowledge",
12
- owners: [OwnersEnum.PlatformContent],
13
- tags: [
14
- "knowledge",
15
- "product-canon",
16
- TagsEnum.Guide
17
- ],
18
- stability: StabilityEnum.Experimental
19
- },
20
- workflows: { answerFaq: {
21
- key: "artisan.knowledge.answerFaq",
22
- version: "1.0.0"
23
- } },
24
- notes: "Workflows and assistants running on this blueprint should bind the Product Canon knowledge space."
1
+ // @bun
2
+ // src/blueprint.ts
3
+ import {
4
+ OwnersEnum,
5
+ StabilityEnum,
6
+ TagsEnum
7
+ } from "@contractspec/lib.contracts/ownership";
8
+ var artisanKnowledgeBlueprint = {
9
+ meta: {
10
+ key: "artisan.knowledge.product",
11
+ version: "1.0.0",
12
+ appId: "artisan",
13
+ title: "ArtisanOS Knowledge \u2013 Product Canon",
14
+ description: "Blueprint that surfaces canonical product knowledge to agents and workflows.",
15
+ domain: "knowledge",
16
+ owners: [OwnersEnum.PlatformContent],
17
+ tags: ["knowledge", "product-canon", TagsEnum.Guide],
18
+ stability: StabilityEnum.Experimental
19
+ },
20
+ workflows: {
21
+ answerFaq: { key: "artisan.knowledge.answerFaq", version: "1.0.0" }
22
+ },
23
+ notes: "Workflows and assistants running on this blueprint should bind the Product Canon knowledge space."
24
+ };
25
+ export {
26
+ artisanKnowledgeBlueprint
25
27
  };
26
-
27
- //#endregion
28
- export { artisanKnowledgeBlueprint };
29
- //# sourceMappingURL=blueprint.js.map
@@ -0,0 +1,31 @@
1
+ // src/agent.ts
2
+ function selectKnowledgeBindings(resolved, options) {
3
+ return resolved.knowledge.filter(({ binding }) => {
4
+ if (!binding.scope)
5
+ return true;
6
+ if (options.workflowId && binding.scope.workflows?.includes(options.workflowId))
7
+ return true;
8
+ if (options.agentId && binding.scope.agents?.includes(options.agentId))
9
+ return true;
10
+ return false;
11
+ });
12
+ }
13
+ async function answerWithKnowledge(resolved, question, { workflowId, agentId }) {
14
+ const bindings = selectKnowledgeBindings(resolved, { workflowId, agentId });
15
+ if (bindings.length === 0) {
16
+ return "No knowledge space available for this request.";
17
+ }
18
+ const summaries = bindings.map(({ space }) => `• ${space.meta.title || space.meta.description}`);
19
+ return [
20
+ `Q: ${question}`,
21
+ "Routed to knowledge spaces:",
22
+ ...summaries,
23
+ "",
24
+ "TODO: invoke knowledge search service and synthesize response."
25
+ ].join(`
26
+ `);
27
+ }
28
+ export {
29
+ selectKnowledgeBindings,
30
+ answerWithKnowledge
31
+ };
@@ -0,0 +1,26 @@
1
+ // src/blueprint.ts
2
+ import {
3
+ OwnersEnum,
4
+ StabilityEnum,
5
+ TagsEnum
6
+ } from "@contractspec/lib.contracts/ownership";
7
+ var artisanKnowledgeBlueprint = {
8
+ meta: {
9
+ key: "artisan.knowledge.product",
10
+ version: "1.0.0",
11
+ appId: "artisan",
12
+ title: "ArtisanOS Knowledge – Product Canon",
13
+ description: "Blueprint that surfaces canonical product knowledge to agents and workflows.",
14
+ domain: "knowledge",
15
+ owners: [OwnersEnum.PlatformContent],
16
+ tags: ["knowledge", "product-canon", TagsEnum.Guide],
17
+ stability: StabilityEnum.Experimental
18
+ },
19
+ workflows: {
20
+ answerFaq: { key: "artisan.knowledge.answerFaq", version: "1.0.0" }
21
+ },
22
+ notes: "Workflows and assistants running on this blueprint should bind the Product Canon knowledge space."
23
+ };
24
+ export {
25
+ artisanKnowledgeBlueprint
26
+ };
@@ -0,0 +1,42 @@
1
+ // src/docs/knowledge-canon.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.knowledge-canon",
6
+ title: "Knowledge Example — Product Canon Space",
7
+ summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/knowledge-canon",
11
+ tags: ["knowledge", "canon", "example"],
12
+ body: `## Included assets
13
+ - Blueprint referencing a workflow depending on the Product Canon space.
14
+ - Tenant app config binding the space to a workflow and agent scope.
15
+ - Sample knowledge source configuration.
16
+ - Helper to pick knowledge bindings from ResolvedAppConfig.
17
+
18
+ ## Guardrails
19
+ - Keep sources scoped per tenant.
20
+ - Keep secret fields out of config (use secret providers).
21
+ - Enforce scope restrictions before answering.`
22
+ },
23
+ {
24
+ id: "docs.examples.knowledge-canon.usage",
25
+ title: "Knowledge Canon — Usage",
26
+ summary: "How to register the space, configure sources, and route requests.",
27
+ kind: "usage",
28
+ visibility: "public",
29
+ route: "/docs/examples/knowledge-canon/usage",
30
+ tags: ["knowledge", "usage"],
31
+ body: `## Usage
32
+ 1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
33
+ 2) Persist the source config through knowledge CRUD operations.
34
+ 3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
35
+ 4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
36
+
37
+ ## Notes
38
+ - Avoid logging PII.
39
+ - Keep search results auditable and cite sources.`
40
+ }
41
+ ];
42
+ registerDocBlocks(blocks);
@@ -0,0 +1,42 @@
1
+ // src/docs/knowledge-canon.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.knowledge-canon",
6
+ title: "Knowledge Example — Product Canon Space",
7
+ summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/knowledge-canon",
11
+ tags: ["knowledge", "canon", "example"],
12
+ body: `## Included assets
13
+ - Blueprint referencing a workflow depending on the Product Canon space.
14
+ - Tenant app config binding the space to a workflow and agent scope.
15
+ - Sample knowledge source configuration.
16
+ - Helper to pick knowledge bindings from ResolvedAppConfig.
17
+
18
+ ## Guardrails
19
+ - Keep sources scoped per tenant.
20
+ - Keep secret fields out of config (use secret providers).
21
+ - Enforce scope restrictions before answering.`
22
+ },
23
+ {
24
+ id: "docs.examples.knowledge-canon.usage",
25
+ title: "Knowledge Canon — Usage",
26
+ summary: "How to register the space, configure sources, and route requests.",
27
+ kind: "usage",
28
+ visibility: "public",
29
+ route: "/docs/examples/knowledge-canon/usage",
30
+ tags: ["knowledge", "usage"],
31
+ body: `## Usage
32
+ 1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
33
+ 2) Persist the source config through knowledge CRUD operations.
34
+ 3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
35
+ 4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
36
+
37
+ ## Notes
38
+ - Avoid logging PII.
39
+ - Keep search results auditable and cite sources.`
40
+ }
41
+ ];
42
+ registerDocBlocks(blocks);
@@ -0,0 +1,33 @@
1
+ // src/example.ts
2
+ import { defineExample } from "@contractspec/lib.contracts";
3
+ var example = defineExample({
4
+ meta: {
5
+ key: "knowledge-canon",
6
+ version: "1.0.0",
7
+ title: "Knowledge Canon (Product Canon space)",
8
+ description: "Bind a canonical knowledge space to a tenant and route assistant/workflow requests to the right sources (blueprint + app config pattern).",
9
+ kind: "knowledge",
10
+ visibility: "public",
11
+ stability: "experimental",
12
+ owners: ["@platform.core"],
13
+ tags: ["knowledge", "canon", "app-config", "agents", "workflows"]
14
+ },
15
+ docs: {
16
+ rootDocId: "docs.examples.knowledge-canon",
17
+ usageDocId: "docs.examples.knowledge-canon.usage"
18
+ },
19
+ entrypoints: {
20
+ packageName: "@contractspec/example.knowledge-canon",
21
+ docs: "./docs"
22
+ },
23
+ surfaces: {
24
+ templates: true,
25
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
26
+ studio: { enabled: true, installable: true },
27
+ mcp: { enabled: true }
28
+ }
29
+ });
30
+ var example_default = example;
31
+ export {
32
+ example_default as default
33
+ };
@@ -0,0 +1,191 @@
1
+ // src/agent.ts
2
+ function selectKnowledgeBindings(resolved, options) {
3
+ return resolved.knowledge.filter(({ binding }) => {
4
+ if (!binding.scope)
5
+ return true;
6
+ if (options.workflowId && binding.scope.workflows?.includes(options.workflowId))
7
+ return true;
8
+ if (options.agentId && binding.scope.agents?.includes(options.agentId))
9
+ return true;
10
+ return false;
11
+ });
12
+ }
13
+ async function answerWithKnowledge(resolved, question, { workflowId, agentId }) {
14
+ const bindings = selectKnowledgeBindings(resolved, { workflowId, agentId });
15
+ if (bindings.length === 0) {
16
+ return "No knowledge space available for this request.";
17
+ }
18
+ const summaries = bindings.map(({ space }) => `• ${space.meta.title || space.meta.description}`);
19
+ return [
20
+ `Q: ${question}`,
21
+ "Routed to knowledge spaces:",
22
+ ...summaries,
23
+ "",
24
+ "TODO: invoke knowledge search service and synthesize response."
25
+ ].join(`
26
+ `);
27
+ }
28
+
29
+ // src/blueprint.ts
30
+ import {
31
+ OwnersEnum,
32
+ StabilityEnum,
33
+ TagsEnum
34
+ } from "@contractspec/lib.contracts/ownership";
35
+ var artisanKnowledgeBlueprint = {
36
+ meta: {
37
+ key: "artisan.knowledge.product",
38
+ version: "1.0.0",
39
+ appId: "artisan",
40
+ title: "ArtisanOS Knowledge – Product Canon",
41
+ description: "Blueprint that surfaces canonical product knowledge to agents and workflows.",
42
+ domain: "knowledge",
43
+ owners: [OwnersEnum.PlatformContent],
44
+ tags: ["knowledge", "product-canon", TagsEnum.Guide],
45
+ stability: StabilityEnum.Experimental
46
+ },
47
+ workflows: {
48
+ answerFaq: { key: "artisan.knowledge.answerFaq", version: "1.0.0" }
49
+ },
50
+ notes: "Workflows and assistants running on this blueprint should bind the Product Canon knowledge space."
51
+ };
52
+
53
+ // src/docs/knowledge-canon.docblock.ts
54
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
55
+ var blocks = [
56
+ {
57
+ id: "docs.examples.knowledge-canon",
58
+ title: "Knowledge Example — Product Canon Space",
59
+ summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
60
+ kind: "reference",
61
+ visibility: "public",
62
+ route: "/docs/examples/knowledge-canon",
63
+ tags: ["knowledge", "canon", "example"],
64
+ body: `## Included assets
65
+ - Blueprint referencing a workflow depending on the Product Canon space.
66
+ - Tenant app config binding the space to a workflow and agent scope.
67
+ - Sample knowledge source configuration.
68
+ - Helper to pick knowledge bindings from ResolvedAppConfig.
69
+
70
+ ## Guardrails
71
+ - Keep sources scoped per tenant.
72
+ - Keep secret fields out of config (use secret providers).
73
+ - Enforce scope restrictions before answering.`
74
+ },
75
+ {
76
+ id: "docs.examples.knowledge-canon.usage",
77
+ title: "Knowledge Canon — Usage",
78
+ summary: "How to register the space, configure sources, and route requests.",
79
+ kind: "usage",
80
+ visibility: "public",
81
+ route: "/docs/examples/knowledge-canon/usage",
82
+ tags: ["knowledge", "usage"],
83
+ body: `## Usage
84
+ 1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
85
+ 2) Persist the source config through knowledge CRUD operations.
86
+ 3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
87
+ 4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
88
+
89
+ ## Notes
90
+ - Avoid logging PII.
91
+ - Keep search results auditable and cite sources.`
92
+ }
93
+ ];
94
+ registerDocBlocks(blocks);
95
+ // src/example.ts
96
+ import { defineExample } from "@contractspec/lib.contracts";
97
+ var example = defineExample({
98
+ meta: {
99
+ key: "knowledge-canon",
100
+ version: "1.0.0",
101
+ title: "Knowledge Canon (Product Canon space)",
102
+ description: "Bind a canonical knowledge space to a tenant and route assistant/workflow requests to the right sources (blueprint + app config pattern).",
103
+ kind: "knowledge",
104
+ visibility: "public",
105
+ stability: "experimental",
106
+ owners: ["@platform.core"],
107
+ tags: ["knowledge", "canon", "app-config", "agents", "workflows"]
108
+ },
109
+ docs: {
110
+ rootDocId: "docs.examples.knowledge-canon",
111
+ usageDocId: "docs.examples.knowledge-canon.usage"
112
+ },
113
+ entrypoints: {
114
+ packageName: "@contractspec/example.knowledge-canon",
115
+ docs: "./docs"
116
+ },
117
+ surfaces: {
118
+ templates: true,
119
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
120
+ studio: { enabled: true, installable: true },
121
+ mcp: { enabled: true }
122
+ }
123
+ });
124
+ var example_default = example;
125
+
126
+ // src/tenant.ts
127
+ var artisanKnowledgeTenantConfig = {
128
+ meta: {
129
+ id: "tenant-config-artisan-knowledge",
130
+ tenantId: "artisan-co",
131
+ appId: "artisan",
132
+ blueprintName: "artisan.knowledge.product",
133
+ blueprintVersion: "1.0.0",
134
+ environment: "production",
135
+ version: "1.0.0",
136
+ status: "published",
137
+ createdAt: "2026-01-01T00:00:00.000Z",
138
+ updatedAt: "2026-01-01T00:00:00.000Z"
139
+ },
140
+ knowledge: [
141
+ {
142
+ spaceKey: "knowledge.product-canon",
143
+ spaceVersion: "1.0.0",
144
+ scope: {
145
+ workflows: ["answerFaq"],
146
+ agents: ["productSupportAssistant"]
147
+ },
148
+ constraints: {
149
+ maxTokensPerQuery: 4096,
150
+ maxQueriesPerMinute: 30
151
+ }
152
+ }
153
+ ],
154
+ integrations: [],
155
+ notes: "Product Canon knowledge space bound for production assistants."
156
+ };
157
+
158
+ // src/source.sample.ts
159
+ var productCanonNotionSource = {
160
+ meta: {
161
+ id: "source-canon-notion",
162
+ tenantId: "artisan-co",
163
+ spaceKey: "knowledge.product-canon",
164
+ spaceVersion: "1.0.0",
165
+ label: "Product Canon (Notion)",
166
+ sourceType: "notion",
167
+ createdAt: "2026-01-01T00:00:00.000Z",
168
+ updatedAt: "2026-01-01T00:00:00.000Z"
169
+ },
170
+ config: {
171
+ notionDatabaseId: "xxxxxxxxxxxxxxxx",
172
+ apiKey: "secret_notion_token"
173
+ },
174
+ syncSchedule: {
175
+ enabled: true,
176
+ cron: "0 * * * *"
177
+ },
178
+ lastSync: {
179
+ timestamp: new Date("2026-01-01T00:00:00.000Z"),
180
+ success: true,
181
+ itemsProcessed: 128
182
+ }
183
+ };
184
+ export {
185
+ selectKnowledgeBindings,
186
+ productCanonNotionSource,
187
+ example_default as example,
188
+ artisanKnowledgeTenantConfig,
189
+ artisanKnowledgeBlueprint,
190
+ answerWithKnowledge
191
+ };