@signetai/connector-gemini 0.154.4 → 0.154.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +156 -79
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -6,29 +6,32 @@ import {
6
6
  readFileSync as readFileSync2,
7
7
  readdirSync,
8
8
  readlinkSync,
9
- rmSync,
9
+ rmSync as rmSync2,
10
10
  unlinkSync as unlinkSync3,
11
- writeFileSync as writeFileSync2
11
+ writeFileSync as writeFileSync3
12
12
  } from "node:fs";
13
- import { homedir as homedir4 } from "node:os";
14
- import { dirname as dirname7, join as join6, resolve as resolve2, sep } from "node:path";
13
+ import { homedir as homedir5 } from "node:os";
14
+ import { dirname as dirname8, join as join6, resolve as resolve2, sep } from "node:path";
15
15
 
16
16
  // ../../../libs/connector-base/dist/index.js
17
17
  import { randomBytes } from "node:crypto";
18
- import { existsSync, readFileSync, renameSync, statSync, unlinkSync as unlinkSync2, writeFileSync } from "node:fs";
18
+ import { existsSync, readFileSync, renameSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync } from "node:fs";
19
19
  import { homedir } from "node:os";
20
- import { dirname as dirname2, join as join3, resolve } from "node:path";
20
+ import { dirname as dirname3, join as join3 } from "node:path";
21
21
  import { createRequire } from "node:module";
22
22
  import { dirname, join } from "node:path";
23
23
  import { fileURLToPath } from "node:url";
24
24
  import { homedir as homedir2 } from "os";
25
25
  import { join as join2 } from "path";
26
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
27
+ import { homedir as homedir3 } from "node:os";
28
+ import { dirname as dirname2, join as join5, resolve } from "node:path";
26
29
  import { createRequire as createRequire2 } from "node:module";
27
- import { homedir as homedir3, platform as platform2 } from "node:os";
28
- import { basename, dirname as dirname3, resolve as resolve3 } from "node:path";
29
- import { homedir as homedir7 } from "node:os";
30
- import { existsSync as existsSync12, lstatSync, mkdirSync as mkdirSync8, readdirSync as readdirSync6, symlinkSync, unlinkSync } from "node:fs";
31
- import { join as join12 } from "node:path";
30
+ import { homedir as homedir4, platform as platform2 } from "node:os";
31
+ import { basename, dirname as dirname4, resolve as resolve4 } from "node:path";
32
+ import { homedir as homedir8 } from "node:os";
33
+ import { existsSync as existsSync13, lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync6, symlinkSync, unlinkSync } from "node:fs";
34
+ import { join as join13 } from "node:path";
32
35
  var __create2 = Object.create;
33
36
  var __getProtoOf2 = Object.getPrototypeOf;
34
37
  var __defProp2 = Object.defineProperty;
@@ -10714,6 +10717,109 @@ function expandHome(p, home = homedir2()) {
10714
10717
  }
10715
10718
  var LOCAL_BINDS = new Set(["127.0.0.1", "localhost", "::1", "::ffff:127.0.0.1"]);
10716
10719
  var import_yaml2 = __toESM2(require_dist(), 1);
