@openbkn/dsh-business-context 0.1.5-rc.1

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 (46) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +42 -0
  3. package/README.zh.md +42 -0
  4. package/cordis.patch.yml +3 -0
  5. package/lib/client.js +7553 -0
  6. package/lib/index.js +1788 -0
  7. package/lib/typert.host.d.ts +3 -0
  8. package/lib/typert.host.js +624 -0
  9. package/lib/typert.remote-client.d.ts +40 -0
  10. package/lib/typert.remote-client.js +435 -0
  11. package/lib/types/auth.d.ts +42 -0
  12. package/lib/types/business-context-service.d.ts +126 -0
  13. package/lib/types/business-graph-model.d.ts +34 -0
  14. package/lib/types/business-network-catalog.d.ts +8 -0
  15. package/lib/types/client/BoundNetworkBadge.d.ts +37 -0
  16. package/lib/types/client/OpenBknContextToolView.d.ts +4 -0
  17. package/lib/types/client/OpenBknEntry.d.ts +9 -0
  18. package/lib/types/client/OpenBknOverlay.d.ts +16 -0
  19. package/lib/types/client/ProvenanceOverlay.d.ts +33 -0
  20. package/lib/types/client/SuggestionDock.d.ts +12 -0
  21. package/lib/types/client/TurnProvenanceActions.d.ts +13 -0
  22. package/lib/types/client/index.d.ts +11 -0
  23. package/lib/types/client/network-directory.d.ts +13 -0
  24. package/lib/types/client/openbkn-ui-controller.d.ts +51 -0
  25. package/lib/types/client/suggestion-dock-controller.d.ts +22 -0
  26. package/lib/types/client/turn-provenance-controller.d.ts +14 -0
  27. package/lib/types/config.d.ts +30 -0
  28. package/lib/types/dsh-session-binding.d.ts +26 -0
  29. package/lib/types/dsh-session-provenance.d.ts +27 -0
  30. package/lib/types/index.d.ts +33 -0
  31. package/lib/types/interaction-references.d.ts +15 -0
  32. package/lib/types/managed-session-policy.d.ts +18 -0
  33. package/lib/types/native-mcp-provenance.d.ts +17 -0
  34. package/lib/types/network-capability-profile.d.ts +26 -0
  35. package/lib/types/openbkn-cli-subprocess.d.ts +50 -0
  36. package/lib/types/openbkn-mcp-manager.d.ts +32 -0
  37. package/lib/types/platform-reader.d.ts +51 -0
  38. package/lib/types/provenance-handle.d.ts +5 -0
  39. package/lib/types/provenance-view.d.ts +11 -0
  40. package/lib/types/scoped-business-context.d.ts +10 -0
  41. package/lib/types/session-binding.d.ts +35 -0
  42. package/lib/types/suggested-prompts.d.ts +3 -0
  43. package/lib/types/turn-provenance.d.ts +25 -0
  44. package/lib/types/types.d.ts +111 -0
  45. package/lib/types/workspace-binding-registry.d.ts +40 -0
  46. package/package.json +131 -0
