terse-sdk 0.9.20 → 0.9.21
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/durableExecution.d.ts +0 -15
- package/dist/durableExecution.d.ts.map +1 -1
- package/dist/durableExecution.js +49 -31
- package/dist/durableExecution.js.map +1 -1
- package/dist/execution.d.ts +0 -5
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +22 -15
- package/dist/execution.js.map +1 -1
- package/dist/hmac.d.ts +0 -7
- package/dist/hmac.d.ts.map +1 -1
- package/dist/hmac.js +66 -57
- package/dist/hmac.js.map +1 -1
- package/dist/index.d.ts +0 -197
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +873 -642
- package/dist/index.js.map +1 -1
- package/dist/inputRequest.d.ts +0 -55
- package/dist/inputRequest.d.ts.map +1 -1
- package/dist/inputRequest.js +239 -160
- package/dist/inputRequest.js.map +1 -1
- package/dist/poll.d.ts +0 -8
- package/dist/poll.d.ts.map +1 -1
- package/dist/poll.js +33 -24
- package/dist/poll.js.map +1 -1
- package/dist/types.d.ts +0 -51
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +88 -12
- package/dist/types.js.map +1 -1
- package/package.json +4 -10
package/dist/poll.js
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in src/index.ts.
|
|
3
|
+
// export type PollUntilOptions = {
|
|
4
|
+
// intervalMs: number
|
|
5
|
+
// /** Stop and return null once this much time has passed. Omit to poll until attempt() produces a value. */
|
|
6
|
+
// timeoutMs?: number
|
|
7
|
+
// /** Rethrow once attempt() has been failing continuously for this long. Omit to treat errors as pending. */
|
|
8
|
+
// errorToleranceMs?: number
|
|
9
|
+
// }
|
|
10
|
+
//
|
|
11
|
+
// // The one polling loop: attempt() returns undefined while pending, a value when done.
|
|
12
|
+
// // Transient attempt() errors count as pending so a network blip never kills a wait,
|
|
13
|
+
// // bounded by errorToleranceMs for waits that must not spin on a persistent failure.
|
|
14
|
+
// export async function pollUntil<T>(attempt: () => Promise<T | undefined>, options: PollUntilOptions): Promise<T | null> {
|
|
15
|
+
// const startedAt = Date.now()
|
|
16
|
+
// let failingSince: number | null = null
|
|
17
|
+
//
|
|
18
|
+
// while (true) {
|
|
19
|
+
// try {
|
|
20
|
+
// const result = await attempt()
|
|
21
|
+
// if (result !== undefined) return result
|
|
22
|
+
// failingSince = null
|
|
23
|
+
// } catch (error) {
|
|
24
|
+
// failingSince ??= Date.now()
|
|
25
|
+
// if (options.errorToleranceMs !== undefined && Date.now() - failingSince >= options.errorToleranceMs) {
|
|
26
|
+
// throw error
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
//
|
|
30
|
+
// if (options.timeoutMs !== undefined && Date.now() - startedAt >= options.timeoutMs) return null
|
|
31
|
+
// await new Promise(resolve => setTimeout(resolve, options.intervalMs))
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
25
34
|
//# sourceMappingURL=poll.js.map
|
package/dist/poll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../src/poll.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../src/poll.ts"],"names":[],"mappings":";AAAA,6GAA6G;AAC7G,mCAAmC;AACnC,yBAAyB;AACzB,iHAAiH;AACjH,yBAAyB;AACzB,kHAAkH;AAClH,gCAAgC;AAChC,IAAI;AACJ,EAAE;AACF,yFAAyF;AACzF,uFAAuF;AACvF,uFAAuF;AACvF,4HAA4H;AAC5H,mCAAmC;AACnC,6CAA6C;AAC7C,EAAE;AACF,qBAAqB;AACrB,gBAAgB;AAChB,6CAA6C;AAC7C,sDAAsD;AACtD,kCAAkC;AAClC,4BAA4B;AAC5B,0CAA0C;AAC1C,qHAAqH;AACrH,8BAA8B;AAC9B,gBAAgB;AAChB,YAAY;AACZ,EAAE;AACF,0GAA0G;AAC1G,gFAAgF;AAChF,QAAQ;AACR,IAAI"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import { IntegrationType } from "terse-types";
|
|
2
|
-
import type { ConfigData, SerializedEvent, Trigger } from "terse-types";
|
|
3
|
-
import type { z } from "zod";
|
|
4
|
-
export { registerEventTransform } from "./context.js";
|
|
5
|
-
/**
|
|
6
|
-
* Lightweight interface for toolbox entries.
|
|
7
|
-
* The backend's concrete ToolboxEntry (which depends on @openai/agents Tool) structurally satisfies this interface.
|
|
8
|
-
*/
|
|
9
|
-
export interface ToolboxEntry {
|
|
10
|
-
isReadOnly: boolean;
|
|
11
|
-
integration: IntegrationType;
|
|
12
|
-
displayName: string;
|
|
13
|
-
}
|
|
14
|
-
export type TriggerLike = {
|
|
15
|
-
integrationType: string;
|
|
16
|
-
eventType: string;
|
|
17
|
-
};
|
|
18
|
-
export type SDKTrigger<TEvent extends TriggerLike = Trigger> = TEvent & {
|
|
19
|
-
triggeredAt: Date;
|
|
20
|
-
formatForAgentRunner(): string;
|
|
21
|
-
debugLog(): string;
|
|
22
|
-
};
|
|
23
|
-
export type InferStructuredOutput<TSchema, TFallback = string> = TSchema extends {
|
|
24
|
-
_output: infer TOutput;
|
|
25
|
-
} ? TOutput : TFallback;
|
|
26
|
-
export declare function createSDKTrigger(serialized: SerializedEvent): SDKTrigger;
|
|
27
|
-
export type TypedTrigger<TEvent extends TriggerLike = Trigger> = ConfigData & {
|
|
28
|
-
readonly __eventType?: TEvent;
|
|
29
|
-
};
|
|
30
|
-
export type InferEvent<T> = T extends TypedTrigger<infer E> ? SDKTrigger<E> : SDKTrigger;
|
|
31
|
-
export type InferEvents<T extends readonly unknown[]> = InferEvent<T[number]>;
|
|
32
|
-
export type TypedSkill<TToolName extends string = never> = ConfigData & {
|
|
33
|
-
readonly __toolApprovalNames?: TToolName;
|
|
34
|
-
};
|
|
35
|
-
export type InferToolApproval<T> = T extends TypedSkill<infer TToolName> ? TToolName : never;
|
|
36
|
-
export type InferToolApprovals<T extends readonly unknown[]> = InferToolApproval<T[number]>;
|
|
37
|
-
export type StateDefinition<K extends string = string, S extends z.ZodType = z.ZodType> = {
|
|
38
|
-
key: K;
|
|
39
|
-
value: S;
|
|
40
|
-
};
|
|
41
|
-
type Read<S extends z.ZodType> = S extends z.ZodDefault<z.ZodTypeAny> ? z.infer<S> : z.infer<S> | undefined;
|
|
42
|
-
type StateReads<TStates extends readonly StateDefinition[]> = {
|
|
43
|
-
[S in TStates[number] as S["key"]]: Read<S["value"]>;
|
|
44
|
-
};
|
|
45
|
-
type StateWrites<TStates extends readonly StateDefinition[]> = {
|
|
46
|
-
[S in TStates[number] as S["key"]]: z.infer<S["value"]>;
|
|
47
|
-
};
|
|
48
|
-
export type StateAccessor<TStates extends readonly StateDefinition[]> = {
|
|
49
|
-
get<K extends keyof StateReads<TStates> & string>(key: K): Promise<StateReads<TStates>[K]>;
|
|
50
|
-
set<K extends keyof StateWrites<TStates> & string>(key: K, value: StateWrites<TStates>[K]): Promise<StateWrites<TStates>[K]>;
|
|
51
|
-
};
|
|
52
1
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/types.js
CHANGED
|
@@ -1,13 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in src/index.ts.
|
|
3
|
+
// import { IntegrationType } from "terse-types"
|
|
4
|
+
// import type { ConfigData, SerializedEvent, Trigger } from "terse-types"
|
|
5
|
+
// import type { z } from "zod"
|
|
6
|
+
//
|
|
7
|
+
// import { getEventTransform } from "./context.js"
|
|
8
|
+
//
|
|
9
|
+
// export { registerEventTransform } from "./context.js"
|
|
10
|
+
//
|
|
11
|
+
// /**
|
|
12
|
+
// * Lightweight interface for toolbox entries.
|
|
13
|
+
// * The backend's concrete ToolboxEntry (which depends on @openai/agents Tool) structurally satisfies this interface.
|
|
14
|
+
// */
|
|
15
|
+
// export interface ToolboxEntry {
|
|
16
|
+
// isReadOnly: boolean
|
|
17
|
+
// integration: IntegrationType
|
|
18
|
+
// displayName: string
|
|
19
|
+
// }
|
|
20
|
+
//
|
|
21
|
+
// export type TriggerLike = { integrationType: string; eventType: string }
|
|
22
|
+
//
|
|
23
|
+
// export type SDKTrigger<TEvent extends TriggerLike = Trigger> = TEvent & {
|
|
24
|
+
// triggeredAt: Date
|
|
25
|
+
// formatForAgentRunner(): string
|
|
26
|
+
// debugLog(): string
|
|
27
|
+
// }
|
|
28
|
+
//
|
|
29
|
+
// export type InferStructuredOutput<TSchema, TFallback = string> = TSchema extends { _output: infer TOutput } ? TOutput : TFallback
|
|
30
|
+
//
|
|
31
|
+
// export function createSDKTrigger(serialized: SerializedEvent): SDKTrigger {
|
|
32
|
+
// const integrationType = (serialized.data as { integrationType?: string }).integrationType
|
|
33
|
+
// const transform = integrationType ? getEventTransform(integrationType) : undefined
|
|
34
|
+
// const data = transform ? transform(serialized.data) : serialized.data
|
|
35
|
+
// return Object.assign({}, data, {
|
|
36
|
+
// triggeredAt: new Date(serialized.triggeredAt),
|
|
37
|
+
// formatForAgentRunner: () => serialized.formattedContent,
|
|
38
|
+
// debugLog: () => serialized.debugLog
|
|
39
|
+
// }) as SDKTrigger
|
|
40
|
+
// }
|
|
41
|
+
//
|
|
42
|
+
// // ---------------------------------------------------------------------------
|
|
43
|
+
// // TypedTrigger – phantom-typed ConfigData for generic event inference
|
|
44
|
+
// // ---------------------------------------------------------------------------
|
|
45
|
+
//
|
|
46
|
+
// export type TypedTrigger<TEvent extends TriggerLike = Trigger> = ConfigData & {
|
|
47
|
+
// readonly __eventType?: TEvent
|
|
48
|
+
// }
|
|
49
|
+
//
|
|
50
|
+
// export type InferEvent<T> = T extends TypedTrigger<infer E> ? SDKTrigger<E> : SDKTrigger
|
|
51
|
+
// export type InferEvents<T extends readonly unknown[]> = InferEvent<T[number]>
|
|
52
|
+
//
|
|
53
|
+
// // ---------------------------------------------------------------------------
|
|
54
|
+
// // TypedSkill – phantom-typed ConfigData for skill tool inference
|
|
55
|
+
// // ---------------------------------------------------------------------------
|
|
56
|
+
//
|
|
57
|
+
// export type TypedSkill<TToolName extends string = never> = ConfigData & {
|
|
58
|
+
// readonly __toolApprovalNames?: TToolName
|
|
59
|
+
// }
|
|
60
|
+
//
|
|
61
|
+
// export type InferToolApproval<T> = T extends TypedSkill<infer TToolName> ? TToolName : never
|
|
62
|
+
// export type InferToolApprovals<T extends readonly unknown[]> = InferToolApproval<T[number]>
|
|
63
|
+
//
|
|
64
|
+
// // ---------------------------------------------------------------------------
|
|
65
|
+
// // State – typed per-job key/value store, narrowed to the declared `states` keys
|
|
66
|
+
// // ---------------------------------------------------------------------------
|
|
67
|
+
//
|
|
68
|
+
// export type StateDefinition<K extends string = string, S extends z.ZodType = z.ZodType> = {
|
|
69
|
+
// key: K
|
|
70
|
+
// value: S
|
|
71
|
+
// }
|
|
72
|
+
//
|
|
73
|
+
// // A key whose schema carries a `.default(...)` can never read back as undefined; one without a default can
|
|
74
|
+
// // (it may have been never set). `get` reflects that per key; `set` returns the value it just wrote.
|
|
75
|
+
// type Read<S extends z.ZodType> = S extends z.ZodDefault<z.ZodTypeAny> ? z.infer<S> : z.infer<S> | undefined
|
|
76
|
+
//
|
|
77
|
+
// type StateReads<TStates extends readonly StateDefinition[]> = {
|
|
78
|
+
// [S in TStates[number] as S["key"]]: Read<S["value"]>
|
|
79
|
+
// }
|
|
80
|
+
//
|
|
81
|
+
// type StateWrites<TStates extends readonly StateDefinition[]> = {
|
|
82
|
+
// [S in TStates[number] as S["key"]]: z.infer<S["value"]>
|
|
83
|
+
// }
|
|
84
|
+
//
|
|
85
|
+
// export type StateAccessor<TStates extends readonly StateDefinition[]> = {
|
|
86
|
+
// get<K extends keyof StateReads<TStates> & string>(key: K): Promise<StateReads<TStates>[K]>
|
|
87
|
+
// set<K extends keyof StateWrites<TStates> & string>(key: K, value: StateWrites<TStates>[K]): Promise<StateWrites<TStates>[K]>
|
|
88
|
+
// }
|
|
13
89
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,6GAA6G;AAC7G,gDAAgD;AAChD,0EAA0E;AAC1E,+BAA+B;AAC/B,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,wDAAwD;AACxD,EAAE;AACF,MAAM;AACN,gDAAgD;AAChD,uHAAuH;AACvH,MAAM;AACN,kCAAkC;AAClC,0BAA0B;AAC1B,mCAAmC;AACnC,0BAA0B;AAC1B,IAAI;AACJ,EAAE;AACF,2EAA2E;AAC3E,EAAE;AACF,4EAA4E;AAC5E,wBAAwB;AACxB,qCAAqC;AACrC,yBAAyB;AACzB,IAAI;AACJ,EAAE;AACF,oIAAoI;AACpI,EAAE;AACF,8EAA8E;AAC9E,gGAAgG;AAChG,yFAAyF;AACzF,4EAA4E;AAC5E,uCAAuC;AACvC,yDAAyD;AACzD,mEAAmE;AACnE,8CAA8C;AAC9C,uBAAuB;AACvB,IAAI;AACJ,EAAE;AACF,iFAAiF;AACjF,yEAAyE;AACzE,iFAAiF;AACjF,EAAE;AACF,kFAAkF;AAClF,oCAAoC;AACpC,IAAI;AACJ,EAAE;AACF,2FAA2F;AAC3F,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,oEAAoE;AACpE,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,+CAA+C;AAC/C,IAAI;AACJ,EAAE;AACF,+FAA+F;AAC/F,8FAA8F;AAC9F,EAAE;AACF,iFAAiF;AACjF,mFAAmF;AACnF,iFAAiF;AACjF,EAAE;AACF,8FAA8F;AAC9F,aAAa;AACb,eAAe;AACf,IAAI;AACJ,EAAE;AACF,8GAA8G;AAC9G,uGAAuG;AACvG,8GAA8G;AAC9G,EAAE;AACF,kEAAkE;AAClE,2DAA2D;AAC3D,IAAI;AACJ,EAAE;AACF,mEAAmE;AACnE,8DAA8D;AAC9D,IAAI;AACJ,EAAE;AACF,4EAA4E;AAC5E,iGAAiG;AACjG,mIAAmI;AACnI,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terse-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./dist/context.js"
|
|
@@ -43,21 +43,15 @@
|
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"zod": "^4.3.6"
|
|
48
|
-
},
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@types/ms": "^2.1.0",
|
|
51
47
|
"@types/node": "^22.0.0",
|
|
52
48
|
"esbuild": "^0.28.2",
|
|
53
|
-
"typescript": "^5.0.0"
|
|
54
|
-
"zod": "^4.3.6"
|
|
49
|
+
"typescript": "^5.0.0"
|
|
55
50
|
},
|
|
56
51
|
"dependencies": {
|
|
57
52
|
"durable-actors": "0.8.1",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"terse-types": "0.9.20"
|
|
53
|
+
"zod": "^4.3.6",
|
|
54
|
+
"terse-types": "0.9.21"
|
|
61
55
|
},
|
|
62
56
|
"scripts": {
|
|
63
57
|
"build": "rm -rf dist && tsc",
|