@valon-technologies/gestalt 0.0.1-alpha.18 → 0.0.1-alpha.20
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/README.md +34 -12
- package/package.json +5 -3
- package/src/agent-conversions.ts +201 -0
- package/src/agent-manager.ts +272 -83
- package/src/agent.ts +1023 -224
- package/src/api.ts +42 -0
- package/src/auth.ts +3 -3
- package/src/authorization.ts +1700 -51
- package/src/cache.ts +3 -3
- package/src/catalog.ts +22 -0
- package/src/http-subject.ts +9 -2
- package/src/index.ts +191 -17
- package/src/indexeddb.ts +3 -15
- package/src/internal/gen/v1/agent_pb.ts +137 -51
- package/src/internal/gen/v1/authorization_pb.ts +505 -27
- package/src/internal/gen/v1/plugin_pb.ts +67 -21
- package/src/internal/gen/v1/pluginruntime_pb.ts +95 -6
- package/src/internal/gen/v1/workflow_pb.ts +344 -62
- package/src/invoker.ts +6 -35
- package/src/plugin.ts +12 -12
- package/src/pluginruntime.ts +337 -49
- package/src/protocol/v1.ts +19 -0
- package/src/protocol-internal.ts +19 -0
- package/src/protocol.ts +186 -0
- package/src/provider-kind.ts +7 -3
- package/src/provider.ts +21 -13
- package/src/runtime-log-host.ts +80 -52
- package/src/runtime.ts +67 -0
- package/src/s3.ts +13 -28
- package/src/secrets.ts +3 -3
- package/src/workflow-manager.ts +350 -121
- package/src/workflow.ts +2598 -389
package/src/s3.ts
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
WriteObjectResponseSchema,
|
|
29
29
|
} from "./internal/gen/v1/s3_pb.ts";
|
|
30
30
|
import { errorMessage, type MaybePromise } from "./api.ts";
|
|
31
|
-
import {
|
|
31
|
+
import { ProviderBase, type ProviderBaseOptions } from "./provider.ts";
|
|
32
|
+
import { dateFromTimestamp, timestampFromDate } from "./protocol.ts";
|
|
32
33
|
|
|
33
34
|
/** Base environment variable for discovering S3 runtime sockets. */
|
|
34
35
|
export const ENV_S3_SOCKET = "GESTALT_S3_SOCKET";
|
|
@@ -245,7 +246,7 @@ export interface ProviderReadResult {
|
|
|
245
246
|
/**
|
|
246
247
|
* Runtime hooks required to implement a Gestalt S3 provider.
|
|
247
248
|
*/
|
|
248
|
-
export interface S3ProviderOptions extends
|
|
249
|
+
export interface S3ProviderOptions extends ProviderBaseOptions {
|
|
249
250
|
headObject: (ref: ObjectRef) => MaybePromise<ObjectMeta>;
|
|
250
251
|
readObject: (ref: ObjectRef, options?: ReadOptions) => MaybePromise<ProviderReadResult>;
|
|
251
252
|
writeObject: (
|
|
@@ -269,7 +270,7 @@ export interface S3ProviderOptions extends RuntimeProviderOptions {
|
|
|
269
270
|
/**
|
|
270
271
|
* S3 provider implementation consumed by the Gestalt runtime.
|
|
271
272
|
*/
|
|
272
|
-
export class S3Provider extends
|
|
273
|
+
export class S3Provider extends ProviderBase {
|
|
273
274
|
readonly kind = "s3" as const;
|
|
274
275
|
|
|
275
276
|
private readonly headObjectHandler: S3ProviderOptions["headObject"];
|
|
@@ -517,7 +518,7 @@ export function createS3Service(
|
|
|
517
518
|
expiresAt?: { seconds: bigint; nanos: number };
|
|
518
519
|
};
|
|
519
520
|
if (result.expiresAt) {
|
|
520
|
-
response.expiresAt =
|
|
521
|
+
response.expiresAt = timestampFromDate(result.expiresAt);
|
|
521
522
|
}
|
|
522
523
|
return create(PresignObjectResponseSchema, response);
|
|
523
524
|
},
|
|
@@ -693,7 +694,7 @@ export class S3 {
|
|
|
693
694
|
headers: cloneStringMap(response.headers),
|
|
694
695
|
};
|
|
695
696
|
if (response.expiresAt) {
|
|
696
|
-
result.expiresAt =
|
|
697
|
+
result.expiresAt = dateFromTimestamp(response.expiresAt);
|
|
697
698
|
}
|
|
698
699
|
return result;
|
|
699
700
|
}
|
|
@@ -722,7 +723,7 @@ export class S3 {
|
|
|
722
723
|
headers: cloneStringMap(response.headers),
|
|
723
724
|
};
|
|
724
725
|
if (response.expiresAt) {
|
|
725
|
-
result.expiresAt =
|
|
726
|
+
result.expiresAt = dateFromTimestamp(response.expiresAt);
|
|
726
727
|
}
|
|
727
728
|
return result;
|
|
728
729
|
}
|
|
@@ -1185,7 +1186,7 @@ function toProtoObjectMeta(meta: ObjectMeta) {
|
|
|
1185
1186
|
storageClass: meta.storageClass,
|
|
1186
1187
|
};
|
|
1187
1188
|
if (meta.lastModified) {
|
|
1188
|
-
value.lastModified =
|
|
1189
|
+
value.lastModified = timestampFromDate(meta.lastModified);
|
|
1189
1190
|
}
|
|
1190
1191
|
return value;
|
|
1191
1192
|
}
|
|
@@ -1200,7 +1201,7 @@ function fromProtoObjectMeta(meta: ProtoS3ObjectMeta | undefined): ObjectMeta {
|
|
|
1200
1201
|
storageClass: meta?.storageClass ?? "",
|
|
1201
1202
|
};
|
|
1202
1203
|
if (meta?.lastModified) {
|
|
1203
|
-
value.lastModified =
|
|
1204
|
+
value.lastModified = dateFromTimestamp(meta.lastModified);
|
|
1204
1205
|
}
|
|
1205
1206
|
return value;
|
|
1206
1207
|
}
|
|
@@ -1214,10 +1215,10 @@ function toProtoReadOptions(options?: ReadOptions) {
|
|
|
1214
1215
|
proto.range = toProtoByteRange(options.range);
|
|
1215
1216
|
}
|
|
1216
1217
|
if (options?.ifModifiedSince) {
|
|
1217
|
-
proto.ifModifiedSince =
|
|
1218
|
+
proto.ifModifiedSince = timestampFromDate(options.ifModifiedSince);
|
|
1218
1219
|
}
|
|
1219
1220
|
if (options?.ifUnmodifiedSince) {
|
|
1220
|
-
proto.ifUnmodifiedSince =
|
|
1221
|
+
proto.ifUnmodifiedSince = timestampFromDate(options.ifUnmodifiedSince);
|
|
1221
1222
|
}
|
|
1222
1223
|
return proto;
|
|
1223
1224
|
}
|
|
@@ -1234,10 +1235,10 @@ function fromProtoReadOptions(request: ProtoReadObjectRequest | undefined): Read
|
|
|
1234
1235
|
options.ifNoneMatch = request.ifNoneMatch;
|
|
1235
1236
|
}
|
|
1236
1237
|
if (request?.ifModifiedSince) {
|
|
1237
|
-
options.ifModifiedSince =
|
|
1238
|
+
options.ifModifiedSince = dateFromTimestamp(request.ifModifiedSince);
|
|
1238
1239
|
}
|
|
1239
1240
|
if (request?.ifUnmodifiedSince) {
|
|
1240
|
-
options.ifUnmodifiedSince =
|
|
1241
|
+
options.ifUnmodifiedSince = dateFromTimestamp(request.ifUnmodifiedSince);
|
|
1241
1242
|
}
|
|
1242
1243
|
return options;
|
|
1243
1244
|
}
|
|
@@ -1330,22 +1331,6 @@ function fromProtoPresignMethod(method: ProtoPresignMethod): PresignMethod {
|
|
|
1330
1331
|
}
|
|
1331
1332
|
}
|
|
1332
1333
|
|
|
1333
|
-
function toProtoTimestamp(value: Date) {
|
|
1334
|
-
const millis = value.getTime();
|
|
1335
|
-
const seconds = Math.floor(millis / 1000);
|
|
1336
|
-
const nanos = Math.trunc((millis - (seconds * 1000)) * 1_000_000);
|
|
1337
|
-
return {
|
|
1338
|
-
seconds: BigInt(seconds),
|
|
1339
|
-
nanos,
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
function fromProtoTimestamp(value: { seconds?: bigint; nanos?: number }): Date {
|
|
1344
|
-
const seconds = Number(value.seconds ?? 0n);
|
|
1345
|
-
const nanos = Number(value.nanos ?? 0);
|
|
1346
|
-
return new Date((seconds * 1000) + Math.trunc(nanos / 1_000_000));
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
1334
|
function normalizeProtoInt(value: number | bigint | undefined): bigint {
|
|
1350
1335
|
if (typeof value === "bigint") {
|
|
1351
1336
|
return value;
|
package/src/secrets.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderBase, type ProviderBaseOptions } from "./provider.ts";
|
|
2
2
|
import type { MaybePromise } from "./api.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Runtime hooks required to implement a Gestalt secrets provider.
|
|
6
6
|
*/
|
|
7
|
-
export interface SecretsProviderOptions extends
|
|
7
|
+
export interface SecretsProviderOptions extends ProviderBaseOptions {
|
|
8
8
|
getSecret: (name: string) => MaybePromise<string>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Secrets provider implementation consumed by the Gestalt runtime.
|
|
13
13
|
*/
|
|
14
|
-
export class SecretsProvider extends
|
|
14
|
+
export class SecretsProvider extends ProviderBase {
|
|
15
15
|
readonly kind = "secrets" as const;
|
|
16
16
|
|
|
17
17
|
private readonly getSecretHandler: SecretsProviderOptions["getSecret"];
|