@runtypelabs/sdk 1.7.3 → 1.8.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.
- package/dist/index.cjs +239 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +238 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -445,6 +445,7 @@ interface DeploySandboxRequest {
|
|
|
445
445
|
port?: number;
|
|
446
446
|
sandboxId?: string;
|
|
447
447
|
startCommand?: string;
|
|
448
|
+
files?: Record<string, string>;
|
|
448
449
|
}
|
|
449
450
|
interface DeploySandboxResponse {
|
|
450
451
|
sandboxId: string;
|
|
@@ -4119,6 +4120,8 @@ interface AgentExecuteRequest {
|
|
|
4119
4120
|
/** Runtime tools to make available during execution */
|
|
4120
4121
|
tools?: {
|
|
4121
4122
|
runtimeTools?: AgentRuntimeToolDefinition[];
|
|
4123
|
+
/** IDs of built-in tools to enable (e.g., "exa", "firecrawl", "dalle") */
|
|
4124
|
+
toolIds?: string[];
|
|
4122
4125
|
};
|
|
4123
4126
|
}
|
|
4124
4127
|
/**
|
|
@@ -4129,6 +4132,10 @@ interface AgentExecuteResponse {
|
|
|
4129
4132
|
result: string;
|
|
4130
4133
|
iterations: number;
|
|
4131
4134
|
totalCost: number;
|
|
4135
|
+
totalTokens?: {
|
|
4136
|
+
input: number;
|
|
4137
|
+
output: number;
|
|
4138
|
+
};
|
|
4132
4139
|
stopReason: 'complete' | 'end_turn' | 'max_turns' | 'max_cost' | 'timeout' | 'error';
|
|
4133
4140
|
reflections?: string[];
|
|
4134
4141
|
error?: string;
|
|
@@ -4177,6 +4184,11 @@ interface RunTaskSessionSummary {
|
|
|
4177
4184
|
index: number;
|
|
4178
4185
|
/** Cost of this individual session (USD) */
|
|
4179
4186
|
cost: number;
|
|
4187
|
+
/** Token counts for this session */
|
|
4188
|
+
totalTokens?: {
|
|
4189
|
+
input: number;
|
|
4190
|
+
output: number;
|
|
4191
|
+
};
|
|
4180
4192
|
/** Number of loop iterations in this session */
|
|
4181
4193
|
iterations: number;
|
|
4182
4194
|
/** Why this session stopped */
|
|
@@ -4217,6 +4229,11 @@ interface RunTaskState {
|
|
|
4217
4229
|
sessionCount: number;
|
|
4218
4230
|
/** Total cost across all sessions (USD) */
|
|
4219
4231
|
totalCost: number;
|
|
4232
|
+
/** Total tokens across all sessions */
|
|
4233
|
+
totalTokens?: {
|
|
4234
|
+
input: number;
|
|
4235
|
+
output: number;
|
|
4236
|
+
};
|
|
4220
4237
|
/** Last agent output (full text) */
|
|
4221
4238
|
lastOutput: string;
|
|
4222
4239
|
/** Last terminal error captured from agent execution */
|
|
@@ -4330,6 +4347,8 @@ interface RunTaskOptions {
|
|
|
4330
4347
|
toolWindow?: 'session' | number;
|
|
4331
4348
|
/** Custom workflow definition (defaults to the built-in research→planning→execution workflow) */
|
|
4332
4349
|
workflow?: WorkflowDefinition;
|
|
4350
|
+
/** IDs of built-in tools to enable for the agent (e.g., "exa", "firecrawl", "dalle") */
|
|
4351
|
+
toolIds?: string[];
|
|
4333
4352
|
}
|
|
4334
4353
|
/**
|
|
4335
4354
|
* Final result returned by `agents.runTask()`
|
|
@@ -4338,6 +4357,10 @@ interface RunTaskResult {
|
|
|
4338
4357
|
status: RunTaskStatus;
|
|
4339
4358
|
sessionCount: number;
|
|
4340
4359
|
totalCost: number;
|
|
4360
|
+
totalTokens?: {
|
|
4361
|
+
input: number;
|
|
4362
|
+
output: number;
|
|
4363
|
+
};
|
|
4341
4364
|
lastOutput: string;
|
|
4342
4365
|
sessions: RunTaskSessionSummary[];
|
|
4343
4366
|
/** The record ID if trackProgress was enabled */
|
|
@@ -5127,6 +5150,31 @@ declare const defaultWorkflow: WorkflowDefinition;
|
|
|
5127
5150
|
|
|
5128
5151
|
declare const deployWorkflow: WorkflowDefinition;
|
|
5129
5152
|
|
|
5153
|
+
/**
|
|
5154
|
+
* Game workflow: design → build → verify.
|
|
5155
|
+
*
|
|
5156
|
+
* A three-phase workflow for tasks where the goal is to build a game
|
|
5157
|
+
* (Three.js, Phaser, WebGL, etc.) and deploy it to a Daytona sandbox.
|
|
5158
|
+
*
|
|
5159
|
+
* The key difference from the deploy workflow is that game code often
|
|
5160
|
+
* uses template literals, which break when embedded inside Express
|
|
5161
|
+
* `res.send()` template literals. This workflow instructs the agent to
|
|
5162
|
+
* use the `files` parameter for multi-file deployment (Express static
|
|
5163
|
+
* server + separate HTML/JS/CSS files).
|
|
5164
|
+
*
|
|
5165
|
+
* Phase 1 (design): Understand game requirements. Auto-advances after
|
|
5166
|
+
* the first session.
|
|
5167
|
+
*
|
|
5168
|
+
* Phase 2 (build): Write game code using multi-file deployment. The
|
|
5169
|
+
* agent uses `code` for a minimal Express static server and `files`
|
|
5170
|
+
* for the actual game assets (HTML, JS, CSS).
|
|
5171
|
+
*
|
|
5172
|
+
* Phase 3 (verify): Confirm the game is running and playable. Auto-
|
|
5173
|
+
* accepts completion when deploy_sandbox has succeeded.
|
|
5174
|
+
*/
|
|
5175
|
+
|
|
5176
|
+
declare const gameWorkflow: WorkflowDefinition;
|
|
5177
|
+
|
|
5130
5178
|
/**
|
|
5131
5179
|
* Utility functions shared between workflow phase handlers and AgentsEndpoint.
|
|
5132
5180
|
*
|
|
@@ -5144,4 +5192,4 @@ declare function getLikelySupportingCandidatePaths(bestCandidatePath: string | u
|
|
|
5144
5192
|
declare function getDefaultPlanPath(taskName: string): string;
|
|
5145
5193
|
declare function sanitizeTaskSlug(taskName: string): string;
|
|
5146
5194
|
|
|
5147
|
-
export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionLoopSnapshotSlice, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContinuation, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
|
|
5195
|
+
export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionLoopSnapshotSlice, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContinuation, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
|
package/dist/index.d.ts
CHANGED
|
@@ -445,6 +445,7 @@ interface DeploySandboxRequest {
|
|
|
445
445
|
port?: number;
|
|
446
446
|
sandboxId?: string;
|
|
447
447
|
startCommand?: string;
|
|
448
|
+
files?: Record<string, string>;
|
|
448
449
|
}
|
|
449
450
|
interface DeploySandboxResponse {
|
|
450
451
|
sandboxId: string;
|
|
@@ -4119,6 +4120,8 @@ interface AgentExecuteRequest {
|
|
|
4119
4120
|
/** Runtime tools to make available during execution */
|
|
4120
4121
|
tools?: {
|
|
4121
4122
|
runtimeTools?: AgentRuntimeToolDefinition[];
|
|
4123
|
+
/** IDs of built-in tools to enable (e.g., "exa", "firecrawl", "dalle") */
|
|
4124
|
+
toolIds?: string[];
|
|
4122
4125
|
};
|
|
4123
4126
|
}
|
|
4124
4127
|
/**
|
|
@@ -4129,6 +4132,10 @@ interface AgentExecuteResponse {
|
|
|
4129
4132
|
result: string;
|
|
4130
4133
|
iterations: number;
|
|
4131
4134
|
totalCost: number;
|
|
4135
|
+
totalTokens?: {
|
|
4136
|
+
input: number;
|
|
4137
|
+
output: number;
|
|
4138
|
+
};
|
|
4132
4139
|
stopReason: 'complete' | 'end_turn' | 'max_turns' | 'max_cost' | 'timeout' | 'error';
|
|
4133
4140
|
reflections?: string[];
|
|
4134
4141
|
error?: string;
|
|
@@ -4177,6 +4184,11 @@ interface RunTaskSessionSummary {
|
|
|
4177
4184
|
index: number;
|
|
4178
4185
|
/** Cost of this individual session (USD) */
|
|
4179
4186
|
cost: number;
|
|
4187
|
+
/** Token counts for this session */
|
|
4188
|
+
totalTokens?: {
|
|
4189
|
+
input: number;
|
|
4190
|
+
output: number;
|
|
4191
|
+
};
|
|
4180
4192
|
/** Number of loop iterations in this session */
|
|
4181
4193
|
iterations: number;
|
|
4182
4194
|
/** Why this session stopped */
|
|
@@ -4217,6 +4229,11 @@ interface RunTaskState {
|
|
|
4217
4229
|
sessionCount: number;
|
|
4218
4230
|
/** Total cost across all sessions (USD) */
|
|
4219
4231
|
totalCost: number;
|
|
4232
|
+
/** Total tokens across all sessions */
|
|
4233
|
+
totalTokens?: {
|
|
4234
|
+
input: number;
|
|
4235
|
+
output: number;
|
|
4236
|
+
};
|
|
4220
4237
|
/** Last agent output (full text) */
|
|
4221
4238
|
lastOutput: string;
|
|
4222
4239
|
/** Last terminal error captured from agent execution */
|
|
@@ -4330,6 +4347,8 @@ interface RunTaskOptions {
|
|
|
4330
4347
|
toolWindow?: 'session' | number;
|
|
4331
4348
|
/** Custom workflow definition (defaults to the built-in research→planning→execution workflow) */
|
|
4332
4349
|
workflow?: WorkflowDefinition;
|
|
4350
|
+
/** IDs of built-in tools to enable for the agent (e.g., "exa", "firecrawl", "dalle") */
|
|
4351
|
+
toolIds?: string[];
|
|
4333
4352
|
}
|
|
4334
4353
|
/**
|
|
4335
4354
|
* Final result returned by `agents.runTask()`
|
|
@@ -4338,6 +4357,10 @@ interface RunTaskResult {
|
|
|
4338
4357
|
status: RunTaskStatus;
|
|
4339
4358
|
sessionCount: number;
|
|
4340
4359
|
totalCost: number;
|
|
4360
|
+
totalTokens?: {
|
|
4361
|
+
input: number;
|
|
4362
|
+
output: number;
|
|
4363
|
+
};
|
|
4341
4364
|
lastOutput: string;
|
|
4342
4365
|
sessions: RunTaskSessionSummary[];
|
|
4343
4366
|
/** The record ID if trackProgress was enabled */
|
|
@@ -5127,6 +5150,31 @@ declare const defaultWorkflow: WorkflowDefinition;
|
|
|
5127
5150
|
|
|
5128
5151
|
declare const deployWorkflow: WorkflowDefinition;
|
|
5129
5152
|
|
|
5153
|
+
/**
|
|
5154
|
+
* Game workflow: design → build → verify.
|
|
5155
|
+
*
|
|
5156
|
+
* A three-phase workflow for tasks where the goal is to build a game
|
|
5157
|
+
* (Three.js, Phaser, WebGL, etc.) and deploy it to a Daytona sandbox.
|
|
5158
|
+
*
|
|
5159
|
+
* The key difference from the deploy workflow is that game code often
|
|
5160
|
+
* uses template literals, which break when embedded inside Express
|
|
5161
|
+
* `res.send()` template literals. This workflow instructs the agent to
|
|
5162
|
+
* use the `files` parameter for multi-file deployment (Express static
|
|
5163
|
+
* server + separate HTML/JS/CSS files).
|
|
5164
|
+
*
|
|
5165
|
+
* Phase 1 (design): Understand game requirements. Auto-advances after
|
|
5166
|
+
* the first session.
|
|
5167
|
+
*
|
|
5168
|
+
* Phase 2 (build): Write game code using multi-file deployment. The
|
|
5169
|
+
* agent uses `code` for a minimal Express static server and `files`
|
|
5170
|
+
* for the actual game assets (HTML, JS, CSS).
|
|
5171
|
+
*
|
|
5172
|
+
* Phase 3 (verify): Confirm the game is running and playable. Auto-
|
|
5173
|
+
* accepts completion when deploy_sandbox has succeeded.
|
|
5174
|
+
*/
|
|
5175
|
+
|
|
5176
|
+
declare const gameWorkflow: WorkflowDefinition;
|
|
5177
|
+
|
|
5130
5178
|
/**
|
|
5131
5179
|
* Utility functions shared between workflow phase handlers and AgentsEndpoint.
|
|
5132
5180
|
*
|
|
@@ -5144,4 +5192,4 @@ declare function getLikelySupportingCandidatePaths(bestCandidatePath: string | u
|
|
|
5144
5192
|
declare function getDefaultPlanPath(taskName: string): string;
|
|
5145
5193
|
declare function sanitizeTaskSlug(taskName: string): string;
|
|
5146
5194
|
|
|
5147
|
-
export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionLoopSnapshotSlice, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContinuation, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
|
|
5195
|
+
export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionLoopSnapshotSlice, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContinuation, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
|
package/dist/index.js
CHANGED
|
@@ -2840,8 +2840,8 @@ var scaffoldPhase = {
|
|
|
2840
2840
|
].join("\n");
|
|
2841
2841
|
},
|
|
2842
2842
|
interceptToolCall(toolName, _args, _ctx) {
|
|
2843
|
-
const
|
|
2844
|
-
if (
|
|
2843
|
+
const blockedTools2 = ["write_file", "read_file", "search_repo", "glob_files", "tree_directory", "list_directory", "restore_file_checkpoint"];
|
|
2844
|
+
if (blockedTools2.includes(toolName)) {
|
|
2845
2845
|
return [
|
|
2846
2846
|
`Blocked: ${toolName} is not available in deploy mode.`,
|
|
2847
2847
|
"Use deploy_sandbox to deploy your code to a live sandbox instead of writing files to the local repo."
|
|
@@ -2880,6 +2880,7 @@ var deployPhase = {
|
|
|
2880
2880
|
"",
|
|
2881
2881
|
"deploy_sandbox takes:",
|
|
2882
2882
|
" - code: The full source code (written to main.ts/main.js/main.py)",
|
|
2883
|
+
' - files: Additional files (path \u2192 content), e.g. { "public/index.html": "<html>..." }',
|
|
2883
2884
|
' - packageJson: Dependencies as a JSON object, e.g. { "dependencies": { "express": "^4.18.2" } }',
|
|
2884
2885
|
' - language: "typescript" (default), "javascript", or "python"',
|
|
2885
2886
|
" - port: The port your server listens on (default: 3000)",
|
|
@@ -2893,7 +2894,8 @@ var deployPhase = {
|
|
|
2893
2894
|
" 3. Include ALL dependencies in packageJson \u2014 nothing is pre-installed except Node.js built-ins.",
|
|
2894
2895
|
" 4. If the deploy fails, read the error output, fix the code, and call deploy_sandbox again.",
|
|
2895
2896
|
" 5. The sandbox is persistent \u2014 subsequent calls reuse the same sandbox.",
|
|
2896
|
-
" 6. When the deploy succeeds and the preview URL is live, tell the user and end with TASK_COMPLETE."
|
|
2897
|
+
" 6. When the deploy succeeds and the preview URL is live, tell the user and end with TASK_COMPLETE.",
|
|
2898
|
+
" 7. For apps with HTML frontends, use the `files` parameter to write HTML/CSS/JS to separate files and serve them with express.static, rather than embedding HTML in template literals."
|
|
2897
2899
|
].join("\n");
|
|
2898
2900
|
},
|
|
2899
2901
|
buildToolGuidance(_state) {
|
|
@@ -2908,8 +2910,8 @@ var deployPhase = {
|
|
|
2908
2910
|
return false;
|
|
2909
2911
|
},
|
|
2910
2912
|
interceptToolCall(toolName, _args, _ctx) {
|
|
2911
|
-
const
|
|
2912
|
-
if (
|
|
2913
|
+
const blockedTools2 = ["write_file", "read_file", "search_repo", "glob_files", "tree_directory", "list_directory", "restore_file_checkpoint"];
|
|
2914
|
+
if (blockedTools2.includes(toolName)) {
|
|
2913
2915
|
return [
|
|
2914
2916
|
`Blocked: ${toolName} is not available in deploy mode.`,
|
|
2915
2917
|
"Use deploy_sandbox to deploy your code to a live sandbox instead of writing files to the local repo."
|
|
@@ -2917,8 +2919,13 @@ var deployPhase = {
|
|
|
2917
2919
|
}
|
|
2918
2920
|
return void 0;
|
|
2919
2921
|
},
|
|
2920
|
-
canAcceptCompletion(
|
|
2921
|
-
|
|
2922
|
+
canAcceptCompletion(state, trace) {
|
|
2923
|
+
if (trace.entries.some((entry) => entry.startsWith("deploy_sandbox"))) {
|
|
2924
|
+
return true;
|
|
2925
|
+
}
|
|
2926
|
+
return state.sessions.some(
|
|
2927
|
+
(s) => s.actionKeys?.some((key) => key.startsWith("deploy_sandbox"))
|
|
2928
|
+
);
|
|
2922
2929
|
},
|
|
2923
2930
|
buildRecoveryMessage(state) {
|
|
2924
2931
|
const recent = state.sessions.slice(-2);
|
|
@@ -2989,6 +2996,204 @@ var deployWorkflow = {
|
|
|
2989
2996
|
}
|
|
2990
2997
|
};
|
|
2991
2998
|
|
|
2999
|
+
// src/workflows/game-workflow.ts
|
|
3000
|
+
var blockedTools = ["write_file", "read_file", "search_repo", "glob_files", "tree_directory", "list_directory", "restore_file_checkpoint"];
|
|
3001
|
+
function blockLocalTools(toolName) {
|
|
3002
|
+
if (blockedTools.includes(toolName)) {
|
|
3003
|
+
return [
|
|
3004
|
+
`Blocked: ${toolName} is not available in game deploy mode.`,
|
|
3005
|
+
"Use deploy_sandbox to deploy your game to a live sandbox instead of writing files to the local repo."
|
|
3006
|
+
].join(" ");
|
|
3007
|
+
}
|
|
3008
|
+
return void 0;
|
|
3009
|
+
}
|
|
3010
|
+
var designPhase = {
|
|
3011
|
+
name: "design",
|
|
3012
|
+
description: "Understand game requirements and plan the approach",
|
|
3013
|
+
buildInstructions(_state) {
|
|
3014
|
+
return [
|
|
3015
|
+
"--- Workflow Phase: Design ---",
|
|
3016
|
+
"This is a game development task. You will build a game and deploy it to a live sandbox \u2014 you are NOT editing files in the local repository.",
|
|
3017
|
+
"Quickly determine:",
|
|
3018
|
+
" 1. What type of game (3D, 2D, platformer, racing, puzzle, etc.)",
|
|
3019
|
+
" 2. Theme and visual style",
|
|
3020
|
+
" 3. Core game mechanics (controls, scoring, win/lose conditions)",
|
|
3021
|
+
" 4. Tech stack (Three.js, Phaser, vanilla Canvas/WebGL, etc.)",
|
|
3022
|
+
" 5. Any specific dependencies needed",
|
|
3023
|
+
"",
|
|
3024
|
+
"Do NOT inspect the local repo or search for files to edit.",
|
|
3025
|
+
"Do NOT write a plan file.",
|
|
3026
|
+
"Once you understand the requirements, proceed to build and deploy."
|
|
3027
|
+
].join("\n");
|
|
3028
|
+
},
|
|
3029
|
+
buildToolGuidance(_state) {
|
|
3030
|
+
return [
|
|
3031
|
+
"This is a sandbox deploy task \u2014 do NOT use write_file, read_file, search_repo, glob_files, tree_directory, or list_directory.",
|
|
3032
|
+
"Your primary tool is deploy_sandbox. Use it to deploy code to a persistent sandbox and get a live preview URL."
|
|
3033
|
+
];
|
|
3034
|
+
},
|
|
3035
|
+
isComplete(ctx) {
|
|
3036
|
+
return ctx.state.sessions.length >= 1 || ctx.trace.entries.some((entry) => entry.startsWith("deploy_sandbox"));
|
|
3037
|
+
},
|
|
3038
|
+
buildTransitionSummary(_state, _nextPhaseName) {
|
|
3039
|
+
return [
|
|
3040
|
+
"Automatic phase transition: design \u2192 build.",
|
|
3041
|
+
"Requirements understood. Build the game and deploy it using deploy_sandbox with the files parameter."
|
|
3042
|
+
].join("\n");
|
|
3043
|
+
},
|
|
3044
|
+
interceptToolCall(toolName, _args, _ctx) {
|
|
3045
|
+
return blockLocalTools(toolName);
|
|
3046
|
+
},
|
|
3047
|
+
shouldForceEndTurn(snapshot, _ctx) {
|
|
3048
|
+
if (snapshot.pauseCount >= 12) {
|
|
3049
|
+
return "design phase is looping without progressing \u2014 end the turn so the system can advance to build";
|
|
3050
|
+
}
|
|
3051
|
+
return void 0;
|
|
3052
|
+
}
|
|
3053
|
+
};
|
|
3054
|
+
var buildPhase = {
|
|
3055
|
+
name: "build",
|
|
3056
|
+
description: "Build the game and deploy to sandbox with live preview",
|
|
3057
|
+
buildInstructions(_state) {
|
|
3058
|
+
return [
|
|
3059
|
+
"--- Workflow Phase: Build ---",
|
|
3060
|
+
"Build the game and deploy it using the deploy_sandbox tool.",
|
|
3061
|
+
"",
|
|
3062
|
+
"CRITICAL: Multi-file deployment pattern",
|
|
3063
|
+
" You MUST use the `files` parameter for the game HTML/JS/CSS.",
|
|
3064
|
+
" NEVER embed HTML inside a JavaScript template literal in Express `res.send()` \u2014 this WILL break",
|
|
3065
|
+
" because game code uses backticks (template literals) which cause nested backtick corruption.",
|
|
3066
|
+
"",
|
|
3067
|
+
" Correct pattern:",
|
|
3068
|
+
" - code: A minimal Express static file server (~5 lines):",
|
|
3069
|
+
" ```",
|
|
3070
|
+
' const express = require("express");',
|
|
3071
|
+
" const app = express();",
|
|
3072
|
+
' app.use(express.static("public"));',
|
|
3073
|
+
' app.listen(3000, () => console.log("Server running on port 3000"));',
|
|
3074
|
+
" ```",
|
|
3075
|
+
" - files: Your game assets as separate files:",
|
|
3076
|
+
" {",
|
|
3077
|
+
' "public/index.html": "<!DOCTYPE html>...",',
|
|
3078
|
+
' "public/game.js": "// game logic...",',
|
|
3079
|
+
' "public/style.css": "body { margin: 0; }"',
|
|
3080
|
+
" }",
|
|
3081
|
+
"",
|
|
3082
|
+
" WRONG pattern (DO NOT DO THIS):",
|
|
3083
|
+
' - code: `app.get("/", (req, res) => res.send(\\`<html>...game code with backticks...\\`))`',
|
|
3084
|
+
" - This breaks because game code uses template literals inside the res.send template literal.",
|
|
3085
|
+
"",
|
|
3086
|
+
"deploy_sandbox takes:",
|
|
3087
|
+
" - code: The server source code (written to main.ts/main.js/main.py)",
|
|
3088
|
+
' - files: Additional files (path \u2192 content), e.g. { "public/index.html": "<html>..." }',
|
|
3089
|
+
' - packageJson: Dependencies as a JSON object, e.g. { "dependencies": { "express": "^4.18.2", "three": "^0.170.0" } }',
|
|
3090
|
+
' - language: "javascript" (recommended for games), "typescript", or "python"',
|
|
3091
|
+
" - port: The port your server listens on (default: 3000)",
|
|
3092
|
+
" - startCommand: Custom start command (auto-detected by default)",
|
|
3093
|
+
"",
|
|
3094
|
+
"Guidelines:",
|
|
3095
|
+
' 1. Use `language: "javascript"` \u2014 simpler for static file servers.',
|
|
3096
|
+
" 2. The `code` param should be a minimal Express static server. ALL game code goes in `files`.",
|
|
3097
|
+
" 3. Include ALL dependencies in packageJson (express, three, phaser, etc.).",
|
|
3098
|
+
" 4. If the deploy fails, read the error output, fix the code, and call deploy_sandbox again.",
|
|
3099
|
+
" 5. The sandbox is persistent \u2014 subsequent calls reuse the same sandbox.",
|
|
3100
|
+
" 6. Load game libraries from CDN in your HTML (e.g., Three.js from unpkg/cdnjs) OR include them in packageJson.",
|
|
3101
|
+
" 7. Make the game fullscreen by default (width: 100vw, height: 100vh, no margin/padding on body)."
|
|
3102
|
+
].join("\n");
|
|
3103
|
+
},
|
|
3104
|
+
buildToolGuidance(_state) {
|
|
3105
|
+
return [
|
|
3106
|
+
"Your primary tool is deploy_sandbox. Call it with code (Express static server), files (game HTML/JS/CSS), and packageJson.",
|
|
3107
|
+
"ALWAYS use the `files` parameter for game HTML, JavaScript, and CSS \u2014 NEVER embed them in template literals.",
|
|
3108
|
+
"Do NOT use write_file, read_file, search_repo, glob_files, tree_directory, or list_directory.",
|
|
3109
|
+
"You may use run_sandbox_code for quick one-off tests if needed."
|
|
3110
|
+
];
|
|
3111
|
+
},
|
|
3112
|
+
isComplete() {
|
|
3113
|
+
return false;
|
|
3114
|
+
},
|
|
3115
|
+
interceptToolCall(toolName, _args, _ctx) {
|
|
3116
|
+
return blockLocalTools(toolName);
|
|
3117
|
+
},
|
|
3118
|
+
canAcceptCompletion(_state, trace) {
|
|
3119
|
+
return trace.entries.some((entry) => entry.startsWith("deploy_sandbox"));
|
|
3120
|
+
},
|
|
3121
|
+
buildRecoveryMessage(state) {
|
|
3122
|
+
const recent = state.sessions.slice(-2);
|
|
3123
|
+
if (recent.length < 2) return void 0;
|
|
3124
|
+
const noProgress = recent.every(
|
|
3125
|
+
(s) => s.hadTextOutput === false && s.wroteFiles === false
|
|
3126
|
+
);
|
|
3127
|
+
if (!noProgress) return void 0;
|
|
3128
|
+
return [
|
|
3129
|
+
"Recovery instruction:",
|
|
3130
|
+
"You should be deploying the game using deploy_sandbox with the `files` parameter.",
|
|
3131
|
+
"Use `code` for a minimal Express static server and `files` for game HTML/JS/CSS.",
|
|
3132
|
+
"NEVER embed HTML in a JavaScript template literal \u2014 use separate files."
|
|
3133
|
+
].join("\n");
|
|
3134
|
+
},
|
|
3135
|
+
shouldForceEndTurn(snapshot, _ctx) {
|
|
3136
|
+
if (snapshot.consecutiveDiscoveryPauseCount >= 8) {
|
|
3137
|
+
return "build phase is looping on discovery tools instead of calling deploy_sandbox";
|
|
3138
|
+
}
|
|
3139
|
+
if (snapshot.actionKeyCount >= 4) {
|
|
3140
|
+
return `the same action repeated ${snapshot.actionKeyCount} times \u2014 try a different approach`;
|
|
3141
|
+
}
|
|
3142
|
+
return void 0;
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
var verifyPhase = {
|
|
3146
|
+
name: "verify",
|
|
3147
|
+
description: "Verify the game is running and playable",
|
|
3148
|
+
buildInstructions(_state) {
|
|
3149
|
+
return [
|
|
3150
|
+
"--- Workflow Phase: Verify ---",
|
|
3151
|
+
"The game has been deployed. Verify it is working:",
|
|
3152
|
+
" 1. Check the server log for errors. If there are errors, fix and redeploy using deploy_sandbox.",
|
|
3153
|
+
" 2. Tell the user the preview URL so they can play the game.",
|
|
3154
|
+
" 3. End with TASK_COMPLETE.",
|
|
3155
|
+
"",
|
|
3156
|
+
"If the user reports issues, fix the code and redeploy."
|
|
3157
|
+
].join("\n");
|
|
3158
|
+
},
|
|
3159
|
+
buildToolGuidance(_state) {
|
|
3160
|
+
return [
|
|
3161
|
+
"Use deploy_sandbox to redeploy if fixes are needed.",
|
|
3162
|
+
"Do NOT use local file system tools.",
|
|
3163
|
+
"When the game is working, tell the user the preview URL and end with TASK_COMPLETE."
|
|
3164
|
+
];
|
|
3165
|
+
},
|
|
3166
|
+
isComplete() {
|
|
3167
|
+
return false;
|
|
3168
|
+
},
|
|
3169
|
+
interceptToolCall(toolName, _args, _ctx) {
|
|
3170
|
+
return blockLocalTools(toolName);
|
|
3171
|
+
},
|
|
3172
|
+
canAcceptCompletion(_state, trace) {
|
|
3173
|
+
return trace.entries.some((entry) => entry.startsWith("deploy_sandbox"));
|
|
3174
|
+
},
|
|
3175
|
+
shouldForceEndTurn(snapshot, _ctx) {
|
|
3176
|
+
if (snapshot.actionKeyCount >= 4) {
|
|
3177
|
+
return `the same action repeated ${snapshot.actionKeyCount} times \u2014 try a different approach`;
|
|
3178
|
+
}
|
|
3179
|
+
return void 0;
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
function classifyVariant3() {
|
|
3183
|
+
return "game";
|
|
3184
|
+
}
|
|
3185
|
+
var gameWorkflow = {
|
|
3186
|
+
name: "game",
|
|
3187
|
+
phases: [designPhase, buildPhase, verifyPhase],
|
|
3188
|
+
classifyVariant: classifyVariant3,
|
|
3189
|
+
async generateBootstrapContext() {
|
|
3190
|
+
return void 0;
|
|
3191
|
+
},
|
|
3192
|
+
buildCandidateBlock() {
|
|
3193
|
+
return "";
|
|
3194
|
+
}
|
|
3195
|
+
};
|
|
3196
|
+
|
|
2992
3197
|
// src/endpoints.ts
|
|
2993
3198
|
var FlowsEndpoint = class {
|
|
2994
3199
|
constructor(client) {
|
|
@@ -5244,13 +5449,15 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5244
5449
|
maxSessions,
|
|
5245
5450
|
localToolNames,
|
|
5246
5451
|
continuationContext,
|
|
5247
|
-
workflow
|
|
5452
|
+
workflow,
|
|
5453
|
+
options.toolIds
|
|
5248
5454
|
);
|
|
5249
5455
|
let sessionResult;
|
|
5250
5456
|
const sessionData = {
|
|
5251
5457
|
messages,
|
|
5252
5458
|
debugMode: options.debugMode,
|
|
5253
|
-
model: options.model
|
|
5459
|
+
model: options.model,
|
|
5460
|
+
...options.toolIds?.length ? { tools: { toolIds: options.toolIds } } : {}
|
|
5254
5461
|
};
|
|
5255
5462
|
let sessionToolMessages = [];
|
|
5256
5463
|
if (useStream && options.localTools) {
|
|
@@ -5274,6 +5481,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5274
5481
|
result: completeEvent.finalOutput || "",
|
|
5275
5482
|
iterations: completeEvent.iterations,
|
|
5276
5483
|
totalCost: completeEvent.totalCost || 0,
|
|
5484
|
+
totalTokens: completeEvent.totalTokens,
|
|
5277
5485
|
stopReason: completeEvent.stopReason,
|
|
5278
5486
|
error: completeEvent.error
|
|
5279
5487
|
};
|
|
@@ -5291,6 +5499,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5291
5499
|
result: completeEvent.finalOutput || "",
|
|
5292
5500
|
iterations: completeEvent.iterations,
|
|
5293
5501
|
totalCost: completeEvent.totalCost || 0,
|
|
5502
|
+
totalTokens: completeEvent.totalTokens,
|
|
5294
5503
|
stopReason: completeEvent.stopReason,
|
|
5295
5504
|
error: completeEvent.error
|
|
5296
5505
|
};
|
|
@@ -5303,8 +5512,15 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5303
5512
|
toolTraceSummary
|
|
5304
5513
|
);
|
|
5305
5514
|
const sessionCost = sessionResult.totalCost;
|
|
5515
|
+
const sessionTokens = sessionResult.totalTokens;
|
|
5306
5516
|
state.sessionCount = session + 1;
|
|
5307
5517
|
state.totalCost += sessionCost;
|
|
5518
|
+
if (sessionTokens) {
|
|
5519
|
+
state.totalTokens = {
|
|
5520
|
+
input: (state.totalTokens?.input || 0) + sessionTokens.input,
|
|
5521
|
+
output: (state.totalTokens?.output || 0) + sessionTokens.output
|
|
5522
|
+
};
|
|
5523
|
+
}
|
|
5308
5524
|
state.lastOutput = effectiveSessionOutput;
|
|
5309
5525
|
state.lastError = sessionResult.stopReason === "error" ? sessionResult.error || "Agent session ended with an error." : void 0;
|
|
5310
5526
|
state.lastStopReason = sessionResult.stopReason;
|
|
@@ -5312,6 +5528,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5312
5528
|
state.sessions.push({
|
|
5313
5529
|
index: session + 1,
|
|
5314
5530
|
cost: sessionCost,
|
|
5531
|
+
totalTokens: sessionTokens,
|
|
5315
5532
|
iterations: sessionResult.iterations,
|
|
5316
5533
|
stopReason: sessionResult.stopReason,
|
|
5317
5534
|
outputPreview: effectiveSessionOutput.slice(0, 300),
|
|
@@ -5425,6 +5642,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5425
5642
|
status: state.status,
|
|
5426
5643
|
sessionCount: state.sessionCount,
|
|
5427
5644
|
totalCost: state.totalCost,
|
|
5645
|
+
totalTokens: state.totalTokens,
|
|
5428
5646
|
lastOutput: state.lastOutput,
|
|
5429
5647
|
sessions: state.sessions,
|
|
5430
5648
|
recordId
|
|
@@ -5471,12 +5689,12 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5471
5689
|
* Build messages for a session, injecting progress context for continuation sessions.
|
|
5472
5690
|
* Optionally accepts continuation context for marathon resume scenarios.
|
|
5473
5691
|
*/
|
|
5474
|
-
buildSessionMessages(originalMessage, state, sessionIndex, maxSessions, localToolNames, continuationContext, workflow) {
|
|
5692
|
+
buildSessionMessages(originalMessage, state, sessionIndex, maxSessions, localToolNames, continuationContext, workflow, builtinToolIds) {
|
|
5475
5693
|
const wf = workflow ?? defaultWorkflow;
|
|
5476
5694
|
const currentPhase = wf.phases.find((p) => p.name === state.workflowPhase);
|
|
5477
5695
|
const toolGuidanceLines = currentPhase?.buildToolGuidance(state) ?? [];
|
|
5478
5696
|
const isDeployWorkflow = wf.name === "deploy";
|
|
5479
|
-
const
|
|
5697
|
+
const localToolsBlock = localToolNames?.length ? [
|
|
5480
5698
|
"",
|
|
5481
5699
|
"--- Local Tools ---",
|
|
5482
5700
|
`You have access to tools (${localToolNames.join(", ")}) that execute directly on the user's machine.`,
|
|
@@ -5486,6 +5704,14 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5486
5704
|
...toolGuidanceLines,
|
|
5487
5705
|
...isDeployWorkflow ? [] : ["Always use write_file to save your output so the user can run it immediately."]
|
|
5488
5706
|
].join("\n") : "";
|
|
5707
|
+
const builtinToolNames = builtinToolIds?.map((id) => id.replace(/^builtin:/, ""));
|
|
5708
|
+
const builtinToolsBlock = builtinToolNames?.length ? [
|
|
5709
|
+
"",
|
|
5710
|
+
"--- Built-in Tools ---",
|
|
5711
|
+
`You have access to built-in tools (${builtinToolNames.join(", ")}) for web search, web scraping, image generation, and other capabilities.`,
|
|
5712
|
+
"Use these tools when the task requires information from the web, generating images, or other capabilities beyond local file operations."
|
|
5713
|
+
].join("\n") : "";
|
|
5714
|
+
const toolsBlock = localToolsBlock + builtinToolsBlock;
|
|
5489
5715
|
const bootstrapBlock = state.bootstrapContext ? ["", "--- Initial Repository Discovery ---", state.bootstrapContext].join("\n") : "";
|
|
5490
5716
|
const phaseBlock = ["", this.buildPhaseInstructions(state, wf)].join("\n");
|
|
5491
5717
|
const candidateBlock = wf.buildCandidateBlock?.(state) ?? "";
|
|
@@ -6941,6 +7167,7 @@ export {
|
|
|
6941
7167
|
defaultWorkflow,
|
|
6942
7168
|
deployWorkflow,
|
|
6943
7169
|
evaluateGeneratedRuntimeToolProposal,
|
|
7170
|
+
gameWorkflow,
|
|
6944
7171
|
getDefaultPlanPath,
|
|
6945
7172
|
getLikelySupportingCandidatePaths,
|
|
6946
7173
|
isDiscoveryToolName,
|