@dual-os/sdk 0.8.0-next.2 → 0.8.0-next.3
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/PluginRuntime.d.ts +305 -9
- package/dist/PluginRuntime.d.ts.map +1 -1
- package/dist/PluginRuntime.js +9 -3
- package/dist/PluginRuntime.js.map +1 -1
- package/dist/remote-runtime.d.ts +292 -10
- package/dist/remote-runtime.d.ts.map +1 -1
- package/dist/remote-runtime.js +9 -15
- package/dist/remote-runtime.js.map +1 -1
- package/package.json +1 -1
- package/src/PluginRuntime.ts +9 -4
- package/src/remote-runtime.ts +12 -23
package/dist/PluginRuntime.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { AuthMethodHookError, ExpectedOAuth2MethodError, OAuth2RefreshTokenUnavailableError } from "./AuthMethod.js";
|
|
2
|
+
import { ActionHandlerError, RetryableActionHandlerError } from "./Action.js";
|
|
1
3
|
import { ChannelError } from "./AgentChannel.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
+
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolverStoreError, ConnectionSelectionRequiredError, InvalidConnectionIdError, InvalidResolvedConnectionError } from "./ConnectionResolver.js";
|
|
5
|
+
import { ActionHandlerNotFoundError, ActionNotFoundError, InvalidActionInputError, InvalidActionOutputError } from "./internal/dual/invoke.js";
|
|
6
|
+
import { AuthMethodNotFoundError, Service } from "./DualRuntime.js";
|
|
4
7
|
import { Service as Service$1 } from "./OAuthFlow.js";
|
|
5
8
|
import "./PluginRuntime.js";
|
|
6
9
|
import { Cause, Effect, Schema, Stream } from "effect";
|
|
@@ -905,7 +908,7 @@ export declare const Output: Schema.Union<readonly [Schema.Union<readonly [Schem
|
|
|
905
908
|
}>;
|
|
906
909
|
readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
907
910
|
}>, Schema.TaggedStruct<"failure", {
|
|
908
|
-
readonly error: Schema.Struct<{
|
|
911
|
+
readonly error: Schema.Union<readonly [typeof ActionHandlerError, typeof RetryableActionHandlerError, Schema.Struct<{
|
|
909
912
|
readonly category: Schema.Literals<readonly ["validation", "connection", "handler", "initialization", "protocol"]>;
|
|
910
913
|
readonly channel: Schema.optionalKey<Schema.Struct<{
|
|
911
914
|
readonly code: Schema.Literals<readonly ["invalid_definition", "not_found", "invalid_input", "invalid_auth", "unsupported_feature", "invalid_result", "handler_unavailable", "provider_failure"]>;
|
|
@@ -919,7 +922,7 @@ export declare const Output: Schema.Union<readonly [Schema.Union<readonly [Schem
|
|
|
919
922
|
readonly retryAfterSeconds: Schema.optionalKey<Schema.Finite>;
|
|
920
923
|
readonly retryable: Schema.Boolean;
|
|
921
924
|
readonly status: Schema.optionalKey<Schema.Int>;
|
|
922
|
-
}>;
|
|
925
|
+
}>]>;
|
|
923
926
|
readonly identity: Schema.Struct<{
|
|
924
927
|
readonly artifactDigest: Schema.String;
|
|
925
928
|
readonly invocationId: Schema.NonEmptyString;
|
|
@@ -1850,7 +1853,7 @@ export declare const decodeInput: (input: unknown) => Effect.Effect<{
|
|
|
1850
1853
|
}, PluginExecutionError | Schema.SchemaError, never>;
|
|
1851
1854
|
export declare const encodeOutput: (output: {
|
|
1852
1855
|
readonly _tag: "failure";
|
|
1853
|
-
readonly error: {
|
|
1856
|
+
readonly error: ActionHandlerError | RetryableActionHandlerError | {
|
|
1854
1857
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1855
1858
|
readonly channel?: {
|
|
1856
1859
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -1894,6 +1897,19 @@ export declare const encodeOutput: (output: {
|
|
|
1894
1897
|
}, maximum: number) => Effect.Effect<{
|
|
1895
1898
|
readonly _tag: "failure";
|
|
1896
1899
|
readonly error: {
|
|
1900
|
+
readonly _tag: "ActionHandlerError";
|
|
1901
|
+
readonly cause?: Schema.Json | undefined;
|
|
1902
|
+
readonly details?: unknown;
|
|
1903
|
+
readonly message: string;
|
|
1904
|
+
readonly status?: number | undefined;
|
|
1905
|
+
} | {
|
|
1906
|
+
readonly _tag: "RetryableActionHandlerError";
|
|
1907
|
+
readonly cause?: Schema.Json | undefined;
|
|
1908
|
+
readonly details?: unknown;
|
|
1909
|
+
readonly message: string;
|
|
1910
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
1911
|
+
readonly status?: number | undefined;
|
|
1912
|
+
} | {
|
|
1897
1913
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1898
1914
|
readonly channel?: {
|
|
1899
1915
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -1937,7 +1953,7 @@ export declare const encodeOutput: (output: {
|
|
|
1937
1953
|
}, PluginExecutionError | Schema.SchemaError, never>;
|
|
1938
1954
|
export declare const decodeOutput: (output: unknown) => Effect.Effect<{
|
|
1939
1955
|
readonly _tag: "failure";
|
|
1940
|
-
readonly error: {
|
|
1956
|
+
readonly error: ActionHandlerError | RetryableActionHandlerError | {
|
|
1941
1957
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1942
1958
|
readonly channel?: {
|
|
1943
1959
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3110,7 +3126,7 @@ export declare const execute: (request: {
|
|
|
3110
3126
|
};
|
|
3111
3127
|
}) => Effect.Effect<{
|
|
3112
3128
|
_tag: "failure";
|
|
3113
|
-
error:
|
|
3129
|
+
error: ActionHandlerError | RetryableActionHandlerError | {
|
|
3114
3130
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3115
3131
|
readonly channel?: {
|
|
3116
3132
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3124,7 +3140,7 @@ export declare const execute: (request: {
|
|
|
3124
3140
|
readonly retryAfterSeconds?: number;
|
|
3125
3141
|
readonly retryable: boolean;
|
|
3126
3142
|
readonly status?: number;
|
|
3127
|
-
} |
|
|
3143
|
+
} | (ActionHandlerError & {
|
|
3128
3144
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3129
3145
|
readonly channel?: {
|
|
3130
3146
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3138,7 +3154,287 @@ export declare const execute: (request: {
|
|
|
3138
3154
|
readonly retryAfterSeconds?: number;
|
|
3139
3155
|
readonly retryable: boolean;
|
|
3140
3156
|
readonly status?: number;
|
|
3141
|
-
}
|
|
3157
|
+
}) | (ActionHandlerNotFoundError & {
|
|
3158
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3159
|
+
readonly channel?: {
|
|
3160
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3161
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3162
|
+
};
|
|
3163
|
+
readonly code: string;
|
|
3164
|
+
readonly fields?: readonly {
|
|
3165
|
+
readonly path: string;
|
|
3166
|
+
}[];
|
|
3167
|
+
readonly message: string;
|
|
3168
|
+
readonly retryAfterSeconds?: number;
|
|
3169
|
+
readonly retryable: boolean;
|
|
3170
|
+
readonly status?: number;
|
|
3171
|
+
}) | (ActionNotFoundError & {
|
|
3172
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3173
|
+
readonly channel?: {
|
|
3174
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3175
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3176
|
+
};
|
|
3177
|
+
readonly code: string;
|
|
3178
|
+
readonly fields?: readonly {
|
|
3179
|
+
readonly path: string;
|
|
3180
|
+
}[];
|
|
3181
|
+
readonly message: string;
|
|
3182
|
+
readonly retryAfterSeconds?: number;
|
|
3183
|
+
readonly retryable: boolean;
|
|
3184
|
+
readonly status?: number;
|
|
3185
|
+
}) | (AuthMethodHookError & {
|
|
3186
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3187
|
+
readonly channel?: {
|
|
3188
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3189
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3190
|
+
};
|
|
3191
|
+
readonly code: string;
|
|
3192
|
+
readonly fields?: readonly {
|
|
3193
|
+
readonly path: string;
|
|
3194
|
+
}[];
|
|
3195
|
+
readonly message: string;
|
|
3196
|
+
readonly retryAfterSeconds?: number;
|
|
3197
|
+
readonly retryable: boolean;
|
|
3198
|
+
readonly status?: number;
|
|
3199
|
+
}) | (AuthMethodNotFoundError & {
|
|
3200
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3201
|
+
readonly channel?: {
|
|
3202
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3203
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3204
|
+
};
|
|
3205
|
+
readonly code: string;
|
|
3206
|
+
readonly fields?: readonly {
|
|
3207
|
+
readonly path: string;
|
|
3208
|
+
}[];
|
|
3209
|
+
readonly message: string;
|
|
3210
|
+
readonly retryAfterSeconds?: number;
|
|
3211
|
+
readonly retryable: boolean;
|
|
3212
|
+
readonly status?: number;
|
|
3213
|
+
}) | (ChannelError & {
|
|
3214
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3215
|
+
readonly channel?: {
|
|
3216
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3217
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3218
|
+
};
|
|
3219
|
+
readonly code: string;
|
|
3220
|
+
readonly fields?: readonly {
|
|
3221
|
+
readonly path: string;
|
|
3222
|
+
}[];
|
|
3223
|
+
readonly message: string;
|
|
3224
|
+
readonly retryAfterSeconds?: number;
|
|
3225
|
+
readonly retryable: boolean;
|
|
3226
|
+
readonly status?: number;
|
|
3227
|
+
}) | (ConnectionIdNotAllowedError & {
|
|
3228
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3229
|
+
readonly channel?: {
|
|
3230
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3231
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3232
|
+
};
|
|
3233
|
+
readonly code: string;
|
|
3234
|
+
readonly fields?: readonly {
|
|
3235
|
+
readonly path: string;
|
|
3236
|
+
}[];
|
|
3237
|
+
readonly message: string;
|
|
3238
|
+
readonly retryAfterSeconds?: number;
|
|
3239
|
+
readonly retryable: boolean;
|
|
3240
|
+
readonly status?: number;
|
|
3241
|
+
}) | (ConnectionReauthorizationRequiredError & {
|
|
3242
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3243
|
+
readonly channel?: {
|
|
3244
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3245
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3246
|
+
};
|
|
3247
|
+
readonly code: string;
|
|
3248
|
+
readonly fields?: readonly {
|
|
3249
|
+
readonly path: string;
|
|
3250
|
+
}[];
|
|
3251
|
+
readonly message: string;
|
|
3252
|
+
readonly retryAfterSeconds?: number;
|
|
3253
|
+
readonly retryable: boolean;
|
|
3254
|
+
readonly status?: number;
|
|
3255
|
+
}) | (ConnectionRequiredError & {
|
|
3256
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3257
|
+
readonly channel?: {
|
|
3258
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3259
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3260
|
+
};
|
|
3261
|
+
readonly code: string;
|
|
3262
|
+
readonly fields?: readonly {
|
|
3263
|
+
readonly path: string;
|
|
3264
|
+
}[];
|
|
3265
|
+
readonly message: string;
|
|
3266
|
+
readonly retryAfterSeconds?: number;
|
|
3267
|
+
readonly retryable: boolean;
|
|
3268
|
+
readonly status?: number;
|
|
3269
|
+
}) | (ConnectionResolverStoreError & {
|
|
3270
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3271
|
+
readonly channel?: {
|
|
3272
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3273
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3274
|
+
};
|
|
3275
|
+
readonly code: string;
|
|
3276
|
+
readonly fields?: readonly {
|
|
3277
|
+
readonly path: string;
|
|
3278
|
+
}[];
|
|
3279
|
+
readonly message: string;
|
|
3280
|
+
readonly retryAfterSeconds?: number;
|
|
3281
|
+
readonly retryable: boolean;
|
|
3282
|
+
readonly status?: number;
|
|
3283
|
+
}) | (ConnectionSelectionRequiredError & {
|
|
3284
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3285
|
+
readonly channel?: {
|
|
3286
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3287
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3288
|
+
};
|
|
3289
|
+
readonly code: string;
|
|
3290
|
+
readonly fields?: readonly {
|
|
3291
|
+
readonly path: string;
|
|
3292
|
+
}[];
|
|
3293
|
+
readonly message: string;
|
|
3294
|
+
readonly retryAfterSeconds?: number;
|
|
3295
|
+
readonly retryable: boolean;
|
|
3296
|
+
readonly status?: number;
|
|
3297
|
+
}) | (ExpectedOAuth2MethodError & {
|
|
3298
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3299
|
+
readonly channel?: {
|
|
3300
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3301
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3302
|
+
};
|
|
3303
|
+
readonly code: string;
|
|
3304
|
+
readonly fields?: readonly {
|
|
3305
|
+
readonly path: string;
|
|
3306
|
+
}[];
|
|
3307
|
+
readonly message: string;
|
|
3308
|
+
readonly retryAfterSeconds?: number;
|
|
3309
|
+
readonly retryable: boolean;
|
|
3310
|
+
readonly status?: number;
|
|
3311
|
+
}) | (InvalidActionInputError & {
|
|
3312
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3313
|
+
readonly channel?: {
|
|
3314
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3315
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3316
|
+
};
|
|
3317
|
+
readonly code: string;
|
|
3318
|
+
readonly fields?: readonly {
|
|
3319
|
+
readonly path: string;
|
|
3320
|
+
}[];
|
|
3321
|
+
readonly message: string;
|
|
3322
|
+
readonly retryAfterSeconds?: number;
|
|
3323
|
+
readonly retryable: boolean;
|
|
3324
|
+
readonly status?: number;
|
|
3325
|
+
}) | (InvalidActionOutputError & {
|
|
3326
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3327
|
+
readonly channel?: {
|
|
3328
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3329
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3330
|
+
};
|
|
3331
|
+
readonly code: string;
|
|
3332
|
+
readonly fields?: readonly {
|
|
3333
|
+
readonly path: string;
|
|
3334
|
+
}[];
|
|
3335
|
+
readonly message: string;
|
|
3336
|
+
readonly retryAfterSeconds?: number;
|
|
3337
|
+
readonly retryable: boolean;
|
|
3338
|
+
readonly status?: number;
|
|
3339
|
+
}) | (InvalidConnectionIdError & {
|
|
3340
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3341
|
+
readonly channel?: {
|
|
3342
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3343
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3344
|
+
};
|
|
3345
|
+
readonly code: string;
|
|
3346
|
+
readonly fields?: readonly {
|
|
3347
|
+
readonly path: string;
|
|
3348
|
+
}[];
|
|
3349
|
+
readonly message: string;
|
|
3350
|
+
readonly retryAfterSeconds?: number;
|
|
3351
|
+
readonly retryable: boolean;
|
|
3352
|
+
readonly status?: number;
|
|
3353
|
+
}) | (InvalidResolvedConnectionError & {
|
|
3354
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3355
|
+
readonly channel?: {
|
|
3356
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3357
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3358
|
+
};
|
|
3359
|
+
readonly code: string;
|
|
3360
|
+
readonly fields?: readonly {
|
|
3361
|
+
readonly path: string;
|
|
3362
|
+
}[];
|
|
3363
|
+
readonly message: string;
|
|
3364
|
+
readonly retryAfterSeconds?: number;
|
|
3365
|
+
readonly retryable: boolean;
|
|
3366
|
+
readonly status?: number;
|
|
3367
|
+
}) | (OAuth2RefreshTokenUnavailableError & {
|
|
3368
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3369
|
+
readonly channel?: {
|
|
3370
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3371
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3372
|
+
};
|
|
3373
|
+
readonly code: string;
|
|
3374
|
+
readonly fields?: readonly {
|
|
3375
|
+
readonly path: string;
|
|
3376
|
+
}[];
|
|
3377
|
+
readonly message: string;
|
|
3378
|
+
readonly retryAfterSeconds?: number;
|
|
3379
|
+
readonly retryable: boolean;
|
|
3380
|
+
readonly status?: number;
|
|
3381
|
+
}) | (RetryableActionHandlerError & {
|
|
3382
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3383
|
+
readonly channel?: {
|
|
3384
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3385
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3386
|
+
};
|
|
3387
|
+
readonly code: string;
|
|
3388
|
+
readonly fields?: readonly {
|
|
3389
|
+
readonly path: string;
|
|
3390
|
+
}[];
|
|
3391
|
+
readonly message: string;
|
|
3392
|
+
readonly retryAfterSeconds?: number;
|
|
3393
|
+
readonly retryable: boolean;
|
|
3394
|
+
readonly status?: number;
|
|
3395
|
+
}) | (Schema.SchemaError & {
|
|
3396
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3397
|
+
readonly channel?: {
|
|
3398
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3399
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3400
|
+
};
|
|
3401
|
+
readonly code: string;
|
|
3402
|
+
readonly fields?: readonly {
|
|
3403
|
+
readonly path: string;
|
|
3404
|
+
}[];
|
|
3405
|
+
readonly message: string;
|
|
3406
|
+
readonly retryAfterSeconds?: number;
|
|
3407
|
+
readonly retryable: boolean;
|
|
3408
|
+
readonly status?: number;
|
|
3409
|
+
}) | ({
|
|
3410
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3411
|
+
readonly channel?: {
|
|
3412
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3413
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3414
|
+
};
|
|
3415
|
+
readonly code: string;
|
|
3416
|
+
readonly fields?: readonly {
|
|
3417
|
+
readonly path: string;
|
|
3418
|
+
}[];
|
|
3419
|
+
readonly message: string;
|
|
3420
|
+
readonly retryAfterSeconds?: number;
|
|
3421
|
+
readonly retryable: boolean;
|
|
3422
|
+
readonly status?: number;
|
|
3423
|
+
} & ActionHandlerError) | ({
|
|
3424
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3425
|
+
readonly channel?: {
|
|
3426
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3427
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3428
|
+
};
|
|
3429
|
+
readonly code: string;
|
|
3430
|
+
readonly fields?: readonly {
|
|
3431
|
+
readonly path: string;
|
|
3432
|
+
}[];
|
|
3433
|
+
readonly message: string;
|
|
3434
|
+
readonly retryAfterSeconds?: number;
|
|
3435
|
+
readonly retryable: boolean;
|
|
3436
|
+
readonly status?: number;
|
|
3437
|
+
} & RetryableActionHandlerError);
|
|
3142
3438
|
identity: {
|
|
3143
3439
|
readonly artifactDigest: string;
|
|
3144
3440
|
readonly invocationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRuntime.d.ts","names":["_$__AgentChannel_ts0.ChannelError","DualRuntime.
|
|
1
|
+
{"version":3,"file":"PluginRuntime.d.ts","names":["DualRuntime.ActionHandlerError","DualRuntime.RetryableActionHandlerError","DualRuntime.ActionHandlerNotFoundError","DualRuntime.ActionNotFoundError","_$__AuthMethod_ts0.AuthMethodHookError","DualRuntime.AuthMethodNotFoundError","_$__AgentChannel_ts0.ChannelError","DualRuntime.ConnectionIdNotAllowedError","DualRuntime.ConnectionReauthorizationRequiredError","DualRuntime.ConnectionRequiredError","DualRuntime.ConnectionResolverStoreError","DualRuntime.ConnectionSelectionRequiredError","_$__AuthMethod_ts0.ExpectedOAuth2MethodError","DualRuntime.InvalidActionInputError","DualRuntime.InvalidActionOutputError","DualRuntime.InvalidConnectionIdError","DualRuntime.InvalidResolvedConnectionError","_$__AuthMethod_ts0.OAuth2RefreshTokenUnavailableError","DualRuntime.Service","OAuthFlow.Service"],"sources":["../src/PluginRuntime.ts"],"mappings":";;;;;;;;;;;;;;;;;qBASa,6BAA6B;qBAS7B;qBACA;;qBAEA;qBACA;;iBAGI;WACN,KAAK,eAAe,WAAW;WAC/B,iBAAiB,eAAe,WAAW;;;iBAIrC;WACN;WACA,SAAS;;;wBAIJ,YAAY,SAAS,YAAS,OAAA,gBAAA;;wBAqC9B,QAAQ,SAAS,WAAW,gBAAa,OAAA,aAAA;YAoB7C,2BAA2B,kBAAkB;qBAC5C,mBAAiB,OAAA;;;;;;YAOlB,sBAAsB,aAAa;qBAClC,cAAY,OAAA;;;;;;;;;;YAYb,6BAA6B,oBAAoB;qBAChD,qBAAmB,OAAA;;;;YAKpB,qBAAqB,YAAY;qBAChC,aAAW,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoCZ,gCAAgC,uBAAuB;qBACtD,wBAAsB,OAAA;;;;;;;;;;;;;;YASvB,0BAA0B,iBAAiB;qBAC1C,kBAAgB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,UAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjDa;;;;;;;;;WAqCE;;;;;;;;;UAgBjCkB,UAAAC"}
|
package/dist/PluginRuntime.js
CHANGED
|
@@ -292,14 +292,20 @@ const executeAuth = Effect.fnUntraced(function* (request) {
|
|
|
292
292
|
};
|
|
293
293
|
})), Effect.catch((error) => {
|
|
294
294
|
const cause = error._tag === "AuthMethodHookError" ? error.cause : error;
|
|
295
|
-
|
|
295
|
+
const failure$1 = failure(error);
|
|
296
|
+
if (Schema.is(OAuthGrantRejected)(cause) && !("_tag" in failure$1)) return Effect.succeed({
|
|
296
297
|
_tag: "failure",
|
|
297
298
|
error: {
|
|
298
|
-
...failure
|
|
299
|
-
|
|
299
|
+
...failure$1,
|
|
300
|
+
code: "OAuthGrantRejected"
|
|
300
301
|
},
|
|
301
302
|
identity: request.identity
|
|
302
303
|
});
|
|
304
|
+
return Effect.succeed({
|
|
305
|
+
_tag: "failure",
|
|
306
|
+
error: failure$1,
|
|
307
|
+
identity: request.identity
|
|
308
|
+
});
|
|
303
309
|
})));
|
|
304
310
|
const executeChannelSettings = Effect.fnUntraced(function* (request) {
|
|
305
311
|
const runtime = yield* Service;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRuntime.js","names":["RemoteRuntime.Identity","AuthMethodExecution.JsonRequest","RemoteRuntime.Request","RemoteRuntime.Response","DualRuntime.Service","OAuthFlow.Service","RemoteRuntime.failure","RemoteRuntime.execute"],"sources":["../src/PluginRuntime.ts"],"sourcesContent":["import { Cause, Effect, Queue, Redacted, Schema, Stream, pipe } from \"effect\";\n\nimport { HttpClientRequest } from \"effect/http\";\n\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport * as DualRuntime from \"./DualRuntime.ts\";\nimport { OAuthFlow, OAuthGrantRejected } from \"./OAuthFlow.ts\";\nimport { RemoteRuntime } from \"./remote-runtime.ts\";\n\nexport class PluginExecutionError extends Schema.TaggedError<PluginExecutionError>()(\n \"PluginExecutionError\",\n {\n category: Schema.Literals([\"transport\", \"runner\", \"protocol\", \"cleanup\", \"artifact-expired\"]),\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n },\n) {}\n\nexport const maxPayloadBytes = 1024 * 1024;\nexport const maxMetadataBytes = 64 * 1024 * 1024;\n/** An Agent Channel result carries a read asset of up to 14 MiB. */\nexport const maxChannelResultBytes = 16 * 1024 * 1024;\nexport const cancellationTimeout = \"5 seconds\";\n\n/** The listener half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcEvents {\n readonly on: (event: string, listener: (value: unknown) => void) => unknown;\n readonly removeListener: (event: string, listener: (value: unknown) => void) => unknown;\n}\n\n/** The sending half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcSender {\n readonly connected: boolean;\n readonly send?: ((message: object) => unknown) | undefined;\n}\n\n/** Receive native Node and Bun IPC messages without interpreting plugin logs. */\nexport function ipcMessages(channel: IpcEvents) {\n return Stream.callback<unknown, PluginExecutionError>(queue => {\n const message = (value: unknown) => {\n Queue.offerUnsafe(queue, value);\n };\n const disconnected = () => {\n Queue.endUnsafe(queue);\n };\n const failed = (cause: unknown) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Plugin IPC channel failed\",\n }),\n ),\n );\n };\n return Effect.acquireRelease(\n Effect.sync(() => {\n channel.on(\"message\", message);\n channel.on(\"disconnect\", disconnected);\n channel.on(\"error\", failed);\n }),\n () =>\n Effect.sync(() => {\n channel.removeListener(\"message\", message);\n channel.removeListener(\"disconnect\", disconnected);\n channel.removeListener(\"error\", failed);\n }),\n );\n });\n}\n\n/** Queue a JSON message; the runtime reports asynchronous send failures through its error event. */\nexport function sendIpc(channel: IpcSender, value: object) {\n return Effect.try({\n try: () => {\n if (!channel.connected || channel.send === undefined) {\n throw PluginExecutionError.make({\n category: \"runner\",\n message: \"Plugin IPC channel is closed\",\n });\n }\n channel.send(value);\n },\n catch: cause =>\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Cannot send plugin IPC message\",\n }),\n });\n}\n\nexport type OAuthContinuation = typeof OAuthContinuation.Type;\nexport const OAuthContinuation = Schema.Struct({\n expiresAt: Schema.DateFromString,\n pkceVerifier: Schema.NullOr(Schema.String),\n redirectUri: Schema.String,\n state: Schema.String,\n});\n\nexport type OAuthStarted = typeof OAuthStarted.Type;\nexport const OAuthStarted = Schema.Struct({\n authorizationUrl: Schema.String,\n continuation: OAuthContinuation,\n});\n\nconst oauth = {\n authMethodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n};\n\n/** The origins a Connection's credential may reach from a run sandbox, and the headers one request gets. */\nexport type SandboxAccessResult = typeof SandboxAccessResult.Type;\nexport const SandboxAccessResult = Schema.Struct({\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n origins: Schema.Array(Schema.String),\n});\n\nexport type AuthRequest = typeof AuthRequest.Type;\nexport const AuthRequest = Schema.TaggedStruct(\"auth\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.Union([\n AuthMethodExecution.JsonRequest,\n Schema.TaggedStruct(\"oauthStart\", { ...oauth, redirectUri: Schema.String }),\n Schema.TaggedStruct(\"oauthComplete\", {\n ...oauth,\n continuation: OAuthContinuation,\n query: Schema.Record(Schema.String, Schema.String),\n }),\n // Without `request`, only the origins; with it, the headers the plugin adds to that request.\n Schema.TaggedStruct(\"sandboxAccess\", {\n ...oauth,\n material: Schema.Json,\n request: Schema.optionalKey(\n Schema.Struct({\n headers: Schema.Record(Schema.String, Schema.String),\n method: Schema.Literals([\n \"GET\",\n \"POST\",\n \"PUT\",\n \"DELETE\",\n \"PATCH\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"QUERY\",\n ]),\n url: Schema.String,\n }),\n ),\n }),\n ]),\n});\n\n/** Decode an Agent Channel's settings outside any tenant, as publication validates them. */\nexport type ChannelSettingsRequest = typeof ChannelSettingsRequest.Type;\nexport const ChannelSettingsRequest = Schema.TaggedStruct(\"channelSettings\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.TaggedStruct(\"decodeChannelSettings\", {\n channelId: Schema.NonEmptyString,\n field: Schema.Literals([\"definitionSettings\", \"deploymentSettings\"]),\n value: Schema.Json,\n }),\n});\n\nexport type ExecutionRequest = typeof ExecutionRequest.Type;\nexport const ExecutionRequest = Schema.Union([\n RemoteRuntime.Request,\n AuthRequest,\n ChannelSettingsRequest,\n]);\n\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Union([\n ExecutionRequest,\n Schema.TaggedStruct(\"extract\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Input = typeof Input.Type;\nexport const Input = Schema.Union([\n Request,\n Schema.TaggedStruct(\"cancel\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Output = typeof Output.Type;\nexport const Output = Schema.Union([\n RemoteRuntime.Response,\n Schema.TaggedStruct(\"interrupted\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport function checkMessageSize(value: unknown, maximum: number) {\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength <= maximum) return Effect.void;\n return Effect.fail(\n PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin message exceeds its transport limit\",\n }),\n );\n}\n\nexport const encodeInput = Effect.fnUntraced(function* (input: Input) {\n const encoded = yield* Schema.encodeEffect(Input)(input);\n yield* checkMessageSize(encoded, maxPayloadBytes);\n return encoded;\n});\n\nexport const decodeInput = Effect.fnUntraced(function* (input: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(input);\n yield* checkMessageSize(json, maxPayloadBytes);\n return yield* Schema.decodeUnknownEffect(Input)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (output: Output, maximum: number) {\n const encoded = yield* Schema.encodeEffect(Output)(output);\n yield* checkMessageSize(encoded, maximum);\n return encoded;\n});\n\nexport const decodeOutput = Effect.fnUntraced(function* (output: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(output);\n yield* checkMessageSize(json, maxMetadataBytes);\n return yield* Schema.decodeUnknownEffect(Output)(json);\n});\n\nexport function responseLimit(request: Request) {\n if (\"_tag\" in request && request._tag === \"extract\") return maxMetadataBytes;\n if (\"context\" in request && request.operation._tag === \"channelExecute\") {\n return maxChannelResultBytes;\n }\n return maxPayloadBytes;\n}\n\nexport type Invocation = typeof Invocation.Type;\nexport const Invocation = Schema.Struct({\n entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),\n exportName: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u)),\n request: Request,\n});\n\nexport const encodeRequest = Effect.fnUntraced(function* (request: Request) {\n const encoded = yield* pipe(\n Schema.encodeEffect(Schema.fromJsonString(Request))(request),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Invalid plugin request\",\n }),\n ),\n );\n if (new TextEncoder().encode(encoded).byteLength > maxPayloadBytes) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin request exceeds the 1 MiB transport limit\",\n });\n }\n return encoded;\n});\n\nexport const readBounded = Effect.fnUntraced(function* <E, R>(\n input: Stream.Stream<Uint8Array, E, R>,\n maximum = maxPayloadBytes,\n) {\n const output = { bytes: Buffer.alloc(maximum), size: 0 };\n yield* pipe(\n input,\n Stream.runForEach(chunk =>\n Effect.gen(function* () {\n if (output.size + chunk.byteLength > maximum) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin payload exceeds its transport limit\",\n });\n }\n Buffer.from(chunk).copy(output.bytes, output.size);\n output.size += chunk.byteLength;\n }),\n ),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Cannot read plugin payload\",\n }),\n ),\n );\n return output.bytes.toString(\"utf8\", 0, output.size);\n});\n\nexport const verifyResponse = Effect.fnUntraced(function* <Response extends Output>(\n request: Request,\n response: Response,\n) {\n if (\n response.identity.invocationId !== request.identity.invocationId ||\n response.identity.artifactDigest !== request.identity.artifactDigest ||\n response.identity.organizationId !== request.identity.organizationId ||\n response.identity.pluginKey !== request.identity.pluginKey ||\n response.identity.pluginVersion !== request.identity.pluginVersion\n ) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin result does not match its invocation\",\n });\n }\n return response;\n});\n\nconst executeAuth = Effect.fnUntraced(\n function* (request: AuthRequest) {\n const operation = request.operation;\n const runtime = yield* DualRuntime.Service;\n if (operation._tag === \"sandboxAccess\") {\n const access = yield* runtime.resolveSandboxAccess({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n if (operation.request === undefined) {\n return yield* Schema.encodeEffect(SandboxAccessResult)({ origins: access.origins });\n }\n const authorized = yield* access.authorize(\n HttpClientRequest.make(operation.request.method)(operation.request.url, {\n headers: operation.request.headers,\n }),\n );\n return yield* Schema.encodeEffect(SandboxAccessResult)({\n headers: authorized.headers,\n origins: access.origins,\n });\n }\n if (operation._tag !== \"oauthStart\" && operation._tag !== \"oauthComplete\") {\n return yield* runtime.executeAuthJson(operation);\n }\n const method = yield* runtime.getAuthMethod(operation);\n const setup = yield* runtime.decodeAuthMethodSetup({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n const oauth = yield* OAuthFlow.Service;\n if (operation._tag === \"oauthStart\") {\n return yield* Schema.encodeEffect(OAuthStarted)(\n yield* oauth.start({ method, redirectUri: operation.redirectUri, setup }),\n );\n }\n const completed = yield* oauth.complete({ ...operation, method, setup });\n return yield* runtime.executeAuthJson(\n yield* Schema.decodeUnknownEffect(AuthMethodExecution.JsonRequest)({\n ...operation,\n _tag: \"prepareOAuth2Tokens\",\n tokens: completed.tokens,\n }),\n );\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n const result = { _tag: \"success\" as const, identity: request.identity };\n if (value === undefined) return result;\n return { ...result, value: yield* Schema.decodeUnknownEffect(Schema.Json)(value) };\n }),\n ),\n Effect.catch(error => {\n const cause = error._tag === \"AuthMethodHookError\" ? error.cause : error;\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: {\n ...RemoteRuntime.failure(error),\n ...(Schema.is(OAuthGrantRejected)(cause) ? { code: \"OAuthGrantRejected\" } : {}),\n },\n identity: request.identity,\n });\n }),\n ),\n);\n\nconst executeChannelSettings = Effect.fnUntraced(\n function* (request: ChannelSettingsRequest) {\n const runtime = yield* DualRuntime.Service;\n const { channelId, field, value } = request.operation;\n const input = { channelId, value };\n if (field === \"definitionSettings\") {\n return yield* runtime.decodeAgentChannelDefinitionSettings(input);\n }\n return yield* runtime.decodeAgentChannelDeploymentSettings(input);\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.map(value => ({ _tag: \"success\", identity: request.identity, value }) as const),\n Effect.catch(error =>\n Effect.succeed({\n _tag: \"failure\" as const,\n error: RemoteRuntime.failure(error),\n identity: request.identity,\n }),\n ),\n ),\n);\n\n/** Execute one request against the plugin built in this process; only the guest runner calls it in production. */\nexport const execute = Effect.fnUntraced(function* (request: ExecutionRequest) {\n if (!(\"_tag\" in request)) return yield* RemoteRuntime.execute(request);\n if (request._tag === \"auth\") return yield* executeAuth(request);\n return yield* executeChannelSettings(request);\n});\n\nexport * as PluginRuntime from \"./PluginRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO,SAAS;EAAC;EAAa;EAAU;EAAY;EAAW;CAAkB,CAAC;CAC5F,OAAO,OAAO,YAAY,OAAO,SAAS,OAAO,OAAO,CAAC,CAAC;CAC1D,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;;AAEhC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;;AAenC,SAAgB,YAAY,SAAoB;CAC9C,OAAO,OAAO,UAAwC,UAAS;EAC7D,MAAM,WAAW,UAAmB;GAClC,MAAM,YAAY,OAAO,KAAK;EAChC;EACA,MAAM,qBAAqB;GACzB,MAAM,UAAU,KAAK;EACvB;EACA,MAAM,UAAU,UAAmB;GACjC,MAAM,gBACJ,OACA,MAAM,KACJ,qBAAqB,KAAK;IACxB,UAAU;IACV,OAAO,SAAS,KAAK,KAAK;IAC1B,SAAS;GACX,CAAC,CACH,CACF;EACF;EACA,OAAO,OAAO,eACZ,OAAO,WAAW;GAChB,QAAQ,GAAG,WAAW,OAAO;GAC7B,QAAQ,GAAG,cAAc,YAAY;GACrC,QAAQ,GAAG,SAAS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AO,QAAQ;EACpB,MAAM;EACN,OAAO;GACL,GAAGK,QAAsB,KAAK;GAC9B,GAAI,OAAO,GAAG,kBAAkB,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,qBAAqB,IAAI,CAAC;EAC/E;EACA,UAAU,QAAQ;CACpB,CAAC;AACH,CAAC,CACH,CACJ;AAEA,MAAM,yBAAyB,OAAO,WACpC,WAAW,SAAiC;CAC1C,MAAM,UAAU,OAAOF;CACvB,MAAM,EAAE,WAAW,OAAO,UAAU,QAAQ;CAC5C,MAAM,QAAQ;EAAE;EAAW;CAAM;CACjC,IAAI,UAAU,sBACZ,OAAO,OAAO,QAAQ,qCAAqC,KAAK;CAElE,OAAO,OAAO,QAAQ,qCAAqC,KAAK;AAClE,IACC,QAAQ,YACP,KACE,QACA,OAAO,KAAI,WAAU;CAAE,MAAM;CAAW,UAAU,QAAQ;CAAU;AAAM,EAAW,GACrF,OAAO,OAAM,UACX,OAAO,QAAQ;CACb,MAAM;CACN,OAAOE,QAAsB,KAAK;CAClC,UAAU,QAAQ;AACpB,CAAC,CACH,CACF,CACJ;;AAGA,MAAa,UAAU,OAAO,WAAW,WAAW,SAA2B;CAC7E,IAAI,EAAE,UAAU,UAAU,OAAO,OAAOC,UAAsB,OAAO;CACrE,IAAI,QAAQ,SAAS,QAAQ,OAAO,OAAO,YAAY,OAAO;CAC9D,OAAO,OAAO,uBAAuB,OAAO;AAC9C,CAAC"}
|
|
1
|
+
{"version":3,"file":"PluginRuntime.js","names":["RemoteRuntime.Identity","AuthMethodExecution.JsonRequest","RemoteRuntime.Request","RemoteRuntime.Response","DualRuntime.Service","OAuthFlow.Service","failure","RemoteRuntime.failure","RemoteRuntime.execute"],"sources":["../src/PluginRuntime.ts"],"sourcesContent":["import { Cause, Effect, Queue, Redacted, Schema, Stream, pipe } from \"effect\";\n\nimport { HttpClientRequest } from \"effect/http\";\n\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport * as DualRuntime from \"./DualRuntime.ts\";\nimport { OAuthFlow, OAuthGrantRejected } from \"./OAuthFlow.ts\";\nimport { RemoteRuntime } from \"./remote-runtime.ts\";\n\nexport class PluginExecutionError extends Schema.TaggedError<PluginExecutionError>()(\n \"PluginExecutionError\",\n {\n category: Schema.Literals([\"transport\", \"runner\", \"protocol\", \"cleanup\", \"artifact-expired\"]),\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n },\n) {}\n\nexport const maxPayloadBytes = 1024 * 1024;\nexport const maxMetadataBytes = 64 * 1024 * 1024;\n/** An Agent Channel result carries a read asset of up to 14 MiB. */\nexport const maxChannelResultBytes = 16 * 1024 * 1024;\nexport const cancellationTimeout = \"5 seconds\";\n\n/** The listener half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcEvents {\n readonly on: (event: string, listener: (value: unknown) => void) => unknown;\n readonly removeListener: (event: string, listener: (value: unknown) => void) => unknown;\n}\n\n/** The sending half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcSender {\n readonly connected: boolean;\n readonly send?: ((message: object) => unknown) | undefined;\n}\n\n/** Receive native Node and Bun IPC messages without interpreting plugin logs. */\nexport function ipcMessages(channel: IpcEvents) {\n return Stream.callback<unknown, PluginExecutionError>(queue => {\n const message = (value: unknown) => {\n Queue.offerUnsafe(queue, value);\n };\n const disconnected = () => {\n Queue.endUnsafe(queue);\n };\n const failed = (cause: unknown) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Plugin IPC channel failed\",\n }),\n ),\n );\n };\n return Effect.acquireRelease(\n Effect.sync(() => {\n channel.on(\"message\", message);\n channel.on(\"disconnect\", disconnected);\n channel.on(\"error\", failed);\n }),\n () =>\n Effect.sync(() => {\n channel.removeListener(\"message\", message);\n channel.removeListener(\"disconnect\", disconnected);\n channel.removeListener(\"error\", failed);\n }),\n );\n });\n}\n\n/** Queue a JSON message; the runtime reports asynchronous send failures through its error event. */\nexport function sendIpc(channel: IpcSender, value: object) {\n return Effect.try({\n try: () => {\n if (!channel.connected || channel.send === undefined) {\n throw PluginExecutionError.make({\n category: \"runner\",\n message: \"Plugin IPC channel is closed\",\n });\n }\n channel.send(value);\n },\n catch: cause =>\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Cannot send plugin IPC message\",\n }),\n });\n}\n\nexport type OAuthContinuation = typeof OAuthContinuation.Type;\nexport const OAuthContinuation = Schema.Struct({\n expiresAt: Schema.DateFromString,\n pkceVerifier: Schema.NullOr(Schema.String),\n redirectUri: Schema.String,\n state: Schema.String,\n});\n\nexport type OAuthStarted = typeof OAuthStarted.Type;\nexport const OAuthStarted = Schema.Struct({\n authorizationUrl: Schema.String,\n continuation: OAuthContinuation,\n});\n\nconst oauth = {\n authMethodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n};\n\n/** The origins a Connection's credential may reach from a run sandbox, and the headers one request gets. */\nexport type SandboxAccessResult = typeof SandboxAccessResult.Type;\nexport const SandboxAccessResult = Schema.Struct({\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n origins: Schema.Array(Schema.String),\n});\n\nexport type AuthRequest = typeof AuthRequest.Type;\nexport const AuthRequest = Schema.TaggedStruct(\"auth\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.Union([\n AuthMethodExecution.JsonRequest,\n Schema.TaggedStruct(\"oauthStart\", { ...oauth, redirectUri: Schema.String }),\n Schema.TaggedStruct(\"oauthComplete\", {\n ...oauth,\n continuation: OAuthContinuation,\n query: Schema.Record(Schema.String, Schema.String),\n }),\n // Without `request`, only the origins; with it, the headers the plugin adds to that request.\n Schema.TaggedStruct(\"sandboxAccess\", {\n ...oauth,\n material: Schema.Json,\n request: Schema.optionalKey(\n Schema.Struct({\n headers: Schema.Record(Schema.String, Schema.String),\n method: Schema.Literals([\n \"GET\",\n \"POST\",\n \"PUT\",\n \"DELETE\",\n \"PATCH\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"QUERY\",\n ]),\n url: Schema.String,\n }),\n ),\n }),\n ]),\n});\n\n/** Decode an Agent Channel's settings outside any tenant, as publication validates them. */\nexport type ChannelSettingsRequest = typeof ChannelSettingsRequest.Type;\nexport const ChannelSettingsRequest = Schema.TaggedStruct(\"channelSettings\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.TaggedStruct(\"decodeChannelSettings\", {\n channelId: Schema.NonEmptyString,\n field: Schema.Literals([\"definitionSettings\", \"deploymentSettings\"]),\n value: Schema.Json,\n }),\n});\n\nexport type ExecutionRequest = typeof ExecutionRequest.Type;\nexport const ExecutionRequest = Schema.Union([\n RemoteRuntime.Request,\n AuthRequest,\n ChannelSettingsRequest,\n]);\n\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Union([\n ExecutionRequest,\n Schema.TaggedStruct(\"extract\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Input = typeof Input.Type;\nexport const Input = Schema.Union([\n Request,\n Schema.TaggedStruct(\"cancel\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Output = typeof Output.Type;\nexport const Output = Schema.Union([\n RemoteRuntime.Response,\n Schema.TaggedStruct(\"interrupted\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport function checkMessageSize(value: unknown, maximum: number) {\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength <= maximum) return Effect.void;\n return Effect.fail(\n PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin message exceeds its transport limit\",\n }),\n );\n}\n\nexport const encodeInput = Effect.fnUntraced(function* (input: Input) {\n const encoded = yield* Schema.encodeEffect(Input)(input);\n yield* checkMessageSize(encoded, maxPayloadBytes);\n return encoded;\n});\n\nexport const decodeInput = Effect.fnUntraced(function* (input: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(input);\n yield* checkMessageSize(json, maxPayloadBytes);\n return yield* Schema.decodeUnknownEffect(Input)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (output: Output, maximum: number) {\n const encoded = yield* Schema.encodeEffect(Output)(output);\n yield* checkMessageSize(encoded, maximum);\n return encoded;\n});\n\nexport const decodeOutput = Effect.fnUntraced(function* (output: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(output);\n yield* checkMessageSize(json, maxMetadataBytes);\n return yield* Schema.decodeUnknownEffect(Output)(json);\n});\n\nexport function responseLimit(request: Request) {\n if (\"_tag\" in request && request._tag === \"extract\") return maxMetadataBytes;\n if (\"context\" in request && request.operation._tag === \"channelExecute\") {\n return maxChannelResultBytes;\n }\n return maxPayloadBytes;\n}\n\nexport type Invocation = typeof Invocation.Type;\nexport const Invocation = Schema.Struct({\n entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),\n exportName: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u)),\n request: Request,\n});\n\nexport const encodeRequest = Effect.fnUntraced(function* (request: Request) {\n const encoded = yield* pipe(\n Schema.encodeEffect(Schema.fromJsonString(Request))(request),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Invalid plugin request\",\n }),\n ),\n );\n if (new TextEncoder().encode(encoded).byteLength > maxPayloadBytes) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin request exceeds the 1 MiB transport limit\",\n });\n }\n return encoded;\n});\n\nexport const readBounded = Effect.fnUntraced(function* <E, R>(\n input: Stream.Stream<Uint8Array, E, R>,\n maximum = maxPayloadBytes,\n) {\n const output = { bytes: Buffer.alloc(maximum), size: 0 };\n yield* pipe(\n input,\n Stream.runForEach(chunk =>\n Effect.gen(function* () {\n if (output.size + chunk.byteLength > maximum) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin payload exceeds its transport limit\",\n });\n }\n Buffer.from(chunk).copy(output.bytes, output.size);\n output.size += chunk.byteLength;\n }),\n ),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Cannot read plugin payload\",\n }),\n ),\n );\n return output.bytes.toString(\"utf8\", 0, output.size);\n});\n\nexport const verifyResponse = Effect.fnUntraced(function* <Response extends Output>(\n request: Request,\n response: Response,\n) {\n if (\n response.identity.invocationId !== request.identity.invocationId ||\n response.identity.artifactDigest !== request.identity.artifactDigest ||\n response.identity.organizationId !== request.identity.organizationId ||\n response.identity.pluginKey !== request.identity.pluginKey ||\n response.identity.pluginVersion !== request.identity.pluginVersion\n ) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin result does not match its invocation\",\n });\n }\n return response;\n});\n\nconst executeAuth = Effect.fnUntraced(\n function* (request: AuthRequest) {\n const operation = request.operation;\n const runtime = yield* DualRuntime.Service;\n if (operation._tag === \"sandboxAccess\") {\n const access = yield* runtime.resolveSandboxAccess({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n if (operation.request === undefined) {\n return yield* Schema.encodeEffect(SandboxAccessResult)({ origins: access.origins });\n }\n const authorized = yield* access.authorize(\n HttpClientRequest.make(operation.request.method)(operation.request.url, {\n headers: operation.request.headers,\n }),\n );\n return yield* Schema.encodeEffect(SandboxAccessResult)({\n headers: authorized.headers,\n origins: access.origins,\n });\n }\n if (operation._tag !== \"oauthStart\" && operation._tag !== \"oauthComplete\") {\n return yield* runtime.executeAuthJson(operation);\n }\n const method = yield* runtime.getAuthMethod(operation);\n const setup = yield* runtime.decodeAuthMethodSetup({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n const oauth = yield* OAuthFlow.Service;\n if (operation._tag === \"oauthStart\") {\n return yield* Schema.encodeEffect(OAuthStarted)(\n yield* oauth.start({ method, redirectUri: operation.redirectUri, setup }),\n );\n }\n const completed = yield* oauth.complete({ ...operation, method, setup });\n return yield* runtime.executeAuthJson(\n yield* Schema.decodeUnknownEffect(AuthMethodExecution.JsonRequest)({\n ...operation,\n _tag: \"prepareOAuth2Tokens\",\n tokens: completed.tokens,\n }),\n );\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n const result = { _tag: \"success\" as const, identity: request.identity };\n if (value === undefined) return result;\n return { ...result, value: yield* Schema.decodeUnknownEffect(Schema.Json)(value) };\n }),\n ),\n Effect.catch(error => {\n const cause = error._tag === \"AuthMethodHookError\" ? error.cause : error;\n const failure = RemoteRuntime.failure(error);\n if (Schema.is(OAuthGrantRejected)(cause) && !(\"_tag\" in failure)) {\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: { ...failure, code: \"OAuthGrantRejected\" },\n identity: request.identity,\n });\n }\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: failure,\n identity: request.identity,\n });\n }),\n ),\n);\n\nconst executeChannelSettings = Effect.fnUntraced(\n function* (request: ChannelSettingsRequest) {\n const runtime = yield* DualRuntime.Service;\n const { channelId, field, value } = request.operation;\n const input = { channelId, value };\n if (field === \"definitionSettings\") {\n return yield* runtime.decodeAgentChannelDefinitionSettings(input);\n }\n return yield* runtime.decodeAgentChannelDeploymentSettings(input);\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.map(value => ({ _tag: \"success\", identity: request.identity, value }) as const),\n Effect.catch(error =>\n Effect.succeed({\n _tag: \"failure\" as const,\n error: RemoteRuntime.failure(error),\n identity: request.identity,\n }),\n ),\n ),\n);\n\n/** Execute one request against the plugin built in this process; only the guest runner calls it in production. */\nexport const execute = Effect.fnUntraced(function* (request: ExecutionRequest) {\n if (!(\"_tag\" in request)) return yield* RemoteRuntime.execute(request);\n if (request._tag === \"auth\") return yield* executeAuth(request);\n return yield* executeChannelSettings(request);\n});\n\nexport * as PluginRuntime from \"./PluginRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,C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AqC,KAAK;CAElE,OAAO,OAAO,QAAQ,qCAAqC,KAAK;AAClE,IACC,QAAQ,YACP,KACE,QACA,OAAO,KAAI,WAAU;CAAE,MAAM;CAAW,UAAU,QAAQ;CAAU;AAAM,EAAW,GACrF,OAAO,OAAM,UACX,OAAO,QAAQ;CACb,MAAM;CACN,OAAOG,QAAsB,KAAK;CAClC,UAAU,QAAQ;AACpB,CAAC,CACH,CACF,CACJ;;AAGA,MAAa,UAAU,OAAO,WAAW,WAAW,SAA2B;CAC7E,IAAI,EAAE,UAAU,UAAU,OAAO,OAAOC,UAAsB,OAAO;CACrE,IAAI,QAAQ,SAAS,QAAQ,OAAO,OAAO,YAAY,OAAO;CAC9D,OAAO,OAAO,uBAAuB,OAAO;AAC9C,CAAC"}
|
package/dist/remote-runtime.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { AuthMethodHookError, ExpectedOAuth2MethodError, OAuth2RefreshTokenUnavailableError } from "./AuthMethod.js";
|
|
2
|
+
import { ActionHandlerError, RetryableActionHandlerError } from "./Action.js";
|
|
1
3
|
import { ChannelError } from "./AgentChannel.js";
|
|
2
|
-
import { Service } from "./ConnectionResolver.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolverStoreError, ConnectionSelectionRequiredError, InvalidConnectionIdError, InvalidResolvedConnectionError, Service } from "./ConnectionResolver.js";
|
|
5
|
+
import { ActionHandlerNotFoundError, ActionNotFoundError, InvalidActionInputError, InvalidActionOutputError } from "./internal/dual/invoke.js";
|
|
6
|
+
import { AuthMethodNotFoundError, Service as Service$1 } from "./DualRuntime.js";
|
|
5
7
|
import { Service as Service$2 } from "./Files.js";
|
|
6
8
|
import "./remote-runtime.js";
|
|
7
9
|
import { Effect, Layer, Schema } from "effect";
|
|
@@ -276,7 +278,7 @@ export declare const Request: Schema.Struct<{
|
|
|
276
278
|
}>]>]>;
|
|
277
279
|
}>;
|
|
278
280
|
export type Failure = typeof Failure.Type;
|
|
279
|
-
export declare const Failure: Schema.Struct<{
|
|
281
|
+
export declare const Failure: Schema.Union<readonly [typeof ActionHandlerError, typeof RetryableActionHandlerError, Schema.Struct<{
|
|
280
282
|
readonly category: Schema.Literals<readonly ["validation", "connection", "handler", "initialization", "protocol"]>;
|
|
281
283
|
/** The Agent Channel failure the host rebuilds as its `ChannelError`. */
|
|
282
284
|
readonly channel: Schema.optionalKey<Schema.Struct<{
|
|
@@ -292,7 +294,7 @@ export declare const Failure: Schema.Struct<{
|
|
|
292
294
|
readonly retryable: Schema.Boolean;
|
|
293
295
|
/** The provider's HTTP status, kept so the host can report why a provider rejected the call. */
|
|
294
296
|
readonly status: Schema.optionalKey<Schema.Int>;
|
|
295
|
-
}>;
|
|
297
|
+
}>]>;
|
|
296
298
|
export type Response = typeof Response.Type;
|
|
297
299
|
export declare const Response: Schema.Union<readonly [Schema.TaggedStruct<"success", {
|
|
298
300
|
readonly identity: Schema.Struct<{
|
|
@@ -304,7 +306,7 @@ export declare const Response: Schema.Union<readonly [Schema.TaggedStruct<"succe
|
|
|
304
306
|
}>;
|
|
305
307
|
readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
306
308
|
}>, Schema.TaggedStruct<"failure", {
|
|
307
|
-
readonly error: Schema.Struct<{
|
|
309
|
+
readonly error: Schema.Union<readonly [typeof ActionHandlerError, typeof RetryableActionHandlerError, Schema.Struct<{
|
|
308
310
|
readonly category: Schema.Literals<readonly ["validation", "connection", "handler", "initialization", "protocol"]>;
|
|
309
311
|
/** The Agent Channel failure the host rebuilds as its `ChannelError`. */
|
|
310
312
|
readonly channel: Schema.optionalKey<Schema.Struct<{
|
|
@@ -320,7 +322,7 @@ export declare const Response: Schema.Union<readonly [Schema.TaggedStruct<"succe
|
|
|
320
322
|
readonly retryable: Schema.Boolean;
|
|
321
323
|
/** The provider's HTTP status, kept so the host can report why a provider rejected the call. */
|
|
322
324
|
readonly status: Schema.optionalKey<Schema.Int>;
|
|
323
|
-
}>;
|
|
325
|
+
}>]>;
|
|
324
326
|
readonly identity: Schema.Struct<{
|
|
325
327
|
readonly artifactDigest: Schema.String;
|
|
326
328
|
readonly invocationId: Schema.NonEmptyString;
|
|
@@ -528,7 +530,7 @@ export declare const execute: (request: {
|
|
|
528
530
|
value: Schema.Json;
|
|
529
531
|
} | {
|
|
530
532
|
_tag: "failure";
|
|
531
|
-
error:
|
|
533
|
+
error: ActionHandlerError | RetryableActionHandlerError | {
|
|
532
534
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
533
535
|
readonly channel?: {
|
|
534
536
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -542,7 +544,7 @@ export declare const execute: (request: {
|
|
|
542
544
|
readonly retryAfterSeconds?: number;
|
|
543
545
|
readonly retryable: boolean;
|
|
544
546
|
readonly status?: number;
|
|
545
|
-
} |
|
|
547
|
+
} | (ActionHandlerError & {
|
|
546
548
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
547
549
|
readonly channel?: {
|
|
548
550
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -556,7 +558,287 @@ export declare const execute: (request: {
|
|
|
556
558
|
readonly retryAfterSeconds?: number;
|
|
557
559
|
readonly retryable: boolean;
|
|
558
560
|
readonly status?: number;
|
|
559
|
-
}
|
|
561
|
+
}) | (ActionHandlerNotFoundError & {
|
|
562
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
563
|
+
readonly channel?: {
|
|
564
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
565
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
566
|
+
};
|
|
567
|
+
readonly code: string;
|
|
568
|
+
readonly fields?: readonly {
|
|
569
|
+
readonly path: string;
|
|
570
|
+
}[];
|
|
571
|
+
readonly message: string;
|
|
572
|
+
readonly retryAfterSeconds?: number;
|
|
573
|
+
readonly retryable: boolean;
|
|
574
|
+
readonly status?: number;
|
|
575
|
+
}) | (ActionNotFoundError & {
|
|
576
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
577
|
+
readonly channel?: {
|
|
578
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
579
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
580
|
+
};
|
|
581
|
+
readonly code: string;
|
|
582
|
+
readonly fields?: readonly {
|
|
583
|
+
readonly path: string;
|
|
584
|
+
}[];
|
|
585
|
+
readonly message: string;
|
|
586
|
+
readonly retryAfterSeconds?: number;
|
|
587
|
+
readonly retryable: boolean;
|
|
588
|
+
readonly status?: number;
|
|
589
|
+
}) | (AuthMethodHookError & {
|
|
590
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
591
|
+
readonly channel?: {
|
|
592
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
593
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
594
|
+
};
|
|
595
|
+
readonly code: string;
|
|
596
|
+
readonly fields?: readonly {
|
|
597
|
+
readonly path: string;
|
|
598
|
+
}[];
|
|
599
|
+
readonly message: string;
|
|
600
|
+
readonly retryAfterSeconds?: number;
|
|
601
|
+
readonly retryable: boolean;
|
|
602
|
+
readonly status?: number;
|
|
603
|
+
}) | (AuthMethodNotFoundError & {
|
|
604
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
605
|
+
readonly channel?: {
|
|
606
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
607
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
608
|
+
};
|
|
609
|
+
readonly code: string;
|
|
610
|
+
readonly fields?: readonly {
|
|
611
|
+
readonly path: string;
|
|
612
|
+
}[];
|
|
613
|
+
readonly message: string;
|
|
614
|
+
readonly retryAfterSeconds?: number;
|
|
615
|
+
readonly retryable: boolean;
|
|
616
|
+
readonly status?: number;
|
|
617
|
+
}) | (ChannelError & {
|
|
618
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
619
|
+
readonly channel?: {
|
|
620
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
621
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
622
|
+
};
|
|
623
|
+
readonly code: string;
|
|
624
|
+
readonly fields?: readonly {
|
|
625
|
+
readonly path: string;
|
|
626
|
+
}[];
|
|
627
|
+
readonly message: string;
|
|
628
|
+
readonly retryAfterSeconds?: number;
|
|
629
|
+
readonly retryable: boolean;
|
|
630
|
+
readonly status?: number;
|
|
631
|
+
}) | (ConnectionIdNotAllowedError & {
|
|
632
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
633
|
+
readonly channel?: {
|
|
634
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
635
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
636
|
+
};
|
|
637
|
+
readonly code: string;
|
|
638
|
+
readonly fields?: readonly {
|
|
639
|
+
readonly path: string;
|
|
640
|
+
}[];
|
|
641
|
+
readonly message: string;
|
|
642
|
+
readonly retryAfterSeconds?: number;
|
|
643
|
+
readonly retryable: boolean;
|
|
644
|
+
readonly status?: number;
|
|
645
|
+
}) | (ConnectionReauthorizationRequiredError & {
|
|
646
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
647
|
+
readonly channel?: {
|
|
648
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
649
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
650
|
+
};
|
|
651
|
+
readonly code: string;
|
|
652
|
+
readonly fields?: readonly {
|
|
653
|
+
readonly path: string;
|
|
654
|
+
}[];
|
|
655
|
+
readonly message: string;
|
|
656
|
+
readonly retryAfterSeconds?: number;
|
|
657
|
+
readonly retryable: boolean;
|
|
658
|
+
readonly status?: number;
|
|
659
|
+
}) | (ConnectionRequiredError & {
|
|
660
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
661
|
+
readonly channel?: {
|
|
662
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
663
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
664
|
+
};
|
|
665
|
+
readonly code: string;
|
|
666
|
+
readonly fields?: readonly {
|
|
667
|
+
readonly path: string;
|
|
668
|
+
}[];
|
|
669
|
+
readonly message: string;
|
|
670
|
+
readonly retryAfterSeconds?: number;
|
|
671
|
+
readonly retryable: boolean;
|
|
672
|
+
readonly status?: number;
|
|
673
|
+
}) | (ConnectionResolverStoreError & {
|
|
674
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
675
|
+
readonly channel?: {
|
|
676
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
677
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
678
|
+
};
|
|
679
|
+
readonly code: string;
|
|
680
|
+
readonly fields?: readonly {
|
|
681
|
+
readonly path: string;
|
|
682
|
+
}[];
|
|
683
|
+
readonly message: string;
|
|
684
|
+
readonly retryAfterSeconds?: number;
|
|
685
|
+
readonly retryable: boolean;
|
|
686
|
+
readonly status?: number;
|
|
687
|
+
}) | (ConnectionSelectionRequiredError & {
|
|
688
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
689
|
+
readonly channel?: {
|
|
690
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
691
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
692
|
+
};
|
|
693
|
+
readonly code: string;
|
|
694
|
+
readonly fields?: readonly {
|
|
695
|
+
readonly path: string;
|
|
696
|
+
}[];
|
|
697
|
+
readonly message: string;
|
|
698
|
+
readonly retryAfterSeconds?: number;
|
|
699
|
+
readonly retryable: boolean;
|
|
700
|
+
readonly status?: number;
|
|
701
|
+
}) | (ExpectedOAuth2MethodError & {
|
|
702
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
703
|
+
readonly channel?: {
|
|
704
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
705
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
706
|
+
};
|
|
707
|
+
readonly code: string;
|
|
708
|
+
readonly fields?: readonly {
|
|
709
|
+
readonly path: string;
|
|
710
|
+
}[];
|
|
711
|
+
readonly message: string;
|
|
712
|
+
readonly retryAfterSeconds?: number;
|
|
713
|
+
readonly retryable: boolean;
|
|
714
|
+
readonly status?: number;
|
|
715
|
+
}) | (InvalidActionInputError & {
|
|
716
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
717
|
+
readonly channel?: {
|
|
718
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
719
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
720
|
+
};
|
|
721
|
+
readonly code: string;
|
|
722
|
+
readonly fields?: readonly {
|
|
723
|
+
readonly path: string;
|
|
724
|
+
}[];
|
|
725
|
+
readonly message: string;
|
|
726
|
+
readonly retryAfterSeconds?: number;
|
|
727
|
+
readonly retryable: boolean;
|
|
728
|
+
readonly status?: number;
|
|
729
|
+
}) | (InvalidActionOutputError & {
|
|
730
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
731
|
+
readonly channel?: {
|
|
732
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
733
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
734
|
+
};
|
|
735
|
+
readonly code: string;
|
|
736
|
+
readonly fields?: readonly {
|
|
737
|
+
readonly path: string;
|
|
738
|
+
}[];
|
|
739
|
+
readonly message: string;
|
|
740
|
+
readonly retryAfterSeconds?: number;
|
|
741
|
+
readonly retryable: boolean;
|
|
742
|
+
readonly status?: number;
|
|
743
|
+
}) | (InvalidConnectionIdError & {
|
|
744
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
745
|
+
readonly channel?: {
|
|
746
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
747
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
748
|
+
};
|
|
749
|
+
readonly code: string;
|
|
750
|
+
readonly fields?: readonly {
|
|
751
|
+
readonly path: string;
|
|
752
|
+
}[];
|
|
753
|
+
readonly message: string;
|
|
754
|
+
readonly retryAfterSeconds?: number;
|
|
755
|
+
readonly retryable: boolean;
|
|
756
|
+
readonly status?: number;
|
|
757
|
+
}) | (InvalidResolvedConnectionError & {
|
|
758
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
759
|
+
readonly channel?: {
|
|
760
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
761
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
762
|
+
};
|
|
763
|
+
readonly code: string;
|
|
764
|
+
readonly fields?: readonly {
|
|
765
|
+
readonly path: string;
|
|
766
|
+
}[];
|
|
767
|
+
readonly message: string;
|
|
768
|
+
readonly retryAfterSeconds?: number;
|
|
769
|
+
readonly retryable: boolean;
|
|
770
|
+
readonly status?: number;
|
|
771
|
+
}) | (OAuth2RefreshTokenUnavailableError & {
|
|
772
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
773
|
+
readonly channel?: {
|
|
774
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
775
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
776
|
+
};
|
|
777
|
+
readonly code: string;
|
|
778
|
+
readonly fields?: readonly {
|
|
779
|
+
readonly path: string;
|
|
780
|
+
}[];
|
|
781
|
+
readonly message: string;
|
|
782
|
+
readonly retryAfterSeconds?: number;
|
|
783
|
+
readonly retryable: boolean;
|
|
784
|
+
readonly status?: number;
|
|
785
|
+
}) | (RetryableActionHandlerError & {
|
|
786
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
787
|
+
readonly channel?: {
|
|
788
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
789
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
790
|
+
};
|
|
791
|
+
readonly code: string;
|
|
792
|
+
readonly fields?: readonly {
|
|
793
|
+
readonly path: string;
|
|
794
|
+
}[];
|
|
795
|
+
readonly message: string;
|
|
796
|
+
readonly retryAfterSeconds?: number;
|
|
797
|
+
readonly retryable: boolean;
|
|
798
|
+
readonly status?: number;
|
|
799
|
+
}) | (Schema.SchemaError & {
|
|
800
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
801
|
+
readonly channel?: {
|
|
802
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
803
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
804
|
+
};
|
|
805
|
+
readonly code: string;
|
|
806
|
+
readonly fields?: readonly {
|
|
807
|
+
readonly path: string;
|
|
808
|
+
}[];
|
|
809
|
+
readonly message: string;
|
|
810
|
+
readonly retryAfterSeconds?: number;
|
|
811
|
+
readonly retryable: boolean;
|
|
812
|
+
readonly status?: number;
|
|
813
|
+
}) | ({
|
|
814
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
815
|
+
readonly channel?: {
|
|
816
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
817
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
818
|
+
};
|
|
819
|
+
readonly code: string;
|
|
820
|
+
readonly fields?: readonly {
|
|
821
|
+
readonly path: string;
|
|
822
|
+
}[];
|
|
823
|
+
readonly message: string;
|
|
824
|
+
readonly retryAfterSeconds?: number;
|
|
825
|
+
readonly retryable: boolean;
|
|
826
|
+
readonly status?: number;
|
|
827
|
+
} & ActionHandlerError) | ({
|
|
828
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
829
|
+
readonly channel?: {
|
|
830
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
831
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
832
|
+
};
|
|
833
|
+
readonly code: string;
|
|
834
|
+
readonly fields?: readonly {
|
|
835
|
+
readonly path: string;
|
|
836
|
+
}[];
|
|
837
|
+
readonly message: string;
|
|
838
|
+
readonly retryAfterSeconds?: number;
|
|
839
|
+
readonly retryable: boolean;
|
|
840
|
+
readonly status?: number;
|
|
841
|
+
} & RetryableActionHandlerError);
|
|
560
842
|
identity: {
|
|
561
843
|
readonly artifactDigest: string;
|
|
562
844
|
readonly invocationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-runtime.d.ts","names":["Files.Service","ConnectionResolver.Service","AgentChannel.ChannelError","DualRuntime.
|
|
1
|
+
{"version":3,"file":"remote-runtime.d.ts","names":["Files.Service","ConnectionResolver.Service","DualRuntime.ActionHandlerNotFoundError","DualRuntime.ActionNotFoundError","_$__AuthMethod_ts0.AuthMethodHookError","DualRuntime.AuthMethodNotFoundError","AgentChannel.ChannelError","ConnectionResolver.ConnectionIdNotAllowedError","ConnectionResolver.ConnectionReauthorizationRequiredError","ConnectionResolver.ConnectionRequiredError","ConnectionResolver.ConnectionResolverStoreError","ConnectionResolver.ConnectionSelectionRequiredError","_$__AuthMethod_ts0.ExpectedOAuth2MethodError","DualRuntime.InvalidActionInputError","DualRuntime.InvalidActionOutputError","ConnectionResolver.InvalidConnectionIdError","ConnectionResolver.InvalidResolvedConnectionError","_$__AuthMethod_ts0.OAuth2RefreshTokenUnavailableError","DualRuntime.Service"],"sources":["../src/remote-runtime.ts"],"mappings":";;;;;;;;;;;;YA6BY,kBAAkB,SAAS;qBAC1B,UAAQ,OAAA;;;;;;;YAoDT,mBAAmB,UAAU;qBAC5B,WAAS,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAeV,oBAAoB,WAAW;qBAC9B,YAAU,OAAA;;;;YACX,iBAAiB,QAAQ;qBACxB,SAAO,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAyBR,iBAAiB,QAAQ;qBACxB,SAAO,OAAA,uBAAA,2BAAA,6BAAA,OAAA;;;;;;;;;;;;;;;;;YAKR,kBAAkB,SAAS;qBAC1B,UAAQ,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAML,QAAQ,iBAAiB;qBAqG5B,kBAAgB,MAAA,MAAAA;wBA2Eb,gBAAgB,SAAS,UAAO,MAAA,MAAAC;;qBAiFnC,UAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2DlBiB"}
|
package/dist/remote-runtime.js
CHANGED
|
@@ -117,7 +117,7 @@ const Request = Schema.Struct({
|
|
|
117
117
|
identity: Identity,
|
|
118
118
|
operation: Operation
|
|
119
119
|
});
|
|
120
|
-
const
|
|
120
|
+
const RuntimeFailure = Schema.Struct({
|
|
121
121
|
category: Schema.Literals([
|
|
122
122
|
"validation",
|
|
123
123
|
"connection",
|
|
@@ -138,6 +138,11 @@ const Failure = Schema.Struct({
|
|
|
138
138
|
/** The provider's HTTP status, kept so the host can report why a provider rejected the call. */
|
|
139
139
|
status: Schema.optionalKey(Schema.Int)
|
|
140
140
|
});
|
|
141
|
+
const Failure = Schema.Union([
|
|
142
|
+
ActionHandlerError,
|
|
143
|
+
RetryableActionHandlerError,
|
|
144
|
+
RuntimeFailure
|
|
145
|
+
]);
|
|
141
146
|
const Response = Schema.Union([Schema.TaggedStruct("success", {
|
|
142
147
|
identity: Identity,
|
|
143
148
|
value: Schema.optionalKey(Schema.Json)
|
|
@@ -146,6 +151,7 @@ const Response = Schema.Union([Schema.TaggedStruct("success", {
|
|
|
146
151
|
identity: Identity
|
|
147
152
|
})]);
|
|
148
153
|
function failure(error) {
|
|
154
|
+
if (Schema.is(ActionHandlerError)(error) || Schema.is(RetryableActionHandlerError)(error)) return error;
|
|
149
155
|
if (Schema.is(ChannelError)(error)) return {
|
|
150
156
|
category: "handler",
|
|
151
157
|
channel: Option.match(Option.fromUndefinedOr(error.providerCode), {
|
|
@@ -159,7 +165,7 @@ function failure(error) {
|
|
|
159
165
|
message: "Agent Channel operation failed",
|
|
160
166
|
retryable: false
|
|
161
167
|
};
|
|
162
|
-
if (Schema.is(FileError)(error)
|
|
168
|
+
if (Schema.is(FileError)(error)) return {
|
|
163
169
|
category: "handler",
|
|
164
170
|
code: "FileError",
|
|
165
171
|
message: "A Dual Files operation failed",
|
|
@@ -172,16 +178,6 @@ function failure(error) {
|
|
|
172
178
|
message: "Plugin action validation failed",
|
|
173
179
|
retryable: false
|
|
174
180
|
};
|
|
175
|
-
if (Schema.is(RetryableActionHandlerError)(error)) return {
|
|
176
|
-
category: "handler",
|
|
177
|
-
code: error._tag,
|
|
178
|
-
message: "Plugin handler failed",
|
|
179
|
-
retryable: true,
|
|
180
|
-
...Option.match(Option.fromUndefinedOr(error.retryAfterSeconds), {
|
|
181
|
-
onNone: () => ({}),
|
|
182
|
-
onSome: (seconds) => ({ retryAfterSeconds: seconds })
|
|
183
|
-
})
|
|
184
|
-
};
|
|
185
181
|
const tag = Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag) ? error._tag : "PluginHandlerError";
|
|
186
182
|
return {
|
|
187
183
|
category: pipe(Match.value(tag), Match.when("SchemaError", () => "validation"), Match.whenOr("InvalidTriggerConfigError", "InvalidTriggerStateError", "InvalidTriggerOutputError", () => "validation"), Match.whenOr("ConnectionRequiredError", "InvalidConnectionIdError", "InvalidResolvedConnectionError", "ConnectionIdNotAllowedError", "AuthMethodNotFoundError", "AuthMethodHookError", "ExpectedOAuth2MethodError", "OAuth2RefreshTokenUnavailableError", () => "connection"), Match.orElse(() => "handler")),
|
|
@@ -200,7 +196,6 @@ function failure(error) {
|
|
|
200
196
|
"OAuth2RefreshTokenUnavailableError",
|
|
201
197
|
"ActionNotFoundError",
|
|
202
198
|
"ActionHandlerNotFoundError",
|
|
203
|
-
"ActionHandlerError",
|
|
204
199
|
"TriggerNotFoundError",
|
|
205
200
|
"UnsupportedTriggerRuntimeError",
|
|
206
201
|
"FileError",
|
|
@@ -208,8 +203,7 @@ function failure(error) {
|
|
|
208
203
|
"SandboxRequestNotAllowedError"
|
|
209
204
|
], tag) ? tag : "PluginHandlerError",
|
|
210
205
|
message: "Plugin operation failed",
|
|
211
|
-
retryable: false
|
|
212
|
-
...Schema.is(ActionHandlerError)(error) && Schema.is(Schema.Int)(error.status) ? { status: error.status } : {}
|
|
206
|
+
retryable: false
|
|
213
207
|
};
|
|
214
208
|
}
|
|
215
209
|
const unavailableFiles = Service$2.of({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-runtime.js","names":["AgentChannel.VerifiedIdentity","AuthMethodExecution.JsonRequest","AgentChannel.ErrorCode","AgentChannel.FailureCode","AgentChannel.ChannelError","Files.FileError","DualRuntime.InvalidActionInputError","DualRuntime.InvalidActionOutputError","Files.Service","Files.File","ConnectionResolver.Service","DualRuntime.Service"],"sources":["../src/remote-runtime.ts"],"sourcesContent":["/**\n * Data-only SDK lifecycle requests for an installed, isolated integration plugin.\n *\n * @since 0.3.0\n */\nimport {\n Array,\n Cause,\n Effect,\n Layer,\n Match,\n Option,\n Predicate,\n Redacted,\n Schema,\n flow,\n pipe,\n} from \"effect\";\n\nimport { HttpClient, HttpClientRequest } from \"effect/http\";\nimport type { HttpClientResponse } from \"effect/http\";\n\nimport { ActionHandlerError, RetryableActionHandlerError } from \"./Action.ts\";\nimport * as AgentChannel from \"./AgentChannel.ts\";\nimport { AuthMethodExecution } from \"./AuthMethodExecution.ts\";\nimport { ConnectionResolver } from \"./ConnectionResolver.ts\";\nimport { DualRuntime } from \"./DualRuntime.ts\";\nimport { Files } from \"./Files.ts\";\n\nexport type Identity = typeof Identity.Type;\nexport const Identity = Schema.Struct({\n artifactDigest: Schema.String.check(Schema.isPattern(/^[a-f0-9]{128}$/u)),\n invocationId: Schema.NonEmptyString,\n organizationId: Schema.NonEmptyString,\n pluginKey: Schema.NonEmptyString,\n pluginVersion: Schema.NonEmptyString,\n});\n\nconst connection = Schema.Struct({\n connectionId: Schema.NonEmptyString,\n material: Schema.Json,\n methodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n});\nconst context = Schema.Struct({\n actor: Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"user\"), userId: Schema.NonEmptyString }),\n Schema.Struct({ kind: Schema.Literal(\"system\"), reason: Schema.optionalKey(Schema.String) }),\n ]),\n metadata: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),\n source: Schema.Struct({\n kind: Schema.NonEmptyString,\n metadata: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),\n subjectId: Schema.optionalKey(Schema.String),\n }),\n tenant: Schema.Struct({ organizationId: Schema.NonEmptyString, teamId: Schema.NonEmptyString }),\n});\nconst trigger = {\n config: Schema.Json,\n state: Schema.optionalKey(Schema.Json),\n triggerId: Schema.NonEmptyString,\n};\nconst webhook = { ...trigger, webhookUrl: Schema.String };\nconst channel = {\n channelId: Schema.NonEmptyString,\n definitionSettings: Schema.Json,\n deploymentSettings: Schema.Json,\n};\nconst delivery = {\n ...webhook,\n request: Schema.Struct({\n body: Schema.Json,\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n method: Schema.optionalKey(Schema.String),\n query: Schema.optionalKey(\n Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Array(Schema.String)])),\n ),\n rawBody: Schema.Uint8ArrayFromBase64,\n url: Schema.optionalKey(Schema.String),\n }),\n};\nexport type Operation = typeof Operation.Type;\nexport const Operation = Schema.Union([\n Schema.TaggedStruct(\"invoke\", { actionId: Schema.NonEmptyString, input: Schema.Json }),\n Schema.TaggedStruct(\"activate\", webhook),\n Schema.TaggedStruct(\"deactivate\", webhook),\n Schema.TaggedStruct(\"verify\", delivery),\n Schema.TaggedStruct(\"parse\", delivery),\n Schema.TaggedStruct(\"poll\", trigger),\n Schema.TaggedStruct(\"channelCheckAccess\", {\n ...channel,\n identity: AgentChannel.VerifiedIdentity,\n }),\n Schema.TaggedStruct(\"channelExecute\", { ...channel, command: Schema.Json }),\n AuthMethodExecution.JsonRequest,\n]);\n/** Where this call reads and stores the caller's files, and the token that lets it. */\nexport type FileAccess = typeof FileAccess.Type;\nexport const FileAccess = Schema.Struct({ token: Schema.NonEmptyString, url: Schema.String });\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Struct({\n connection: Schema.optionalKey(connection),\n context,\n files: Schema.optionalKey(FileAccess),\n identity: Identity,\n operation: Operation,\n});\n\nexport type Failure = typeof Failure.Type;\nexport const Failure = Schema.Struct({\n category: Schema.Literals([\"validation\", \"connection\", \"handler\", \"initialization\", \"protocol\"]),\n /** The Agent Channel failure the host rebuilds as its `ChannelError`. */\n channel: Schema.optionalKey(\n Schema.Struct({\n code: AgentChannel.ErrorCode,\n providerCode: Schema.optionalKey(AgentChannel.FailureCode),\n }),\n ),\n code: Schema.String,\n fields: Schema.optionalKey(Schema.Array(Schema.Struct({ path: Schema.String }))),\n message: Schema.String,\n retryAfterSeconds: Schema.optionalKey(Schema.Finite),\n retryable: Schema.Boolean,\n /** The provider's HTTP status, kept so the host can report why a provider rejected the call. */\n status: Schema.optionalKey(Schema.Int),\n});\nexport type Response = typeof Response.Type;\nexport const Response = Schema.Union([\n Schema.TaggedStruct(\"success\", { identity: Identity, value: Schema.optionalKey(Schema.Json) }),\n Schema.TaggedStruct(\"failure\", { error: Failure, identity: Identity }),\n]);\n\n// Plugin causes and schema descriptions can contain credentials or submitted input.\nexport function failure(error: unknown): Failure {\n if (Schema.is(AgentChannel.ChannelError)(error)) {\n return {\n category: \"handler\",\n channel: Option.match(Option.fromUndefinedOr(error.providerCode), {\n onNone: () => ({ code: error.code }),\n onSome: providerCode => ({ code: error.code, providerCode }),\n }),\n code: error._tag,\n message: \"Agent Channel operation failed\",\n retryable: false,\n };\n }\n if (\n Schema.is(Files.FileError)(error) ||\n (Schema.is(ActionHandlerError)(error) && Schema.is(Files.FileError)(error.cause))\n ) {\n return {\n category: \"handler\",\n code: \"FileError\",\n message: \"A Dual Files operation failed\",\n retryable: false,\n };\n }\n if (\n Schema.is(DualRuntime.InvalidActionInputError)(error) ||\n Schema.is(DualRuntime.InvalidActionOutputError)(error)\n ) {\n return {\n category: \"validation\",\n code: error._tag,\n fields: Array.map(error.fields, field => ({ path: field.path })),\n message: \"Plugin action validation failed\",\n retryable: false,\n };\n }\n if (Schema.is(RetryableActionHandlerError)(error)) {\n return {\n category: \"handler\",\n code: error._tag,\n message: \"Plugin handler failed\",\n retryable: true,\n ...Option.match(Option.fromUndefinedOr(error.retryAfterSeconds), {\n onNone: () => ({}),\n onSome: seconds => ({ retryAfterSeconds: seconds }),\n }),\n };\n }\n const tag =\n Predicate.hasProperty(error, \"_tag\") && Predicate.isString(error._tag)\n ? error._tag\n : \"PluginHandlerError\";\n const category = pipe(\n Match.value(tag),\n Match.when(\"SchemaError\", () => \"validation\" as const),\n Match.whenOr(\n \"InvalidTriggerConfigError\",\n \"InvalidTriggerStateError\",\n \"InvalidTriggerOutputError\",\n () => \"validation\" as const,\n ),\n Match.whenOr(\n \"ConnectionRequiredError\",\n \"InvalidConnectionIdError\",\n \"InvalidResolvedConnectionError\",\n \"ConnectionIdNotAllowedError\",\n \"AuthMethodNotFoundError\",\n \"AuthMethodHookError\",\n \"ExpectedOAuth2MethodError\",\n \"OAuth2RefreshTokenUnavailableError\",\n () => \"connection\" as const,\n ),\n Match.orElse(() => \"handler\" as const),\n );\n return {\n category,\n code: Array.contains(\n [\n \"SchemaError\",\n \"InvalidTriggerConfigError\",\n \"InvalidTriggerStateError\",\n \"InvalidTriggerOutputError\",\n \"ConnectionRequiredError\",\n \"InvalidConnectionIdError\",\n \"InvalidResolvedConnectionError\",\n \"ConnectionIdNotAllowedError\",\n \"AuthMethodNotFoundError\",\n \"AuthMethodHookError\",\n \"ExpectedOAuth2MethodError\",\n \"OAuth2RefreshTokenUnavailableError\",\n \"ActionNotFoundError\",\n \"ActionHandlerNotFoundError\",\n \"ActionHandlerError\",\n \"TriggerNotFoundError\",\n \"UnsupportedTriggerRuntimeError\",\n \"FileError\",\n \"SandboxAccessNotDeclaredError\",\n \"SandboxRequestNotAllowedError\",\n ],\n tag,\n )\n ? tag\n : \"PluginHandlerError\",\n message: \"Plugin operation failed\",\n retryable: false,\n ...(Schema.is(ActionHandlerError)(error) && Schema.is(Schema.Int)(error.status)\n ? { status: error.status }\n : {}),\n };\n}\n\nconst unavailableFiles = Files.Service.of({\n read: () =>\n Effect.fail(Files.FileError.make({ message: \"Dual Files is not available to this operation\" })),\n write: () =>\n Effect.fail(Files.FileError.make({ message: \"Dual Files is not available to this operation\" })),\n});\nexport const filesUnavailable = Layer.succeed(Files.Service, unavailableFiles);\n\nconst FileFailure = Schema.Struct({ message: Schema.String });\n\n// The host's file routes do the reading and storing, as the caller the token names.\nfunction filesService(access: FileAccess, http: HttpClient.HttpClient) {\n const client = HttpClient.mapRequest(\n http,\n flow(\n HttpClientRequest.prependUrl(`${access.url}/api/plugin-files`),\n HttpClientRequest.bearerToken(access.token),\n ),\n );\n function call<A>(\n request: HttpClientRequest.HttpClientRequest,\n read: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, unknown>,\n ) {\n return pipe(\n Effect.gen(function* () {\n const response = yield* client.execute(request);\n if (response.status < 200 || response.status >= 300) {\n return yield* Files.FileError.make(\n yield* Schema.decodeUnknownEffect(FileFailure)(yield* response.json),\n );\n }\n return yield* read(response);\n }),\n Effect.mapError(cause =>\n Schema.is(Files.FileError)(cause)\n ? cause\n : Files.FileError.make({\n cause: Redacted.make(cause),\n message: \"Cannot reach Dual Files\",\n }),\n ),\n );\n }\n return Files.Service.of({\n read: file =>\n call(HttpClientRequest.get(`/${encodeURIComponent(file.id)}`), response =>\n Effect.map(response.arrayBuffer, buffer => new Uint8Array(buffer)),\n ),\n write: file =>\n call(\n pipe(\n HttpClientRequest.post(\"\", { urlParams: { name: file.name } }),\n HttpClientRequest.bodyUint8Array(file.bytes, file.contentType ?? undefined),\n ),\n response => Effect.flatMap(response.json, Schema.decodeUnknownEffect(Files.File)),\n ),\n });\n}\n\nfunction connectionService(request: Request) {\n return ConnectionResolver.Service.of({\n resolve: input => {\n const selected = request.connection;\n if (selected === undefined) {\n return Effect.fail(ConnectionResolver.ConnectionRequiredError.make(input.target));\n }\n if (\n selected.providerId !== input.target.providerId ||\n (input.connectionId !== undefined && input.connectionId !== selected.connectionId)\n ) {\n return Effect.fail(\n ConnectionResolver.InvalidConnectionIdError.make({\n ...input.target,\n connectionId: input.connectionId ?? selected.connectionId,\n }),\n );\n }\n return Effect.succeed({ ...selected, encoding: \"json\" as const, setup: selected.setup });\n },\n });\n}\nexport function connectionLayer(request: Request) {\n return Layer.succeed(ConnectionResolver.Service, connectionService(request));\n}\n\nconst run = Effect.fnUntraced(\n function* (request: Request) {\n const runtime = yield* DualRuntime.Service;\n const connectionId = Option.match(Option.fromUndefinedOr(request.connection), {\n onNone: () => ({}),\n onSome: selected => ({ connectionId: selected.connectionId }),\n });\n const target = {\n ...connectionId,\n context: request.context,\n pluginKey: request.identity.pluginKey,\n };\n const operation = request.operation;\n if (operation._tag === \"invoke\") {\n return yield* runtime.invokeJson({ ...operation, ...target });\n }\n if (operation._tag === \"poll\") {\n const result = yield* flow(\n runtime.pollTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { events: result.events, meta: result.meta };\n return result;\n }\n if (operation._tag === \"activate\") {\n const result = yield* flow(\n runtime.activateTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { meta: result.meta };\n return result;\n }\n if (operation._tag === \"deactivate\") {\n return yield* flow(\n runtime.deactivateTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n }\n if (operation._tag === \"verify\") {\n return yield* flow(\n runtime.verifyTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n }\n if (operation._tag === \"parse\") {\n const result = yield* flow(\n runtime.parseTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { events: result.events, meta: result.meta };\n return result;\n }\n if (operation._tag === \"channelCheckAccess\") {\n return yield* runtime.checkAccessAgentChannel({\n channelId: operation.channelId,\n definitionSettings: operation.definitionSettings,\n deploymentSettings: operation.deploymentSettings,\n identity: operation.identity,\n ...connectionId,\n });\n }\n if (operation._tag === \"channelExecute\") {\n return yield* runtime.executeAgentChannel({\n channelId: operation.channelId,\n command: operation.command,\n definitionSettings: operation.definitionSettings,\n deploymentSettings: operation.deploymentSettings,\n ...connectionId,\n });\n }\n\n return yield* runtime.executeAuthJson(operation);\n },\n Effect.mapError(error => (Schema.is(Failure)(error) ? error : failure(error))),\n);\n\n/** Execute only in the guest after importing and building its installed plugin. */\nexport const execute = Effect.fn(\"RemoteRuntime.execute\")(function* (request: Request) {\n // The guest runner supplies its fetch client; a host calling in-process has no file routes to reach.\n const http = yield* Effect.serviceOption(HttpClient.HttpClient);\n if (request.identity.organizationId !== request.context.tenant.organizationId) {\n return {\n _tag: \"failure\",\n error: {\n category: \"protocol\",\n code: \"OrganizationMismatch\",\n message: \"Invocation organization does not match its context\",\n retryable: false,\n },\n identity: request.identity,\n } satisfies Response;\n }\n return yield* pipe(\n run(request),\n Effect.provideService(ConnectionResolver.Service, connectionService(request)),\n Effect.provideService(\n Files.Service,\n pipe(\n Option.fromUndefinedOr(request.files),\n Option.flatMap(access => Option.map(http, client => filesService(access, client))),\n Option.getOrElse(() => unavailableFiles),\n ),\n ),\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n if (value === undefined) {\n return { _tag: \"success\", identity: request.identity } satisfies Response;\n }\n return {\n _tag: \"success\",\n identity: request.identity,\n value: yield* pipe(\n Schema.decodeUnknownEffect(Schema.Json)(value),\n Effect.mapError(failure),\n ),\n } satisfies Response;\n }),\n ),\n Effect.catch(error =>\n Effect.succeed({ _tag: \"failure\", error, identity: request.identity } satisfies Response),\n ),\n Effect.catchCauseIf(\n cause => !Cause.hasInterrupts(cause),\n () =>\n Effect.succeed({\n _tag: \"failure\",\n error: {\n category: \"handler\",\n code: \"PluginDefect\",\n message: \"Plugin operation failed\",\n retryable: false,\n },\n identity: request.identity,\n } satisfies Response),\n ),\n );\n});\n\nexport * as RemoteRuntime from \"./remote-runtime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,WAAW,OAAO,OAAO;CACpC,gBAAgB,OAAO,OAAO,MAAM,OAAO,UAAU,kBAAkB,CAAC;CACxE,cAAc,OAAO;CACrB,gBAAgB,OAAO;CACvB,WAAW,OAAO;CAClB,eAAe,OAAO;AACxB,CAAC;AAED,MAAM,aAAa,OAAO,OAAO;CAC/B,cAAc,OAAO;CACrB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB,OAAO,OAAO,YAAY,OAAO,IAAI;AACvC,CAAC;AACD,MAAM,UAAU,OAAO,OAAO;CAC5B,OAAO,OAAO,MAAM,CAClB,OAAO,OAAO;EAAE,MAAM,OAAO,QAAQ,MAAM;EAAG,QAAQ,OAAO;CAAe,CAAC,GAC7E,OAAO,OAAO;EAAE,MAAM,OAAO,QAAQ,QAAQ;EAAG,QAAQ,OAAO,YAAY,OAAO,MAAM;CAAE,CAAC,CAC7F,CAAC;CACD,UAAU,OAAO,YAAY,OAAO,OAAO,OAAO,QAAQ,OAAO,IAAI,CAAC;CACtE,QAAQ,OAAO,OAAO;EACpB,MAAM,OAAO;EACb,UAAU,OAAO,YAAY,OAAO,OAAO,OAAO,QA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,uBAAuB,CAAC,CAAC,WAAW,SAAkB;CAErF,MAAM,OAAO,OAAO,OAAO,cAAc,WAAW,UAAU;CAC9D,IAAI,QAAQ,SAAS,mBAAmB,QAAQ,QAAQ,OAAO,gBAC7D,OAAO;EACL,MAAM;EACN,OAAO;GACL,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;EACb;EACA,UAAU,QAAQ;CACpB;CAEF,OAAO,OAAO,KACZ,IAAI,OAAO,GACX,OAAO,eAAeD,SAA4B,kBAAkB,OAAO,CAAC,GAC5E,OAAO,eACLF,WACA,KACE,OAAO,gBAAgB,QAAQ,KAAK,GACpC,OAAO,SAAQ,WAAU,OAAO,IAAI,OAAM,WAAU,aAAa,QAAQ,MAAM,CAAC,CAAC,GACjF,OAAO,gBAAgB,gBAAgB,CACzC,CACF,GACA,OAAO,QACL,OAAO,WAAW,WAAW,OAAO;EAClC,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE,MAAM;GAAW,UAAU,QAAQ;EAAS;EAEvD,OAAO;GACL,MAAM;GACN,UAAU,QAAQ;GAClB,OAAO,OAAO,KACZ,OAAO,oBAAoB,OAAO,IAAI,CAAC,CAAC,KAAK,GAC7C,OAAO,SAAS,OAAO,CACzB;EACF;CACF,CAAC,CACH,GACA,OAAO,OAAM,UACX,OAAO,QAAQ;EAAE,MAAM;EAAW;EAAO,UAAU,QAAQ;CAAS,CAAoB,CAC1F,GACA,OAAO,cACL,UAAS,CAAC,MAAM,cAAc,KAAK,SAEjC,OAAO,QAAQ;EACb,MAAM;EACN,OAAO;GACL,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;EACb;EACA,UAAU,QAAQ;CACpB,CAAoB,CACxB,CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"remote-runtime.js","names":["AgentChannel.VerifiedIdentity","AuthMethodExecution.JsonRequest","AgentChannel.ErrorCode","AgentChannel.FailureCode","AgentChannel.ChannelError","Files.FileError","DualRuntime.InvalidActionInputError","DualRuntime.InvalidActionOutputError","Files.Service","Files.File","ConnectionResolver.Service","DualRuntime.Service"],"sources":["../src/remote-runtime.ts"],"sourcesContent":["/**\n * Data-only SDK lifecycle requests for an installed, isolated integration plugin.\n *\n * @since 0.3.0\n */\nimport {\n Array,\n Cause,\n Effect,\n Layer,\n Match,\n Option,\n Predicate,\n Redacted,\n Schema,\n flow,\n pipe,\n} from \"effect\";\n\nimport { HttpClient, HttpClientRequest } from \"effect/http\";\nimport type { HttpClientResponse } from \"effect/http\";\n\nimport { ActionHandlerError, RetryableActionHandlerError } from \"./Action.ts\";\nimport * as AgentChannel from \"./AgentChannel.ts\";\nimport { AuthMethodExecution } from \"./AuthMethodExecution.ts\";\nimport { ConnectionResolver } from \"./ConnectionResolver.ts\";\nimport { DualRuntime } from \"./DualRuntime.ts\";\nimport { Files } from \"./Files.ts\";\n\nexport type Identity = typeof Identity.Type;\nexport const Identity = Schema.Struct({\n artifactDigest: Schema.String.check(Schema.isPattern(/^[a-f0-9]{128}$/u)),\n invocationId: Schema.NonEmptyString,\n organizationId: Schema.NonEmptyString,\n pluginKey: Schema.NonEmptyString,\n pluginVersion: Schema.NonEmptyString,\n});\n\nconst connection = Schema.Struct({\n connectionId: Schema.NonEmptyString,\n material: Schema.Json,\n methodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n});\nconst context = Schema.Struct({\n actor: Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"user\"), userId: Schema.NonEmptyString }),\n Schema.Struct({ kind: Schema.Literal(\"system\"), reason: Schema.optionalKey(Schema.String) }),\n ]),\n metadata: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),\n source: Schema.Struct({\n kind: Schema.NonEmptyString,\n metadata: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),\n subjectId: Schema.optionalKey(Schema.String),\n }),\n tenant: Schema.Struct({ organizationId: Schema.NonEmptyString, teamId: Schema.NonEmptyString }),\n});\nconst trigger = {\n config: Schema.Json,\n state: Schema.optionalKey(Schema.Json),\n triggerId: Schema.NonEmptyString,\n};\nconst webhook = { ...trigger, webhookUrl: Schema.String };\nconst channel = {\n channelId: Schema.NonEmptyString,\n definitionSettings: Schema.Json,\n deploymentSettings: Schema.Json,\n};\nconst delivery = {\n ...webhook,\n request: Schema.Struct({\n body: Schema.Json,\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n method: Schema.optionalKey(Schema.String),\n query: Schema.optionalKey(\n Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Array(Schema.String)])),\n ),\n rawBody: Schema.Uint8ArrayFromBase64,\n url: Schema.optionalKey(Schema.String),\n }),\n};\nexport type Operation = typeof Operation.Type;\nexport const Operation = Schema.Union([\n Schema.TaggedStruct(\"invoke\", { actionId: Schema.NonEmptyString, input: Schema.Json }),\n Schema.TaggedStruct(\"activate\", webhook),\n Schema.TaggedStruct(\"deactivate\", webhook),\n Schema.TaggedStruct(\"verify\", delivery),\n Schema.TaggedStruct(\"parse\", delivery),\n Schema.TaggedStruct(\"poll\", trigger),\n Schema.TaggedStruct(\"channelCheckAccess\", {\n ...channel,\n identity: AgentChannel.VerifiedIdentity,\n }),\n Schema.TaggedStruct(\"channelExecute\", { ...channel, command: Schema.Json }),\n AuthMethodExecution.JsonRequest,\n]);\n/** Where this call reads and stores the caller's files, and the token that lets it. */\nexport type FileAccess = typeof FileAccess.Type;\nexport const FileAccess = Schema.Struct({ token: Schema.NonEmptyString, url: Schema.String });\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Struct({\n connection: Schema.optionalKey(connection),\n context,\n files: Schema.optionalKey(FileAccess),\n identity: Identity,\n operation: Operation,\n});\n\nconst RuntimeFailure = Schema.Struct({\n category: Schema.Literals([\"validation\", \"connection\", \"handler\", \"initialization\", \"protocol\"]),\n /** The Agent Channel failure the host rebuilds as its `ChannelError`. */\n channel: Schema.optionalKey(\n Schema.Struct({\n code: AgentChannel.ErrorCode,\n providerCode: Schema.optionalKey(AgentChannel.FailureCode),\n }),\n ),\n code: Schema.String,\n fields: Schema.optionalKey(Schema.Array(Schema.Struct({ path: Schema.String }))),\n message: Schema.String,\n retryAfterSeconds: Schema.optionalKey(Schema.Finite),\n retryable: Schema.Boolean,\n /** The provider's HTTP status, kept so the host can report why a provider rejected the call. */\n status: Schema.optionalKey(Schema.Int),\n});\nexport type Failure = typeof Failure.Type;\nexport const Failure = Schema.Union([\n ActionHandlerError,\n RetryableActionHandlerError,\n RuntimeFailure,\n]);\nexport type Response = typeof Response.Type;\nexport const Response = Schema.Union([\n Schema.TaggedStruct(\"success\", { identity: Identity, value: Schema.optionalKey(Schema.Json) }),\n Schema.TaggedStruct(\"failure\", { error: Failure, identity: Identity }),\n]);\n\n// Declared Action failures reach the host intact; the host owns public error filtering.\nexport function failure(error: unknown): Failure {\n if (Schema.is(ActionHandlerError)(error) || Schema.is(RetryableActionHandlerError)(error)) {\n return error;\n }\n if (Schema.is(AgentChannel.ChannelError)(error)) {\n return {\n category: \"handler\",\n channel: Option.match(Option.fromUndefinedOr(error.providerCode), {\n onNone: () => ({ code: error.code }),\n onSome: providerCode => ({ code: error.code, providerCode }),\n }),\n code: error._tag,\n message: \"Agent Channel operation failed\",\n retryable: false,\n };\n }\n if (Schema.is(Files.FileError)(error)) {\n return {\n category: \"handler\",\n code: \"FileError\",\n message: \"A Dual Files operation failed\",\n retryable: false,\n };\n }\n if (\n Schema.is(DualRuntime.InvalidActionInputError)(error) ||\n Schema.is(DualRuntime.InvalidActionOutputError)(error)\n ) {\n return {\n category: \"validation\",\n code: error._tag,\n fields: Array.map(error.fields, field => ({ path: field.path })),\n message: \"Plugin action validation failed\",\n retryable: false,\n };\n }\n const tag =\n Predicate.hasProperty(error, \"_tag\") && Predicate.isString(error._tag)\n ? error._tag\n : \"PluginHandlerError\";\n const category = pipe(\n Match.value(tag),\n Match.when(\"SchemaError\", () => \"validation\" as const),\n Match.whenOr(\n \"InvalidTriggerConfigError\",\n \"InvalidTriggerStateError\",\n \"InvalidTriggerOutputError\",\n () => \"validation\" as const,\n ),\n Match.whenOr(\n \"ConnectionRequiredError\",\n \"InvalidConnectionIdError\",\n \"InvalidResolvedConnectionError\",\n \"ConnectionIdNotAllowedError\",\n \"AuthMethodNotFoundError\",\n \"AuthMethodHookError\",\n \"ExpectedOAuth2MethodError\",\n \"OAuth2RefreshTokenUnavailableError\",\n () => \"connection\" as const,\n ),\n Match.orElse(() => \"handler\" as const),\n );\n return {\n category,\n code: Array.contains(\n [\n \"SchemaError\",\n \"InvalidTriggerConfigError\",\n \"InvalidTriggerStateError\",\n \"InvalidTriggerOutputError\",\n \"ConnectionRequiredError\",\n \"InvalidConnectionIdError\",\n \"InvalidResolvedConnectionError\",\n \"ConnectionIdNotAllowedError\",\n \"AuthMethodNotFoundError\",\n \"AuthMethodHookError\",\n \"ExpectedOAuth2MethodError\",\n \"OAuth2RefreshTokenUnavailableError\",\n \"ActionNotFoundError\",\n \"ActionHandlerNotFoundError\",\n \"TriggerNotFoundError\",\n \"UnsupportedTriggerRuntimeError\",\n \"FileError\",\n \"SandboxAccessNotDeclaredError\",\n \"SandboxRequestNotAllowedError\",\n ],\n tag,\n )\n ? tag\n : \"PluginHandlerError\",\n message: \"Plugin operation failed\",\n retryable: false,\n };\n}\n\nconst unavailableFiles = Files.Service.of({\n read: () =>\n Effect.fail(Files.FileError.make({ message: \"Dual Files is not available to this operation\" })),\n write: () =>\n Effect.fail(Files.FileError.make({ message: \"Dual Files is not available to this operation\" })),\n});\nexport const filesUnavailable = Layer.succeed(Files.Service, unavailableFiles);\n\nconst FileFailure = Schema.Struct({ message: Schema.String });\n\n// The host's file routes do the reading and storing, as the caller the token names.\nfunction filesService(access: FileAccess, http: HttpClient.HttpClient) {\n const client = HttpClient.mapRequest(\n http,\n flow(\n HttpClientRequest.prependUrl(`${access.url}/api/plugin-files`),\n HttpClientRequest.bearerToken(access.token),\n ),\n );\n function call<A>(\n request: HttpClientRequest.HttpClientRequest,\n read: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, unknown>,\n ) {\n return pipe(\n Effect.gen(function* () {\n const response = yield* client.execute(request);\n if (response.status < 200 || response.status >= 300) {\n return yield* Files.FileError.make(\n yield* Schema.decodeUnknownEffect(FileFailure)(yield* response.json),\n );\n }\n return yield* read(response);\n }),\n Effect.mapError(cause =>\n Schema.is(Files.FileError)(cause)\n ? cause\n : Files.FileError.make({\n cause: Redacted.make(cause),\n message: \"Cannot reach Dual Files\",\n }),\n ),\n );\n }\n return Files.Service.of({\n read: file =>\n call(HttpClientRequest.get(`/${encodeURIComponent(file.id)}`), response =>\n Effect.map(response.arrayBuffer, buffer => new Uint8Array(buffer)),\n ),\n write: file =>\n call(\n pipe(\n HttpClientRequest.post(\"\", { urlParams: { name: file.name } }),\n HttpClientRequest.bodyUint8Array(file.bytes, file.contentType ?? undefined),\n ),\n response => Effect.flatMap(response.json, Schema.decodeUnknownEffect(Files.File)),\n ),\n });\n}\n\nfunction connectionService(request: Request) {\n return ConnectionResolver.Service.of({\n resolve: input => {\n const selected = request.connection;\n if (selected === undefined) {\n return Effect.fail(ConnectionResolver.ConnectionRequiredError.make(input.target));\n }\n if (\n selected.providerId !== input.target.providerId ||\n (input.connectionId !== undefined && input.connectionId !== selected.connectionId)\n ) {\n return Effect.fail(\n ConnectionResolver.InvalidConnectionIdError.make({\n ...input.target,\n connectionId: input.connectionId ?? selected.connectionId,\n }),\n );\n }\n return Effect.succeed({ ...selected, encoding: \"json\" as const, setup: selected.setup });\n },\n });\n}\nexport function connectionLayer(request: Request) {\n return Layer.succeed(ConnectionResolver.Service, connectionService(request));\n}\n\nconst run = Effect.fnUntraced(\n function* (request: Request) {\n const runtime = yield* DualRuntime.Service;\n const connectionId = Option.match(Option.fromUndefinedOr(request.connection), {\n onNone: () => ({}),\n onSome: selected => ({ connectionId: selected.connectionId }),\n });\n const target = {\n ...connectionId,\n context: request.context,\n pluginKey: request.identity.pluginKey,\n };\n const operation = request.operation;\n if (operation._tag === \"invoke\") {\n return yield* runtime.invokeJson({ ...operation, ...target });\n }\n if (operation._tag === \"poll\") {\n const result = yield* flow(\n runtime.pollTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { events: result.events, meta: result.meta };\n return result;\n }\n if (operation._tag === \"activate\") {\n const result = yield* flow(\n runtime.activateTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { meta: result.meta };\n return result;\n }\n if (operation._tag === \"deactivate\") {\n return yield* flow(\n runtime.deactivateTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n }\n if (operation._tag === \"verify\") {\n return yield* flow(\n runtime.verifyTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n }\n if (operation._tag === \"parse\") {\n const result = yield* flow(\n runtime.parseTrigger,\n Effect.mapError(failure),\n )({ ...operation, ...target });\n if (result.state === undefined) return { events: result.events, meta: result.meta };\n return result;\n }\n if (operation._tag === \"channelCheckAccess\") {\n return yield* runtime.checkAccessAgentChannel({\n channelId: operation.channelId,\n definitionSettings: operation.definitionSettings,\n deploymentSettings: operation.deploymentSettings,\n identity: operation.identity,\n ...connectionId,\n });\n }\n if (operation._tag === \"channelExecute\") {\n return yield* runtime.executeAgentChannel({\n channelId: operation.channelId,\n command: operation.command,\n definitionSettings: operation.definitionSettings,\n deploymentSettings: operation.deploymentSettings,\n ...connectionId,\n });\n }\n\n return yield* runtime.executeAuthJson(operation);\n },\n Effect.mapError(error => (Schema.is(Failure)(error) ? error : failure(error))),\n);\n\n/** Execute only in the guest after importing and building its installed plugin. */\nexport const execute = Effect.fn(\"RemoteRuntime.execute\")(function* (request: Request) {\n // The guest runner supplies its fetch client; a host calling in-process has no file routes to reach.\n const http = yield* Effect.serviceOption(HttpClient.HttpClient);\n if (request.identity.organizationId !== request.context.tenant.organizationId) {\n return {\n _tag: \"failure\",\n error: {\n category: \"protocol\",\n code: \"OrganizationMismatch\",\n message: \"Invocation organization does not match its context\",\n retryable: false,\n },\n identity: request.identity,\n } satisfies Response;\n }\n return yield* pipe(\n run(request),\n Effect.provideService(ConnectionResolver.Service, connectionService(request)),\n Effect.provideService(\n Files.Service,\n pipe(\n Option.fromUndefinedOr(request.files),\n Option.flatMap(access => Option.map(http, client => filesService(access, client))),\n Option.getOrElse(() => unavailableFiles),\n ),\n ),\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n if (value === undefined) {\n return { _tag: \"success\", identity: request.identity } satisfies Response;\n }\n return {\n _tag: \"success\",\n identity: request.identity,\n value: yield* pipe(\n Schema.decodeUnknownEffect(Schema.Json)(value),\n Effect.mapError(failure),\n ),\n } satisfies Response;\n }),\n ),\n Effect.catch(error =>\n Effect.succeed({ _tag: \"failure\", error, identity: request.identity } satisfies Response),\n ),\n Effect.catchCauseIf(\n cause => !Cause.hasInterrupts(cause),\n () =>\n Effect.succeed({\n _tag: \"failure\",\n error: {\n category: \"handler\",\n code: \"PluginDefect\",\n message: \"Plugin operation failed\",\n retryable: false,\n },\n identity: request.identity,\n } satisfies Response),\n ),\n );\n});\n\nexport * as RemoteRuntime from \"./remote-runtime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,WAAW,OAAO,OAAO;CACpC,gBAAgB,OAAO,OAAO,MAAM,OAAO,UAAU,kBAAkB,CAAC;CACxE,cAAc,OAAO;CACrB,gBAAgB,OAAO;CACvB,WAAW,OAAO;CAClB,eAAe,OAAO;AACxB,CAAC;AAED,MAAM,aAAa,OAAO,OAAO;CAC/B,cAAc,OAAO;CACrB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB,OAAO,OAAO,YAAY,OAAO,IAAI;AACvC,CAAC;AACD,MAAM,UAAU,OAAO,OAAO;CAC5B,OAAO,OAAO,MAAM,CAClB,OAAO,OAAO;EAAE,MAAM,OAAO,QAAQ,MAAM;EAAG,QAAQ,OAAO;CAAe,CAAC,GAC7E,OAAO,OAAO;EAAE,MAAM,OAAO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SAAS,mBAAmB,QAAQ,QAAQ,OAAO,gBAC7D,OAAO;EACL,MAAM;EACN,OAAO;GACL,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;EACb;EACA,UAAU,QAAQ;CACpB;CAEF,OAAO,OAAO,KACZ,IAAI,OAAO,GACX,OAAO,eAAeD,SAA4B,kBAAkB,OAAO,CAAC,GAC5E,OAAO,eACLF,WACA,KACE,OAAO,gBAAgB,QAAQ,KAAK,GACpC,OAAO,SAAQ,WAAU,OAAO,IAAI,OAAM,WAAU,aAAa,QAAQ,MAAM,CAAC,CAAC,GACjF,OAAO,gBAAgB,gBAAgB,CACzC,CACF,GACA,OAAO,QACL,OAAO,WAAW,WAAW,OAAO;EAClC,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE,MAAM;GAAW,UAAU,QAAQ;EAAS;EAEvD,OAAO;GACL,MAAM;GACN,UAAU,QAAQ;GAClB,OAAO,OAAO,KACZ,OAAO,oBAAoB,OAAO,IAAI,CAAC,CAAC,KAAK,GAC7C,OAAO,SAAS,OAAO,CACzB;EACF;CACF,CAAC,CACH,GACA,OAAO,OAAM,UACX,OAAO,QAAQ;EAAE,MAAM;EAAW;EAAO,UAAU,QAAQ;CAAS,CAAoB,CAC1F,GACA,OAAO,cACL,UAAS,CAAC,MAAM,cAAc,KAAK,SAEjC,OAAO,QAAQ;EACb,MAAM;EACN,OAAO;GACL,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;EACb;EACA,UAAU,QAAQ;CACpB,CAAoB,CACxB,CACF;AACF,CAAC"}
|
package/package.json
CHANGED
package/src/PluginRuntime.ts
CHANGED
|
@@ -368,12 +368,17 @@ const executeAuth = Effect.fnUntraced(
|
|
|
368
368
|
),
|
|
369
369
|
Effect.catch(error => {
|
|
370
370
|
const cause = error._tag === "AuthMethodHookError" ? error.cause : error;
|
|
371
|
+
const failure = RemoteRuntime.failure(error);
|
|
372
|
+
if (Schema.is(OAuthGrantRejected)(cause) && !("_tag" in failure)) {
|
|
373
|
+
return Effect.succeed({
|
|
374
|
+
_tag: "failure" as const,
|
|
375
|
+
error: { ...failure, code: "OAuthGrantRejected" },
|
|
376
|
+
identity: request.identity,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
371
379
|
return Effect.succeed({
|
|
372
380
|
_tag: "failure" as const,
|
|
373
|
-
error:
|
|
374
|
-
...RemoteRuntime.failure(error),
|
|
375
|
-
...(Schema.is(OAuthGrantRejected)(cause) ? { code: "OAuthGrantRejected" } : {}),
|
|
376
|
-
},
|
|
381
|
+
error: failure,
|
|
377
382
|
identity: request.identity,
|
|
378
383
|
});
|
|
379
384
|
}),
|
package/src/remote-runtime.ts
CHANGED
|
@@ -107,8 +107,7 @@ export const Request = Schema.Struct({
|
|
|
107
107
|
operation: Operation,
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
export const Failure = Schema.Struct({
|
|
110
|
+
const RuntimeFailure = Schema.Struct({
|
|
112
111
|
category: Schema.Literals(["validation", "connection", "handler", "initialization", "protocol"]),
|
|
113
112
|
/** The Agent Channel failure the host rebuilds as its `ChannelError`. */
|
|
114
113
|
channel: Schema.optionalKey(
|
|
@@ -125,14 +124,23 @@ export const Failure = Schema.Struct({
|
|
|
125
124
|
/** The provider's HTTP status, kept so the host can report why a provider rejected the call. */
|
|
126
125
|
status: Schema.optionalKey(Schema.Int),
|
|
127
126
|
});
|
|
127
|
+
export type Failure = typeof Failure.Type;
|
|
128
|
+
export const Failure = Schema.Union([
|
|
129
|
+
ActionHandlerError,
|
|
130
|
+
RetryableActionHandlerError,
|
|
131
|
+
RuntimeFailure,
|
|
132
|
+
]);
|
|
128
133
|
export type Response = typeof Response.Type;
|
|
129
134
|
export const Response = Schema.Union([
|
|
130
135
|
Schema.TaggedStruct("success", { identity: Identity, value: Schema.optionalKey(Schema.Json) }),
|
|
131
136
|
Schema.TaggedStruct("failure", { error: Failure, identity: Identity }),
|
|
132
137
|
]);
|
|
133
138
|
|
|
134
|
-
//
|
|
139
|
+
// Declared Action failures reach the host intact; the host owns public error filtering.
|
|
135
140
|
export function failure(error: unknown): Failure {
|
|
141
|
+
if (Schema.is(ActionHandlerError)(error) || Schema.is(RetryableActionHandlerError)(error)) {
|
|
142
|
+
return error;
|
|
143
|
+
}
|
|
136
144
|
if (Schema.is(AgentChannel.ChannelError)(error)) {
|
|
137
145
|
return {
|
|
138
146
|
category: "handler",
|
|
@@ -145,10 +153,7 @@ export function failure(error: unknown): Failure {
|
|
|
145
153
|
retryable: false,
|
|
146
154
|
};
|
|
147
155
|
}
|
|
148
|
-
if (
|
|
149
|
-
Schema.is(Files.FileError)(error) ||
|
|
150
|
-
(Schema.is(ActionHandlerError)(error) && Schema.is(Files.FileError)(error.cause))
|
|
151
|
-
) {
|
|
156
|
+
if (Schema.is(Files.FileError)(error)) {
|
|
152
157
|
return {
|
|
153
158
|
category: "handler",
|
|
154
159
|
code: "FileError",
|
|
@@ -168,18 +173,6 @@ export function failure(error: unknown): Failure {
|
|
|
168
173
|
retryable: false,
|
|
169
174
|
};
|
|
170
175
|
}
|
|
171
|
-
if (Schema.is(RetryableActionHandlerError)(error)) {
|
|
172
|
-
return {
|
|
173
|
-
category: "handler",
|
|
174
|
-
code: error._tag,
|
|
175
|
-
message: "Plugin handler failed",
|
|
176
|
-
retryable: true,
|
|
177
|
-
...Option.match(Option.fromUndefinedOr(error.retryAfterSeconds), {
|
|
178
|
-
onNone: () => ({}),
|
|
179
|
-
onSome: seconds => ({ retryAfterSeconds: seconds }),
|
|
180
|
-
}),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
176
|
const tag =
|
|
184
177
|
Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag)
|
|
185
178
|
? error._tag
|
|
@@ -224,7 +217,6 @@ export function failure(error: unknown): Failure {
|
|
|
224
217
|
"OAuth2RefreshTokenUnavailableError",
|
|
225
218
|
"ActionNotFoundError",
|
|
226
219
|
"ActionHandlerNotFoundError",
|
|
227
|
-
"ActionHandlerError",
|
|
228
220
|
"TriggerNotFoundError",
|
|
229
221
|
"UnsupportedTriggerRuntimeError",
|
|
230
222
|
"FileError",
|
|
@@ -237,9 +229,6 @@ export function failure(error: unknown): Failure {
|
|
|
237
229
|
: "PluginHandlerError",
|
|
238
230
|
message: "Plugin operation failed",
|
|
239
231
|
retryable: false,
|
|
240
|
-
...(Schema.is(ActionHandlerError)(error) && Schema.is(Schema.Int)(error.status)
|
|
241
|
-
? { status: error.status }
|
|
242
|
-
: {}),
|
|
243
232
|
};
|
|
244
233
|
}
|
|
245
234
|
|