@clearlysh/beehaven 0.8.16
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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/__tests__/_cli-switch.js +105 -0
- package/dist/__tests__/agent-wrap-probe.js +136 -0
- package/dist/agent-attribution.js +192 -0
- package/dist/agent-identity-daemon.js +135 -0
- package/dist/agent-onboard.js +156 -0
- package/dist/agent-scope.js +79 -0
- package/dist/agent-sessions.js +370 -0
- package/dist/agent-state.js +482 -0
- package/dist/app-manifest.js +221 -0
- package/dist/app-signer.js +54 -0
- package/dist/app-signing.js +127 -0
- package/dist/audio-play.js +98 -0
- package/dist/avatar-protocol.js +25 -0
- package/dist/avatar-route.js +79 -0
- package/dist/bee/cloud-proxy.js +130 -0
- package/dist/blocked-actions.js +120 -0
- package/dist/build-channel.js +101 -0
- package/dist/buildings/daemon-workspace.js +475 -0
- package/dist/claude-bridge.js +310 -0
- package/dist/claude-credential-store.js +633 -0
- package/dist/clearly-sync.js +518 -0
- package/dist/clearly.js +616 -0
- package/dist/cli-state.js +334 -0
- package/dist/cli.js +6973 -0
- package/dist/commands/agent-skills.js +302 -0
- package/dist/commands/agent.js +1310 -0
- package/dist/commands/app.js +1123 -0
- package/dist/commands/auth.js +171 -0
- package/dist/commands/building-shell.js +392 -0
- package/dist/commands/canvas.js +932 -0
- package/dist/commands/claude.js +218 -0
- package/dist/commands/compliance.js +387 -0
- package/dist/commands/compose.js +507 -0
- package/dist/commands/composition.js +95 -0
- package/dist/commands/connect-session.js +409 -0
- package/dist/commands/conversations.js +160 -0
- package/dist/commands/costs.js +443 -0
- package/dist/commands/d1.js +253 -0
- package/dist/commands/daemon-cmd.js +162 -0
- package/dist/commands/deploy.js +164 -0
- package/dist/commands/design.js +617 -0
- package/dist/commands/dev-generate.js +125 -0
- package/dist/commands/dev.js +109 -0
- package/dist/commands/devices.js +135 -0
- package/dist/commands/explain-router.js +24 -0
- package/dist/commands/explain.js +882 -0
- package/dist/commands/explore.js +264 -0
- package/dist/commands/help.js +2418 -0
- package/dist/commands/init.js +408 -0
- package/dist/commands/install.js +129 -0
- package/dist/commands/library.js +229 -0
- package/dist/commands/marketplace.js +138 -0
- package/dist/commands/mcp-install.js +476 -0
- package/dist/commands/mention.js +257 -0
- package/dist/commands/omni.js +529 -0
- package/dist/commands/secrets.js +323 -0
- package/dist/commands/self-update.js +206 -0
- package/dist/commands/sheet.js +264 -0
- package/dist/commands/shell-output.js +309 -0
- package/dist/commands/shell.js +1048 -0
- package/dist/commands/shop.js +368 -0
- package/dist/commands/skills.js +311 -0
- package/dist/commands/slides.js +418 -0
- package/dist/commands/swarm.js +341 -0
- package/dist/commands/ticket.js +1301 -0
- package/dist/commands/tool.js +312 -0
- package/dist/commands/trash.js +106 -0
- package/dist/commands/treehouse.js +120 -0
- package/dist/commands/user.js +240 -0
- package/dist/commands/voice-tts.js +319 -0
- package/dist/commands/voice.js +166 -0
- package/dist/commands/watch-git.js +401 -0
- package/dist/commands/webhook.js +159 -0
- package/dist/commands/workspace.js +3354 -0
- package/dist/composition-repos.js +91 -0
- package/dist/daemon-avatar.js +130 -0
- package/dist/daemon-claude-code-auto-install.js +52 -0
- package/dist/daemon-client.js +363 -0
- package/dist/daemon-codex.js +349 -0
- package/dist/daemon-entry.js +101 -0
- package/dist/daemon-fetch-allowlist.js +194 -0
- package/dist/daemon-gemini.js +224 -0
- package/dist/daemon-mcp-clearly.js +353 -0
- package/dist/daemon-mcp-sandbox.js +127 -0
- package/dist/daemon-omni-company.js +338 -0
- package/dist/daemon-omni-hooks.js +375 -0
- package/dist/daemon-omni-identity.js +229 -0
- package/dist/daemon-omni-pipeline.js +251 -0
- package/dist/daemon-omni-policies.js +346 -0
- package/dist/daemon-omni-principal.js +580 -0
- package/dist/daemon-omni-tool-gate.js +116 -0
- package/dist/daemon-omni.js +1442 -0
- package/dist/daemon-path-transform.js +120 -0
- package/dist/daemon-write-sandbox.js +191 -0
- package/dist/daemon.js +4471 -0
- package/dist/dashboard.js +846 -0
- package/dist/dep-installer.js +286 -0
- package/dist/dev-mode.js +67 -0
- package/dist/doc-indexer.js +169 -0
- package/dist/e2e-crypto.js +94 -0
- package/dist/feature-flags.js +154 -0
- package/dist/file-browser.js +88 -0
- package/dist/first-party-hives.js +211 -0
- package/dist/folder-sync.js +226 -0
- package/dist/health.js +56 -0
- package/dist/ipc-auth.js +299 -0
- package/dist/ipc-client.js +495 -0
- package/dist/ipc-server.js +684 -0
- package/dist/keychain.js +224 -0
- package/dist/lib/admin-client.js +73 -0
- package/dist/lib/mobile-build-parser.js +156 -0
- package/dist/local-app-manager.js +660 -0
- package/dist/log-redaction.js +89 -0
- package/dist/logger.js +108 -0
- package/dist/manifest.js +143 -0
- package/dist/marketplace.js +793 -0
- package/dist/min-version-copy.js +51 -0
- package/dist/min-version.js +214 -0
- package/dist/public-surface.js +23 -0
- package/dist/relay-presets.js +89 -0
- package/dist/relay.js +2723 -0
- package/dist/repl.js +619 -0
- package/dist/setup-relay.js +363 -0
- package/dist/setup-service.js +536 -0
- package/dist/shared/bee-memory/index.js +6 -0
- package/dist/shared/bee-memory/types.js +682 -0
- package/dist/shared/claude-code/daemon-types.js +112 -0
- package/dist/shared/claude-code/index.js +2 -0
- package/dist/shared/claude-code/types.js +1 -0
- package/dist/shared/status/schema.js +133 -0
- package/dist/shell-session.js +198 -0
- package/dist/speak-lock.js +97 -0
- package/dist/spinner.js +57 -0
- package/dist/telemetry.js +166 -0
- package/dist/terminal/block-parser.js +207 -0
- package/dist/terminal/shell-integration.js +108 -0
- package/dist/transcript-tailer.js +215 -0
- package/dist/tts-qwen3.js +547 -0
- package/dist/types.js +4 -0
- package/dist/utm.js +38 -0
- package/dist/verb-surface.js +331 -0
- package/dist/version-utils.js +85 -0
- package/dist/watcher.js +207 -0
- package/package.json +88 -0
- package/python/qwen3_tts.py +230 -0
- package/scripts/stamp-build-channel.mjs +115 -0
- package/scripts/sync-installed.mjs +159 -0
- package/scripts/sync-skills.mjs +112 -0
- package/skills/README.md +24 -0
- package/skills/agent-doodle-space/SKILL.md +118 -0
- package/skills/agent-home/SKILL.md +98 -0
- package/skills/beehaven-cli/SKILL.md +144 -0
- package/skills/claude-shopper/README.md +90 -0
- package/skills/claude-shopper/SKILL.md +151 -0
- package/skills/clearly-agent/SKILL.md +183 -0
- package/skills/clearly-canvas/SKILL.md +222 -0
- package/skills/clearly-canvas/authoring.md +160 -0
- package/skills/clearly-canvas/communications.md +32 -0
- package/skills/clearly-canvas/composition-patterns.md +84 -0
- package/skills/clearly-canvas/example.mjs +78 -0
- package/skills/clearly-canvas/project-plans.md +156 -0
- package/skills/clearly-canvas/review.mjs +68 -0
- package/skills/clearly-workspace/SKILL.md +79 -0
- package/skills/clearly-workspace/survey.mjs +101 -0
- package/skills/codebase-map/SKILL.md +142 -0
- package/skills/design-craft/SKILL.md +300 -0
- package/skills/index.json +79 -0
- package/skills/layout-systems/SKILL.md +184 -0
- package/skills/pair-on-canvas/SKILL.md +92 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* canUseTool policy framework (#58) — foundation for #59-#63.
|
|
3
|
+
*
|
|
4
|
+
* The SDK exposes a `canUseTool: CanUseTool` option on `query()`. Every
|
|
5
|
+
* tool call passes through it before execution: the function returns
|
|
6
|
+
* `{behavior:'allow', updatedInput?}` or `{behavior:'deny', message?}`.
|
|
7
|
+
*
|
|
8
|
+
* Rather than write one giant function, we compose N small POLICIES
|
|
9
|
+
* (today: bash-cost-gate, per-tool-quota, tier-restrict).
|
|
10
|
+
* Each policy is independent + testable. The dispatcher chains them:
|
|
11
|
+
*
|
|
12
|
+
* 1. Run policies in registration order.
|
|
13
|
+
* 2. First DENY wins (short-circuits).
|
|
14
|
+
* 3. Otherwise, accumulate `updatedInput` from each policy that
|
|
15
|
+
* returned `{transformedInput}`. Later transforms see earlier
|
|
16
|
+
* results — order matters when policies compose.
|
|
17
|
+
* 4. If no policy denied, return `{behavior: 'allow', updatedInput}`
|
|
18
|
+
* with the accumulated transformations (or unchanged input).
|
|
19
|
+
*
|
|
20
|
+
* Why this design:
|
|
21
|
+
* - Policies are composable. canUseTool framework + tier policy +
|
|
22
|
+
* cost gate + path transform all stack without one fat function.
|
|
23
|
+
* - First-deny semantics match security intuition: a single veto
|
|
24
|
+
* blocks; transforms layer up.
|
|
25
|
+
* - Async-friendly. Policies can hit the DB, call out to the FAB
|
|
26
|
+
* for user approval (#59), etc.
|
|
27
|
+
*
|
|
28
|
+
* Per-session vs global:
|
|
29
|
+
* - Global registry (this file's `policies` Map) is for policies
|
|
30
|
+
* that apply to every session — e.g. cost gates, tier checks.
|
|
31
|
+
* - Per-session policies could be added later via OmniSession.config
|
|
32
|
+
* (e.g. when a composition is tagged "shopify-store", attach an
|
|
33
|
+
* extra policy that gates Bash commands hitting the store API).
|
|
34
|
+
*/
|
|
35
|
+
const policies = new Map();
|
|
36
|
+
/** Register a policy. Returns an unregister function. Idempotent on
|
|
37
|
+
* id — re-registering replaces. */
|
|
38
|
+
export function registerToolGatePolicy(policy) {
|
|
39
|
+
policies.set(policy.id, policy);
|
|
40
|
+
return () => { policies.delete(policy.id); };
|
|
41
|
+
}
|
|
42
|
+
/** For diagnostics / `omni:sessions` UI later. */
|
|
43
|
+
export function listToolGatePolicies() {
|
|
44
|
+
return [...policies.values()]
|
|
45
|
+
.map((p) => ({ id: p.id, priority: p.priority ?? 100 }))
|
|
46
|
+
.sort((a, b) => a.priority - b.priority);
|
|
47
|
+
}
|
|
48
|
+
/** Compose a `CanUseTool` callback bound to a specific session. The
|
|
49
|
+
* returned function is what we pass to the SDK's `canUseTool` option.
|
|
50
|
+
* Each turn calls this once per tool use; we walk the policy chain
|
|
51
|
+
* and produce a PermissionResult.
|
|
52
|
+
*
|
|
53
|
+
* The signature here matches the SDK's CanUseTool type exactly so
|
|
54
|
+
* it can be passed directly into `buildSdkOptions().canUseTool`.
|
|
55
|
+
*/
|
|
56
|
+
export function buildToolGate(sessionCtx) {
|
|
57
|
+
return async (toolName, input, options) => {
|
|
58
|
+
const sorted = [...policies.values()].sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
|
|
59
|
+
let workingInput = input;
|
|
60
|
+
for (const policy of sorted) {
|
|
61
|
+
if (policy.appliesTo && !policy.appliesTo(toolName))
|
|
62
|
+
continue;
|
|
63
|
+
let decision;
|
|
64
|
+
try {
|
|
65
|
+
decision = await policy.decide(toolName, workingInput, {
|
|
66
|
+
sessionId: sessionCtx.sessionId,
|
|
67
|
+
userId: sessionCtx.userId,
|
|
68
|
+
signal: options.signal,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
// FAIL CLOSED. This used to swallow the error and continue
|
|
73
|
+
// ("better to let through than to block on a buggy policy"),
|
|
74
|
+
// which inverted the gate: anything that could make a deny
|
|
75
|
+
// policy throw — an aborted signal, a DB blip, a timed-out FAB
|
|
76
|
+
// approval round-trip — turned a denial into an ALLOW, silently.
|
|
77
|
+
// The policies this framework is built for are explicitly async
|
|
78
|
+
// and I/O-bound (the header advertises DB hits and user-approval
|
|
79
|
+
// prompts), so throwing is a normal failure mode, not an exotic
|
|
80
|
+
// one. A policy that genuinely shouldn't block sets failOpen.
|
|
81
|
+
const msg = err?.message ?? String(err);
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.warn(`[omni.gate] policy '${policy.id}' threw: ${msg}`);
|
|
84
|
+
if (policy.failOpen) {
|
|
85
|
+
decision = null;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return {
|
|
89
|
+
behavior: 'deny',
|
|
90
|
+
message: `Blocked '${toolName}': the '${policy.id}' safety check could not complete ` +
|
|
91
|
+
`(${msg}). This is a fail-closed refusal, not a policy decision — retry, ` +
|
|
92
|
+
`and if it persists the check itself is broken.`,
|
|
93
|
+
interrupt: false,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!decision)
|
|
98
|
+
continue;
|
|
99
|
+
if ('deny' in decision) {
|
|
100
|
+
return {
|
|
101
|
+
behavior: 'deny',
|
|
102
|
+
message: decision.message,
|
|
103
|
+
interrupt: decision.interrupt ?? false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if ('allow' in decision && decision.updatedInput) {
|
|
107
|
+
workingInput = decision.updatedInput;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// No policy denied. Allow with whatever accumulated transforms.
|
|
111
|
+
return {
|
|
112
|
+
behavior: 'allow',
|
|
113
|
+
updatedInput: workingInput,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}
|