theokit 0.1.0-alpha.6 → 0.2.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.
Files changed (62) hide show
  1. package/dist/add-2ZFFGGE4.js +0 -0
  2. package/dist/aws-lambda-PONVF3UX.js +0 -0
  3. package/dist/broadcast-QOQGUNNK.js +0 -0
  4. package/dist/build-IQQYCA3B.js +0 -0
  5. package/dist/bun-DITMZMKL.js +0 -0
  6. package/dist/check-PZR67OY5.js +0 -0
  7. package/dist/chunk-3Q36SEDK.js +0 -0
  8. package/dist/chunk-5ODOE6EF.js +0 -0
  9. package/dist/chunk-GQSTRXXB.js +0 -0
  10. package/dist/{chunk-MCP6Y5BA.js → chunk-JBC7PFV4.js} +25 -1
  11. package/dist/chunk-JBC7PFV4.js.map +1 -0
  12. package/dist/chunk-JZ5WEG3S.js +0 -0
  13. package/dist/chunk-KT3MWNZG.js +0 -0
  14. package/dist/chunk-O7335ZGH.js +0 -0
  15. package/dist/chunk-OK2PJOLK.js +105 -0
  16. package/dist/chunk-OK2PJOLK.js.map +1 -0
  17. package/dist/chunk-S3JBIFKS.js +0 -0
  18. package/dist/chunk-WQCPKA2L.js +0 -0
  19. package/dist/chunk-WZ7CPVQB.js +0 -0
  20. package/dist/chunk-XMS5VRIK.js +0 -0
  21. package/dist/chunk-Y5KE6YFP.js +0 -0
  22. package/dist/chunk-ZK5JCE5J.js +0 -0
  23. package/dist/cli/index.js +1 -1
  24. package/dist/cloudflare-RBANU3SE.js +0 -0
  25. package/dist/configure-agent-registry-6YGTJYBC.js +0 -0
  26. package/dist/deno-deploy-J7LI6HNL.js +0 -0
  27. package/dist/dev-VN6WS3CM.js +0 -0
  28. package/dist/devtools/entry.js +249 -203
  29. package/dist/devtools/entry.js.map +1 -1
  30. package/dist/dispatcher-IK3FVMX5.js +8 -0
  31. package/dist/dispatcher-IK3FVMX5.js.map +1 -0
  32. package/dist/{dist-UZV7J3YI.js → dist-Q5VBFWVL.js} +251 -89
  33. package/dist/dist-Q5VBFWVL.js.map +1 -0
  34. package/dist/docker-EZDA5FT7.js +0 -0
  35. package/dist/generate-SIO4JSKJ.js +0 -0
  36. package/dist/info-B3UOXFUF.js +0 -0
  37. package/dist/lib-NST3PNZX.js +0 -0
  38. package/dist/netlify-IFY6ZGFV.js +0 -0
  39. package/dist/node-KWZI3CKV.js +0 -0
  40. package/dist/proper-lockfile-MVKMQGFK.js +0 -0
  41. package/dist/registry-BB3UYAOG.js +0 -0
  42. package/dist/routes-CAGFZKUK.js +0 -0
  43. package/dist/scan-C2BOKLSY.js +0 -0
  44. package/dist/schema-MVB2FVK6.js +0 -0
  45. package/dist/server/cost/index.d.ts +7 -0
  46. package/dist/server/cost/index.js +1 -1
  47. package/dist/server/index.js +70 -2
  48. package/dist/server/index.js.map +1 -1
  49. package/dist/services-typed-client-ZX5JUHH3.js +0 -0
  50. package/dist/sqlite-vec-54KB4RD3.js +0 -0
  51. package/dist/{start-CSLJQXV3.js → start-ZGWW5MOL.js} +3 -3
  52. package/dist/static-BH6JQNM2.js +0 -0
  53. package/dist/storage-manager-D5KBXXKB.js +0 -0
  54. package/dist/theo-cloud-3K4DGB3S.js +0 -0
  55. package/dist/upgrade-readiness-OHL36FQL.js +0 -0
  56. package/dist/vercel-RHADE5IP.js +0 -0
  57. package/dist/vite-plugin-WA3G45YY.js +0 -0
  58. package/package.json +8 -8
  59. package/LICENSE +0 -201
  60. package/dist/chunk-MCP6Y5BA.js.map +0 -1
  61. package/dist/dist-UZV7J3YI.js.map +0 -1
  62. /package/dist/{start-CSLJQXV3.js.map → start-ZGWW5MOL.js.map} +0 -0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -90,6 +90,8 @@ interface TrackAgentRunInput {
90
90
  costUsd: number;
91
91
  /** Defaults to `new Date()`. */
92
92
  timestamp?: Date;
93
+ /** Optional execution status surfaced to devtools (default 'finished'). */
94
+ status?: 'finished' | 'error' | 'aborted';
93
95
  }
