@vellumai/credential-executor 0.10.7-dev.202607102035.64f07ea → 0.10.7-staging.1

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 (65) hide show
  1. package/Dockerfile +1 -1
  2. package/node_modules/@vellumai/service-contracts/package.json +2 -1
  3. package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +2 -0
  4. package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +686 -0
  5. package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +5 -3
  6. package/node_modules/@vellumai/service-contracts/src/grants.ts +184 -0
  7. package/node_modules/@vellumai/service-contracts/src/index.ts +4 -2
  8. package/node_modules/@vellumai/service-contracts/src/rendering.ts +135 -0
  9. package/node_modules/@vellumai/service-contracts/src/rpc.ts +447 -4
  10. package/package.json +3 -2
  11. package/src/__tests__/bulk-set-credentials.test.ts +1 -1
  12. package/src/__tests__/command-executor.test.ts +1879 -0
  13. package/src/__tests__/command-validator.test.ts +1405 -0
  14. package/src/__tests__/command-workspace.test.ts +1050 -0
  15. package/src/__tests__/grant-store.test.ts +689 -0
  16. package/src/__tests__/http-executor.test.ts +1336 -0
  17. package/src/__tests__/http-policy.test.ts +1069 -0
  18. package/src/__tests__/local-materializers.test.ts +860 -0
  19. package/src/__tests__/local-standalone.test.ts +36 -5
  20. package/src/__tests__/local-token-refresh.test.ts +361 -0
  21. package/src/__tests__/manage-secure-command-tool.test.ts +134 -0
  22. package/src/__tests__/managed-integration.test.ts +91 -112
  23. package/src/__tests__/managed-lazy-getters.test.ts +359 -0
  24. package/src/__tests__/managed-materializers.test.ts +1028 -0
  25. package/src/__tests__/managed-reconnect.test.ts +2 -2
  26. package/src/__tests__/managed-rejection.test.ts +43 -0
  27. package/src/__tests__/toolstore.test.ts +773 -0
  28. package/src/__tests__/transport.test.ts +27 -23
  29. package/src/audit/store.ts +188 -0
  30. package/src/cli.ts +1 -1
  31. package/src/commands/auth-adapters.ts +169 -0
  32. package/src/commands/egress-hooks.ts +203 -0
  33. package/src/commands/executor.ts +1155 -0
  34. package/src/commands/output-scan.ts +157 -0
  35. package/src/commands/profiles.ts +286 -0
  36. package/src/commands/validator.ts +702 -0
  37. package/src/commands/workspace.ts +550 -0
  38. package/src/grants/index.ts +17 -0
  39. package/src/grants/persistent-store.ts +309 -0
  40. package/src/grants/rpc-handlers.ts +293 -0
  41. package/src/grants/temporary-store.ts +289 -0
  42. package/src/http/audit.ts +84 -0
  43. package/src/http/executor.ts +684 -0
  44. package/src/http/path-template.ts +245 -0
  45. package/src/http/policy.ts +238 -0
  46. package/src/http/response-filter.ts +233 -0
  47. package/src/index.ts +88 -8
  48. package/src/main.ts +340 -228
  49. package/src/managed-errors.ts +9 -0
  50. package/src/managed-lazy-getters.ts +106 -0
  51. package/src/managed-main.ts +822 -0
  52. package/src/materializers/local-oauth-lookup.ts +98 -0
  53. package/src/materializers/local-token-refresh.ts +287 -0
  54. package/src/materializers/local.ts +316 -0
  55. package/src/materializers/managed-platform.ts +295 -0
  56. package/src/paths.ts +20 -4
  57. package/src/server.ts +469 -52
  58. package/src/subjects/local.ts +177 -0
  59. package/src/subjects/managed.ts +311 -0
  60. package/src/subjects/policy.ts +79 -0
  61. package/src/toolstore/integrity.ts +94 -0
  62. package/src/toolstore/manifest.ts +154 -0
  63. package/src/toolstore/publish.ts +571 -0
  64. package/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +0 -104
  65. package/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +0 -118
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Error message constants for managed-mode CES.
3
+ *
4
+ * Re-exported from @vellumai/service-contracts so both the assistant and
5
+ * credential-executor can share the constant via the approved shared-code
6
+ * path without violating the hard process-boundary isolation.
7
+ */
8
+
9
+ export { MANAGED_LOCAL_STATIC_REJECTION_ERROR } from "@vellumai/service-contracts/credential-rpc";
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Lazy getter pattern for managed CES API key propagation.
3
+ *
4
+ * In managed mode the assistant API key may arrive after CES handlers are
5
+ * registered (via the handshake callback or a later RPC update). The
6
+ * `ApiKeyRef` + `buildLazyGetters` pattern allows handlers to resolve
7
+ * the key at call time rather than at registration time.
8
+ *
9
+ * Extracted from `managed-main.ts` so the behavioral contract can be
10
+ * tested directly without exercising the full managed bootstrap lifecycle.
11
+ */
12
+
13
+ import type { ManagedSubjectResolverOptions } from "./subjects/managed.js";
14
+ import type { ManagedMaterializerOptions } from "./materializers/managed-platform.js";
15
+
16
+ /**
17
+ * Mutable reference to the assistant API key. Allows the handshake callback
18
+ * to inject the key provisioned at runtime (which arrives after handlers are
19
+ * built). Handlers read `.current` at call time, not at registration time.
20
+ */
21
+ export interface ApiKeyRef {
22
+ current: string;
23
+ }
24
+
25
+ /**
26
+ * Mutable reference to the platform assistant ID. The assistant ID is not
27
+ * available at CES startup (warm-pool pods); the assistant forwards it via
28
+ * the handshake or update_managed_credential RPC after provisioning, and
29
+ * `.current` is updated so lazy getters pick it up.
30
+ */
31
+ export interface AssistantIdRef {
32
+ current: string;
33
+ }
34
+
35
+ /**
36
+ * Overwrite the session-scoped managed credential refs.
37
+ *
38
+ * The managed handler registry is long-lived — it persists across assistant
39
+ * reconnects — so every handshake and every `update_managed_credential` must
40
+ * fully overwrite these refs, including clearing them when a value is absent.
41
+ * Otherwise a new or reprovisioned session could keep materializing platform
42
+ * credentials with the previous session's API key or assistant ID. Absent
43
+ * values fall back to "" (fail closed): the lazy getters then return no
44
+ * materialization options, and `getAssistantApiKey` falls back to the env key.
45
+ */
46
+ export function applyManagedCredentialRefs(
47
+ apiKeyRef: ApiKeyRef,
48
+ assistantIdRef: AssistantIdRef,
49
+ apiKey: string | undefined,
50
+ assistantId: string | undefined,
51
+ ): void {
52
+ apiKeyRef.current = apiKey ?? "";
53
+ assistantIdRef.current = assistantId ?? "";
54
+ }
55
+
56
+ export interface LazyGetterOptions {
57
+ platformBaseUrl: string;
58
+ assistantIdRef: AssistantIdRef;
59
+ apiKeyRef: ApiKeyRef;
60
+ envApiKey?: string;
61
+ }
62
+
63
+ export interface LazyGetters {
64
+ getAssistantApiKey: () => string;
65
+ getManagedSubjectOptions: () => ManagedSubjectResolverOptions | undefined;
66
+ getManagedMaterializerOptions: () => ManagedMaterializerOptions | undefined;
67
+ }
68
+
69
+ /**
70
+ * Build lazy getter functions that resolve the API key at call time.
71
+ *
72
+ * Prefers the handshake-provided key (via `apiKeyRef.current`) over the
73
+ * env-var fallback, since in managed mode the env var may not be set
74
+ * (chicken-and-egg: key is provisioned after hatch).
75
+ */
76
+ export function buildLazyGetters(opts: LazyGetterOptions): LazyGetters {
77
+ const { platformBaseUrl, assistantIdRef, apiKeyRef, envApiKey } = opts;
78
+
79
+ const getAssistantApiKey = (): string => apiKeyRef.current || envApiKey || "";
80
+
81
+ const getManagedSubjectOptions = ():
82
+ | ManagedSubjectResolverOptions
83
+ | undefined => {
84
+ const key = getAssistantApiKey();
85
+ const id = assistantIdRef.current;
86
+ return platformBaseUrl && key && id
87
+ ? { platformBaseUrl, assistantApiKey: key, assistantId: id }
88
+ : undefined;
89
+ };
90
+
91
+ const getManagedMaterializerOptions = ():
92
+ | ManagedMaterializerOptions
93
+ | undefined => {
94
+ const key = getAssistantApiKey();
95
+ const id = assistantIdRef.current;
96
+ return platformBaseUrl && key && id
97
+ ? { platformBaseUrl, assistantApiKey: key, assistantId: id }
98
+ : undefined;
99
+ };
100
+
101
+ return {
102
+ getAssistantApiKey,
103
+ getManagedSubjectOptions,
104
+ getManagedMaterializerOptions,
105
+ };
106
+ }