@roarkanalytics/sdk 5.12.0 → 5.14.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/CHANGELOG.md +19 -0
- package/lib/config.d.mts +45 -0
- package/lib/config.d.mts.map +1 -0
- package/lib/config.d.ts +45 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +91 -0
- package/lib/config.js.map +1 -0
- package/lib/config.mjs +73 -0
- package/lib/config.mjs.map +1 -0
- package/package.json +11 -1
- package/resources/config.d.mts +48 -0
- package/resources/config.d.mts.map +1 -1
- package/resources/config.d.ts +48 -0
- package/resources/config.d.ts.map +1 -1
- package/src/lib/config.ts +131 -0
- package/src/resources/config.ts +72 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Code-first config authoring: a typed, ergonomic alternative to hand-written
|
|
2
|
+
// config YAML. Build agents, tools, personas, flows, metrics and the rest in
|
|
3
|
+
// TypeScript, then ship them with `client.config.apply(...)` (or preview with
|
|
4
|
+
// `client.config.diff(...)`).
|
|
5
|
+
//
|
|
6
|
+
// Each `define*` helper injects the resource's `kind` (and any fixed
|
|
7
|
+
// discriminator) and returns the exact param object the config endpoints expect,
|
|
8
|
+
// so the output is identical to the YAML path: both produce a config bundle.
|
|
9
|
+
// Input types are DERIVED from the generated `ConfigApplyParams`, so a new field
|
|
10
|
+
// on a resource (for example a tool `handler`) shows up here automatically on the
|
|
11
|
+
// next codegen, with no change to this file.
|
|
12
|
+
//
|
|
13
|
+
// This lives in `src/lib`, which Stainless codegen never touches. Import it from
|
|
14
|
+
// `@roarkanalytics/sdk/lib/config`.
|
|
15
|
+
|
|
16
|
+
import type { ConfigApplyParams } from '../resources/config';
|
|
17
|
+
|
|
18
|
+
// ── Cross-references ──
|
|
19
|
+
// A resource that points at another by name accepts either the construct a
|
|
20
|
+
// `define*` helper returned (its `name` is used) or a bare name string.
|
|
21
|
+
export type Ref<T extends { name: string }> = T | string;
|
|
22
|
+
|
|
23
|
+
const refName = <T extends { name: string }>(ref: Ref<T>): string =>
|
|
24
|
+
typeof ref === 'string' ? ref : ref.name;
|
|
25
|
+
|
|
26
|
+
// ── Friendly aliases for the generated param types ──
|
|
27
|
+
export type AgentConfig = ConfigApplyParams.AgentConfig;
|
|
28
|
+
export type HTTPRequestDefinitionConfig = ConfigApplyParams.HTTPRequestDefinitionConfig;
|
|
29
|
+
export type PersonaConfig = ConfigApplyParams.PersonaConfig;
|
|
30
|
+
export type ImprovFlowConfig = ConfigApplyParams.ImprovFlowConfig;
|
|
31
|
+
export type ScriptedFlowConfig = ConfigApplyParams.ScriptedFlowConfig;
|
|
32
|
+
export type CollectorConfig = ConfigApplyParams.CollectorConfig;
|
|
33
|
+
export type MetricConfig = ConfigApplyParams.MetricConfig;
|
|
34
|
+
export type SimulationPlanConfig = ConfigApplyParams.SimulationPlanConfig;
|
|
35
|
+
export type QaSimulationPlanConfig = ConfigApplyParams.QaSimulationPlanConfig;
|
|
36
|
+
export type SimulationGroupConfig = ConfigApplyParams.SimulationGroupConfig;
|
|
37
|
+
export type AlertConfig = ConfigApplyParams.AlertConfig;
|
|
38
|
+
export type ToolConfig = ConfigApplyParams.ToolConfig;
|
|
39
|
+
export type DashboardConfig = ConfigApplyParams.DashboardConfig;
|
|
40
|
+
export type ProjectConfig = ConfigApplyParams.ProjectConfig;
|
|
41
|
+
|
|
42
|
+
/** Any resource a config bundle can carry. */
|
|
43
|
+
export type ResourceConfig = ConfigApplyParams['resources'][number];
|
|
44
|
+
|
|
45
|
+
// ── Builders ──
|
|
46
|
+
// Prompts are just strings here: pass an inline template literal or
|
|
47
|
+
// `readFileSync('./prompt.md', 'utf8')`. No `file://` sentinel needed.
|
|
48
|
+
|
|
49
|
+
export const defineAgent = (agent: Omit<AgentConfig, 'kind'>): AgentConfig => ({ kind: 'agent', ...agent });
|
|
50
|
+
|
|
51
|
+
export const defineHTTPRequestDefinition = (
|
|
52
|
+
def: Omit<HTTPRequestDefinitionConfig, 'kind'>,
|
|
53
|
+
): HTTPRequestDefinitionConfig => ({ kind: 'httpRequestDefinition', ...def });
|
|
54
|
+
|
|
55
|
+
export const definePersona = (persona: Omit<PersonaConfig, 'kind'>): PersonaConfig => ({
|
|
56
|
+
kind: 'persona',
|
|
57
|
+
...persona,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const defineImprovFlow = (flow: Omit<ImprovFlowConfig, 'kind' | 'type'>): ImprovFlowConfig => ({
|
|
61
|
+
kind: 'flow',
|
|
62
|
+
type: 'improv',
|
|
63
|
+
...flow,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const defineScriptedFlow = (flow: Omit<ScriptedFlowConfig, 'kind' | 'type'>): ScriptedFlowConfig => ({
|
|
67
|
+
kind: 'flow',
|
|
68
|
+
type: 'scripted',
|
|
69
|
+
...flow,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const defineCollector = (collector: Omit<CollectorConfig, 'kind'>): CollectorConfig => ({
|
|
73
|
+
kind: 'collector',
|
|
74
|
+
...collector,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const defineMetric = (metric: Omit<MetricConfig, 'kind'>): MetricConfig => ({
|
|
78
|
+
kind: 'metric',
|
|
79
|
+
...metric,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const defineSimulationPlan = (plan: Omit<SimulationPlanConfig, 'kind'>): SimulationPlanConfig => ({
|
|
83
|
+
kind: 'simulationPlan',
|
|
84
|
+
...plan,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const defineQaSimulationPlan = (
|
|
88
|
+
plan: Omit<QaSimulationPlanConfig, 'kind' | 'template'>,
|
|
89
|
+
): QaSimulationPlanConfig => ({ kind: 'simulationPlan', template: 'question-answer-check', ...plan });
|
|
90
|
+
|
|
91
|
+
export const defineSimulationGroup = (group: Omit<SimulationGroupConfig, 'kind'>): SimulationGroupConfig => ({
|
|
92
|
+
kind: 'simulationGroup',
|
|
93
|
+
...group,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const defineAlert = (alert: Omit<AlertConfig, 'kind'>): AlertConfig => ({ kind: 'alert', ...alert });
|
|
97
|
+
|
|
98
|
+
export const defineDashboard = (dashboard: Omit<DashboardConfig, 'kind'>): DashboardConfig => ({
|
|
99
|
+
kind: 'dashboard',
|
|
100
|
+
...dashboard,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const defineProject = (project: Omit<ProjectConfig, 'kind'>): ProjectConfig => ({
|
|
104
|
+
kind: 'project',
|
|
105
|
+
...project,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/** Input to `defineTool`: `agent` accepts the agent construct or a name string. */
|
|
109
|
+
export type DefineToolInput = Omit<ToolConfig, 'kind' | 'agent'> & {
|
|
110
|
+
/** Scope the tool to one agent (omit for a project-wide tool). */
|
|
111
|
+
agent?: Ref<AgentConfig>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const defineTool = (tool: DefineToolInput): ToolConfig => {
|
|
115
|
+
const { agent, ...rest } = tool;
|
|
116
|
+
return { kind: 'tool', ...rest, ...(agent === undefined ? {} : { agent: refName(agent) }) };
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ── The bundle ──
|
|
120
|
+
// `defineConfig` assembles the bundle you hand to `client.config.apply(bundle)`
|
|
121
|
+
// or `client.config.diff(bundle)`. `resources` accepts both construct outputs
|
|
122
|
+
// and raw resource objects, so a kind without a dedicated builder still fits.
|
|
123
|
+
|
|
124
|
+
export const defineConfig = (bundle: {
|
|
125
|
+
resources: Array<ResourceConfig>;
|
|
126
|
+
/** When true (the server default) config-managed resources absent from the bundle are deleted. */
|
|
127
|
+
prune?: boolean;
|
|
128
|
+
}): ConfigApplyParams => ({
|
|
129
|
+
resources: bundle.resources,
|
|
130
|
+
...(bundle.prune === undefined ? {} : { prune: bundle.prune }),
|
|
131
|
+
});
|
package/src/resources/config.ts
CHANGED
|
@@ -982,11 +982,23 @@ export namespace Bundle {
|
|
|
982
982
|
|
|
983
983
|
expectedResult?: string | null;
|
|
984
984
|
|
|
985
|
+
handler?: ToolConfig.Handler;
|
|
986
|
+
|
|
985
987
|
invocationCriteria?: string | null;
|
|
986
988
|
|
|
987
989
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
988
990
|
}
|
|
989
991
|
|
|
992
|
+
export namespace ToolConfig {
|
|
993
|
+
export interface Handler {
|
|
994
|
+
type: 'http';
|
|
995
|
+
|
|
996
|
+
url: string;
|
|
997
|
+
|
|
998
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
990
1002
|
export interface DashboardConfig {
|
|
991
1003
|
kind: 'dashboard';
|
|
992
1004
|
|
|
@@ -2193,11 +2205,23 @@ export namespace Bundle {
|
|
|
2193
2205
|
|
|
2194
2206
|
expectedResult?: string | null;
|
|
2195
2207
|
|
|
2208
|
+
handler?: ToolConfig.Handler;
|
|
2209
|
+
|
|
2196
2210
|
invocationCriteria?: string | null;
|
|
2197
2211
|
|
|
2198
2212
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
2199
2213
|
}
|
|
2200
2214
|
|
|
2215
|
+
export namespace ToolConfig {
|
|
2216
|
+
export interface Handler {
|
|
2217
|
+
type: 'http';
|
|
2218
|
+
|
|
2219
|
+
url: string;
|
|
2220
|
+
|
|
2221
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2201
2225
|
export interface DashboardConfig {
|
|
2202
2226
|
kind: 'dashboard';
|
|
2203
2227
|
|
|
@@ -3553,11 +3577,23 @@ export namespace ConfigApplyParams {
|
|
|
3553
3577
|
|
|
3554
3578
|
expectedResult?: string | null;
|
|
3555
3579
|
|
|
3580
|
+
handler?: ToolConfig.Handler;
|
|
3581
|
+
|
|
3556
3582
|
invocationCriteria?: string | null;
|
|
3557
3583
|
|
|
3558
3584
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
3559
3585
|
}
|
|
3560
3586
|
|
|
3587
|
+
export namespace ToolConfig {
|
|
3588
|
+
export interface Handler {
|
|
3589
|
+
type: 'http';
|
|
3590
|
+
|
|
3591
|
+
url: string;
|
|
3592
|
+
|
|
3593
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3561
3597
|
export interface DashboardConfig {
|
|
3562
3598
|
kind: 'dashboard';
|
|
3563
3599
|
|
|
@@ -4764,11 +4800,23 @@ export namespace ConfigApplyParams {
|
|
|
4764
4800
|
|
|
4765
4801
|
expectedResult?: string | null;
|
|
4766
4802
|
|
|
4803
|
+
handler?: ToolConfig.Handler;
|
|
4804
|
+
|
|
4767
4805
|
invocationCriteria?: string | null;
|
|
4768
4806
|
|
|
4769
4807
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
4770
4808
|
}
|
|
4771
4809
|
|
|
4810
|
+
export namespace ToolConfig {
|
|
4811
|
+
export interface Handler {
|
|
4812
|
+
type: 'http';
|
|
4813
|
+
|
|
4814
|
+
url: string;
|
|
4815
|
+
|
|
4816
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4817
|
+
}
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4772
4820
|
export interface DashboardConfig {
|
|
4773
4821
|
kind: 'dashboard';
|
|
4774
4822
|
|
|
@@ -5951,11 +5999,23 @@ export namespace ConfigDiffParams {
|
|
|
5951
5999
|
|
|
5952
6000
|
expectedResult?: string | null;
|
|
5953
6001
|
|
|
6002
|
+
handler?: ToolConfig.Handler;
|
|
6003
|
+
|
|
5954
6004
|
invocationCriteria?: string | null;
|
|
5955
6005
|
|
|
5956
6006
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
5957
6007
|
}
|
|
5958
6008
|
|
|
6009
|
+
export namespace ToolConfig {
|
|
6010
|
+
export interface Handler {
|
|
6011
|
+
type: 'http';
|
|
6012
|
+
|
|
6013
|
+
url: string;
|
|
6014
|
+
|
|
6015
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
|
|
5959
6019
|
export interface DashboardConfig {
|
|
5960
6020
|
kind: 'dashboard';
|
|
5961
6021
|
|
|
@@ -7162,11 +7222,23 @@ export namespace ConfigDiffParams {
|
|
|
7162
7222
|
|
|
7163
7223
|
expectedResult?: string | null;
|
|
7164
7224
|
|
|
7225
|
+
handler?: ToolConfig.Handler;
|
|
7226
|
+
|
|
7165
7227
|
invocationCriteria?: string | null;
|
|
7166
7228
|
|
|
7167
7229
|
parameters?: { [key: string]: 'string' | 'number' | 'boolean' };
|
|
7168
7230
|
}
|
|
7169
7231
|
|
|
7232
|
+
export namespace ToolConfig {
|
|
7233
|
+
export interface Handler {
|
|
7234
|
+
type: 'http';
|
|
7235
|
+
|
|
7236
|
+
url: string;
|
|
7237
|
+
|
|
7238
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
7239
|
+
}
|
|
7240
|
+
}
|
|
7241
|
+
|
|
7170
7242
|
export interface DashboardConfig {
|
|
7171
7243
|
kind: 'dashboard';
|
|
7172
7244
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '5.
|
|
1
|
+
export const VERSION = '5.14.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.
|
|
1
|
+
export declare const VERSION = "5.14.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.
|
|
1
|
+
export declare const VERSION = "5.14.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '5.
|
|
1
|
+
export const VERSION = '5.14.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|