@vantageos/agent-engine 0.1.0-alpha.8 → 0.3.0-alpha.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.
- package/README.md +33 -8
- package/dist/component/_generated/api.d.ts +14 -3
- package/dist/component/_generated/api.js +0 -25
- package/dist/component/_generated/component.d.ts +369 -73
- package/dist/component/_generated/component.js +0 -9
- package/dist/component/_generated/dataModel.js +0 -9
- package/dist/component/_generated/server.js +0 -69
- package/dist/component/convex.config.js +0 -44
- package/dist/component/engine/agents.d.ts +3 -3
- package/dist/component/engine/agents.js +0 -7
- package/dist/component/engine/awaitEventTimeout.d.ts +1 -1
- package/dist/component/engine/awaitEventTimeout.js +16 -26
- package/dist/component/engine/connections.d.ts +74 -0
- package/dist/component/engine/connections.js +254 -0
- package/dist/component/engine/delegation.d.ts +5 -5
- package/dist/component/engine/delegation.js +0 -74
- package/dist/component/engine/directory.js +0 -18
- package/dist/component/engine/durableJob.d.ts +24 -17
- package/dist/component/engine/durableJob.js +182 -138
- package/dist/component/engine/mandates.d.ts +2 -2
- package/dist/component/engine/mandates.js +0 -59
- package/dist/component/engine/queue.d.ts +97 -0
- package/dist/component/engine/queue.js +201 -0
- package/dist/component/engine/resolvers.d.ts +1 -1
- package/dist/component/engine/resolvers.js +6 -18
- package/dist/component/engine/sandboxCallback.d.ts +2 -2
- package/dist/component/engine/sandboxCallback.js +2 -79
- package/dist/component/engine/sandboxConfigProvider.d.ts +9 -0
- package/dist/component/engine/sandboxConfigProvider.js +32 -0
- package/dist/component/engine/sessions.d.ts +28 -10
- package/dist/component/engine/sessions.js +130 -170
- package/dist/component/engine/streams.d.ts +47 -0
- package/dist/component/engine/streams.js +162 -0
- package/dist/component/engine/toolApprovals.d.ts +1 -1
- package/dist/component/engine/toolApprovals.js +12 -37
- package/dist/component/engine/vpConnection.js +0 -40
- package/dist/component/engine/wakeup.d.ts +7 -9
- package/dist/component/engine/wakeup.js +54 -127
- package/dist/component/engine/workflows.d.ts +26 -8
- package/dist/component/engine/workflows.js +59 -64
- package/dist/component/engine/world.d.ts +250 -0
- package/dist/component/engine/world.js +689 -0
- package/dist/component/lib/auth.js +0 -26
- package/dist/component/lib/connectionSecret.d.ts +5 -0
- package/dist/component/lib/connectionSecret.js +32 -0
- package/dist/component/schema.d.ts +240 -175
- package/dist/component/schema.js +134 -294
- package/package.json +21 -6
- package/dist/component/engine/habits.d.ts +0 -70
- package/dist/component/engine/habits.js +0 -218
- package/dist/component/testFixtures/callerSteps.d.ts +0 -20
- package/dist/component/testFixtures/callerSteps.js +0 -90
- package/dist/component/testFixtures/delegationDemoWorkflow.d.ts +0 -18
- package/dist/component/testFixtures/delegationDemoWorkflow.js +0 -75
- package/dist/component/testFixtures/sandboxDemoWorkflow.d.ts +0 -19
- package/dist/component/testFixtures/sandboxDemoWorkflow.js +0 -69
- package/dist/component/testFixtures/vpTool.d.ts +0 -4
- package/dist/component/testFixtures/vpTool.js +0 -25
- package/dist/component/testFixtures/wakeupDemoWorkflow.d.ts +0 -19
- package/dist/component/testFixtures/wakeupDemoWorkflow.js +0 -77
- package/dist/component/testFixtures/wakeupWork.d.ts +0 -8
- package/dist/component/testFixtures/wakeupWork.js +0 -21
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
// Trust model (CORRECTIF BLOQUANT, VP k1741evjzm72rj91tkcbdhpskx8ah35a):
|
|
2
|
-
// Convex does NOT propagate the calling app's `ctx.auth` identity across a
|
|
3
|
-
// component boundary -- this is a platform isolation guarantee, not a
|
|
4
|
-
// choice this component makes (convex-test: "Auth doesn't propagate across
|
|
5
|
-
// component boundaries"). A handler inside this component can therefore
|
|
6
|
-
// NEVER read `ctx.auth.getUserIdentity()` and expect it to reflect the
|
|
7
|
-
// consumer app's end user -- there is no such identity to read here.
|
|
8
|
-
//
|
|
9
|
-
// The consumer app has ALREADY authenticated its user and resolved their
|
|
10
|
-
// orgId on ITS OWN side (e.g. Clerk org claim, read in the consumer's own
|
|
11
|
-
// `ctx.auth`) before ever calling into this component. `orgId` is passed
|
|
12
|
-
// as an explicit argument on every public function in this component.
|
|
13
|
-
//
|
|
14
|
-
// What does NOT change: this component still derives NOTHING from the
|
|
15
|
-
// client beyond what the consumer's public API surface exposes, still
|
|
16
|
-
// denies by default, and `orgId` is still the first field of every index
|
|
17
|
-
// and is still enforced on every document read via `assertSameOrg` below
|
|
18
|
-
// -- a caller-supplied `orgId` can never see another org's rows. The
|
|
19
|
-
// isolation boundary moved from "component reads ctx.auth" (impossible
|
|
20
|
-
// across a component boundary) to "component enforces the orgId the
|
|
21
|
-
// consumer already vouches for"; the boundary itself -- deny by default,
|
|
22
|
-
// orgId first, no cross-org reads -- is unchanged.
|
|
23
1
|
export function requireOrgId(orgId) {
|
|
24
2
|
if (!orgId || typeof orgId !== "string" || orgId.trim().length === 0) {
|
|
25
3
|
throw new Error("Unauthenticated: caller did not supply a non-empty orgId");
|
|
26
4
|
}
|
|
27
5
|
return orgId;
|
|
28
6
|
}
|
|
29
|
-
// Throws unless the document's orgId matches the caller-supplied orgId.
|
|
30
|
-
// Use on every read/write of a document fetched by _id, since db.get()
|
|
31
|
-
// does not filter by index.
|
|
32
7
|
export function assertSameOrg(callerOrgId, doc, notFoundMessage) {
|
|
33
8
|
if (!doc || doc.orgId !== callerOrgId) {
|
|
34
|
-
// Same error for "not found" and "cross-org" -- do not leak existence.
|
|
35
9
|
throw new Error(notFoundMessage);
|
|
36
10
|
}
|
|
37
11
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function bytesToBase64(bytes) {
|
|
2
|
+
let binary = "";
|
|
3
|
+
for (const byte of bytes)
|
|
4
|
+
binary += String.fromCharCode(byte);
|
|
5
|
+
return btoa(binary);
|
|
6
|
+
}
|
|
7
|
+
function base64ToBytes(base64) {
|
|
8
|
+
const binary = atob(base64);
|
|
9
|
+
const bytes = new Uint8Array(binary.length);
|
|
10
|
+
for (let i = 0; i < binary.length; i++)
|
|
11
|
+
bytes[i] = binary.charCodeAt(i);
|
|
12
|
+
return bytes;
|
|
13
|
+
}
|
|
14
|
+
export async function encryptSecret(plaintext, encryptionKeyBase64) {
|
|
15
|
+
if (plaintext.length === 0) {
|
|
16
|
+
throw new Error("Validation: secret plaintext must not be empty");
|
|
17
|
+
}
|
|
18
|
+
if (!encryptionKeyBase64 || encryptionKeyBase64.trim().length === 0) {
|
|
19
|
+
throw new Error("Validation: encryptionKeyBase64 must not be empty -- caller must supply a key, this component never reads one from process.env");
|
|
20
|
+
}
|
|
21
|
+
const keyBytes = base64ToBytes(encryptionKeyBase64);
|
|
22
|
+
if (keyBytes.length !== 32) {
|
|
23
|
+
throw new Error(`Validation: encryptionKeyBase64 must decode to exactly 32 bytes (AES-256), got ${keyBytes.length}`);
|
|
24
|
+
}
|
|
25
|
+
const key = await crypto.subtle.importKey("raw", keyBytes, { name: "AES-GCM" }, false, ["encrypt"]);
|
|
26
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
27
|
+
const ciphertext = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, new TextEncoder().encode(plaintext));
|
|
28
|
+
return {
|
|
29
|
+
ciphertextBase64: bytesToBase64(new Uint8Array(ciphertext)),
|
|
30
|
+
ivBase64: bytesToBase64(iv),
|
|
31
|
+
};
|
|
32
|
+
}
|