@runtypelabs/sdk 4.21.0 → 5.1.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 +4 -138
- package/dist/index.d.cts +918 -1022
- package/dist/index.d.ts +918 -1022
- package/dist/index.mjs +4 -137
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,7 +60,6 @@ __export(index_exports, {
|
|
|
60
60
|
ProductDriftError: () => ProductDriftError,
|
|
61
61
|
ProductEnsureConflictError: () => ProductEnsureConflictError,
|
|
62
62
|
ProductsNamespace: () => ProductsNamespace,
|
|
63
|
-
PromptRunner: () => PromptRunner,
|
|
64
63
|
PromptsEndpoint: () => PromptsEndpoint,
|
|
65
64
|
PromptsNamespace: () => PromptsNamespace,
|
|
66
65
|
ProviderKeysEndpoint: () => ProviderKeysEndpoint,
|
|
@@ -951,7 +950,7 @@ var FlowResult = class {
|
|
|
951
950
|
/**
|
|
952
951
|
* @param options.unified - The response is a unified-vocabulary SSE stream
|
|
953
952
|
* (`/dispatch` since the unified-SSE cutover). Set by dispatch call sites;
|
|
954
|
-
* left unset by still-legacy
|
|
953
|
+
* left unset by the still-legacy eval stream producer.
|
|
955
954
|
*/
|
|
956
955
|
constructor(response, summary, options = {}) {
|
|
957
956
|
this.consumed = false;
|
|
@@ -1034,6 +1033,7 @@ var FlowResult = class {
|
|
|
1034
1033
|
* const analysis = await result.getResult('analyze screenshot') // ✗ undefined
|
|
1035
1034
|
* ```
|
|
1036
1035
|
*/
|
|
1036
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK step results are intentionally untyped (FlowSummary.results is Map<string, any>); consumers narrow at the use site
|
|
1037
1037
|
async getResult(stepName) {
|
|
1038
1038
|
const summary = await this.ensureSummary();
|
|
1039
1039
|
if (summary.results.has(stepName)) {
|
|
@@ -1054,6 +1054,7 @@ var FlowResult = class {
|
|
|
1054
1054
|
* }
|
|
1055
1055
|
* ```
|
|
1056
1056
|
*/
|
|
1057
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK step results are intentionally untyped (FlowSummary.results is Map<string, any>); consumers narrow at the use site
|
|
1057
1058
|
async getAllResults() {
|
|
1058
1059
|
const summary = await this.ensureSummary();
|
|
1059
1060
|
return summary.results;
|
|
@@ -3615,138 +3616,10 @@ var EvalsNamespace = class {
|
|
|
3615
3616
|
};
|
|
3616
3617
|
|
|
3617
3618
|
// src/prompts-namespace.ts
|
|
3618
|
-
var PromptRunner = class {
|
|
3619
|
-
constructor(getClient, promptId, options) {
|
|
3620
|
-
this.getClient = getClient;
|
|
3621
|
-
this.promptId = promptId;
|
|
3622
|
-
this.options = options;
|
|
3623
|
-
}
|
|
3624
|
-
/**
|
|
3625
|
-
* Execute the prompt with streaming response
|
|
3626
|
-
*
|
|
3627
|
-
* Streams the prompt response as it's generated.
|
|
3628
|
-
*
|
|
3629
|
-
* @example
|
|
3630
|
-
* ```typescript
|
|
3631
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3632
|
-
* recordId: 'rec_456'
|
|
3633
|
-
* }).stream()
|
|
3634
|
-
*
|
|
3635
|
-
* // Process with callbacks
|
|
3636
|
-
* await result.stream({
|
|
3637
|
-
* onStepDelta: (text) => process.stdout.write(text),
|
|
3638
|
-
* onFlowComplete: () => console.log('Done!'),
|
|
3639
|
-
* })
|
|
3640
|
-
* ```
|
|
3641
|
-
*/
|
|
3642
|
-
async stream(callbacks) {
|
|
3643
|
-
const client = this.getClient();
|
|
3644
|
-
const payload = this.buildPayload();
|
|
3645
|
-
payload.stream = true;
|
|
3646
|
-
const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
|
|
3647
|
-
method: "POST",
|
|
3648
|
-
body: JSON.stringify(payload)
|
|
3649
|
-
});
|
|
3650
|
-
const result = new FlowResult(response);
|
|
3651
|
-
if (callbacks) {
|
|
3652
|
-
await result.stream(callbacks);
|
|
3653
|
-
}
|
|
3654
|
-
return result;
|
|
3655
|
-
}
|
|
3656
|
-
/**
|
|
3657
|
-
* Execute the prompt and wait for complete result
|
|
3658
|
-
*
|
|
3659
|
-
* Waits for the entire response before returning.
|
|
3660
|
-
*
|
|
3661
|
-
* @example
|
|
3662
|
-
* ```typescript
|
|
3663
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3664
|
-
* recordId: 'rec_456'
|
|
3665
|
-
* }).result()
|
|
3666
|
-
*
|
|
3667
|
-
* const output = await result.getResult('prompt')
|
|
3668
|
-
* console.log(output)
|
|
3669
|
-
* ```
|
|
3670
|
-
*/
|
|
3671
|
-
async result() {
|
|
3672
|
-
const client = this.getClient();
|
|
3673
|
-
const payload = this.buildPayload();
|
|
3674
|
-
payload.stream = true;
|
|
3675
|
-
const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
|
|
3676
|
-
method: "POST",
|
|
3677
|
-
body: JSON.stringify(payload)
|
|
3678
|
-
});
|
|
3679
|
-
const result = new FlowResult(response);
|
|
3680
|
-
await result.getSummary();
|
|
3681
|
-
return result;
|
|
3682
|
-
}
|
|
3683
|
-
/**
|
|
3684
|
-
* Build the run payload
|
|
3685
|
-
*/
|
|
3686
|
-
buildPayload() {
|
|
3687
|
-
const payload = {};
|
|
3688
|
-
if (this.options.recordId) {
|
|
3689
|
-
payload.recordId = this.options.recordId;
|
|
3690
|
-
} else if (this.options.record) {
|
|
3691
|
-
payload.record = this.options.record;
|
|
3692
|
-
}
|
|
3693
|
-
if (this.options.modelOverride) {
|
|
3694
|
-
payload.modelOverride = this.options.modelOverride;
|
|
3695
|
-
}
|
|
3696
|
-
if (this.options.temperature !== void 0) {
|
|
3697
|
-
payload.temperature = this.options.temperature;
|
|
3698
|
-
}
|
|
3699
|
-
if (this.options.topP !== void 0) {
|
|
3700
|
-
payload.topP = this.options.topP;
|
|
3701
|
-
}
|
|
3702
|
-
if (this.options.topK !== void 0) {
|
|
3703
|
-
payload.topK = this.options.topK;
|
|
3704
|
-
}
|
|
3705
|
-
if (this.options.frequencyPenalty !== void 0) {
|
|
3706
|
-
payload.frequencyPenalty = this.options.frequencyPenalty;
|
|
3707
|
-
}
|
|
3708
|
-
if (this.options.presencePenalty !== void 0) {
|
|
3709
|
-
payload.presencePenalty = this.options.presencePenalty;
|
|
3710
|
-
}
|
|
3711
|
-
if (this.options.seed !== void 0) {
|
|
3712
|
-
payload.seed = this.options.seed;
|
|
3713
|
-
}
|
|
3714
|
-
if (this.options.maxTokens !== void 0) {
|
|
3715
|
-
payload.maxTokens = this.options.maxTokens;
|
|
3716
|
-
}
|
|
3717
|
-
if (this.options.storeResult !== void 0) {
|
|
3718
|
-
payload.storeResult = this.options.storeResult;
|
|
3719
|
-
}
|
|
3720
|
-
return payload;
|
|
3721
|
-
}
|
|
3722
|
-
};
|
|
3723
3619
|
var PromptsNamespace = class {
|
|
3724
3620
|
constructor(getClient) {
|
|
3725
3621
|
this.getClient = getClient;
|
|
3726
3622
|
}
|
|
3727
|
-
/**
|
|
3728
|
-
* Run a prompt
|
|
3729
|
-
*
|
|
3730
|
-
* Returns a PromptRunner with terminal methods:
|
|
3731
|
-
* - .stream() - Execute and stream results
|
|
3732
|
-
* - .result() - Execute and wait for complete result
|
|
3733
|
-
*
|
|
3734
|
-
* @example
|
|
3735
|
-
* ```typescript
|
|
3736
|
-
* // Stream the response
|
|
3737
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3738
|
-
* recordId: 'rec_456'
|
|
3739
|
-
* }).stream()
|
|
3740
|
-
*
|
|
3741
|
-
* // Get complete result
|
|
3742
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3743
|
-
* record: { name: 'Test', metadata: { input: 'Hello' } }
|
|
3744
|
-
* }).result()
|
|
3745
|
-
* ```
|
|
3746
|
-
*/
|
|
3747
|
-
run(promptId, options = {}) {
|
|
3748
|
-
return new PromptRunner(this.getClient, promptId, options);
|
|
3749
|
-
}
|
|
3750
3623
|
/**
|
|
3751
3624
|
* Create a new prompt
|
|
3752
3625
|
*
|
|
@@ -5797,7 +5670,7 @@ var Runtype = class {
|
|
|
5797
5670
|
|
|
5798
5671
|
// src/version.ts
|
|
5799
5672
|
var FALLBACK_VERSION = "0.0.0";
|
|
5800
|
-
var SDK_VERSION = "
|
|
5673
|
+
var SDK_VERSION = "5.1.0".length > 0 ? "5.1.0" : FALLBACK_VERSION;
|
|
5801
5674
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
5802
5675
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
5803
5676
|
|
|
@@ -7920,12 +7793,6 @@ var PromptsEndpoint = class {
|
|
|
7920
7793
|
async delete(id) {
|
|
7921
7794
|
return this.client.delete(`/prompts/${id}`);
|
|
7922
7795
|
}
|
|
7923
|
-
/**
|
|
7924
|
-
* Run a prompt on a specific record
|
|
7925
|
-
*/
|
|
7926
|
-
async runOnRecord(id, recordId) {
|
|
7927
|
-
return this.client.post(`/prompts/${id}/run-on-record`, { recordId });
|
|
7928
|
-
}
|
|
7929
7796
|
/**
|
|
7930
7797
|
* Get flows using this prompt
|
|
7931
7798
|
*/
|
|
@@ -13477,7 +13344,6 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13477
13344
|
ProductDriftError,
|
|
13478
13345
|
ProductEnsureConflictError,
|
|
13479
13346
|
ProductsNamespace,
|
|
13480
|
-
PromptRunner,
|
|
13481
13347
|
PromptsEndpoint,
|
|
13482
13348
|
PromptsNamespace,
|
|
13483
13349
|
ProviderKeysEndpoint,
|