@aexhq/sdk 0.46.4-canary → 0.50.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/LICENSE +201 -0
- package/NOTICE +38 -0
- package/README.md +23 -31
- package/dist/client/aex.d.ts +33 -0
- package/dist/client/aex.js +98 -0
- package/dist/client/aex.js.map +1 -0
- package/dist/client/credentials.d.ts +25 -0
- package/dist/client/credentials.js +97 -0
- package/dist/client/credentials.js.map +1 -0
- package/dist/client/routing.d.ts +7 -0
- package/dist/client/routing.js +29 -0
- package/dist/client/routing.js.map +1 -0
- package/dist/downloads/download.d.ts +25 -0
- package/dist/downloads/download.js +53 -0
- package/dist/downloads/download.js.map +1 -0
- package/dist/generated/errors.d.ts +12 -0
- package/dist/generated/errors.js +81 -0
- package/dist/generated/errors.js.map +1 -0
- package/dist/generated/resources.d.ts +730 -0
- package/dist/generated/resources.js +606 -0
- package/dist/generated/resources.js.map +1 -0
- package/dist/generated/routes.d.ts +42 -0
- package/dist/generated/routes.js +2101 -0
- package/dist/generated/routes.js.map +1 -0
- package/dist/index.d.ts +20 -50
- package/dist/index.js +11 -62
- package/dist/index.js.map +1 -1
- package/dist/observations/stream.d.ts +1 -0
- package/dist/observations/stream.js +18 -0
- package/dist/observations/stream.js.map +1 -0
- package/dist/transport/errors.d.ts +60 -0
- package/dist/transport/errors.js +107 -0
- package/dist/transport/errors.js.map +1 -0
- package/dist/transport/pagination.d.ts +8 -0
- package/dist/transport/pagination.js +34 -0
- package/dist/transport/pagination.js.map +1 -0
- package/dist/transport/retry.d.ts +21 -0
- package/dist/transport/retry.js +37 -0
- package/dist/transport/retry.js.map +1 -0
- package/dist/transport/transport.d.ts +25 -0
- package/dist/transport/transport.js +28 -0
- package/dist/transport/transport.js.map +1 -0
- package/package.json +63 -30
- package/dist/_contracts/account-operations.d.ts +0 -101
- package/dist/_contracts/account-operations.js +0 -242
- package/dist/_contracts/account-types.d.ts +0 -461
- package/dist/_contracts/account-types.js +0 -1
- package/dist/_contracts/api-key.d.ts +0 -61
- package/dist/_contracts/api-key.js +0 -101
- package/dist/_contracts/api-routes.d.ts +0 -20
- package/dist/_contracts/api-routes.js +0 -109
- package/dist/_contracts/archive-limits.d.ts +0 -3
- package/dist/_contracts/archive-limits.js +0 -23
- package/dist/_contracts/asset-authoring.d.ts +0 -22
- package/dist/_contracts/asset-authoring.js +0 -106
- package/dist/_contracts/asset-bundle.d.ts +0 -64
- package/dist/_contracts/asset-bundle.js +0 -263
- package/dist/_contracts/asset-upload-helper.d.ts +0 -31
- package/dist/_contracts/asset-upload-helper.js +0 -84
- package/dist/_contracts/billing-admission.d.ts +0 -29
- package/dist/_contracts/billing-admission.js +0 -28
- package/dist/_contracts/bundle-manifest.d.ts +0 -89
- package/dist/_contracts/bundle-manifest.js +0 -158
- package/dist/_contracts/canonical-sha256.d.ts +0 -8
- package/dist/_contracts/canonical-sha256.js +0 -8
- package/dist/_contracts/connection-ticket.d.ts +0 -22
- package/dist/_contracts/connection-ticket.js +0 -54
- package/dist/_contracts/continuation-event.d.ts +0 -31
- package/dist/_contracts/continuation-event.js +0 -6
- package/dist/_contracts/contract-parse-error.d.ts +0 -12
- package/dist/_contracts/contract-parse-error.js +0 -51
- package/dist/_contracts/error-codes.d.ts +0 -26
- package/dist/_contracts/error-codes.js +0 -116
- package/dist/_contracts/error-factory.d.ts +0 -32
- package/dist/_contracts/error-factory.js +0 -174
- package/dist/_contracts/event-envelope.d.ts +0 -471
- package/dist/_contracts/event-envelope.js +0 -501
- package/dist/_contracts/event-stream-client.d.ts +0 -122
- package/dist/_contracts/event-stream-client.js +0 -445
- package/dist/_contracts/event-view.d.ts +0 -44
- package/dist/_contracts/event-view.js +0 -69
- package/dist/_contracts/failure-class.d.ts +0 -29
- package/dist/_contracts/failure-class.js +0 -73
- package/dist/_contracts/http.d.ts +0 -135
- package/dist/_contracts/http.js +0 -434
- package/dist/_contracts/ids.d.ts +0 -66
- package/dist/_contracts/ids.js +0 -119
- package/dist/_contracts/index.d.ts +0 -42
- package/dist/_contracts/index.js +0 -52
- package/dist/_contracts/internal.d.ts +0 -55
- package/dist/_contracts/internal.js +0 -113
- package/dist/_contracts/models.d.ts +0 -30
- package/dist/_contracts/models.js +0 -28
- package/dist/_contracts/operation-core.d.ts +0 -36
- package/dist/_contracts/operation-core.js +0 -70
- package/dist/_contracts/operations.d.ts +0 -218
- package/dist/_contracts/operations.js +0 -1496
- package/dist/_contracts/otlp-projection.d.ts +0 -78
- package/dist/_contracts/otlp-projection.js +0 -171
- package/dist/_contracts/post-hook.d.ts +0 -31
- package/dist/_contracts/post-hook.js +0 -61
- package/dist/_contracts/provider-fault.d.ts +0 -34
- package/dist/_contracts/provider-fault.js +0 -68
- package/dist/_contracts/retry-core.d.ts +0 -29
- package/dist/_contracts/retry-core.js +0 -79
- package/dist/_contracts/runner-event.d.ts +0 -117
- package/dist/_contracts/runner-event.js +0 -172
- package/dist/_contracts/runtime-kind.d.ts +0 -60
- package/dist/_contracts/runtime-kind.js +0 -70
- package/dist/_contracts/runtime-manifest.d.ts +0 -121
- package/dist/_contracts/runtime-manifest.js +0 -83
- package/dist/_contracts/runtime-security-profile.d.ts +0 -26
- package/dist/_contracts/runtime-security-profile.js +0 -73
- package/dist/_contracts/runtime-sizes.d.ts +0 -104
- package/dist/_contracts/runtime-sizes.js +0 -111
- package/dist/_contracts/runtime-types.d.ts +0 -618
- package/dist/_contracts/runtime-types.js +0 -58
- package/dist/_contracts/schemas/asset-bundle.d.ts +0 -70
- package/dist/_contracts/schemas/asset-bundle.js +0 -107
- package/dist/_contracts/schemas/asset-ref.d.ts +0 -61
- package/dist/_contracts/schemas/asset-ref.js +0 -118
- package/dist/_contracts/schemas/bundle-manifest.d.ts +0 -66
- package/dist/_contracts/schemas/bundle-manifest.js +0 -77
- package/dist/_contracts/schemas/index.d.ts +0 -32
- package/dist/_contracts/schemas/index.js +0 -30
- package/dist/_contracts/schemas/mcp-server.d.ts +0 -99
- package/dist/_contracts/schemas/mcp-server.js +0 -209
- package/dist/_contracts/schemas/models.d.ts +0 -29
- package/dist/_contracts/schemas/models.js +0 -51
- package/dist/_contracts/schemas/numeric.d.ts +0 -18
- package/dist/_contracts/schemas/numeric.js +0 -28
- package/dist/_contracts/schemas/post-hook.d.ts +0 -45
- package/dist/_contracts/schemas/post-hook.js +0 -68
- package/dist/_contracts/schemas/response-assets.d.ts +0 -75
- package/dist/_contracts/schemas/response-assets.js +0 -81
- package/dist/_contracts/schemas/response-billing.d.ts +0 -208
- package/dist/_contracts/schemas/response-billing.js +0 -139
- package/dist/_contracts/schemas/response-common.d.ts +0 -132
- package/dist/_contracts/schemas/response-common.js +0 -162
- package/dist/_contracts/schemas/response-identity.d.ts +0 -648
- package/dist/_contracts/schemas/response-identity.js +0 -131
- package/dist/_contracts/schemas/response-mcp-servers.d.ts +0 -51
- package/dist/_contracts/schemas/response-mcp-servers.js +0 -32
- package/dist/_contracts/schemas/response-secrets.d.ts +0 -50
- package/dist/_contracts/schemas/response-secrets.js +0 -32
- package/dist/_contracts/schemas/response-sessions-internal.d.ts +0 -200
- package/dist/_contracts/schemas/response-sessions-internal.js +0 -142
- package/dist/_contracts/schemas/response-sessions.d.ts +0 -1598
- package/dist/_contracts/schemas/response-sessions.js +0 -377
- package/dist/_contracts/schemas/response-webhooks.d.ts +0 -76
- package/dist/_contracts/schemas/response-webhooks.js +0 -42
- package/dist/_contracts/schemas/response-workspace.d.ts +0 -225
- package/dist/_contracts/schemas/response-workspace.js +0 -99
- package/dist/_contracts/schemas/runtime-kind.d.ts +0 -31
- package/dist/_contracts/schemas/runtime-kind.js +0 -29
- package/dist/_contracts/schemas/runtime-security-profile.d.ts +0 -28
- package/dist/_contracts/schemas/runtime-security-profile.js +0 -26
- package/dist/_contracts/schemas/runtime-sizes.d.ts +0 -70
- package/dist/_contracts/schemas/runtime-sizes.js +0 -127
- package/dist/_contracts/schemas/session-limits.d.ts +0 -34
- package/dist/_contracts/schemas/session-limits.js +0 -39
- package/dist/_contracts/schemas/session-machine.d.ts +0 -23
- package/dist/_contracts/schemas/session-machine.js +0 -24
- package/dist/_contracts/schemas/session-request-config.d.ts +0 -58
- package/dist/_contracts/schemas/session-request-config.js +0 -134
- package/dist/_contracts/schemas/session-webhook.d.ts +0 -11
- package/dist/_contracts/schemas/session-webhook.js +0 -38
- package/dist/_contracts/schemas/side-effect-audit.d.ts +0 -98
- package/dist/_contracts/schemas/side-effect-audit.js +0 -102
- package/dist/_contracts/schemas/submission-assets.d.ts +0 -117
- package/dist/_contracts/schemas/submission-assets.js +0 -147
- package/dist/_contracts/schemas/submission-body.d.ts +0 -251
- package/dist/_contracts/schemas/submission-body.js +0 -378
- package/dist/_contracts/schemas/submission-environment.d.ts +0 -79
- package/dist/_contracts/schemas/submission-environment.js +0 -179
- package/dist/_contracts/schemas/submission-request.d.ts +0 -158
- package/dist/_contracts/schemas/submission-request.js +0 -49
- package/dist/_contracts/schemas/submission-secrets.d.ts +0 -47
- package/dist/_contracts/schemas/submission-secrets.js +0 -108
- package/dist/_contracts/schemas/wire.d.ts +0 -118
- package/dist/_contracts/schemas/wire.js +0 -171
- package/dist/_contracts/schemas/workspace-resources.d.ts +0 -50
- package/dist/_contracts/schemas/workspace-resources.js +0 -87
- package/dist/_contracts/sdk-errors.d.ts +0 -212
- package/dist/_contracts/sdk-errors.js +0 -313
- package/dist/_contracts/sdk-secrets.d.ts +0 -67
- package/dist/_contracts/sdk-secrets.js +0 -427
- package/dist/_contracts/session-archive.d.ts +0 -16
- package/dist/_contracts/session-archive.js +0 -92
- package/dist/_contracts/session-artifacts.d.ts +0 -189
- package/dist/_contracts/session-artifacts.js +0 -264
- package/dist/_contracts/session-config.d.ts +0 -373
- package/dist/_contracts/session-config.js +0 -562
- package/dist/_contracts/session-cost-types.d.ts +0 -211
- package/dist/_contracts/session-cost-types.js +0 -69
- package/dist/_contracts/session-cost.d.ts +0 -8
- package/dist/_contracts/session-cost.js +0 -582
- package/dist/_contracts/session-custody.d.ts +0 -165
- package/dist/_contracts/session-custody.js +0 -345
- package/dist/_contracts/session-file-query.d.ts +0 -14
- package/dist/_contracts/session-file-query.js +0 -178
- package/dist/_contracts/session-record.d.ts +0 -112
- package/dist/_contracts/session-record.js +0 -165
- package/dist/_contracts/session-retention.d.ts +0 -201
- package/dist/_contracts/session-retention.js +0 -450
- package/dist/_contracts/side-effect-audit.d.ts +0 -126
- package/dist/_contracts/side-effect-audit.js +0 -520
- package/dist/_contracts/sse.d.ts +0 -74
- package/dist/_contracts/sse.js +0 -227
- package/dist/_contracts/stable.d.ts +0 -45
- package/dist/_contracts/stable.js +0 -62
- package/dist/_contracts/status.d.ts +0 -25
- package/dist/_contracts/status.js +0 -57
- package/dist/_contracts/submission-limits.d.ts +0 -61
- package/dist/_contracts/submission-limits.js +0 -60
- package/dist/_contracts/submission.d.ts +0 -547
- package/dist/_contracts/submission.js +0 -812
- package/dist/_contracts/suggest.d.ts +0 -15
- package/dist/_contracts/suggest.js +0 -53
- package/dist/_contracts/testing/response-bindings.d.ts +0 -45
- package/dist/_contracts/testing/response-bindings.js +0 -256
- package/dist/_contracts/testing/wire-conformance-entry.d.ts +0 -10
- package/dist/_contracts/testing/wire-conformance-entry.js +0 -8
- package/dist/_contracts/testing/wire-conformance.d.ts +0 -169
- package/dist/_contracts/testing/wire-conformance.js +0 -276
- package/dist/_contracts/turn-trace.d.ts +0 -28
- package/dist/_contracts/turn-trace.js +0 -1
- package/dist/_contracts/unknown-field-error.d.ts +0 -13
- package/dist/_contracts/unknown-field-error.js +0 -21
- package/dist/_contracts/value-guards.d.ts +0 -20
- package/dist/_contracts/value-guards.js +0 -34
- package/dist/_contracts/webhook-verify.d.ts +0 -34
- package/dist/_contracts/webhook-verify.js +0 -93
- package/dist/_contracts/wire-observer.d.ts +0 -49
- package/dist/_contracts/wire-observer.js +0 -34
- package/dist/_contracts/workflow-status.d.ts +0 -7
- package/dist/_contracts/workflow-status.js +0 -43
- package/dist/_contracts/workspace-resources.d.ts +0 -98
- package/dist/_contracts/workspace-resources.js +0 -39
- package/dist/archive-limits.d.ts +0 -1
- package/dist/archive-limits.js +0 -2
- package/dist/archive-limits.js.map +0 -1
- package/dist/asset-upload.d.ts +0 -47
- package/dist/asset-upload.js +0 -269
- package/dist/asset-upload.js.map +0 -1
- package/dist/bundle.d.ts +0 -9
- package/dist/bundle.js +0 -20
- package/dist/bundle.js.map +0 -1
- package/dist/canonical-zip.d.ts +0 -68
- package/dist/canonical-zip.js +0 -355
- package/dist/canonical-zip.js.map +0 -1
- package/dist/cli.mjs +0 -12048
- package/dist/cli.mjs.sha256 +0 -1
- package/dist/client-types.d.ts +0 -192
- package/dist/client-types.js +0 -2
- package/dist/client-types.js.map +0 -1
- package/dist/client.d.ts +0 -464
- package/dist/client.js +0 -1207
- package/dist/client.js.map +0 -1
- package/dist/event-projection.d.ts +0 -22
- package/dist/event-projection.js +0 -380
- package/dist/event-projection.js.map +0 -1
- package/dist/fetch-archive.d.ts +0 -16
- package/dist/fetch-archive.js +0 -252
- package/dist/fetch-archive.js.map +0 -1
- package/dist/file.d.ts +0 -96
- package/dist/file.js +0 -272
- package/dist/file.js.map +0 -1
- package/dist/instructions.d.ts +0 -20
- package/dist/instructions.js +0 -40
- package/dist/instructions.js.map +0 -1
- package/dist/legacy-session-provider-fault.d.ts +0 -7
- package/dist/legacy-session-provider-fault.js +0 -38
- package/dist/legacy-session-provider-fault.js.map +0 -1
- package/dist/mcp-server.d.ts +0 -84
- package/dist/mcp-server.js +0 -117
- package/dist/mcp-server.js.map +0 -1
- package/dist/node-fs.d.ts +0 -29
- package/dist/node-fs.js +0 -19
- package/dist/node-fs.js.map +0 -1
- package/dist/node-walk.d.ts +0 -69
- package/dist/node-walk.js +0 -151
- package/dist/node-walk.js.map +0 -1
- package/dist/path-basename.d.ts +0 -5
- package/dist/path-basename.js +0 -9
- package/dist/path-basename.js.map +0 -1
- package/dist/retry.d.ts +0 -70
- package/dist/retry.js +0 -155
- package/dist/retry.js.map +0 -1
- package/dist/secret.d.ts +0 -65
- package/dist/secret.js +0 -110
- package/dist/secret.js.map +0 -1
- package/dist/session-validate.d.ts +0 -100
- package/dist/session-validate.js +0 -303
- package/dist/session-validate.js.map +0 -1
- package/dist/skill.d.ts +0 -99
- package/dist/skill.js +0 -169
- package/dist/skill.js.map +0 -1
- package/dist/submission-wire.d.ts +0 -13
- package/dist/submission-wire.js +0 -69
- package/dist/submission-wire.js.map +0 -1
- package/dist/tool.d.ts +0 -41
- package/dist/tool.js +0 -76
- package/dist/tool.js.map +0 -1
- package/dist/version.d.ts +0 -9
- package/dist/version.js +0 -10
- package/dist/version.js.map +0 -1
- package/docs/authentication.md +0 -125
- package/docs/billing.md +0 -164
- package/docs/cleanup.md +0 -27
- package/docs/concepts/agent-tools.md +0 -47
- package/docs/concepts/composition.md +0 -60
- package/docs/concepts/providers-and-runtimes.md +0 -121
- package/docs/concepts/sessions.md +0 -51
- package/docs/concepts/subagents.md +0 -35
- package/docs/credentials.md +0 -116
- package/docs/defaults.md +0 -51
- package/docs/errors.md +0 -258
- package/docs/events.md +0 -143
- package/docs/files.md +0 -130
- package/docs/limits-and-quotas.md +0 -114
- package/docs/limits.md +0 -51
- package/docs/mcp.md +0 -47
- package/docs/networking.md +0 -114
- package/docs/provider-runtime-capabilities.md +0 -32
- package/docs/public-surface.json +0 -73
- package/docs/quickstart.md +0 -135
- package/docs/release.md +0 -44
- package/docs/retries.md +0 -108
- package/docs/secrets.md +0 -141
- package/docs/session-config.md +0 -51
- package/docs/session-record.md +0 -58
- package/docs/skills.md +0 -65
- package/docs/telemetry.md +0 -66
- package/docs/testing.md +0 -35
- package/docs/vision-skills.md +0 -94
- package/docs/webhooks.md +0 -143
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { AexEvent } from "./event-envelope.js";
|
|
2
|
-
/** Signals exposed by the session telemetry pull API. */
|
|
3
|
-
export type OtlpSignal = "traces" | "logs";
|
|
4
|
-
/** OTLP/HTTP JSON AnyValue. The projection emits only public scalar values. */
|
|
5
|
-
export type OtlpAnyValue = {
|
|
6
|
-
readonly stringValue: string;
|
|
7
|
-
} | {
|
|
8
|
-
readonly boolValue: boolean;
|
|
9
|
-
} | {
|
|
10
|
-
readonly intValue: string;
|
|
11
|
-
} | {
|
|
12
|
-
readonly doubleValue: number;
|
|
13
|
-
};
|
|
14
|
-
export interface OtlpKeyValue {
|
|
15
|
-
readonly key: string;
|
|
16
|
-
readonly value: OtlpAnyValue;
|
|
17
|
-
}
|
|
18
|
-
export interface OtlpResource {
|
|
19
|
-
readonly attributes: readonly OtlpKeyValue[];
|
|
20
|
-
}
|
|
21
|
-
export interface OtlpInstrumentationScope {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly version?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface OtlpTraceSpan {
|
|
26
|
-
readonly traceId: string;
|
|
27
|
-
readonly spanId: string;
|
|
28
|
-
readonly parentSpanId?: string;
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly kind: 1;
|
|
31
|
-
readonly startTimeUnixNano: string;
|
|
32
|
-
readonly endTimeUnixNano: string;
|
|
33
|
-
readonly attributes: readonly OtlpKeyValue[];
|
|
34
|
-
readonly status: {
|
|
35
|
-
readonly code: 1 | 2;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface OtlpScopeSpans {
|
|
39
|
-
readonly scope: OtlpInstrumentationScope;
|
|
40
|
-
readonly spans: readonly OtlpTraceSpan[];
|
|
41
|
-
}
|
|
42
|
-
export interface OtlpResourceSpans {
|
|
43
|
-
readonly resource: OtlpResource;
|
|
44
|
-
readonly scopeSpans: readonly OtlpScopeSpans[];
|
|
45
|
-
}
|
|
46
|
-
/** Standards-pure OTLP ExportTraceServiceRequest JSON body. */
|
|
47
|
-
export interface OtlpExportTraceServiceRequest {
|
|
48
|
-
readonly resourceSpans: readonly OtlpResourceSpans[];
|
|
49
|
-
}
|
|
50
|
-
export interface OtlpLogRecord {
|
|
51
|
-
readonly timeUnixNano: string;
|
|
52
|
-
readonly observedTimeUnixNano: string;
|
|
53
|
-
readonly severityNumber: 9 | 13 | 17;
|
|
54
|
-
readonly severityText: "INFO" | "WARN" | "ERROR";
|
|
55
|
-
readonly body: OtlpAnyValue;
|
|
56
|
-
readonly attributes: readonly OtlpKeyValue[];
|
|
57
|
-
readonly traceId?: string;
|
|
58
|
-
readonly spanId?: string;
|
|
59
|
-
}
|
|
60
|
-
export interface OtlpScopeLogs {
|
|
61
|
-
readonly scope: OtlpInstrumentationScope;
|
|
62
|
-
readonly logRecords: readonly OtlpLogRecord[];
|
|
63
|
-
}
|
|
64
|
-
export interface OtlpResourceLogs {
|
|
65
|
-
readonly resource: OtlpResource;
|
|
66
|
-
readonly scopeLogs: readonly OtlpScopeLogs[];
|
|
67
|
-
}
|
|
68
|
-
/** Standards-pure OTLP ExportLogsServiceRequest JSON body. */
|
|
69
|
-
export interface OtlpExportLogsServiceRequest {
|
|
70
|
-
readonly resourceLogs: readonly OtlpResourceLogs[];
|
|
71
|
-
}
|
|
72
|
-
export type OtlpExportRequest = OtlpExportTraceServiceRequest | OtlpExportLogsServiceRequest;
|
|
73
|
-
export interface ToOtlpOptions<Signal extends OtlpSignal = OtlpSignal> {
|
|
74
|
-
readonly signal: Signal;
|
|
75
|
-
}
|
|
76
|
-
export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions<"traces">): OtlpExportTraceServiceRequest;
|
|
77
|
-
export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions<"logs">): OtlpExportLogsServiceRequest;
|
|
78
|
-
export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions): OtlpExportRequest;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { redactString } from "./sdk-secrets.js";
|
|
2
|
-
const TRACE_ID = /^[0-9a-f]{32}$/;
|
|
3
|
-
const SPAN_ID = /^[0-9a-f]{16}$/;
|
|
4
|
-
const SCOPE = Object.freeze({ name: "@aexhq/contracts", version: "1" });
|
|
5
|
-
/**
|
|
6
|
-
* Project public event envelopes into a standards-pure OTLP/HTTP JSON body.
|
|
7
|
-
*
|
|
8
|
-
* This function accepts only the public event contract. It never accepts or
|
|
9
|
-
* imports private journal rows. Projection is allow-list based: arbitrary
|
|
10
|
-
* event data is ignored, and text that is intentionally public is passed
|
|
11
|
-
* through the canonical public redactor before it becomes telemetry.
|
|
12
|
-
*/
|
|
13
|
-
export function toOTLP(events, options) {
|
|
14
|
-
if (options.signal === "traces")
|
|
15
|
-
return projectTraces(events);
|
|
16
|
-
if (options.signal === "logs")
|
|
17
|
-
return projectLogs(events);
|
|
18
|
-
throw new TypeError(`unsupported OTLP signal: ${String(options.signal)}`);
|
|
19
|
-
}
|
|
20
|
-
function projectTraces(events) {
|
|
21
|
-
const spans = events.flatMap((event) => {
|
|
22
|
-
if (!validTraceIdentity(event))
|
|
23
|
-
return [];
|
|
24
|
-
const start = unixNano(event.time);
|
|
25
|
-
return [{
|
|
26
|
-
traceId: event.traceId,
|
|
27
|
-
spanId: event.spanId,
|
|
28
|
-
...(validSpanId(event.parentSpanId) ? { parentSpanId: event.parentSpanId } : {}),
|
|
29
|
-
name: publicSpanName(event),
|
|
30
|
-
kind: 1,
|
|
31
|
-
startTimeUnixNano: start,
|
|
32
|
-
endTimeUnixNano: (BigInt(start) + 1n).toString(),
|
|
33
|
-
attributes: publicAttributes(event, "traces"),
|
|
34
|
-
status: { code: event.type === "RUN_ERROR" ? 2 : 1 }
|
|
35
|
-
}];
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
resourceSpans: spans.length === 0 ? [] : [{
|
|
39
|
-
resource: publicResource(),
|
|
40
|
-
scopeSpans: [{ scope: SCOPE, spans }]
|
|
41
|
-
}]
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function projectLogs(events) {
|
|
45
|
-
const logRecords = events
|
|
46
|
-
.filter((event) => event.channel === "log" || event.type === "LOG")
|
|
47
|
-
.map((event) => {
|
|
48
|
-
const time = unixNano(event.time);
|
|
49
|
-
const severity = severityOf(event.level);
|
|
50
|
-
const message = typeof event.message === "string"
|
|
51
|
-
? event.message
|
|
52
|
-
: typeof event.data["message"] === "string"
|
|
53
|
-
? event.data["message"]
|
|
54
|
-
: event.type;
|
|
55
|
-
return {
|
|
56
|
-
timeUnixNano: time,
|
|
57
|
-
observedTimeUnixNano: time,
|
|
58
|
-
...severity,
|
|
59
|
-
body: { stringValue: redactString(message) },
|
|
60
|
-
attributes: publicAttributes(event, "logs"),
|
|
61
|
-
...(validTraceId(event.traceId) ? { traceId: event.traceId } : {}),
|
|
62
|
-
...(validSpanId(event.spanId) ? { spanId: event.spanId } : {})
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
resourceLogs: logRecords.length === 0 ? [] : [{
|
|
67
|
-
resource: publicResource(),
|
|
68
|
-
scopeLogs: [{ scope: SCOPE, logRecords }]
|
|
69
|
-
}]
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function publicResource() {
|
|
73
|
-
return {
|
|
74
|
-
attributes: [
|
|
75
|
-
attribute("service.name", "aex"),
|
|
76
|
-
attribute("aex.visibility", "external")
|
|
77
|
-
]
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function publicAttributes(event, signal) {
|
|
81
|
-
const attributes = [
|
|
82
|
-
attribute("aex.visibility", "external"),
|
|
83
|
-
attribute("aex.session.id", event.subject),
|
|
84
|
-
attribute("aex.run.id", event.runId)
|
|
85
|
-
];
|
|
86
|
-
const turnSeq = publicNumber(event.data["turnSeq"])
|
|
87
|
-
?? publicNestedNumber(event.data["value"], "turnSeq");
|
|
88
|
-
if (turnSeq !== undefined)
|
|
89
|
-
attributes.push(attribute("aex.turn.seq", turnSeq));
|
|
90
|
-
const callId = publicString(event.data["callId"])
|
|
91
|
-
?? publicNestedString(event.data["fields"], "callId")
|
|
92
|
-
?? publicNestedString(event.data["value"], "callId");
|
|
93
|
-
if (callId !== undefined)
|
|
94
|
-
attributes.push(attribute("aex.call.id", callId));
|
|
95
|
-
const failureClass = publicString(event.data["failureClass"]);
|
|
96
|
-
if (failureClass !== undefined)
|
|
97
|
-
attributes.push(attribute("aex.failure.class_public", failureClass));
|
|
98
|
-
if (signal === "logs") {
|
|
99
|
-
const ioStream = publicIoStream(event.data["stream"])
|
|
100
|
-
?? publicNestedIoStream(event.data["fields"], "stream")
|
|
101
|
-
?? publicNestedIoStream(event.data["value"], "stream");
|
|
102
|
-
if (ioStream !== undefined)
|
|
103
|
-
attributes.push(attribute("log.iostream", ioStream));
|
|
104
|
-
}
|
|
105
|
-
const exitCode = publicSafeInteger(event.data["exitCode"])
|
|
106
|
-
?? publicNestedSafeInteger(event.data["fields"], "exitCode")
|
|
107
|
-
?? publicNestedSafeInteger(event.data["value"], "exitCode");
|
|
108
|
-
if (exitCode !== undefined)
|
|
109
|
-
attributes.push(attribute("aex.tool.exit_code", exitCode));
|
|
110
|
-
return attributes;
|
|
111
|
-
}
|
|
112
|
-
function publicSpanName(event) {
|
|
113
|
-
const customName = event.type === "CUSTOM" ? publicString(event.data["name"]) : undefined;
|
|
114
|
-
return redactString(customName ?? event.type);
|
|
115
|
-
}
|
|
116
|
-
function attribute(key, value) {
|
|
117
|
-
if (typeof value === "string")
|
|
118
|
-
return { key, value: { stringValue: redactString(value) } };
|
|
119
|
-
if (typeof value === "boolean")
|
|
120
|
-
return { key, value: { boolValue: value } };
|
|
121
|
-
return Number.isSafeInteger(value)
|
|
122
|
-
? { key, value: { intValue: String(value) } }
|
|
123
|
-
: { key, value: { doubleValue: value } };
|
|
124
|
-
}
|
|
125
|
-
function severityOf(level) {
|
|
126
|
-
if (level === "error")
|
|
127
|
-
return { severityNumber: 17, severityText: "ERROR" };
|
|
128
|
-
if (level === "warn")
|
|
129
|
-
return { severityNumber: 13, severityText: "WARN" };
|
|
130
|
-
return { severityNumber: 9, severityText: "INFO" };
|
|
131
|
-
}
|
|
132
|
-
function unixNano(value) {
|
|
133
|
-
const milliseconds = Date.parse(value);
|
|
134
|
-
return (BigInt(Number.isFinite(milliseconds) ? Math.max(0, Math.trunc(milliseconds)) : 0) * 1000000n).toString();
|
|
135
|
-
}
|
|
136
|
-
function validTraceIdentity(event) {
|
|
137
|
-
return validTraceId(event.traceId) && validSpanId(event.spanId);
|
|
138
|
-
}
|
|
139
|
-
function validTraceId(value) {
|
|
140
|
-
return typeof value === "string" && TRACE_ID.test(value) && !/^0+$/.test(value);
|
|
141
|
-
}
|
|
142
|
-
function validSpanId(value) {
|
|
143
|
-
return typeof value === "string" && SPAN_ID.test(value) && !/^0+$/.test(value);
|
|
144
|
-
}
|
|
145
|
-
function publicString(value) {
|
|
146
|
-
return typeof value === "string" && value.length > 0 ? redactString(value) : undefined;
|
|
147
|
-
}
|
|
148
|
-
function publicNumber(value) {
|
|
149
|
-
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
150
|
-
}
|
|
151
|
-
function publicSafeInteger(value) {
|
|
152
|
-
return typeof value === "number" && Number.isSafeInteger(value) ? value : undefined;
|
|
153
|
-
}
|
|
154
|
-
function publicIoStream(value) {
|
|
155
|
-
return value === "stdout" || value === "stderr" ? value : undefined;
|
|
156
|
-
}
|
|
157
|
-
function publicNestedString(value, key) {
|
|
158
|
-
return isPlainRecord(value) ? publicString(value[key]) : undefined;
|
|
159
|
-
}
|
|
160
|
-
function publicNestedNumber(value, key) {
|
|
161
|
-
return isPlainRecord(value) ? publicNumber(value[key]) : undefined;
|
|
162
|
-
}
|
|
163
|
-
function publicNestedSafeInteger(value, key) {
|
|
164
|
-
return isPlainRecord(value) ? publicSafeInteger(value[key]) : undefined;
|
|
165
|
-
}
|
|
166
|
-
function publicNestedIoStream(value, key) {
|
|
167
|
-
return isPlainRecord(value) ? publicIoStream(value[key]) : undefined;
|
|
168
|
-
}
|
|
169
|
-
function isPlainRecord(value) {
|
|
170
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
171
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** Default post-agent-run hook timeout (5 minutes). */
|
|
2
|
-
export declare const DEFAULT_POST_HOOK_TIMEOUT_MS: number;
|
|
3
|
-
/** Default number of repair turns after a failing hook. */
|
|
4
|
-
export declare const DEFAULT_POST_HOOK_MAX_TURNS = 10;
|
|
5
|
-
/**
|
|
6
|
-
* Private post-agent-run verifier input. The public SDK does not
|
|
7
|
-
* accepts this field; platform-internal paths may still normalize old wire
|
|
8
|
-
* records to {@link PlatformPostHook}.
|
|
9
|
-
*
|
|
10
|
-
* The runtime statement of this shape is `postHookSchema()` in
|
|
11
|
-
* `./schemas/post-hook.ts`; its keys are the accepted field list.
|
|
12
|
-
*/
|
|
13
|
-
export interface PlatformPostHookInput {
|
|
14
|
-
readonly command: string;
|
|
15
|
-
readonly timeout?: string;
|
|
16
|
-
readonly maxTurns?: number;
|
|
17
|
-
readonly maxChars?: number | null;
|
|
18
|
-
}
|
|
19
|
-
/** Parsed post-agent-run verifier carried through dispatch to the runner. */
|
|
20
|
-
export interface PlatformPostHook {
|
|
21
|
-
readonly command: string;
|
|
22
|
-
readonly timeoutMs: number;
|
|
23
|
-
readonly maxTurns: number;
|
|
24
|
-
readonly maxChars: number | null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Parse the private `postHook` option. An omitted hook, null hook, or hook with
|
|
28
|
-
* an empty/whitespace-only command is treated as omitted so callers can pre-fill
|
|
29
|
-
* configs without enabling the verifier accidentally.
|
|
30
|
-
*/
|
|
31
|
-
export declare function parsePostHook(input: unknown, path?: string): PlatformPostHook | undefined;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { parseDurationToMs } from "./runtime-sizes.js";
|
|
2
|
-
import { withContractParseError } from "./contract-parse-error.js";
|
|
3
|
-
import { postHookGateSchema, postHookSchema } from "./schemas/post-hook.js";
|
|
4
|
-
import { parseWire } from "./schemas/wire.js";
|
|
5
|
-
/** Default post-agent-run hook timeout (5 minutes). */
|
|
6
|
-
export const DEFAULT_POST_HOOK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
7
|
-
/** Default number of repair turns after a failing hook. */
|
|
8
|
-
export const DEFAULT_POST_HOOK_MAX_TURNS = 10;
|
|
9
|
-
/**
|
|
10
|
-
* Parse the private `postHook` option. An omitted hook, null hook, or hook with
|
|
11
|
-
* an empty/whitespace-only command is treated as omitted so callers can pre-fill
|
|
12
|
-
* configs without enabling the verifier accidentally.
|
|
13
|
-
*/
|
|
14
|
-
export function parsePostHook(input, path = "postHook") {
|
|
15
|
-
return withContractParseError("parsePostHook", () => {
|
|
16
|
-
if (input === undefined || input === null) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
// Two passes, deliberately. The gate settles shape, the allow-list and the
|
|
20
|
-
// command; only if the command is non-blank do the sibling rules run. A
|
|
21
|
-
// single pass would reject `{ command: "", timeout: <junk> }`, which is
|
|
22
|
-
// exactly the pre-filled config the blank-command rule exists to allow.
|
|
23
|
-
if (parseWire(postHookGateSchema(path), input).command.trim().length === 0) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
return normalizePostHook(parseWire(postHookSchema(path), input), path);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Apply the hook's defaults and turn its wire duration into milliseconds.
|
|
31
|
-
*
|
|
32
|
-
* Separate from the schema because both halves are transforms — per D4 a schema
|
|
33
|
-
* that transformed could not be converted on the output side — and because the
|
|
34
|
-
* duration parse belongs to {@link parseDurationToMs}, which brands its own
|
|
35
|
-
* failures.
|
|
36
|
-
*
|
|
37
|
-
* The blank-command collapse is repeated here so this function is correct on its
|
|
38
|
-
* own; the caller has already applied it via the gate schema, which is what
|
|
39
|
-
* keeps a blank command from ever reaching the sibling field rules.
|
|
40
|
-
*/
|
|
41
|
-
function normalizePostHook(hook, path) {
|
|
42
|
-
if (hook.command.trim().length === 0) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
command: hook.command,
|
|
47
|
-
timeoutMs: postHookTimeoutMs(hook.timeout, `${path}.timeout`),
|
|
48
|
-
maxTurns: hook.maxTurns ?? DEFAULT_POST_HOOK_MAX_TURNS,
|
|
49
|
-
maxChars: hook.maxChars ?? null
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function postHookTimeoutMs(timeout, path) {
|
|
53
|
-
if (timeout === undefined) {
|
|
54
|
-
return DEFAULT_POST_HOOK_TIMEOUT_MS;
|
|
55
|
-
}
|
|
56
|
-
const ms = parseDurationToMs(timeout);
|
|
57
|
-
if (ms <= 0) {
|
|
58
|
-
throw new Error(`${path} must be greater than 0ms; got ${ms}ms`);
|
|
59
|
-
}
|
|
60
|
-
return ms;
|
|
61
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** Canonical, redaction-safe terminal fault reported by an upstream provider. */
|
|
2
|
-
export declare const PROVIDER_FAULT_KINDS: readonly ["rate_limit", "overloaded", "quota_exceeded", "unavailable", "provider_error"];
|
|
3
|
-
export type KnownProviderFaultKind = (typeof PROVIDER_FAULT_KINDS)[number];
|
|
4
|
-
declare const UNKNOWN_PROVIDER_FAULT_KIND: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* A syntactically valid future provider-fault kind accepted from the wire.
|
|
7
|
-
* Producers must use a known kind; only the canonical parser creates this type.
|
|
8
|
-
*/
|
|
9
|
-
export type UnknownProviderFaultKind = string & {
|
|
10
|
-
readonly [UNKNOWN_PROVIDER_FAULT_KIND]: "UnknownProviderFaultKind";
|
|
11
|
-
};
|
|
12
|
-
export type ProviderFaultKind = KnownProviderFaultKind | UnknownProviderFaultKind;
|
|
13
|
-
export interface ProviderFault {
|
|
14
|
-
/** Upstream provider id, for example `anthropic`, when reported. */
|
|
15
|
-
readonly provider?: string;
|
|
16
|
-
/** Exact machine-readable fault class. Unknown future tokens are non-throttling. */
|
|
17
|
-
readonly kind: ProviderFaultKind;
|
|
18
|
-
/** Upstream HTTP status, when reported. */
|
|
19
|
-
readonly status?: number;
|
|
20
|
-
/** Retry delay in milliseconds, when reported. */
|
|
21
|
-
readonly retryAfterMs?: number;
|
|
22
|
-
/** Short, already-redacted diagnostic message. */
|
|
23
|
-
readonly message?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function isKnownProviderFaultKind(kind: string): kind is KnownProviderFaultKind;
|
|
26
|
-
/**
|
|
27
|
-
* Strictly parse the canonical provider-fault wire object.
|
|
28
|
-
*
|
|
29
|
-
* This parser intentionally rejects aliases, coercions, unknown fields, and
|
|
30
|
-
* malformed present values. A valid future `kind` token is preserved for
|
|
31
|
-
* forward compatibility, but callers must not infer throttle semantics from it.
|
|
32
|
-
*/
|
|
33
|
-
export declare function parseProviderFault(value: unknown): ProviderFault;
|
|
34
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/** Canonical, redaction-safe terminal fault reported by an upstream provider. */
|
|
2
|
-
import { rethrowContractParseError } from "./contract-parse-error.js";
|
|
3
|
-
import { isRecord } from "./value-guards.js";
|
|
4
|
-
export const PROVIDER_FAULT_KINDS = [
|
|
5
|
-
"rate_limit",
|
|
6
|
-
"overloaded",
|
|
7
|
-
"quota_exceeded",
|
|
8
|
-
"unavailable",
|
|
9
|
-
"provider_error"
|
|
10
|
-
];
|
|
11
|
-
const PROVIDER_FAULT_KIND_SET = new Set(PROVIDER_FAULT_KINDS);
|
|
12
|
-
const PROVIDER_FAULT_KEYS = new Set(["provider", "kind", "status", "retryAfterMs", "message"]);
|
|
13
|
-
const KIND_TOKEN = /^[a-z][a-z0-9_.:-]{0,63}$/;
|
|
14
|
-
const PROVIDER_TOKEN = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
|
|
15
|
-
const MAX_MESSAGE_LENGTH = 512;
|
|
16
|
-
export function isKnownProviderFaultKind(kind) {
|
|
17
|
-
return PROVIDER_FAULT_KIND_SET.has(kind);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Strictly parse the canonical provider-fault wire object.
|
|
21
|
-
*
|
|
22
|
-
* This parser intentionally rejects aliases, coercions, unknown fields, and
|
|
23
|
-
* malformed present values. A valid future `kind` token is preserved for
|
|
24
|
-
* forward compatibility, but callers must not infer throttle semantics from it.
|
|
25
|
-
*/
|
|
26
|
-
export function parseProviderFault(value) {
|
|
27
|
-
try {
|
|
28
|
-
return parseProviderFaultValue(value);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
rethrowContractParseError(error, "parseProviderFault");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function parseProviderFaultValue(value) {
|
|
35
|
-
if (!isRecord(value))
|
|
36
|
-
throw new TypeError("providerFault must be an object");
|
|
37
|
-
for (const key of Object.keys(value)) {
|
|
38
|
-
if (!PROVIDER_FAULT_KEYS.has(key)) {
|
|
39
|
-
throw new TypeError("providerFault contains an unknown field");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (!Object.hasOwn(value, "kind") || typeof value.kind !== "string" || !KIND_TOKEN.test(value.kind)) {
|
|
43
|
-
throw new TypeError("providerFault.kind must be a canonical token");
|
|
44
|
-
}
|
|
45
|
-
if (Object.hasOwn(value, "provider") && (typeof value.provider !== "string" || !PROVIDER_TOKEN.test(value.provider))) {
|
|
46
|
-
throw new TypeError("providerFault.provider must be a canonical provider token");
|
|
47
|
-
}
|
|
48
|
-
if (Object.hasOwn(value, "status") && (!Number.isInteger(value.status) || value.status < 100 || value.status > 599)) {
|
|
49
|
-
throw new TypeError("providerFault.status must be an HTTP status integer");
|
|
50
|
-
}
|
|
51
|
-
if (Object.hasOwn(value, "retryAfterMs") && (!Number.isSafeInteger(value.retryAfterMs) || value.retryAfterMs < 0)) {
|
|
52
|
-
throw new TypeError("providerFault.retryAfterMs must be a non-negative safe integer");
|
|
53
|
-
}
|
|
54
|
-
if (Object.hasOwn(value, "message") && (typeof value.message !== "string" || value.message.length === 0 ||
|
|
55
|
-
value.message.length > MAX_MESSAGE_LENGTH || /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(value.message))) {
|
|
56
|
-
throw new TypeError(`providerFault.message must be 1-${MAX_MESSAGE_LENGTH} printable characters`);
|
|
57
|
-
}
|
|
58
|
-
const kind = isKnownProviderFaultKind(value.kind)
|
|
59
|
-
? value.kind
|
|
60
|
-
: value.kind;
|
|
61
|
-
return {
|
|
62
|
-
kind,
|
|
63
|
-
...(Object.hasOwn(value, "provider") ? { provider: value.provider } : {}),
|
|
64
|
-
...(Object.hasOwn(value, "status") ? { status: value.status } : {}),
|
|
65
|
-
...(Object.hasOwn(value, "retryAfterMs") ? { retryAfterMs: value.retryAfterMs } : {}),
|
|
66
|
-
...(Object.hasOwn(value, "message") ? { message: value.message } : {})
|
|
67
|
-
};
|
|
68
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public-safe retry primitives shared by public packages through the
|
|
3
|
-
* `@aexhq/contracts/internal` subpath. Keep this module free of hosted
|
|
4
|
-
* implementation details and do not export it from the public contracts root.
|
|
5
|
-
*/
|
|
6
|
-
export declare const RETRYABLE_HTTP_STATUS: readonly number[];
|
|
7
|
-
export declare const RATE_LIMIT_HTTP_STATUS: readonly number[];
|
|
8
|
-
export interface RetryBackoffConfig {
|
|
9
|
-
readonly initialDelayMs: number;
|
|
10
|
-
readonly maxDelayMs: number;
|
|
11
|
-
}
|
|
12
|
-
export type RetryRandom = () => number;
|
|
13
|
-
export declare function isRetryableHttpStatus(status: number): boolean;
|
|
14
|
-
export declare function isRateLimitHttpStatus(status: number): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Parse an HTTP `Retry-After` header into milliseconds. RFC 7231 permits either
|
|
17
|
-
* a non-negative integer number of seconds or an HTTP-date.
|
|
18
|
-
*/
|
|
19
|
-
export declare function tryParseRetryAfterMs(headerValue: string | null | undefined, now?: number): number | undefined;
|
|
20
|
-
/** @deprecated Use {@link tryParseRetryAfterMs}; this compatibility wrapper is identical. */
|
|
21
|
-
export declare function parseRetryAfterMs(headerValue: string | null | undefined, now?: number): number | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Full-jitter exponential backoff: the nominal wait doubles per failed attempt
|
|
24
|
-
* and the actual delay is sampled uniformly in `[0, nominal]`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function computeRetryBackoffDelayMs(config: RetryBackoffConfig, attemptNumber: number, random: RetryRandom): number;
|
|
27
|
-
/** Combine a server `Retry-After` floor with the jittered backoff delay. */
|
|
28
|
-
export declare function computeRetryDelayMs(config: RetryBackoffConfig, attemptNumber: number, random: RetryRandom, retryAfterMs: number | undefined): number;
|
|
29
|
-
export declare function abortableSleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public-safe retry primitives shared by public packages through the
|
|
3
|
-
* `@aexhq/contracts/internal` subpath. Keep this module free of hosted
|
|
4
|
-
* implementation details and do not export it from the public contracts root.
|
|
5
|
-
*/
|
|
6
|
-
export const RETRYABLE_HTTP_STATUS = [429, 500, 502, 503, 504, 529];
|
|
7
|
-
export const RATE_LIMIT_HTTP_STATUS = [429, 503, 529];
|
|
8
|
-
const RETRYABLE_HTTP_STATUS_SET = new Set(RETRYABLE_HTTP_STATUS);
|
|
9
|
-
const RATE_LIMIT_HTTP_STATUS_SET = new Set(RATE_LIMIT_HTTP_STATUS);
|
|
10
|
-
export function isRetryableHttpStatus(status) {
|
|
11
|
-
return RETRYABLE_HTTP_STATUS_SET.has(status);
|
|
12
|
-
}
|
|
13
|
-
export function isRateLimitHttpStatus(status) {
|
|
14
|
-
return RATE_LIMIT_HTTP_STATUS_SET.has(status);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parse an HTTP `Retry-After` header into milliseconds. RFC 7231 permits either
|
|
18
|
-
* a non-negative integer number of seconds or an HTTP-date.
|
|
19
|
-
*/
|
|
20
|
-
export function tryParseRetryAfterMs(headerValue, now = Date.now()) {
|
|
21
|
-
if (headerValue === null || headerValue === undefined)
|
|
22
|
-
return undefined;
|
|
23
|
-
const trimmed = headerValue.trim();
|
|
24
|
-
if (trimmed.length === 0)
|
|
25
|
-
return undefined;
|
|
26
|
-
if (/^\d+$/.test(trimmed)) {
|
|
27
|
-
return Number(trimmed) * 1000;
|
|
28
|
-
}
|
|
29
|
-
const dateMs = Date.parse(trimmed);
|
|
30
|
-
if (!Number.isNaN(dateMs)) {
|
|
31
|
-
return Math.max(0, dateMs - now);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
/** @deprecated Use {@link tryParseRetryAfterMs}; this compatibility wrapper is identical. */
|
|
36
|
-
export function parseRetryAfterMs(headerValue, now = Date.now()) {
|
|
37
|
-
return tryParseRetryAfterMs(headerValue, now);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Full-jitter exponential backoff: the nominal wait doubles per failed attempt
|
|
41
|
-
* and the actual delay is sampled uniformly in `[0, nominal]`.
|
|
42
|
-
*/
|
|
43
|
-
export function computeRetryBackoffDelayMs(config, attemptNumber, random) {
|
|
44
|
-
const exponent = Math.max(0, attemptNumber - 1);
|
|
45
|
-
const nominal = Math.min(config.maxDelayMs, config.initialDelayMs * 2 ** exponent);
|
|
46
|
-
return Math.round(random() * nominal);
|
|
47
|
-
}
|
|
48
|
-
/** Combine a server `Retry-After` floor with the jittered backoff delay. */
|
|
49
|
-
export function computeRetryDelayMs(config, attemptNumber, random, retryAfterMs) {
|
|
50
|
-
const backoff = computeRetryBackoffDelayMs(config, attemptNumber, random);
|
|
51
|
-
return retryAfterMs === undefined ? backoff : Math.max(retryAfterMs, backoff);
|
|
52
|
-
}
|
|
53
|
-
export function abortableSleep(ms, signal) {
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
if (signal?.aborted) {
|
|
56
|
-
reject(abortReason(signal));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const timer = setTimeout(() => {
|
|
60
|
-
signal?.removeEventListener("abort", onAbort);
|
|
61
|
-
resolve();
|
|
62
|
-
}, ms);
|
|
63
|
-
const onAbort = () => {
|
|
64
|
-
clearTimeout(timer);
|
|
65
|
-
reject(signal ? abortReason(signal) : makeAbortError());
|
|
66
|
-
};
|
|
67
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function abortReason(signal) {
|
|
71
|
-
return signal.reason instanceof Error ? signal.reason : makeAbortError();
|
|
72
|
-
}
|
|
73
|
-
function makeAbortError() {
|
|
74
|
-
if (typeof DOMException !== "undefined")
|
|
75
|
-
return new DOMException("Aborted", "AbortError");
|
|
76
|
-
const err = new Error("Aborted");
|
|
77
|
-
err.name = "AbortError";
|
|
78
|
-
return err;
|
|
79
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified runner event schema. The managed runtime feeds one shape into
|
|
3
|
-
* the hosted aex event pipeline:
|
|
4
|
-
*
|
|
5
|
-
* - The per-session managed runtime POSTs batches of NDJSON events to
|
|
6
|
-
* `/sessions/{id}/runner/events`; the runtime adapter translates each
|
|
7
|
-
* event into one or more `RunnerEvent`s.
|
|
8
|
-
*
|
|
9
|
-
* The downstream subscribers (dashboard, SDK `streamEvents`, observable
|
|
10
|
-
* spans) never see runtime-specific wire shapes — they only see
|
|
11
|
-
* `RunnerEvent`s.
|
|
12
|
-
*
|
|
13
|
-
* This is the public event contract consumed by SDK and CLI clients.
|
|
14
|
-
*/
|
|
15
|
-
import { type JsonValue } from "./value-guards.js";
|
|
16
|
-
/**
|
|
17
|
-
* Schema version. Bump when the shape of `RunnerEvent`, its kind set,
|
|
18
|
-
* or the batch envelope changes. Subscribers gate on this so a future
|
|
19
|
-
* v2 wire shape can land behind a feature flag.
|
|
20
|
-
*/
|
|
21
|
-
export declare const RUNNER_EVENT_VERSION: 1;
|
|
22
|
-
/**
|
|
23
|
-
* The set of event kinds emitted into the unified stream. Adapters
|
|
24
|
-
* fold runtime-specific events into one of these — anything that
|
|
25
|
-
* doesn't fit is mapped to `notification` so the data is captured
|
|
26
|
-
* even when no UI handler exists yet.
|
|
27
|
-
*
|
|
28
|
-
* - `runtime_started` — the managed runtime announced "ready" or
|
|
29
|
-
* accepted the first turn.
|
|
30
|
-
* - `assistant_text` — model text delta.
|
|
31
|
-
* - `tool_request` — model emitted a tool_use / function call.
|
|
32
|
-
* - `tool_response` — tool result delivered back to the model.
|
|
33
|
-
* - `skill_loaded` — a skill was loaded from a provider ref or
|
|
34
|
-
* a workspace folder mount.
|
|
35
|
-
* - `file_uploaded` — a file became available to the agent
|
|
36
|
-
* (Files API id OR workspace path).
|
|
37
|
-
* - `notification` — runtime/extension notification; catch-all
|
|
38
|
-
* for diagnostic data.
|
|
39
|
-
* - `stream_error` — stream-level error (non-fatal). Subscribers
|
|
40
|
-
* may surface this as a UI warning; the session
|
|
41
|
-
* continues unless `runtime_terminal` follows.
|
|
42
|
-
* - `runtime_terminal` — the session reached a terminal state. The
|
|
43
|
-
* adapter MUST emit exactly one of these per
|
|
44
|
-
* run; subscribers gate on it for end-of-stream.
|
|
45
|
-
*/
|
|
46
|
-
export declare const RUNNER_EVENT_KINDS: readonly ["runtime_started", "assistant_text", "tool_request", "tool_response", "skill_loaded", "file_uploaded", "notification", "stream_error", "runtime_terminal"];
|
|
47
|
-
export type RunnerEventKind = (typeof RUNNER_EVENT_KINDS)[number];
|
|
48
|
-
/**
|
|
49
|
-
* One event in the unified stream. `seq` is monotonically increasing
|
|
50
|
-
* within a single run (the adapter is responsible for assigning seqs
|
|
51
|
-
* — no two events with the same `seq` for the same `sessionId`); `tMs` is
|
|
52
|
-
* a millisecond-resolution timestamp that is also monotonically
|
|
53
|
-
* non-decreasing within a single run (an event's `tMs` is never less
|
|
54
|
-
* than the previous event's `tMs`). `data` carries the runtime- and
|
|
55
|
-
* kind-specific payload, JSON-typed so the batch round-trips through
|
|
56
|
-
* the database column without ad-hoc serialization.
|
|
57
|
-
*/
|
|
58
|
-
export interface RunnerEvent {
|
|
59
|
-
readonly seq: number;
|
|
60
|
-
readonly tMs: number;
|
|
61
|
-
/** Optional per-source ordering counter carried through to AexEvent. */
|
|
62
|
-
readonly sourceSeq?: number;
|
|
63
|
-
/** Optional producer wall-clock time in milliseconds. */
|
|
64
|
-
readonly emittedAt?: number;
|
|
65
|
-
readonly kind: RunnerEventKind;
|
|
66
|
-
readonly data: Readonly<Record<string, JsonValue>>;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Batch envelope. The runner ships one or more events per POST so the
|
|
70
|
-
* inbox writes them atomically. `events` MUST be sorted by `seq`
|
|
71
|
-
* ascending; api.aex.dev rejects malformed batches before touching
|
|
72
|
-
* Postgres.
|
|
73
|
-
*/
|
|
74
|
-
export interface RunnerEventBatch {
|
|
75
|
-
readonly v: typeof RUNNER_EVENT_VERSION;
|
|
76
|
-
readonly sessionId: string;
|
|
77
|
-
readonly events: readonly RunnerEvent[];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Maximum number of events per batch. Bounds the size of the body
|
|
81
|
-
* api.aex.dev accepts and the size of the downstream Postgres / metadata-store
|
|
82
|
-
* write. Larger streams are split into multiple batches; the runner is
|
|
83
|
-
* responsible for chunking.
|
|
84
|
-
*/
|
|
85
|
-
export declare const RUNNER_EVENT_BATCH_MAX_EVENTS: 256;
|
|
86
|
-
/**
|
|
87
|
-
* Validation outcome for an inbound batch. The `ok` branch returns
|
|
88
|
-
* the parsed batch with frozen events; the `error` branch returns the
|
|
89
|
-
* code + a short human message suitable for an HTTP 400 body. Codes
|
|
90
|
-
* are stable strings — the dashboard / SDK may branch on them.
|
|
91
|
-
*/
|
|
92
|
-
export type RunnerEventBatchValidation = {
|
|
93
|
-
readonly ok: true;
|
|
94
|
-
readonly batch: RunnerEventBatch;
|
|
95
|
-
} | {
|
|
96
|
-
readonly ok: false;
|
|
97
|
-
readonly code: RunnerEventBatchValidationCode;
|
|
98
|
-
readonly message: string;
|
|
99
|
-
};
|
|
100
|
-
export declare const RUNNER_EVENT_BATCH_VALIDATION_CODES: readonly ["invalid_envelope", "version_mismatch", "missing_session_id", "empty_batch", "batch_too_large", "invalid_event", "seq_not_monotonic", "t_ms_not_monotonic"];
|
|
101
|
-
export type RunnerEventBatchValidationCode = (typeof RUNNER_EVENT_BATCH_VALIDATION_CODES)[number];
|
|
102
|
-
/**
|
|
103
|
-
* Parse + validate an inbound runner event batch (untrusted input).
|
|
104
|
-
* Used at the api.aex.dev ingress so adapters never have to
|
|
105
|
-
* re-check the wire shape, and used by tests to assert the contract.
|
|
106
|
-
*
|
|
107
|
-
* Successful validation guarantees:
|
|
108
|
-
* - top-level envelope matches {@link RunnerEventBatch}
|
|
109
|
-
* - `v === RUNNER_EVENT_VERSION`
|
|
110
|
-
* - `sessionId` is a non-empty string
|
|
111
|
-
* - `events` is a non-empty array of at most
|
|
112
|
-
* {@link RUNNER_EVENT_BATCH_MAX_EVENTS} entries
|
|
113
|
-
* - each event is a {@link RunnerEvent} with a known `kind`
|
|
114
|
-
* - `seq` is strictly increasing across the batch
|
|
115
|
-
* - `tMs` is non-decreasing across the batch
|
|
116
|
-
*/
|
|
117
|
-
export declare function validateRunnerEventBatch(input: unknown): RunnerEventBatchValidation;
|