@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.
- package/.turbo/turbo-build.log +40 -42
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +12 -0
- package/dist/agent.d.ts +8 -16
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +28 -31
- package/dist/blueprint.d.ts +2 -6
- package/dist/blueprint.d.ts.map +1 -1
- package/dist/blueprint.js +26 -28
- package/dist/browser/agent.js +31 -0
- package/dist/browser/blueprint.js +26 -0
- package/dist/browser/docs/index.js +42 -0
- package/dist/browser/docs/knowledge-canon.docblock.js +42 -0
- package/dist/browser/example.js +33 -0
- package/dist/browser/index.js +191 -0
- package/dist/browser/source.sample.js +29 -0
- package/dist/browser/tenant.js +34 -0
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +43 -1
- package/dist/docs/knowledge-canon.docblock.d.ts +2 -1
- package/dist/docs/knowledge-canon.docblock.d.ts.map +1 -0
- package/dist/docs/knowledge-canon.docblock.js +40 -26
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +32 -44
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +192 -8
- package/dist/node/agent.js +31 -0
- package/dist/node/blueprint.js +26 -0
- package/dist/node/docs/index.js +42 -0
- package/dist/node/docs/knowledge-canon.docblock.js +42 -0
- package/dist/node/example.js +33 -0
- package/dist/node/index.js +191 -0
- package/dist/node/source.sample.js +29 -0
- package/dist/node/tenant.js +34 -0
- package/dist/source.sample.d.ts +2 -6
- package/dist/source.sample.d.ts.map +1 -1
- package/dist/source.sample.js +29 -29
- package/dist/tenant.d.ts +2 -6
- package/dist/tenant.d.ts.map +1 -1
- package/dist/tenant.js +34 -32
- package/package.json +84 -29
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -42
- package/dist/agent.js.map +0 -1
- package/dist/blueprint.js.map +0 -1
- package/dist/docs/knowledge-canon.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/source.sample.js.map +0 -1
- package/dist/tenant.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/source.sample.ts
|
|
2
|
+
var productCanonNotionSource = {
|
|
3
|
+
meta: {
|
|
4
|
+
id: "source-canon-notion",
|
|
5
|
+
tenantId: "artisan-co",
|
|
6
|
+
spaceKey: "knowledge.product-canon",
|
|
7
|
+
spaceVersion: "1.0.0",
|
|
8
|
+
label: "Product Canon (Notion)",
|
|
9
|
+
sourceType: "notion",
|
|
10
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
11
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
12
|
+
},
|
|
13
|
+
config: {
|
|
14
|
+
notionDatabaseId: "xxxxxxxxxxxxxxxx",
|
|
15
|
+
apiKey: "secret_notion_token"
|
|
16
|
+
},
|
|
17
|
+
syncSchedule: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
cron: "0 * * * *"
|
|
20
|
+
},
|
|
21
|
+
lastSync: {
|
|
22
|
+
timestamp: new Date("2026-01-01T00:00:00.000Z"),
|
|
23
|
+
success: true,
|
|
24
|
+
itemsProcessed: 128
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
productCanonNotionSource
|
|
29
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/tenant.ts
|
|
2
|
+
var artisanKnowledgeTenantConfig = {
|
|
3
|
+
meta: {
|
|
4
|
+
id: "tenant-config-artisan-knowledge",
|
|
5
|
+
tenantId: "artisan-co",
|
|
6
|
+
appId: "artisan",
|
|
7
|
+
blueprintName: "artisan.knowledge.product",
|
|
8
|
+
blueprintVersion: "1.0.0",
|
|
9
|
+
environment: "production",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
status: "published",
|
|
12
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
13
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
14
|
+
},
|
|
15
|
+
knowledge: [
|
|
16
|
+
{
|
|
17
|
+
spaceKey: "knowledge.product-canon",
|
|
18
|
+
spaceVersion: "1.0.0",
|
|
19
|
+
scope: {
|
|
20
|
+
workflows: ["answerFaq"],
|
|
21
|
+
agents: ["productSupportAssistant"]
|
|
22
|
+
},
|
|
23
|
+
constraints: {
|
|
24
|
+
maxTokensPerQuery: 4096,
|
|
25
|
+
maxQueriesPerMinute: 30
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
integrations: [],
|
|
30
|
+
notes: "Product Canon knowledge space bound for production assistants."
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
artisanKnowledgeTenantConfig
|
|
34
|
+
};
|
package/dist/docs/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import './knowledge-canon.docblock';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC"}
|
package/dist/docs/index.js
CHANGED
|
@@ -1 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/docs/knowledge-canon.docblock.ts
|
|
3
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
4
|
+
var blocks = [
|
|
5
|
+
{
|
|
6
|
+
id: "docs.examples.knowledge-canon",
|
|
7
|
+
title: "Knowledge Example \u2014 Product Canon Space",
|
|
8
|
+
summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
|
|
9
|
+
kind: "reference",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
route: "/docs/examples/knowledge-canon",
|
|
12
|
+
tags: ["knowledge", "canon", "example"],
|
|
13
|
+
body: `## Included assets
|
|
14
|
+
- Blueprint referencing a workflow depending on the Product Canon space.
|
|
15
|
+
- Tenant app config binding the space to a workflow and agent scope.
|
|
16
|
+
- Sample knowledge source configuration.
|
|
17
|
+
- Helper to pick knowledge bindings from ResolvedAppConfig.
|
|
18
|
+
|
|
19
|
+
## Guardrails
|
|
20
|
+
- Keep sources scoped per tenant.
|
|
21
|
+
- Keep secret fields out of config (use secret providers).
|
|
22
|
+
- Enforce scope restrictions before answering.`
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "docs.examples.knowledge-canon.usage",
|
|
26
|
+
title: "Knowledge Canon \u2014 Usage",
|
|
27
|
+
summary: "How to register the space, configure sources, and route requests.",
|
|
28
|
+
kind: "usage",
|
|
29
|
+
visibility: "public",
|
|
30
|
+
route: "/docs/examples/knowledge-canon/usage",
|
|
31
|
+
tags: ["knowledge", "usage"],
|
|
32
|
+
body: `## Usage
|
|
33
|
+
1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
|
|
34
|
+
2) Persist the source config through knowledge CRUD operations.
|
|
35
|
+
3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
|
|
36
|
+
4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
|
|
37
|
+
|
|
38
|
+
## Notes
|
|
39
|
+
- Avoid logging PII.
|
|
40
|
+
- Keep search results auditable and cite sources.`
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
registerDocBlocks(blocks);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=knowledge-canon.docblock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-canon.docblock.d.ts","sourceRoot":"","sources":["../../src/docs/knowledge-canon.docblock.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +1,43 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/docs/knowledge-canon.docblock.ts
|
|
1
3
|
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
4
|
+
var blocks = [
|
|
5
|
+
{
|
|
6
|
+
id: "docs.examples.knowledge-canon",
|
|
7
|
+
title: "Knowledge Example \u2014 Product Canon Space",
|
|
8
|
+
summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
|
|
9
|
+
kind: "reference",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
route: "/docs/examples/knowledge-canon",
|
|
12
|
+
tags: ["knowledge", "canon", "example"],
|
|
13
|
+
body: `## Included assets
|
|
14
|
+
- Blueprint referencing a workflow depending on the Product Canon space.
|
|
15
|
+
- Tenant app config binding the space to a workflow and agent scope.
|
|
16
|
+
- Sample knowledge source configuration.
|
|
17
|
+
- Helper to pick knowledge bindings from ResolvedAppConfig.
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
kind: "usage",
|
|
22
|
-
visibility: "public",
|
|
23
|
-
route: "/docs/examples/knowledge-canon/usage",
|
|
24
|
-
tags: ["knowledge", "usage"],
|
|
25
|
-
body: `## Usage\n1) Register the knowledge space spec in your KnowledgeSpaceRegistry.\n2) Persist the source config through knowledge CRUD operations.\n3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.\n4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.\n\n## Notes\n- Avoid logging PII.\n- Keep search results auditable and cite sources.`
|
|
26
|
-
}]);
|
|
19
|
+
## Guardrails
|
|
20
|
+
- Keep sources scoped per tenant.
|
|
21
|
+
- Keep secret fields out of config (use secret providers).
|
|
22
|
+
- Enforce scope restrictions before answering.`
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "docs.examples.knowledge-canon.usage",
|
|
26
|
+
title: "Knowledge Canon \u2014 Usage",
|
|
27
|
+
summary: "How to register the space, configure sources, and route requests.",
|
|
28
|
+
kind: "usage",
|
|
29
|
+
visibility: "public",
|
|
30
|
+
route: "/docs/examples/knowledge-canon/usage",
|
|
31
|
+
tags: ["knowledge", "usage"],
|
|
32
|
+
body: `## Usage
|
|
33
|
+
1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
|
|
34
|
+
2) Persist the source config through knowledge CRUD operations.
|
|
35
|
+
3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
|
|
36
|
+
4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
## Notes
|
|
39
|
+
- Avoid logging PII.
|
|
40
|
+
- Keep search results auditable and cite sources.`
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
registerDocBlocks(blocks);
|
package/dist/example.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region src/example.d.ts
|
|
4
|
-
declare const example: _contractspec_lib_contracts0.ExampleSpec;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { example as default };
|
|
1
|
+
declare const example: import("@contractspec/lib.contracts").ExampleSpec;
|
|
2
|
+
export default example;
|
|
7
3
|
//# sourceMappingURL=example.d.ts.map
|
package/dist/example.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.d.ts","
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,OAAO,mDA2BX,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
package/dist/example.js
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/example.ts
|
|
1
3
|
import { defineExample } from "@contractspec/lib.contracts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
docs: "./docs"
|
|
29
|
-
},
|
|
30
|
-
surfaces: {
|
|
31
|
-
templates: true,
|
|
32
|
-
sandbox: {
|
|
33
|
-
enabled: true,
|
|
34
|
-
modes: ["markdown", "specs"]
|
|
35
|
-
},
|
|
36
|
-
studio: {
|
|
37
|
-
enabled: true,
|
|
38
|
-
installable: true
|
|
39
|
-
},
|
|
40
|
-
mcp: { enabled: true }
|
|
41
|
-
}
|
|
4
|
+
var example = defineExample({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "knowledge-canon",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
title: "Knowledge Canon (Product Canon space)",
|
|
9
|
+
description: "Bind a canonical knowledge space to a tenant and route assistant/workflow requests to the right sources (blueprint + app config pattern).",
|
|
10
|
+
kind: "knowledge",
|
|
11
|
+
visibility: "public",
|
|
12
|
+
stability: "experimental",
|
|
13
|
+
owners: ["@platform.core"],
|
|
14
|
+
tags: ["knowledge", "canon", "app-config", "agents", "workflows"]
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: "docs.examples.knowledge-canon",
|
|
18
|
+
usageDocId: "docs.examples.knowledge-canon.usage"
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: "@contractspec/example.knowledge-canon",
|
|
22
|
+
docs: "./docs"
|
|
23
|
+
},
|
|
24
|
+
surfaces: {
|
|
25
|
+
templates: true,
|
|
26
|
+
sandbox: { enabled: true, modes: ["markdown", "specs"] },
|
|
27
|
+
studio: { enabled: true, installable: true },
|
|
28
|
+
mcp: { enabled: true }
|
|
29
|
+
}
|
|
42
30
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
var example_default = example;
|
|
32
|
+
export {
|
|
33
|
+
example_default as default
|
|
34
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export * from './agent';
|
|
2
|
+
export * from './blueprint';
|
|
3
|
+
export * from './tenant';
|
|
4
|
+
export * from './source.sample';
|
|
5
|
+
export { default as example } from './example';
|
|
6
|
+
import './docs';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,192 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/agent.ts
|
|
3
|
+
function selectKnowledgeBindings(resolved, options) {
|
|
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
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function answerWithKnowledge(resolved, question, { workflowId, agentId }) {
|
|
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
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/blueprint.ts
|
|
31
|
+
import {
|
|
32
|
+
OwnersEnum,
|
|
33
|
+
StabilityEnum,
|
|
34
|
+
TagsEnum
|
|
35
|
+
} from "@contractspec/lib.contracts/ownership";
|
|
36
|
+
var artisanKnowledgeBlueprint = {
|
|
37
|
+
meta: {
|
|
38
|
+
key: "artisan.knowledge.product",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
appId: "artisan",
|
|
41
|
+
title: "ArtisanOS Knowledge \u2013 Product Canon",
|
|
42
|
+
description: "Blueprint that surfaces canonical product knowledge to agents and workflows.",
|
|
43
|
+
domain: "knowledge",
|
|
44
|
+
owners: [OwnersEnum.PlatformContent],
|
|
45
|
+
tags: ["knowledge", "product-canon", TagsEnum.Guide],
|
|
46
|
+
stability: StabilityEnum.Experimental
|
|
47
|
+
},
|
|
48
|
+
workflows: {
|
|
49
|
+
answerFaq: { key: "artisan.knowledge.answerFaq", version: "1.0.0" }
|
|
50
|
+
},
|
|
51
|
+
notes: "Workflows and assistants running on this blueprint should bind the Product Canon knowledge space."
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/docs/knowledge-canon.docblock.ts
|
|
55
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
56
|
+
var blocks = [
|
|
57
|
+
{
|
|
58
|
+
id: "docs.examples.knowledge-canon",
|
|
59
|
+
title: "Knowledge Example \u2014 Product Canon Space",
|
|
60
|
+
summary: "Bind the Product Canon KnowledgeSpaceSpec to a tenant and expose it to agents/workflows via ResolvedAppConfig.",
|
|
61
|
+
kind: "reference",
|
|
62
|
+
visibility: "public",
|
|
63
|
+
route: "/docs/examples/knowledge-canon",
|
|
64
|
+
tags: ["knowledge", "canon", "example"],
|
|
65
|
+
body: `## Included assets
|
|
66
|
+
- Blueprint referencing a workflow depending on the Product Canon space.
|
|
67
|
+
- Tenant app config binding the space to a workflow and agent scope.
|
|
68
|
+
- Sample knowledge source configuration.
|
|
69
|
+
- Helper to pick knowledge bindings from ResolvedAppConfig.
|
|
70
|
+
|
|
71
|
+
## Guardrails
|
|
72
|
+
- Keep sources scoped per tenant.
|
|
73
|
+
- Keep secret fields out of config (use secret providers).
|
|
74
|
+
- Enforce scope restrictions before answering.`
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "docs.examples.knowledge-canon.usage",
|
|
78
|
+
title: "Knowledge Canon \u2014 Usage",
|
|
79
|
+
summary: "How to register the space, configure sources, and route requests.",
|
|
80
|
+
kind: "usage",
|
|
81
|
+
visibility: "public",
|
|
82
|
+
route: "/docs/examples/knowledge-canon/usage",
|
|
83
|
+
tags: ["knowledge", "usage"],
|
|
84
|
+
body: `## Usage
|
|
85
|
+
1) Register the knowledge space spec in your KnowledgeSpaceRegistry.
|
|
86
|
+
2) Persist the source config through knowledge CRUD operations.
|
|
87
|
+
3) Compose ResolvedAppConfig and pass it to your workflow/agent runtime.
|
|
88
|
+
4) Use helpers like \`selectKnowledgeBindings\` before dispatching to search/embedding.
|
|
89
|
+
|
|
90
|
+
## Notes
|
|
91
|
+
- Avoid logging PII.
|
|
92
|
+
- Keep search results auditable and cite sources.`
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
registerDocBlocks(blocks);
|
|
96
|
+
// src/example.ts
|
|
97
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
98
|
+
var example = defineExample({
|
|
99
|
+
meta: {
|
|
100
|
+
key: "knowledge-canon",
|
|
101
|
+
version: "1.0.0",
|
|
102
|
+
title: "Knowledge Canon (Product Canon space)",
|
|
103
|
+
description: "Bind a canonical knowledge space to a tenant and route assistant/workflow requests to the right sources (blueprint + app config pattern).",
|
|
104
|
+
kind: "knowledge",
|
|
105
|
+
visibility: "public",
|
|
106
|
+
stability: "experimental",
|
|
107
|
+
owners: ["@platform.core"],
|
|
108
|
+
tags: ["knowledge", "canon", "app-config", "agents", "workflows"]
|
|
109
|
+
},
|
|
110
|
+
docs: {
|
|
111
|
+
rootDocId: "docs.examples.knowledge-canon",
|
|
112
|
+
usageDocId: "docs.examples.knowledge-canon.usage"
|
|
113
|
+
},
|
|
114
|
+
entrypoints: {
|
|
115
|
+
packageName: "@contractspec/example.knowledge-canon",
|
|
116
|
+
docs: "./docs"
|
|
117
|
+
},
|
|
118
|
+
surfaces: {
|
|
119
|
+
templates: true,
|
|
120
|
+
sandbox: { enabled: true, modes: ["markdown", "specs"] },
|
|
121
|
+
studio: { enabled: true, installable: true },
|
|
122
|
+
mcp: { enabled: true }
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
var example_default = example;
|
|
126
|
+
|
|
127
|
+
// src/tenant.ts
|
|
128
|
+
var artisanKnowledgeTenantConfig = {
|
|
129
|
+
meta: {
|
|
130
|
+
id: "tenant-config-artisan-knowledge",
|
|
131
|
+
tenantId: "artisan-co",
|
|
132
|
+
appId: "artisan",
|
|
133
|
+
blueprintName: "artisan.knowledge.product",
|
|
134
|
+
blueprintVersion: "1.0.0",
|
|
135
|
+
environment: "production",
|
|
136
|
+
version: "1.0.0",
|
|
137
|
+
status: "published",
|
|
138
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
139
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
140
|
+
},
|
|
141
|
+
knowledge: [
|
|
142
|
+
{
|
|
143
|
+
spaceKey: "knowledge.product-canon",
|
|
144
|
+
spaceVersion: "1.0.0",
|
|
145
|
+
scope: {
|
|
146
|
+
workflows: ["answerFaq"],
|
|
147
|
+
agents: ["productSupportAssistant"]
|
|
148
|
+
},
|
|
149
|
+
constraints: {
|
|
150
|
+
maxTokensPerQuery: 4096,
|
|
151
|
+
maxQueriesPerMinute: 30
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
integrations: [],
|
|
156
|
+
notes: "Product Canon knowledge space bound for production assistants."
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/source.sample.ts
|
|
160
|
+
var productCanonNotionSource = {
|
|
161
|
+
meta: {
|
|
162
|
+
id: "source-canon-notion",
|
|
163
|
+
tenantId: "artisan-co",
|
|
164
|
+
spaceKey: "knowledge.product-canon",
|
|
165
|
+
spaceVersion: "1.0.0",
|
|
166
|
+
label: "Product Canon (Notion)",
|
|
167
|
+
sourceType: "notion",
|
|
168
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
169
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
170
|
+
},
|
|
171
|
+
config: {
|
|
172
|
+
notionDatabaseId: "xxxxxxxxxxxxxxxx",
|
|
173
|
+
apiKey: "secret_notion_token"
|
|
174
|
+
},
|
|
175
|
+
syncSchedule: {
|
|
176
|
+
enabled: true,
|
|
177
|
+
cron: "0 * * * *"
|
|
178
|
+
},
|
|
179
|
+
lastSync: {
|
|
180
|
+
timestamp: new Date("2026-01-01T00:00:00.000Z"),
|
|
181
|
+
success: true,
|
|
182
|
+
itemsProcessed: 128
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
export {
|
|
186
|
+
selectKnowledgeBindings,
|
|
187
|
+
productCanonNotionSource,
|
|
188
|
+
example_default as example,
|
|
189
|
+
artisanKnowledgeTenantConfig,
|
|
190
|
+
artisanKnowledgeBlueprint,
|
|
191
|
+
answerWithKnowledge
|
|
192
|
+
};
|
|
@@ -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);
|