10720
+ var WORKSPACE_ENV_KEYS = ["SIGNET_PATH", "SIGNET_WORKSPACE"];
10721
+ var DEFAULT_AGENTS_DIRNAME = ".agents";
10722
+ function normalizeWorkspacePath(pathValue, home = homedir3()) {
10723
+ return resolve(expandHome(pathValue.trim(), home));
10724
+ }
10725
+ function readTrimmedEnv(env, name) {
10726
+ const value = env[name];
10727
+ if (typeof value !== "string")
10728
+ return;
10729
+ const trimmed = value.trim();
10730
+ return trimmed.length > 0 ? trimmed : undefined;
10731
+ }
10732
+ function readConfigHome(env, home) {
10733
+ const raw = env.XDG_CONFIG_HOME;
10734
+ if (typeof raw !== "string")
10735
+ return join5(home, ".config");
10736
+ const trimmed = raw.trim();
10737
+ return trimmed.length > 0 ? normalizeWorkspacePath(trimmed, home) : join5(home, ".config");
10738
+ }
10739
+ function isExistingDirectory(path) {
10740
+ try {
10741
+ return statSync(path).isDirectory();
10742
+ } catch {
10743
+ return false;
10744
+ }
10745
+ }
10746
+ function isRecord4(value) {
10747
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10748
+ }
10749
+ function getWorkspaceConfigPath(env = process.env, home = homedir3()) {
10750
+ return join5(readConfigHome(env, home), "signet", "workspace.json");
10751
+ }
10752
+ function readConfiguredWorkspacePath(env = process.env, home = homedir3(), options = {}) {
10753
+ const strict = options.strict ?? false;
10754
+ const configPath = getWorkspaceConfigPath(env, home);
10755
+ if (!existsSync4(configPath))
10756
+ return null;
10757
+ let raw;
10758
+ try {
10759
+ raw = JSON.parse(readFileSync3(configPath, "utf-8"));
10760
+ } catch (err) {
10761
+ if (strict) {
10762
+ const detail = err instanceof Error ? err.message : String(err);
10763
+ throw new Error(`Invalid Signet workspace config at ${configPath}: ${detail}`);
10764
+ }
10765
+ return null;
10766
+ }
10767
+ if (!isRecord4(raw) || !("workspace" in raw)) {
10768
+ if (strict)
10769
+ throw new Error(`Invalid Signet workspace config at ${configPath}: missing workspace`);
10770
+ return null;
10771
+ }
10772
+ const workspace = raw.workspace;
10773
+ if (typeof workspace !== "string" || workspace.trim().length === 0) {
10774
+ if (strict)
10775
+ throw new Error(`Invalid Signet workspace config at ${configPath}: workspace must be a non-empty string`);
10776
+ return null;
10777
+ }
10778
+ return normalizeWorkspacePath(workspace, home);
10779
+ }
10780
+ function resolveWorkspacePath(options = {}) {
10781
+ const env = options.env ?? process.env;
10782
+ const home = options.home ?? homedir3();
10783
+ const strict = options.strict ?? false;
10784
+ const requireExistingEnvPath = options.requireExistingEnvPath ?? false;
10785
+ const configPath = getWorkspaceConfigPath(env, home);
10786
+ const envPath = resolveEnvWorkspace(env, home, requireExistingEnvPath);
10787
+ const configValue = readConfiguredWorkspacePath(env, home, { strict: envPath ? false : strict });
10788
+ if (envPath) {
10789
+ return {
10790
+ path: envPath,
10791
+ source: "env",
10792
+ configPath,
10793
+ configuredPath: configValue
10794
+ };
10795
+ }
10796
+ if (configValue) {
10797
+ return {
10798
+ path: configValue,
10799
+ source: "config",
10800
+ configPath,
10801
+ configuredPath: configValue
10802
+ };
10803
+ }
10804
+ return {
10805
+ path: join5(home, DEFAULT_AGENTS_DIRNAME),
10806
+ source: "default",
10807
+ configPath,
10808
+ configuredPath: configValue
10809
+ };
10810
+ }
10811
+ function resolveEnvWorkspace(env, home, requireExisting) {
10812
+ for (const key of WORKSPACE_ENV_KEYS) {
10813
+ const raw = readTrimmedEnv(env, key);
10814
+ if (!raw)
10815
+ continue;
10816
+ const normalized = normalizeWorkspacePath(raw, home);
10817
+ if (!requireExisting || isExistingDirectory(normalized))
10818
+ return normalized;
10819
+ console.warn(`[signet] ${key}="${raw}" does not point to an existing workspace directory; using the default workspace resolution instead.`);
10820
+ }
10821
+ return null;
10822
+ }
10717
10823
  var native = null;
