@makinbakin/sdk 0.0.0-bootstrap.0 → 0.0.1-rc.10

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 (40) hide show
  1. package/README.md +21 -10
  2. package/_internal/app/components/agent-select.d.ts +7 -2
  3. package/_internal/app/components/integrated-brainstorm/activity.d.ts +23 -0
  4. package/_internal/app/components/integrated-brainstorm/index.d.ts +6 -1
  5. package/_internal/app/components/integrated-brainstorm/session.d.ts +16 -0
  6. package/_internal/app/components/integrated-brainstorm/sse.d.ts +8 -0
  7. package/_internal/app/components/integrated-brainstorm/types.d.ts +7 -5
  8. package/_internal/app/components/ui/badge.d.ts +1 -1
  9. package/_internal/app/components/ui/button.d.ts +1 -1
  10. package/_internal/app/hooks/use-content-store.d.ts +2 -0
  11. package/_internal/app/hooks/use-nav-badge.d.ts +13 -0
  12. package/_internal/app/types/index.d.ts +0 -42
  13. package/_internal/core/adapters/runtime/concepts.d.ts +119 -2
  14. package/_internal/core/adapters/runtime/index.d.ts +1 -1
  15. package/_internal/core/constants.d.ts +15 -0
  16. package/_internal/core/content-dir.d.ts +42 -0
  17. package/_internal/core/generated-version.d.ts +1 -0
  18. package/_internal/core/logger.d.ts +8 -0
  19. package/_internal/core/plugin-types.d.ts +168 -37
  20. package/_internal/core/routing/index.d.ts +1 -1
  21. package/_internal/plugins/team/types.d.ts +12 -2
  22. package/components/index.d.ts +39 -3
  23. package/components/index.js +16257 -1550
  24. package/hooks/index.d.ts +58 -9
  25. package/hooks/index.js +14414 -413
  26. package/index.d.ts +43 -10
  27. package/index.js +400 -1
  28. package/metadata/index.d.ts +16 -3
  29. package/package.json +2 -2
  30. package/register.d.ts +20 -9
  31. package/routing/index.d.ts +8 -3
  32. package/routing/index.js +327 -0
  33. package/slots/index.d.ts +1 -1
  34. package/slots/index.js +20 -1
  35. package/types/index.d.ts +431 -50
  36. package/ui/index.d.ts +2 -2
  37. package/ui/index.js +2 -1
  38. package/utils/index.d.ts +24 -2
  39. package/utils/index.js +269 -1
  40. package/_internal/app/hooks/use-assets.d.ts +0 -25
package/routing/index.js CHANGED
@@ -13696,6 +13696,333 @@ var errorEnvelope = exports_external.object({
13696
13696
  error: exports_external.string(),
13697
13697
  issues: exports_external.array(exports_external.unknown()).optional()
13698
13698
  });
