deepline 0.1.138 → 0.1.139

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/dist/index.js CHANGED
@@ -127,22 +127,6 @@ var PROD_URL = "https://code.deepline.com";
127
127
  var DEFAULT_TIMEOUT = 6e4;
128
128
  var DEFAULT_MAX_RETRIES = 3;
129
129
  var PROJECT_DEEPLINE_ENV_FILE = ".env.deepline";
130
- var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
131
- ".auto-memory",
132
- ".claude",
133
- ".remote-plugins",
134
- "outputs",
135
- "plugins",
136
- "uploads"
137
- ]);
138
- var COWORK_PROJECT_MARKERS = [
139
- ".deepline",
140
- ".env.deepline",
141
- ".git",
142
- "AGENTS.md",
143
- "package.json",
144
- "pyproject.toml"
145
- ];
146
130
  function baseUrlSlug(baseUrl) {
147
131
  let url;
148
132
  try {
@@ -188,124 +172,9 @@ function findNearestEnvFile(name, startDir = process.cwd()) {
188
172
  current = parent;
189
173
  }
190
174
  }
191
- function isDirectory(path) {
192
- try {
193
- return (0, import_node_fs.statSync)(path).isDirectory();
194
- } catch {
195
- return false;
196
- }
197
- }
198
- function canonicalPath(path) {
199
- try {
200
- return (0, import_node_fs.realpathSync)(path);
201
- } catch {
202
- return (0, import_node_path.resolve)(path);
203
- }
204
- }
205
- function isTruthy(value) {
206
- return /^(1|true|yes|on)$/i.test(value?.trim() ?? "");
207
- }
208
- function sessionRootFromPath(path) {
209
- const trimmed = path?.trim();
210
- if (!trimmed) return null;
211
- const match = /^\/sessions\/[^/]+(?=\/|$)/.exec(trimmed);
212
- return match?.[0] ?? null;
213
- }
214
- function coworkSessionRoot() {
215
- const home = process.env.HOME?.trim();
216
- const homeSessionRoot = sessionRootFromPath(home);
217
- if (homeSessionRoot && isDirectory((0, import_node_path.join)(homeSessionRoot, "mnt"))) {
218
- return homeSessionRoot;
219
- }
220
- const cwdSessionRoot = sessionRootFromPath(process.cwd());
221
- if (cwdSessionRoot && isDirectory((0, import_node_path.join)(cwdSessionRoot, "mnt"))) {
222
- return cwdSessionRoot;
223
- }
224
- if (isTruthy(process.env.CLAUDE_CODE_REMOTE) && home) {
225
- const mountedRoot = (0, import_node_path.join)(home, "mnt");
226
- if (isDirectory(mountedRoot)) return (0, import_node_path.resolve)(home);
227
- }
228
- return null;
229
- }
230
- function isCoworkLikeSandbox() {
231
- const home = process.env.HOME?.trim();
232
- return isTruthy(process.env.CLAUDE_CODE_REMOTE) || sessionRootFromPath(home) !== null || sessionRootFromPath(process.cwd()) !== null;
233
- }
234
- function coworkProjectScore(path) {
235
- let score = 0;
236
- for (const marker of COWORK_PROJECT_MARKERS) {
237
- if ((0, import_node_fs.existsSync)((0, import_node_path.join)(path, marker))) score += 1;
238
- }
239
- return score;
240
- }
241
- function listCoworkWorkspaceDirCandidates() {
242
- if (!isCoworkLikeSandbox()) {
243
- return [];
244
- }
245
- const explicitProjectDir = process.env.CLAUDE_PROJECT_DIR?.trim();
246
- if (explicitProjectDir && isDirectory(explicitProjectDir)) {
247
- return [(0, import_node_path.resolve)(explicitProjectDir)];
248
- }
249
- const sessionRoot = coworkSessionRoot();
250
- if (!sessionRoot) return [];
251
- const mountedRoot = (0, import_node_path.join)(sessionRoot, "mnt");
252
- if (!isDirectory(mountedRoot)) return [];
253
- let names;
254
- try {
255
- names = (0, import_node_fs.readdirSync)(mountedRoot).sort();
256
- } catch {
257
- return [];
258
- }
259
- const candidates = [];
260
- for (const name of names) {
261
- if (name.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(name)) {
262
- continue;
263
- }
264
- const candidate = (0, import_node_path.join)(mountedRoot, name);
265
- if (isDirectory(candidate)) candidates.push(candidate);
266
- }
267
- if (candidates.length <= 1) return candidates;
268
- const projectLike = candidates.filter(
269
- (candidate) => coworkProjectScore(candidate) > 0
270
- );
271
- return projectLike.length > 0 ? projectLike : candidates;
272
- }
273
- function isInIgnoredCoworkMount(path) {
274
- const sessionRoot = coworkSessionRoot();
275
- if (!sessionRoot) return false;
276
- const mountedRoot = canonicalPath((0, import_node_path.join)(sessionRoot, "mnt"));
277
- const resolvedPath = canonicalPath(path);
278
- const prefix = `${mountedRoot}/`;
279
- if (!resolvedPath.startsWith(prefix)) return false;
280
- const relativePath = resolvedPath.slice(prefix.length);
281
- const mountName = relativePath.split("/")[0];
282
- return mountName.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(mountName);
283
- }
284
- function detectCoworkWorkspaceDir() {
285
- const candidates = listCoworkWorkspaceDirCandidates();
286
- return candidates.length === 1 ? candidates[0] : null;
287
- }
288
- function loadProjectEnvCandidates(startDir = process.cwd()) {
289
- const filePaths = [];
290
- const sources = /* @__PURE__ */ new Map();
291
- const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
292
- if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
293
- filePaths.push(nearestFile);
294
- sources.set((0, import_node_path.resolve)(nearestFile), "nearest");
295
- }
296
- const coworkWorkspaceDir = detectCoworkWorkspaceDir();
297
- if (coworkWorkspaceDir) {
298
- const coworkFile = (0, import_node_path.join)(coworkWorkspaceDir, PROJECT_DEEPLINE_ENV_FILE);
299
- if ((0, import_node_fs.existsSync)(coworkFile) && !filePaths.some((filePath) => (0, import_node_path.resolve)(filePath) === (0, import_node_path.resolve)(coworkFile))) {
300
- filePaths.push(coworkFile);
301
- sources.set((0, import_node_path.resolve)(coworkFile), "cowork");
302
- }
303
- }
304
- return filePaths.map((filePath) => ({
305
- filePath,
306
- env: parseEnvFile(filePath),
307
- source: sources.get((0, import_node_path.resolve)(filePath)) ?? "nearest"
308
- }));
175
+ function loadProjectDeeplineEnv(startDir = process.cwd()) {
176
+ const filePath = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
177
+ return filePath ? parseEnvFile(filePath) : {};
309
178
  }
310
179
  function normalizeBaseUrl(baseUrl) {
311
180
  const trimmed = baseUrl.trim().replace(/\/+$/, "");
@@ -350,23 +219,20 @@ function loadGlobalCliEnv() {
350
219
  return loadCliEnv(PROD_URL);
351
220
  }
352
221
  function autoDetectBaseUrl() {
353
- const projectEnvs = loadProjectEnvCandidates();
222
+ const projectEnv = loadProjectDeeplineEnv();
354
223
  const globalEnv = loadGlobalCliEnv();
355
- return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") || firstNonEmpty(
356
- ...projectEnvs.map(({ env }) => normalizeBaseUrl(env[HOST_URL_ENV]))
357
- ) || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
224
+ return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") || normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "") || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
358
225
  }
359
226
  function resolveApiKeyForBaseUrl(baseUrl, explicitApiKey) {
360
227
  const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
361
- const projectEnvs = loadProjectEnvCandidates();
228
+ const projectEnv = loadProjectDeeplineEnv();
362
229
  const cliEnv = loadCliEnv(normalizedBaseUrl || baseUrl);
230
+ const projectBaseUrl = normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "");
231
+ const projectKeyApplies = projectBaseUrl === normalizedBaseUrl;
363
232
  return firstNonEmpty(
364
233
  explicitApiKey,
365
234
  process.env[API_KEY_ENV],
366
- ...projectEnvs.map(({ env }) => {
367
- const projectBaseUrl = normalizeBaseUrl(env[HOST_URL_ENV] ?? "");
368
- return projectBaseUrl === normalizedBaseUrl ? env[API_KEY_ENV] : "";
369
- }),
235
+ projectKeyApplies ? projectEnv[API_KEY_ENV] : "",
370
236
  cliEnv[API_KEY_ENV]
371
237
  );
372
238
  }
