@elevasis/sdk 0.4.5 → 0.4.7

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/dist/cli.cjs +829 -413
  2. package/dist/index.d.ts +79 -14
  3. package/dist/index.js +17 -12
  4. package/dist/templates.js +747 -0
  5. package/dist/types/templates.d.ts +1 -0
  6. package/dist/types/worker/index.d.ts +6 -0
  7. package/dist/types/worker/platform.d.ts +32 -0
  8. package/dist/worker/index.js +4701 -9
  9. package/package.json +10 -3
  10. package/reference/_index.md +95 -0
  11. package/reference/_navigation.md +104 -0
  12. package/reference/cli/index.mdx +497 -0
  13. package/reference/concepts/index.mdx +203 -0
  14. package/reference/deployment/api.mdx +297 -0
  15. package/reference/deployment/index.mdx +153 -0
  16. package/reference/developer/interaction-guidance.mdx +213 -0
  17. package/reference/framework/agent.mdx +175 -0
  18. package/reference/framework/documentation.mdx +92 -0
  19. package/reference/framework/index.mdx +95 -0
  20. package/reference/framework/memory.mdx +337 -0
  21. package/reference/framework/project-structure.mdx +294 -0
  22. package/reference/getting-started/index.mdx +148 -0
  23. package/reference/index.mdx +113 -0
  24. package/reference/platform-tools/examples.mdx +187 -0
  25. package/reference/platform-tools/index.mdx +182 -0
  26. package/reference/resources/index.mdx +289 -0
  27. package/reference/resources/patterns.mdx +341 -0
  28. package/reference/resources/types.mdx +207 -0
  29. package/reference/roadmap/index.mdx +147 -0
  30. package/reference/runtime/index.mdx +141 -0
  31. package/reference/runtime/limits.mdx +77 -0
  32. package/reference/security/credentials.mdx +141 -0
  33. package/reference/templates/data-enrichment.mdx +162 -0
  34. package/reference/templates/email-sender.mdx +135 -0
  35. package/reference/templates/lead-scorer.mdx +175 -0
  36. package/reference/templates/pdf-generator.mdx +151 -0
  37. package/reference/templates/recurring-job.mdx +189 -0
  38. package/reference/templates/text-classifier.mdx +147 -0
  39. package/reference/templates/web-scraper.mdx +135 -0
  40. package/reference/troubleshooting/common-errors.mdx +210 -0
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  /**
4
- * Workflow-specific logging types
4
+ * Workflow-specific logging types and utilities
5
5
  */
6
6
 