13699
+
13700
+ // packages/core/src/logger.ts
13701
+ import { createWriteStream, existsSync, mkdirSync, renameSync, statSync } from "fs";
13702
+ import { join as join2 } from "path";
13703
+
13704
+ // packages/core/src/content-dir.ts
13705
+ import { join } from "path";
13706
+ import { homedir } from "os";
13707
+ // packages/core/src/constants.ts
13708
+ var APP_SLUG = "bakin";
13709
+
13710
+ // packages/core/src/content-dir.ts
13711
+ function bakinHomeDefault() {
13712
+ return join(homedir(), `.${APP_SLUG}`);
13713
+ }
13714
+ var resolvedContentDir = null;
13715
+ function isTestEnv() {
13716
+ return process.env.VITEST === "true" || !!process.env.VITEST;
13717
+ }
13718
+ function realBakinHome() {
13719
+ const realHome = process.env.HOME || process.env.USERPROFILE || "";
13720
+ if (!realHome)
13721
+ return "";
13722
+ return join(realHome, `.${APP_SLUG}`);
13723
+ }
13724
+ function assertSafeForTest(path) {
13725
+ if (!isTestEnv())
13726
+ return;
13727
+ const real = realBakinHome();
13728
+ if (real && path === real) {
13729
+ throw new Error(`[bakin] getContentDir() resolved to the real Bakin home (${real}) ` + `during a test run. This would write test data to your production instance. ` + `Fix: mock src/core/content-dir in this test, or set BAKIN_HOME to a temp ` + `directory before importing any Bakin module. See CLAUDE.md \xA7 Testing Rules.`);
13730
+ }
13731
+ }
13732
+ function getContentDir() {
13733
+ if (resolvedContentDir)
13734
+ return resolvedContentDir;
13735
+ const resolved = resolveContentDirInner();
13736
+ assertSafeForTest(resolved);
13737
+ resolvedContentDir = resolved;
13738
+ return resolvedContentDir;
13739
+ }
13740
+ function resolveContentDirInner() {
13741
+ if (process.env.BAKIN_HOME)
13742
+ return process.env.BAKIN_HOME;
13743
+ return bakinHomeDefault();
13744
+ }
13745
+ function getBakinPaths() {
13746
+ const home = getContentDir();
13747
+ const assets = join(home, "assets");
13748
+ return {
13749
+ home,
13750
+ memoryLog: join(home, "MEMORY-LOG.md"),
13751
+ audit: join(home, "audit.jsonl"),
13752
+ assets,
13753
+ "assets.store": join(assets, "store"),
13754
+ "assets.inbox": join(assets, "inbox"),
13755
+ "assets.trash": join(assets, ".trash"),
13756
+ agents: join(home, "agents"),
13757
+ personas: join(home, "team", "personas"),
13758
+ team: join(home, "team"),
13759
+ heartbeats: join(home, "heartbeats"),
13760
+ inbox: join(home, "inbox"),
13761
+ tasks: join(home, "tasks"),
13762
+ workflows: join(home, "workflows"),
13763
+ settings: join(home, "settings.json"),
13764
+ logs: join(home, "logs")
13765
+ };
13766
+ }
13767
+
13768
+ // packages/core/src/logger.ts
13769
+ var MAX_LOG_BYTES = 10 * 1024 * 1024;
13770
+ var LEVEL_RANK = {
13771
+ debug: 10,
13772
+ info: 20,
13773
+ warn: 30,
13774
+ error: 40
13775
+ };
13776
+ var COLOR_RESET = "\x1B[0m";
13777
+ var COLORS = {
13778
+ dim: "\x1B[2m",
13779
+ blue: "\x1B[34m",
13780
+ cyan: "\x1B[36m",
13781
+ green: "\x1B[32m",
13782
+ magenta: "\x1B[35m",
13783
+ red: "\x1B[31m",
13784
+ yellow: "\x1B[33m"
13785
+ };
13786
+ var fileStream = null;
13787
+ var fileTransportInitialized = false;
13788
+ var fileTransportDisabled = false;
13789
+ function fileTransportEnabled() {
13790
+ if (fileTransportDisabled)
13791
+ return false;
13792
+ if (false)
13793
+ ;
13794
+ if (process.env.VITEST)
13795
+ return false;
13796
+ if (process.env.BAKIN_DISABLE_FILE_LOG === "1")
13797
+ return false;
13798
+ return true;
13799
+ }
13800
+ function ensureFileStream() {
13801
+ if (fileTransportInitialized)
13802
+ return fileStream;
13803
+ fileTransportInitialized = true;
13804
+ if (!fileTransportEnabled())
13805
+ return null;
13806
+ try {
13807
+ const logsDir = getBakinPaths().logs;
13808
+ if (!existsSync(logsDir))
13809
+ mkdirSync(logsDir, { recursive: true });
13810
+ const logPath = join2(logsDir, "server.log");
13811
+ if (existsSync(logPath)) {
13812
+ try {
13813
+ const size = statSync(logPath).size;
13814
+ if (size > MAX_LOG_BYTES) {
13815
+ const rotated = join2(logsDir, "server.log.1");
13816
+ renameSync(logPath, rotated);
13817
+ }
13818
+ } catch {}
13819
+ }
13820
+ fileStream = createWriteStream(logPath, { flags: "a" });
13821
+ fileStream.on("error", () => {
13822
+ fileTransportDisabled = true;
13823
+ fileStream = null;
13824
+ });
13825
+ } catch {
13826
+ fileTransportDisabled = true;
13827
+ fileStream = null;
13828
+ }
13829
+ return fileStream;
13830
+ }
13831
+ function formatEntry(entry) {
13832
+ const parts = [`[${entry.ts}] [${entry.level.toUpperCase()}] [${entry.module}] ${entry.message}`];
13833
+ if (entry.error)
13834
+ parts.push(` error: ${entry.error}`);
13835
+ if (entry.data)
13836
+ parts.push(` data: ${JSON.stringify(entry.data)}`);
13837
+ return parts.join(`
13838
+ `);
13839
+ }
13840
+ function consoleFormat() {
13841
+ const configured = process.env.BAKIN_CONSOLE_FORMAT;
13842
+ if (configured === "pretty" || configured === "verbose" || configured === "plain" || configured === "silent") {
13843
+ return configured;
13844
+ }
13845
+ return process.stdout.isTTY === true ? "pretty" : "plain";
13846
+ }
13847
+ function consoleMinLevel(format) {
13848
+ const configured = process.env.BAKIN_LOG_LEVEL;
13849
+ if (configured === "debug" || configured === "info" || configured === "warn" || configured === "error") {
13850
+ return configured;
13851
+ }
13852
+ if (format === "verbose")
13853
+ return "debug";
13854
+ if (format === "silent")
13855
+ return "error";
13856
+ if (format === "pretty")
13857
+ return "info";
13858
+ return "debug";
13859
+ }
13860
+ function colorEnabled(format) {
13861
+ if (format === "plain")
13862
+ return false;
13863
+ if (process.env.NO_COLOR || process.env.BAKIN_NO_COLOR === "1")
13864
+ return false;
13865
+ return process.stdout.isTTY === true;
13866
+ }
13867
+ function colorize(text, color, enabled) {
13868
+ return enabled ? `${COLORS[color]}${text}${COLOR_RESET}` : text;
13869
+ }
13870
+ function sourceLabel(entry) {
13871
+ const data = entry.data;
13872
+ const explicitSource = typeof data?.source === "string" ? data.source : undefined;
13873
+ const pluginId = typeof data?.pluginId === "string" ? data.pluginId : undefined;
13874
+ if (explicitSource === "antfly")
13875
+ return "antfly";
13876
+ if (explicitSource === "dev")
13877
+ return "dev";
13878
+ if (explicitSource === "plugin" && pluginId)
13879
+ return `plugin:${pluginId}`;
13880
+ if (entry.module === "plugin-registry" && pluginId)
13881
+ return `plugin:${pluginId}`;
13882
+ if (entry.module.startsWith("api:"))
13883
+ return "api";
13884
+ return entry.module;
13885
+ }
13886
+ function sourceColor(source) {
13887
+ if (source === "dev")
13888
+ return "cyan";
13889
+ if (source === "server")
13890
+ return "blue";
13891
+ if (source === "antfly")
13892
+ return "magenta";
13893
+ if (source.startsWith("plugin:"))
13894
+ return "green";
13895
+ if (source.includes("search"))
13896
+ return "cyan";
13897
+ if (source.includes("runtime"))
13898
+ return "magenta";
13899
+ return "dim";
13900
+ }
13901
+ function levelColor(level) {
13902
+ if (level === "debug")
13903
+ return "dim";
13904
+ if (level === "warn")
13905
+ return "yellow";
13906
+ if (level === "error")
13907
+ return "red";
13908
+ return "blue";
13909
+ }
13910
+ function isImportantAntflyInfo(entry) {
13911
+ return [
13912
+ "Metadata API server is ready",
13913
+ "Store HTTP server is ready",
13914
+ "Swarm mode: all servers are ready",
13915
+ "Termite's api server starting"
13916
+ ].some((message) => entry.message.includes(message));
13917
+ }
13918
+ function suppressPrettyInfo(entry) {
13919
+ if (entry.level !== "info")
13920
+ return false;
13921
+ if (entry.data?.source === "antfly")
13922
+ return !isImportantAntflyInfo(entry);
13923
+ if (entry.module === "plugin-registry") {
13924
+ return entry.message === "plugin activated" || entry.message.startsWith("Auto-registered ") || entry.message.startsWith("Plugin activation order:");
13925
+ }
13926
+ return [
13927
+ "search-registry",
13928
+ "search-reconcile",
13929
+ "search-cleanup",
13930
+ "hot-reload-coordinator",
13931
+ "mcporter",
13932
+ "dispatch",
13933
+ "watchdog",
13934
+ "doctor",
13935
+ "lifecycle"
13936
+ ].includes(entry.module);
13937
+ }
13938
+ function shouldWriteConsole(entry, format) {
13939
+ if (format === "silent")
13940
+ return false;
13941
+ const minLevel = consoleMinLevel(format);
13942
+ if (LEVEL_RANK[entry.level] < LEVEL_RANK[minLevel])
13943
+ return false;
13944
+ if (format === "pretty" && suppressPrettyInfo(entry))
13945
+ return false;
13946
+ return true;
13947
+ }
13948
+ function formatPrettyEntry(entry, format) {
13949
+ const colors = colorEnabled(format);
13950
+ const time3 = new Date(entry.ts).toTimeString().slice(0, 8);
13951
+ const level = entry.level.padEnd(5);
13952
+ const source = sourceLabel(entry);
13953
+ const label = source.padEnd(18);
13954
+ const levelPart = colorize(level, levelColor(entry.level), colors);
13955
+ const sourcePart = colorize(label, sourceColor(source), colors);
13956
+ const messagePart = entry.level === "error" ? colorize(entry.message, "red", colors) : entry.message;
13957
+ const parts = [`${colorize(time3, "dim", colors)} ${levelPart} ${sourcePart} ${messagePart}`];
13958
+ if (entry.error)
13959
+ parts[0] += ` - ${entry.error}`;
13960
+ if (format === "verbose" && entry.data) {
13961
+ parts.push(` data: ${JSON.stringify(entry.data)}`);
13962
+ }
13963
+ return parts.join(`
13964
+ `);
13965
+ }
13966
+ function formatConsoleEntry(entry) {
13967
+ const format = consoleFormat();
13968
+ if (format === "plain")
13969
+ return formatEntry(entry);
13970
+ if (format === "silent")
13971
+ return "";
13972
+ return formatPrettyEntry(entry, format);
13973
+ }
13974
+ function writeToFile(entry) {
13975
+ const stream = ensureFileStream();
13976
+ if (!stream)
13977
+ return;
13978
+ try {
13979
+ stream.write(JSON.stringify(entry) + `
13980
+ `);
13981
+ } catch {
13982
+ fileTransportDisabled = true;
13983
+ fileStream = null;
13984
+ }
13985
+ }
13986
+ function createLogger(module) {
13987
+ function log(level, message, errorOrData, data) {
13988
+ const entry = {
13989
+ ts: new Date().toISOString(),
13990
+ level,
13991
+ module,
13992
+ message
13993
+ };
13994
+ if (errorOrData instanceof Error) {
13995
+ entry.error = errorOrData.message;
13996
+ entry.data = data ? { ...data, stack: errorOrData.stack } : { stack: errorOrData.stack };
13997
+ } else if (typeof errorOrData === "string") {
13998
+ entry.error = errorOrData;
13999
+ entry.data = data;
14000
+ } else if (errorOrData && typeof errorOrData === "object") {
14001
+ entry.data = errorOrData;
14002
+ }
14003
+ const format = consoleFormat();
14004
+ if (shouldWriteConsole(entry, format)) {
14005
+ const formatted = formatConsoleEntry(entry);
14006
+ if (level === "error") {
14007
+ console.error(formatted);
14008
+ } else if (level === "warn") {
14009
+ console.warn(formatted);
14010
+ } else {
14011
+ console.log(formatted);
14012
+ }
14013
+ }
14014
+ writeToFile(entry);
14015
+ }
14016
+ return {
14017
+ debug: (message, data) => log("debug", message, data),
14018
+ info: (message, data) => log("info", message, data),
14019
+ warn: (message, errorOrData, data) => log("warn", message, errorOrData, data),
14020
+ error: (message, errorOrData, data) => log("error", message, errorOrData, data)
14021
+ };
14022
+ }
14023
+
14024
+ // packages/core/src/routing/dispatcher.ts
14025
+ var log = createLogger("dispatcher");
13699
14026
  // packages/core/src/routing/search-route.ts
