@behavior-os/sdk 0.0.0-stage → 2.2.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.
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/package.json +25 -3
- package/src/index.ts +146 -0
- package/tests/sdk-integration.test.ts +80 -0
- package/tests/sdk.test.ts +159 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +16 -0
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @behavior-os/sdk
|
|
2
|
+
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(publish): ship installable manifests
|
|
8
|
+
|
|
9
|
+
The 2.2.0 tarballs were produced with `npm publish` from the workspace, so the
|
|
10
|
+
published manifests still contained `workspace:*` dependency ranges and npm
|
|
11
|
+
rejects the install with `EUNSUPPORTEDPROTOCOL: Unsupported URL Type
|
|
12
|
+
"workspace:"`. Republishing through `pnpm changeset publish` rewrites those
|
|
13
|
+
ranges to the real version.
|
|
14
|
+
|
|
15
|
+
`pnpm verify:publish` now packs every publishable package and fails when a
|
|
16
|
+
packed manifest still carries a `workspace:` range or declares a `bin`/`main`
|
|
17
|
+
target that is missing from the tarball. The release and tag workflows run it
|
|
18
|
+
before publishing, and it is part of `pnpm verify:all`.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @behavior-os/schemas@2.2.1
|
|
21
|
+
- @behavior-os/core@2.2.1
|
|
22
|
+
|
|
23
|
+
## 2.2.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 885f016: fix: unify MCP protocol advancement steps with plugin host
|
|
28
|
+
|
|
29
|
+
The MCP server now advances `bos_list_dna` (step 2) and `bos_get_state` (step 3)
|
|
30
|
+
protocol steps, matching the plugin host's behavior. Previously, MCP callers
|
|
31
|
+
stalled at step 1 after `bos_select_dna` because only `bos_start_mission` advanced
|
|
32
|
+
the protocol in MCP.
|
|
33
|
+
|
|
34
|
+
Also completes the SDK lifecycle gap (added `completeMission`, `failMission`,
|
|
35
|
+
`cancelMission`, `listMissions`, `requiredChecks`/`verificationMode` on
|
|
36
|
+
`createMission`) and fixes the CLI `autonomous` command to close dry-run missions.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [885f016]
|
|
41
|
+
- @behavior-os/core@2.2.0
|
|
42
|
+
- @behavior-os/schemas@2.2.0
|
|
43
|
+
|
|
44
|
+
## 2.1.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- c95526d: Transparent execution on Windows and an asynchronous audit engine:
|
|
49
|
+
|
|
50
|
+
- `AuditEngine.run/runReal/runStageReal` are now async so hosts can await them
|
|
51
|
+
(MCP server, plugin, SDK, CLI and examples all updated). Callers that used
|
|
52
|
+
the result synchronously must await — hence the minor bumps.
|
|
53
|
+
- Every process spawn in the governed paths sets `windowsHide: true` and uses
|
|
54
|
+
`shell: true` with a single-string command (Node DEP0190-safe), so governed
|
|
55
|
+
execution no longer flashes CMD windows; `pnpm` invocations get the shell
|
|
56
|
+
treatment required by Windows `.cmd` shims.
|
|
57
|
+
- Audit stages run sequentially under contention (parallel tsc produced false
|
|
58
|
+
failures), and the plugin tool handlers await their audit calls, too.
|
|
59
|
+
- New UX gate: `pnpm verify:windows` runs `scripts/win-window-probe.mjs`
|
|
60
|
+
against the spawn topology that leaked windows before and fails (exit 1)
|
|
61
|
+
when any new visible console window appears, reporting pid/name
|
|
62
|
+
attribution. It is part of `verify:all` and documented in the AGENTS.md
|
|
63
|
+
verification ladder.
|
|
64
|
+
- Examples are covered from the root ladder and `verify:opencode` batches
|
|
65
|
+
`git check-ignore` into a single hidden spawn.
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [2fe6d18]
|
|
70
|
+
- Updated dependencies [2fe6d18]
|
|
71
|
+
- Updated dependencies [2fe6d18]
|
|
72
|
+
- Updated dependencies [c95526d]
|
|
73
|
+
- Updated dependencies [c95526d]
|
|
74
|
+
- Updated dependencies [c95526d]
|
|
75
|
+
- Updated dependencies [2fe6d18]
|
|
76
|
+
- @behavior-os/core@2.1.0
|
|
77
|
+
- @behavior-os/schemas@2.0.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ilvan Joaquim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type BehaviorOSConfig, type MissionTransitionResult } from '@behavior-os/core';
|
|
2
|
+
import type { AuditReport, DNA, GovernanceDecision, LearningEvent, Mission, MissionPriority, MissionStatus, MissionType } from '@behavior-os/schemas';
|
|
3
|
+
export type { BehaviorOSConfig, MissionTransitionResult } from '@behavior-os/core';
|
|
4
|
+
export { BehaviorOS } from '@behavior-os/core';
|
|
5
|
+
export type { Agent, AuditReport, DNA, GovernanceDecision, LearningEvent, Mission, MissionPriority, MissionStatus, MissionType, } from '@behavior-os/schemas';
|
|
6
|
+
export declare class BehaviorOSSDK {
|
|
7
|
+
private bos;
|
|
8
|
+
constructor(config?: BehaviorOSConfig);
|
|
9
|
+
loadDNA(dna: DNA): Promise<void>;
|
|
10
|
+
getDNA(): DNA | null;
|
|
11
|
+
evaluateGovernance(action: string, context: {
|
|
12
|
+
agent: string;
|
|
13
|
+
scope?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}): GovernanceDecision;
|
|
16
|
+
checkQuality(metrics: Record<string, number>): {
|
|
17
|
+
passed: boolean;
|
|
18
|
+
details: unknown;
|
|
19
|
+
};
|
|
20
|
+
runAudit(options: {
|
|
21
|
+
missionId: string;
|
|
22
|
+
agentId?: string;
|
|
23
|
+
stages?: string[];
|
|
24
|
+
simulate?: boolean;
|
|
25
|
+
}): Promise<AuditReport>;
|
|
26
|
+
createMission(options: {
|
|
27
|
+
title: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
type: string;
|
|
30
|
+
priority: string;
|
|
31
|
+
dnaPattern?: string;
|
|
32
|
+
createdBy?: string;
|
|
33
|
+
tags?: string[];
|
|
34
|
+
/** Gates that must each have passing evidence before completion. */
|
|
35
|
+
requiredChecks?: string[];
|
|
36
|
+
/** `executed` requires real, provenance-stamped evidence for every gate. */
|
|
37
|
+
verificationMode?: 'any' | 'executed';
|
|
38
|
+
}): Mission;
|
|
39
|
+
startMission(missionId: string): Mission | null;
|
|
40
|
+
completeMission(missionId: string, options?: {
|
|
41
|
+
expectedVersion?: number;
|
|
42
|
+
actor?: string;
|
|
43
|
+
evidence?: Array<{
|
|
44
|
+
gate: string;
|
|
45
|
+
status: 'passed' | 'failed' | 'skipped';
|
|
46
|
+
source: string;
|
|
47
|
+
detail?: string;
|
|
48
|
+
simulated?: boolean;
|
|
49
|
+
provenance?: 'executed' | 'reported' | 'simulated';
|
|
50
|
+
executionId?: string;
|
|
51
|
+
}>;
|
|
52
|
+
}): Mission | null;
|
|
53
|
+
failMission(missionId: string, reason?: string): Mission | null;
|
|
54
|
+
cancelMission(missionId: string): MissionTransitionResult;
|
|
55
|
+
listMissions(limit?: number, filters?: {
|
|
56
|
+
status?: MissionStatus;
|
|
57
|
+
type?: MissionType;
|
|
58
|
+
priority?: MissionPriority;
|
|
59
|
+
}): Mission[];
|
|
60
|
+
recordLearning(options: {
|
|
61
|
+
type: string;
|
|
62
|
+
source: string;
|
|
63
|
+
content: string;
|
|
64
|
+
impact: string;
|
|
65
|
+
relatedMission?: string;
|
|
66
|
+
}): LearningEvent;
|
|
67
|
+
getInsights(limit?: number): LearningEvent[];
|
|
68
|
+
getStatus(): {
|
|
69
|
+
engine: boolean;
|
|
70
|
+
dna: string | null;
|
|
71
|
+
missions: number;
|
|
72
|
+
agents: number;
|
|
73
|
+
state: import("@behavior-os/schemas").AgentState;
|
|
74
|
+
config: {
|
|
75
|
+
governance: "strict" | "moderate" | "lenient";
|
|
76
|
+
qualityEnabled: boolean;
|
|
77
|
+
auditEnabled: boolean;
|
|
78
|
+
learningEnabled: boolean;
|
|
79
|
+
};
|
|
80
|
+
store: boolean | null;
|
|
81
|
+
storeError: string | null;
|
|
82
|
+
};
|
|
83
|
+
getState(): {
|
|
84
|
+
currentStep: number;
|
|
85
|
+
selectedDna: string | null;
|
|
86
|
+
agentId: string | null;
|
|
87
|
+
persona: string | null;
|
|
88
|
+
activeMission: string | null;
|
|
89
|
+
stepHistory: Record<string, unknown>[];
|
|
90
|
+
createdAt: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export default BehaviorOSSDK;
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,KAAK,EACV,WAAW,EACX,GAAG,EACH,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EACV,KAAK,EACL,WAAW,EACX,GAAG,EACH,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,GAAE,gBAAqB;IAKnC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,MAAM,IAAI,GAAG,GAAG,IAAI;IAKpB,kBAAkB,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACjE,kBAAkB;IAKrB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;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AG,IAAI;IAIjB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAI/D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB;IAIzD,YAAY,CACV,KAAK,SAAK,EACV,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,aAAa,CAAC;QAAC,IAAI,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,eAAe,CAAA;KAAO,GACvF,OAAO,EAAE;IAKZ,cAAc,CAAC,OAAO,EAAE;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,aAAa;IAIjB,WAAW,CAAC,KAAK,SAAK,GAAG,aAAa,EAAE;IAKxC,SAAS;;;;;;;;;;;;;;;IAIT,QAAQ;;;;;;;;;;CAGT;AAED,eAAe,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BehaviorOS } from '@behavior-os/core';
|
|
2
|
+
export { BehaviorOS } from '@behavior-os/core';
|
|
3
|
+
export class BehaviorOSSDK {
|
|
4
|
+
bos;
|
|
5
|
+
constructor(config = {}) {
|
|
6
|
+
this.bos = new BehaviorOS(config);
|
|
7
|
+
}
|
|
8
|
+
// DNA Management
|
|
9
|
+
async loadDNA(dna) {
|
|
10
|
+
await this.bos.loadDNA(dna);
|
|
11
|
+
}
|
|
12
|
+
getDNA() {
|
|
13
|
+
return this.bos.getDNA();
|
|
14
|
+
}
|
|
15
|
+
// Governance
|
|
16
|
+
evaluateGovernance(action, context) {
|
|
17
|
+
return this.bos.evaluateGovernance(action, context);
|
|
18
|
+
}
|
|
19
|
+
// Quality
|
|
20
|
+
checkQuality(metrics) {
|
|
21
|
+
return this.bos.checkQuality(metrics);
|
|
22
|
+
}
|
|
23
|
+
// Audit
|
|
24
|
+
async runAudit(options) {
|
|
25
|
+
return this.bos.runAudit(options);
|
|
26
|
+
}
|
|
27
|
+
// Missions
|
|
28
|
+
createMission(options) {
|
|
29
|
+
return this.bos.createMission(options);
|
|
30
|
+
}
|
|
31
|
+
startMission(missionId) {
|
|
32
|
+
return this.bos.startMission(missionId);
|
|
33
|
+
}
|
|
34
|
+
completeMission(missionId, options = {}) {
|
|
35
|
+
return this.bos.completeMission(missionId, options);
|
|
36
|
+
}
|
|
37
|
+
failMission(missionId, reason) {
|
|
38
|
+
return this.bos.failMission(missionId, reason);
|
|
39
|
+
}
|
|
40
|
+
cancelMission(missionId) {
|
|
41
|
+
return this.bos.cancelMission(missionId);
|
|
42
|
+
}
|
|
43
|
+
listMissions(limit = 50, filters = {}) {
|
|
44
|
+
return this.bos.listMissions(limit, filters);
|
|
45
|
+
}
|
|
46
|
+
// Learning
|
|
47
|
+
recordLearning(options) {
|
|
48
|
+
return this.bos.recordLearning(options);
|
|
49
|
+
}
|
|
50
|
+
getInsights(limit = 10) {
|
|
51
|
+
return this.bos.getInsights(limit);
|
|
52
|
+
}
|
|
53
|
+
// Status
|
|
54
|
+
getStatus() {
|
|
55
|
+
return this.bos.getStatus();
|
|
56
|
+
}
|
|
57
|
+
getState() {
|
|
58
|
+
return this.bos.getState();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export default BehaviorOSSDK;
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuD,MAAM,mBAAmB,CAAC;AAapG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,MAAM,OAAO,aAAa;IAChB,GAAG,CAAa;IAExB,YAAY,SAA2B,EAAE;QACvC,IAAI,CAAC,GAAG,GAAG,I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AAK,GAAG,EAAE,EACV,UAAsF,EAAE;QAExF,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,WAAW;IACX,cAAc,CAAC,OAMd;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,KAAK,GAAG,EAAE;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,SAAS;IACT,SAAS;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;IAC9B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavior-os/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.2.1",
|
|
4
|
+
"description": "High-level TypeScript SDK for Behavior-OS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@behavior-os/core": "2.2.1",
|
|
16
|
+
"@behavior-os/schemas": "2.2.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "~5.9.3",
|
|
20
|
+
"vitest": "^4.1.11"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
26
|
+
"clean": "node ../../scripts/clean.mjs"
|
|
27
|
+
}
|
|
6
28
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { BehaviorOS, type BehaviorOSConfig, type MissionTransitionResult } from '@behavior-os/core';
|
|
2
|
+
import type {
|
|
3
|
+
AuditReport,
|
|
4
|
+
DNA,
|
|
5
|
+
GovernanceDecision,
|
|
6
|
+
LearningEvent,
|
|
7
|
+
Mission,
|
|
8
|
+
MissionPriority,
|
|
9
|
+
MissionStatus,
|
|
10
|
+
MissionType,
|
|
11
|
+
} from '@behavior-os/schemas';
|
|
12
|
+
|
|
13
|
+
export type { BehaviorOSConfig, MissionTransitionResult } from '@behavior-os/core';
|
|
14
|
+
export { BehaviorOS } from '@behavior-os/core';
|
|
15
|
+
export type {
|
|
16
|
+
Agent,
|
|
17
|
+
AuditReport,
|
|
18
|
+
DNA,
|
|
19
|
+
GovernanceDecision,
|
|
20
|
+
LearningEvent,
|
|
21
|
+
Mission,
|
|
22
|
+
MissionPriority,
|
|
23
|
+
MissionStatus,
|
|
24
|
+
MissionType,
|
|
25
|
+
} from '@behavior-os/schemas';
|
|
26
|
+
|
|
27
|
+
export class BehaviorOSSDK {
|
|
28
|
+
private bos: BehaviorOS;
|
|
29
|
+
|
|
30
|
+
constructor(config: BehaviorOSConfig = {}) {
|
|
31
|
+
this.bos = new BehaviorOS(config);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// DNA Management
|
|
35
|
+
async loadDNA(dna: DNA): Promise<void> {
|
|
36
|
+
await this.bos.loadDNA(dna);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getDNA(): DNA | null {
|
|
40
|
+
return this.bos.getDNA();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Governance
|
|
44
|
+
evaluateGovernance(
|
|
45
|
+
action: string,
|
|
46
|
+
context: { agent: string; scope?: string; [key: string]: unknown },
|
|
47
|
+
): GovernanceDecision {
|
|
48
|
+
return this.bos.evaluateGovernance(action, context);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Quality
|
|
52
|
+
checkQuality(metrics: Record<string, number>): { passed: boolean; details: unknown } {
|
|
53
|
+
return this.bos.checkQuality(metrics);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Audit
|
|
57
|
+
async runAudit(options: {
|
|
58
|
+
missionId: string;
|
|
59
|
+
agentId?: string;
|
|
60
|
+
stages?: string[];
|
|
61
|
+
simulate?: boolean;
|
|
62
|
+
}): Promise<AuditReport> {
|
|
63
|
+
return this.bos.runAudit(options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Missions
|
|
67
|
+
createMission(options: {
|
|
68
|
+
title: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
type: string;
|
|
71
|
+
priority: string;
|
|
72
|
+
dnaPattern?: string;
|
|
73
|
+
createdBy?: string;
|
|
74
|
+
tags?: string[];
|
|
75
|
+
/** Gates that must each have passing evidence before completion. */
|
|
76
|
+
requiredChecks?: string[];
|
|
77
|
+
/** `executed` requires real, provenance-stamped evidence for every gate. */
|
|
78
|
+
verificationMode?: 'any' | 'executed';
|
|
79
|
+
}): Mission {
|
|
80
|
+
return this.bos.createMission(options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
startMission(missionId: string): Mission | null {
|
|
84
|
+
return this.bos.startMission(missionId);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
completeMission(
|
|
88
|
+
missionId: string,
|
|
89
|
+
options: {
|
|
90
|
+
expectedVersion?: number;
|
|
91
|
+
actor?: string;
|
|
92
|
+
evidence?: Array<{
|
|
93
|
+
gate: string;
|
|
94
|
+
status: 'passed' | 'failed' | 'skipped';
|
|
95
|
+
source: string;
|
|
96
|
+
detail?: string;
|
|
97
|
+
simulated?: boolean;
|
|
98
|
+
provenance?: 'executed' | 'reported' | 'simulated';
|
|
99
|
+
executionId?: string;
|
|
100
|
+
}>;
|
|
101
|
+
} = {},
|
|
102
|
+
): Mission | null {
|
|
103
|
+
return this.bos.completeMission(missionId, options);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
failMission(missionId: string, reason?: string): Mission | null {
|
|
107
|
+
return this.bos.failMission(missionId, reason);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
cancelMission(missionId: string): MissionTransitionResult {
|
|
111
|
+
return this.bos.cancelMission(missionId);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
listMissions(
|
|
115
|
+
limit = 50,
|
|
116
|
+
filters: { status?: MissionStatus; type?: MissionType; priority?: MissionPriority } = {},
|
|
117
|
+
): Mission[] {
|
|
118
|
+
return this.bos.listMissions(limit, filters);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Learning
|
|
122
|
+
recordLearning(options: {
|
|
123
|
+
type: string;
|
|
124
|
+
source: string;
|
|
125
|
+
content: string;
|
|
126
|
+
impact: string;
|
|
127
|
+
relatedMission?: string;
|
|
128
|
+
}): LearningEvent {
|
|
129
|
+
return this.bos.recordLearning(options);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getInsights(limit = 10): LearningEvent[] {
|
|
133
|
+
return this.bos.getInsights(limit);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Status
|
|
137
|
+
getStatus() {
|
|
138
|
+
return this.bos.getStatus();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getState() {
|
|
142
|
+
return this.bos.getState();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default BehaviorOSSDK;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DNA } from '@behavior-os/schemas';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import { BehaviorOSSDK } from '../src/index.js';
|
|
4
|
+
|
|
5
|
+
describe('BehaviorOSSDK Integration', () => {
|
|
6
|
+
let sdk: BehaviorOSSDK;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
sdk = new BehaviorOSSDK();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should create and manage missions through SDK', () => {
|
|
13
|
+
const mission = sdk.createMission({
|
|
14
|
+
title: 'SDK Test Mission',
|
|
15
|
+
type: 'feature',
|
|
16
|
+
priority: 'high',
|
|
17
|
+
dnaPattern: 'enterprise-governance',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(mission.id).toBeDefined();
|
|
21
|
+
expect(mission.title).toBe('SDK Test Mission');
|
|
22
|
+
|
|
23
|
+
const started = sdk.startMission(mission.id);
|
|
24
|
+
expect(started?.status).toBe('active');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should evaluate governance through SDK', async () => {
|
|
28
|
+
const dna: DNA = {
|
|
29
|
+
name: 'Test DNA',
|
|
30
|
+
version: '1.0.0',
|
|
31
|
+
description: 'Test',
|
|
32
|
+
personas: [],
|
|
33
|
+
governance: [],
|
|
34
|
+
quality: [],
|
|
35
|
+
};
|
|
36
|
+
await sdk.loadDNA(dna);
|
|
37
|
+
|
|
38
|
+
const decision = sdk.evaluateGovernance('test-action', {
|
|
39
|
+
agent: 'sdk-agent',
|
|
40
|
+
context: {},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(decision.action).toBe('test-action');
|
|
44
|
+
expect(decision.verdict).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should record and retrieve learning through SDK', () => {
|
|
48
|
+
sdk.recordLearning({
|
|
49
|
+
type: 'insight',
|
|
50
|
+
source: 'sdk-test',
|
|
51
|
+
content: 'SDK learning test',
|
|
52
|
+
impact: 'high',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const insights = sdk.getInsights(10);
|
|
56
|
+
expect(insights.length).toBeGreaterThan(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should get status and state through SDK', () => {
|
|
60
|
+
const status = sdk.getStatus();
|
|
61
|
+
expect(status.engine).toBe(true);
|
|
62
|
+
|
|
63
|
+
const state = sdk.getState();
|
|
64
|
+
expect(state).toBeDefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should load DNA through SDK', async () => {
|
|
68
|
+
const dna: DNA = {
|
|
69
|
+
name: 'SDK DNA',
|
|
70
|
+
version: '1.0.0',
|
|
71
|
+
description: 'SDK test DNA',
|
|
72
|
+
personas: [],
|
|
73
|
+
governance: [],
|
|
74
|
+
quality: [],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
await sdk.loadDNA(dna);
|
|
78
|
+
expect(sdk.getDNA()?.name).toBe('SDK DNA');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { DNA } from '@behavior-os/schemas';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import { BehaviorOSSDK } from '../src/index.js';
|
|
4
|
+
|
|
5
|
+
describe('BehaviorOSSDK', () => {
|
|
6
|
+
let sdk: BehaviorOSSDK;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
sdk = new BehaviorOSSDK();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should initialize with default config', () => {
|
|
13
|
+
const status = sdk.getStatus();
|
|
14
|
+
expect(status.engine).toBe(true);
|
|
15
|
+
expect(status.dna).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should load DNA pattern', async () => {
|
|
19
|
+
const dna: DNA = {
|
|
20
|
+
name: 'Test DNA',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
description: 'Test',
|
|
23
|
+
personas: [],
|
|
24
|
+
governance: [],
|
|
25
|
+
quality: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
await sdk.loadDNA(dna);
|
|
29
|
+
expect(sdk.getDNA()).toEqual(dna);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should evaluate governance with DNA loaded', async () => {
|
|
33
|
+
const dna: DNA = {
|
|
34
|
+
name: 'Test DNA',
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
description: 'Test',
|
|
37
|
+
personas: [],
|
|
38
|
+
governance: [],
|
|
39
|
+
quality: [],
|
|
40
|
+
};
|
|
41
|
+
await sdk.loadDNA(dna);
|
|
42
|
+
|
|
43
|
+
const decision = sdk.evaluateGovernance('test-action', {
|
|
44
|
+
agent: 'agent-1',
|
|
45
|
+
context: {},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(decision.action).toBe('test-action');
|
|
49
|
+
expect(decision.verdict).toBeDefined();
|
|
50
|
+
expect(decision.timestamp).toBeDefined();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create mission', () => {
|
|
54
|
+
const mission = sdk.createMission({
|
|
55
|
+
title: 'Test Mission',
|
|
56
|
+
type: 'feature',
|
|
57
|
+
priority: 'high',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(mission.id).toBeDefined();
|
|
61
|
+
expect(mission.title).toBe('Test Mission');
|
|
62
|
+
expect(mission.status).toBe('pending');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should record learning', () => {
|
|
66
|
+
const event = sdk.recordLearning({
|
|
67
|
+
type: 'insight',
|
|
68
|
+
source: 'test',
|
|
69
|
+
content: 'Test insight',
|
|
70
|
+
impact: 'medium',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(event.id).toBeDefined();
|
|
74
|
+
expect(event.content).toBe('Test insight');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should get insights after recording', () => {
|
|
78
|
+
sdk.recordLearning({
|
|
79
|
+
type: 'insight',
|
|
80
|
+
source: 'test',
|
|
81
|
+
content: 'Test insight',
|
|
82
|
+
impact: 'high',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const insights = sdk.getInsights(10);
|
|
86
|
+
expect(insights.length).toBeGreaterThan(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should create mission with requiredChecks', () => {
|
|
90
|
+
const mission = sdk.createMission({
|
|
91
|
+
title: 'Test Mission',
|
|
92
|
+
type: 'feature',
|
|
93
|
+
priority: 'high',
|
|
94
|
+
requiredChecks: ['governance', 'audit'],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expect(mission.id).toBeDefined();
|
|
98
|
+
expect(mission.title).toBe('Test Mission');
|
|
99
|
+
expect(mission.status).toBe('pending');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should start, complete, and cancel missions via SDK', () => {
|
|
103
|
+
const mission = sdk.createMission({
|
|
104
|
+
title: 'Lifecycle Mission',
|
|
105
|
+
type: 'feature',
|
|
106
|
+
priority: 'high',
|
|
107
|
+
requiredChecks: ['governance'],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Start -> active
|
|
111
|
+
const started = sdk.startMission(mission.id);
|
|
112
|
+
expect(started).not.toBeNull();
|
|
113
|
+
expect(started?.status).toBe('active');
|
|
114
|
+
|
|
115
|
+
// Complete with evidence
|
|
116
|
+
const completed = sdk.completeMission(mission.id, {
|
|
117
|
+
evidence: [{ gate: 'governance', status: 'passed', source: 'test' }],
|
|
118
|
+
});
|
|
119
|
+
expect(completed).not.toBeNull();
|
|
120
|
+
expect(completed?.status).toBe('completed');
|
|
121
|
+
|
|
122
|
+
// Cancel a new mission
|
|
123
|
+
const cancelTarget = sdk.createMission({
|
|
124
|
+
title: 'Cancel Mission',
|
|
125
|
+
type: 'refactor',
|
|
126
|
+
priority: 'medium',
|
|
127
|
+
});
|
|
128
|
+
const result = sdk.cancelMission(cancelTarget.id);
|
|
129
|
+
expect(result.ok).toBe(true);
|
|
130
|
+
expect(result.mission?.status).toBe('cancelled');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should list missions with filters', () => {
|
|
134
|
+
sdk.createMission({ title: 'Feature A', type: 'feature', priority: 'high' });
|
|
135
|
+
sdk.createMission({ title: 'Bug B', type: 'bugfix', priority: 'low' });
|
|
136
|
+
|
|
137
|
+
const all = sdk.listMissions();
|
|
138
|
+
expect(all.length).toBeGreaterThanOrEqual(2);
|
|
139
|
+
|
|
140
|
+
const features = sdk.listMissions(50, { type: 'feature' });
|
|
141
|
+
expect(features.every((m) => m.type === 'feature')).toBe(true);
|
|
142
|
+
|
|
143
|
+
const highPriority = sdk.listMissions(50, { priority: 'high' });
|
|
144
|
+
expect(highPriority.every((m) => m.priority === 'high')).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should fail a mission with reason', () => {
|
|
148
|
+
const mission = sdk.createMission({
|
|
149
|
+
title: 'Fail Mission',
|
|
150
|
+
type: 'incident',
|
|
151
|
+
priority: 'critical',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
sdk.startMission(mission.id);
|
|
155
|
+
const failed = sdk.failMission(mission.id, 'Test failure reason');
|
|
156
|
+
expect(failed).not.toBeNull();
|
|
157
|
+
expect(failed?.status).toBe('failed');
|
|
158
|
+
});
|
|
159
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": true,
|
|
5
|
+
"declaration": false,
|
|
6
|
+
"declarationMap": false,
|
|
7
|
+
"types": ["node"]
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*", "tests/**/*", "vitest.config.ts"],
|
|
10
|
+
"exclude": ["node_modules", "dist"]
|
|
11
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: 'node',
|
|
8
|
+
include: ['tests/**/*.test.ts'],
|
|
9
|
+
},
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@behavior-os/core': path.resolve(__dirname, '../core/src/index.ts'),
|
|
13
|
+
'@behavior-os/schemas': path.resolve(__dirname, '../schemas/src/index.ts'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
package/README.md
DELETED