@perstack/runtime 0.0.18 → 0.0.20
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.d.ts +64 -50
- package/dist/index.js +83 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2820,7 +2820,6 @@ declare const RunParamsSchema: z.ZodObject<{
|
|
|
2820
2820
|
temperature: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
2821
2821
|
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
2822
2822
|
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
2823
|
-
/** Optional workspace directory path. If provided, sets WORKSPACE_DIR environment variable for skill execution. */
|
|
2824
2823
|
workspace: z.ZodOptional<z.ZodString>;
|
|
2825
2824
|
startedAt: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
2826
2825
|
updatedAt: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -4082,6 +4081,7 @@ type RunSetting = z.infer<typeof RunParamsSchema.shape.setting>;
|
|
|
4082
4081
|
type RunInput = z.infer<typeof RunParamsSchema.shape.setting.shape.input>;
|
|
4083
4082
|
type Step = {
|
|
4084
4083
|
stepNumber: number;
|
|
4084
|
+
inputMessages?: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4085
4085
|
newMessages: Message[];
|
|
4086
4086
|
toolCall?: ToolCall;
|
|
4087
4087
|
toolResult?: ToolResult;
|
|
@@ -4110,7 +4110,7 @@ type ToolResult = {
|
|
|
4110
4110
|
type ExpertEventPayloads = {
|
|
4111
4111
|
startRun: {
|
|
4112
4112
|
initialCheckpoint: Checkpoint;
|
|
4113
|
-
inputMessages:
|
|
4113
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4114
4114
|
};
|
|
4115
4115
|
startGeneration: {
|
|
4116
4116
|
messages: Message[];
|
|
@@ -4197,12 +4197,12 @@ declare const startRun: (setting: RunSetting, checkpoint: Checkpoint, data: Omit
|
|
|
4197
4197
|
type: "startRun";
|
|
4198
4198
|
} & {
|
|
4199
4199
|
initialCheckpoint: Checkpoint;
|
|
4200
|
-
inputMessages:
|
|
4200
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4201
4201
|
}, "id" | "type" | "runId" | "stepNumber" | "expertKey" | "timestamp">) => BaseEvent & {
|
|
4202
4202
|
type: "startRun";
|
|
4203
4203
|
} & {
|
|
4204
4204
|
initialCheckpoint: Checkpoint;
|
|
4205
|
-
inputMessages:
|
|
4205
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4206
4206
|
};
|
|
4207
4207
|
declare const startGeneration: (setting: RunSetting, checkpoint: Checkpoint, data: Omit<BaseEvent & {
|
|
4208
4208
|
type: "startGeneration";
|
|
@@ -4380,6 +4380,7 @@ declare const continueToNextStep: (setting: RunSetting, checkpoint: Checkpoint,
|
|
|
4380
4380
|
};
|
|
4381
4381
|
|
|
4382
4382
|
declare function run(runInput: RunParamsInput, options?: {
|
|
4383
|
+
shouldContinueRun?: (setting: RunSetting, checkpoint: Checkpoint, step: Step) => Promise<boolean>;
|
|
4383
4384
|
retrieveCheckpoint?: (checkpointId: string) => Promise<Checkpoint>;
|
|
4384
4385
|
storeCheckpoint?: (checkpoint: Checkpoint, timestamp: number) => Promise<void>;
|
|
4385
4386
|
eventListener?: (event: RunEvent) => Promise<void>;
|
|
@@ -4438,7 +4439,7 @@ declare class SkillManager {
|
|
|
4438
4439
|
|
|
4439
4440
|
declare const runtimeStateMachine: xstate.StateMachine<{
|
|
4440
4441
|
setting: RunSetting;
|
|
4441
|
-
step
|
|
4442
|
+
step: Step;
|
|
4442
4443
|
checkpoint: Checkpoint;
|
|
4443
4444
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
4444
4445
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -4452,7 +4453,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
4452
4453
|
type: "startRun";
|
|
4453
4454
|
} & {
|
|
4454
4455
|
initialCheckpoint: Checkpoint;
|
|
4455
|
-
inputMessages:
|
|
4456
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4456
4457
|
}) | ({
|
|
4457
4458
|
id: string;
|
|
4458
4459
|
expertKey: string;
|
|
@@ -4655,7 +4656,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
4655
4656
|
};
|
|
4656
4657
|
self: xstate.ActorRef<xstate.MachineSnapshot<{
|
|
4657
4658
|
setting: RunSetting;
|
|
4658
|
-
step
|
|
4659
|
+
step: Step;
|
|
4659
4660
|
checkpoint: Checkpoint;
|
|
4660
4661
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
4661
4662
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -4669,7 +4670,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
4669
4670
|
type: "startRun";
|
|
4670
4671
|
} & {
|
|
4671
4672
|
initialCheckpoint: Checkpoint;
|
|
4672
|
-
inputMessages:
|
|
4673
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4673
4674
|
}) | ({
|
|
4674
4675
|
id: string;
|
|
4675
4676
|
expertKey: string;
|
|
@@ -4855,7 +4856,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
4855
4856
|
type: "startRun";
|
|
4856
4857
|
} & {
|
|
4857
4858
|
initialCheckpoint: Checkpoint;
|
|
4858
|
-
inputMessages:
|
|
4859
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
4859
4860
|
}) | ({
|
|
4860
4861
|
id: string;
|
|
4861
4862
|
expertKey: string;
|
|
@@ -5220,6 +5221,19 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5220
5221
|
checkpointId: string;
|
|
5221
5222
|
} | undefined;
|
|
5222
5223
|
};
|
|
5224
|
+
step: {
|
|
5225
|
+
stepNumber: number;
|
|
5226
|
+
inputMessages: never[];
|
|
5227
|
+
newMessages: never[];
|
|
5228
|
+
usage: {
|
|
5229
|
+
promptTokens: number;
|
|
5230
|
+
completionTokens: number;
|
|
5231
|
+
totalTokens: number;
|
|
5232
|
+
cacheCreationInputTokens: number;
|
|
5233
|
+
cacheReadInputTokens: number;
|
|
5234
|
+
};
|
|
5235
|
+
startedAt: number;
|
|
5236
|
+
};
|
|
5223
5237
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
5224
5238
|
skillManagers: Record<string, SkillManager>;
|
|
5225
5239
|
};
|
|
@@ -5230,7 +5244,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5230
5244
|
readonly target: "PreparingForStep";
|
|
5231
5245
|
readonly actions: xstate.ActionFunction<{
|
|
5232
5246
|
setting: RunSetting;
|
|
5233
|
-
step
|
|
5247
|
+
step: Step;
|
|
5234
5248
|
checkpoint: Checkpoint;
|
|
5235
5249
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
5236
5250
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -5244,7 +5258,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5244
5258
|
type: "startRun";
|
|
5245
5259
|
} & {
|
|
5246
5260
|
initialCheckpoint: Checkpoint;
|
|
5247
|
-
inputMessages:
|
|
5261
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
5248
5262
|
}, ({
|
|
5249
5263
|
id: string;
|
|
5250
5264
|
expertKey: string;
|
|
@@ -5255,7 +5269,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5255
5269
|
type: "startRun";
|
|
5256
5270
|
} & {
|
|
5257
5271
|
initialCheckpoint: Checkpoint;
|
|
5258
|
-
inputMessages:
|
|
5272
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
5259
5273
|
}) | ({
|
|
5260
5274
|
id: string;
|
|
5261
5275
|
expertKey: string;
|
|
@@ -5441,7 +5455,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5441
5455
|
readonly target: "GeneratingToolCall";
|
|
5442
5456
|
readonly actions: xstate.ActionFunction<{
|
|
5443
5457
|
setting: RunSetting;
|
|
5444
|
-
step
|
|
5458
|
+
step: Step;
|
|
5445
5459
|
checkpoint: Checkpoint;
|
|
5446
5460
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
5447
5461
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -5465,7 +5479,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5465
5479
|
type: "startRun";
|
|
5466
5480
|
} & {
|
|
5467
5481
|
initialCheckpoint: Checkpoint;
|
|
5468
|
-
inputMessages:
|
|
5482
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
5469
5483
|
}) | ({
|
|
5470
5484
|
id: string;
|
|
5471
5485
|
expertKey: string;
|
|
@@ -5651,7 +5665,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5651
5665
|
readonly target: "FinishingStep";
|
|
5652
5666
|
readonly actions: xstate.ActionFunction<{
|
|
5653
5667
|
setting: RunSetting;
|
|
5654
|
-
step
|
|
5668
|
+
step: Step;
|
|
5655
5669
|
checkpoint: Checkpoint;
|
|
5656
5670
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
5657
5671
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -5676,7 +5690,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5676
5690
|
type: "startRun";
|
|
5677
5691
|
} & {
|
|
5678
5692
|
initialCheckpoint: Checkpoint;
|
|
5679
|
-
inputMessages:
|
|
5693
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
5680
5694
|
}) | ({
|
|
5681
5695
|
id: string;
|
|
5682
5696
|
expertKey: string;
|
|
@@ -5858,7 +5872,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5858
5872
|
readonly target: "CallingTool";
|
|
5859
5873
|
readonly actions: xstate.ActionFunction<{
|
|
5860
5874
|
setting: RunSetting;
|
|
5861
|
-
step
|
|
5875
|
+
step: Step;
|
|
5862
5876
|
checkpoint: Checkpoint;
|
|
5863
5877
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
5864
5878
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -5884,7 +5898,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
5884
5898
|
type: "startRun";
|
|
5885
5899
|
} & {
|
|
5886
5900
|
initialCheckpoint: Checkpoint;
|
|
5887
|
-
inputMessages:
|
|
5901
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
5888
5902
|
}) | ({
|
|
5889
5903
|
id: string;
|
|
5890
5904
|
expertKey: string;
|
|
@@ -6066,7 +6080,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6066
6080
|
readonly target: "CallingInteractiveTool";
|
|
6067
6081
|
readonly actions: xstate.ActionFunction<{
|
|
6068
6082
|
setting: RunSetting;
|
|
6069
|
-
step
|
|
6083
|
+
step: Step;
|
|
6070
6084
|
checkpoint: Checkpoint;
|
|
6071
6085
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
6072
6086
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -6092,7 +6106,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6092
6106
|
type: "startRun";
|
|
6093
6107
|
} & {
|
|
6094
6108
|
initialCheckpoint: Checkpoint;
|
|
6095
|
-
inputMessages:
|
|
6109
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
6096
6110
|
}) | ({
|
|
6097
6111
|
id: string;
|
|
6098
6112
|
expertKey: string;
|
|
@@ -6274,7 +6288,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6274
6288
|
readonly target: "CallingDelegate";
|
|
6275
6289
|
readonly actions: xstate.ActionFunction<{
|
|
6276
6290
|
setting: RunSetting;
|
|
6277
|
-
step
|
|
6291
|
+
step: Step;
|
|
6278
6292
|
checkpoint: Checkpoint;
|
|
6279
6293
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
6280
6294
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -6300,7 +6314,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6300
6314
|
type: "startRun";
|
|
6301
6315
|
} & {
|
|
6302
6316
|
initialCheckpoint: Checkpoint;
|
|
6303
|
-
inputMessages:
|
|
6317
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
6304
6318
|
}) | ({
|
|
6305
6319
|
id: string;
|
|
6306
6320
|
expertKey: string;
|
|
@@ -6486,7 +6500,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6486
6500
|
readonly target: "ResolvingToolResult";
|
|
6487
6501
|
readonly actions: xstate.ActionFunction<{
|
|
6488
6502
|
setting: RunSetting;
|
|
6489
|
-
step
|
|
6503
|
+
step: Step;
|
|
6490
6504
|
checkpoint: Checkpoint;
|
|
6491
6505
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
6492
6506
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -6510,7 +6524,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6510
6524
|
type: "startRun";
|
|
6511
6525
|
} & {
|
|
6512
6526
|
initialCheckpoint: Checkpoint;
|
|
6513
|
-
inputMessages:
|
|
6527
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
6514
6528
|
}) | ({
|
|
6515
6529
|
id: string;
|
|
6516
6530
|
expertKey: string;
|
|
@@ -6692,7 +6706,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6692
6706
|
readonly target: "ResolvingThought";
|
|
6693
6707
|
readonly actions: xstate.ActionFunction<{
|
|
6694
6708
|
setting: RunSetting;
|
|
6695
|
-
step
|
|
6709
|
+
step: Step;
|
|
6696
6710
|
checkpoint: Checkpoint;
|
|
6697
6711
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
6698
6712
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -6716,7 +6730,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6716
6730
|
type: "startRun";
|
|
6717
6731
|
} & {
|
|
6718
6732
|
initialCheckpoint: Checkpoint;
|
|
6719
|
-
inputMessages:
|
|
6733
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
6720
6734
|
}) | ({
|
|
6721
6735
|
id: string;
|
|
6722
6736
|
expertKey: string;
|
|
@@ -6898,7 +6912,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6898
6912
|
readonly target: "ResolvingPdfFile";
|
|
6899
6913
|
readonly actions: xstate.ActionFunction<{
|
|
6900
6914
|
setting: RunSetting;
|
|
6901
|
-
step
|
|
6915
|
+
step: Step;
|
|
6902
6916
|
checkpoint: Checkpoint;
|
|
6903
6917
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
6904
6918
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -6922,7 +6936,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
6922
6936
|
type: "startRun";
|
|
6923
6937
|
} & {
|
|
6924
6938
|
initialCheckpoint: Checkpoint;
|
|
6925
|
-
inputMessages:
|
|
6939
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
6926
6940
|
}) | ({
|
|
6927
6941
|
id: string;
|
|
6928
6942
|
expertKey: string;
|
|
@@ -7104,7 +7118,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7104
7118
|
readonly target: "ResolvingImageFile";
|
|
7105
7119
|
readonly actions: xstate.ActionFunction<{
|
|
7106
7120
|
setting: RunSetting;
|
|
7107
|
-
step
|
|
7121
|
+
step: Step;
|
|
7108
7122
|
checkpoint: Checkpoint;
|
|
7109
7123
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
7110
7124
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -7128,7 +7142,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7128
7142
|
type: "startRun";
|
|
7129
7143
|
} & {
|
|
7130
7144
|
initialCheckpoint: Checkpoint;
|
|
7131
|
-
inputMessages:
|
|
7145
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
7132
7146
|
}) | ({
|
|
7133
7147
|
id: string;
|
|
7134
7148
|
expertKey: string;
|
|
@@ -7310,7 +7324,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7310
7324
|
readonly target: "GeneratingRunResult";
|
|
7311
7325
|
readonly actions: xstate.ActionFunction<{
|
|
7312
7326
|
setting: RunSetting;
|
|
7313
|
-
step
|
|
7327
|
+
step: Step;
|
|
7314
7328
|
checkpoint: Checkpoint;
|
|
7315
7329
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
7316
7330
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -7334,7 +7348,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7334
7348
|
type: "startRun";
|
|
7335
7349
|
} & {
|
|
7336
7350
|
initialCheckpoint: Checkpoint;
|
|
7337
|
-
inputMessages:
|
|
7351
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
7338
7352
|
}) | ({
|
|
7339
7353
|
id: string;
|
|
7340
7354
|
expertKey: string;
|
|
@@ -7520,7 +7534,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7520
7534
|
readonly target: "FinishingStep";
|
|
7521
7535
|
readonly actions: xstate.ActionFunction<{
|
|
7522
7536
|
setting: RunSetting;
|
|
7523
|
-
step
|
|
7537
|
+
step: Step;
|
|
7524
7538
|
checkpoint: Checkpoint;
|
|
7525
7539
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
7526
7540
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -7544,7 +7558,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7544
7558
|
type: "startRun";
|
|
7545
7559
|
} & {
|
|
7546
7560
|
initialCheckpoint: Checkpoint;
|
|
7547
|
-
inputMessages:
|
|
7561
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
7548
7562
|
}) | ({
|
|
7549
7563
|
id: string;
|
|
7550
7564
|
expertKey: string;
|
|
@@ -7730,7 +7744,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7730
7744
|
readonly target: "FinishingStep";
|
|
7731
7745
|
readonly actions: xstate.ActionFunction<{
|
|
7732
7746
|
setting: RunSetting;
|
|
7733
|
-
step
|
|
7747
|
+
step: Step;
|
|
7734
7748
|
checkpoint: Checkpoint;
|
|
7735
7749
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
7736
7750
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -7754,7 +7768,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7754
7768
|
type: "startRun";
|
|
7755
7769
|
} & {
|
|
7756
7770
|
initialCheckpoint: Checkpoint;
|
|
7757
|
-
inputMessages:
|
|
7771
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
7758
7772
|
}) | ({
|
|
7759
7773
|
id: string;
|
|
7760
7774
|
expertKey: string;
|
|
@@ -7940,7 +7954,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7940
7954
|
readonly target: "FinishingStep";
|
|
7941
7955
|
readonly actions: xstate.ActionFunction<{
|
|
7942
7956
|
setting: RunSetting;
|
|
7943
|
-
step
|
|
7957
|
+
step: Step;
|
|
7944
7958
|
checkpoint: Checkpoint;
|
|
7945
7959
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
7946
7960
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -7964,7 +7978,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
7964
7978
|
type: "startRun";
|
|
7965
7979
|
} & {
|
|
7966
7980
|
initialCheckpoint: Checkpoint;
|
|
7967
|
-
inputMessages:
|
|
7981
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
7968
7982
|
}) | ({
|
|
7969
7983
|
id: string;
|
|
7970
7984
|
expertKey: string;
|
|
@@ -8150,7 +8164,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8150
8164
|
readonly target: "FinishingStep";
|
|
8151
8165
|
readonly actions: xstate.ActionFunction<{
|
|
8152
8166
|
setting: RunSetting;
|
|
8153
|
-
step
|
|
8167
|
+
step: Step;
|
|
8154
8168
|
checkpoint: Checkpoint;
|
|
8155
8169
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
8156
8170
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -8174,7 +8188,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8174
8188
|
type: "startRun";
|
|
8175
8189
|
} & {
|
|
8176
8190
|
initialCheckpoint: Checkpoint;
|
|
8177
|
-
inputMessages:
|
|
8191
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
8178
8192
|
}) | ({
|
|
8179
8193
|
id: string;
|
|
8180
8194
|
expertKey: string;
|
|
@@ -8360,7 +8374,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8360
8374
|
readonly target: "Stopped";
|
|
8361
8375
|
readonly actions: xstate.ActionFunction<{
|
|
8362
8376
|
setting: RunSetting;
|
|
8363
|
-
step
|
|
8377
|
+
step: Step;
|
|
8364
8378
|
checkpoint: Checkpoint;
|
|
8365
8379
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
8366
8380
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -8387,7 +8401,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8387
8401
|
type: "startRun";
|
|
8388
8402
|
} & {
|
|
8389
8403
|
initialCheckpoint: Checkpoint;
|
|
8390
|
-
inputMessages:
|
|
8404
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
8391
8405
|
}) | ({
|
|
8392
8406
|
id: string;
|
|
8393
8407
|
expertKey: string;
|
|
@@ -8573,7 +8587,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8573
8587
|
readonly target: "Stopped";
|
|
8574
8588
|
readonly actions: xstate.ActionFunction<{
|
|
8575
8589
|
setting: RunSetting;
|
|
8576
|
-
step
|
|
8590
|
+
step: Step;
|
|
8577
8591
|
checkpoint: Checkpoint;
|
|
8578
8592
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
8579
8593
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -8598,7 +8612,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8598
8612
|
type: "startRun";
|
|
8599
8613
|
} & {
|
|
8600
8614
|
initialCheckpoint: Checkpoint;
|
|
8601
|
-
inputMessages:
|
|
8615
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
8602
8616
|
}) | ({
|
|
8603
8617
|
id: string;
|
|
8604
8618
|
expertKey: string;
|
|
@@ -8784,7 +8798,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8784
8798
|
readonly target: "Stopped";
|
|
8785
8799
|
readonly actions: xstate.ActionFunction<{
|
|
8786
8800
|
setting: RunSetting;
|
|
8787
|
-
step
|
|
8801
|
+
step: Step;
|
|
8788
8802
|
checkpoint: Checkpoint;
|
|
8789
8803
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
8790
8804
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -8809,7 +8823,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8809
8823
|
type: "startRun";
|
|
8810
8824
|
} & {
|
|
8811
8825
|
initialCheckpoint: Checkpoint;
|
|
8812
|
-
inputMessages:
|
|
8826
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
8813
8827
|
}) | ({
|
|
8814
8828
|
id: string;
|
|
8815
8829
|
expertKey: string;
|
|
@@ -8995,7 +9009,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
8995
9009
|
readonly target: "PreparingForStep";
|
|
8996
9010
|
readonly actions: xstate.ActionFunction<{
|
|
8997
9011
|
setting: RunSetting;
|
|
8998
|
-
step
|
|
9012
|
+
step: Step;
|
|
8999
9013
|
checkpoint: Checkpoint;
|
|
9000
9014
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
9001
9015
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -9021,7 +9035,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
9021
9035
|
type: "startRun";
|
|
9022
9036
|
} & {
|
|
9023
9037
|
initialCheckpoint: Checkpoint;
|
|
9024
|
-
inputMessages:
|
|
9038
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
9025
9039
|
}) | ({
|
|
9026
9040
|
id: string;
|
|
9027
9041
|
expertKey: string;
|
|
@@ -9204,7 +9218,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
9204
9218
|
readonly target: "Stopped";
|
|
9205
9219
|
readonly actions: xstate.ActionFunction<{
|
|
9206
9220
|
setting: RunSetting;
|
|
9207
|
-
step
|
|
9221
|
+
step: Step;
|
|
9208
9222
|
checkpoint: Checkpoint;
|
|
9209
9223
|
eventListener: (event: RunEvent) => Promise<void>;
|
|
9210
9224
|
skillManagers: Record<string, SkillManager>;
|
|
@@ -9229,7 +9243,7 @@ declare const runtimeStateMachine: xstate.StateMachine<{
|
|
|
9229
9243
|
type: "startRun";
|
|
9230
9244
|
} & {
|
|
9231
9245
|
initialCheckpoint: Checkpoint;
|
|
9232
|
-
inputMessages:
|
|
9246
|
+
inputMessages: (InstructionMessage | UserMessage | ToolMessage)[];
|
|
9233
9247
|
}) | ({
|
|
9234
9248
|
id: string;
|
|
9235
9249
|
expertKey: string;
|
package/dist/index.js
CHANGED
|
@@ -394,7 +394,6 @@ var RunParamsSchema = z2.object({
|
|
|
394
394
|
temperature: z2.number().min(0).max(1).optional().default(0.3),
|
|
395
395
|
maxSteps: z2.number().min(1).optional(),
|
|
396
396
|
maxRetries: z2.number().min(0).optional().default(10),
|
|
397
|
-
/** Optional workspace directory path. If provided, sets WORKSPACE_DIR environment variable for skill execution. */
|
|
398
397
|
workspace: z2.string().optional(),
|
|
399
398
|
startedAt: z2.number().optional().default(Date.now()),
|
|
400
399
|
updatedAt: z2.number().optional().default(Date.now())
|
|
@@ -464,7 +463,7 @@ async function defaultStoreEvent(event) {
|
|
|
464
463
|
// package.json
|
|
465
464
|
var package_default = {
|
|
466
465
|
name: "@perstack/runtime",
|
|
467
|
-
version: "0.0.
|
|
466
|
+
version: "0.0.20",
|
|
468
467
|
description: "PerStack Runtime",
|
|
469
468
|
author: "Wintermute Technologies, Inc.",
|
|
470
469
|
license: "Apache-2.0",
|
|
@@ -1777,33 +1776,48 @@ async function initLogic({
|
|
|
1777
1776
|
const { expertKey, experts } = setting;
|
|
1778
1777
|
const expert = experts[expertKey];
|
|
1779
1778
|
switch (checkpoint.status) {
|
|
1780
|
-
case "init":
|
|
1779
|
+
case "init": {
|
|
1780
|
+
if (!setting.input.text) {
|
|
1781
|
+
throw new Error("Input message is undefined");
|
|
1782
|
+
}
|
|
1781
1783
|
return startRun(setting, checkpoint, {
|
|
1782
1784
|
initialCheckpoint: checkpoint,
|
|
1783
|
-
inputMessages: [
|
|
1785
|
+
inputMessages: [
|
|
1786
|
+
createInstructionMessage(expert, experts),
|
|
1787
|
+
createUserMessage([{ type: "textPart", text: setting.input.text }])
|
|
1788
|
+
]
|
|
1784
1789
|
});
|
|
1785
|
-
|
|
1790
|
+
}
|
|
1791
|
+
case "proceeding": {
|
|
1792
|
+
if (!setting.input.text) {
|
|
1793
|
+
throw new Error("Input message is undefined");
|
|
1794
|
+
}
|
|
1786
1795
|
return startRun(setting, checkpoint, {
|
|
1787
1796
|
initialCheckpoint: checkpoint,
|
|
1788
|
-
inputMessages: [
|
|
1797
|
+
inputMessages: [createUserMessage([{ type: "textPart", text: setting.input.text }])]
|
|
1789
1798
|
});
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
return createUserMessage([{ type: "textPart", text: input.text }]);
|
|
1795
|
-
}
|
|
1796
|
-
if (input.interactiveToolCallResult) {
|
|
1797
|
-
return createToolMessage([
|
|
1798
|
-
{
|
|
1799
|
-
type: "toolResultPart",
|
|
1800
|
-
toolCallId: input.interactiveToolCallResult.toolCallId,
|
|
1801
|
-
toolName: input.interactiveToolCallResult.toolName,
|
|
1802
|
-
contents: [{ type: "textPart", text: input.interactiveToolCallResult.text }]
|
|
1799
|
+
}
|
|
1800
|
+
case "stoppedByInteractiveTool": {
|
|
1801
|
+
if (!setting.input.interactiveToolCallResult) {
|
|
1802
|
+
throw new Error("Interactive tool call result is undefined");
|
|
1803
1803
|
}
|
|
1804
|
-
|
|
1804
|
+
return startRun(setting, checkpoint, {
|
|
1805
|
+
initialCheckpoint: checkpoint,
|
|
1806
|
+
inputMessages: [
|
|
1807
|
+
createToolMessage([
|
|
1808
|
+
{
|
|
1809
|
+
type: "toolResultPart",
|
|
1810
|
+
toolCallId: setting.input.interactiveToolCallResult.toolCallId,
|
|
1811
|
+
toolName: setting.input.interactiveToolCallResult.toolName,
|
|
1812
|
+
contents: [{ type: "textPart", text: setting.input.interactiveToolCallResult.text }]
|
|
1813
|
+
}
|
|
1814
|
+
])
|
|
1815
|
+
]
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
default:
|
|
1819
|
+
throw new Error(`Unexpected checkpoint status: ${checkpoint.status}`);
|
|
1805
1820
|
}
|
|
1806
|
-
throw new Error("Input message is undefined");
|
|
1807
1821
|
}
|
|
1808
1822
|
|
|
1809
1823
|
// src/states/preparing-for-step.ts
|
|
@@ -1970,6 +1984,13 @@ var runtimeStateMachine = setup({
|
|
|
1970
1984
|
context: ({ input }) => ({
|
|
1971
1985
|
setting: input.setting,
|
|
1972
1986
|
checkpoint: input.initialCheckpoint,
|
|
1987
|
+
step: {
|
|
1988
|
+
stepNumber: input.initialCheckpoint.stepNumber,
|
|
1989
|
+
inputMessages: [],
|
|
1990
|
+
newMessages: [],
|
|
1991
|
+
usage: createEmptyUsage(),
|
|
1992
|
+
startedAt: Date.now()
|
|
1993
|
+
},
|
|
1973
1994
|
eventListener: input.eventListener,
|
|
1974
1995
|
skillManagers: input.skillManagers
|
|
1975
1996
|
}),
|
|
@@ -1983,6 +2004,13 @@ var runtimeStateMachine = setup({
|
|
|
1983
2004
|
...event.initialCheckpoint,
|
|
1984
2005
|
messages: [...event.initialCheckpoint.messages, ...event.inputMessages],
|
|
1985
2006
|
status: "proceeding"
|
|
2007
|
+
}),
|
|
2008
|
+
step: ({ event }) => ({
|
|
2009
|
+
stepNumber: event.initialCheckpoint.stepNumber,
|
|
2010
|
+
inputMessages: event.inputMessages,
|
|
2011
|
+
newMessages: [],
|
|
2012
|
+
usage: createEmptyUsage(),
|
|
2013
|
+
startedAt: event.timestamp
|
|
1986
2014
|
})
|
|
1987
2015
|
})
|
|
1988
2016
|
}
|
|
@@ -1995,6 +2023,7 @@ var runtimeStateMachine = setup({
|
|
|
1995
2023
|
actions: assign({
|
|
1996
2024
|
step: ({ context, event }) => ({
|
|
1997
2025
|
stepNumber: context.checkpoint.stepNumber,
|
|
2026
|
+
inputMessages: context.step.inputMessages,
|
|
1998
2027
|
newMessages: [],
|
|
1999
2028
|
usage: createEmptyUsage(),
|
|
2000
2029
|
startedAt: event.timestamp
|
|
@@ -2226,7 +2255,10 @@ var runtimeStateMachine = setup({
|
|
|
2226
2255
|
target: "PreparingForStep",
|
|
2227
2256
|
actions: assign({
|
|
2228
2257
|
checkpoint: ({ event }) => event.nextCheckpoint,
|
|
2229
|
-
step: ({ event }) =>
|
|
2258
|
+
step: ({ event }) => ({
|
|
2259
|
+
...event.step,
|
|
2260
|
+
inputMessages: void 0
|
|
2261
|
+
})
|
|
2230
2262
|
}),
|
|
2231
2263
|
reenter: true
|
|
2232
2264
|
},
|
|
@@ -2234,7 +2266,10 @@ var runtimeStateMachine = setup({
|
|
|
2234
2266
|
target: "Stopped",
|
|
2235
2267
|
actions: assign({
|
|
2236
2268
|
checkpoint: ({ event }) => event.checkpoint,
|
|
2237
|
-
step: ({ event }) =>
|
|
2269
|
+
step: ({ event }) => ({
|
|
2270
|
+
...event.step,
|
|
2271
|
+
inputMessages: void 0
|
|
2272
|
+
})
|
|
2238
2273
|
})
|
|
2239
2274
|
}
|
|
2240
2275
|
}
|
|
@@ -2340,7 +2375,19 @@ async function run(runInput, options) {
|
|
|
2340
2375
|
...setting,
|
|
2341
2376
|
experts
|
|
2342
2377
|
},
|
|
2343
|
-
initialCheckpoint: checkpoint
|
|
2378
|
+
initialCheckpoint: checkpoint ? {
|
|
2379
|
+
id: createId7(),
|
|
2380
|
+
runId: setting.runId,
|
|
2381
|
+
expert: {
|
|
2382
|
+
key: setting.expertKey,
|
|
2383
|
+
name: expertToRun.name,
|
|
2384
|
+
version: expertToRun.version
|
|
2385
|
+
},
|
|
2386
|
+
stepNumber: checkpoint.stepNumber + 1,
|
|
2387
|
+
status: "proceeding",
|
|
2388
|
+
messages: checkpoint.messages,
|
|
2389
|
+
usage: checkpoint.usage
|
|
2390
|
+
} : {
|
|
2344
2391
|
id: createId7(),
|
|
2345
2392
|
runId: setting.runId,
|
|
2346
2393
|
expert: {
|
|
@@ -2373,6 +2420,18 @@ async function run(runInput, options) {
|
|
|
2373
2420
|
await storeCheckpoint(event.checkpoint, event.timestamp);
|
|
2374
2421
|
}
|
|
2375
2422
|
await eventEmitter.emit(event);
|
|
2423
|
+
if (options?.shouldContinueRun) {
|
|
2424
|
+
const shouldContinue = await options.shouldContinueRun(
|
|
2425
|
+
runState.context.setting,
|
|
2426
|
+
runState.context.checkpoint,
|
|
2427
|
+
runState.context.step
|
|
2428
|
+
);
|
|
2429
|
+
if (!shouldContinue) {
|
|
2430
|
+
runActor.stop();
|
|
2431
|
+
resolve(runState.context.checkpoint);
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2376
2435
|
runActor.send(event);
|
|
2377
2436
|
}
|
|
2378
2437
|
} catch (error) {
|