13700
14027
  var searchQuery = exports_external.object({
13701
14028
  q: exports_external.string().min(1),
package/slots/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `@bakin/sdk/slots` — client-side slot registry + `<Slot>` primitive.
2
+ * `@makinbakin/sdk/slots` — client-side slot registry + `<Slot>` primitive.
3
3
  *
4
4
  * The slot system lets a plugin render components contributed by other
5
5
  * plugins at a named extension point. Today it's used for:
package/slots/index.js CHANGED
@@ -20,15 +20,34 @@ function getRegistry() {
20
20
  cleanupByPlugin: new Map,
21
21
  navItemsSnapshot: [],
22
22
  version: 0,
23
- listeners: new Set
23
+ listeners: new Set,
24
+ badgesByPlugin: new Map,
25
+ badgesSnapshot: new Map,
26
+ badgeListeners: new Set
24
27
  };
25
28
  }
26
29
  const registry = g.__bakinClientRegistry;
27
30
  if (!Array.isArray(registry.navItemsSnapshot)) {
28
31
  registry.navItemsSnapshot = buildNavItemsSnapshot(registry);
29
32
  }
33
+ if (!registry.badgesByPlugin)
34
+ registry.badgesByPlugin = new Map;
35
+ if (!registry.badgesSnapshot)
36
+ registry.badgesSnapshot = buildBadgesSnapshot(registry);
37
+ if (!registry.badgeListeners)
38
+ registry.badgeListeners = new Set;
30
39
  return registry;
31
40
  }
41
+ function buildBadgesSnapshot(registry) {
42
+ const snapshot = new Map;
43
+ for (const byNavItemId of registry.badgesByPlugin.values()) {
44
+ for (const [navItemId, badge] of byNavItemId) {
45
+ if (!snapshot.has(navItemId))
46
+ snapshot.set(navItemId, badge);
47
+ }
48
+ }
49
+ return snapshot;
50
+ }
32
51
  function getRegistryVersion() {
33
52
  return getRegistry().version;
34
53
  }