@@ -0,0 +1,11 @@
1
+ import type { ProvenanceHandle, ProvenanceView } from './types.js';
2
+ export interface ProvenanceViewLimits {
3
+ readonly maxGraphNodes: number;
4
+ readonly maxGraphEdges: number;
5
+ }
6
+ /**
7
+ * Projects Community execution facts plus the exact EE-owned interaction
8
+ * projection. It never derives BKN mappings from raw Core or MCP payloads.
9
+ */
10
+ export declare function buildProvenanceView(handle: ProvenanceHandle, operationsResponse: unknown, enterpriseProjection: unknown | undefined, limits: ProvenanceViewLimits): ProvenanceView;
11
+ //# sourceMappingURL=provenance-view.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { Agent } from '@deepseek-ai/dsh-agent';
2
+ import type { NetworkCapabilityProfile } from './network-capability-profile.js';
3
+ import type { PlatformReaderConfig } from './platform-reader.js';
4
+ /**
5
+ * Mount the model-visible OpenBKN tool in one Agent's Cordis scope. An
6
+ * unbound or differently configured session gets no registration at all, so
7
+ * native DSH conversations keep their original tool catalogue.
8
+ */
9
+ export declare function mountBoundBusinessNetworkTool(agent: Agent, config: PlatformReaderConfig, profile?: NetworkCapabilityProfile): boolean;
10
+ //# sourceMappingURL=scoped-business-context.d.ts.map
@@ -0,0 +1,35 @@
1
+ import type { BusinessNetworkBinding } from './types.js';
2
+ export type { BusinessNetworkBinding } from './types.js';
3
+ /** Durable DSH event type for the business network selected by a session. */
4
+ export declare const BUSINESS_NETWORK_BOUND_EVENT = "openbkn/business-network-bound";
5
+ /** Minimal DSH session-log shape needed to restore an OpenBKN binding. */
6
+ export interface SessionEventLike {
7
+ readonly type: string;
8
+ readonly data: unknown;
9
+ }
10
+ /** The event that a DSH adapter appends exactly once after a selection. */
11
+ export interface BusinessNetworkBoundEvent {
12
+ readonly type: typeof BUSINESS_NETWORK_BOUND_EVENT;
13
+ readonly data: BusinessNetworkBinding;
14
+ }
15
+ export type BindBusinessNetworkResult = {
16
+ readonly kind: 'bound';
17
+ readonly event: BusinessNetworkBoundEvent;
18
+ } | {
19
+ readonly kind: 'already-bound';
20
+ readonly binding: BusinessNetworkBinding;
21
+ };
22
+ /** A durable session already names a different OpenBKN network or platform. */
23
+ export declare class BusinessNetworkBindingConflictError extends Error {
24
+ readonly existing: BusinessNetworkBinding;
25
+ readonly requested: BusinessNetworkBinding;
26
+ constructor(existing: BusinessNetworkBinding, requested: BusinessNetworkBinding);
27
+ }
28
+ /** Reconstruct the one permitted business-network binding from a DSH event log. */
29
+ export declare function readBusinessNetworkBinding(events: readonly SessionEventLike[]): BusinessNetworkBinding | undefined;
30
+ /**
31
+ * Decide whether selection emits the one durable event. The caller appends the
32
+ * returned event through DSH's session log; no in-memory side store exists.
33
+ */
34
+ export declare function bindBusinessNetwork(events: readonly SessionEventLike[], requested: BusinessNetworkBinding): BindBusinessNetworkResult;
35
+ //# sourceMappingURL=session-binding.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** The only prompt shown before a bound business session has a completed answer. */
2
+ export declare function emptyBusinessSessionPrompt(displayName: string): string;
3
+ //# sourceMappingURL=suggested-prompts.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type { ProvenanceHandle } from './types.js';
2
+ /** Durable session event binding one finalized assistant message to one OpenBKN interaction. */
3
+ export declare const TURN_PROVENANCE_EVENT = "openbkn/turn-provenance";
4
+ export interface TurnProvenanceEvent {
5
+ readonly type: typeof TURN_PROVENANCE_EVENT;
6
+ readonly data: {
7
+ readonly messageId: string;
8
+ readonly handle: ProvenanceHandle;
9
+ };
10
+ }
11
+ interface SessionEventLike {
12
+ readonly type: string;
13
+ readonly data: unknown;
14
+ }
15
+ /** A completed message cannot be rewritten to point at a different interaction. */
16
+ export declare class TurnProvenanceConflictError extends Error {
17
+ readonly messageId: string;
18
+ constructor(messageId: string);
19
+ }
20
+ /** Return the one append-only provenance event to write, or undefined if already recorded identically. */
21
+ export declare function appendTurnProvenance(events: readonly SessionEventLike[], messageId: string, handle: ProvenanceHandle): TurnProvenanceEvent | undefined;
22
+ /** Recover the committed handle for exactly one finalized assistant message. */
23
+ export declare function readTurnProvenance(events: readonly SessionEventLike[], messageId: string): ProvenanceHandle | undefined;
24
+ export {};
25
+ //# sourceMappingURL=turn-provenance.d.ts.map
@@ -0,0 +1,111 @@
1
+ /** Safe, UI-ready representation of OpenBKN authentication state. */
2
+ export type AuthSnapshot = {
3
+ readonly kind: 'authenticated';
4
+ readonly baseUrl: string;
5
+ readonly userId?: string;
6
+ readonly username?: string;
7
+ } | {
8
+ readonly kind: 'authentication-required';
9
+ readonly baseUrl: string;
10
+ } | {
11
+ readonly kind: 'platform-mismatch';
12
+ readonly expectedBaseUrl: string;
13
+ readonly actualBaseUrl: string;
14
+ };
15
+ /** The only platform-network fields allowed to cross from Host to Client. */
16
+ export interface BusinessNetworkSummary {
17
+ readonly id: string;
18
+ readonly displayName: string;
19
+ readonly description?: string;
20
+ /** A local DSH workspace previously chosen for this network, if any. */
21
+ readonly workspacePath?: string;
22
+ }
23
+ /** Immutable network identity that may cross the generated Host/Client boundary. */
24
+ export interface BusinessNetworkBinding {
25
+ readonly platformBaseUrl: string;
26
+ readonly knowledgeNetworkId: string;
27
+ readonly displayName: string;
28
+ }
29
+ /** Bounded, display-safe references for one completed OpenBKN-backed DSH turn. */
30
+ export interface ProvenanceHandle {
31
+ readonly schemaVersion: 1;
32
+ readonly interactionId: string;
33
+ readonly requestIds: readonly string[];
34
+ readonly traceIds: readonly string[];
35
+ readonly receiptIds: readonly string[];
36
+ readonly status: 'completed' | 'failed';
37
+ readonly partial: boolean;
38
+ }
39
+ /** Public, bounded DTO returned by the Host-only provenance reader. */
40
+ export interface ProvenanceOperationView {
41
+ readonly id: string;
42
+ readonly label: string;
43
+ readonly protocol?: string;
44
+ readonly status?: string;
45
+ readonly startedAt?: string;
46
+ readonly finishedAt?: string;
47
+ readonly requestId?: string;
48
+ readonly traceId?: string;
49
+ readonly receiptId?: string;
50
+ }
51
+ /** A display-safe element resolved by the Enterprise provenance service. */
52
+ export interface ProvenanceBusinessElement {
53
+ readonly kind: 'object' | 'relation' | 'action' | 'property' | 'logic' | 'metric';
54
+ readonly id: string;
55
+ readonly name: string;
56
+ readonly parentId?: string;
57
+ readonly field?: string;
58
+ }
59
+ /** An Enterprise resolver result. The Host copies these facts; it does not derive mappings. */
60
+ export interface ProvenanceBusinessOperation {
61
+ readonly id: string;
62
+ readonly attempt: number;
63
+ readonly toolName: string;
64
+ readonly knowledgeNetworkId?: string;
65
+ readonly status: 'resolved' | 'ambiguous' | 'unresolved' | 'not_evaluable';
66
+ readonly elements: readonly ProvenanceBusinessElement[];
67
+ readonly missingFacts: readonly string[];
68
+ }
69
+ export interface ProvenanceConversationContext {
70
+ readonly knowledgeNetworkId: string;
71
+ readonly sourceInteractionId: string;
72
+ readonly sourceOperationId: string;
73
+ }
74
+ export interface ProvenanceDerivedFact {
75
+ readonly rule: string;
76
+ readonly sourceOperationId: string;
77
+ readonly operationId: string;
78
+ readonly elementId: string;
79
+ }
80
+ /** A relationship disclosed by the Enterprise Interaction projection. */
81
+ export interface ProvenanceContextRelation {
82
+ readonly id: string;
83
+ readonly knowledgeNetworkId: string;
84
+ readonly name: string;
85
+ readonly sourceObjectId: string;
86
+ readonly targetObjectId: string;
87
+ }
88
+ /** Enterprise BFF state, deliberately separate from Community execution facts. */
89
+ export type ProvenanceBusinessView = {
90
+ readonly kind: 'unavailable';
91
+ } | {
92
+ readonly kind: 'ready';
93
+ readonly operations: readonly ProvenanceBusinessOperation[];
94
+ readonly conversationContext: readonly ProvenanceConversationContext[];
95
+ readonly derivedFacts: readonly ProvenanceDerivedFact[];
96
+ readonly contextRelations: readonly ProvenanceContextRelation[];
97
+ };
98
+ /** The current Enterprise Interaction projection does not define an evidence-chain DTO. */
99
+ export type ProvenanceEvidenceView = {
100
+ readonly kind: 'unavailable';
101
+ };
102
+ export interface ProvenanceView {
103
+ readonly interactionId: string;
104
+ readonly execution: {
105
+ readonly status?: string;
106
+ readonly operations: readonly ProvenanceOperationView[];
107
+ };
108
+ readonly business: ProvenanceBusinessView;
109
+ readonly evidence: ProvenanceEvidenceView;
110
+ }
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { Service, type Context } from '@deepseek-ai/cordis';
2
+ import { z } from 'zod';
3
+ declare module '@deepseek-ai/cordis' {
4
+ interface Context {
5
+ /** Durable, non-secret OpenBKN knowledge-network to DSH workspace mapping. */
6
+ openbknWorkspaceBindingRegistry: OpenBknWorkspaceBindingRegistry;
7
+ }
8
+ }
9
+ /** A local DSH workspace chosen for one OpenBKN business knowledge network. */
10
+ export declare const workspaceBindingRecord: z.ZodObject<{
11
+ platformBaseUrl: z.ZodString;
12
+ knowledgeNetworkId: z.ZodString;
13
+ displayName: z.ZodOptional<z.ZodString>;
14
+ workspacePath: z.ZodString;
15
+ updatedAt: z.ZodString;
16
+ }, z.core.$strip>;
17
+ export type WorkspaceBindingRecord = z.infer<typeof workspaceBindingRecord>;
18
+ /** Stable storage key: one configurable OpenBKN platform and network identity. */
19
+ export declare function workspaceBindingKey(platformBaseUrl: string, knowledgeNetworkId: string): string;
20
+ /**
21
+ * Host-owned durable index for the small, non-secret network-to-workspace
22
+ * association. It deliberately stores a path rather than a DSH workspace id:
23
+ * DSH resolves a registered workspace id from the path at each Client run.
24
+ */
25
+ export declare class OpenBknWorkspaceBindingRegistry extends Service {
26
+ static inject: string[];
27
+ private table?;
28
+ constructor(ctx: Context);
29
+ protected [Service.init](): Promise<void>;
30
+ get(platformBaseUrl: string, knowledgeNetworkId: string): WorkspaceBindingRecord | undefined;
31
+ /**
32
+ * Return the one network associated with a native DSH workspace. Ambiguous
33
+ * workspace associations deliberately produce no result so a session is
34
+ * never bound to a network by guesswork.
35
+ */
36
+ findUniqueByWorkspace(platformBaseUrl: string, workspacePath: string): WorkspaceBindingRecord | undefined;
37
+ put(input: Omit<WorkspaceBindingRecord, 'updatedAt'>): Promise<WorkspaceBindingRecord>;
38
+ private requireTable;
39
+ }
40
+ //# sourceMappingURL=workspace-binding-registry.d.ts.map
package/package.json ADDED
@@ -0,0 +1,131 @@
1
+ {
2
+ "name": "@openbkn/dsh-business-context",
3
+ "version": "0.1.5-rc.1",
4
+ "description": "OpenBKN business knowledge-network context for DeepSeek Harness",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/openbkn-ai/bkn-dsh.git"
10
+ },
11
+ "homepage": "https://github.com/openbkn-ai/bkn-dsh#readme",
12
+ "keywords": [
13
+ "deepseek-harness",
14
+ "dsh",
15
+ "dsh-plugin",
16
+ "openbkn",
17
+ "knowledge-network",
18
+ "business-context",
19
+ "provenance"
20
+ ],
21
+ "engines": {
22
+ "node": "^22.19.0 || >=24.0.0"
23
+ },
24
+ "main": "./lib/index.js",
25
+ "types": "./lib/types/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./lib/types/index.d.ts",
29
+ "default": "./lib/index.js"
30
+ },
31
+ "./types": {
32
+ "types": "./lib/types/types.d.ts"
33
+ },
34
+ "./client": {
35
+ "types": "./lib/types/client/index.d.ts",
36
+ "default": "./lib/client.js"
37
+ },
38
+ "./typert": {
39
+ "types": "./lib/typert.host.d.ts",
40
+ "default": "./lib/typert.host.js"
41
+ },
42
+ "./remote": {
43
+ "types": "./lib/typert.remote-client.d.ts",
44
+ "default": "./lib/typert.remote-client.js"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "files": [
49
+ "lib/index.js",
50
+ "lib/client.js",
51
+ "lib/types/**/*.d.ts",
52
+ "lib/typert.host.js",
53
+ "lib/typert.host.d.ts",
54
+ "lib/typert.remote-client.js",
55
+ "lib/typert.remote-client.d.ts",
56
+ "cordis.patch.yml",
57
+ "README.md",
58
+ "README.zh.md",
59
+ "LICENSE"
60
+ ],
61
+ "dsh": {
62
+ "bundle": {
63
+ "patch": "./cordis.patch.yml"
64
+ },
65
+ "client": {
66
+ "inject": [
67
+ "@deepseek-ai/dsh-api-remotes",
68
+ "@deepseek-ai/dsh-client-ui-slots"
69
+ ],
70
+ "platform": "web"
71
+ }
72
+ },
73
+ "dependencies": {
74
+ "@deepseek-ai/schemastery": "^3.18.2",
75
+ "zod": "^4.4.3"
76
+ },
77
+ "peerDependencies": {
78
+ "@deepseek-ai/cordis": "^4.0.2",
79
+ "@deepseek-ai/dsh-agent": "0.1.6-alpha.2",
80
+ "@deepseek-ai/dsh-credentials": "0.1.6-alpha.2",
81
+ "@deepseek-ai/dsh-mcp-client": "0.1.6-alpha.2",
82
+ "@deepseek-ai/dsh-session": "0.1.6-alpha.2",
83
+ "@deepseek-ai/dsh-storage": "0.1.6-alpha.2",
84
+ "@deepseek-ai/dsh-storage-domain": "0.1.6-alpha.2",
85
+ "@deepseek-ai/dsh-system-prompt": "0.1.6-alpha.2",
86
+ "@deepseek-ai/dsh-subprocess": "0.1.6-alpha.2",
87
+ "@deepseek-ai/dsh-tools": "0.1.6-alpha.2",
88
+ "@deepseek-ai/dsh-typert-protocol": "0.1.6-alpha.2",
89
+ "@deepseek-ai/dsh-util-values": "0.1.6-alpha.2"
90
+ },
91
+ "devDependencies": {
92
+ "@deepseek-ai/cordis": "^4.0.2",
93
+ "@deepseek-ai/dsh-agent": "0.1.6-alpha.2",
94
+ "@deepseek-ai/dsh-credentials": "0.1.6-alpha.2",
95
+ "@deepseek-ai/dsh-mcp-client": "0.1.6-alpha.2",
96
+ "@deepseek-ai/dsh-api-remotes": "0.1.6-alpha.2",
97
+ "@deepseek-ai/dsh-api-session-controller": "0.1.6-alpha.2",
98
+ "@deepseek-ai/dsh-client-ui-chat": "0.1.6-alpha.2",
99
+ "@deepseek-ai/dsh-client-ui-conversation": "0.1.6-alpha.2",
100
+ "@deepseek-ai/dsh-client-ui-layout": "0.1.6-alpha.2",
101
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.6-alpha.2",
102
+ "@deepseek-ai/dsh-client-ui-session": "0.1.6-alpha.2",
103
+ "@deepseek-ai/dsh-client-ui-sidebar": "0.1.6-alpha.2",
104
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.6-alpha.2",
105
+ "@deepseek-ai/dsh-client-ui-tool": "0.1.6-alpha.2",
106
+ "@deepseek-ai/dsh-client-ui-workspace": "0.1.6-alpha.2",
107
+ "@deepseek-ai/dsh-api-workspace-controller": "0.1.6-alpha.2",
108
+ "@deepseek-ai/dsh-session": "0.1.6-alpha.2",
109
+ "@deepseek-ai/dsh-system-prompt": "0.1.6-alpha.2",
110
+ "@deepseek-ai/dsh-subprocess": "0.1.6-alpha.2",
111
+ "@deepseek-ai/dsh-tools": "0.1.6-alpha.2",
112
+ "@deepseek-ai/dsh-typert-protocol": "0.1.6-alpha.2",
113
+ "@types/node": "^24.0.0",
114
+ "@deepseek-ai/dsh-util-values": "0.1.6-alpha.2",
115
+ "tsdown": "^0.22.2",
116
+ "@types/react": "~18.3.1",
117
+ "react": "^18.2.0",
118
+ "tsx": "^4.23.13",
119
+ "typescript": "^5.9.3"
120
+ },
121
+ "publishConfig": {
122
+ "access": "public"
123
+ },
124
+ "scripts": {
125
+ "build": "pnpm run build:host && pnpm run build:client",
126
+ "build:host": "tsc -p tsconfig.package.host.json && tsdown --env.DSH_BUILD_FACE host",
127
+ "build:client": "tsc -p tsconfig.package.client.json && tsdown --env.DSH_BUILD_FACE client",
128
+ "test": "pnpm run build && node --import tsx --test tests/*.test.mjs tests/*.test.ts",
129
+ "typecheck": "tsc -b ../.."
130
+ }
131
+ }