10718
10824
  try {
10719
10825
  const esmRequire = createRequire2(import.meta.url);
@@ -10788,11 +10894,11 @@ var VALID_GITHUB_RESOURCE_TYPES = new Set(DEFAULT_GITHUB_RESOURCE_TYPES);
10788
10894
  function defaultDiscordDesktopCachePath() {
10789
10895
  switch (platform2()) {
10790
10896
  case "darwin":
10791
- return resolve3(homedir3(), "Library", "Application Support", "discord");
10897
+ return resolve4(homedir4(), "Library", "Application Support", "discord");
10792
10898
  case "win32":
10793
- return resolve3(process.env.APPDATA || resolve3(homedir3(), "AppData", "Roaming"), "discord");
10899
+ return resolve4(process.env.APPDATA || resolve4(homedir4(), "AppData", "Roaming"), "discord");
10794
10900
  default:
10795
- return resolve3(process.env.XDG_CONFIG_HOME || resolve3(homedir3(), ".config"), "discord");
10901
+ return resolve4(process.env.XDG_CONFIG_HOME || resolve4(homedir4(), ".config"), "discord");
10796
10902
  }
10797
10903
  }
10798
10904
  var IDENTITY_FILES = {
@@ -10860,15 +10966,15 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
10860
10966
  skipped: [],
10861
10967
  errors: []
10862
10968
  };
10863
- if (!existsSync12(sourceDir)) {
10969
+ if (!existsSync13(sourceDir)) {
10864
10970
  return result;
10865
10971
  }
10866
- const targetParent = join12(targetDir, "..");
10867
- if (!existsSync12(targetParent)) {
10868
- mkdirSync8(targetParent, { recursive: true });
10972
+ const targetParent = join13(targetDir, "..");
10973
+ if (!existsSync13(targetParent)) {
10974
+ mkdirSync9(targetParent, { recursive: true });
10869
10975
  }
10870
- if (!existsSync12(targetDir)) {
10871
- mkdirSync8(targetDir, { recursive: true });
10976
+ if (!existsSync13(targetDir)) {
10977
+ mkdirSync9(targetDir, { recursive: true });
10872
10978
  }
10873
10979
  let entries;
10874
10980
  try {
@@ -10881,8 +10987,8 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
10881
10987
  return result;
10882
10988
  }
10883
10989
  for (const entry of entries) {
10884
- const srcPath = join12(sourceDir, entry);
10885
- const destPath = join12(targetDir, entry);
10990
+ const srcPath = join13(sourceDir, entry);
10991
+ const destPath = join13(targetDir, entry);
10886
10992
  try {
10887
10993
  const src = lstatSync(srcPath);
10888
10994
  if (src.isSymbolicLink() || !src.isDirectory()) {
@@ -10923,7 +11029,7 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
10923
11029
  }
10924
11030
  return result;
10925
11031
  }
10926
- var home = homedir7();
11032
+ var home = homedir8();
10927
11033
  var SIGNET_BLOCK_START = "<!-- SIGNET:START -->";
10928
11034
  var SIGNET_BLOCK_END = "<!-- SIGNET:END -->";
10929
11035
  function stripSignetBlock(content) {
@@ -11080,7 +11186,7 @@ class BaseConnector {
11080
11186
  generateHeader(sourcePath, targetName) {
11081
11187
  const name = targetName || this.name;
11082
11188
  const safe = (p) => p.replace(/[\n\r]/g, "");
11083
- const root = dirname2(sourcePath);
11189
+ const root = dirname3(sourcePath);
11084
11190
  return `# Auto-generated from ${safe(sourcePath)}
11085
11191
  # Source: ${safe(sourcePath)}
11086
11192
  # Generated: ${new Date().toISOString()}
@@ -11117,11 +11223,11 @@ function isSignetGeneratedFile(raw) {
11117
11223
  return lines.some((line, i) => /^#\s+AUTO-GENERATED\s+from\s+.*\s+by\s+Signet/i.test(line) || /^#\s+Auto-generated\s+from\s+/.test(line) && i + 1 < lines.length && /^#\s+Source:\s+/.test(lines[i + 1]));
11118
11224
  }
11119
11225
  function atomicWriteText(path, content, mode) {
11120
- const tmp = join3(dirname2(path), `.${randomBytes(6).toString("hex")}.tmp`);
11226
+ const tmp = join3(dirname3(path), `.${randomBytes(6).toString("hex")}.tmp`);
11121
11227
  let writeMode = mode;
11122
11228
  if (writeMode === undefined) {
11123
11229
  try {
11124
- writeMode = statSync(path).mode & 511;
11230
+ writeMode = statSync2(path).mode & 511;
11125
11231
  } catch {}
11126
11232
  }
11127
11233
  try {
@@ -11138,51 +11244,22 @@ function atomicWriteJson(path, data, indent = 2) {
11138
11244
  atomicWriteText(path, `${JSON.stringify(data, null, indent)}
11139
11245
  `);
11140
11246
  }
11141
- function readManagedTrimmedEnv(name) {
11142
- const value = process.env[name];
11143
- if (typeof value !== "string")
11144
- return;
11145
- const trimmed = value.trim();
11146
- return trimmed.length > 0 ? trimmed : undefined;
11147
- }
11148
11247
  function resolveSignetWorkspacePath(home2 = homedir()) {
11149
- const configured = readManagedTrimmedEnv("SIGNET_PATH");
11150
- if (configured)
11151
- return resolve(expandHome(configured));
11152
- const defaultWorkspace = join3(home2, ".agents");
11153
- const configHome = readManagedTrimmedEnv("XDG_CONFIG_HOME") ?? join3(home2, ".config");
11154
- const workspaceConfigPath = join3(configHome, "signet", "workspace.json");
11155
- if (!existsSync(workspaceConfigPath))
11156
- return defaultWorkspace;
11157
- let raw;
11158
- try {
11159
- raw = JSON.parse(readFileSync(workspaceConfigPath, "utf8"));
11160
- } catch (err) {
11161
- const detail = err instanceof Error ? err.message : String(err);
11162
- throw new Error(`Invalid Signet workspace config at ${workspaceConfigPath}: ${detail}`);
11163
- }
11164
- if (typeof raw !== "object" || raw === null || !("workspace" in raw)) {
11165
- throw new Error(`Invalid Signet workspace config at ${workspaceConfigPath}: missing workspace`);
11166
- }
11167
- const workspace = raw.workspace;
11168
- if (typeof workspace !== "string" || workspace.trim().length === 0) {
11169
- throw new Error(`Invalid Signet workspace config at ${workspaceConfigPath}: workspace must be a non-empty string`);
11170
- }
11171
- return resolve(expandHome(workspace.trim()));
11248
+ return resolveWorkspacePath({ home: home2, strict: true, requireExistingEnvPath: true }).path;
11172
11249
  }
11173
11250
 
11174
11251
  // ../../../platform/core/dist/index.js
11175
11252
  import { createRequire as createRequire3 } from "node:module";
11176
- import { dirname as dirname4, join as join4 } from "node:path";
11253
+ import { dirname as dirname5, join as join4 } from "node:path";
11177
11254
  import { fileURLToPath as fileURLToPath2 } from "node:url";
11178
11255
  import { homedir as homedir22 } from "os";
11179
11256
  import { join as join22 } from "path";
11180
11257
  import { createRequire as createRequire22 } from "node:module";
11181
- import { homedir as homedir32, platform as platform22 } from "node:os";
11182
- import { basename as basename2, dirname as dirname32, resolve as resolve32 } from "node:path";
11183
- import { existsSync as existsSync10, readFileSync as readFileSync8, readdirSync as readdirSync4, realpathSync, statSync as statSync4 } from "node:fs";
11184
- import { dirname as dirname6, join as join10 } from "node:path";
11185
- import { homedir as homedir72 } from "node:os";
11258
+ import { homedir as homedir42, platform as platform22 } from "node:os";
11259
+ import { basename as basename2, dirname as dirname42, resolve as resolve42 } from "node:path";
11260
+ import { existsSync as existsSync11, readFileSync as readFileSync9, readdirSync as readdirSync4, realpathSync, statSync as statSync5 } from "node:fs";
11261
+ import { dirname as dirname7, join as join11 } from "node:path";
11262
+ import { homedir as homedir82 } from "node:os";
11186
11263
  var __create = Object.create;
11187
11264
  var __getProtoOf = Object.getPrototypeOf;
11188
11265
  var __defProp = Object.defineProperty;
@@ -21857,7 +21934,7 @@ var MIGRATIONS2 = [
21857
21934
  ];
21858
21935
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
21859
21936
  var __filename22 = fileURLToPath2(import.meta.url);
21860
- var __dirname22 = dirname4(__filename22);
21937
+ var __dirname22 = dirname5(__filename22);
21861
21938
  var import_yaml3 = __toESM(require_dist2(), 1);
21862
21939
  function expandHome2(p, home2 = homedir22()) {
21863
21940
  if (p === "~")
@@ -21950,11 +22027,11 @@ var VALID_GITHUB_RESOURCE_TYPES2 = new Set(DEFAULT_GITHUB_RESOURCE_TYPES2);
21950
22027
  function defaultDiscordDesktopCachePath2() {
21951
22028
  switch (platform22()) {
21952
22029
  case "darwin":
21953
- return resolve32(homedir32(), "Library", "Application Support", "discord");
22030
+ return resolve42(homedir42(), "Library", "Application Support", "discord");
21954
22031
  case "win32":
21955
- return resolve32(process.env.APPDATA || resolve32(homedir32(), "AppData", "Roaming"), "discord");
22032
+ return resolve42(process.env.APPDATA || resolve42(homedir42(), "AppData", "Roaming"), "discord");
21956
22033
  default:
21957
- return resolve32(process.env.XDG_CONFIG_HOME || resolve32(homedir32(), ".config"), "discord");
22034
+ return resolve42(process.env.XDG_CONFIG_HOME || resolve42(homedir42(), ".config"), "discord");
21958
22035
  }
21959
22036
  }
21960
22037
  var IDENTITY_MODES = ["managed", "passthrough", "off"];
@@ -22019,7 +22096,7 @@ function hasValidIdentity(basePath) {
22019
22096
  return true;
22020
22097
  for (const key of REQUIRED_IDENTITY_KEYS2) {
22021
22098
  const spec = IDENTITY_FILES2[key];
22022
- if (!existsSync10(join10(basePath, spec.path))) {
22099
+ if (!existsSync11(join11(basePath, spec.path))) {
22023
22100
  return false;
22024
22101
  }
22025
22102
  }
@@ -22045,16 +22122,16 @@ function resolveIdentityModeFromConfig(config) {
22045
22122
  return "managed";
22046
22123
  }
22047
22124
  function loadIdentityMode(agentsDir) {
22048
- const agentYaml = join10(agentsDir, "agent.yaml");
22049
- if (!existsSync10(agentYaml))
22125
+ const agentYaml = join11(agentsDir, "agent.yaml");
22126
+ if (!existsSync11(agentYaml))
22050
22127
  return "managed";
22051
22128
  try {
22052
- return resolveIdentityModeFromConfig(parseSimpleYaml(readFileSync8(agentYaml, "utf-8")));
22129
+ return resolveIdentityModeFromConfig(parseSimpleYaml(readFileSync9(agentYaml, "utf-8")));
22053
22130
  } catch {
22054
22131
  return "managed";
22055
22132
  }
22056
22133
  }
22057
- var home2 = homedir72();
22134
+ var home2 = homedir82();
22058
22135
  var SKIP_SUBTYPES2 = new Set([
22059
22136
  "channel_join",
22060
22137
  "channel_leave",
@@ -22195,7 +22272,7 @@ class GeminiConnector extends BaseConnector {
22195
22272
  name = "Gemini";
22196
22273
  harnessId = "gemini";
22197
22274
  getGeminiHome() {
22198
- return join6(homedir4(), ".gemini");
22275
+ return join6(homedir5(), ".gemini");
22199
22276
  }
22200
22277
  getConfigPath() {
22201
22278
  return join6(this.getGeminiHome(), "settings.json");
@@ -22218,7 +22295,7 @@ class GeminiConnector extends BaseConnector {
22218
22295
  async install(basePath) {
22219
22296
  const filesWritten = [];
22220
22297
  const configsPatched = [];
22221
- const expandedBasePath = expandHome2(basePath || join6(homedir4(), ".agents"));
22298
+ const expandedBasePath = expandHome2(basePath || join6(homedir5(), ".agents"));
22222
22299
  const identityMode = loadIdentityMode(expandedBasePath);
22223
22300
  if (!hasValidIdentity(expandedBasePath)) {
22224
22301
  return {
@@ -22253,7 +22330,7 @@ class GeminiConnector extends BaseConnector {
22253
22330
  try {
22254
22331
  const raw = readFileSync2(staleGeminiMd, "utf-8");
22255
22332
  if (isSignetGeneratedFile(raw)) {
22256
- rmSync(staleGeminiMd);
22333
+ rmSync2(staleGeminiMd);
22257
22334
  }
22258
22335
  } catch {}
22259
22336
  }
@@ -22283,7 +22360,7 @@ class GeminiConnector extends BaseConnector {
22283
22360
  if (existsSync2(geminiMdPath)) {
22284
22361
  const raw = readFileSync2(geminiMdPath, "utf-8");
22285
22362
  if (isSignetGeneratedFile(raw)) {
22286
- rmSync(geminiMdPath);
22363
+ rmSync2(geminiMdPath);
22287
22364
  filesRemoved.push(geminiMdPath);
22288
22365
  }
22289
22366
  }
@@ -22301,7 +22378,7 @@ class GeminiConnector extends BaseConnector {
22301
22378
  return isJsonObject(mcpServers) && "signet" in mcpServers;
22302
22379
  }
22303
22380
  static isHarnessInstalled() {
22304
- return existsSync2(join6(homedir4(), ".gemini", "settings.json"));
22381
+ return existsSync2(join6(homedir5(), ".gemini", "settings.json"));
22305
22382
  }
22306
22383
  removeSignetSkillSymlinks(skillsDir, signetWorkspace) {
22307
22384
  const signetSkillsSource = resolve2(signetWorkspace, "skills");
@@ -22322,7 +22399,7 @@ class GeminiConnector extends BaseConnector {
22322
22399
  if (stat?.isSymbolicLink()) {
22323
22400
  try {
22324
22401
  const rawTarget = readlinkSync(entryPath);
22325
- const target = resolve2(dirname7(entryPath), rawTarget);
22402
+ const target = resolve2(dirname8(entryPath), rawTarget);
22326
22403
  if (isChildOf(target, signetSkillsSource)) {
22327
22404
  unlinkSync3(entryPath);
22328
22405
  }
@@ -22390,8 +22467,8 @@ class GeminiConnector extends BaseConnector {
22390
22467
  const header = this.generateHeader(sourcePath);
22391
22468
  const extras = this.composeIdentityExtras(basePath);
22392
22469
  const destPath = this.getGeminiMdPath();
22393
- mkdirSync(dirname7(destPath), { recursive: true });
22394
- writeFileSync2(destPath, header + userContent + extras);
22470
+ mkdirSync(dirname8(destPath), { recursive: true });
22471
+ writeFileSync3(destPath, header + userContent + extras);
22395
22472
  return destPath;
22396
22473
  }
22397
22474
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-gemini",
3
- "version": "0.154.4",
3
+ "version": "0.154.7",
4
4
  "description": "Signet connector for Gemini CLI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "typecheck": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "@signetai/connector-base": "0.154.4",
28
- "@signetai/core": "0.154.4"
27
+ "@signetai/connector-base": "0.154.7",
28
+ "@signetai/core": "0.154.7"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.0.0",