94
96
  interface TrackAgentRunOptions {
95
97
  /** Adapter resolved from `theo.config.ts > cost.storage`. */
@@ -106,6 +108,11 @@ interface TrackAgentRunOptions {
106
108
  *
107
109
  * No-op when `storage` is undefined (cost tracking unconfigured).
108
110
  *
111
+ * In dev mode (Vite OR tsup-built with NODE_ENV != 'production'), fires a
112
+ * `theokit-evolution-ci-and-dx` Phase 3 dispatcher event so the devtools
113
+ * Agents tab can render the run. Prod tree-shakes the entire dispatcher
114
+ * import via the `__IS_DEV` IIFE guard.
115
+ *
109
116
  * @see docs/concepts/cost-tracking.md (when implemented in T6.3)
110
117
  */
111
118
  declare function trackAgentRun(input: TrackAgentRunInput, opts: TrackAgentRunOptions): Promise<void>;
@@ -2,7 +2,7 @@ import {
2
2
  InMemoryUsageStorage,
3
3
  trackAgentRun,
4
4
  trackAgentTools
5
- } from "../../chunk-MCP6Y5BA.js";
5
+ } from "../../chunk-JBC7PFV4.js";
6
6
  import "../../chunk-DGUM43GV.js";
7
7
  export {
8
8
  InMemoryUsageStorage,
@@ -28,7 +28,7 @@ import {
28
28
  InMemoryUsageStorage,
29
29
  trackAgentRun,
30
30
  trackAgentTools
31
- } from "../chunk-MCP6Y5BA.js";
31
+ } from "../chunk-JBC7PFV4.js";
32
32
  import {
33
33
  CRON_MANIFEST_SCHEMA_VERSION,
34
34
  DuplicateCronNameError,
@@ -551,6 +551,53 @@ async function* streamAgentRun(run) {
551
551
  }
552
552
  }
553
553
 
554
+ // src/server/agent/provider-resolver.ts
555
+ var DEFAULT_REGISTRY = [
556
+ {
557
+ name: "openrouter",
558
+ envKey: "OPENROUTER_API_KEY",
559
+ baseUrl: "https://openrouter.ai/api/v1",
560
+ priority: 1
561
+ },
562
+ {
563
+ name: "openai",
564
+ envKey: "OPENAI_API_KEY",
565
+ baseUrl: "https://api.openai.com/v1",
566
+ priority: 2
567
+ },
568
+ {
569
+ name: "anthropic",
570
+ envKey: "ANTHROPIC_API_KEY",
571
+ baseUrl: "https://api.anthropic.com",
572
+ priority: 3
573
+ }
574
+ ];
575
+ var registry = [...DEFAULT_REGISTRY];
576
+ function resolveProvider() {
577
+ const sorted = [...registry].sort((a, b) => a.priority - b.priority);
578
+ for (const desc of sorted) {
579
+ const apiKey = process.env[desc.envKey];
580
+ if (apiKey && apiKey.length > 0) {
581
+ return {
582
+ name: desc.name,
583
+ apiKey,
584
+ baseUrl: desc.baseUrl
585
+ };
586
+ }
587
+ }
588
+ const envKeys = sorted.map((p) => p.envKey).join(" OR ");
589
+ throw new Error(
590
+ `No LLM provider API key found in environment. Set one of: ${envKeys}. Get a free OpenRouter key at https://openrouter.ai/keys (recommended \u2014 one key, many models).`
591
+ );
592
+ }
593
+ function tryResolveProvider() {
594
+ try {
595
+ return resolveProvider();
596
+ } catch {
597
+ return null;
598
+ }
599
+ }
600
+
554
601
  // src/server/agent/create-conversation-history.ts
555
602
  var sdkOverride = void 0;
556
603
  function __setSdkForTests(sdk) {
@@ -645,10 +692,31 @@ async function createConversationHistory(args) {
645
692
  });
646
693
  args.response.headers.append("set-cookie", cookie);
647
694
  }
695
+ const resolvedOptions = autoResolveProviderIfNeeded(args.options);
648
696
  const sdk = await loadSdk();
649
- const agent = await sdk.Agent.getOrCreate(conversationId, args.options);
697
+ const agent = await sdk.Agent.getOrCreate(conversationId, resolvedOptions);
650
698
  return { agent, conversationId, isNew };
651
699
  }
700
+ function autoResolveProviderIfNeeded(options) {
701
+ if (typeof options.apiKey === "string" && options.apiKey.length > 0) {
702
+ return options;
703
+ }
704
+ const resolved = tryResolveProvider();
705
+ if (resolved === null) {
706
+ throw new Error(
707
+ "No LLM provider API key found in environment. Set OPENROUTER_API_KEY (recommended \u2014 gateway to many models) OR OPENAI_API_KEY OR ANTHROPIC_API_KEY in your .env. Get a free OpenRouter key at https://openrouter.ai/keys. (Pass `options.apiKey` explicitly to bypass auto-resolution.)"
708
+ );
709
+ }
710
+ return {
711
+ ...options,
712
+ apiKey: resolved.apiKey,
713
+ providers: {
714
+ routes: [
715
+ { capability: "chat", provider: resolved.name, baseUrl: resolved.baseUrl }
716
+ ]
717
+ }
718
+ };
719
+ }
652
720
 
653
721
  // src/server/rate-limit/rate-limit-per-route.ts
654
722
  import { createHash } from "crypto";