@deepagents/context 2.4.0 → 3.0.0
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
CHANGED
|
@@ -35,6 +35,11 @@ See the docs for the full API surface:
|
|
|
35
35
|
|
|
36
36
|
- [Sandbox](https://januarylabs.github.io/deepagents/docs/context/sandbox)
|
|
37
37
|
- [Subcommand Builders](https://januarylabs.github.io/deepagents/docs/context/subcommand)
|
|
38
|
+
- [GCS Cloud Storage Volumes](https://januarylabs.github.io/deepagents/docs/context/recipes/gcs-cloud-storage)
|
|
39
|
+
|
|
40
|
+
For same-host Linux Docker daemons, `gcs({ hostPath, mountPath })` provides a
|
|
41
|
+
typed bind-volume helper over a host `gcsfuse` mount. For remote daemons, keep
|
|
42
|
+
cloud wiring in the daemon/plugin layer and attach the resulting named volume.
|
|
38
43
|
|
|
39
44
|
## Basic Usage
|
|
40
45
|
|
package/dist/index.js
CHANGED
|
@@ -6595,11 +6595,9 @@ function resolveRealCwd(ctx) {
|
|
|
6595
6595
|
// packages/context/src/lib/sandbox/daytona-sandbox.ts
|
|
6596
6596
|
import "bash-tool";
|
|
6597
6597
|
import { randomUUID } from "node:crypto";
|
|
6598
|
-
import { createRequire } from "node:module";
|
|
6599
6598
|
var DAYTONA_DEFAULT_DESTINATION = "/home/daytona";
|
|
6600
6599
|
var DAYTONA_EXIT_POLL_INTERVAL_MS = 250;
|
|
6601
6600
|
var DAYTONA_EXIT_POLL_TIMEOUT_MS = 3e4;
|
|
6602
|
-
var requireOptional = createRequire(import.meta.url);
|
|
6603
6601
|
var DaytonaSandboxError = class extends Error {
|
|
6604
6602
|
constructor(message2, cause) {
|
|
6605
6603
|
super(message2);
|
|
@@ -6630,28 +6628,28 @@ var DaytonaCommandError = class extends DaytonaSandboxError {
|
|
|
6630
6628
|
};
|
|
6631
6629
|
async function createDaytonaSandbox(options = {}) {
|
|
6632
6630
|
validateDaytonaOptions(options);
|
|
6633
|
-
const
|
|
6631
|
+
const sdk = await importDaytonaSdk();
|
|
6634
6632
|
let client;
|
|
6635
6633
|
try {
|
|
6636
|
-
client = new Daytona(createDaytonaConfig(options));
|
|
6634
|
+
client = new sdk.Daytona(createDaytonaConfig(options));
|
|
6637
6635
|
} catch (error) {
|
|
6638
|
-
|
|
6639
|
-
throw new DaytonaCreationError(err.message, err);
|
|
6636
|
+
throw normalizeDaytonaError(error, sdk);
|
|
6640
6637
|
}
|
|
6641
6638
|
const attached = options.sandboxId !== void 0;
|
|
6642
|
-
const
|
|
6639
|
+
const reuseByName = !attached && options.name !== void 0;
|
|
6640
|
+
const deleteOnDispose = options.deleteOnDispose ?? (!attached && !reuseByName);
|
|
6643
6641
|
let sandbox;
|
|
6644
6642
|
try {
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6643
|
+
if (reuseByName) {
|
|
6644
|
+
sandbox = await acquireReusedSandbox(client, options, sdk);
|
|
6645
|
+
} else if (attached) {
|
|
6646
|
+
sandbox = await client.get(options.sandboxId);
|
|
6647
|
+
await startIfStopped(sandbox, options);
|
|
6648
|
+
} else {
|
|
6649
|
+
sandbox = await createSandbox(client, options);
|
|
6651
6650
|
}
|
|
6652
6651
|
} catch (error) {
|
|
6653
|
-
|
|
6654
|
-
throw new DaytonaCreationError(err.message, err);
|
|
6652
|
+
throw normalizeDaytonaError(error, sdk);
|
|
6655
6653
|
}
|
|
6656
6654
|
return createDaytonaSandboxMethods({
|
|
6657
6655
|
client,
|
|
@@ -6661,15 +6659,39 @@ async function createDaytonaSandbox(options = {}) {
|
|
|
6661
6659
|
deleteTimeout: options.deleteTimeout
|
|
6662
6660
|
});
|
|
6663
6661
|
}
|
|
6662
|
+
async function acquireReusedSandbox(client, options, sdk) {
|
|
6663
|
+
try {
|
|
6664
|
+
const sandbox = await client.get(options.name);
|
|
6665
|
+
await startIfStopped(sandbox, options);
|
|
6666
|
+
return sandbox;
|
|
6667
|
+
} catch (error) {
|
|
6668
|
+
if (!(error instanceof sdk.DaytonaNotFoundError)) {
|
|
6669
|
+
throw error;
|
|
6670
|
+
}
|
|
6671
|
+
return createSandbox(client, options);
|
|
6672
|
+
}
|
|
6673
|
+
}
|
|
6674
|
+
async function startIfStopped(sandbox, options) {
|
|
6675
|
+
if (sandbox.state && sandbox.state !== "started") {
|
|
6676
|
+
await sandbox.start?.(options.startTimeout ?? options.createTimeout);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
function normalizeDaytonaError(error, sdk) {
|
|
6680
|
+
const err = toError(error);
|
|
6681
|
+
if (err instanceof sdk.DaytonaError) {
|
|
6682
|
+
return err;
|
|
6683
|
+
}
|
|
6684
|
+
return new DaytonaCreationError(err.message, err);
|
|
6685
|
+
}
|
|
6664
6686
|
async function importDaytonaSdk() {
|
|
6665
6687
|
try {
|
|
6666
|
-
const mod =
|
|
6688
|
+
const mod = await import("@daytona/sdk");
|
|
6667
6689
|
if (typeof mod.Daytona !== "function") {
|
|
6668
6690
|
throw new DaytonaSandboxError(
|
|
6669
6691
|
"@daytona/sdk did not export a Daytona constructor"
|
|
6670
6692
|
);
|
|
6671
6693
|
}
|
|
6672
|
-
return
|
|
6694
|
+
return mod;
|
|
6673
6695
|
} catch (error) {
|
|
6674
6696
|
if (error instanceof DaytonaSandboxError) {
|
|
6675
6697
|
throw error;
|
|
@@ -6692,7 +6714,7 @@ function createDaytonaConfig(options) {
|
|
|
6692
6714
|
_experimental: options.experimental
|
|
6693
6715
|
});
|
|
6694
6716
|
}
|
|
6695
|
-
function
|
|
6717
|
+
function createSandbox(client, options) {
|
|
6696
6718
|
const base = compactObject({
|
|
6697
6719
|
name: options.name,
|
|
6698
6720
|
user: options.user,
|
|
@@ -6708,18 +6730,24 @@ function createDaytonaParams(options) {
|
|
|
6708
6730
|
networkAllowList: options.networkAllowList,
|
|
6709
6731
|
ephemeral: options.ephemeral
|
|
6710
6732
|
});
|
|
6711
|
-
if (options.image) {
|
|
6712
|
-
|
|
6733
|
+
if (options.image !== void 0) {
|
|
6734
|
+
const params2 = compactObject({
|
|
6713
6735
|
...base,
|
|
6714
6736
|
image: options.image,
|
|
6715
6737
|
resources: options.resources
|
|
6716
6738
|
});
|
|
6739
|
+
return client.create(params2, {
|
|
6740
|
+
timeout: options.createTimeout,
|
|
6741
|
+
onSnapshotCreateLogs: options.onSnapshotCreateLogs
|
|
6742
|
+
});
|
|
6717
6743
|
}
|
|
6718
6744
|
const params = compactObject({
|
|
6719
6745
|
...base,
|
|
6720
6746
|
snapshot: options.snapshot
|
|
6721
6747
|
});
|
|
6722
|
-
return Object.keys(params).length > 0 ? params : void 0
|
|
6748
|
+
return client.create(Object.keys(params).length > 0 ? params : void 0, {
|
|
6749
|
+
timeout: options.createTimeout
|
|
6750
|
+
});
|
|
6723
6751
|
}
|
|
6724
6752
|
function validateDaytonaOptions(options) {
|
|
6725
6753
|
if (options.image && options.snapshot) {
|
|
@@ -8517,7 +8545,7 @@ function soul() {
|
|
|
8517
8545
|
}
|
|
8518
8546
|
|
|
8519
8547
|
// packages/context/src/lib/store/postgres.store.ts
|
|
8520
|
-
import { createRequire
|
|
8548
|
+
import { createRequire } from "node:module";
|
|
8521
8549
|
|
|
8522
8550
|
// packages/context/src/lib/store/ddl.postgres.ts
|
|
8523
8551
|
function storeDDL(schema) {
|
|
@@ -8629,7 +8657,7 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
8629
8657
|
}
|
|
8630
8658
|
static #requirePg() {
|
|
8631
8659
|
try {
|
|
8632
|
-
const require2 =
|
|
8660
|
+
const require2 = createRequire(import.meta.url);
|
|
8633
8661
|
return require2("pg");
|
|
8634
8662
|
} catch {
|
|
8635
8663
|
throw new Error(
|
|
@@ -9225,7 +9253,7 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
9225
9253
|
};
|
|
9226
9254
|
|
|
9227
9255
|
// packages/context/src/lib/store/sqlserver.store.ts
|
|
9228
|
-
import { createRequire as
|
|
9256
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
9229
9257
|
|
|
9230
9258
|
// packages/context/src/lib/store/ddl.sqlserver.ts
|
|
9231
9259
|
function storeDDL2(schema) {
|
|
@@ -9367,7 +9395,7 @@ var SqlServerContextStore = class _SqlServerContextStore extends ContextStore {
|
|
|
9367
9395
|
}
|
|
9368
9396
|
static #requireMssql() {
|
|
9369
9397
|
try {
|
|
9370
|
-
const require2 =
|
|
9398
|
+
const require2 = createRequire2(import.meta.url);
|
|
9371
9399
|
return require2("mssql");
|
|
9372
9400
|
} catch {
|
|
9373
9401
|
throw new Error(
|
|
@@ -10357,7 +10385,7 @@ function asStaticWordPartText(parts, options = {}) {
|
|
|
10357
10385
|
}
|
|
10358
10386
|
|
|
10359
10387
|
// packages/context/src/lib/stream/postgres-notify-change-source.ts
|
|
10360
|
-
import { createRequire as
|
|
10388
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
10361
10389
|
|
|
10362
10390
|
// packages/context/src/lib/stream/ddl.stream.postgres-notify.ts
|
|
10363
10391
|
var DEFAULT_POSTGRES_STREAM_CHANGES_CHANNEL = "deepagents_stream_changes";
|
|
@@ -10459,7 +10487,7 @@ var PostgresNotifyChangeSource = class _PostgresNotifyChangeSource {
|
|
|
10459
10487
|
}
|
|
10460
10488
|
static #requirePg() {
|
|
10461
10489
|
try {
|
|
10462
|
-
const require2 =
|
|
10490
|
+
const require2 = createRequire3(import.meta.url);
|
|
10463
10491
|
return require2("pg");
|
|
10464
10492
|
} catch {
|
|
10465
10493
|
throw new Error(
|
|
@@ -10714,7 +10742,7 @@ function assertIdentifier(value, label) {
|
|
|
10714
10742
|
}
|
|
10715
10743
|
|
|
10716
10744
|
// packages/context/src/lib/stream/postgres.stream-store.ts
|
|
10717
|
-
import { createRequire as
|
|
10745
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
10718
10746
|
|
|
10719
10747
|
// packages/context/src/lib/stream/ddl.stream.postgres.ts
|
|
10720
10748
|
function postgresStreamDDL(schema) {
|
|
@@ -10788,7 +10816,7 @@ var PostgresStreamStore = class _PostgresStreamStore extends StreamStore {
|
|
|
10788
10816
|
}
|
|
10789
10817
|
static #requirePg() {
|
|
10790
10818
|
try {
|
|
10791
|
-
const require2 =
|
|
10819
|
+
const require2 = createRequire4(import.meta.url);
|
|
10792
10820
|
return require2("pg");
|
|
10793
10821
|
} catch {
|
|
10794
10822
|
throw new Error(
|