@@ -418,10 +284,10 @@ var SDK_RELEASE = {
418
284
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
419
285
  // the SDK enrich generator's one-second stale policy.
420
286
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
421
- version: "0.1.138",
287
+ version: "0.1.139",
422
288
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
423
289
  supportPolicy: {
424
- latest: "0.1.138",
290
+ latest: "0.1.139",
425
291
  minimumSupported: "0.1.53",
426
292
  deprecatedBelow: "0.1.53",
427
293
  commandMinimumSupported: [
@@ -512,7 +378,7 @@ function normalizeAgentRuntime(value) {
512
378
  if (explicit === "gemini_cli") return "gemini";
513
379
  return EXPLICIT_AGENT_RUNTIMES.has(explicit) ? explicit : null;
514
380
  }
515
- function isCoworkLikeSandbox2() {
381
+ function isCoworkLikeSandbox() {
516
382
  const pluginMode = truthyEnv("DEEPLINE_PLUGIN_MODE");
517
383
  const claudeRemote = truthyEnv("CLAUDE_CODE_REMOTE");
518
384
  const projectDir = Boolean(process.env.CLAUDE_PROJECT_DIR?.trim());
@@ -525,7 +391,7 @@ function detectAgentRuntime(options = {}) {
525
391
  const explicit = normalizeAgentRuntime(process.env.DEEPLINE_AGENT_RUNTIME);
526
392
  if (explicit) return explicit;
527
393
  if (process.env.CODEX_THREAD_ID?.trim()) return "codex";
528
- if (options.detectCowork !== false && isCoworkLikeSandbox2()) {
394
+ if (options.detectCowork !== false && isCoworkLikeSandbox()) {
529
395
  return "claude_cowork";
530
396
  }
531
397
  if (process.env.CLAUDECODE?.trim() === "1") return "claude_code";
@@ -991,7 +857,7 @@ function sleep(ms) {
991
857
  return new Promise((resolve2) => setTimeout(resolve2, ms));
992
858
  }
993
859
  function withCoworkNetworkHint(message) {
994
- if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
860
+ if (!isCoworkLikeSandbox() || message.includes(COWORK_NETWORK_HINT)) {
995
861
  return message;
996
862
  }
997
863
  return `${message}
package/dist/index.mjs CHANGED
@@ -1,13 +1,5 @@
1
1
  // src/config.ts
2
- import {
3
- existsSync,
4
- mkdirSync,
5
- readdirSync,
6
- realpathSync,
7
- readFileSync,
8
- statSync,
9
- writeFileSync
10
- } from "fs";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
11
3
  import { homedir } from "os";
12
4
  import { dirname, join, resolve } from "path";
13
5
 
@@ -57,22 +49,6 @@ var PROD_URL = "https://code.deepline.com";
57
49
  var DEFAULT_TIMEOUT = 6e4;
58
50
  var DEFAULT_MAX_RETRIES = 3;
59
51
  var PROJECT_DEEPLINE_ENV_FILE = ".env.deepline";
60
- var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
61
- ".auto-memory",
62
- ".claude",
63
- ".remote-plugins",
64
- "outputs",
65
- "plugins",
66
- "uploads"
67
- ]);
68
- var COWORK_PROJECT_MARKERS = [
69
- ".deepline",
70
- ".env.deepline",
71
- ".git",
72
- "AGENTS.md",
73
- "package.json",
74
- "pyproject.toml"
75
- ];
76
52
  function baseUrlSlug(baseUrl) {
77
53
  let url;
78
54
  try {
@@ -118,124 +94,9 @@ function findNearestEnvFile(name, startDir = process.cwd()) {
118
94
  current = parent;
119
95
  }
120
96
  }
121
- function isDirectory(path) {
122
- try {
123
- return statSync(path).isDirectory();
124
- } catch {
125
- return false;
126
- }
127
- }
128
- function canonicalPath(path) {
129
- try {
130
- return realpathSync(path);
131
- } catch {
132
- return resolve(path);
133
- }
134
- }
135
- function isTruthy(value) {
136
- return /^(1|true|yes|on)$/i.test(value?.trim() ?? "");
137
- }
138
- function sessionRootFromPath(path) {
139
- const trimmed = path?.trim();
140
- if (!trimmed) return null;
141
- const match = /^\/sessions\/[^/]+(?=\/|$)/.exec(trimmed);
142
- return match?.[0] ?? null;
143
- }
144
- function coworkSessionRoot() {
145
- const home = process.env.HOME?.trim();
146
- const homeSessionRoot = sessionRootFromPath(home);
147
- if (homeSessionRoot && isDirectory(join(homeSessionRoot, "mnt"))) {
148
- return homeSessionRoot;
149
- }
150
- const cwdSessionRoot = sessionRootFromPath(process.cwd());
151
- if (cwdSessionRoot && isDirectory(join(cwdSessionRoot, "mnt"))) {
152
- return cwdSessionRoot;
153
- }
154
- if (isTruthy(process.env.CLAUDE_CODE_REMOTE) && home) {
155
- const mountedRoot = join(home, "mnt");
156
- if (isDirectory(mountedRoot)) return resolve(home);
157
- }
158
- return null;
159
- }
160
- function isCoworkLikeSandbox() {
161
- const home = process.env.HOME?.trim();
162
- return isTruthy(process.env.CLAUDE_CODE_REMOTE) || sessionRootFromPath(home) !== null || sessionRootFromPath(process.cwd()) !== null;
163
- }
164
- function coworkProjectScore(path) {
165
- let score = 0;
166
- for (const marker of COWORK_PROJECT_MARKERS) {
167
- if (existsSync(join(path, marker))) score += 1;
168
- }
169
- return score;
170
- }
171
- function listCoworkWorkspaceDirCandidates() {
172
- if (!isCoworkLikeSandbox()) {
173
- return [];
174
- }
175
- const explicitProjectDir = process.env.CLAUDE_PROJECT_DIR?.trim();
176
- if (explicitProjectDir && isDirectory(explicitProjectDir)) {
177
- return [resolve(explicitProjectDir)];
178
- }
179
- const sessionRoot = coworkSessionRoot();
180
- if (!sessionRoot) return [];
181
- const mountedRoot = join(sessionRoot, "mnt");
182
- if (!isDirectory(mountedRoot)) return [];
183
- let names;
184
- try {
185
- names = readdirSync(mountedRoot).sort();
186
- } catch {
187
- return [];
188
- }
189
- const candidates = [];
190
- for (const name of names) {
191
- if (name.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(name)) {
192
- continue;
193
- }
194
- const candidate = join(mountedRoot, name);
195
- if (isDirectory(candidate)) candidates.push(candidate);
196
- }
197
- if (candidates.length <= 1) return candidates;
198
- const projectLike = candidates.filter(
199
- (candidate) => coworkProjectScore(candidate) > 0
200
- );
201
- return projectLike.length > 0 ? projectLike : candidates;
202
- }
203
- function isInIgnoredCoworkMount(path) {
204
- const sessionRoot = coworkSessionRoot();
205
- if (!sessionRoot) return false;
206
- const mountedRoot = canonicalPath(join(sessionRoot, "mnt"));
207
- const resolvedPath = canonicalPath(path);
208
- const prefix = `${mountedRoot}/`;
209
- if (!resolvedPath.startsWith(prefix)) return false;
210
- const relativePath = resolvedPath.slice(prefix.length);
211
- const mountName = relativePath.split("/")[0];
212
- return mountName.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(mountName);
213
- }
214
- function detectCoworkWorkspaceDir() {
215
- const candidates = listCoworkWorkspaceDirCandidates();
216
- return candidates.length === 1 ? candidates[0] : null;
217
- }
218
- function loadProjectEnvCandidates(startDir = process.cwd()) {
219
- const filePaths = [];
220
- const sources = /* @__PURE__ */ new Map();
221
- const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
222
- if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
223
- filePaths.push(nearestFile);
224
- sources.set(resolve(nearestFile), "nearest");
225
- }
226
- const coworkWorkspaceDir = detectCoworkWorkspaceDir();
227
- if (coworkWorkspaceDir) {
228
- const coworkFile = join(coworkWorkspaceDir, PROJECT_DEEPLINE_ENV_FILE);
229
- if (existsSync(coworkFile) && !filePaths.some((filePath) => resolve(filePath) === resolve(coworkFile))) {
230
- filePaths.push(coworkFile);
231
- sources.set(resolve(coworkFile), "cowork");
232
- }
233
- }
234
- return filePaths.map((filePath) => ({
235
- filePath,
236
- env: parseEnvFile(filePath),
237
- source: sources.get(resolve(filePath)) ?? "nearest"
238
- }));
97
+ function loadProjectDeeplineEnv(startDir = process.cwd()) {
98
+ const filePath = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
99
+ return filePath ? parseEnvFile(filePath) : {};
239
100
  }
240
101
  function normalizeBaseUrl(baseUrl) {
241
102
  const trimmed = baseUrl.trim().replace(/\/+$/, "");
@@ -280,23 +141,20 @@ function loadGlobalCliEnv() {
280
141
  return loadCliEnv(PROD_URL);
281
142
  }
282
143
  function autoDetectBaseUrl() {
283
- const projectEnvs = loadProjectEnvCandidates();
144
+ const projectEnv = loadProjectDeeplineEnv();
284
145
  const globalEnv = loadGlobalCliEnv();
285
- return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") || firstNonEmpty(
286
- ...projectEnvs.map(({ env }) => normalizeBaseUrl(env[HOST_URL_ENV]))
287
- ) || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
146
+ return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") || normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "") || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
288
147
  }
289
148
  function resolveApiKeyForBaseUrl(baseUrl, explicitApiKey) {
290
149
  const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
291
- const projectEnvs = loadProjectEnvCandidates();
150
+ const projectEnv = loadProjectDeeplineEnv();
292
151
  const cliEnv = loadCliEnv(normalizedBaseUrl || baseUrl);
152
+ const projectBaseUrl = normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "");
153
+ const projectKeyApplies = projectBaseUrl === normalizedBaseUrl;
293
154
  return firstNonEmpty(
294
155
  explicitApiKey,
295
156
  process.env[API_KEY_ENV],
296
- ...projectEnvs.map(({ env }) => {
297
- const projectBaseUrl = normalizeBaseUrl(env[HOST_URL_ENV] ?? "");
298
- return projectBaseUrl === normalizedBaseUrl ? env[API_KEY_ENV] : "";
299
- }),
157
+ projectKeyApplies ? projectEnv[API_KEY_ENV] : "",
300
158
  cliEnv[API_KEY_ENV]
301
159
  );
302
160
  }
@@ -348,10 +206,10 @@ var SDK_RELEASE = {
348
206
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
349
207
  // the SDK enrich generator's one-second stale policy.
350
208
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
351
- version: "0.1.138",
209
+ version: "0.1.139",
352
210
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
353
211
  supportPolicy: {
354
- latest: "0.1.138",
212
+ latest: "0.1.139",
355
213
  minimumSupported: "0.1.53",
356
214
  deprecatedBelow: "0.1.53",
357
215
  commandMinimumSupported: [
@@ -442,7 +300,7 @@ function normalizeAgentRuntime(value) {
442
300
  if (explicit === "gemini_cli") return "gemini";
443
301
  return EXPLICIT_AGENT_RUNTIMES.has(explicit) ? explicit : null;
444
302
  }
445
- function isCoworkLikeSandbox2() {
303
+ function isCoworkLikeSandbox() {
446
304
  const pluginMode = truthyEnv("DEEPLINE_PLUGIN_MODE");
447
305
  const claudeRemote = truthyEnv("CLAUDE_CODE_REMOTE");
448
306
  const projectDir = Boolean(process.env.CLAUDE_PROJECT_DIR?.trim());
@@ -455,7 +313,7 @@ function detectAgentRuntime(options = {}) {
455
313
  const explicit = normalizeAgentRuntime(process.env.DEEPLINE_AGENT_RUNTIME);
456
314
  if (explicit) return explicit;
457
315
  if (process.env.CODEX_THREAD_ID?.trim()) return "codex";
458
- if (options.detectCowork !== false && isCoworkLikeSandbox2()) {
316
+ if (options.detectCowork !== false && isCoworkLikeSandbox()) {
459
317
  return "claude_cowork";
460
318
  }
461
319
  if (process.env.CLAUDECODE?.trim() === "1") return "claude_code";
@@ -921,7 +779,7 @@ function sleep(ms) {
921
779
  return new Promise((resolve2) => setTimeout(resolve2, ms));
922
780
  }
923
781
  function withCoworkNetworkHint(message) {
924
- if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
782
+ if (!isCoworkLikeSandbox() || message.includes(COWORK_NETWORK_HINT)) {
925
783
  return message;
926
784
  }
927
785
  return `${message}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.138",
3
+ "version": "0.1.139",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {