@alook/cli 0.0.103 → 0.0.105

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
@@ -15,12 +15,10 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/index.ts
18
- import { Command as Command12 } from "commander";
18
+ import { Command as Command13 } from "commander";
19
19
 
20
20
  // commands/register.ts
21
21
  import { Command } from "commander";
22
- import { execSync } from "child_process";
23
- import { hostname as hostname4 } from "os";
24
22
 
25
23
  // lib/client.ts
26
24
  class APIClient {
@@ -106,51 +104,6 @@ class APIClient {
106
104
  }
107
105
  }
108
106
 
109
- // lib/config.ts
110
- import { readFileSync, writeFileSync, mkdirSync } from "fs";
111
- import { join } from "path";
112
- import { homedir } from "os";
113
- function configDir() {
114
- return process.env.ALOOK_PROJECT_ROOT || join(homedir(), ".alook");
115
- }
116
- function configPath() {
117
- return join(configDir(), "config.json");
118
- }
119
- function loadCLIConfig() {
120
- try {
121
- return JSON.parse(readFileSync(configPath(), "utf-8"));
122
- } catch {
123
- return {};
124
- }
125
- }
126
- function loadCLIConfigForProfile(profile) {
127
- const cfg = loadCLIConfig();
128
- const profileName = profile || cfg.default_profile;
129
- if (profileName && cfg.profiles?.[profileName]) {
130
- return cfg.profiles[profileName];
131
- }
132
- return {
133
- server_url: cfg.server_url || "",
134
- watched_workspaces: cfg.watched_workspaces || []
135
- };
136
- }
137
- function saveCLIConfig(cfg) {
138
- mkdirSync(configDir(), { recursive: true, mode: 448 });
139
- writeFileSync(configPath(), JSON.stringify(cfg, null, 2), { mode: 384 });
140
- }
141
- function saveCLIConfigForProfile(profile, profileConfig) {
142
- const cfg = loadCLIConfig();
143
- if (profile) {
144
- if (!cfg.profiles)
145
- cfg.profiles = {};
146
- cfg.profiles[profile] = profileConfig;
147
- } else {
148
- cfg.server_url = profileConfig.server_url;
149
- cfg.watched_workspaces = profileConfig.watched_workspaces;
150
- }
151
- saveCLIConfig(cfg);
152
- }
153
-
154
107
  // ../shared/src/constants.ts
