autopilot-ai 1.2.2 → 1.5.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/README.md +52 -0
- package/dist/index.js +5479 -2066
- package/dist/index.js.map +1 -1
- package/dist/sdk/index.d.ts +179 -1
- package/dist/sdk/index.js +1958 -148
- package/dist/sdk/index.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk/index.d.ts
CHANGED
|
@@ -91,6 +91,8 @@ interface OpenRouterProviderPrefs {
|
|
|
91
91
|
max_price?: Record<string, number>;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
type SubagentPolicy = "off" | "suggest" | "auto";
|
|
95
|
+
|
|
94
96
|
type ReasoningEffort = "low" | "medium" | "high";
|
|
95
97
|
interface McpServerConfig {
|
|
96
98
|
type: "local" | "remote";
|
|
@@ -124,6 +126,13 @@ interface KimiConfig {
|
|
|
124
126
|
* Bring-your-own only: kimiflare never pays for or proxies model calls.
|
|
125
127
|
*/
|
|
126
128
|
openrouterApiKey?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional Requesty API key (env: REQUESTY_API_KEY, which wins over the
|
|
131
|
+
* file). Used only when no OpenRouter key and no custom endpoint are
|
|
132
|
+
* configured: model calls then go to Requesty (https://requesty.ai). Set
|
|
133
|
+
* REQUESTY_BASE_URL to pick a region, e.g. https://router.eu.requesty.ai/v1.
|
|
134
|
+
*/
|
|
135
|
+
requestyApiKey?: string;
|
|
127
136
|
/** OpenRouter model id, e.g. "moonshotai/kimi-k2.6". */
|
|
128
137
|
model: string;
|
|
129
138
|
/**
|
|
@@ -156,6 +165,8 @@ interface KimiConfig {
|
|
|
156
165
|
accountId?: string;
|
|
157
166
|
apiToken?: string;
|
|
158
167
|
reasoningEffort?: ReasoningEffort;
|
|
168
|
+
/** Harness subagent routing: off, suggest (default), or auto. Auto never bypasses tool permission or worker budgets. */
|
|
169
|
+
subagentPolicy?: SubagentPolicy;
|
|
159
170
|
/**
|
|
160
171
|
* Feature flag for the plan / edit / auto permission modes. Off by default:
|
|
161
172
|
* every session runs in auto (tools run without per-call prompts) and the
|
|
@@ -228,6 +239,8 @@ interface KimiConfig {
|
|
|
228
239
|
uiEngine?: "ink" | "camouflage";
|
|
229
240
|
/** Worker endpoint URL for spawning standalone research/executor workers. */
|
|
230
241
|
workerEndpoint?: string;
|
|
242
|
+
/** Worker provider. Remote remains the compatibility default. */
|
|
243
|
+
workerBackend?: "remote" | "hotcell";
|
|
231
244
|
/** Max cost per worker in USD (default: 1.0). */
|
|
232
245
|
workerBudgetUsd?: number;
|
|
233
246
|
/** Hard ceiling for workerBudgetUsd. Any configured or programmatic value above this is silently capped. Default: 5.0. */
|
|
@@ -319,6 +332,8 @@ declare function saveConfig(cfg: KimiConfig): Promise<string>;
|
|
|
319
332
|
interface LlmAuth {
|
|
320
333
|
/** The user's OpenRouter key. */
|
|
321
334
|
openrouterApiKey?: string;
|
|
335
|
+
/** The user's Requesty key; used only when there is no OpenRouter key or custom endpoint. */
|
|
336
|
+
requestyApiKey?: string;
|
|
322
337
|
/** Host-app broker endpoint; when set, used instead of OpenRouter. */
|
|
323
338
|
customEndpoint?: CustomEndpoint;
|
|
324
339
|
/** Extra OpenRouter provider-routing preferences. */
|
|
@@ -372,6 +387,7 @@ interface MemoryStats {
|
|
|
372
387
|
interface MemoryManagerOpts {
|
|
373
388
|
dbPath: string;
|
|
374
389
|
openrouterApiKey?: string;
|
|
390
|
+
requestyApiKey?: string;
|
|
375
391
|
customEndpoint?: CustomEndpoint;
|
|
376
392
|
model?: string;
|
|
377
393
|
plumbingModel?: string;
|
|
@@ -384,6 +400,7 @@ interface MemoryManagerOpts {
|
|
|
384
400
|
}
|
|
385
401
|
interface LlmOpts {
|
|
386
402
|
openrouterApiKey?: string;
|
|
403
|
+
requestyApiKey?: string;
|
|
387
404
|
customEndpoint?: CustomEndpoint;
|
|
388
405
|
model: string;
|
|
389
406
|
provider?: OpenRouterProviderPrefs;
|
|
@@ -506,6 +523,12 @@ interface ToolContext {
|
|
|
506
523
|
llmAuth?: LlmAuth;
|
|
507
524
|
/** Model id for tools that need to call an LLM. */
|
|
508
525
|
model?: string;
|
|
526
|
+
/** Optional override for the durable managed-jobs database (primarily for embedding/tests). */
|
|
527
|
+
jobsDbPath?: string;
|
|
528
|
+
/** Run identifier for durable tool-boundary journaling in unattended runs. */
|
|
529
|
+
runId?: string;
|
|
530
|
+
/** Optional override for the durable run/event/timer database. */
|
|
531
|
+
runsDbPath?: string;
|
|
509
532
|
/** When false (default), the bash tool blocks `git push` to the repository's
|
|
510
533
|
* default branch and directs the model to open a PR instead. */
|
|
511
534
|
allowDirectPush?: boolean;
|
|
@@ -519,10 +542,19 @@ interface ToolRender {
|
|
|
519
542
|
after: string;
|
|
520
543
|
};
|
|
521
544
|
}
|
|
545
|
+
interface RunWaitRequest {
|
|
546
|
+
runId: string;
|
|
547
|
+
timerId: string;
|
|
548
|
+
condition: "time" | "job";
|
|
549
|
+
jobId?: string;
|
|
550
|
+
wakeAt: number;
|
|
551
|
+
}
|
|
522
552
|
interface ToolOutput {
|
|
523
553
|
content: string;
|
|
524
554
|
rawBytes: number;
|
|
525
555
|
reducedBytes: number;
|
|
556
|
+
/** Internal control signal: persist the wait and end this agent turn. */
|
|
557
|
+
waitRequest?: RunWaitRequest;
|
|
526
558
|
}
|
|
527
559
|
interface ToolSpec<Args = any> {
|
|
528
560
|
name: string;
|
|
@@ -741,6 +773,152 @@ declare function createDefaultPermissionHandler(options: {
|
|
|
741
773
|
|
|
742
774
|
declare function startRpcServer(input?: Readable, output?: Writable, createSession?: typeof createAgentSession): Promise<void>;
|
|
743
775
|
|
|
776
|
+
type RunStatus = "queued" | "running" | "waiting" | "needs_input" | "completed" | "failed" | "cancelled" | "interrupted_unknown";
|
|
777
|
+
type RunEventType = "state" | "tool_intent" | "tool_result";
|
|
778
|
+
type TimerCondition = "time" | "job" | "approval";
|
|
779
|
+
type TimerStatus = "scheduled" | "claimed" | "completed" | "failed" | "cancelled";
|
|
780
|
+
interface RunRecord {
|
|
781
|
+
id: string;
|
|
782
|
+
sessionId: string | null;
|
|
783
|
+
cwd: string;
|
|
784
|
+
task: string;
|
|
785
|
+
status: RunStatus;
|
|
786
|
+
stopReason: string | null;
|
|
787
|
+
allowedTools: string[];
|
|
788
|
+
maxToolIterations: number;
|
|
789
|
+
maxRuntimeMs: number;
|
|
790
|
+
createdAt: number;
|
|
791
|
+
updatedAt: number;
|
|
792
|
+
startedAt: number | null;
|
|
793
|
+
finishedAt: number | null;
|
|
794
|
+
}
|
|
795
|
+
interface RunEvent {
|
|
796
|
+
sequence: number;
|
|
797
|
+
runId: string;
|
|
798
|
+
type: RunEventType;
|
|
799
|
+
toolCallId: string | null;
|
|
800
|
+
toolName: string | null;
|
|
801
|
+
metadata: Record<string, unknown>;
|
|
802
|
+
createdAt: number;
|
|
803
|
+
}
|
|
804
|
+
interface RunTimer {
|
|
805
|
+
id: string;
|
|
806
|
+
runId: string;
|
|
807
|
+
condition: TimerCondition;
|
|
808
|
+
jobId: string | null;
|
|
809
|
+
wakeAt: number;
|
|
810
|
+
intervalMs: number;
|
|
811
|
+
status: TimerStatus;
|
|
812
|
+
attempts: number;
|
|
813
|
+
maxAttempts: number;
|
|
814
|
+
leaseUntil: number | null;
|
|
815
|
+
lastError: string | null;
|
|
816
|
+
createdAt: number;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* SQLite persistence for unattended runs, tool-boundary checkpoints, and
|
|
820
|
+
* durable wake timers. Constructing a store only opens/migrates the schema;
|
|
821
|
+
* call reconcileInterruptedRuns explicitly once at supervisor startup.
|
|
822
|
+
*/
|
|
823
|
+
declare class RunStore {
|
|
824
|
+
private readonly db;
|
|
825
|
+
constructor(dbPath?: string);
|
|
826
|
+
close(): void;
|
|
827
|
+
createRun(input: {
|
|
828
|
+
task: string;
|
|
829
|
+
cwd: string;
|
|
830
|
+
sessionId?: string;
|
|
831
|
+
allowedTools?: string[];
|
|
832
|
+
maxToolIterations?: number;
|
|
833
|
+
maxRuntimeMs?: number;
|
|
834
|
+
}): RunRecord;
|
|
835
|
+
getRun(id: string): RunRecord | undefined;
|
|
836
|
+
listRuns(options?: {
|
|
837
|
+
status?: RunStatus;
|
|
838
|
+
limit?: number;
|
|
839
|
+
}): RunRecord[];
|
|
840
|
+
transition(id: string, status: RunStatus, reason?: string): RunRecord;
|
|
841
|
+
/** Persist a tool intent before execution. Only hashes are retained, never raw arguments. */
|
|
842
|
+
recordToolIntent(runId: string, toolCallId: string, toolName: string, args: unknown): void;
|
|
843
|
+
/** Persist completion metadata after execution without storing tool output text. */
|
|
844
|
+
recordToolResult(runId: string, toolCallId: string, toolName: string, result: {
|
|
845
|
+
ok: boolean;
|
|
846
|
+
content: string;
|
|
847
|
+
errorCode?: string;
|
|
848
|
+
}): void;
|
|
849
|
+
listEvents(runId: string): RunEvent[];
|
|
850
|
+
countToolIterations(runId: string): number;
|
|
851
|
+
/**
|
|
852
|
+
* On daemon startup, mark every still-running run interrupted. An unmatched
|
|
853
|
+
* intent is the explicit ambiguous-action case; no tool is ever replayed.
|
|
854
|
+
*/
|
|
855
|
+
reconcileInterruptedRuns(now?: number): RunRecord[];
|
|
856
|
+
scheduleTimer(input: {
|
|
857
|
+
runId: string;
|
|
858
|
+
condition: TimerCondition;
|
|
859
|
+
wakeAt: number;
|
|
860
|
+
intervalMs?: number;
|
|
861
|
+
jobId?: string;
|
|
862
|
+
maxAttempts?: number;
|
|
863
|
+
}): RunTimer;
|
|
864
|
+
getTimer(id: string): RunTimer | undefined;
|
|
865
|
+
nextTimerAt(): number | null;
|
|
866
|
+
listFailedTimers(limit?: number): RunTimer[];
|
|
867
|
+
/** Reschedule a successful job-status check without consuming failure retries. */
|
|
868
|
+
rescheduleTimer(id: string, wakeAt: number): RunTimer;
|
|
869
|
+
/** Atomically lease timers due now; expired claims are safely retried. */
|
|
870
|
+
claimDueTimers(now?: number, limit?: number, leaseMs?: number): RunTimer[];
|
|
871
|
+
completeTimer(id: string): RunTimer;
|
|
872
|
+
retryTimer(id: string, error: string, now?: number): RunTimer;
|
|
873
|
+
cancelTimersForRun(runId: string): number;
|
|
874
|
+
cancelTimer(id: string): RunTimer;
|
|
875
|
+
private updateTimer;
|
|
876
|
+
private appendEvent;
|
|
877
|
+
private assertRunExists;
|
|
878
|
+
private assertRunActive;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
type JobStatus = "starting" | "running" | "cancelling" | "completed" | "failed" | "timed_out" | "cancelled" | "unknown";
|
|
882
|
+
|
|
883
|
+
interface RunWakeEvent {
|
|
884
|
+
runId: string;
|
|
885
|
+
timerId: string;
|
|
886
|
+
condition: "time" | "job";
|
|
887
|
+
jobId?: string;
|
|
888
|
+
jobStatus?: JobStatus | "not_found";
|
|
889
|
+
}
|
|
890
|
+
interface RunWakeSchedulerOptions {
|
|
891
|
+
/** Enqueue/resume the run; must be idempotent by timerId and return promptly. */
|
|
892
|
+
onWake: (event: RunWakeEvent) => void | Promise<void>;
|
|
893
|
+
runsDbPath?: string;
|
|
894
|
+
jobsDbPath?: string;
|
|
895
|
+
leaseMs?: number;
|
|
896
|
+
batchSize?: number;
|
|
897
|
+
onError?: (error: Error, timer?: RunTimer) => void;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Durable timer dispatcher. It holds no timer state in memory: every wake is
|
|
901
|
+
* claimed from SQLite, so a restart recovers scheduled and expired leases.
|
|
902
|
+
* onWake must be idempotent by timerId because delivery is at-least-once.
|
|
903
|
+
*/
|
|
904
|
+
declare class RunWakeScheduler {
|
|
905
|
+
private readonly store;
|
|
906
|
+
private readonly options;
|
|
907
|
+
private timer;
|
|
908
|
+
private running;
|
|
909
|
+
private disposed;
|
|
910
|
+
constructor(options: RunWakeSchedulerOptions);
|
|
911
|
+
start(): void;
|
|
912
|
+
stop(): void;
|
|
913
|
+
dispose(): void;
|
|
914
|
+
/** Deterministic entry point for tests and hosts that own their scheduler loop. */
|
|
915
|
+
processDueTimers(now?: number): Promise<number>;
|
|
916
|
+
private tick;
|
|
917
|
+
private scheduleNextTick;
|
|
918
|
+
private processTimer;
|
|
919
|
+
private failRunsForFailedTimers;
|
|
920
|
+
}
|
|
921
|
+
|
|
744
922
|
declare function resolveSdkConfig(opts: CreateSessionOptions): Promise<KimiConfig>;
|
|
745
923
|
|
|
746
|
-
export { type ChatMessage, type CreateSessionOptions, DEFAULT_MODEL, DEFAULT_REASONING_EFFORT, type KimiConfig, type KimiFlareSession, type PermissionDecision, type PermissionHandler, type PermissionRequest, type PromptOptions, type SessionEvent, type SessionStatus, type SessionUsage, type Task, type ToolSpec, createAgentSession, createDefaultPermissionHandler, loadConfig, resolveSdkConfig, saveConfig, startRpcServer };
|
|
924
|
+
export { type ChatMessage, type CreateSessionOptions, DEFAULT_MODEL, DEFAULT_REASONING_EFFORT, type KimiConfig, type KimiFlareSession, type PermissionDecision, type PermissionHandler, type PermissionRequest, type PromptOptions, type RunEvent, type RunEventType, type RunRecord, type RunStatus, RunStore, type RunTimer, type RunWakeEvent, RunWakeScheduler, type RunWakeSchedulerOptions, type SessionEvent, type SessionStatus, type SessionUsage, type Task, type TimerCondition, type TimerStatus, type ToolSpec, createAgentSession, createDefaultPermissionHandler, loadConfig, resolveSdkConfig, saveConfig, startRpcServer };
|