@elevasis/sdk 0.5.16 → 0.5.17
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 +33 -14
- package/dist/index.d.ts +26 -3
- package/dist/index.js +18 -5
- package/dist/worker/index.js +60 -30
- package/package.json +1 -1
- package/reference/framework/agent.mdx +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -40221,7 +40221,7 @@ var GPT5ConfigSchema = external_exports.object({
|
|
|
40221
40221
|
apiKey: external_exports.string(),
|
|
40222
40222
|
temperature: external_exports.literal(1),
|
|
40223
40223
|
// Required to be exactly 1
|
|
40224
|
-
|
|
40224
|
+
maxOutputTokens: external_exports.number().min(4e3).optional(),
|
|
40225
40225
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
40226
40226
|
modelOptions: GPT5OptionsSchema.optional()
|
|
40227
40227
|
});
|
|
@@ -40230,7 +40230,7 @@ var MockConfigSchema = external_exports.object({
|
|
|
40230
40230
|
provider: external_exports.enum(["mock"]),
|
|
40231
40231
|
apiKey: external_exports.string(),
|
|
40232
40232
|
temperature: external_exports.number().min(0).max(2).optional(),
|
|
40233
|
-
|
|
40233
|
+
maxOutputTokens: external_exports.number().min(500).optional(),
|
|
40234
40234
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
40235
40235
|
modelOptions: external_exports.object({}).strict().optional()
|
|
40236
40236
|
// No options supported
|
|
@@ -40250,7 +40250,7 @@ var OpenRouterConfigSchema = external_exports.object({
|
|
|
40250
40250
|
provider: external_exports.literal("openrouter"),
|
|
40251
40251
|
apiKey: external_exports.string(),
|
|
40252
40252
|
temperature: external_exports.number().min(0).max(2).optional(),
|
|
40253
|
-
|
|
40253
|
+
maxOutputTokens: external_exports.number().min(500).optional(),
|
|
40254
40254
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
40255
40255
|
modelOptions: OpenRouterOptionsSchema.optional()
|
|
40256
40256
|
});
|
|
@@ -40264,7 +40264,7 @@ var GoogleConfigSchema = external_exports.object({
|
|
|
40264
40264
|
apiKey: external_exports.string(),
|
|
40265
40265
|
temperature: external_exports.literal(1).optional(),
|
|
40266
40266
|
// Must be 1 for Gemini 3 (changing degrades performance)
|
|
40267
|
-
|
|
40267
|
+
maxOutputTokens: external_exports.number().min(500).optional(),
|
|
40268
40268
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
40269
40269
|
modelOptions: GoogleOptionsSchema.optional()
|
|
40270
40270
|
});
|
|
@@ -40274,7 +40274,7 @@ var AnthropicConfigSchema = external_exports.object({
|
|
|
40274
40274
|
provider: external_exports.literal("anthropic"),
|
|
40275
40275
|
apiKey: external_exports.string(),
|
|
40276
40276
|
temperature: external_exports.number().min(0).max(1).optional(),
|
|
40277
|
-
|
|
40277
|
+
maxOutputTokens: external_exports.number().min(1e3).optional(),
|
|
40278
40278
|
// Anthropic requires max_tokens
|
|
40279
40279
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
40280
40280
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
@@ -43228,6 +43228,17 @@ function buildEdges(resources) {
|
|
|
43228
43228
|
}
|
|
43229
43229
|
|
|
43230
43230
|
// ../core/src/platform/registry/resource-registry.ts
|
|
43231
|
+
function filterArchived(org) {
|
|
43232
|
+
return {
|
|
43233
|
+
...org,
|
|
43234
|
+
workflows: org.workflows?.filter((w) => !w.config.archived),
|
|
43235
|
+
agents: org.agents?.filter((a) => !a.config.archived),
|
|
43236
|
+
triggers: org.triggers?.filter((t) => !t.archived),
|
|
43237
|
+
integrations: org.integrations?.filter((i) => !i.archived),
|
|
43238
|
+
externalResources: org.externalResources?.filter((e) => !e.archived),
|
|
43239
|
+
humanCheckpoints: org.humanCheckpoints?.filter((h) => !h.archived)
|
|
43240
|
+
};
|
|
43241
|
+
}
|
|
43231
43242
|
var ResourceRegistry = class {
|
|
43232
43243
|
constructor(registry2) {
|
|
43233
43244
|
this.registry = registry2;
|
|
@@ -43359,6 +43370,7 @@ var ResourceRegistry = class {
|
|
|
43359
43370
|
* @throws Error if incoming deployment contains duplicate resourceIds
|
|
43360
43371
|
*/
|
|
43361
43372
|
registerOrganization(orgName, org, remote) {
|
|
43373
|
+
org = filterArchived(org);
|
|
43362
43374
|
const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
|
|
43363
43375
|
const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
|
|
43364
43376
|
const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
|
|
@@ -43420,6 +43432,7 @@ var ResourceRegistry = class {
|
|
|
43420
43432
|
* @param org - Resource definitions with real handlers (not stubs)
|
|
43421
43433
|
*/
|
|
43422
43434
|
registerStaticResources(orgName, org) {
|
|
43435
|
+
org = filterArchived(org);
|
|
43423
43436
|
const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
|
|
43424
43437
|
const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
|
|
43425
43438
|
const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
|
|
@@ -43851,7 +43864,7 @@ async function apiDelete(endpoint, apiUrl = resolveApiUrl()) {
|
|
|
43851
43864
|
// package.json
|
|
43852
43865
|
var package_default = {
|
|
43853
43866
|
name: "@elevasis/sdk",
|
|
43854
|
-
version: "0.5.
|
|
43867
|
+
version: "0.5.17",
|
|
43855
43868
|
description: "SDK for building Elevasis organization resources",
|
|
43856
43869
|
type: "module",
|
|
43857
43870
|
bin: {
|
|
@@ -44422,6 +44435,8 @@ function registerDeployCommand(program3) {
|
|
|
44422
44435
|
}
|
|
44423
44436
|
const validateSpinner = ora("Validating...").start();
|
|
44424
44437
|
let org;
|
|
44438
|
+
let activeWorkflows = [];
|
|
44439
|
+
let activeAgents = [];
|
|
44425
44440
|
try {
|
|
44426
44441
|
const jiti = (0, import_jiti.createJiti)(import_meta.url);
|
|
44427
44442
|
const entryModule = await jiti.import((0, import_path.resolve)(entryPath));
|
|
@@ -44432,20 +44447,24 @@ function registerDeployCommand(program3) {
|
|
|
44432
44447
|
throw new Error("Invalid entry: no default export found");
|
|
44433
44448
|
}
|
|
44434
44449
|
new ResourceRegistry({ [orgName]: org });
|
|
44435
|
-
|
|
44436
|
-
|
|
44437
|
-
const
|
|
44450
|
+
activeWorkflows = (org.workflows ?? []).filter((w) => !w.config.archived);
|
|
44451
|
+
activeAgents = (org.agents ?? []).filter((a) => !a.config.archived);
|
|
44452
|
+
const archivedCount = (org.workflows?.length ?? 0) + (org.agents?.length ?? 0) - activeWorkflows.length - activeAgents.length;
|
|
44453
|
+
const totalCount = activeWorkflows.length + activeAgents.length;
|
|
44438
44454
|
validateSpinner.succeed(
|
|
44439
44455
|
source_default.green("Validating...") + source_default.white(" done") + source_default.gray(` (${totalCount} resource${totalCount !== 1 ? "s" : ""}, 0 errors)`)
|
|
44440
44456
|
);
|
|
44457
|
+
if (archivedCount > 0) {
|
|
44458
|
+
console.log(source_default.gray(` Skipping ${archivedCount} archived resource${archivedCount !== 1 ? "s" : ""}`));
|
|
44459
|
+
}
|
|
44441
44460
|
console.log("");
|
|
44442
44461
|
console.log(source_default.gray(` Org: ${orgName}`));
|
|
44443
44462
|
console.log(source_default.gray(` Target: ${apiUrl} (${env2})`));
|
|
44444
44463
|
console.log("");
|
|
44445
|
-
for (const w of
|
|
44464
|
+
for (const w of activeWorkflows) {
|
|
44446
44465
|
console.log(source_default.gray(` workflow ${source_default.white(w.config.resourceId)} v${w.config.version}`));
|
|
44447
44466
|
}
|
|
44448
|
-
for (const a of
|
|
44467
|
+
for (const a of activeAgents) {
|
|
44449
44468
|
console.log(source_default.gray(` agent ${source_default.white(a.config.resourceId)} v${a.config.version}`));
|
|
44450
44469
|
}
|
|
44451
44470
|
console.log("");
|
|
@@ -44489,7 +44508,7 @@ function registerDeployCommand(program3) {
|
|
|
44489
44508
|
);
|
|
44490
44509
|
}
|
|
44491
44510
|
const schemaWarnings = [];
|
|
44492
|
-
const workflows =
|
|
44511
|
+
const workflows = activeWorkflows.map((w) => {
|
|
44493
44512
|
const meta = {
|
|
44494
44513
|
resourceId: w.config.resourceId,
|
|
44495
44514
|
name: w.config.name,
|
|
@@ -44514,7 +44533,7 @@ function registerDeployCommand(program3) {
|
|
|
44514
44533
|
}
|
|
44515
44534
|
return meta;
|
|
44516
44535
|
});
|
|
44517
|
-
const agents =
|
|
44536
|
+
const agents = activeAgents.map((a) => {
|
|
44518
44537
|
const meta = {
|
|
44519
44538
|
resourceId: a.config.resourceId,
|
|
44520
44539
|
name: a.config.name,
|
|
@@ -44615,7 +44634,7 @@ startWorker(org)
|
|
|
44615
44634
|
}
|
|
44616
44635
|
const result = await response.json();
|
|
44617
44636
|
uploadSpinner.succeed(source_default.green("Uploading...") + source_default.white(" done"));
|
|
44618
|
-
const totalResources =
|
|
44637
|
+
const totalResources = activeWorkflows.length + activeAgents.length;
|
|
44619
44638
|
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
44620
44639
|
if (result.status === "active") {
|
|
44621
44640
|
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
|
-
|
|
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
|
|
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
|
|
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
|
@@ -197,7 +197,7 @@ var GPT5ConfigSchema = z.object({
|
|
|
197
197
|
apiKey: z.string(),
|
|
198
198
|
temperature: z.literal(1),
|
|
199
199
|
// Required to be exactly 1
|
|
200
|
-
|
|
200
|
+
maxOutputTokens: z.number().min(4e3).optional(),
|
|
201
201
|
topP: z.number().min(0).max(1).optional(),
|
|
202
202
|
modelOptions: GPT5OptionsSchema.optional()
|
|
203
203
|
});
|
|
@@ -206,7 +206,7 @@ var MockConfigSchema = z.object({
|
|
|
206
206
|
provider: z.enum(["mock"]),
|
|
207
207
|
apiKey: z.string(),
|
|
208
208
|
temperature: z.number().min(0).max(2).optional(),
|
|
209
|
-
|
|
209
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
210
210
|
topP: z.number().min(0).max(1).optional(),
|
|
211
211
|
modelOptions: z.object({}).strict().optional()
|
|
212
212
|
// No options supported
|
|
@@ -226,7 +226,7 @@ var OpenRouterConfigSchema = z.object({
|
|
|
226
226
|
provider: z.literal("openrouter"),
|
|
227
227
|
apiKey: z.string(),
|
|
228
228
|
temperature: z.number().min(0).max(2).optional(),
|
|
229
|
-
|
|
229
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
230
230
|
topP: z.number().min(0).max(1).optional(),
|
|
231
231
|
modelOptions: OpenRouterOptionsSchema.optional()
|
|
232
232
|
});
|
|
@@ -240,7 +240,7 @@ var GoogleConfigSchema = z.object({
|
|
|
240
240
|
apiKey: z.string(),
|
|
241
241
|
temperature: z.literal(1).optional(),
|
|
242
242
|
// Must be 1 for Gemini 3 (changing degrades performance)
|
|
243
|
-
|
|
243
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
244
244
|
topP: z.number().min(0).max(1).optional(),
|
|
245
245
|
modelOptions: GoogleOptionsSchema.optional()
|
|
246
246
|
});
|
|
@@ -250,7 +250,7 @@ var AnthropicConfigSchema = z.object({
|
|
|
250
250
|
provider: z.literal("anthropic"),
|
|
251
251
|
apiKey: z.string(),
|
|
252
252
|
temperature: z.number().min(0).max(1).optional(),
|
|
253
|
-
|
|
253
|
+
maxOutputTokens: z.number().min(1e3).optional(),
|
|
254
254
|
// Anthropic requires max_tokens
|
|
255
255
|
topP: z.number().min(0).max(1).optional(),
|
|
256
256
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
@@ -3160,6 +3160,17 @@ function buildEdges(resources) {
|
|
|
3160
3160
|
}
|
|
3161
3161
|
|
|
3162
3162
|
// ../core/src/platform/registry/resource-registry.ts
|
|
3163
|
+
function filterArchived(org) {
|
|
3164
|
+
return {
|
|
3165
|
+
...org,
|
|
3166
|
+
workflows: org.workflows?.filter((w) => !w.config.archived),
|
|
3167
|
+
agents: org.agents?.filter((a) => !a.config.archived),
|
|
3168
|
+
triggers: org.triggers?.filter((t) => !t.archived),
|
|
3169
|
+
integrations: org.integrations?.filter((i) => !i.archived),
|
|
3170
|
+
externalResources: org.externalResources?.filter((e) => !e.archived),
|
|
3171
|
+
humanCheckpoints: org.humanCheckpoints?.filter((h) => !h.archived)
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3163
3174
|
var ResourceRegistry = class {
|
|
3164
3175
|
constructor(registry) {
|
|
3165
3176
|
this.registry = registry;
|
|
@@ -3291,6 +3302,7 @@ var ResourceRegistry = class {
|
|
|
3291
3302
|
* @throws Error if incoming deployment contains duplicate resourceIds
|
|
3292
3303
|
*/
|
|
3293
3304
|
registerOrganization(orgName, org, remote) {
|
|
3305
|
+
org = filterArchived(org);
|
|
3294
3306
|
const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
|
|
3295
3307
|
const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
|
|
3296
3308
|
const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
|
|
@@ -3352,6 +3364,7 @@ var ResourceRegistry = class {
|
|
|
3352
3364
|
* @param org - Resource definitions with real handlers (not stubs)
|
|
3353
3365
|
*/
|
|
3354
3366
|
registerStaticResources(orgName, org) {
|
|
3367
|
+
org = filterArchived(org);
|
|
3355
3368
|
const incomingWorkflowIds = (org.workflows ?? []).map((w) => w.config.resourceId);
|
|
3356
3369
|
const incomingAgentIds = (org.agents ?? []).map((a) => a.config.resourceId);
|
|
3357
3370
|
const incomingIds = [...incomingWorkflowIds, ...incomingAgentIds];
|
package/dist/worker/index.js
CHANGED
|
@@ -2551,10 +2551,13 @@ function buildReasoningRequest(iterationContext) {
|
|
|
2551
2551
|
systemPrompt,
|
|
2552
2552
|
tools: toolDefinitions,
|
|
2553
2553
|
constraints: {
|
|
2554
|
-
|
|
2554
|
+
maxOutputTokens: iterationContext.modelConfig.maxOutputTokens,
|
|
2555
2555
|
temperature: 1
|
|
2556
2556
|
},
|
|
2557
|
-
memoryContext: iterationContext.memoryManager.toContext(
|
|
2557
|
+
memoryContext: iterationContext.memoryManager.toContext(
|
|
2558
|
+
iterationContext.iteration,
|
|
2559
|
+
iterationContext.executionContext.sessionTurnNumber
|
|
2560
|
+
),
|
|
2558
2561
|
includeMessageAction: isSessionCapable,
|
|
2559
2562
|
includeNavigateKnowledge: hasKnowledgeMap,
|
|
2560
2563
|
includeMemoryOps
|
|
@@ -2595,7 +2598,7 @@ var GPT5ConfigSchema = z.object({
|
|
|
2595
2598
|
apiKey: z.string(),
|
|
2596
2599
|
temperature: z.literal(1),
|
|
2597
2600
|
// Required to be exactly 1
|
|
2598
|
-
|
|
2601
|
+
maxOutputTokens: z.number().min(4e3).optional(),
|
|
2599
2602
|
topP: z.number().min(0).max(1).optional(),
|
|
2600
2603
|
modelOptions: GPT5OptionsSchema.optional()
|
|
2601
2604
|
});
|
|
@@ -2604,7 +2607,7 @@ var MockConfigSchema = z.object({
|
|
|
2604
2607
|
provider: z.enum(["mock"]),
|
|
2605
2608
|
apiKey: z.string(),
|
|
2606
2609
|
temperature: z.number().min(0).max(2).optional(),
|
|
2607
|
-
|
|
2610
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
2608
2611
|
topP: z.number().min(0).max(1).optional(),
|
|
2609
2612
|
modelOptions: z.object({}).strict().optional()
|
|
2610
2613
|
// No options supported
|
|
@@ -2624,7 +2627,7 @@ var OpenRouterConfigSchema = z.object({
|
|
|
2624
2627
|
provider: z.literal("openrouter"),
|
|
2625
2628
|
apiKey: z.string(),
|
|
2626
2629
|
temperature: z.number().min(0).max(2).optional(),
|
|
2627
|
-
|
|
2630
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
2628
2631
|
topP: z.number().min(0).max(1).optional(),
|
|
2629
2632
|
modelOptions: OpenRouterOptionsSchema.optional()
|
|
2630
2633
|
});
|
|
@@ -2638,7 +2641,7 @@ var GoogleConfigSchema = z.object({
|
|
|
2638
2641
|
apiKey: z.string(),
|
|
2639
2642
|
temperature: z.literal(1).optional(),
|
|
2640
2643
|
// Must be 1 for Gemini 3 (changing degrades performance)
|
|
2641
|
-
|
|
2644
|
+
maxOutputTokens: z.number().min(500).optional(),
|
|
2642
2645
|
topP: z.number().min(0).max(1).optional(),
|
|
2643
2646
|
modelOptions: GoogleOptionsSchema.optional()
|
|
2644
2647
|
});
|
|
@@ -2648,7 +2651,7 @@ var AnthropicConfigSchema = z.object({
|
|
|
2648
2651
|
provider: z.literal("anthropic"),
|
|
2649
2652
|
apiKey: z.string(),
|
|
2650
2653
|
temperature: z.number().min(0).max(1).optional(),
|
|
2651
|
-
|
|
2654
|
+
maxOutputTokens: z.number().min(1e3).optional(),
|
|
2652
2655
|
// Anthropic requires max_tokens
|
|
2653
2656
|
topP: z.number().min(0).max(1).optional(),
|
|
2654
2657
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
@@ -2904,9 +2907,9 @@ var AgentIterationOutputSchema = z.object({
|
|
|
2904
2907
|
memoryOps: MemoryOperationsSchema.optional(),
|
|
2905
2908
|
nextActions: z.array(AgentActionSchema)
|
|
2906
2909
|
});
|
|
2907
|
-
function validateTokenConfiguration(model,
|
|
2910
|
+
function validateTokenConfiguration(model, maxOutputTokens) {
|
|
2908
2911
|
const modelInfo = getModelInfo(model);
|
|
2909
|
-
const configured =
|
|
2912
|
+
const configured = maxOutputTokens || 1e3;
|
|
2910
2913
|
if (!modelInfo) {
|
|
2911
2914
|
if (configured < 2e3) {
|
|
2912
2915
|
throw new InsufficientTokensError(
|
|
@@ -2929,15 +2932,20 @@ function validateTokenConfiguration(model, maxTokens) {
|
|
|
2929
2932
|
}
|
|
2930
2933
|
}
|
|
2931
2934
|
async function callLLMForAgentIteration(adapter, request) {
|
|
2932
|
-
validateTokenConfiguration(request.model, request.constraints.
|
|
2935
|
+
validateTokenConfiguration(request.model, request.constraints.maxOutputTokens);
|
|
2933
2936
|
const messages = [
|
|
2934
2937
|
{ role: "system", content: request.systemPrompt },
|
|
2935
2938
|
{ role: "user", content: request.memoryContext }
|
|
2936
2939
|
];
|
|
2937
2940
|
const response = await adapter.generate({
|
|
2938
2941
|
messages,
|
|
2939
|
-
responseSchema: buildIterationResponseSchema(
|
|
2940
|
-
|
|
2942
|
+
responseSchema: buildIterationResponseSchema(
|
|
2943
|
+
request.tools,
|
|
2944
|
+
request.includeMessageAction,
|
|
2945
|
+
request.includeNavigateKnowledge,
|
|
2946
|
+
request.includeMemoryOps
|
|
2947
|
+
),
|
|
2948
|
+
maxOutputTokens: request.constraints.maxOutputTokens,
|
|
2941
2949
|
temperature: request.constraints.temperature,
|
|
2942
2950
|
signal: request.signal
|
|
2943
2951
|
});
|
|
@@ -2949,16 +2957,13 @@ async function callLLMForAgentIteration(adapter, request) {
|
|
|
2949
2957
|
nextActions: validated.nextActions
|
|
2950
2958
|
};
|
|
2951
2959
|
} catch (error) {
|
|
2952
|
-
throw new AgentOutputValidationError(
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
zodError: error instanceof ZodError ? error.format() : error
|
|
2956
|
-
}
|
|
2957
|
-
);
|
|
2960
|
+
throw new AgentOutputValidationError("Agent iteration output validation failed", {
|
|
2961
|
+
zodError: error instanceof ZodError ? error.format() : error
|
|
2962
|
+
});
|
|
2958
2963
|
}
|
|
2959
2964
|
}
|
|
2960
2965
|
async function callLLMForAgentCompletion(adapter, request) {
|
|
2961
|
-
validateTokenConfiguration(request.model, request.constraints.
|
|
2966
|
+
validateTokenConfiguration(request.model, request.constraints.maxOutputTokens);
|
|
2962
2967
|
const response = await adapter.generate({
|
|
2963
2968
|
messages: [
|
|
2964
2969
|
{ role: "system", content: request.systemPrompt },
|
|
@@ -2967,7 +2972,7 @@ async function callLLMForAgentCompletion(adapter, request) {
|
|
|
2967
2972
|
responseSchema: request.outputSchema,
|
|
2968
2973
|
// Use output schema directly
|
|
2969
2974
|
temperature: request.constraints.temperature || 0.3,
|
|
2970
|
-
|
|
2975
|
+
maxOutputTokens: request.constraints.maxOutputTokens,
|
|
2971
2976
|
signal: request.signal
|
|
2972
2977
|
});
|
|
2973
2978
|
return response.output;
|
|
@@ -3681,8 +3686,19 @@ function estimateTokens(text) {
|
|
|
3681
3686
|
var MAX_SESSION_MEMORY_KEYS = 25;
|
|
3682
3687
|
var MAX_MEMORY_TOKENS = 32e3;
|
|
3683
3688
|
var MAX_SINGLE_ENTRY_TOKENS = 2e3;
|
|
3689
|
+
var MAX_TOOL_RESULT_TOKENS = 4e3;
|
|
3684
3690
|
|
|
3685
3691
|
// ../core/src/execution/engine/agent/memory/manager.ts
|
|
3692
|
+
function truncateToolResult(content, maxTokens) {
|
|
3693
|
+
const estimated = estimateTokens(content);
|
|
3694
|
+
if (estimated <= maxTokens) return content;
|
|
3695
|
+
const maxChars = Math.floor(maxTokens * 3.5);
|
|
3696
|
+
const truncated = content.slice(0, maxChars);
|
|
3697
|
+
const omitted = estimated - maxTokens;
|
|
3698
|
+
return truncated + `
|
|
3699
|
+
|
|
3700
|
+
[Response truncated \u2014 estimated ${omitted} tokens omitted. Use more specific filters to get smaller results.]`;
|
|
3701
|
+
}
|
|
3686
3702
|
var MemoryManager = class {
|
|
3687
3703
|
constructor(memory, constraints = {}, logger) {
|
|
3688
3704
|
this.memory = memory;
|
|
@@ -3750,17 +3766,31 @@ var MemoryManager = class {
|
|
|
3750
3766
|
*/
|
|
3751
3767
|
addToHistory(entry) {
|
|
3752
3768
|
if (entry.turnNumber === void 0 && entry.type !== "context") {
|
|
3753
|
-
throw new AgentMemoryValidationError(
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3769
|
+
throw new AgentMemoryValidationError("turnNumber required for history entries (use null for session memory)", {
|
|
3770
|
+
entryType: entry.type,
|
|
3771
|
+
missingField: "turnNumber",
|
|
3772
|
+
iterationNumber: entry.iterationNumber
|
|
3773
|
+
});
|
|
3774
|
+
}
|
|
3775
|
+
let content = entry.content;
|
|
3776
|
+
if (entry.type === "tool-result") {
|
|
3777
|
+
const before = content;
|
|
3778
|
+
content = truncateToolResult(content, MAX_TOOL_RESULT_TOKENS);
|
|
3779
|
+
if (content !== before) {
|
|
3780
|
+
const truncateTime = Date.now();
|
|
3781
|
+
this.logger?.action(
|
|
3782
|
+
"memory-tool-result-truncate",
|
|
3783
|
+
`Tool result truncated (${estimateTokens(before)} -> ${MAX_TOOL_RESULT_TOKENS} tokens)`,
|
|
3784
|
+
entry.iterationNumber ?? 0,
|
|
3785
|
+
truncateTime,
|
|
3786
|
+
truncateTime,
|
|
3787
|
+
0
|
|
3788
|
+
);
|
|
3789
|
+
}
|
|
3761
3790
|
}
|
|
3762
3791
|
this.memory.history.push({
|
|
3763
3792
|
...entry,
|
|
3793
|
+
content,
|
|
3764
3794
|
timestamp: Date.now()
|
|
3765
3795
|
});
|
|
3766
3796
|
this.autoCompact();
|
|
@@ -4416,7 +4446,7 @@ var Agent = class {
|
|
|
4416
4446
|
memoryContext: this.memoryManager.toContext(this.iterationNumber, this.executionContext?.sessionTurnNumber),
|
|
4417
4447
|
outputSchema,
|
|
4418
4448
|
constraints: {
|
|
4419
|
-
|
|
4449
|
+
maxOutputTokens: this.modelConfig.maxOutputTokens,
|
|
4420
4450
|
temperature
|
|
4421
4451
|
},
|
|
4422
4452
|
model: this.modelConfig.model,
|
|
@@ -4742,7 +4772,7 @@ var PostMessageLLMAdapter = class {
|
|
|
4742
4772
|
messages: request.messages,
|
|
4743
4773
|
responseSchema: request.responseSchema,
|
|
4744
4774
|
temperature: request.temperature,
|
|
4745
|
-
|
|
4775
|
+
maxOutputTokens: request.maxOutputTokens
|
|
4746
4776
|
}
|
|
4747
4777
|
});
|
|
4748
4778
|
return { output: result };
|
package/package.json
CHANGED
|
@@ -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
|
|