@elevasis/sdk 0.5.16 → 0.5.18

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/dist/cli.cjs CHANGED
@@ -40166,6 +40166,7 @@ var DOMAIN_MAP = {
40166
40166
 
40167
40167
  // ../core/src/platform/registry/reserved.ts
40168
40168
  var RESERVED_RESOURCE_IDS = /* @__PURE__ */ new Set(["command-center-assistant"]);
40169
+ var SYSTEM_RESOURCE_IDS = Array.from(RESERVED_RESOURCE_IDS);
40169
40170
  function isReservedResourceId(resourceId) {
40170
40171
  return RESERVED_RESOURCE_IDS.has(resourceId);
40171
40172
  }
@@ -40221,7 +40222,7 @@ var GPT5ConfigSchema = external_exports.object({
40221
40222
  apiKey: external_exports.string(),
40222
40223
  temperature: external_exports.literal(1),
40223
40224
  // Required to be exactly 1
40224
- maxTokens: external_exports.number().min(4e3).optional(),
40225
+ maxOutputTokens: external_exports.number().min(4e3).optional(),
40225
40226
  topP: external_exports.number().min(0).max(1).optional(),
40226
40227
  modelOptions: GPT5OptionsSchema.optional()
40227
40228
  });
@@ -40230,7 +40231,7 @@ var MockConfigSchema = external_exports.object({
40230
40231
  provider: external_exports.enum(["mock"]),
40231
40232
  apiKey: external_exports.string(),
40232
40233
  temperature: external_exports.number().min(0).max(2).optional(),
40233
- maxTokens: external_exports.number().min(500).optional(),
40234
+ maxOutputTokens: external_exports.number().min(500).optional(),
40234
40235
  topP: external_exports.number().min(0).max(1).optional(),
40235
40236
  modelOptions: external_exports.object({}).strict().optional()
40236
40237
  // No options supported
@@ -40250,7 +40251,7 @@ var OpenRouterConfigSchema = external_exports.object({
40250
40251
  provider: external_exports.literal("openrouter"),
40251
40252
  apiKey: external_exports.string(),
40252
40253
  temperature: external_exports.number().min(0).max(2).optional(),
40253
- maxTokens: external_exports.number().min(500).optional(),
40254
+ maxOutputTokens: external_exports.number().min(500).optional(),
40254
40255
  topP: external_exports.number().min(0).max(1).optional(),
40255
40256
  modelOptions: OpenRouterOptionsSchema.optional()
40256
40257
  });
@@ -40264,7 +40265,7 @@ var GoogleConfigSchema = external_exports.object({
40264
40265
  apiKey: external_exports.string(),
40265
40266
  temperature: external_exports.literal(1).optional(),
40266
40267
  // Must be 1 for Gemini 3 (changing degrades performance)
40267
- maxTokens: external_exports.number().min(500).optional(),
40268
+ maxOutputTokens: external_exports.number().min(500).optional(),
40268
40269
  topP: external_exports.number().min(0).max(1).optional(),
40269
40270
  modelOptions: GoogleOptionsSchema.optional()
40270
40271
  });
@@ -40274,7 +40275,7 @@ var AnthropicConfigSchema = external_exports.object({
40274
40275
  provider: external_exports.literal("anthropic"),
40275
40276
  apiKey: external_exports.string(),
40276
40277
  temperature: external_exports.number().min(0).max(1).optional(),
40277
- maxTokens: external_exports.number().min(1e3).optional(),
40278
+ maxOutputTokens: external_exports.number().min(1e3).optional(),
40278
40279
  // Anthropic requires max_tokens
40279
40280
  topP: external_exports.number().min(0).max(1).optional(),
40280
40281
  modelOptions: AnthropicOptionsSchema.optional()
@@ -43228,6 +43229,17 @@ function buildEdges(resources) {
43228
43229
  }
43229
43230
 
43230
43231
  // ../core/src/platform/registry/resource-registry.ts
43232
+ function filterArchived(org) {
43233
+ return {
43234
+ ...org,
43235
+ workflows: org.workflows?.filter((w) => !w.config.archived),
43236
+ agents: org.agents?.filter((a) => !a.config.archived),
43237
+ triggers: org.triggers?.filter((t) => !t.archived),
43238
+ integrations: org.integrations?.filter((i) => !i.archived),
43239
+ externalResources: org.externalResources?.filter((e) => !e.archived),
43240
+ humanCheckpoints: org.humanCheckpoints?.filter((h) => !h.archived)
43241
+ };
43242
+ }
43231
43243
  var ResourceRegistry = class {
43232
43244
  constructor(registry2) {
43233
43245
  this.registry = registry2;
@@ -43359,6 +43371,7 @@ var ResourceRegistry = class {
43359
43371
  * @throws Error if incoming deployment contains duplicate resourceIds
43360
43372
  */
43361
43373
  registerOrganization(orgName, org, remote) {
43374
+ org = filterArchived(org);
43362
43375
  const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
43363
43376
  const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
43364
43377
  const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
@@ -43420,6 +43433,7 @@ var ResourceRegistry = class {
43420
43433
  * @param org - Resource definitions with real handlers (not stubs)
43421
43434
  */
43422
43435
  registerStaticResources(orgName, org) {
43436
+ org = filterArchived(org);
43423
43437
  const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
43424
43438
  const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
43425
43439
  const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
@@ -43851,7 +43865,7 @@ async function apiDelete(endpoint, apiUrl = resolveApiUrl()) {
43851
43865
  // package.json
43852
43866
  var package_default = {
43853
43867
  name: "@elevasis/sdk",
43854
- version: "0.5.16",
43868
+ version: "0.5.18",
43855
43869
  description: "SDK for building Elevasis organization resources",
43856
43870
  type: "module",
43857
43871
  bin: {
@@ -43917,6 +43931,7 @@ var SDK_VERSION = package_default.version;
43917
43931
 
43918
43932
  // src/cli/commands/deploy.ts
43919
43933
  var import_meta = {};
43934
+ var IGNORED_DOC_DIRS = /* @__PURE__ */ new Set([".archive"]);
43920
43935
  async function scanDocumentation() {
43921
43936
  const docsDir = (0, import_path.resolve)("docs");
43922
43937
  const files = [];
@@ -43932,6 +43947,7 @@ async function scanDocumentation() {
43932
43947
  const fullPath = (0, import_path.resolve)(dir, entry.name);
43933
43948
  const relPath = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
43934
43949
  if (entry.isDirectory()) {
43950
+ if (IGNORED_DOC_DIRS.has(entry.name)) continue;
43935
43951
  await scan(fullPath, relPath);
43936
43952
  } else if (entry.isFile() && entry.name.endsWith(".mdx")) {
43937
43953
  const raw = await (0, import_promises.readFile)(fullPath, "utf-8");
@@ -44127,6 +44143,7 @@ async function generateProjectMap(org) {
44127
44143
  for (const entry of entries) {
44128
44144
  const relPath = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
44129
44145
  if (entry.isDirectory()) {
44146
+ if (IGNORED_DOC_DIRS.has(entry.name)) continue;
44130
44147
  await scanDocsDir((0, import_path.resolve)(dir, entry.name), relPath);
44131
44148
  } else if (entry.isFile() && entry.name.endsWith(".mdx") && relPath !== "project-map.mdx" && relPath !== "resource-map.mdx") {
44132
44149
  try {
@@ -44422,6 +44439,8 @@ function registerDeployCommand(program3) {
44422
44439
  }
44423
44440
  const validateSpinner = ora("Validating...").start();
44424
44441
  let org;
44442
+ let activeWorkflows = [];
44443
+ let activeAgents = [];
44425
44444
  try {
44426
44445
  const jiti = (0, import_jiti.createJiti)(import_meta.url);
44427
44446
  const entryModule = await jiti.import((0, import_path.resolve)(entryPath));
@@ -44432,20 +44451,24 @@ function registerDeployCommand(program3) {
44432
44451
  throw new Error("Invalid entry: no default export found");
44433
44452
  }
44434
44453
  new ResourceRegistry({ [orgName]: org });
44435
- const workflowCount = org.workflows?.length ?? 0;
44436
- const agentCount = org.agents?.length ?? 0;
44437
- const totalCount = workflowCount + agentCount;
44454
+ activeWorkflows = (org.workflows ?? []).filter((w) => !w.config.archived);
44455
+ activeAgents = (org.agents ?? []).filter((a) => !a.config.archived);
44456
+ const archivedCount = (org.workflows?.length ?? 0) + (org.agents?.length ?? 0) - activeWorkflows.length - activeAgents.length;
44457
+ const totalCount = activeWorkflows.length + activeAgents.length;
44438
44458
  validateSpinner.succeed(
44439
44459
  source_default.green("Validating...") + source_default.white(" done") + source_default.gray(` (${totalCount} resource${totalCount !== 1 ? "s" : ""}, 0 errors)`)
44440
44460
  );
44461
+ if (archivedCount > 0) {
44462
+ console.log(source_default.gray(` Skipping ${archivedCount} archived resource${archivedCount !== 1 ? "s" : ""}`));
44463
+ }
44441
44464
  console.log("");
44442
44465
  console.log(source_default.gray(` Org: ${orgName}`));
44443
44466
  console.log(source_default.gray(` Target: ${apiUrl} (${env2})`));
44444
44467
  console.log("");
44445
- for (const w of org.workflows ?? []) {
44468
+ for (const w of activeWorkflows) {
44446
44469
  console.log(source_default.gray(` workflow ${source_default.white(w.config.resourceId)} v${w.config.version}`));
44447
44470
  }
44448
- for (const a of org.agents ?? []) {
44471
+ for (const a of activeAgents) {
44449
44472
  console.log(source_default.gray(` agent ${source_default.white(a.config.resourceId)} v${a.config.version}`));
44450
44473
  }
44451
44474
  console.log("");
@@ -44489,7 +44512,7 @@ function registerDeployCommand(program3) {
44489
44512
  );
44490
44513
  }
44491
44514
  const schemaWarnings = [];
44492
- const workflows = (org.workflows ?? []).map((w) => {
44515
+ const workflows = activeWorkflows.map((w) => {
44493
44516
  const meta = {
44494
44517
  resourceId: w.config.resourceId,
44495
44518
  name: w.config.name,
@@ -44514,7 +44537,7 @@ function registerDeployCommand(program3) {
44514
44537
  }
44515
44538
  return meta;
44516
44539
  });
44517
- const agents = (org.agents ?? []).map((a) => {
44540
+ const agents = activeAgents.map((a) => {
44518
44541
  const meta = {
44519
44542
  resourceId: a.config.resourceId,
44520
44543
  name: a.config.name,
@@ -44615,7 +44638,7 @@ startWorker(org)
44615
44638
  }
44616
44639
  const result = await response.json();
44617
44640
  uploadSpinner.succeed(source_default.green("Uploading...") + source_default.white(" done"));
44618
- const totalResources = (org.workflows?.length ?? 0) + (org.agents?.length ?? 0);
44641
+ const totalResources = activeWorkflows.length + activeAgents.length;
44619
44642
  const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
44620
44643
  if (result.status === "active") {
44621
44644
  console.log("");
package/dist/index.d.ts CHANGED
@@ -488,6 +488,8 @@ interface SerializedAgentDefinition {
488
488
  version: string;
489
489
  type: 'agent';
490
490
  status: 'dev' | 'prod';
491
+ /** Whether this resource is archived and should be excluded from registration and deployment */
492
+ archived?: boolean;
491
493
  systemPrompt: string;
492
494
  constraints?: {
493
495
  maxIterations?: number;
@@ -503,7 +505,7 @@ interface SerializedAgentDefinition {
503
505
  model: string;
504
506
  apiKey: string;
505
507
  temperature: number;
506
- maxTokens: number;
508
+ maxOutputTokens: number;
507
509
  topP?: number;
508
510
  modelOptions?: Record<string, unknown>;
509
511
  };
@@ -541,6 +543,8 @@ interface SerializedWorkflowDefinition {
541
543
  version: string;
542
544
  type: 'workflow';
543
545
  status: 'dev' | 'prod';
546
+ /** Whether this resource is archived and should be excluded from registration and deployment */
547
+ archived?: boolean;
544
548
  };
545
549
  entryPoint: string;
546
550
  steps: Array<{
@@ -653,7 +657,8 @@ interface ModelConfig {
653
657
  provider: 'openai' | 'anthropic' | 'openrouter' | 'google' | 'mock';
654
658
  apiKey: string;
655
659
  temperature?: number;
656
- maxTokens?: number;
660
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
661
+ maxOutputTokens?: number;
657
662
  topP?: number;
658
663
  /**
659
664
  * Model-specific options (flat structure)
@@ -783,7 +788,8 @@ interface LLMMessage {
783
788
  interface LLMGenerateRequest {
784
789
  messages: LLMMessage[];
785
790
  responseSchema: unknown;
786
- maxTokens?: number;
791
+ /** Maximum output tokens per LLM call. NOT the model's context window — see ModelInfo.maxTokens for that. */
792
+ maxOutputTokens?: number;
787
793
  temperature?: number;
788
794
  topP?: number;
789
795
  signal?: AbortSignal;
@@ -5650,12 +5656,27 @@ interface ExecutionMetadata {
5650
5656
  * Unified message event type - covers all message types in sessions
5651
5657
  * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
5652
5658
  */
5659
+ /**
5660
+ * Structured action metadata attached to assistant messages.
5661
+ * Frontend reads this instead of parsing text prefixes.
5662
+ */
5663
+ type AssistantAction = {
5664
+ kind: 'navigate';
5665
+ path: string;
5666
+ reason: string;
5667
+ } | {
5668
+ kind: 'update_filters';
5669
+ timeRange: string | null;
5670
+ statusFilter: string | null;
5671
+ searchQuery: string | null;
5672
+ };
5653
5673
  type MessageEvent = {
5654
5674
  type: 'user_message';
5655
5675
  text: string;
5656
5676
  } | {
5657
5677
  type: 'assistant_message';
5658
5678
  text: string;
5679
+ _action?: AssistantAction;
5659
5680
  } | {
5660
5681
  type: 'agent:started';
5661
5682
  } | {
@@ -5791,6 +5812,8 @@ interface ResourceDefinition {
5791
5812
  sessionCapable?: boolean;
5792
5813
  /** Whether the resource is local (monorepo) or remote (externally deployed) */
5793
5814
  origin?: 'local' | 'remote';
5815
+ /** Whether this resource is archived and should be excluded from registration and deployment */
5816
+ archived?: boolean;
5794
5817
  }
5795
5818
  /**
5796
5819
  * Domain definition for Command View filtering
package/dist/index.js CHANGED
@@ -144,6 +144,7 @@ var DOMAIN_MAP = {
144
144
 
145
145
  // ../core/src/platform/registry/reserved.ts
146
146
  var RESERVED_RESOURCE_IDS = /* @__PURE__ */ new Set(["command-center-assistant"]);
147
+ Array.from(RESERVED_RESOURCE_IDS);
147
148
  function isReservedResourceId(resourceId) {
148
149
  return RESERVED_RESOURCE_IDS.has(resourceId);
149
150
  }
@@ -197,7 +198,7 @@ var GPT5ConfigSchema = z.object({
197
198
  apiKey: z.string(),
198
199
  temperature: z.literal(1),
199
200
  // Required to be exactly 1
200
- maxTokens: z.number().min(4e3).optional(),
201
+ maxOutputTokens: z.number().min(4e3).optional(),
201
202
  topP: z.number().min(0).max(1).optional(),
202
203
  modelOptions: GPT5OptionsSchema.optional()
203
204
  });
@@ -206,7 +207,7 @@ var MockConfigSchema = z.object({
206
207
  provider: z.enum(["mock"]),
207
208
  apiKey: z.string(),
208
209
  temperature: z.number().min(0).max(2).optional(),
209
- maxTokens: z.number().min(500).optional(),
210
+ maxOutputTokens: z.number().min(500).optional(),
210
211
  topP: z.number().min(0).max(1).optional(),
211
212
  modelOptions: z.object({}).strict().optional()
212
213
  // No options supported
@@ -226,7 +227,7 @@ var OpenRouterConfigSchema = z.object({
226
227
  provider: z.literal("openrouter"),
227
228
  apiKey: z.string(),
228
229
  temperature: z.number().min(0).max(2).optional(),
229
- maxTokens: z.number().min(500).optional(),
230
+ maxOutputTokens: z.number().min(500).optional(),
230
231
  topP: z.number().min(0).max(1).optional(),
231
232
  modelOptions: OpenRouterOptionsSchema.optional()
232
233
  });
@@ -240,7 +241,7 @@ var GoogleConfigSchema = z.object({
240
241
  apiKey: z.string(),
241
242
  temperature: z.literal(1).optional(),
242
243
  // Must be 1 for Gemini 3 (changing degrades performance)
243
- maxTokens: z.number().min(500).optional(),
244
+ maxOutputTokens: z.number().min(500).optional(),
244
245
  topP: z.number().min(0).max(1).optional(),
245
246
  modelOptions: GoogleOptionsSchema.optional()
246
247
  });
@@ -250,7 +251,7 @@ var AnthropicConfigSchema = z.object({
250
251
  provider: z.literal("anthropic"),
251
252
  apiKey: z.string(),
252
253
  temperature: z.number().min(0).max(1).optional(),
253
- maxTokens: z.number().min(1e3).optional(),
254
+ maxOutputTokens: z.number().min(1e3).optional(),
254
255
  // Anthropic requires max_tokens
255
256
  topP: z.number().min(0).max(1).optional(),
256
257
  modelOptions: AnthropicOptionsSchema.optional()
@@ -3160,6 +3161,17 @@ function buildEdges(resources) {
3160
3161
  }
3161
3162
 
3162
3163
  // ../core/src/platform/registry/resource-registry.ts
3164
+ function filterArchived(org) {
3165
+ return {
3166
+ ...org,
3167
+ workflows: org.workflows?.filter((w) => !w.config.archived),
3168
+ agents: org.agents?.filter((a) => !a.config.archived),
3169
+ triggers: org.triggers?.filter((t) => !t.archived),
3170
+ integrations: org.integrations?.filter((i) => !i.archived),
3171
+ externalResources: org.externalResources?.filter((e) => !e.archived),
3172
+ humanCheckpoints: org.humanCheckpoints?.filter((h) => !h.archived)
3173
+ };
3174
+ }
3163
3175
  var ResourceRegistry = class {
3164
3176
  constructor(registry) {
3165
3177
  this.registry = registry;
@@ -3291,6 +3303,7 @@ var ResourceRegistry = class {
3291
3303
  * @throws Error if incoming deployment contains duplicate resourceIds
3292
3304
  */
3293
3305
  registerOrganization(orgName, org, remote) {
3306
+ org = filterArchived(org);
3294
3307
  const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
3295
3308
  const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
3296
3309
  const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
@@ -3352,6 +3365,7 @@ var ResourceRegistry = class {
3352
3365
  * @param org - Resource definitions with real handlers (not stubs)
3353
3366
  */
3354
3367
  registerStaticResources(orgName, org) {
3368
+ org = filterArchived(org);
3355
3369
  const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
3356
3370
  const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
3357
3371
  const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
@@ -2282,7 +2282,9 @@ ${actionsList}
2282
2282
  - Batch independent tool calls in one iteration (faster execution)
2283
2283
  - Dependent operations need separate iterations (tool B needs tool A's result)
2284
2284
  - "complete" cannot mix with tool-call${includeNavigateKnowledge ? "/navigate-knowledge" : ""}${includeMessageAction ? `
2285
- - Always send at least one message before completing` : ""}
2285
+ - Always send at least one message before completing
2286
+ - When you have your answer, send message + complete in the SAME iteration. Never send a message alone then complete in a later iteration.
2287
+ - Never repeat or rephrase the same answer across iterations. One clear answer, then complete.` : ""}
2286
2288
 
2287
2289
  **Use "complete" when:**
2288
2290
  - Task finished successfully
@@ -2421,8 +2423,8 @@ function buildToolsPrompt(tools) {
2421
2423
  section += "To call a tool, return a tool-call action:\n";
2422
2424
  section += '{\n "type": "tool-call",\n "id": "unique-id",\n "name": "tool-name",\n "input": { /* tool input matching schema */ }\n}\n\n';
2423
2425
  section += "**IMPORTANT RULES:**\n";
2424
- section += '1. The "complete" action MUST be the ONLY action in nextActions when you want to finish\n';
2425
- section += "2. You CANNOT return tool-call or navigate-knowledge actions AND a complete action in the same response\n";
2426
+ section += '1. "complete" CANNOT mix with tool-call or navigate-knowledge actions in the same response\n';
2427
+ section += '2. "complete" CAN mix with message \u2014 always pair your final message with complete in the same iteration\n';
2426
2428
  section += "3. To use tools, return ONLY tool-call actions, then wait for results in the next iteration\n";
2427
2429
  section += "4. After receiving tool results, you can either call more tools OR complete with final answer\n";
2428
2430
  section += "5. navigate-knowledge actions load new capabilities - tools become available in the next iteration\n";
@@ -2551,10 +2553,13 @@ function buildReasoningRequest(iterationContext) {
2551
2553
  systemPrompt,
2552
2554
  tools: toolDefinitions,
2553
2555
  constraints: {
2554
- maxTokens: iterationContext.modelConfig.maxTokens,
2556
+ maxOutputTokens: iterationContext.modelConfig.maxOutputTokens,
2555
2557
  temperature: 1
2556
2558
  },
2557
- memoryContext: iterationContext.memoryManager.toContext(iterationContext.iteration, iterationContext.executionContext.sessionTurnNumber),
2559
+ memoryContext: iterationContext.memoryManager.toContext(
2560
+ iterationContext.iteration,
2561
+ iterationContext.executionContext.sessionTurnNumber
2562
+ ),
2558
2563
  includeMessageAction: isSessionCapable,
2559
2564
  includeNavigateKnowledge: hasKnowledgeMap,
2560
2565
  includeMemoryOps
@@ -2595,7 +2600,7 @@ var GPT5ConfigSchema = z.object({
2595
2600
  apiKey: z.string(),
2596
2601
  temperature: z.literal(1),
2597
2602
  // Required to be exactly 1
2598
- maxTokens: z.number().min(4e3).optional(),
2603
+ maxOutputTokens: z.number().min(4e3).optional(),
2599
2604
  topP: z.number().min(0).max(1).optional(),
2600
2605
  modelOptions: GPT5OptionsSchema.optional()
2601
2606
  });
@@ -2604,7 +2609,7 @@ var MockConfigSchema = z.object({
2604
2609
  provider: z.enum(["mock"]),
2605
2610
  apiKey: z.string(),
2606
2611
  temperature: z.number().min(0).max(2).optional(),
2607
- maxTokens: z.number().min(500).optional(),
2612
+ maxOutputTokens: z.number().min(500).optional(),
2608
2613
  topP: z.number().min(0).max(1).optional(),
2609
2614
  modelOptions: z.object({}).strict().optional()
2610
2615
  // No options supported
@@ -2624,7 +2629,7 @@ var OpenRouterConfigSchema = z.object({
2624
2629
  provider: z.literal("openrouter"),
2625
2630
  apiKey: z.string(),
2626
2631
  temperature: z.number().min(0).max(2).optional(),
2627
- maxTokens: z.number().min(500).optional(),
2632
+ maxOutputTokens: z.number().min(500).optional(),
2628
2633
  topP: z.number().min(0).max(1).optional(),
2629
2634
  modelOptions: OpenRouterOptionsSchema.optional()
2630
2635
  });
@@ -2638,7 +2643,7 @@ var GoogleConfigSchema = z.object({
2638
2643
  apiKey: z.string(),
2639
2644
  temperature: z.literal(1).optional(),
2640
2645
  // Must be 1 for Gemini 3 (changing degrades performance)
2641
- maxTokens: z.number().min(500).optional(),
2646
+ maxOutputTokens: z.number().min(500).optional(),
2642
2647
  topP: z.number().min(0).max(1).optional(),
2643
2648
  modelOptions: GoogleOptionsSchema.optional()
2644
2649
  });
@@ -2648,7 +2653,7 @@ var AnthropicConfigSchema = z.object({
2648
2653
  provider: z.literal("anthropic"),
2649
2654
  apiKey: z.string(),
2650
2655
  temperature: z.number().min(0).max(1).optional(),
2651
- maxTokens: z.number().min(1e3).optional(),
2656
+ maxOutputTokens: z.number().min(1e3).optional(),
2652
2657
  // Anthropic requires max_tokens
2653
2658
  topP: z.number().min(0).max(1).optional(),
2654
2659
  modelOptions: AnthropicOptionsSchema.optional()
@@ -2904,9 +2909,9 @@ var AgentIterationOutputSchema = z.object({
2904
2909
  memoryOps: MemoryOperationsSchema.optional(),
2905
2910
  nextActions: z.array(AgentActionSchema)
2906
2911
  });
2907
- function validateTokenConfiguration(model, maxTokens) {
2912
+ function validateTokenConfiguration(model, maxOutputTokens) {
2908
2913
  const modelInfo = getModelInfo(model);
2909
- const configured = maxTokens || 1e3;
2914
+ const configured = maxOutputTokens || 1e3;
2910
2915
  if (!modelInfo) {
2911
2916
  if (configured < 2e3) {
2912
2917
  throw new InsufficientTokensError(
@@ -2929,15 +2934,20 @@ function validateTokenConfiguration(model, maxTokens) {
2929
2934
  }
2930
2935
  }
2931
2936
  async function callLLMForAgentIteration(adapter, request) {
2932
- validateTokenConfiguration(request.model, request.constraints.maxTokens);
2937
+ validateTokenConfiguration(request.model, request.constraints.maxOutputTokens);
2933
2938
  const messages = [
2934
2939
  { role: "system", content: request.systemPrompt },
2935
2940
  { role: "user", content: request.memoryContext }
2936
2941
  ];
2937
2942
  const response = await adapter.generate({
2938
2943
  messages,
2939
- responseSchema: buildIterationResponseSchema(request.tools, request.includeMessageAction, request.includeNavigateKnowledge, request.includeMemoryOps),
2940
- maxTokens: request.constraints.maxTokens,
2944
+ responseSchema: buildIterationResponseSchema(
2945
+ request.tools,
2946
+ request.includeMessageAction,
2947
+ request.includeNavigateKnowledge,
2948
+ request.includeMemoryOps
2949
+ ),
2950
+ maxOutputTokens: request.constraints.maxOutputTokens,
2941
2951
  temperature: request.constraints.temperature,
2942
2952
  signal: request.signal
2943
2953
  });
@@ -2949,16 +2959,13 @@ async function callLLMForAgentIteration(adapter, request) {
2949
2959
  nextActions: validated.nextActions
2950
2960
  };
2951
2961
  } catch (error) {
2952
- throw new AgentOutputValidationError(
2953
- "Agent iteration output validation failed",
2954
- {
2955
- zodError: error instanceof ZodError ? error.format() : error
2956
- }
2957
- );
2962
+ throw new AgentOutputValidationError("Agent iteration output validation failed", {
2963
+ zodError: error instanceof ZodError ? error.format() : error
2964
+ });
2958
2965
  }
2959
2966
  }
2960
2967
  async function callLLMForAgentCompletion(adapter, request) {
2961
- validateTokenConfiguration(request.model, request.constraints.maxTokens);
2968
+ validateTokenConfiguration(request.model, request.constraints.maxOutputTokens);
2962
2969
  const response = await adapter.generate({
2963
2970
  messages: [
2964
2971
  { role: "system", content: request.systemPrompt },
@@ -2967,7 +2974,7 @@ async function callLLMForAgentCompletion(adapter, request) {
2967
2974
  responseSchema: request.outputSchema,
2968
2975
  // Use output schema directly
2969
2976
  temperature: request.constraints.temperature || 0.3,
2970
- maxTokens: request.constraints.maxTokens,
2977
+ maxOutputTokens: request.constraints.maxOutputTokens,
2971
2978
  signal: request.signal
2972
2979
  });
2973
2980
  return response.output;
@@ -3681,8 +3688,19 @@ function estimateTokens(text) {
3681
3688
  var MAX_SESSION_MEMORY_KEYS = 25;
3682
3689
  var MAX_MEMORY_TOKENS = 32e3;
3683
3690
  var MAX_SINGLE_ENTRY_TOKENS = 2e3;
3691
+ var MAX_TOOL_RESULT_TOKENS = 4e3;
3684
3692
 
3685
3693
  // ../core/src/execution/engine/agent/memory/manager.ts
3694
+ function truncateToolResult(content, maxTokens) {
3695
+ const estimated = estimateTokens(content);
3696
+ if (estimated <= maxTokens) return content;
3697
+ const maxChars = Math.floor(maxTokens * 3.5);
3698
+ const truncated = content.slice(0, maxChars);
3699
+ const omitted = estimated - maxTokens;
3700
+ return truncated + `
3701
+
3702
+ [Response truncated \u2014 estimated ${omitted} tokens omitted. Use more specific filters to get smaller results.]`;
3703
+ }
3686
3704
  var MemoryManager = class {
3687
3705
  constructor(memory, constraints = {}, logger) {
3688
3706
  this.memory = memory;
@@ -3750,17 +3768,31 @@ var MemoryManager = class {
3750
3768
  */
3751
3769
  addToHistory(entry) {
3752
3770
  if (entry.turnNumber === void 0 && entry.type !== "context") {
3753
- throw new AgentMemoryValidationError(
3754
- "turnNumber required for history entries (use null for session memory)",
3755
- {
3756
- entryType: entry.type,
3757
- missingField: "turnNumber",
3758
- iterationNumber: entry.iterationNumber
3759
- }
3760
- );
3771
+ throw new AgentMemoryValidationError("turnNumber required for history entries (use null for session memory)", {
3772
+ entryType: entry.type,
3773
+ missingField: "turnNumber",
3774
+ iterationNumber: entry.iterationNumber
3775
+ });
3776
+ }
3777
+ let content = entry.content;
3778
+ if (entry.type === "tool-result") {
3779
+ const before = content;
3780
+ content = truncateToolResult(content, MAX_TOOL_RESULT_TOKENS);
3781
+ if (content !== before) {
3782
+ const truncateTime = Date.now();
3783
+ this.logger?.action(
3784
+ "memory-tool-result-truncate",
3785
+ `Tool result truncated (${estimateTokens(before)} -> ${MAX_TOOL_RESULT_TOKENS} tokens)`,
3786
+ entry.iterationNumber ?? 0,
3787
+ truncateTime,
3788
+ truncateTime,
3789
+ 0
3790
+ );
3791
+ }
3761
3792
  }
3762
3793
  this.memory.history.push({
3763
3794
  ...entry,
3795
+ content,
3764
3796
  timestamp: Date.now()
3765
3797
  });
3766
3798
  this.autoCompact();
@@ -4416,7 +4448,7 @@ var Agent = class {
4416
4448
  memoryContext: this.memoryManager.toContext(this.iterationNumber, this.executionContext?.sessionTurnNumber),
4417
4449
  outputSchema,
4418
4450
  constraints: {
4419
- maxTokens: this.modelConfig.maxTokens,
4451
+ maxOutputTokens: this.modelConfig.maxOutputTokens,
4420
4452
  temperature
4421
4453
  },
4422
4454
  model: this.modelConfig.model,
@@ -4742,7 +4774,7 @@ var PostMessageLLMAdapter = class {
4742
4774
  messages: request.messages,
4743
4775
  responseSchema: request.responseSchema,
4744
4776
  temperature: request.temperature,
4745
- maxTokens: request.maxTokens
4777
+ maxOutputTokens: request.maxOutputTokens
4746
4778
  }
4747
4779
  });
4748
4780
  return { output: result };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevasis/sdk",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "description": "SDK for building Elevasis organization resources",
5
5
  "type": "module",
6
6
  "bin": {
@@ -81,7 +81,7 @@ The `/work` command manages in-progress task tracking across sessions. It uses `
81
81
  - **Auto-create** -- When the user describes work that doesn't match an existing task, the agent creates a task doc automatically. If intent is clear, it skips the interview; if ambiguous, it asks 1-2 focused questions.
82
82
  - **Auto-save** -- The agent saves progress silently when the conversation context is getting heavy, the user is wrapping up, or 2+ steps have been completed without saving. Updates progress markers, files modified, and resume context.
83
83
  - **Auto-resume** -- When the user picks an existing task (by number, name, or keyword), the agent loads context and resumes automatically.
84
- - **Suggest complete** -- When all plan steps are marked COMPLETE, the agent suggests finalizing: "All steps for '{task}' look done. Want me to finalize it?" It never auto-invokes completion. The complete flow validates readiness, cleans the doc (strips resume context, removes progress markers, targets 200-400 lines), determines destination in `docs/`, confirms with user, moves, and verifies.
84
+ - **Suggest complete** -- When all plan steps are marked COMPLETE, the agent suggests finalizing: "All steps for '`{task}`' look done. Want me to finalize it?" It never auto-invokes completion. The complete flow validates readiness, cleans the doc (strips resume context, removes progress markers, targets 200-400 lines), determines destination in `docs/`, confirms with user, moves, and verifies.
85
85
 
86
86
  **Directory conventions for `docs/in-progress/`:**
87
87