@valon-technologies/gestalt 0.0.1-alpha.17 → 0.0.1-alpha.19

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.
Files changed (39) hide show
  1. package/README.md +34 -12
  2. package/package.json +5 -3
  3. package/src/agent-conversions.ts +201 -0
  4. package/src/agent-manager.ts +272 -83
  5. package/src/agent.ts +1029 -219
  6. package/src/api.ts +54 -0
  7. package/src/auth.ts +3 -3
  8. package/src/authorization.ts +1702 -52
  9. package/src/cache.ts +5 -4
  10. package/src/catalog.ts +22 -0
  11. package/src/http-subject.ts +13 -2
  12. package/src/index.ts +194 -17
  13. package/src/indexeddb.ts +5 -16
  14. package/src/internal/gen/v1/agent_pb.ts +353 -74
  15. package/src/internal/gen/v1/authentication_pb.ts +1 -1
  16. package/src/internal/gen/v1/authorization_pb.ts +505 -27
  17. package/src/internal/gen/v1/cache_pb.ts +1 -1
  18. package/src/internal/gen/v1/datastore_pb.ts +1 -1
  19. package/src/internal/gen/v1/external_credential_pb.ts +434 -29
  20. package/src/internal/gen/v1/plugin_pb.ts +92 -22
  21. package/src/internal/gen/v1/pluginruntime_pb.ts +95 -6
  22. package/src/internal/gen/v1/runtime_pb.ts +1 -1
  23. package/src/internal/gen/v1/s3_pb.ts +1 -1
  24. package/src/internal/gen/v1/secrets_pb.ts +1 -1
  25. package/src/internal/gen/v1/workflow_pb.ts +349 -67
  26. package/src/invoker.ts +6 -35
  27. package/src/plugin.ts +12 -12
  28. package/src/pluginruntime.ts +337 -49
  29. package/src/protocol/v1.ts +19 -0
  30. package/src/protocol-internal.ts +19 -0
  31. package/src/protocol.ts +183 -0
  32. package/src/provider-kind.ts +7 -3
  33. package/src/provider.ts +21 -13
  34. package/src/runtime-log-host.ts +81 -53
  35. package/src/runtime.ts +72 -0
  36. package/src/s3.ts +15 -29
  37. package/src/secrets.ts +3 -3
  38. package/src/workflow-manager.ts +350 -121
  39. package/src/workflow.ts +2598 -389
package/src/api.ts CHANGED
@@ -6,6 +6,26 @@ export interface Subject {
6
6
  kind: string;
7
7
  displayName: string;
8
8
  authSource: string;
9
+ email: string;
10
+ }
11
+
12
+ /**
13
+ * Subject payload authored by provider-side hooks.
14
+ */
15
+ export interface SubjectInput {
16
+ id: string;
17
+ kind: string;
18
+ displayName: string;
19
+ authSource: string;
20
+ email?: string | undefined;
21
+ }
22
+
23
+ /**
24
+ * Provider-owned external identity attached to an incoming provider request.
25
+ */
26
+ export interface ExternalIdentity {
27
+ type: string;
28
+ id: string;
9
29
  }
10
30
 
11
31
  /**
@@ -26,6 +46,13 @@ export interface Access {
26
46
  role: string;
27
47
  }
28
48
 
49
+ /**
50
+ * Describes public host metadata available to provider code.
51
+ */
52
+ export interface Host {
53
+ publicBaseUrl: string;
54
+ }
55
+
29
56
  /**
30
57
  * Request metadata forwarded to provider handlers by the Gestalt runtime.
31
58
  */
@@ -33,8 +60,12 @@ export interface Request {
33
60
  token: string;
34
61
  connectionParams: Record<string, string>;
35
62
  subject: Subject;
63
+ agentSubject: Subject;
64
+ externalIdentity: ExternalIdentity;
65
+ agentExternalIdentity: ExternalIdentity;
36
66
  credential: Credential;
37
67
  access: Access;
68
+ host: Host;
38
69
  idempotencyKey: string;
39
70
  // Workflow callback metadata uses a JSON-style lowerCamelCase object such as
40
71
  // runId, target.plugin.pluginName, trigger.scheduleId, and trigger.event.specVersion.
@@ -106,6 +137,10 @@ export function request(
106
137
  workflow: Record<string, unknown> = {},
107
138
  invocationToken = "",
108
139
  idempotencyKey = "",
140
+ host: Partial<Host> = {},
141
+ agentSubject: Partial<Subject> = {},
142
+ externalIdentity: Partial<ExternalIdentity> = {},
143
+ agentExternalIdentity: Partial<ExternalIdentity> = {},
109
144
  ): Request {
110
145
  return {
111
146
  token,
@@ -117,6 +152,22 @@ export function request(
117
152
  kind: subject.kind ?? "",
118
153
  displayName: subject.displayName ?? "",
119
154
  authSource: subject.authSource ?? "",
155
+ email: subject.email ?? "",
156
+ },
157
+ agentSubject: {
158
+ id: agentSubject.id ?? "",
159
+ kind: agentSubject.kind ?? "",
160
+ displayName: agentSubject.displayName ?? "",
161
+ authSource: agentSubject.authSource ?? "",
162
+ email: agentSubject.email ?? "",
163
+ },
164
+ externalIdentity: {
165
+ type: externalIdentity.type ?? "",
166
+ id: externalIdentity.id ?? "",
167
+ },
168
+ agentExternalIdentity: {
169
+ type: agentExternalIdentity.type ?? "",
170
+ id: agentExternalIdentity.id ?? "",
120
171
  },
121
172
  credential: {
122
173
  mode: credential.mode ?? "",
@@ -131,6 +182,9 @@ export function request(
131
182
  workflow: {
132
183
  ...workflow,
133
184
  },
185
+ host: {
186
+ publicBaseUrl: host.publicBaseUrl ?? "",
187
+ },
134
188
  invocationToken,
135
189
  idempotencyKey: idempotencyKey.trim(),
136
190
  };
package/src/auth.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RuntimeProvider, type RuntimeProviderOptions } from "./provider.ts";
1
+ import { ProviderBase, type ProviderBaseOptions } from "./provider.ts";
2
2
  import type { MaybePromise } from "./api.ts";
3
3
 
4
4
  /**
@@ -52,7 +52,7 @@ export interface AuthenticationSessionSettings {
52
52
  /**
53
53
  * Runtime hooks required to implement a Gestalt authentication provider.
54
54
  */
55
- export interface AuthenticationProviderOptions extends RuntimeProviderOptions {
55
+ export interface AuthenticationProviderOptions extends ProviderBaseOptions {
56
56
  beginLogin: (
57
57
  request: BeginLoginRequest,
58
58
  ) => MaybePromise<BeginLoginResponse>;
@@ -68,7 +68,7 @@ export interface AuthenticationProviderOptions extends RuntimeProviderOptions {
68
68
  /**
69
69
  * Authentication provider implementation consumed by the Gestalt runtime.
70
70
  */
71
- export class AuthenticationProvider extends RuntimeProvider {
71
+ export class AuthenticationProvider extends ProviderBase {
72
72
  readonly kind = "authentication" as const;
73
73
 
74
74
  private readonly beginLoginHandler: AuthenticationProviderOptions["beginLogin"];