155
108
  var TaskStatus = {
156
109
  QUEUED: "queued",
@@ -14963,9 +14916,10 @@ var RecruitAgentRequestSchema = exports_external.object({
14963
14916
  relationship: exports_external.string().min(1, "relationship is required"),
14964
14917
  name: exports_external.string().optional(),
14965
14918
  description: exports_external.string().optional().default(""),
14966
- model: exports_external.string().max(100).optional()
14919
+ model: exports_external.string().max(100).optional(),
14920
+ context_key: exports_external.string().optional()
14967
14921
  });
14968
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/entity.js
14922
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/entity.js
14969
14923
  var entityKind = Symbol.for("drizzle:entityKind");
14970
14924
  var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
14971
14925
  function is(value, type) {
@@ -14990,10 +14944,10 @@ function is(value, type) {
14990
14944
  return false;
14991
14945
  }
14992
14946
 
14993
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/table.utils.js
14947
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/table.utils.js
14994
14948
  var TableName = Symbol.for("drizzle:Name");
14995
14949
 
14996
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/table.js
14950
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/table.js
14997
14951
  var Schema = Symbol.for("drizzle:Schema");
14998
14952
  var Columns = Symbol.for("drizzle:Columns");
14999
14953
  var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
@@ -15031,7 +14985,7 @@ class Table {
15031
14985
  }
15032
14986
  }
15033
14987
 
15034
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/column.js
14988
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/column.js
15035
14989
  class Column {
15036
14990
  constructor(table, config2) {
15037
14991
  this.table = table;
@@ -15081,7 +15035,7 @@ class Column {
15081
15035
  }
15082
15036
  }
15083
15037
 
15084
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/column-builder.js
15038
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/column-builder.js
15085
15039
  class ColumnBuilder {
15086
15040
  static [entityKind] = "ColumnBuilder";
15087
15041
  config;
@@ -15137,17 +15091,17 @@ class ColumnBuilder {
15137
15091
  }
15138
15092
  }
15139
15093
 
15140
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/tracing-utils.js
15094
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/tracing-utils.js
15141
15095
  function iife(fn, ...args) {
15142
15096
  return fn(...args);
15143
15097
  }
15144
15098
 
15145
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/pg-core/unique-constraint.js
15099
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/pg-core/unique-constraint.js
15146
15100
  function uniqueKeyName(table, columns) {
15147
15101
  return `${table[TableName]}_${columns.join("_")}_unique`;
15148
15102
  }
15149
15103
 
15150
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/pg-core/columns/common.js
15104
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/pg-core/columns/common.js
15151
15105
  class PgColumn extends Column {
15152
15106
  constructor(table, config2) {
15153
15107
  if (!config2.uniqueName) {
@@ -15196,7 +15150,7 @@ class ExtraConfigColumn extends PgColumn {
15196
15150
  }
15197
15151
  }
15198
15152
 
15199
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/pg-core/columns/enum.js
15153
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/pg-core/columns/enum.js
15200
15154
  class PgEnumObjectColumn extends PgColumn {
15201
15155
  static [entityKind] = "PgEnumObjectColumn";
15202
15156
  enum;
@@ -15226,7 +15180,7 @@ class PgEnumColumn extends PgColumn {
15226
15180
  }
15227
15181
  }
15228
15182
 
15229
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/subquery.js
15183
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/subquery.js
15230
15184
  class Subquery {
15231
15185
  static [entityKind] = "Subquery";
15232
15186
  constructor(sql, fields, alias, isWith = false, usedTables = []) {
@@ -15241,10 +15195,10 @@ class Subquery {
15241
15195
  }
15242
15196
  }
15243
15197
 
15244
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/version.js
15198
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/version.js
15245
15199
  var version2 = "0.45.2";
15246
15200
 
15247
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/tracing.js
15201
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/tracing.js
15248
15202
  var otel;
15249
15203
  var rawTracer;
15250
15204
  var tracer = {
@@ -15271,10 +15225,10 @@ var tracer = {
15271
15225
  }
15272
15226
  };
15273
15227
 
15274
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/view-common.js
15228
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/view-common.js
15275
15229
  var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
15276
15230
 
15277
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sql/sql.js
15231
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sql/sql.js
15278
15232
  function isSQLWrapper(value) {
15279
15233
  return value !== null && value !== undefined && typeof value.getSQL === "function";
15280
15234
  }
@@ -15551,7 +15505,7 @@ function sql(strings, ...params) {
15551
15505
  return new SQL([new StringChunk(str)]);
15552
15506
  }
15553
15507
  sql2.raw = raw;
15554
- function join2(chunks, separator) {
15508
+ function join(chunks, separator) {
15555
15509
  const result = [];
15556
15510
  for (const [i, chunk] of chunks.entries()) {
15557
15511
  if (i > 0 && separator !== undefined) {
@@ -15561,7 +15515,7 @@ function sql(strings, ...params) {
15561
15515
  }
15562
15516
  return new SQL(result);
15563
15517
  }
15564
- sql2.join = join2;
15518
+ sql2.join = join;
15565
15519
  function identifier(value) {
15566
15520
  return new Name(value);
15567
15521
  }
@@ -15634,7 +15588,7 @@ Subquery.prototype.getSQL = function() {
15634
15588
  return new SQL([this]);
15635
15589
  };
15636
15590
 
15637
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/utils.js
15591
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/utils.js
15638
15592
  function getColumnNameAndConfig(a, b) {
15639
15593
  return {
15640
15594
  name: typeof a === "string" && a.length > 0 ? a : "",
@@ -15643,7 +15597,7 @@ function getColumnNameAndConfig(a, b) {
15643
15597
  }
15644
15598
  var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
15645
15599
 
15646
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
15600
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
15647
15601
  class ForeignKeyBuilder {
15648
15602
  static [entityKind] = "SQLiteForeignKeyBuilder";
15649
15603
  reference;
@@ -15711,7 +15665,7 @@ function foreignKey(config2) {
15711
15665
  return new ForeignKeyBuilder(mappedConfig);
15712
15666
  }
15713
15667
 
15714
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
15668
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
15715
15669
  function uniqueKeyName2(table, columns) {
15716
15670
  return `${table[TableName]}_${columns.join("_")}_unique`;
15717
15671
  }
@@ -15756,7 +15710,7 @@ class UniqueConstraint {
15756
15710
  }
15757
15711
  }
15758
15712
 
15759
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/common.js
15713
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/common.js
15760
15714
  class SQLiteColumnBuilder extends ColumnBuilder {
15761
15715
  static [entityKind] = "SQLiteColumnBuilder";
15762
15716
  foreignKeyConfigs = [];
@@ -15807,7 +15761,7 @@ class SQLiteColumn extends Column {
15807
15761
  static [entityKind] = "SQLiteColumn";
15808
15762
  }
15809
15763
 
15810
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/blob.js
15764
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/blob.js
15811
15765
  class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
15812
15766
  static [entityKind] = "SQLiteBigIntBuilder";
15813
15767
  constructor(name) {
@@ -15895,7 +15849,7 @@ function blob(a, b) {
15895
15849
  return new SQLiteBlobBufferBuilder(name);
15896
15850
  }
15897
15851
 
15898
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/custom.js
15852
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/custom.js
15899
15853
  class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
15900
15854
  static [entityKind] = "SQLiteCustomColumnBuilder";
15901
15855
  constructor(name, fieldConfig, customTypeParams) {
@@ -15936,7 +15890,7 @@ function customType(customTypeParams) {
15936
15890
  };
15937
15891
  }
15938
15892
 
15939
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/integer.js
15893
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/integer.js
15940
15894
  class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
15941
15895
  static [entityKind] = "SQLiteBaseIntegerBuilder";
15942
15896
  constructor(name, dataType, columnType) {
@@ -16038,7 +15992,7 @@ function integer2(a, b) {
16038
15992
  return new SQLiteIntegerBuilder(name);
16039
15993
  }
16040
15994
 
16041
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
15995
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
16042
15996
  class SQLiteNumericBuilder extends SQLiteColumnBuilder {
16043
15997
  static [entityKind] = "SQLiteNumericBuilder";
16044
15998
  constructor(name) {
@@ -16108,7 +16062,7 @@ function numeric(a, b) {
16108
16062
  return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
16109
16063
  }
16110
16064
 
16111
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/real.js
16065
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/real.js
16112
16066
  class SQLiteRealBuilder extends SQLiteColumnBuilder {
16113
16067
  static [entityKind] = "SQLiteRealBuilder";
16114
16068
  constructor(name) {
@@ -16129,7 +16083,7 @@ function real(name) {
16129
16083
  return new SQLiteRealBuilder(name ?? "");
16130
16084
  }
16131
16085
 
16132
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/text.js
16086
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/text.js
16133
16087
  class SQLiteTextBuilder extends SQLiteColumnBuilder {
16134
16088
  static [entityKind] = "SQLiteTextBuilder";
16135
16089
  constructor(name, config2) {
@@ -16184,7 +16138,7 @@ function text(a, b = {}) {
16184
16138
  return new SQLiteTextBuilder(name, config2);
16185
16139
  }
16186
16140
 
16187
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/columns/all.js
16141
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/columns/all.js
16188
16142
  function getSQLiteColumnBuilders() {
16189
16143
  return {
16190
16144
  blob,
@@ -16196,7 +16150,7 @@ function getSQLiteColumnBuilders() {
16196
16150
  };
16197
16151
  }
16198
16152
 
16199
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/table.js
16153
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/table.js
16200
16154
  var InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
16201
16155
 
16202
16156
  class SQLiteTable extends Table {
@@ -16230,7 +16184,7 @@ var sqliteTable = (name, columns, extraConfig) => {
16230
16184
  return sqliteTableBase(name, columns, extraConfig);
16231
16185
  };
16232
16186
 
16233
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/indexes.js
16187
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/indexes.js
16234
16188
  class IndexBuilderOn {
16235
16189
  constructor(name, unique2) {
16236
16190
  this.name = name;
@@ -16273,7 +16227,7 @@ function index(name) {
16273
16227
  return new IndexBuilderOn(name, false);
16274
16228
  }
16275
16229
 
16276
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_bun-types@1.3.14_kysely@0.28.17/node_modules/drizzle-orm/sqlite-core/primary-keys.js
16230
+ // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260524.1_@opentelemetry+api@1.9.1_@typ_f775720d1395b789318c4e4a4fd2c362/node_modules/drizzle-orm/sqlite-core/primary-keys.js
16277
16231
  function primaryKey(...config2) {
16278
16232
  if (config2[0].columns) {
16279
16233
  return new PrimaryKeyBuilder(config2[0].columns, config2[0].name);
@@ -16935,6 +16889,54 @@ function cmdPrefix() {
16935
16889
  }));
16936
16890
  }
16937
16891
 
16892
+ // lib/activate.ts
16893
+ import { hostname as hostname4 } from "os";
16894
+
16895
+ // lib/config.ts
16896
+ import { readFileSync, writeFileSync, mkdirSync } from "fs";
16897
+ import { join } from "path";
16898
+ import { homedir } from "os";
16899
+ function configDir() {
16900
+ return process.env.ALOOK_PROJECT_ROOT || join(homedir(), ".alook");
16901
+ }
16902
+ function configPath() {
16903
+ return join(configDir(), "config.json");
16904
+ }
16905
+ function loadCLIConfig() {
16906
+ try {
16907
+ return JSON.parse(readFileSync(configPath(), "utf-8"));
16908
+ } catch {
16909
+ return {};
16910
+ }
16911
+ }
16912
+ function loadCLIConfigForProfile(profile) {
16913
+ const cfg = loadCLIConfig();
16914
+ const profileName = profile || cfg.default_profile;
16915
+ if (profileName && cfg.profiles?.[profileName]) {
16916
+ return cfg.profiles[profileName];
16917
+ }
16918
+ return {
16919
+ server_url: cfg.server_url || "",
16920
+ watched_workspaces: cfg.watched_workspaces || []
16921
+ };
16922
+ }
16923
+ function saveCLIConfig(cfg) {
16924
+ mkdirSync(configDir(), { recursive: true, mode: 448 });
16925
+ writeFileSync(configPath(), JSON.stringify(cfg, null, 2), { mode: 384 });
16926
+ }
16927
+ function saveCLIConfigForProfile(profile, profileConfig) {
16928
+ const cfg = loadCLIConfig();
16929
+ if (profile) {
16930
+ if (!cfg.profiles)
16931
+ cfg.profiles = {};
16932
+ cfg.profiles[profile] = profileConfig;
16933
+ } else {
16934
+ cfg.server_url = profileConfig.server_url;
16935
+ cfg.watched_workspaces = profileConfig.watched_workspaces;
16936
+ }
16937
+ saveCLIConfig(cfg);
16938
+ }
16939
+
16938
16940
  // daemon/pidfile.ts
16939
16941
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
16940
16942
  import { dirname as dirname2 } from "path";
@@ -17215,7 +17217,8 @@ function releaseDaemonPid(profile) {
17215
17217
  removePidFileIfMatches(process.pid, profile);
17216
17218
  }
17217
17219
 
17218
- // commands/register.ts
17220
+ // lib/runtimes.ts
17221
+ import { execSync } from "child_process";
17219
17222
  function isCommandAvailable(cmd) {
17220
17223
  try {
17221
17224
  const check2 = process.platform === "win32" ? `where ${cmd}` : `which ${cmd}`;
@@ -17238,6 +17241,90 @@ function detectRuntimes() {
17238
17241
  }
17239
17242
  return found;
17240
17243
  }
17244
+
17245
+ // lib/activate.ts
17246
+ async function activateAndSave(opts) {
17247
+ const { token, serverUrl, profile } = opts;
17248
+ console.log("Scanning for AI runtimes...");
17249
+ const runtimes = detectRuntimes();
17250
+ if (runtimes.length === 0) {
17251
+ console.error("Error: no runtimes found. Install claude, codex, or opencode first.");
17252
+ process.exit(1);
17253
+ }
17254
+ console.log(`Found: ${runtimes.map((r) => r.type).join(", ")}`);
17255
+ const host = hostname4();
17256
+ console.log("Registering runtime...");
17257
+ let activateResp;
17258
+ try {
17259
+ const res = await fetch(`${serverUrl}/api/machine-tokens/activate`, {
17260
+ method: "POST",
17261
+ headers: { "Content-Type": "application/json" },
17262
+ body: JSON.stringify({ token, hostname: host, runtimes })
17263
+ });
17264
+ if (!res.ok) {
17265
+ const text2 = await res.text();
17266
+ console.error(`Error: registration failed (${res.status}): ${text2}`);
17267
+ process.exit(1);
17268
+ }
17269
+ activateResp = await res.json();
17270
+ } catch (err) {
17271
+ console.error(`Error: failed to activate: ${err instanceof Error ? err.message : err}`);
17272
+ process.exit(1);
17273
+ }
17274
+ const client = new APIClient(serverUrl, token);
17275
+ let workspaces;
17276
+ try {
17277
+ workspaces = await client.getJSON("/api/workspaces");
17278
+ } catch (err) {
17279
+ console.error(`Error: failed to fetch workspaces: ${err instanceof Error ? err.message : err}`);
17280
+ process.exit(1);
17281
+ }
17282
+ if (!workspaces.length) {
17283
+ console.error("Error: no workspaces found for this user");
17284
+ process.exit(1);
17285
+ }
17286
+ const ws = workspaces.find((w) => w.id === activateResp.workspace_id) || workspaces[0];
17287
+ const wsClient = new APIClient(serverUrl, token, ws.id);
17288
+ let agentIds = [];
17289
+ try {
17290
+ const agents = await wsClient.getJSON(`/api/agents?workspace_id=${ws.id}`);
17291
+ agentIds = agents.map((a) => a.id);
17292
+ } catch {}
17293
+ const existing = loadCLIConfigForProfile(profile);
17294
+ const watched = existing.watched_workspaces || [];
17295
+ const idx = watched.findIndex((w) => w.id === ws.id);
17296
+ if (idx >= 0) {
17297
+ watched[idx] = { id: ws.id, name: ws.name, token, agent_ids: agentIds };
17298
+ } else {
17299
+ watched.push({ id: ws.id, name: ws.name, token, agent_ids: agentIds });
17300
+ }
17301
+ saveCLIConfigForProfile(profile, {
17302
+ server_url: serverUrl,
17303
+ watched_workspaces: watched
17304
+ });
17305
+ const daemonPid = readDaemonPid(profile);
17306
+ if (daemonPid && isProcessAlive(daemonPid)) {
17307
+ try {
17308
+ process.kill(daemonPid, "SIGHUP");
17309
+ console.log(`
17310
+ Daemon (pid ${daemonPid}) notified — workspace will be active shortly.`);
17311
+ } catch {
17312
+ console.log(`
17313
+ Daemon is running but could not be notified. Restart it to pick up the new workspace.`);
17314
+ }
17315
+ } else {
17316
+ const startCmd = isDev() ? `${cmdPrefix()} daemon start --foreground` : `${cmdPrefix()} daemon start`;
17317
+ console.log();
17318
+ console.log(`Run '${startCmd}' to start the daemon.`);
17319
+ }
17320
+ return {
17321
+ workspaceId: ws.id,
17322
+ workspaceName: ws.name,
17323
+ runtimeProviders: activateResp.runtimes.map((r) => r.provider)
17324
+ };
17325
+ }
17326
+
17327
+ // commands/register.ts
17241
17328
  function registerCommand() {
17242
17329
  const cmd = new Command("register").description("Register CLI with your Alook account").requiredOption("--token <token>", "API token (starts with al_)").option("--server <url>", "Server URL").option("--profile <name>", "Profile name").action(async (opts, command) => {
17243
17330
  const token = opts.token;
@@ -17260,89 +17347,182 @@ Usage: ${cmdPrefix()} register --token <token>`);
17260
17347
  console.error(`Error: failed to verify token: ${err instanceof Error ? err.message : err}`);
17261
17348
  process.exit(1);
17262
17349
  }
17263
- console.log("Scanning for AI runtimes...");
17264
- const runtimes = detectRuntimes();
17265
- if (runtimes.length === 0) {
17266
- console.error("Error: no runtimes found. Install claude, codex, or opencode first.");
17267
- process.exit(1);
17350
+ const result = await activateAndSave({ token, serverUrl, profile });
17351
+ console.log(`
17352
+ Registered as ${me.email}`);
17353
+ console.log(`Workspace: ${result.workspaceName} (${result.workspaceId})`);
17354
+ console.log(`Runtimes: ${result.runtimeProviders.join(", ")}`);
17355
+ });
17356
+ return cmd;
17357
+ }
17358
+
17359
+ // commands/login.ts
17360
+ import { Command as Command2 } from "commander";
17361
+ import { fork, spawn } from "child_process";
17362
+ import { fileURLToPath as fileURLToPath2 } from "url";
17363
+ var DEVICE_CLIENT_ID = process.env.ALOOK_DEVICE_CLIENT_ID || "alook-cli";
17364
+ function openBrowser(url2) {
17365
+ try {
17366
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : process.platform === "win32" ? "start" : null;
17367
+ if (cmd) {
17368
+ const args = process.platform === "win32" ? ["", url2] : [url2];
17369
+ spawn(cmd, args, { stdio: "ignore", detached: true }).unref();
17268
17370
  }
17269
- console.log(`Found: ${runtimes.map((r) => r.type).join(", ")}`);
17270
- const host = hostname4();
17271
- console.log("Registering runtime...");
17272
- let activateResp;
17371
+ } catch {}
17372
+ }
17373
+ function sleep(ms) {
17374
+ return new Promise((resolve) => setTimeout(resolve, ms));
17375
+ }
17376
+ async function pollAndActivate(opts) {
17377
+ const { deviceCode, expiresIn, serverUrl, profile } = opts;
17378
+ let interval = opts.interval;
17379
+ const expiresAt = Date.now() + expiresIn * 1000;
17380
+ let tokenResp;
17381
+ while (Date.now() < expiresAt) {
17382
+ await sleep(interval);
17273
17383
  try {
17274
- const res = await fetch(`${serverUrl}/api/machine-tokens/activate`, {
17384
+ const res = await fetch(`${serverUrl}/api/auth/device/token`, {
17275
17385
  method: "POST",
17276
17386
  headers: { "Content-Type": "application/json" },
17277
- body: JSON.stringify({ token, hostname: host, runtimes })
17387
+ body: JSON.stringify({
17388
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
17389
+ device_code: deviceCode,
17390
+ client_id: DEVICE_CLIENT_ID
17391
+ })
17278
17392
  });
17279
- if (!res.ok) {
17280
- const text2 = await res.text();
17281
- console.error(`Error: registration failed (${res.status}): ${text2}`);
17393
+ if (res.ok) {
17394
+ tokenResp = await res.json();
17395
+ break;
17396
+ }
17397
+ const errBody = await res.json();
17398
+ if (errBody.error === "slow_down") {
17399
+ interval += 5000;
17400
+ } else if (errBody.error === "authorization_pending") {} else if (errBody.error === "expired_token") {
17401
+ console.error("Error: device code expired. Please run login again.");
17402
+ process.exit(1);
17403
+ } else if (errBody.error === "access_denied") {
17404
+ console.error("Error: authorization was denied.");
17405
+ process.exit(1);
17406
+ } else {
17407
+ console.error(`Error: unexpected error: ${errBody.error_description || errBody.error}`);
17282
17408
  process.exit(1);
17283
17409
  }
17284
- activateResp = await res.json();
17285
- } catch (err) {
17286
- console.error(`Error: failed to activate: ${err instanceof Error ? err.message : err}`);
17410
+ } catch {
17411
+ console.error("Error: network request failed during polling.");
17287
17412
  process.exit(1);
17288
17413
  }
17289
- let workspaces;
17414
+ }
17415
+ if (!tokenResp) {
17416
+ console.error("Error: device code expired (timed out). Please run login again.");
17417
+ process.exit(1);
17418
+ }
17419
+ const sessionToken = tokenResp.access_token;
17420
+ const client = new APIClient(serverUrl, sessionToken);
17421
+ let email3 = "";
17422
+ try {
17423
+ const me = await client.getJSON("/api/me");
17424
+ email3 = me.email;
17425
+ } catch {}
17426
+ let existingWorkspaceId = "";
17427
+ try {
17428
+ const workspaces = await client.getJSON("/api/workspaces");
17429
+ if (workspaces.length > 0) {
17430
+ existingWorkspaceId = workspaces[0].id;
17431
+ }
17432
+ } catch {}
17433
+ const mtUrl = existingWorkspaceId ? `/api/machine-tokens?workspace_id=${existingWorkspaceId}` : "/api/machine-tokens";
17434
+ let machineToken2;
17435
+ try {
17436
+ const mtResp = await client.postJSON(mtUrl);
17437
+ machineToken2 = mtResp.token;
17438
+ } catch {
17439
+ process.exit(1);
17440
+ }
17441
+ const result = await activateAndSave({ token: machineToken2, serverUrl, profile });
17442
+ if (email3) {
17443
+ console.log(`
17444
+ Logged in as ${email3}`);
17445
+ }
17446
+ console.log(`Workspace: ${result.workspaceName} (${result.workspaceId})`);
17447
+ console.log(`Runtimes: ${result.runtimeProviders.join(", ")}`);
17448
+ }
17449
+ if (process.argv.includes("--__login-poll")) {
17450
+ const idx = process.argv.indexOf("--__login-poll");
17451
+ let data;
17452
+ try {
17453
+ data = JSON.parse(process.argv[idx + 1]);
17454
+ } catch {
17455
+ console.error("Error: invalid poll data");
17456
+ process.exit(1);
17457
+ }
17458
+ pollAndActivate(data).catch(() => process.exit(1));
17459
+ }
17460
+ function loginCommand() {
17461
+ const cmd = new Command2("login").description("Log in to Alook via browser (device code flow)").option("--server <url>", "Server URL").option("--profile <name>", "Profile name").action(async (opts, command) => {
17462
+ const profile = opts.profile || command.parent?.opts().profile;
17463
+ const serverUrl = opts.server || command.parent?.opts().server || process.env.ALOOK_SERVER_URL || "https://alook.ai";
17464
+ console.log("Requesting device code...");
17465
+ let deviceResp;
17290
17466
  try {
17291
- workspaces = await client.getJSON("/api/workspaces");
17467
+ const res = await fetch(`${serverUrl}/api/auth/device/code`, {
17468
+ method: "POST",
17469
+ headers: { "Content-Type": "application/json" },
17470
+ body: JSON.stringify({ client_id: DEVICE_CLIENT_ID })
17471
+ });
17472
+ if (!res.ok) {
17473
+ const text2 = await res.text();
17474
+ console.error(`Error: failed to get device code (${res.status}): ${text2}`);
17475
+ process.exit(1);
17476
+ }
17477
+ deviceResp = await res.json();
17292
17478
  } catch (err) {
17293
- console.error(`Error: failed to fetch workspaces: ${err instanceof Error ? err.message : err}`);
17294
- process.exit(1);
17295
- }
17296
- if (!workspaces.length) {
17297
- console.error("Error: no workspaces found for this user");
17479
+ console.error(`Error: failed to request device code: ${err instanceof Error ? err.message : err}`);
17298
17480
  process.exit(1);
17299
17481
  }
17300
- const ws = workspaces.find((w) => w.id === activateResp.workspace_id) || workspaces[0];
17301
- const wsClient = new APIClient(serverUrl, token, ws.id);
17302
- let agentIds = [];
17303
- try {
17304
- const agents = await wsClient.getJSON(`/api/agents?workspace_id=${ws.id}`);
17305
- agentIds = agents.map((a) => a.id);
17306
- } catch {}
17307
- const existing = loadCLIConfigForProfile(profile);
17308
- const watched = existing.watched_workspaces || [];
17309
- const idx = watched.findIndex((w) => w.id === ws.id);
17310
- if (idx >= 0) {
17311
- watched[idx] = { id: ws.id, name: ws.name, token, agent_ids: agentIds };
17312
- } else {
17313
- watched.push({ id: ws.id, name: ws.name, token, agent_ids: agentIds });
17482
+ const verificationUrl = deviceResp.verification_uri_complete || deviceResp.verification_uri;
17483
+ console.log();
17484
+ console.log(` Open this URL in your browser:`);
17485
+ console.log(` ${verificationUrl}`);
17486
+ console.log();
17487
+ console.log(` Enter code: ${deviceResp.user_code}`);
17488
+ console.log();
17489
+ if (!process.stdout.isTTY) {
17490
+ const pollData = JSON.stringify({
17491
+ deviceCode: deviceResp.device_code,
17492
+ interval: (deviceResp.interval || 5) * 1000,
17493
+ expiresIn: deviceResp.expires_in,
17494
+ serverUrl,
17495
+ profile
17496
+ });
17497
+ const thisFile = fileURLToPath2(import.meta.url);
17498
+ const child = fork(thisFile, ["--__login-poll", pollData], {
17499
+ detached: true,
17500
+ stdio: "ignore"
17501
+ });
17502
+ child.unref();
17503
+ console.log(" Polling for authorization in the background (timeout: 5min).");
17504
+ console.log(" Once approved, run `npx @alook/cli status` to verify.");
17505
+ return;
17314
17506
  }
17315
- saveCLIConfigForProfile(profile, {
17316
- server_url: serverUrl,
17317
- watched_workspaces: watched
17507
+ openBrowser(verificationUrl);
17508
+ console.log(" (Browser opened automatically)");
17509
+ console.log();
17510
+ console.log("Waiting for authorization...");
17511
+ await pollAndActivate({
17512
+ deviceCode: deviceResp.device_code,
17513
+ interval: (deviceResp.interval || 5) * 1000,
17514
+ expiresIn: deviceResp.expires_in,
17515
+ serverUrl,
17516
+ profile
17318
17517
  });
17319
- console.log(`
17320
- Registered as ${me.email}`);
17321
- console.log(`Workspace: ${ws.name} (${ws.id})`);
17322
- console.log(`Runtimes: ${activateResp.runtimes.map((r) => r.provider).join(", ")}`);
17323
- const daemonPid = readDaemonPid(profile);
17324
- if (daemonPid && isProcessAlive(daemonPid)) {
17325
- try {
17326
- process.kill(daemonPid, "SIGHUP");
17327
- console.log(`
17328
- Daemon (pid ${daemonPid}) notified — workspace will be active shortly.`);
17329
- } catch {
17330
- console.log(`
17331
- Daemon is running but could not be notified. Restart it to pick up the new workspace.`);
17332
- }
17333
- } else {
17334
- const startCmd = isDev() ? `${cmdPrefix()} daemon start --foreground` : `${cmdPrefix()} daemon start`;
17335
- console.log();
17336
- console.log(`Run '${startCmd}' to start the daemon.`);
17337
- }
17338
17518
  });
17339
17519
  return cmd;
17340
17520
  }
17341
17521
 
17342
17522
  // commands/status.ts
17343
- import { Command as Command2 } from "commander";
17523
+ import { Command as Command3 } from "commander";
17344
17524
  function statusCommand() {
17345
- const cmd = new Command2("status").description("Show registration status").action((_opts, command) => {
17525
+ const cmd = new Command3("status").description("Show registration status").action((_opts, command) => {
17346
17526
  const profile = command.parent?.opts().profile;
17347
17527
  const cfg = loadCLIConfigForProfile(profile);
17348
17528
  const ws = cfg.watched_workspaces?.[0];
@@ -17359,8 +17539,8 @@ function statusCommand() {
17359
17539
  }
17360
17540
 
17361
17541
  // commands/daemon.ts
17362
- import { Command as Command3 } from "commander";
17363
- import { spawn as spawn6 } from "child_process";
17542
+ import { Command as Command4 } from "commander";
17543
+ import { spawn as spawn7 } from "child_process";
17364
17544
  import { openSync as openSync2, closeSync as closeSync2, mkdirSync as mkdirSync9 } from "fs";
17365
17545
  import { dirname as dirname4 } from "path";
17366
17546
 
@@ -17516,7 +17696,7 @@ function createHealthServer(port = DEFAULT_HEALTH_PORT) {
17516
17696
  }
17517
17697
 
17518
17698
  // daemon/agent/claude.ts
17519
- import { spawn } from "child_process";
17699
+ import { spawn as spawn2 } from "child_process";
17520
17700
  import { createInterface } from "readline";
17521
17701
 
17522
17702
  class ClaudeBackend {
@@ -17544,7 +17724,7 @@ class ClaudeBackend {
17544
17724
  if (options.resumeSessionId) {
17545
17725
  args.push("--resume", options.resumeSessionId);
17546
17726
  }
17547
- const proc = spawn(this.cliPath, args, {
17727
+ const proc = spawn2(this.cliPath, args, {
17548
17728
  cwd: options.cwd,
17549
17729
  stdio: ["pipe", "pipe", "pipe"],
17550
17730
  env: { ...process.env, ...options.env },
@@ -17781,7 +17961,7 @@ function handleControlRequest(proc, event) {
17781
17961
  }
17782
17962
 
17783
17963
  // daemon/agent/codex.ts
17784
- import { spawn as spawn2 } from "child_process";
17964
+ import { spawn as spawn3 } from "child_process";
17785
17965
  import { createInterface as createInterface2 } from "readline";
17786
17966
  var RAW_DETECTION_METHODS = new Set([
17787
17967
  "turn/started",
@@ -17813,7 +17993,7 @@ class CodexBackend {
17813
17993
  this.cliPath = cliPath;
17814
17994
  }
17815
17995
  execute(prompt, options) {
17816
- const proc = spawn2(this.cliPath, ["app-server", "--listen", "stdio://", "--config", "sandbox_mode=danger-full-access"], {
17996
+ const proc = spawn3(this.cliPath, ["app-server", "--listen", "stdio://", "--config", "sandbox_mode=danger-full-access"], {
17817
17997
  cwd: options.cwd,
17818
17998
  stdio: ["pipe", "pipe", "pipe"],
17819
17999
  env: { ...process.env, ...options.env },
@@ -18285,7 +18465,7 @@ class CodexBackend {
18285
18465
  }
18286
18466
 
18287
18467
  // daemon/agent/opencode.ts
18288
- import { spawn as spawn3 } from "child_process";
18468
+ import { spawn as spawn4 } from "child_process";
18289
18469
  import { createInterface as createInterface3 } from "readline";
18290
18470
 
18291
18471
  class OpenCodeBackend {
@@ -18303,7 +18483,7 @@ class OpenCodeBackend {
18303
18483
  args.push("--session", options.resumeSessionId);
18304
18484
  }
18305
18485
  args.push(prompt);
18306
- const proc = spawn3(this.cliPath, args, {
18486
+ const proc = spawn4(this.cliPath, args, {
18307
18487
  cwd: options.cwd,
18308
18488
  stdio: ["ignore", "pipe", "pipe"],
18309
18489
  env: { ...process.env, ...options.env, OPENCODE_PERMISSION: '{"*":"allow"}' },
@@ -19077,7 +19257,7 @@ function localISOString() {
19077
19257
  function lockPathFor(timelineDir, filename) {
19078
19258
  return join7(timelineDir, `.${filename}.lock`);
19079
19259
  }
19080
- function sleep(ms) {
19260
+ function sleep2(ms) {
19081
19261
  return new Promise((resolve) => setTimeout(resolve, ms));
19082
19262
  }
19083
19263
  async function initEntryAsync(timelineDir, entry) {
@@ -19087,7 +19267,7 @@ async function initEntryAsync(timelineDir, entry) {
19087
19267
  try {
19088
19268
  let acquired = acquireLock(lockPath);
19089
19269
  if (!acquired) {
19090
- await sleep(200);
19270
+ await sleep2(200);
19091
19271
  acquired = acquireLock(lockPath);
19092
19272
  }
19093
19273
  if (!acquired) {
@@ -19889,7 +20069,7 @@ class DaemonWsClient {
19889
20069
  import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, unlinkSync as unlinkSync4 } from "fs";
19890
20070
 
19891
20071
  // lib/update.ts
19892
- import { spawn as spawn4 } from "child_process";
20072
+ import { spawn as spawn5 } from "child_process";
19893
20073
  function fetchLatestVersion() {
19894
20074
  return fetch("https://registry.npmjs.org/@alook/cli/latest").then((res) => {
19895
20075
  if (!res.ok)
@@ -19900,7 +20080,7 @@ function fetchLatestVersion() {
19900
20080
  function runNpmUpdate(targetVersion) {
19901
20081
  return new Promise((resolve) => {
19902
20082
  const chunks = [];
19903
- const child = spawn4("npm", ["install", "-g", `@alook/cli@${targetVersion}`], {
20083
+ const child = spawn5("npm", ["install", "-g", `@alook/cli@${targetVersion}`], {
19904
20084
  stdio: ["ignore", "pipe", "pipe"]
19905
20085
  });
19906
20086
  child.stdout?.on("data", (d) => chunks.push(d));
@@ -20453,11 +20633,11 @@ function resolveLoginShellEnv() {
20453
20633
  // daemon/daemon.ts
20454
20634
  import { existsSync as existsSync3, mkdirSync as mkdirSync8, openSync, closeSync, readdirSync as readdirSync3, statSync as statSync4, unlinkSync as unlinkSync5 } from "fs";
20455
20635
  import { readdir as readdir2, readFile as readFile2, unlink, stat as fsStat } from "fs/promises";
20456
- import { execSync as execSync4, spawn as spawn5 } from "child_process";
20457
- import { fileURLToPath as fileURLToPath2 } from "url";
20636
+ import { execSync as execSync4, spawn as spawn6 } from "child_process";
20637
+ import { fileURLToPath as fileURLToPath3 } from "url";
20458
20638
  import { dirname as dirname3, join as join11 } from "path";
20459
20639
  var log9 = createLogger2({ module: "daemon" });
20460
- var _dir = dirname3(fileURLToPath2(import.meta.url));
20640
+ var _dir = dirname3(fileURLToPath3(import.meta.url));
20461
20641
  var sessionRunnerPath = existsSync3(join11(_dir, "session-runner.js")) ? join11(_dir, "session-runner.js") : join11(_dir, "session-runner.ts");
20462
20642
  var meetingRunnerPath = existsSync3(join11(_dir, "meeting-runner.js")) ? join11(_dir, "meeting-runner.js") : join11(_dir, "meeting-runner.ts");
20463
20643
  function isCommandAvailable2(cmd) {
@@ -21018,7 +21198,7 @@ async function startDaemon(profile, serverUrl) {
21018
21198
  } catch (e) {
21019
21199
  log9.error(`Failed to open daemon log file ${logPath}`, e);
21020
21200
  }
21021
- const child = spawn5(process.execPath, args, {
21201
+ const child = spawn6(process.execPath, args, {
21022
21202
  detached: true,
21023
21203
  stdio: logFd != null ? ["ignore", logFd, logFd] : ["ignore", "ignore", "ignore"],
21024
21204
  env: resolveLoginShellEnv()
@@ -21093,7 +21273,7 @@ function spawnSessionRunner(input) {
21093
21273
  } catch (e) {
21094
21274
  log9.error(`Failed to open log file ${logFilePath}`, e);
21095
21275
  }
21096
- const child = spawn5(process.execPath, [sessionRunnerPath, encoded], {
21276
+ const child = spawn6(process.execPath, [sessionRunnerPath, encoded], {
21097
21277
  detached: true,
21098
21278
  stdio: fd != null ? ["ignore", fd, fd] : ["ignore", "ignore", "ignore"]
21099
21279
  });
@@ -21113,7 +21293,7 @@ function spawnMeetingRunner(input) {
21113
21293
  } catch (e) {
21114
21294
  log9.error(`Failed to open meeting log file ${logFilePath}`, e);
21115
21295
  }
21116
- const child = spawn5(process.execPath, [meetingRunnerPath, encoded], {
21296
+ const child = spawn6(process.execPath, [meetingRunnerPath, encoded], {
21117
21297
  detached: true,
21118
21298
  stdio: fd != null ? ["ignore", fd, fd] : ["ignore", "ignore", "ignore"]
21119
21299
  });
@@ -21322,7 +21502,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
21322
21502
  var PID_POLL_INTERVAL_MS = 200;
21323
21503
  var PID_POLL_TIMEOUT_MS = 2000;
21324
21504
  var STOP_POLL_INTERVAL_MS = 200;
21325
- function sleep2(ms) {
21505
+ function sleep3(ms) {
21326
21506
  return new Promise((r) => setTimeout(r, ms));
21327
21507
  }
21328
21508
  function buildChildArgs(profile, serverUrl) {
@@ -21341,7 +21521,7 @@ async function waitForPidFile(profile) {
21341
21521
  const pid = readDaemonPid(profile);
21342
21522
  if (pid != null && isProcessAlive(pid))
21343
21523
  return pid;
21344
- await sleep2(PID_POLL_INTERVAL_MS);
21524
+ await sleep3(PID_POLL_INTERVAL_MS);
21345
21525
  }
21346
21526
  return null;
21347
21527
  }
@@ -21355,7 +21535,7 @@ async function startInBackground(profile, serverUrl) {
21355
21535
  const logPath = daemonLogFilePath();
21356
21536
  mkdirSync9(dirname4(logPath), { recursive: true, mode: 448 });
21357
21537
  const logFd = openSync2(logPath, "a", 384);
21358
- const child = spawn6(process.execPath, buildChildArgs(profile, serverUrl), {
21538
+ const child = spawn7(process.execPath, buildChildArgs(profile, serverUrl), {
21359
21539
  detached: true,
21360
21540
  stdio: ["ignore", logFd, logFd],
21361
21541
  env: resolveLoginShellEnv()
@@ -21409,7 +21589,7 @@ async function stopCommand(profile) {
21409
21589
  console.log("Daemon stopped.");
21410
21590
  return;
21411
21591
  }
21412
- await sleep2(STOP_POLL_INTERVAL_MS);
21592
+ await sleep3(STOP_POLL_INTERVAL_MS);
21413
21593
  }
21414
21594
  console.warn(`Daemon did not exit within ${shutdownMs}ms — force killing.`);
21415
21595
  if (!isWindows) {
@@ -21421,7 +21601,7 @@ async function stopCommand(profile) {
21421
21601
  console.log("Daemon stopped.");
21422
21602
  }
21423
21603
  function daemonCommand2() {
21424
- const cmd = new Command3("daemon").description("Manage the Alook daemon");
21604
+ const cmd = new Command4("daemon").description("Manage the Alook daemon");
21425
21605
  cmd.command("start").description("Start the daemon").option("--foreground", "Run in foreground").option("--server <url>", "Server URL override").action(async (opts, command) => {
21426
21606
  const parentOpts = command.parent?.parent?.opts() || {};
21427
21607
  const profile = parentOpts.profile;
@@ -21444,7 +21624,7 @@ function daemonCommand2() {
21444
21624
  }
21445
21625
 
21446
21626
  // commands/config.ts
21447
- import { Command as Command4 } from "commander";
21627
+ import { Command as Command5 } from "commander";
21448
21628
 
21449
21629
  // lib/output.ts
21450
21630
  function printTable(headers, rows) {
@@ -21461,7 +21641,7 @@ function printJSON(data) {
21461
21641
 
21462
21642
  // commands/config.ts
21463
21643
  function configCommand() {
21464
- const cmd = new Command4("config").description("Manage CLI configuration");
21644
+ const cmd = new Command5("config").description("Manage CLI configuration");
21465
21645
  cmd.command("show").description("Show current configuration").action(() => {
21466
21646
  const cfg = loadCLIConfig();
21467
21647
  printJSON(cfg);
@@ -21473,7 +21653,7 @@ function configCommand() {
21473
21653
  }
21474
21654
 
21475
21655
  // commands/email.ts
21476
- import { Command as Command5 } from "commander";
21656
+ import { Command as Command6 } from "commander";
21477
21657
  import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readFileSync as readFileSync11 } from "fs";
21478
21658
  import { join as join12 } from "path";
21479
21659
  import PostalMime from "postal-mime";
@@ -21630,7 +21810,7 @@ var VALID_STATUSES = ["unread", "read", "archived", "sent"];
21630
21810
  var VALID_FOLDERS = ["inbox", "sent", "untrust"];
21631
21811
  var EMAIL_BASE = tempDir("alook-emails");
21632
21812
  function emailCommand() {
21633
- const cmd = new Command5("email").description("Manage agent emails");
21813
+ const cmd = new Command6("email").description("Manage agent emails");
21634
21814
  cmd.command("pull").description("Download and parse emails to /tmp/alook-emails/{workspaceId}/{agentId}/").option("--agent_id <id>", "Agent ID").option("--email_id <id>", "Fetch a single email by ID (mutually exclusive with --status/--folder/--limit/--offset)").option("--status <status>", "Filter by status (unread, read, archived)").option("--folder <folder>", "Email folder (inbox, sent, untrust)").option("--limit <n>", "Maximum number of emails to download").option("--offset <n>", "Number of emails to skip").option("--workspace <id>", "Workspace ID").option("--json", "Output as JSON instead of files").action(async (opts, command) => {
21635
21815
  const agentId = resolveAgentId(opts);
21636
21816
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, { workspace: opts.workspace, agentId });
@@ -21916,7 +22096,7 @@ function emailCommand() {
21916
22096
  process.exit(1);
21917
22097
  }
21918
22098
  });
21919
- const whitelistCmd = new Command5("whitelist").description("Manage email whitelist (allowed senders)");
22099
+ const whitelistCmd = new Command6("whitelist").description("Manage email whitelist (allowed senders)");
21920
22100
  whitelistCmd.command("list").description("List all whitelisted emails for an agent").option("--agent_id <id>", "Agent ID").option("--workspace <id>", "Workspace ID").option("--json", "Output as JSON").action(async (opts, command) => {
21921
22101
  const agentId = resolveAgentId(opts);
21922
22102
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, {
@@ -21990,7 +22170,7 @@ function emailCommand() {
21990
22170
  }
21991
22171
 
21992
22172
  // commands/calendar.ts
21993
- import { Command as Command6 } from "commander";
22173
+ import { Command as Command7 } from "commander";
21994
22174
  function parseLocalDatetime(input) {
21995
22175
  const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(input);
21996
22176
  if (!match) {
@@ -22021,7 +22201,7 @@ function printEventDetail(ev) {
22021
22201
  console.log(ev.description ?? "(no description)");
22022
22202
  }
22023
22203
  function calendarCommand() {
22024
- const cmd = new Command6("calendar").description("Manage scheduled agent events");
22204
+ const cmd = new Command7("calendar").description("Manage scheduled agent events");
22025
22205
  cmd.command("set").description("Create a calendar event").option("--agent_id <id>", "Agent ID").requiredOption("--event_title <title>", "Event title (used as the task prompt)").requiredOption("--datetime <iso>", "Scheduled datetime (YYYY-MM-DDTHH:MM, local time)").option("--description <text>", "Optional longer-form notes for the event").option("--repeat <interval>", "Repeat interval, e.g. 1day, 2hour, 1month").option("--repeat_stop_date <date>", "Stop repeating on or after this date (YYYY-MM-DD, local time)").option("--json", "Output as JSON").action(async (opts, command) => {
22026
22206
  const agentId = resolveAgentId(opts);
22027
22207
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, { agentId });
@@ -22193,7 +22373,7 @@ function calendarCommand() {
22193
22373
  }
22194
22374
 
22195
22375
  // commands/issue.ts
22196
- import { Command as Command7 } from "commander";
22376
+ import { Command as Command8 } from "commander";
22197
22377
  var VALID_STATUSES2 = ["todo", "in_progress", "review", "done", "closed", "canceled", "failed"];
22198
22378
  function printIssue(issue3) {
22199
22379
  console.log(`${issue3.id} ${issue3.status.padEnd(11)} ${issue3.title}`);
@@ -22225,7 +22405,7 @@ comments:`);
22225
22405
  }
22226
22406
  }
22227
22407
  function issueCommand() {
22228
- const cmd = new Command7("issue").description("Manage assigned issues");
22408
+ const cmd = new Command8("issue").description("Manage assigned issues");
22229
22409
  cmd.command("create").description("Create and dispatch an issue to an agent").option("--agent_id <id>", "Agent ID").requiredOption("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--body-file <path>", "Read issue description from a file").option("--json", "Output as JSON").action(async (opts, command) => {
22230
22410
  const agentId = resolveAgentId(opts);
22231
22411
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, { agentId });
@@ -22344,7 +22524,7 @@ function issueCommand() {
22344
22524
  }
22345
22525
 
22346
22526
  // commands/agent.ts
22347
- import { Command as Command8 } from "commander";
22527
+ import { Command as Command9 } from "commander";
22348
22528
  import { readFileSync as readFileSync12 } from "fs";
22349
22529
  function readField(opts, inlineName, fileName) {
22350
22530
  if (opts.inline && opts.file) {
@@ -22356,7 +22536,7 @@ function readField(opts, inlineName, fileName) {
22356
22536
  return opts.inline ?? null;
22357
22537
  }
22358
22538
  function agentCommand() {
22359
- const cmd = new Command8("agent").description("Manage agents");
22539
+ const cmd = new Command9("agent").description("Manage agents");
22360
22540
  cmd.command("recruit").description("Recruit a new colleague agent").option("--agent_id <id>", "Agent ID (or set ALOOK_AGENT_ID env var)").option("--instructions <text>", "Instructions for the new agent (system prompt)").option("--instructions-file <path>", "Read instructions from a file").option("--relationship <text>", "Relationship/delegation instruction for the link").option("--relationship-file <path>", "Read relationship from a file").option("--name <name>", "Preferred name for the new agent (auto-generated if omitted)").option("--description <text>", "Agent description").option("--model <model>", "Model override").option("--json", "Output as JSON").action(async (opts, command) => {
22361
22541
  const instructions = readField({ inline: opts.instructions, file: opts.instructionsFile }, "instructions", "instructions-file");
22362
22542
  if (!instructions) {
@@ -22371,6 +22551,7 @@ function agentCommand() {
22371
22551
  const agentId = resolveAgentId(opts);
22372
22552
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, { agentId });
22373
22553
  const client = new APIClient(serverUrl, token, workspaceId);
22554
+ const ctx = gatherContextEnvVars();
22374
22555
  const body = { instructions, relationship };
22375
22556
  if (opts.name)
22376
22557
  body.name = opts.name;
@@ -22378,6 +22559,8 @@ function agentCommand() {
22378
22559
  body.description = opts.description;
22379
22560
  if (opts.model)
22380
22561
  body.model = opts.model;
22562
+ if (ctx.conversationId)
22563
+ body.context_key = ctx.conversationId;
22381
22564
  try {
22382
22565
  const res = await client.postJSON(`/api/agents/recruit?agentId=${encodeURIComponent(agentId)}`, body);
22383
22566
  if (opts.json)
@@ -22392,18 +22575,18 @@ function agentCommand() {
22392
22575
  }
22393
22576
 
22394
22577
  // commands/version.ts
22395
- import { Command as Command9 } from "commander";
22578
+ import { Command as Command10 } from "commander";
22396
22579
  function versionCommand() {
22397
- const cmd = new Command9("version").description("Show CLI version").action(() => {
22580
+ const cmd = new Command10("version").description("Show CLI version").action(() => {
22398
22581
  console.log(`alook version ${getCurrentVersion()}`);
22399
22582
  });
22400
22583
  return cmd;
22401
22584
  }
22402
22585
 
22403
22586
  // commands/update.ts
22404
- import { Command as Command10 } from "commander";
22587
+ import { Command as Command11 } from "commander";
22405
22588
  function updateCommand() {
22406
- const cmd = new Command10("update").description("Update CLI to the latest version").action(async () => {
22589
+ const cmd = new Command11("update").description("Update CLI to the latest version").action(async () => {
22407
22590
  const current = getCurrentVersion();
22408
22591
  console.log(`Current version: ${current}`);
22409
22592
  const latest = await fetchLatestVersion();
@@ -22437,11 +22620,11 @@ ${result.output}`);
22437
22620
  }
22438
22621
 
22439
22622
  // commands/sync.ts
22440
- import { Command as Command11 } from "commander";
22623
+ import { Command as Command12 } from "commander";
22441
22624
  import { readFileSync as readFileSync13 } from "fs";
22442
22625
  import { basename as basename3 } from "path";
22443
22626
  function syncCommand() {
22444
- const cmd = new Command11("sync").description("File sync utilities");
22627
+ const cmd = new Command12("sync").description("File sync utilities");
22445
22628
  cmd.command("upload-artifact").description("Upload a file artifact to a conversation").option("--agent_id <id>", "Agent ID").requiredOption("--conversation_id <id>", "Conversation ID").requiredOption("--file <path>", "Path to file to upload").action(async (opts, command) => {
22446
22629
  const agentId = resolveAgentId(opts);
22447
22630
  const { serverUrl, token, workspaceId } = resolveClientOpts(command, { agentId });
@@ -22471,9 +22654,10 @@ function syncCommand() {
22471
22654
  }
22472
22655
 
22473
22656
  // src/index.ts
22474
- var program = new Command12;
22657
+ var program = new Command13;
22475
22658
  program.name("alook").description("Alook CLI").option("--server <url>", "Server URL").option("--profile <name>", "Profile name");
22476
22659
  program.addCommand(registerCommand());
22660
+ program.addCommand(loginCommand());
22477
22661
  program.addCommand(statusCommand());
22478
22662
  program.addCommand(daemonCommand2());
22479
22663
  program.addCommand(emailCommand());