7
7
  interface WorkflowExecutionContext {
@@ -677,16 +677,12 @@ interface WorkflowStepDefinition {
677
677
  description: string;
678
678
  }
679
679
  type StepHandler = (input: unknown, context: ExecutionContext) => Promise<unknown>;
680
- declare enum StepType$1 {
681
- LINEAR = "linear",
682
- CONDITIONAL = "conditional"
683
- }
684
680
  interface LinearNext {
685
- type: StepType$1.LINEAR;
681
+ type: 'linear';
686
682
  target: string;
687
683
  }
688
684
  interface ConditionalNext {
689
- type: StepType$1.CONDITIONAL;
685
+ type: 'conditional';
690
686
  routes: Array<{
691
687
  condition: (data: unknown) => boolean;
692
688
  target: string;
@@ -717,6 +713,63 @@ interface WorkflowDefinition {
717
713
  interface?: ExecutionInterface;
718
714
  }
719
715
 
716
+ /**
717
+ * Generic LLM Types
718
+ * Universal interfaces for LLM interaction across all resource types
719
+ */
720
+ /**
721
+ * Standard chat message format
722
+ * Compatible with OpenAI, Anthropic, and other providers
723
+ */
724
+ interface LLMMessage {
725
+ role: 'system' | 'user' | 'assistant';
726
+ content: string;
727
+ }
728
+ /**
729
+ * Generic LLM generation request
730
+ * Usable by agents, workflows, tools, etc.
731
+ */
732
+ interface LLMGenerateRequest {
733
+ messages: LLMMessage[];
734
+ responseSchema: unknown;
735
+ maxTokens?: number;
736
+ temperature?: number;
737
+ topP?: number;
738
+ signal?: AbortSignal;
739
+ }
740
+ /**
741
+ * Generic LLM generation response
742
+ * Usage field is internal-only (stripped by UniversalLLMAdapter wrapper)
743
+ */
744
+ interface LLMGenerateResponse<T = unknown> {
745
+ output: T;
746
+ usage?: {
747
+ inputTokens: number;
748
+ outputTokens: number;
749
+ totalTokens: number;
750
+ };
751
+ cost?: number;
752
+ }
753
+ /**
754
+ * LLM Adapter interface
755
+ * Generic primitive for all resource types (agents, workflows, tools)
756
+ *
757
+ * Design principles:
758
+ * - Single method: generate() - the core LLM primitive
759
+ * - Generic return type for type safety
760
+ * - Universal format (not agent-specific)
761
+ * - Standard message-based input (OpenAI-compatible)
762
+ */
763
+ interface LLMAdapter {
764
+ /**
765
+ * Generate structured output from prompt using LLM
766
+ *
767
+ * @param request - Generation request with messages and response schema
768
+ * @returns Generated output (typed) with optional usage metadata
769
+ */
770
+ generate<T = unknown>(request: LLMGenerateRequest): Promise<LLMGenerateResponse<T>>;
771
+ }
772
+
720
773
  /**
721
774
  * Memory type definitions
722
775
  * Types for agent memory management with semantic entry types
@@ -946,6 +999,16 @@ interface KnowledgeContent {
946
999
  * Types for autonomous agents with tools, memory, and constraints
947
1000
  */
948
1001
 
1002
+ /**
1003
+ * Factory function for creating LLM adapters.
1004
+ * Injected into the Agent class to decouple the engine from server-only provider SDKs.
1005
+ * - API process: provides createLLMAdapter (real SDKs + process.env API keys)
1006
+ * - SDK worker: provides PostMessageLLMAdapter (proxies via platform.call)
1007
+ *
1008
+ * Uses `any` for optional params so both the real createLLMAdapter (with typed
1009
+ * AIUsageCollector/AICallContext) and the worker proxy (which ignores them) satisfy the type.
1010
+ */
1011
+ type LLMAdapterFactory = (config: ModelConfig, ...args: any[]) => LLMAdapter;
949
1012
  interface AgentConfig extends ResourceDefinition {
950
1013
  type: 'agent';
951
1014
  systemPrompt: string;
@@ -1040,6 +1103,7 @@ interface IterationContext {
1040
1103
  iteration: number;
1041
1104
  logger: AgentScopedLogger;
1042
1105
  modelConfig: ModelConfig;
1106
+ adapterFactory: LLMAdapterFactory;
1043
1107
  knowledgeMap?: KnowledgeMap;
1044
1108
  }
1045
1109
 
@@ -1065,10 +1129,10 @@ interface RemoteOrgConfig {
1065
1129
  bundlePath: string;
1066
1130
  /** Deployment record ID */
1067
1131
  deploymentId: string;
1068
- /** Developer-provided environment variables injected into the worker */
1069
- envVars?: Record<string, string>;
1070
1132
  /** Platform tool name -> credential name mapping */
1071
1133
  toolCredentials?: Record<string, string>;
1134
+ /** SDK version used to deploy this bundle */
1135
+ sdkVersion?: string;
1072
1136
  }
1073
1137
  /**
1074
1138
  * Organization-specific resource collection
@@ -1931,10 +1995,11 @@ interface ElevasConfig {
1931
1995
  * Values are identical to their core package counterparts.
1932
1996
  */
1933
1997
  /** Step connection type for multi-step workflows */
1934
- declare enum StepType {
1935
- LINEAR = "linear",
1936
- CONDITIONAL = "conditional"
1937
- }
1998
+ declare const StepType: {
1999
+ readonly LINEAR: "linear";
2000
+ readonly CONDITIONAL: "conditional";
2001
+ };
2002
+ type StepType = typeof StepType[keyof typeof StepType];
1938
2003
  /** Base error class for execution errors */
1939
2004
  declare class ExecutionError extends Error {
1940
2005
  readonly type: string;
@@ -1950,4 +2015,4 @@ declare class ToolingError extends ExecutionError {
1950
2015
  }
1951
2016
 
1952
2017
  export { ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError };
1953
- export type { AgentConfig, AgentConstraints, AgentDefinition, ConditionalNext, Contract, DomainDefinition, ElevasConfig, EventTriggerConfig, ExecutionContext, ExecutionInterface, ExecutionMetadata, FormField, FormFieldType, FormSchema, IntegrationDefinition, LLMModel, LinearNext, ModelConfig, NextConfig, OrganizationResources, ResourceDefinition, ResourceDomain, ResourceMetricsConfig, ResourceStatus, ResourceType, ScheduleTriggerConfig, StepHandler, Tool, ToolExecutionOptions, ToolingErrorType, TriggerConfig, TriggerDefinition, WebhookProviderType, WebhookTriggerConfig, WorkflowConfig, WorkflowDefinition, WorkflowStep };
2018
+ export type { AgentConfig, AgentConstraints, AgentDefinition, ConditionalNext, Contract, DomainDefinition, ElevasConfig, EventTriggerConfig, ExecutionContext, ExecutionInterface, ExecutionMetadata, FormField, FormFieldType, FormSchema, IntegrationDefinition, LLMAdapterFactory, LLMModel, LinearNext, ModelConfig, NextConfig, OrganizationResources, ResourceDefinition, ResourceDomain, ResourceMetricsConfig, ResourceStatus, ResourceType, ScheduleTriggerConfig, StepHandler, Tool, ToolExecutionOptions, ToolingErrorType, TriggerConfig, TriggerDefinition, WebhookProviderType, WebhookTriggerConfig, WorkflowConfig, WorkflowDefinition, WorkflowStep };
package/dist/index.js CHANGED
@@ -8,11 +8,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
  });
9
9
 
10
10
  // src/runtime.ts
11
- var StepType = /* @__PURE__ */ ((StepType2) => {
12
- StepType2["LINEAR"] = "linear";
13
- StepType2["CONDITIONAL"] = "conditional";
14
- return StepType2;
15
- })(StepType || {});
11
+ var StepType = {
12
+ LINEAR: "linear",
13
+ CONDITIONAL: "conditional"
14
+ };
16
15
  var ExecutionError = class extends Error {
17
16
  type;
18
17
  context;
@@ -201,7 +200,7 @@ var GPT5OptionsSchema = z.object({
201
200
  var GPT5ConfigSchema = z.object({
202
201
  model: z.enum(["gpt-5", "gpt-5-mini"]),
203
202
  provider: z.enum(["openai"]),
204
- apiKey: z.string().min(1),
203
+ apiKey: z.string(),
205
204
  temperature: z.literal(1),
206
205
  // Required to be exactly 1
207
206
  maxTokens: z.number().min(4e3).optional(),
@@ -231,7 +230,7 @@ var OpenRouterConfigSchema = z.object({
231
230
  "openrouter/x-ai/grok-4.1-fast"
232
231
  ]),
233
232
  provider: z.literal("openrouter"),
234
- apiKey: z.string().min(1),
233
+ apiKey: z.string(),
235
234
  temperature: z.number().min(0).max(2).optional(),
236
235
  maxTokens: z.number().min(500).optional(),
237
236
  topP: z.number().min(0).max(1).optional(),
@@ -244,7 +243,7 @@ var GoogleOptionsSchema = z.object({
244
243
  var GoogleConfigSchema = z.object({
245
244
  model: z.enum(["gemini-3-flash-preview"]),
246
245
  provider: z.literal("google"),
247
- apiKey: z.string().min(1),
246
+ apiKey: z.string(),
248
247
  temperature: z.literal(1).optional(),
249
248
  // Must be 1 for Gemini 3 (changing degrades performance)
250
249
  maxTokens: z.number().min(500).optional(),
@@ -255,7 +254,7 @@ var AnthropicOptionsSchema = z.object({});
255
254
  var AnthropicConfigSchema = z.object({
256
255
  model: z.enum(["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5"]),
257
256
  provider: z.literal("anthropic"),
258
- apiKey: z.string().min(1),
257
+ apiKey: z.string(),
259
258
  temperature: z.number().min(0).max(1).optional(),
260
259
  maxTokens: z.number().min(1e3).optional(),
261
260
  // Anthropic requires max_tokens
@@ -2801,6 +2800,12 @@ var zodToJsonSchema = (schema, options) => {
2801
2800
  return combined;
2802
2801
  };
2803
2802
 
2803
+ // ../core/src/execution/engine/workflow/types.ts
2804
+ var StepType2 = {
2805
+ LINEAR: "linear",
2806
+ CONDITIONAL: "conditional"
2807
+ };
2808
+
2804
2809
  // ../core/src/execution/engine/base/serialization.ts
2805
2810
  function serializeDefinition(definition, options) {
2806
2811
  const opts = {
@@ -2885,13 +2890,13 @@ function serializeKnowledgeMap(km, ctx) {
2885
2890
  }
2886
2891
  function serializeNextConfig(nextConfig, _context) {
2887
2892
  if (!nextConfig) return null;
2888
- if (nextConfig.type === "linear" /* LINEAR */) {
2893
+ if (nextConfig.type === StepType2.LINEAR) {
2889
2894
  return {
2890
2895
  type: nextConfig.type,
2891
2896
  target: nextConfig.target
2892
2897
  };
2893
2898
  }
2894
- if (nextConfig.type === "conditional" /* CONDITIONAL */) {
2899
+ if (nextConfig.type === StepType2.CONDITIONAL) {
2895
2900
  return {
2896
2901
  type: nextConfig.type,
2897
2902
  routes: nextConfig.routes?.map((route) => ({
@@ -2943,7 +2948,7 @@ function isKnowledgeMapObject(value) {
2943
2948
  return value && typeof value === "object" && "nodes" in value && typeof value.nodes === "object";
2944
2949
  }
2945
2950
  function isNextConfigObject(value) {
2946
- return value && typeof value === "object" && "type" in value && (value.type === "linear" /* LINEAR */ || value.type === "conditional" /* CONDITIONAL */);
2951
+ return value && typeof value === "object" && "type" in value && (value.type === StepType2.LINEAR || value.type === StepType2.CONDITIONAL);
2947
2952
  }
2948
2953
  function isSecretKey(key) {
2949
2954
  const lower = key.toLowerCase();